mutation.go 1.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579
  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/contact"
  19. "wechat-api/ent/contactfield"
  20. "wechat-api/ent/contactfieldtemplate"
  21. "wechat-api/ent/creditbalance"
  22. "wechat-api/ent/creditusage"
  23. "wechat-api/ent/custom_types"
  24. "wechat-api/ent/employee"
  25. "wechat-api/ent/employeeconfig"
  26. "wechat-api/ent/label"
  27. "wechat-api/ent/labelrelationship"
  28. "wechat-api/ent/labeltagging"
  29. "wechat-api/ent/message"
  30. "wechat-api/ent/messagerecords"
  31. "wechat-api/ent/msg"
  32. "wechat-api/ent/payrecharge"
  33. "wechat-api/ent/predicate"
  34. "wechat-api/ent/server"
  35. "wechat-api/ent/sopnode"
  36. "wechat-api/ent/sopstage"
  37. "wechat-api/ent/soptask"
  38. "wechat-api/ent/token"
  39. "wechat-api/ent/tutorial"
  40. "wechat-api/ent/usagedetail"
  41. "wechat-api/ent/usagestatisticday"
  42. "wechat-api/ent/usagestatistichour"
  43. "wechat-api/ent/usagestatisticmonth"
  44. "wechat-api/ent/usagetotal"
  45. "wechat-api/ent/whatsapp"
  46. "wechat-api/ent/whatsappchannel"
  47. "wechat-api/ent/workexperience"
  48. "wechat-api/ent/wpchatroom"
  49. "wechat-api/ent/wpchatroommember"
  50. "wechat-api/ent/wx"
  51. "wechat-api/ent/wxcard"
  52. "wechat-api/ent/wxcarduser"
  53. "wechat-api/ent/wxcardvisit"
  54. "entgo.io/ent"
  55. "entgo.io/ent/dialect/sql"
  56. )
  57. const (
  58. // Operation types.
  59. OpCreate = ent.OpCreate
  60. OpDelete = ent.OpDelete
  61. OpDeleteOne = ent.OpDeleteOne
  62. OpUpdate = ent.OpUpdate
  63. OpUpdateOne = ent.OpUpdateOne
  64. // Node types.
  65. TypeAgent = "Agent"
  66. TypeAgentBase = "AgentBase"
  67. TypeAliyunAvatar = "AliyunAvatar"
  68. TypeAllocAgent = "AllocAgent"
  69. TypeApiKey = "ApiKey"
  70. TypeBatchMsg = "BatchMsg"
  71. TypeCategory = "Category"
  72. TypeChatRecords = "ChatRecords"
  73. TypeChatSession = "ChatSession"
  74. TypeContact = "Contact"
  75. TypeContactField = "ContactField"
  76. TypeContactFieldTemplate = "ContactFieldTemplate"
  77. TypeCreditBalance = "CreditBalance"
  78. TypeCreditUsage = "CreditUsage"
  79. TypeEmployee = "Employee"
  80. TypeEmployeeConfig = "EmployeeConfig"
  81. TypeLabel = "Label"
  82. TypeLabelRelationship = "LabelRelationship"
  83. TypeLabelTagging = "LabelTagging"
  84. TypeMessage = "Message"
  85. TypeMessageRecords = "MessageRecords"
  86. TypeMsg = "Msg"
  87. TypePayRecharge = "PayRecharge"
  88. TypeServer = "Server"
  89. TypeSopNode = "SopNode"
  90. TypeSopStage = "SopStage"
  91. TypeSopTask = "SopTask"
  92. TypeToken = "Token"
  93. TypeTutorial = "Tutorial"
  94. TypeUsageDetail = "UsageDetail"
  95. TypeUsageStatisticDay = "UsageStatisticDay"
  96. TypeUsageStatisticHour = "UsageStatisticHour"
  97. TypeUsageStatisticMonth = "UsageStatisticMonth"
  98. TypeUsageTotal = "UsageTotal"
  99. TypeWhatsapp = "Whatsapp"
  100. TypeWhatsappChannel = "WhatsappChannel"
  101. TypeWorkExperience = "WorkExperience"
  102. TypeWpChatroom = "WpChatroom"
  103. TypeWpChatroomMember = "WpChatroomMember"
  104. TypeWx = "Wx"
  105. TypeWxCard = "WxCard"
  106. TypeWxCardUser = "WxCardUser"
  107. TypeWxCardVisit = "WxCardVisit"
  108. )
  109. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  110. type AgentMutation struct {
  111. config
  112. op Op
  113. typ string
  114. id *uint64
  115. created_at *time.Time
  116. updated_at *time.Time
  117. deleted_at *time.Time
  118. name *string
  119. role *string
  120. status *int
  121. addstatus *int
  122. background *string
  123. examples *string
  124. organization_id *uint64
  125. addorganization_id *int64
  126. dataset_id *string
  127. collection_id *string
  128. clearedFields map[string]struct{}
  129. wx_agent map[uint64]struct{}
  130. removedwx_agent map[uint64]struct{}
  131. clearedwx_agent bool
  132. token_agent map[uint64]struct{}
  133. removedtoken_agent map[uint64]struct{}
  134. clearedtoken_agent bool
  135. wa_agent map[uint64]struct{}
  136. removedwa_agent map[uint64]struct{}
  137. clearedwa_agent bool
  138. key_agent map[uint64]struct{}
  139. removedkey_agent map[uint64]struct{}
  140. clearedkey_agent bool
  141. done bool
  142. oldValue func(context.Context) (*Agent, error)
  143. predicates []predicate.Agent
  144. }
  145. var _ ent.Mutation = (*AgentMutation)(nil)
  146. // agentOption allows management of the mutation configuration using functional options.
  147. type agentOption func(*AgentMutation)
  148. // newAgentMutation creates new mutation for the Agent entity.
  149. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  150. m := &AgentMutation{
  151. config: c,
  152. op: op,
  153. typ: TypeAgent,
  154. clearedFields: make(map[string]struct{}),
  155. }
  156. for _, opt := range opts {
  157. opt(m)
  158. }
  159. return m
  160. }
  161. // withAgentID sets the ID field of the mutation.
  162. func withAgentID(id uint64) agentOption {
  163. return func(m *AgentMutation) {
  164. var (
  165. err error
  166. once sync.Once
  167. value *Agent
  168. )
  169. m.oldValue = func(ctx context.Context) (*Agent, error) {
  170. once.Do(func() {
  171. if m.done {
  172. err = errors.New("querying old values post mutation is not allowed")
  173. } else {
  174. value, err = m.Client().Agent.Get(ctx, id)
  175. }
  176. })
  177. return value, err
  178. }
  179. m.id = &id
  180. }
  181. }
  182. // withAgent sets the old Agent of the mutation.
  183. func withAgent(node *Agent) agentOption {
  184. return func(m *AgentMutation) {
  185. m.oldValue = func(context.Context) (*Agent, error) {
  186. return node, nil
  187. }
  188. m.id = &node.ID
  189. }
  190. }
  191. // Client returns a new `ent.Client` from the mutation. If the mutation was
  192. // executed in a transaction (ent.Tx), a transactional client is returned.
  193. func (m AgentMutation) Client() *Client {
  194. client := &Client{config: m.config}
  195. client.init()
  196. return client
  197. }
  198. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  199. // it returns an error otherwise.
  200. func (m AgentMutation) Tx() (*Tx, error) {
  201. if _, ok := m.driver.(*txDriver); !ok {
  202. return nil, errors.New("ent: mutation is not running in a transaction")
  203. }
  204. tx := &Tx{config: m.config}
  205. tx.init()
  206. return tx, nil
  207. }
  208. // SetID sets the value of the id field. Note that this
  209. // operation is only accepted on creation of Agent entities.
  210. func (m *AgentMutation) SetID(id uint64) {
  211. m.id = &id
  212. }
  213. // ID returns the ID value in the mutation. Note that the ID is only available
  214. // if it was provided to the builder or after it was returned from the database.
  215. func (m *AgentMutation) ID() (id uint64, exists bool) {
  216. if m.id == nil {
  217. return
  218. }
  219. return *m.id, true
  220. }
  221. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  222. // That means, if the mutation is applied within a transaction with an isolation level such
  223. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  224. // or updated by the mutation.
  225. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  226. switch {
  227. case m.op.Is(OpUpdateOne | OpDeleteOne):
  228. id, exists := m.ID()
  229. if exists {
  230. return []uint64{id}, nil
  231. }
  232. fallthrough
  233. case m.op.Is(OpUpdate | OpDelete):
  234. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  235. default:
  236. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  237. }
  238. }
  239. // SetCreatedAt sets the "created_at" field.
  240. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  241. m.created_at = &t
  242. }
  243. // CreatedAt returns the value of the "created_at" field in the mutation.
  244. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  245. v := m.created_at
  246. if v == nil {
  247. return
  248. }
  249. return *v, true
  250. }
  251. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  252. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  253. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  254. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  255. if !m.op.Is(OpUpdateOne) {
  256. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  257. }
  258. if m.id == nil || m.oldValue == nil {
  259. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  260. }
  261. oldValue, err := m.oldValue(ctx)
  262. if err != nil {
  263. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  264. }
  265. return oldValue.CreatedAt, nil
  266. }
  267. // ResetCreatedAt resets all changes to the "created_at" field.
  268. func (m *AgentMutation) ResetCreatedAt() {
  269. m.created_at = nil
  270. }
  271. // SetUpdatedAt sets the "updated_at" field.
  272. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  273. m.updated_at = &t
  274. }
  275. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  276. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  277. v := m.updated_at
  278. if v == nil {
  279. return
  280. }
  281. return *v, true
  282. }
  283. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  284. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  285. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  286. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  287. if !m.op.Is(OpUpdateOne) {
  288. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  289. }
  290. if m.id == nil || m.oldValue == nil {
  291. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  292. }
  293. oldValue, err := m.oldValue(ctx)
  294. if err != nil {
  295. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  296. }
  297. return oldValue.UpdatedAt, nil
  298. }
  299. // ResetUpdatedAt resets all changes to the "updated_at" field.
  300. func (m *AgentMutation) ResetUpdatedAt() {
  301. m.updated_at = nil
  302. }
  303. // SetDeletedAt sets the "deleted_at" field.
  304. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  305. m.deleted_at = &t
  306. }
  307. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  308. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  309. v := m.deleted_at
  310. if v == nil {
  311. return
  312. }
  313. return *v, true
  314. }
  315. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  316. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  317. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  318. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  319. if !m.op.Is(OpUpdateOne) {
  320. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  321. }
  322. if m.id == nil || m.oldValue == nil {
  323. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  324. }
  325. oldValue, err := m.oldValue(ctx)
  326. if err != nil {
  327. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  328. }
  329. return oldValue.DeletedAt, nil
  330. }
  331. // ClearDeletedAt clears the value of the "deleted_at" field.
  332. func (m *AgentMutation) ClearDeletedAt() {
  333. m.deleted_at = nil
  334. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  335. }
  336. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  337. func (m *AgentMutation) DeletedAtCleared() bool {
  338. _, ok := m.clearedFields[agent.FieldDeletedAt]
  339. return ok
  340. }
  341. // ResetDeletedAt resets all changes to the "deleted_at" field.
  342. func (m *AgentMutation) ResetDeletedAt() {
  343. m.deleted_at = nil
  344. delete(m.clearedFields, agent.FieldDeletedAt)
  345. }
  346. // SetName sets the "name" field.
  347. func (m *AgentMutation) SetName(s string) {
  348. m.name = &s
  349. }
  350. // Name returns the value of the "name" field in the mutation.
  351. func (m *AgentMutation) Name() (r string, exists bool) {
  352. v := m.name
  353. if v == nil {
  354. return
  355. }
  356. return *v, true
  357. }
  358. // OldName returns the old "name" field's value of the Agent entity.
  359. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  360. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  361. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  362. if !m.op.Is(OpUpdateOne) {
  363. return v, errors.New("OldName is only allowed on UpdateOne operations")
  364. }
  365. if m.id == nil || m.oldValue == nil {
  366. return v, errors.New("OldName requires an ID field in the mutation")
  367. }
  368. oldValue, err := m.oldValue(ctx)
  369. if err != nil {
  370. return v, fmt.Errorf("querying old value for OldName: %w", err)
  371. }
  372. return oldValue.Name, nil
  373. }
  374. // ResetName resets all changes to the "name" field.
  375. func (m *AgentMutation) ResetName() {
  376. m.name = nil
  377. }
  378. // SetRole sets the "role" field.
  379. func (m *AgentMutation) SetRole(s string) {
  380. m.role = &s
  381. }
  382. // Role returns the value of the "role" field in the mutation.
  383. func (m *AgentMutation) Role() (r string, exists bool) {
  384. v := m.role
  385. if v == nil {
  386. return
  387. }
  388. return *v, true
  389. }
  390. // OldRole returns the old "role" field's value of the Agent entity.
  391. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  392. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  393. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  394. if !m.op.Is(OpUpdateOne) {
  395. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  396. }
  397. if m.id == nil || m.oldValue == nil {
  398. return v, errors.New("OldRole requires an ID field in the mutation")
  399. }
  400. oldValue, err := m.oldValue(ctx)
  401. if err != nil {
  402. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  403. }
  404. return oldValue.Role, nil
  405. }
  406. // ResetRole resets all changes to the "role" field.
  407. func (m *AgentMutation) ResetRole() {
  408. m.role = nil
  409. }
  410. // SetStatus sets the "status" field.
  411. func (m *AgentMutation) SetStatus(i int) {
  412. m.status = &i
  413. m.addstatus = nil
  414. }
  415. // Status returns the value of the "status" field in the mutation.
  416. func (m *AgentMutation) Status() (r int, exists bool) {
  417. v := m.status
  418. if v == nil {
  419. return
  420. }
  421. return *v, true
  422. }
  423. // OldStatus returns the old "status" field's value of the Agent entity.
  424. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  425. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  426. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  427. if !m.op.Is(OpUpdateOne) {
  428. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  429. }
  430. if m.id == nil || m.oldValue == nil {
  431. return v, errors.New("OldStatus requires an ID field in the mutation")
  432. }
  433. oldValue, err := m.oldValue(ctx)
  434. if err != nil {
  435. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  436. }
  437. return oldValue.Status, nil
  438. }
  439. // AddStatus adds i to the "status" field.
  440. func (m *AgentMutation) AddStatus(i int) {
  441. if m.addstatus != nil {
  442. *m.addstatus += i
  443. } else {
  444. m.addstatus = &i
  445. }
  446. }
  447. // AddedStatus returns the value that was added to the "status" field in this mutation.
  448. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  449. v := m.addstatus
  450. if v == nil {
  451. return
  452. }
  453. return *v, true
  454. }
  455. // ClearStatus clears the value of the "status" field.
  456. func (m *AgentMutation) ClearStatus() {
  457. m.status = nil
  458. m.addstatus = nil
  459. m.clearedFields[agent.FieldStatus] = struct{}{}
  460. }
  461. // StatusCleared returns if the "status" field was cleared in this mutation.
  462. func (m *AgentMutation) StatusCleared() bool {
  463. _, ok := m.clearedFields[agent.FieldStatus]
  464. return ok
  465. }
  466. // ResetStatus resets all changes to the "status" field.
  467. func (m *AgentMutation) ResetStatus() {
  468. m.status = nil
  469. m.addstatus = nil
  470. delete(m.clearedFields, agent.FieldStatus)
  471. }
  472. // SetBackground sets the "background" field.
  473. func (m *AgentMutation) SetBackground(s string) {
  474. m.background = &s
  475. }
  476. // Background returns the value of the "background" field in the mutation.
  477. func (m *AgentMutation) Background() (r string, exists bool) {
  478. v := m.background
  479. if v == nil {
  480. return
  481. }
  482. return *v, true
  483. }
  484. // OldBackground returns the old "background" field's value of the Agent entity.
  485. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  486. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  487. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  488. if !m.op.Is(OpUpdateOne) {
  489. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  490. }
  491. if m.id == nil || m.oldValue == nil {
  492. return v, errors.New("OldBackground requires an ID field in the mutation")
  493. }
  494. oldValue, err := m.oldValue(ctx)
  495. if err != nil {
  496. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  497. }
  498. return oldValue.Background, nil
  499. }
  500. // ClearBackground clears the value of the "background" field.
  501. func (m *AgentMutation) ClearBackground() {
  502. m.background = nil
  503. m.clearedFields[agent.FieldBackground] = struct{}{}
  504. }
  505. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  506. func (m *AgentMutation) BackgroundCleared() bool {
  507. _, ok := m.clearedFields[agent.FieldBackground]
  508. return ok
  509. }
  510. // ResetBackground resets all changes to the "background" field.
  511. func (m *AgentMutation) ResetBackground() {
  512. m.background = nil
  513. delete(m.clearedFields, agent.FieldBackground)
  514. }
  515. // SetExamples sets the "examples" field.
  516. func (m *AgentMutation) SetExamples(s string) {
  517. m.examples = &s
  518. }
  519. // Examples returns the value of the "examples" field in the mutation.
  520. func (m *AgentMutation) Examples() (r string, exists bool) {
  521. v := m.examples
  522. if v == nil {
  523. return
  524. }
  525. return *v, true
  526. }
  527. // OldExamples returns the old "examples" field's value of the Agent entity.
  528. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  529. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  530. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  531. if !m.op.Is(OpUpdateOne) {
  532. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  533. }
  534. if m.id == nil || m.oldValue == nil {
  535. return v, errors.New("OldExamples requires an ID field in the mutation")
  536. }
  537. oldValue, err := m.oldValue(ctx)
  538. if err != nil {
  539. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  540. }
  541. return oldValue.Examples, nil
  542. }
  543. // ClearExamples clears the value of the "examples" field.
  544. func (m *AgentMutation) ClearExamples() {
  545. m.examples = nil
  546. m.clearedFields[agent.FieldExamples] = struct{}{}
  547. }
  548. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  549. func (m *AgentMutation) ExamplesCleared() bool {
  550. _, ok := m.clearedFields[agent.FieldExamples]
  551. return ok
  552. }
  553. // ResetExamples resets all changes to the "examples" field.
  554. func (m *AgentMutation) ResetExamples() {
  555. m.examples = nil
  556. delete(m.clearedFields, agent.FieldExamples)
  557. }
  558. // SetOrganizationID sets the "organization_id" field.
  559. func (m *AgentMutation) SetOrganizationID(u uint64) {
  560. m.organization_id = &u
  561. m.addorganization_id = nil
  562. }
  563. // OrganizationID returns the value of the "organization_id" field in the mutation.
  564. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  565. v := m.organization_id
  566. if v == nil {
  567. return
  568. }
  569. return *v, true
  570. }
  571. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  572. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  573. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  574. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  575. if !m.op.Is(OpUpdateOne) {
  576. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  577. }
  578. if m.id == nil || m.oldValue == nil {
  579. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  580. }
  581. oldValue, err := m.oldValue(ctx)
  582. if err != nil {
  583. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  584. }
  585. return oldValue.OrganizationID, nil
  586. }
  587. // AddOrganizationID adds u to the "organization_id" field.
  588. func (m *AgentMutation) AddOrganizationID(u int64) {
  589. if m.addorganization_id != nil {
  590. *m.addorganization_id += u
  591. } else {
  592. m.addorganization_id = &u
  593. }
  594. }
  595. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  596. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  597. v := m.addorganization_id
  598. if v == nil {
  599. return
  600. }
  601. return *v, true
  602. }
  603. // ResetOrganizationID resets all changes to the "organization_id" field.
  604. func (m *AgentMutation) ResetOrganizationID() {
  605. m.organization_id = nil
  606. m.addorganization_id = nil
  607. }
  608. // SetDatasetID sets the "dataset_id" field.
  609. func (m *AgentMutation) SetDatasetID(s string) {
  610. m.dataset_id = &s
  611. }
  612. // DatasetID returns the value of the "dataset_id" field in the mutation.
  613. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  614. v := m.dataset_id
  615. if v == nil {
  616. return
  617. }
  618. return *v, true
  619. }
  620. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  621. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  622. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  623. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  624. if !m.op.Is(OpUpdateOne) {
  625. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  626. }
  627. if m.id == nil || m.oldValue == nil {
  628. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  629. }
  630. oldValue, err := m.oldValue(ctx)
  631. if err != nil {
  632. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  633. }
  634. return oldValue.DatasetID, nil
  635. }
  636. // ResetDatasetID resets all changes to the "dataset_id" field.
  637. func (m *AgentMutation) ResetDatasetID() {
  638. m.dataset_id = nil
  639. }
  640. // SetCollectionID sets the "collection_id" field.
  641. func (m *AgentMutation) SetCollectionID(s string) {
  642. m.collection_id = &s
  643. }
  644. // CollectionID returns the value of the "collection_id" field in the mutation.
  645. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  646. v := m.collection_id
  647. if v == nil {
  648. return
  649. }
  650. return *v, true
  651. }
  652. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  653. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  654. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  655. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  656. if !m.op.Is(OpUpdateOne) {
  657. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  658. }
  659. if m.id == nil || m.oldValue == nil {
  660. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  661. }
  662. oldValue, err := m.oldValue(ctx)
  663. if err != nil {
  664. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  665. }
  666. return oldValue.CollectionID, nil
  667. }
  668. // ResetCollectionID resets all changes to the "collection_id" field.
  669. func (m *AgentMutation) ResetCollectionID() {
  670. m.collection_id = nil
  671. }
  672. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  673. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  674. if m.wx_agent == nil {
  675. m.wx_agent = make(map[uint64]struct{})
  676. }
  677. for i := range ids {
  678. m.wx_agent[ids[i]] = struct{}{}
  679. }
  680. }
  681. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  682. func (m *AgentMutation) ClearWxAgent() {
  683. m.clearedwx_agent = true
  684. }
  685. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  686. func (m *AgentMutation) WxAgentCleared() bool {
  687. return m.clearedwx_agent
  688. }
  689. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  690. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  691. if m.removedwx_agent == nil {
  692. m.removedwx_agent = make(map[uint64]struct{})
  693. }
  694. for i := range ids {
  695. delete(m.wx_agent, ids[i])
  696. m.removedwx_agent[ids[i]] = struct{}{}
  697. }
  698. }
  699. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  700. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  701. for id := range m.removedwx_agent {
  702. ids = append(ids, id)
  703. }
  704. return
  705. }
  706. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  707. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  708. for id := range m.wx_agent {
  709. ids = append(ids, id)
  710. }
  711. return
  712. }
  713. // ResetWxAgent resets all changes to the "wx_agent" edge.
  714. func (m *AgentMutation) ResetWxAgent() {
  715. m.wx_agent = nil
  716. m.clearedwx_agent = false
  717. m.removedwx_agent = nil
  718. }
  719. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  720. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  721. if m.token_agent == nil {
  722. m.token_agent = make(map[uint64]struct{})
  723. }
  724. for i := range ids {
  725. m.token_agent[ids[i]] = struct{}{}
  726. }
  727. }
  728. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  729. func (m *AgentMutation) ClearTokenAgent() {
  730. m.clearedtoken_agent = true
  731. }
  732. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  733. func (m *AgentMutation) TokenAgentCleared() bool {
  734. return m.clearedtoken_agent
  735. }
  736. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  737. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  738. if m.removedtoken_agent == nil {
  739. m.removedtoken_agent = make(map[uint64]struct{})
  740. }
  741. for i := range ids {
  742. delete(m.token_agent, ids[i])
  743. m.removedtoken_agent[ids[i]] = struct{}{}
  744. }
  745. }
  746. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  747. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  748. for id := range m.removedtoken_agent {
  749. ids = append(ids, id)
  750. }
  751. return
  752. }
  753. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  754. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  755. for id := range m.token_agent {
  756. ids = append(ids, id)
  757. }
  758. return
  759. }
  760. // ResetTokenAgent resets all changes to the "token_agent" edge.
  761. func (m *AgentMutation) ResetTokenAgent() {
  762. m.token_agent = nil
  763. m.clearedtoken_agent = false
  764. m.removedtoken_agent = nil
  765. }
  766. // AddWaAgentIDs adds the "wa_agent" edge to the Whatsapp entity by ids.
  767. func (m *AgentMutation) AddWaAgentIDs(ids ...uint64) {
  768. if m.wa_agent == nil {
  769. m.wa_agent = make(map[uint64]struct{})
  770. }
  771. for i := range ids {
  772. m.wa_agent[ids[i]] = struct{}{}
  773. }
  774. }
  775. // ClearWaAgent clears the "wa_agent" edge to the Whatsapp entity.
  776. func (m *AgentMutation) ClearWaAgent() {
  777. m.clearedwa_agent = true
  778. }
  779. // WaAgentCleared reports if the "wa_agent" edge to the Whatsapp entity was cleared.
  780. func (m *AgentMutation) WaAgentCleared() bool {
  781. return m.clearedwa_agent
  782. }
  783. // RemoveWaAgentIDs removes the "wa_agent" edge to the Whatsapp entity by IDs.
  784. func (m *AgentMutation) RemoveWaAgentIDs(ids ...uint64) {
  785. if m.removedwa_agent == nil {
  786. m.removedwa_agent = make(map[uint64]struct{})
  787. }
  788. for i := range ids {
  789. delete(m.wa_agent, ids[i])
  790. m.removedwa_agent[ids[i]] = struct{}{}
  791. }
  792. }
  793. // RemovedWaAgent returns the removed IDs of the "wa_agent" edge to the Whatsapp entity.
  794. func (m *AgentMutation) RemovedWaAgentIDs() (ids []uint64) {
  795. for id := range m.removedwa_agent {
  796. ids = append(ids, id)
  797. }
  798. return
  799. }
  800. // WaAgentIDs returns the "wa_agent" edge IDs in the mutation.
  801. func (m *AgentMutation) WaAgentIDs() (ids []uint64) {
  802. for id := range m.wa_agent {
  803. ids = append(ids, id)
  804. }
  805. return
  806. }
  807. // ResetWaAgent resets all changes to the "wa_agent" edge.
  808. func (m *AgentMutation) ResetWaAgent() {
  809. m.wa_agent = nil
  810. m.clearedwa_agent = false
  811. m.removedwa_agent = nil
  812. }
  813. // AddKeyAgentIDs adds the "key_agent" edge to the ApiKey entity by ids.
  814. func (m *AgentMutation) AddKeyAgentIDs(ids ...uint64) {
  815. if m.key_agent == nil {
  816. m.key_agent = make(map[uint64]struct{})
  817. }
  818. for i := range ids {
  819. m.key_agent[ids[i]] = struct{}{}
  820. }
  821. }
  822. // ClearKeyAgent clears the "key_agent" edge to the ApiKey entity.
  823. func (m *AgentMutation) ClearKeyAgent() {
  824. m.clearedkey_agent = true
  825. }
  826. // KeyAgentCleared reports if the "key_agent" edge to the ApiKey entity was cleared.
  827. func (m *AgentMutation) KeyAgentCleared() bool {
  828. return m.clearedkey_agent
  829. }
  830. // RemoveKeyAgentIDs removes the "key_agent" edge to the ApiKey entity by IDs.
  831. func (m *AgentMutation) RemoveKeyAgentIDs(ids ...uint64) {
  832. if m.removedkey_agent == nil {
  833. m.removedkey_agent = make(map[uint64]struct{})
  834. }
  835. for i := range ids {
  836. delete(m.key_agent, ids[i])
  837. m.removedkey_agent[ids[i]] = struct{}{}
  838. }
  839. }
  840. // RemovedKeyAgent returns the removed IDs of the "key_agent" edge to the ApiKey entity.
  841. func (m *AgentMutation) RemovedKeyAgentIDs() (ids []uint64) {
  842. for id := range m.removedkey_agent {
  843. ids = append(ids, id)
  844. }
  845. return
  846. }
  847. // KeyAgentIDs returns the "key_agent" edge IDs in the mutation.
  848. func (m *AgentMutation) KeyAgentIDs() (ids []uint64) {
  849. for id := range m.key_agent {
  850. ids = append(ids, id)
  851. }
  852. return
  853. }
  854. // ResetKeyAgent resets all changes to the "key_agent" edge.
  855. func (m *AgentMutation) ResetKeyAgent() {
  856. m.key_agent = nil
  857. m.clearedkey_agent = false
  858. m.removedkey_agent = nil
  859. }
  860. // Where appends a list predicates to the AgentMutation builder.
  861. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  862. m.predicates = append(m.predicates, ps...)
  863. }
  864. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  865. // users can use type-assertion to append predicates that do not depend on any generated package.
  866. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  867. p := make([]predicate.Agent, len(ps))
  868. for i := range ps {
  869. p[i] = ps[i]
  870. }
  871. m.Where(p...)
  872. }
  873. // Op returns the operation name.
  874. func (m *AgentMutation) Op() Op {
  875. return m.op
  876. }
  877. // SetOp allows setting the mutation operation.
  878. func (m *AgentMutation) SetOp(op Op) {
  879. m.op = op
  880. }
  881. // Type returns the node type of this mutation (Agent).
  882. func (m *AgentMutation) Type() string {
  883. return m.typ
  884. }
  885. // Fields returns all fields that were changed during this mutation. Note that in
  886. // order to get all numeric fields that were incremented/decremented, call
  887. // AddedFields().
  888. func (m *AgentMutation) Fields() []string {
  889. fields := make([]string, 0, 11)
  890. if m.created_at != nil {
  891. fields = append(fields, agent.FieldCreatedAt)
  892. }
  893. if m.updated_at != nil {
  894. fields = append(fields, agent.FieldUpdatedAt)
  895. }
  896. if m.deleted_at != nil {
  897. fields = append(fields, agent.FieldDeletedAt)
  898. }
  899. if m.name != nil {
  900. fields = append(fields, agent.FieldName)
  901. }
  902. if m.role != nil {
  903. fields = append(fields, agent.FieldRole)
  904. }
  905. if m.status != nil {
  906. fields = append(fields, agent.FieldStatus)
  907. }
  908. if m.background != nil {
  909. fields = append(fields, agent.FieldBackground)
  910. }
  911. if m.examples != nil {
  912. fields = append(fields, agent.FieldExamples)
  913. }
  914. if m.organization_id != nil {
  915. fields = append(fields, agent.FieldOrganizationID)
  916. }
  917. if m.dataset_id != nil {
  918. fields = append(fields, agent.FieldDatasetID)
  919. }
  920. if m.collection_id != nil {
  921. fields = append(fields, agent.FieldCollectionID)
  922. }
  923. return fields
  924. }
  925. // Field returns the value of a field with the given name. The second boolean
  926. // return value indicates that this field was not set, or was not defined in the
  927. // schema.
  928. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  929. switch name {
  930. case agent.FieldCreatedAt:
  931. return m.CreatedAt()
  932. case agent.FieldUpdatedAt:
  933. return m.UpdatedAt()
  934. case agent.FieldDeletedAt:
  935. return m.DeletedAt()
  936. case agent.FieldName:
  937. return m.Name()
  938. case agent.FieldRole:
  939. return m.Role()
  940. case agent.FieldStatus:
  941. return m.Status()
  942. case agent.FieldBackground:
  943. return m.Background()
  944. case agent.FieldExamples:
  945. return m.Examples()
  946. case agent.FieldOrganizationID:
  947. return m.OrganizationID()
  948. case agent.FieldDatasetID:
  949. return m.DatasetID()
  950. case agent.FieldCollectionID:
  951. return m.CollectionID()
  952. }
  953. return nil, false
  954. }
  955. // OldField returns the old value of the field from the database. An error is
  956. // returned if the mutation operation is not UpdateOne, or the query to the
  957. // database failed.
  958. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  959. switch name {
  960. case agent.FieldCreatedAt:
  961. return m.OldCreatedAt(ctx)
  962. case agent.FieldUpdatedAt:
  963. return m.OldUpdatedAt(ctx)
  964. case agent.FieldDeletedAt:
  965. return m.OldDeletedAt(ctx)
  966. case agent.FieldName:
  967. return m.OldName(ctx)
  968. case agent.FieldRole:
  969. return m.OldRole(ctx)
  970. case agent.FieldStatus:
  971. return m.OldStatus(ctx)
  972. case agent.FieldBackground:
  973. return m.OldBackground(ctx)
  974. case agent.FieldExamples:
  975. return m.OldExamples(ctx)
  976. case agent.FieldOrganizationID:
  977. return m.OldOrganizationID(ctx)
  978. case agent.FieldDatasetID:
  979. return m.OldDatasetID(ctx)
  980. case agent.FieldCollectionID:
  981. return m.OldCollectionID(ctx)
  982. }
  983. return nil, fmt.Errorf("unknown Agent field %s", name)
  984. }
  985. // SetField sets the value of a field with the given name. It returns an error if
  986. // the field is not defined in the schema, or if the type mismatched the field
  987. // type.
  988. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  989. switch name {
  990. case agent.FieldCreatedAt:
  991. v, ok := value.(time.Time)
  992. if !ok {
  993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  994. }
  995. m.SetCreatedAt(v)
  996. return nil
  997. case agent.FieldUpdatedAt:
  998. v, ok := value.(time.Time)
  999. if !ok {
  1000. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1001. }
  1002. m.SetUpdatedAt(v)
  1003. return nil
  1004. case agent.FieldDeletedAt:
  1005. v, ok := value.(time.Time)
  1006. if !ok {
  1007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1008. }
  1009. m.SetDeletedAt(v)
  1010. return nil
  1011. case agent.FieldName:
  1012. v, ok := value.(string)
  1013. if !ok {
  1014. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1015. }
  1016. m.SetName(v)
  1017. return nil
  1018. case agent.FieldRole:
  1019. v, ok := value.(string)
  1020. if !ok {
  1021. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1022. }
  1023. m.SetRole(v)
  1024. return nil
  1025. case agent.FieldStatus:
  1026. v, ok := value.(int)
  1027. if !ok {
  1028. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1029. }
  1030. m.SetStatus(v)
  1031. return nil
  1032. case agent.FieldBackground:
  1033. v, ok := value.(string)
  1034. if !ok {
  1035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1036. }
  1037. m.SetBackground(v)
  1038. return nil
  1039. case agent.FieldExamples:
  1040. v, ok := value.(string)
  1041. if !ok {
  1042. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1043. }
  1044. m.SetExamples(v)
  1045. return nil
  1046. case agent.FieldOrganizationID:
  1047. v, ok := value.(uint64)
  1048. if !ok {
  1049. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1050. }
  1051. m.SetOrganizationID(v)
  1052. return nil
  1053. case agent.FieldDatasetID:
  1054. v, ok := value.(string)
  1055. if !ok {
  1056. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1057. }
  1058. m.SetDatasetID(v)
  1059. return nil
  1060. case agent.FieldCollectionID:
  1061. v, ok := value.(string)
  1062. if !ok {
  1063. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1064. }
  1065. m.SetCollectionID(v)
  1066. return nil
  1067. }
  1068. return fmt.Errorf("unknown Agent field %s", name)
  1069. }
  1070. // AddedFields returns all numeric fields that were incremented/decremented during
  1071. // this mutation.
  1072. func (m *AgentMutation) AddedFields() []string {
  1073. var fields []string
  1074. if m.addstatus != nil {
  1075. fields = append(fields, agent.FieldStatus)
  1076. }
  1077. if m.addorganization_id != nil {
  1078. fields = append(fields, agent.FieldOrganizationID)
  1079. }
  1080. return fields
  1081. }
  1082. // AddedField returns the numeric value that was incremented/decremented on a field
  1083. // with the given name. The second boolean return value indicates that this field
  1084. // was not set, or was not defined in the schema.
  1085. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  1086. switch name {
  1087. case agent.FieldStatus:
  1088. return m.AddedStatus()
  1089. case agent.FieldOrganizationID:
  1090. return m.AddedOrganizationID()
  1091. }
  1092. return nil, false
  1093. }
  1094. // AddField adds the value to the field with the given name. It returns an error if
  1095. // the field is not defined in the schema, or if the type mismatched the field
  1096. // type.
  1097. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  1098. switch name {
  1099. case agent.FieldStatus:
  1100. v, ok := value.(int)
  1101. if !ok {
  1102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1103. }
  1104. m.AddStatus(v)
  1105. return nil
  1106. case agent.FieldOrganizationID:
  1107. v, ok := value.(int64)
  1108. if !ok {
  1109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1110. }
  1111. m.AddOrganizationID(v)
  1112. return nil
  1113. }
  1114. return fmt.Errorf("unknown Agent numeric field %s", name)
  1115. }
  1116. // ClearedFields returns all nullable fields that were cleared during this
  1117. // mutation.
  1118. func (m *AgentMutation) ClearedFields() []string {
  1119. var fields []string
  1120. if m.FieldCleared(agent.FieldDeletedAt) {
  1121. fields = append(fields, agent.FieldDeletedAt)
  1122. }
  1123. if m.FieldCleared(agent.FieldStatus) {
  1124. fields = append(fields, agent.FieldStatus)
  1125. }
  1126. if m.FieldCleared(agent.FieldBackground) {
  1127. fields = append(fields, agent.FieldBackground)
  1128. }
  1129. if m.FieldCleared(agent.FieldExamples) {
  1130. fields = append(fields, agent.FieldExamples)
  1131. }
  1132. return fields
  1133. }
  1134. // FieldCleared returns a boolean indicating if a field with the given name was
  1135. // cleared in this mutation.
  1136. func (m *AgentMutation) FieldCleared(name string) bool {
  1137. _, ok := m.clearedFields[name]
  1138. return ok
  1139. }
  1140. // ClearField clears the value of the field with the given name. It returns an
  1141. // error if the field is not defined in the schema.
  1142. func (m *AgentMutation) ClearField(name string) error {
  1143. switch name {
  1144. case agent.FieldDeletedAt:
  1145. m.ClearDeletedAt()
  1146. return nil
  1147. case agent.FieldStatus:
  1148. m.ClearStatus()
  1149. return nil
  1150. case agent.FieldBackground:
  1151. m.ClearBackground()
  1152. return nil
  1153. case agent.FieldExamples:
  1154. m.ClearExamples()
  1155. return nil
  1156. }
  1157. return fmt.Errorf("unknown Agent nullable field %s", name)
  1158. }
  1159. // ResetField resets all changes in the mutation for the field with the given name.
  1160. // It returns an error if the field is not defined in the schema.
  1161. func (m *AgentMutation) ResetField(name string) error {
  1162. switch name {
  1163. case agent.FieldCreatedAt:
  1164. m.ResetCreatedAt()
  1165. return nil
  1166. case agent.FieldUpdatedAt:
  1167. m.ResetUpdatedAt()
  1168. return nil
  1169. case agent.FieldDeletedAt:
  1170. m.ResetDeletedAt()
  1171. return nil
  1172. case agent.FieldName:
  1173. m.ResetName()
  1174. return nil
  1175. case agent.FieldRole:
  1176. m.ResetRole()
  1177. return nil
  1178. case agent.FieldStatus:
  1179. m.ResetStatus()
  1180. return nil
  1181. case agent.FieldBackground:
  1182. m.ResetBackground()
  1183. return nil
  1184. case agent.FieldExamples:
  1185. m.ResetExamples()
  1186. return nil
  1187. case agent.FieldOrganizationID:
  1188. m.ResetOrganizationID()
  1189. return nil
  1190. case agent.FieldDatasetID:
  1191. m.ResetDatasetID()
  1192. return nil
  1193. case agent.FieldCollectionID:
  1194. m.ResetCollectionID()
  1195. return nil
  1196. }
  1197. return fmt.Errorf("unknown Agent field %s", name)
  1198. }
  1199. // AddedEdges returns all edge names that were set/added in this mutation.
  1200. func (m *AgentMutation) AddedEdges() []string {
  1201. edges := make([]string, 0, 4)
  1202. if m.wx_agent != nil {
  1203. edges = append(edges, agent.EdgeWxAgent)
  1204. }
  1205. if m.token_agent != nil {
  1206. edges = append(edges, agent.EdgeTokenAgent)
  1207. }
  1208. if m.wa_agent != nil {
  1209. edges = append(edges, agent.EdgeWaAgent)
  1210. }
  1211. if m.key_agent != nil {
  1212. edges = append(edges, agent.EdgeKeyAgent)
  1213. }
  1214. return edges
  1215. }
  1216. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1217. // name in this mutation.
  1218. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1219. switch name {
  1220. case agent.EdgeWxAgent:
  1221. ids := make([]ent.Value, 0, len(m.wx_agent))
  1222. for id := range m.wx_agent {
  1223. ids = append(ids, id)
  1224. }
  1225. return ids
  1226. case agent.EdgeTokenAgent:
  1227. ids := make([]ent.Value, 0, len(m.token_agent))
  1228. for id := range m.token_agent {
  1229. ids = append(ids, id)
  1230. }
  1231. return ids
  1232. case agent.EdgeWaAgent:
  1233. ids := make([]ent.Value, 0, len(m.wa_agent))
  1234. for id := range m.wa_agent {
  1235. ids = append(ids, id)
  1236. }
  1237. return ids
  1238. case agent.EdgeKeyAgent:
  1239. ids := make([]ent.Value, 0, len(m.key_agent))
  1240. for id := range m.key_agent {
  1241. ids = append(ids, id)
  1242. }
  1243. return ids
  1244. }
  1245. return nil
  1246. }
  1247. // RemovedEdges returns all edge names that were removed in this mutation.
  1248. func (m *AgentMutation) RemovedEdges() []string {
  1249. edges := make([]string, 0, 4)
  1250. if m.removedwx_agent != nil {
  1251. edges = append(edges, agent.EdgeWxAgent)
  1252. }
  1253. if m.removedtoken_agent != nil {
  1254. edges = append(edges, agent.EdgeTokenAgent)
  1255. }
  1256. if m.removedwa_agent != nil {
  1257. edges = append(edges, agent.EdgeWaAgent)
  1258. }
  1259. if m.removedkey_agent != nil {
  1260. edges = append(edges, agent.EdgeKeyAgent)
  1261. }
  1262. return edges
  1263. }
  1264. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1265. // the given name in this mutation.
  1266. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1267. switch name {
  1268. case agent.EdgeWxAgent:
  1269. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1270. for id := range m.removedwx_agent {
  1271. ids = append(ids, id)
  1272. }
  1273. return ids
  1274. case agent.EdgeTokenAgent:
  1275. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1276. for id := range m.removedtoken_agent {
  1277. ids = append(ids, id)
  1278. }
  1279. return ids
  1280. case agent.EdgeWaAgent:
  1281. ids := make([]ent.Value, 0, len(m.removedwa_agent))
  1282. for id := range m.removedwa_agent {
  1283. ids = append(ids, id)
  1284. }
  1285. return ids
  1286. case agent.EdgeKeyAgent:
  1287. ids := make([]ent.Value, 0, len(m.removedkey_agent))
  1288. for id := range m.removedkey_agent {
  1289. ids = append(ids, id)
  1290. }
  1291. return ids
  1292. }
  1293. return nil
  1294. }
  1295. // ClearedEdges returns all edge names that were cleared in this mutation.
  1296. func (m *AgentMutation) ClearedEdges() []string {
  1297. edges := make([]string, 0, 4)
  1298. if m.clearedwx_agent {
  1299. edges = append(edges, agent.EdgeWxAgent)
  1300. }
  1301. if m.clearedtoken_agent {
  1302. edges = append(edges, agent.EdgeTokenAgent)
  1303. }
  1304. if m.clearedwa_agent {
  1305. edges = append(edges, agent.EdgeWaAgent)
  1306. }
  1307. if m.clearedkey_agent {
  1308. edges = append(edges, agent.EdgeKeyAgent)
  1309. }
  1310. return edges
  1311. }
  1312. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1313. // was cleared in this mutation.
  1314. func (m *AgentMutation) EdgeCleared(name string) bool {
  1315. switch name {
  1316. case agent.EdgeWxAgent:
  1317. return m.clearedwx_agent
  1318. case agent.EdgeTokenAgent:
  1319. return m.clearedtoken_agent
  1320. case agent.EdgeWaAgent:
  1321. return m.clearedwa_agent
  1322. case agent.EdgeKeyAgent:
  1323. return m.clearedkey_agent
  1324. }
  1325. return false
  1326. }
  1327. // ClearEdge clears the value of the edge with the given name. It returns an error
  1328. // if that edge is not defined in the schema.
  1329. func (m *AgentMutation) ClearEdge(name string) error {
  1330. switch name {
  1331. }
  1332. return fmt.Errorf("unknown Agent unique edge %s", name)
  1333. }
  1334. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1335. // It returns an error if the edge is not defined in the schema.
  1336. func (m *AgentMutation) ResetEdge(name string) error {
  1337. switch name {
  1338. case agent.EdgeWxAgent:
  1339. m.ResetWxAgent()
  1340. return nil
  1341. case agent.EdgeTokenAgent:
  1342. m.ResetTokenAgent()
  1343. return nil
  1344. case agent.EdgeWaAgent:
  1345. m.ResetWaAgent()
  1346. return nil
  1347. case agent.EdgeKeyAgent:
  1348. m.ResetKeyAgent()
  1349. return nil
  1350. }
  1351. return fmt.Errorf("unknown Agent edge %s", name)
  1352. }
  1353. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1354. type AgentBaseMutation struct {
  1355. config
  1356. op Op
  1357. typ string
  1358. id *string
  1359. q *string
  1360. a *string
  1361. chunk_index *uint64
  1362. addchunk_index *int64
  1363. indexes *[]string
  1364. appendindexes []string
  1365. dataset_id *string
  1366. collection_id *string
  1367. source_name *string
  1368. can_write *[]bool
  1369. appendcan_write []bool
  1370. is_owner *[]bool
  1371. appendis_owner []bool
  1372. clearedFields map[string]struct{}
  1373. wx_agent map[uint64]struct{}
  1374. removedwx_agent map[uint64]struct{}
  1375. clearedwx_agent bool
  1376. done bool
  1377. oldValue func(context.Context) (*AgentBase, error)
  1378. predicates []predicate.AgentBase
  1379. }
  1380. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1381. // agentbaseOption allows management of the mutation configuration using functional options.
  1382. type agentbaseOption func(*AgentBaseMutation)
  1383. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1384. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1385. m := &AgentBaseMutation{
  1386. config: c,
  1387. op: op,
  1388. typ: TypeAgentBase,
  1389. clearedFields: make(map[string]struct{}),
  1390. }
  1391. for _, opt := range opts {
  1392. opt(m)
  1393. }
  1394. return m
  1395. }
  1396. // withAgentBaseID sets the ID field of the mutation.
  1397. func withAgentBaseID(id string) agentbaseOption {
  1398. return func(m *AgentBaseMutation) {
  1399. var (
  1400. err error
  1401. once sync.Once
  1402. value *AgentBase
  1403. )
  1404. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1405. once.Do(func() {
  1406. if m.done {
  1407. err = errors.New("querying old values post mutation is not allowed")
  1408. } else {
  1409. value, err = m.Client().AgentBase.Get(ctx, id)
  1410. }
  1411. })
  1412. return value, err
  1413. }
  1414. m.id = &id
  1415. }
  1416. }
  1417. // withAgentBase sets the old AgentBase of the mutation.
  1418. func withAgentBase(node *AgentBase) agentbaseOption {
  1419. return func(m *AgentBaseMutation) {
  1420. m.oldValue = func(context.Context) (*AgentBase, error) {
  1421. return node, nil
  1422. }
  1423. m.id = &node.ID
  1424. }
  1425. }
  1426. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1427. // executed in a transaction (ent.Tx), a transactional client is returned.
  1428. func (m AgentBaseMutation) Client() *Client {
  1429. client := &Client{config: m.config}
  1430. client.init()
  1431. return client
  1432. }
  1433. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1434. // it returns an error otherwise.
  1435. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1436. if _, ok := m.driver.(*txDriver); !ok {
  1437. return nil, errors.New("ent: mutation is not running in a transaction")
  1438. }
  1439. tx := &Tx{config: m.config}
  1440. tx.init()
  1441. return tx, nil
  1442. }
  1443. // SetID sets the value of the id field. Note that this
  1444. // operation is only accepted on creation of AgentBase entities.
  1445. func (m *AgentBaseMutation) SetID(id string) {
  1446. m.id = &id
  1447. }
  1448. // ID returns the ID value in the mutation. Note that the ID is only available
  1449. // if it was provided to the builder or after it was returned from the database.
  1450. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1451. if m.id == nil {
  1452. return
  1453. }
  1454. return *m.id, true
  1455. }
  1456. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1457. // That means, if the mutation is applied within a transaction with an isolation level such
  1458. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1459. // or updated by the mutation.
  1460. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1461. switch {
  1462. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1463. id, exists := m.ID()
  1464. if exists {
  1465. return []string{id}, nil
  1466. }
  1467. fallthrough
  1468. case m.op.Is(OpUpdate | OpDelete):
  1469. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1470. default:
  1471. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1472. }
  1473. }
  1474. // SetQ sets the "q" field.
  1475. func (m *AgentBaseMutation) SetQ(s string) {
  1476. m.q = &s
  1477. }
  1478. // Q returns the value of the "q" field in the mutation.
  1479. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1480. v := m.q
  1481. if v == nil {
  1482. return
  1483. }
  1484. return *v, true
  1485. }
  1486. // OldQ returns the old "q" field's value of the AgentBase entity.
  1487. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1489. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1490. if !m.op.Is(OpUpdateOne) {
  1491. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1492. }
  1493. if m.id == nil || m.oldValue == nil {
  1494. return v, errors.New("OldQ requires an ID field in the mutation")
  1495. }
  1496. oldValue, err := m.oldValue(ctx)
  1497. if err != nil {
  1498. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1499. }
  1500. return oldValue.Q, nil
  1501. }
  1502. // ClearQ clears the value of the "q" field.
  1503. func (m *AgentBaseMutation) ClearQ() {
  1504. m.q = nil
  1505. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1506. }
  1507. // QCleared returns if the "q" field was cleared in this mutation.
  1508. func (m *AgentBaseMutation) QCleared() bool {
  1509. _, ok := m.clearedFields[agentbase.FieldQ]
  1510. return ok
  1511. }
  1512. // ResetQ resets all changes to the "q" field.
  1513. func (m *AgentBaseMutation) ResetQ() {
  1514. m.q = nil
  1515. delete(m.clearedFields, agentbase.FieldQ)
  1516. }
  1517. // SetA sets the "a" field.
  1518. func (m *AgentBaseMutation) SetA(s string) {
  1519. m.a = &s
  1520. }
  1521. // A returns the value of the "a" field in the mutation.
  1522. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1523. v := m.a
  1524. if v == nil {
  1525. return
  1526. }
  1527. return *v, true
  1528. }
  1529. // OldA returns the old "a" field's value of the AgentBase entity.
  1530. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1531. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1532. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1533. if !m.op.Is(OpUpdateOne) {
  1534. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1535. }
  1536. if m.id == nil || m.oldValue == nil {
  1537. return v, errors.New("OldA requires an ID field in the mutation")
  1538. }
  1539. oldValue, err := m.oldValue(ctx)
  1540. if err != nil {
  1541. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1542. }
  1543. return oldValue.A, nil
  1544. }
  1545. // ClearA clears the value of the "a" field.
  1546. func (m *AgentBaseMutation) ClearA() {
  1547. m.a = nil
  1548. m.clearedFields[agentbase.FieldA] = struct{}{}
  1549. }
  1550. // ACleared returns if the "a" field was cleared in this mutation.
  1551. func (m *AgentBaseMutation) ACleared() bool {
  1552. _, ok := m.clearedFields[agentbase.FieldA]
  1553. return ok
  1554. }
  1555. // ResetA resets all changes to the "a" field.
  1556. func (m *AgentBaseMutation) ResetA() {
  1557. m.a = nil
  1558. delete(m.clearedFields, agentbase.FieldA)
  1559. }
  1560. // SetChunkIndex sets the "chunk_index" field.
  1561. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1562. m.chunk_index = &u
  1563. m.addchunk_index = nil
  1564. }
  1565. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1566. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1567. v := m.chunk_index
  1568. if v == nil {
  1569. return
  1570. }
  1571. return *v, true
  1572. }
  1573. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1574. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1575. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1576. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1577. if !m.op.Is(OpUpdateOne) {
  1578. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1579. }
  1580. if m.id == nil || m.oldValue == nil {
  1581. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1582. }
  1583. oldValue, err := m.oldValue(ctx)
  1584. if err != nil {
  1585. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1586. }
  1587. return oldValue.ChunkIndex, nil
  1588. }
  1589. // AddChunkIndex adds u to the "chunk_index" field.
  1590. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1591. if m.addchunk_index != nil {
  1592. *m.addchunk_index += u
  1593. } else {
  1594. m.addchunk_index = &u
  1595. }
  1596. }
  1597. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1598. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1599. v := m.addchunk_index
  1600. if v == nil {
  1601. return
  1602. }
  1603. return *v, true
  1604. }
  1605. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1606. func (m *AgentBaseMutation) ResetChunkIndex() {
  1607. m.chunk_index = nil
  1608. m.addchunk_index = nil
  1609. }
  1610. // SetIndexes sets the "indexes" field.
  1611. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1612. m.indexes = &s
  1613. m.appendindexes = nil
  1614. }
  1615. // Indexes returns the value of the "indexes" field in the mutation.
  1616. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1617. v := m.indexes
  1618. if v == nil {
  1619. return
  1620. }
  1621. return *v, true
  1622. }
  1623. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1624. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1626. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1627. if !m.op.Is(OpUpdateOne) {
  1628. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1629. }
  1630. if m.id == nil || m.oldValue == nil {
  1631. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1632. }
  1633. oldValue, err := m.oldValue(ctx)
  1634. if err != nil {
  1635. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1636. }
  1637. return oldValue.Indexes, nil
  1638. }
  1639. // AppendIndexes adds s to the "indexes" field.
  1640. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1641. m.appendindexes = append(m.appendindexes, s...)
  1642. }
  1643. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1644. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1645. if len(m.appendindexes) == 0 {
  1646. return nil, false
  1647. }
  1648. return m.appendindexes, true
  1649. }
  1650. // ClearIndexes clears the value of the "indexes" field.
  1651. func (m *AgentBaseMutation) ClearIndexes() {
  1652. m.indexes = nil
  1653. m.appendindexes = nil
  1654. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1655. }
  1656. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1657. func (m *AgentBaseMutation) IndexesCleared() bool {
  1658. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1659. return ok
  1660. }
  1661. // ResetIndexes resets all changes to the "indexes" field.
  1662. func (m *AgentBaseMutation) ResetIndexes() {
  1663. m.indexes = nil
  1664. m.appendindexes = nil
  1665. delete(m.clearedFields, agentbase.FieldIndexes)
  1666. }
  1667. // SetDatasetID sets the "dataset_id" field.
  1668. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1669. m.dataset_id = &s
  1670. }
  1671. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1672. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1673. v := m.dataset_id
  1674. if v == nil {
  1675. return
  1676. }
  1677. return *v, true
  1678. }
  1679. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1680. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1681. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1682. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1683. if !m.op.Is(OpUpdateOne) {
  1684. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1685. }
  1686. if m.id == nil || m.oldValue == nil {
  1687. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1688. }
  1689. oldValue, err := m.oldValue(ctx)
  1690. if err != nil {
  1691. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1692. }
  1693. return oldValue.DatasetID, nil
  1694. }
  1695. // ClearDatasetID clears the value of the "dataset_id" field.
  1696. func (m *AgentBaseMutation) ClearDatasetID() {
  1697. m.dataset_id = nil
  1698. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  1699. }
  1700. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  1701. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  1702. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  1703. return ok
  1704. }
  1705. // ResetDatasetID resets all changes to the "dataset_id" field.
  1706. func (m *AgentBaseMutation) ResetDatasetID() {
  1707. m.dataset_id = nil
  1708. delete(m.clearedFields, agentbase.FieldDatasetID)
  1709. }
  1710. // SetCollectionID sets the "collection_id" field.
  1711. func (m *AgentBaseMutation) SetCollectionID(s string) {
  1712. m.collection_id = &s
  1713. }
  1714. // CollectionID returns the value of the "collection_id" field in the mutation.
  1715. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  1716. v := m.collection_id
  1717. if v == nil {
  1718. return
  1719. }
  1720. return *v, true
  1721. }
  1722. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  1723. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1724. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1725. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1726. if !m.op.Is(OpUpdateOne) {
  1727. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1728. }
  1729. if m.id == nil || m.oldValue == nil {
  1730. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1731. }
  1732. oldValue, err := m.oldValue(ctx)
  1733. if err != nil {
  1734. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1735. }
  1736. return oldValue.CollectionID, nil
  1737. }
  1738. // ClearCollectionID clears the value of the "collection_id" field.
  1739. func (m *AgentBaseMutation) ClearCollectionID() {
  1740. m.collection_id = nil
  1741. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  1742. }
  1743. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  1744. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  1745. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  1746. return ok
  1747. }
  1748. // ResetCollectionID resets all changes to the "collection_id" field.
  1749. func (m *AgentBaseMutation) ResetCollectionID() {
  1750. m.collection_id = nil
  1751. delete(m.clearedFields, agentbase.FieldCollectionID)
  1752. }
  1753. // SetSourceName sets the "source_name" field.
  1754. func (m *AgentBaseMutation) SetSourceName(s string) {
  1755. m.source_name = &s
  1756. }
  1757. // SourceName returns the value of the "source_name" field in the mutation.
  1758. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  1759. v := m.source_name
  1760. if v == nil {
  1761. return
  1762. }
  1763. return *v, true
  1764. }
  1765. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  1766. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1767. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1768. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  1769. if !m.op.Is(OpUpdateOne) {
  1770. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  1771. }
  1772. if m.id == nil || m.oldValue == nil {
  1773. return v, errors.New("OldSourceName requires an ID field in the mutation")
  1774. }
  1775. oldValue, err := m.oldValue(ctx)
  1776. if err != nil {
  1777. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  1778. }
  1779. return oldValue.SourceName, nil
  1780. }
  1781. // ClearSourceName clears the value of the "source_name" field.
  1782. func (m *AgentBaseMutation) ClearSourceName() {
  1783. m.source_name = nil
  1784. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  1785. }
  1786. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  1787. func (m *AgentBaseMutation) SourceNameCleared() bool {
  1788. _, ok := m.clearedFields[agentbase.FieldSourceName]
  1789. return ok
  1790. }
  1791. // ResetSourceName resets all changes to the "source_name" field.
  1792. func (m *AgentBaseMutation) ResetSourceName() {
  1793. m.source_name = nil
  1794. delete(m.clearedFields, agentbase.FieldSourceName)
  1795. }
  1796. // SetCanWrite sets the "can_write" field.
  1797. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  1798. m.can_write = &b
  1799. m.appendcan_write = nil
  1800. }
  1801. // CanWrite returns the value of the "can_write" field in the mutation.
  1802. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  1803. v := m.can_write
  1804. if v == nil {
  1805. return
  1806. }
  1807. return *v, true
  1808. }
  1809. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  1810. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1811. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1812. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  1813. if !m.op.Is(OpUpdateOne) {
  1814. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  1815. }
  1816. if m.id == nil || m.oldValue == nil {
  1817. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  1818. }
  1819. oldValue, err := m.oldValue(ctx)
  1820. if err != nil {
  1821. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  1822. }
  1823. return oldValue.CanWrite, nil
  1824. }
  1825. // AppendCanWrite adds b to the "can_write" field.
  1826. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  1827. m.appendcan_write = append(m.appendcan_write, b...)
  1828. }
  1829. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  1830. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  1831. if len(m.appendcan_write) == 0 {
  1832. return nil, false
  1833. }
  1834. return m.appendcan_write, true
  1835. }
  1836. // ClearCanWrite clears the value of the "can_write" field.
  1837. func (m *AgentBaseMutation) ClearCanWrite() {
  1838. m.can_write = nil
  1839. m.appendcan_write = nil
  1840. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  1841. }
  1842. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  1843. func (m *AgentBaseMutation) CanWriteCleared() bool {
  1844. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  1845. return ok
  1846. }
  1847. // ResetCanWrite resets all changes to the "can_write" field.
  1848. func (m *AgentBaseMutation) ResetCanWrite() {
  1849. m.can_write = nil
  1850. m.appendcan_write = nil
  1851. delete(m.clearedFields, agentbase.FieldCanWrite)
  1852. }
  1853. // SetIsOwner sets the "is_owner" field.
  1854. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  1855. m.is_owner = &b
  1856. m.appendis_owner = nil
  1857. }
  1858. // IsOwner returns the value of the "is_owner" field in the mutation.
  1859. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  1860. v := m.is_owner
  1861. if v == nil {
  1862. return
  1863. }
  1864. return *v, true
  1865. }
  1866. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  1867. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1868. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1869. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  1870. if !m.op.Is(OpUpdateOne) {
  1871. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  1872. }
  1873. if m.id == nil || m.oldValue == nil {
  1874. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  1875. }
  1876. oldValue, err := m.oldValue(ctx)
  1877. if err != nil {
  1878. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  1879. }
  1880. return oldValue.IsOwner, nil
  1881. }
  1882. // AppendIsOwner adds b to the "is_owner" field.
  1883. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  1884. m.appendis_owner = append(m.appendis_owner, b...)
  1885. }
  1886. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  1887. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  1888. if len(m.appendis_owner) == 0 {
  1889. return nil, false
  1890. }
  1891. return m.appendis_owner, true
  1892. }
  1893. // ClearIsOwner clears the value of the "is_owner" field.
  1894. func (m *AgentBaseMutation) ClearIsOwner() {
  1895. m.is_owner = nil
  1896. m.appendis_owner = nil
  1897. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  1898. }
  1899. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  1900. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  1901. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  1902. return ok
  1903. }
  1904. // ResetIsOwner resets all changes to the "is_owner" field.
  1905. func (m *AgentBaseMutation) ResetIsOwner() {
  1906. m.is_owner = nil
  1907. m.appendis_owner = nil
  1908. delete(m.clearedFields, agentbase.FieldIsOwner)
  1909. }
  1910. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  1911. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  1912. if m.wx_agent == nil {
  1913. m.wx_agent = make(map[uint64]struct{})
  1914. }
  1915. for i := range ids {
  1916. m.wx_agent[ids[i]] = struct{}{}
  1917. }
  1918. }
  1919. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  1920. func (m *AgentBaseMutation) ClearWxAgent() {
  1921. m.clearedwx_agent = true
  1922. }
  1923. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  1924. func (m *AgentBaseMutation) WxAgentCleared() bool {
  1925. return m.clearedwx_agent
  1926. }
  1927. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  1928. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  1929. if m.removedwx_agent == nil {
  1930. m.removedwx_agent = make(map[uint64]struct{})
  1931. }
  1932. for i := range ids {
  1933. delete(m.wx_agent, ids[i])
  1934. m.removedwx_agent[ids[i]] = struct{}{}
  1935. }
  1936. }
  1937. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  1938. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  1939. for id := range m.removedwx_agent {
  1940. ids = append(ids, id)
  1941. }
  1942. return
  1943. }
  1944. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  1945. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  1946. for id := range m.wx_agent {
  1947. ids = append(ids, id)
  1948. }
  1949. return
  1950. }
  1951. // ResetWxAgent resets all changes to the "wx_agent" edge.
  1952. func (m *AgentBaseMutation) ResetWxAgent() {
  1953. m.wx_agent = nil
  1954. m.clearedwx_agent = false
  1955. m.removedwx_agent = nil
  1956. }
  1957. // Where appends a list predicates to the AgentBaseMutation builder.
  1958. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  1959. m.predicates = append(m.predicates, ps...)
  1960. }
  1961. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  1962. // users can use type-assertion to append predicates that do not depend on any generated package.
  1963. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  1964. p := make([]predicate.AgentBase, len(ps))
  1965. for i := range ps {
  1966. p[i] = ps[i]
  1967. }
  1968. m.Where(p...)
  1969. }
  1970. // Op returns the operation name.
  1971. func (m *AgentBaseMutation) Op() Op {
  1972. return m.op
  1973. }
  1974. // SetOp allows setting the mutation operation.
  1975. func (m *AgentBaseMutation) SetOp(op Op) {
  1976. m.op = op
  1977. }
  1978. // Type returns the node type of this mutation (AgentBase).
  1979. func (m *AgentBaseMutation) Type() string {
  1980. return m.typ
  1981. }
  1982. // Fields returns all fields that were changed during this mutation. Note that in
  1983. // order to get all numeric fields that were incremented/decremented, call
  1984. // AddedFields().
  1985. func (m *AgentBaseMutation) Fields() []string {
  1986. fields := make([]string, 0, 9)
  1987. if m.q != nil {
  1988. fields = append(fields, agentbase.FieldQ)
  1989. }
  1990. if m.a != nil {
  1991. fields = append(fields, agentbase.FieldA)
  1992. }
  1993. if m.chunk_index != nil {
  1994. fields = append(fields, agentbase.FieldChunkIndex)
  1995. }
  1996. if m.indexes != nil {
  1997. fields = append(fields, agentbase.FieldIndexes)
  1998. }
  1999. if m.dataset_id != nil {
  2000. fields = append(fields, agentbase.FieldDatasetID)
  2001. }
  2002. if m.collection_id != nil {
  2003. fields = append(fields, agentbase.FieldCollectionID)
  2004. }
  2005. if m.source_name != nil {
  2006. fields = append(fields, agentbase.FieldSourceName)
  2007. }
  2008. if m.can_write != nil {
  2009. fields = append(fields, agentbase.FieldCanWrite)
  2010. }
  2011. if m.is_owner != nil {
  2012. fields = append(fields, agentbase.FieldIsOwner)
  2013. }
  2014. return fields
  2015. }
  2016. // Field returns the value of a field with the given name. The second boolean
  2017. // return value indicates that this field was not set, or was not defined in the
  2018. // schema.
  2019. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  2020. switch name {
  2021. case agentbase.FieldQ:
  2022. return m.Q()
  2023. case agentbase.FieldA:
  2024. return m.A()
  2025. case agentbase.FieldChunkIndex:
  2026. return m.ChunkIndex()
  2027. case agentbase.FieldIndexes:
  2028. return m.Indexes()
  2029. case agentbase.FieldDatasetID:
  2030. return m.DatasetID()
  2031. case agentbase.FieldCollectionID:
  2032. return m.CollectionID()
  2033. case agentbase.FieldSourceName:
  2034. return m.SourceName()
  2035. case agentbase.FieldCanWrite:
  2036. return m.CanWrite()
  2037. case agentbase.FieldIsOwner:
  2038. return m.IsOwner()
  2039. }
  2040. return nil, false
  2041. }
  2042. // OldField returns the old value of the field from the database. An error is
  2043. // returned if the mutation operation is not UpdateOne, or the query to the
  2044. // database failed.
  2045. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2046. switch name {
  2047. case agentbase.FieldQ:
  2048. return m.OldQ(ctx)
  2049. case agentbase.FieldA:
  2050. return m.OldA(ctx)
  2051. case agentbase.FieldChunkIndex:
  2052. return m.OldChunkIndex(ctx)
  2053. case agentbase.FieldIndexes:
  2054. return m.OldIndexes(ctx)
  2055. case agentbase.FieldDatasetID:
  2056. return m.OldDatasetID(ctx)
  2057. case agentbase.FieldCollectionID:
  2058. return m.OldCollectionID(ctx)
  2059. case agentbase.FieldSourceName:
  2060. return m.OldSourceName(ctx)
  2061. case agentbase.FieldCanWrite:
  2062. return m.OldCanWrite(ctx)
  2063. case agentbase.FieldIsOwner:
  2064. return m.OldIsOwner(ctx)
  2065. }
  2066. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  2067. }
  2068. // SetField sets the value of a field with the given name. It returns an error if
  2069. // the field is not defined in the schema, or if the type mismatched the field
  2070. // type.
  2071. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  2072. switch name {
  2073. case agentbase.FieldQ:
  2074. v, ok := value.(string)
  2075. if !ok {
  2076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2077. }
  2078. m.SetQ(v)
  2079. return nil
  2080. case agentbase.FieldA:
  2081. v, ok := value.(string)
  2082. if !ok {
  2083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2084. }
  2085. m.SetA(v)
  2086. return nil
  2087. case agentbase.FieldChunkIndex:
  2088. v, ok := value.(uint64)
  2089. if !ok {
  2090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2091. }
  2092. m.SetChunkIndex(v)
  2093. return nil
  2094. case agentbase.FieldIndexes:
  2095. v, ok := value.([]string)
  2096. if !ok {
  2097. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2098. }
  2099. m.SetIndexes(v)
  2100. return nil
  2101. case agentbase.FieldDatasetID:
  2102. v, ok := value.(string)
  2103. if !ok {
  2104. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2105. }
  2106. m.SetDatasetID(v)
  2107. return nil
  2108. case agentbase.FieldCollectionID:
  2109. v, ok := value.(string)
  2110. if !ok {
  2111. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2112. }
  2113. m.SetCollectionID(v)
  2114. return nil
  2115. case agentbase.FieldSourceName:
  2116. v, ok := value.(string)
  2117. if !ok {
  2118. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2119. }
  2120. m.SetSourceName(v)
  2121. return nil
  2122. case agentbase.FieldCanWrite:
  2123. v, ok := value.([]bool)
  2124. if !ok {
  2125. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2126. }
  2127. m.SetCanWrite(v)
  2128. return nil
  2129. case agentbase.FieldIsOwner:
  2130. v, ok := value.([]bool)
  2131. if !ok {
  2132. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2133. }
  2134. m.SetIsOwner(v)
  2135. return nil
  2136. }
  2137. return fmt.Errorf("unknown AgentBase field %s", name)
  2138. }
  2139. // AddedFields returns all numeric fields that were incremented/decremented during
  2140. // this mutation.
  2141. func (m *AgentBaseMutation) AddedFields() []string {
  2142. var fields []string
  2143. if m.addchunk_index != nil {
  2144. fields = append(fields, agentbase.FieldChunkIndex)
  2145. }
  2146. return fields
  2147. }
  2148. // AddedField returns the numeric value that was incremented/decremented on a field
  2149. // with the given name. The second boolean return value indicates that this field
  2150. // was not set, or was not defined in the schema.
  2151. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  2152. switch name {
  2153. case agentbase.FieldChunkIndex:
  2154. return m.AddedChunkIndex()
  2155. }
  2156. return nil, false
  2157. }
  2158. // AddField adds the value to the field with the given name. It returns an error if
  2159. // the field is not defined in the schema, or if the type mismatched the field
  2160. // type.
  2161. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  2162. switch name {
  2163. case agentbase.FieldChunkIndex:
  2164. v, ok := value.(int64)
  2165. if !ok {
  2166. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2167. }
  2168. m.AddChunkIndex(v)
  2169. return nil
  2170. }
  2171. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  2172. }
  2173. // ClearedFields returns all nullable fields that were cleared during this
  2174. // mutation.
  2175. func (m *AgentBaseMutation) ClearedFields() []string {
  2176. var fields []string
  2177. if m.FieldCleared(agentbase.FieldQ) {
  2178. fields = append(fields, agentbase.FieldQ)
  2179. }
  2180. if m.FieldCleared(agentbase.FieldA) {
  2181. fields = append(fields, agentbase.FieldA)
  2182. }
  2183. if m.FieldCleared(agentbase.FieldIndexes) {
  2184. fields = append(fields, agentbase.FieldIndexes)
  2185. }
  2186. if m.FieldCleared(agentbase.FieldDatasetID) {
  2187. fields = append(fields, agentbase.FieldDatasetID)
  2188. }
  2189. if m.FieldCleared(agentbase.FieldCollectionID) {
  2190. fields = append(fields, agentbase.FieldCollectionID)
  2191. }
  2192. if m.FieldCleared(agentbase.FieldSourceName) {
  2193. fields = append(fields, agentbase.FieldSourceName)
  2194. }
  2195. if m.FieldCleared(agentbase.FieldCanWrite) {
  2196. fields = append(fields, agentbase.FieldCanWrite)
  2197. }
  2198. if m.FieldCleared(agentbase.FieldIsOwner) {
  2199. fields = append(fields, agentbase.FieldIsOwner)
  2200. }
  2201. return fields
  2202. }
  2203. // FieldCleared returns a boolean indicating if a field with the given name was
  2204. // cleared in this mutation.
  2205. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2206. _, ok := m.clearedFields[name]
  2207. return ok
  2208. }
  2209. // ClearField clears the value of the field with the given name. It returns an
  2210. // error if the field is not defined in the schema.
  2211. func (m *AgentBaseMutation) ClearField(name string) error {
  2212. switch name {
  2213. case agentbase.FieldQ:
  2214. m.ClearQ()
  2215. return nil
  2216. case agentbase.FieldA:
  2217. m.ClearA()
  2218. return nil
  2219. case agentbase.FieldIndexes:
  2220. m.ClearIndexes()
  2221. return nil
  2222. case agentbase.FieldDatasetID:
  2223. m.ClearDatasetID()
  2224. return nil
  2225. case agentbase.FieldCollectionID:
  2226. m.ClearCollectionID()
  2227. return nil
  2228. case agentbase.FieldSourceName:
  2229. m.ClearSourceName()
  2230. return nil
  2231. case agentbase.FieldCanWrite:
  2232. m.ClearCanWrite()
  2233. return nil
  2234. case agentbase.FieldIsOwner:
  2235. m.ClearIsOwner()
  2236. return nil
  2237. }
  2238. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2239. }
  2240. // ResetField resets all changes in the mutation for the field with the given name.
  2241. // It returns an error if the field is not defined in the schema.
  2242. func (m *AgentBaseMutation) ResetField(name string) error {
  2243. switch name {
  2244. case agentbase.FieldQ:
  2245. m.ResetQ()
  2246. return nil
  2247. case agentbase.FieldA:
  2248. m.ResetA()
  2249. return nil
  2250. case agentbase.FieldChunkIndex:
  2251. m.ResetChunkIndex()
  2252. return nil
  2253. case agentbase.FieldIndexes:
  2254. m.ResetIndexes()
  2255. return nil
  2256. case agentbase.FieldDatasetID:
  2257. m.ResetDatasetID()
  2258. return nil
  2259. case agentbase.FieldCollectionID:
  2260. m.ResetCollectionID()
  2261. return nil
  2262. case agentbase.FieldSourceName:
  2263. m.ResetSourceName()
  2264. return nil
  2265. case agentbase.FieldCanWrite:
  2266. m.ResetCanWrite()
  2267. return nil
  2268. case agentbase.FieldIsOwner:
  2269. m.ResetIsOwner()
  2270. return nil
  2271. }
  2272. return fmt.Errorf("unknown AgentBase field %s", name)
  2273. }
  2274. // AddedEdges returns all edge names that were set/added in this mutation.
  2275. func (m *AgentBaseMutation) AddedEdges() []string {
  2276. edges := make([]string, 0, 1)
  2277. if m.wx_agent != nil {
  2278. edges = append(edges, agentbase.EdgeWxAgent)
  2279. }
  2280. return edges
  2281. }
  2282. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2283. // name in this mutation.
  2284. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2285. switch name {
  2286. case agentbase.EdgeWxAgent:
  2287. ids := make([]ent.Value, 0, len(m.wx_agent))
  2288. for id := range m.wx_agent {
  2289. ids = append(ids, id)
  2290. }
  2291. return ids
  2292. }
  2293. return nil
  2294. }
  2295. // RemovedEdges returns all edge names that were removed in this mutation.
  2296. func (m *AgentBaseMutation) RemovedEdges() []string {
  2297. edges := make([]string, 0, 1)
  2298. if m.removedwx_agent != nil {
  2299. edges = append(edges, agentbase.EdgeWxAgent)
  2300. }
  2301. return edges
  2302. }
  2303. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2304. // the given name in this mutation.
  2305. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2306. switch name {
  2307. case agentbase.EdgeWxAgent:
  2308. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2309. for id := range m.removedwx_agent {
  2310. ids = append(ids, id)
  2311. }
  2312. return ids
  2313. }
  2314. return nil
  2315. }
  2316. // ClearedEdges returns all edge names that were cleared in this mutation.
  2317. func (m *AgentBaseMutation) ClearedEdges() []string {
  2318. edges := make([]string, 0, 1)
  2319. if m.clearedwx_agent {
  2320. edges = append(edges, agentbase.EdgeWxAgent)
  2321. }
  2322. return edges
  2323. }
  2324. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2325. // was cleared in this mutation.
  2326. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2327. switch name {
  2328. case agentbase.EdgeWxAgent:
  2329. return m.clearedwx_agent
  2330. }
  2331. return false
  2332. }
  2333. // ClearEdge clears the value of the edge with the given name. It returns an error
  2334. // if that edge is not defined in the schema.
  2335. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2336. switch name {
  2337. }
  2338. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2339. }
  2340. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2341. // It returns an error if the edge is not defined in the schema.
  2342. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2343. switch name {
  2344. case agentbase.EdgeWxAgent:
  2345. m.ResetWxAgent()
  2346. return nil
  2347. }
  2348. return fmt.Errorf("unknown AgentBase edge %s", name)
  2349. }
  2350. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2351. type AliyunAvatarMutation struct {
  2352. config
  2353. op Op
  2354. typ string
  2355. id *uint64
  2356. created_at *time.Time
  2357. updated_at *time.Time
  2358. deleted_at *time.Time
  2359. user_id *uint64
  2360. adduser_id *int64
  2361. biz_id *string
  2362. access_key_id *string
  2363. access_key_secret *string
  2364. app_id *string
  2365. tenant_id *uint64
  2366. addtenant_id *int64
  2367. response *string
  2368. token *string
  2369. session_id *string
  2370. clearedFields map[string]struct{}
  2371. done bool
  2372. oldValue func(context.Context) (*AliyunAvatar, error)
  2373. predicates []predicate.AliyunAvatar
  2374. }
  2375. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2376. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2377. type aliyunavatarOption func(*AliyunAvatarMutation)
  2378. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2379. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2380. m := &AliyunAvatarMutation{
  2381. config: c,
  2382. op: op,
  2383. typ: TypeAliyunAvatar,
  2384. clearedFields: make(map[string]struct{}),
  2385. }
  2386. for _, opt := range opts {
  2387. opt(m)
  2388. }
  2389. return m
  2390. }
  2391. // withAliyunAvatarID sets the ID field of the mutation.
  2392. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2393. return func(m *AliyunAvatarMutation) {
  2394. var (
  2395. err error
  2396. once sync.Once
  2397. value *AliyunAvatar
  2398. )
  2399. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2400. once.Do(func() {
  2401. if m.done {
  2402. err = errors.New("querying old values post mutation is not allowed")
  2403. } else {
  2404. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2405. }
  2406. })
  2407. return value, err
  2408. }
  2409. m.id = &id
  2410. }
  2411. }
  2412. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2413. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2414. return func(m *AliyunAvatarMutation) {
  2415. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2416. return node, nil
  2417. }
  2418. m.id = &node.ID
  2419. }
  2420. }
  2421. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2422. // executed in a transaction (ent.Tx), a transactional client is returned.
  2423. func (m AliyunAvatarMutation) Client() *Client {
  2424. client := &Client{config: m.config}
  2425. client.init()
  2426. return client
  2427. }
  2428. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2429. // it returns an error otherwise.
  2430. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2431. if _, ok := m.driver.(*txDriver); !ok {
  2432. return nil, errors.New("ent: mutation is not running in a transaction")
  2433. }
  2434. tx := &Tx{config: m.config}
  2435. tx.init()
  2436. return tx, nil
  2437. }
  2438. // SetID sets the value of the id field. Note that this
  2439. // operation is only accepted on creation of AliyunAvatar entities.
  2440. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2441. m.id = &id
  2442. }
  2443. // ID returns the ID value in the mutation. Note that the ID is only available
  2444. // if it was provided to the builder or after it was returned from the database.
  2445. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2446. if m.id == nil {
  2447. return
  2448. }
  2449. return *m.id, true
  2450. }
  2451. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2452. // That means, if the mutation is applied within a transaction with an isolation level such
  2453. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2454. // or updated by the mutation.
  2455. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2456. switch {
  2457. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2458. id, exists := m.ID()
  2459. if exists {
  2460. return []uint64{id}, nil
  2461. }
  2462. fallthrough
  2463. case m.op.Is(OpUpdate | OpDelete):
  2464. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2465. default:
  2466. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2467. }
  2468. }
  2469. // SetCreatedAt sets the "created_at" field.
  2470. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2471. m.created_at = &t
  2472. }
  2473. // CreatedAt returns the value of the "created_at" field in the mutation.
  2474. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2475. v := m.created_at
  2476. if v == nil {
  2477. return
  2478. }
  2479. return *v, true
  2480. }
  2481. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2482. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2483. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2484. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2485. if !m.op.Is(OpUpdateOne) {
  2486. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2487. }
  2488. if m.id == nil || m.oldValue == nil {
  2489. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2490. }
  2491. oldValue, err := m.oldValue(ctx)
  2492. if err != nil {
  2493. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2494. }
  2495. return oldValue.CreatedAt, nil
  2496. }
  2497. // ResetCreatedAt resets all changes to the "created_at" field.
  2498. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2499. m.created_at = nil
  2500. }
  2501. // SetUpdatedAt sets the "updated_at" field.
  2502. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2503. m.updated_at = &t
  2504. }
  2505. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2506. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2507. v := m.updated_at
  2508. if v == nil {
  2509. return
  2510. }
  2511. return *v, true
  2512. }
  2513. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2514. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2515. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2516. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2517. if !m.op.Is(OpUpdateOne) {
  2518. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2519. }
  2520. if m.id == nil || m.oldValue == nil {
  2521. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2522. }
  2523. oldValue, err := m.oldValue(ctx)
  2524. if err != nil {
  2525. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2526. }
  2527. return oldValue.UpdatedAt, nil
  2528. }
  2529. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2530. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2531. m.updated_at = nil
  2532. }
  2533. // SetDeletedAt sets the "deleted_at" field.
  2534. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2535. m.deleted_at = &t
  2536. }
  2537. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2538. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2539. v := m.deleted_at
  2540. if v == nil {
  2541. return
  2542. }
  2543. return *v, true
  2544. }
  2545. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2546. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2547. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2548. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2549. if !m.op.Is(OpUpdateOne) {
  2550. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2551. }
  2552. if m.id == nil || m.oldValue == nil {
  2553. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2554. }
  2555. oldValue, err := m.oldValue(ctx)
  2556. if err != nil {
  2557. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2558. }
  2559. return oldValue.DeletedAt, nil
  2560. }
  2561. // ClearDeletedAt clears the value of the "deleted_at" field.
  2562. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2563. m.deleted_at = nil
  2564. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2565. }
  2566. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2567. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2568. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2569. return ok
  2570. }
  2571. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2572. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2573. m.deleted_at = nil
  2574. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2575. }
  2576. // SetUserID sets the "user_id" field.
  2577. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2578. m.user_id = &u
  2579. m.adduser_id = nil
  2580. }
  2581. // UserID returns the value of the "user_id" field in the mutation.
  2582. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2583. v := m.user_id
  2584. if v == nil {
  2585. return
  2586. }
  2587. return *v, true
  2588. }
  2589. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2590. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2591. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2592. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2593. if !m.op.Is(OpUpdateOne) {
  2594. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2595. }
  2596. if m.id == nil || m.oldValue == nil {
  2597. return v, errors.New("OldUserID requires an ID field in the mutation")
  2598. }
  2599. oldValue, err := m.oldValue(ctx)
  2600. if err != nil {
  2601. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  2602. }
  2603. return oldValue.UserID, nil
  2604. }
  2605. // AddUserID adds u to the "user_id" field.
  2606. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  2607. if m.adduser_id != nil {
  2608. *m.adduser_id += u
  2609. } else {
  2610. m.adduser_id = &u
  2611. }
  2612. }
  2613. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  2614. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  2615. v := m.adduser_id
  2616. if v == nil {
  2617. return
  2618. }
  2619. return *v, true
  2620. }
  2621. // ResetUserID resets all changes to the "user_id" field.
  2622. func (m *AliyunAvatarMutation) ResetUserID() {
  2623. m.user_id = nil
  2624. m.adduser_id = nil
  2625. }
  2626. // SetBizID sets the "biz_id" field.
  2627. func (m *AliyunAvatarMutation) SetBizID(s string) {
  2628. m.biz_id = &s
  2629. }
  2630. // BizID returns the value of the "biz_id" field in the mutation.
  2631. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  2632. v := m.biz_id
  2633. if v == nil {
  2634. return
  2635. }
  2636. return *v, true
  2637. }
  2638. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  2639. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2640. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2641. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  2642. if !m.op.Is(OpUpdateOne) {
  2643. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  2644. }
  2645. if m.id == nil || m.oldValue == nil {
  2646. return v, errors.New("OldBizID requires an ID field in the mutation")
  2647. }
  2648. oldValue, err := m.oldValue(ctx)
  2649. if err != nil {
  2650. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  2651. }
  2652. return oldValue.BizID, nil
  2653. }
  2654. // ResetBizID resets all changes to the "biz_id" field.
  2655. func (m *AliyunAvatarMutation) ResetBizID() {
  2656. m.biz_id = nil
  2657. }
  2658. // SetAccessKeyID sets the "access_key_id" field.
  2659. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  2660. m.access_key_id = &s
  2661. }
  2662. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  2663. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  2664. v := m.access_key_id
  2665. if v == nil {
  2666. return
  2667. }
  2668. return *v, true
  2669. }
  2670. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  2671. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2672. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2673. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  2674. if !m.op.Is(OpUpdateOne) {
  2675. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  2676. }
  2677. if m.id == nil || m.oldValue == nil {
  2678. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  2679. }
  2680. oldValue, err := m.oldValue(ctx)
  2681. if err != nil {
  2682. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  2683. }
  2684. return oldValue.AccessKeyID, nil
  2685. }
  2686. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  2687. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  2688. m.access_key_id = nil
  2689. }
  2690. // SetAccessKeySecret sets the "access_key_secret" field.
  2691. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  2692. m.access_key_secret = &s
  2693. }
  2694. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  2695. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  2696. v := m.access_key_secret
  2697. if v == nil {
  2698. return
  2699. }
  2700. return *v, true
  2701. }
  2702. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  2703. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2704. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2705. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  2706. if !m.op.Is(OpUpdateOne) {
  2707. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  2708. }
  2709. if m.id == nil || m.oldValue == nil {
  2710. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  2711. }
  2712. oldValue, err := m.oldValue(ctx)
  2713. if err != nil {
  2714. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  2715. }
  2716. return oldValue.AccessKeySecret, nil
  2717. }
  2718. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  2719. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  2720. m.access_key_secret = nil
  2721. }
  2722. // SetAppID sets the "app_id" field.
  2723. func (m *AliyunAvatarMutation) SetAppID(s string) {
  2724. m.app_id = &s
  2725. }
  2726. // AppID returns the value of the "app_id" field in the mutation.
  2727. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  2728. v := m.app_id
  2729. if v == nil {
  2730. return
  2731. }
  2732. return *v, true
  2733. }
  2734. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  2735. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2736. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2737. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  2738. if !m.op.Is(OpUpdateOne) {
  2739. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  2740. }
  2741. if m.id == nil || m.oldValue == nil {
  2742. return v, errors.New("OldAppID requires an ID field in the mutation")
  2743. }
  2744. oldValue, err := m.oldValue(ctx)
  2745. if err != nil {
  2746. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  2747. }
  2748. return oldValue.AppID, nil
  2749. }
  2750. // ClearAppID clears the value of the "app_id" field.
  2751. func (m *AliyunAvatarMutation) ClearAppID() {
  2752. m.app_id = nil
  2753. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  2754. }
  2755. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  2756. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  2757. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  2758. return ok
  2759. }
  2760. // ResetAppID resets all changes to the "app_id" field.
  2761. func (m *AliyunAvatarMutation) ResetAppID() {
  2762. m.app_id = nil
  2763. delete(m.clearedFields, aliyunavatar.FieldAppID)
  2764. }
  2765. // SetTenantID sets the "tenant_id" field.
  2766. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  2767. m.tenant_id = &u
  2768. m.addtenant_id = nil
  2769. }
  2770. // TenantID returns the value of the "tenant_id" field in the mutation.
  2771. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  2772. v := m.tenant_id
  2773. if v == nil {
  2774. return
  2775. }
  2776. return *v, true
  2777. }
  2778. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  2779. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2781. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  2782. if !m.op.Is(OpUpdateOne) {
  2783. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  2784. }
  2785. if m.id == nil || m.oldValue == nil {
  2786. return v, errors.New("OldTenantID requires an ID field in the mutation")
  2787. }
  2788. oldValue, err := m.oldValue(ctx)
  2789. if err != nil {
  2790. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  2791. }
  2792. return oldValue.TenantID, nil
  2793. }
  2794. // AddTenantID adds u to the "tenant_id" field.
  2795. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  2796. if m.addtenant_id != nil {
  2797. *m.addtenant_id += u
  2798. } else {
  2799. m.addtenant_id = &u
  2800. }
  2801. }
  2802. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  2803. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  2804. v := m.addtenant_id
  2805. if v == nil {
  2806. return
  2807. }
  2808. return *v, true
  2809. }
  2810. // ResetTenantID resets all changes to the "tenant_id" field.
  2811. func (m *AliyunAvatarMutation) ResetTenantID() {
  2812. m.tenant_id = nil
  2813. m.addtenant_id = nil
  2814. }
  2815. // SetResponse sets the "response" field.
  2816. func (m *AliyunAvatarMutation) SetResponse(s string) {
  2817. m.response = &s
  2818. }
  2819. // Response returns the value of the "response" field in the mutation.
  2820. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  2821. v := m.response
  2822. if v == nil {
  2823. return
  2824. }
  2825. return *v, true
  2826. }
  2827. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  2828. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2829. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2830. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  2831. if !m.op.Is(OpUpdateOne) {
  2832. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  2833. }
  2834. if m.id == nil || m.oldValue == nil {
  2835. return v, errors.New("OldResponse requires an ID field in the mutation")
  2836. }
  2837. oldValue, err := m.oldValue(ctx)
  2838. if err != nil {
  2839. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  2840. }
  2841. return oldValue.Response, nil
  2842. }
  2843. // ResetResponse resets all changes to the "response" field.
  2844. func (m *AliyunAvatarMutation) ResetResponse() {
  2845. m.response = nil
  2846. }
  2847. // SetToken sets the "token" field.
  2848. func (m *AliyunAvatarMutation) SetToken(s string) {
  2849. m.token = &s
  2850. }
  2851. // Token returns the value of the "token" field in the mutation.
  2852. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  2853. v := m.token
  2854. if v == nil {
  2855. return
  2856. }
  2857. return *v, true
  2858. }
  2859. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  2860. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2861. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2862. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  2863. if !m.op.Is(OpUpdateOne) {
  2864. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  2865. }
  2866. if m.id == nil || m.oldValue == nil {
  2867. return v, errors.New("OldToken requires an ID field in the mutation")
  2868. }
  2869. oldValue, err := m.oldValue(ctx)
  2870. if err != nil {
  2871. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  2872. }
  2873. return oldValue.Token, nil
  2874. }
  2875. // ResetToken resets all changes to the "token" field.
  2876. func (m *AliyunAvatarMutation) ResetToken() {
  2877. m.token = nil
  2878. }
  2879. // SetSessionID sets the "session_id" field.
  2880. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  2881. m.session_id = &s
  2882. }
  2883. // SessionID returns the value of the "session_id" field in the mutation.
  2884. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  2885. v := m.session_id
  2886. if v == nil {
  2887. return
  2888. }
  2889. return *v, true
  2890. }
  2891. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  2892. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2893. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2894. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  2895. if !m.op.Is(OpUpdateOne) {
  2896. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  2897. }
  2898. if m.id == nil || m.oldValue == nil {
  2899. return v, errors.New("OldSessionID requires an ID field in the mutation")
  2900. }
  2901. oldValue, err := m.oldValue(ctx)
  2902. if err != nil {
  2903. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  2904. }
  2905. return oldValue.SessionID, nil
  2906. }
  2907. // ResetSessionID resets all changes to the "session_id" field.
  2908. func (m *AliyunAvatarMutation) ResetSessionID() {
  2909. m.session_id = nil
  2910. }
  2911. // Where appends a list predicates to the AliyunAvatarMutation builder.
  2912. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  2913. m.predicates = append(m.predicates, ps...)
  2914. }
  2915. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  2916. // users can use type-assertion to append predicates that do not depend on any generated package.
  2917. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  2918. p := make([]predicate.AliyunAvatar, len(ps))
  2919. for i := range ps {
  2920. p[i] = ps[i]
  2921. }
  2922. m.Where(p...)
  2923. }
  2924. // Op returns the operation name.
  2925. func (m *AliyunAvatarMutation) Op() Op {
  2926. return m.op
  2927. }
  2928. // SetOp allows setting the mutation operation.
  2929. func (m *AliyunAvatarMutation) SetOp(op Op) {
  2930. m.op = op
  2931. }
  2932. // Type returns the node type of this mutation (AliyunAvatar).
  2933. func (m *AliyunAvatarMutation) Type() string {
  2934. return m.typ
  2935. }
  2936. // Fields returns all fields that were changed during this mutation. Note that in
  2937. // order to get all numeric fields that were incremented/decremented, call
  2938. // AddedFields().
  2939. func (m *AliyunAvatarMutation) Fields() []string {
  2940. fields := make([]string, 0, 12)
  2941. if m.created_at != nil {
  2942. fields = append(fields, aliyunavatar.FieldCreatedAt)
  2943. }
  2944. if m.updated_at != nil {
  2945. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  2946. }
  2947. if m.deleted_at != nil {
  2948. fields = append(fields, aliyunavatar.FieldDeletedAt)
  2949. }
  2950. if m.user_id != nil {
  2951. fields = append(fields, aliyunavatar.FieldUserID)
  2952. }
  2953. if m.biz_id != nil {
  2954. fields = append(fields, aliyunavatar.FieldBizID)
  2955. }
  2956. if m.access_key_id != nil {
  2957. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  2958. }
  2959. if m.access_key_secret != nil {
  2960. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  2961. }
  2962. if m.app_id != nil {
  2963. fields = append(fields, aliyunavatar.FieldAppID)
  2964. }
  2965. if m.tenant_id != nil {
  2966. fields = append(fields, aliyunavatar.FieldTenantID)
  2967. }
  2968. if m.response != nil {
  2969. fields = append(fields, aliyunavatar.FieldResponse)
  2970. }
  2971. if m.token != nil {
  2972. fields = append(fields, aliyunavatar.FieldToken)
  2973. }
  2974. if m.session_id != nil {
  2975. fields = append(fields, aliyunavatar.FieldSessionID)
  2976. }
  2977. return fields
  2978. }
  2979. // Field returns the value of a field with the given name. The second boolean
  2980. // return value indicates that this field was not set, or was not defined in the
  2981. // schema.
  2982. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  2983. switch name {
  2984. case aliyunavatar.FieldCreatedAt:
  2985. return m.CreatedAt()
  2986. case aliyunavatar.FieldUpdatedAt:
  2987. return m.UpdatedAt()
  2988. case aliyunavatar.FieldDeletedAt:
  2989. return m.DeletedAt()
  2990. case aliyunavatar.FieldUserID:
  2991. return m.UserID()
  2992. case aliyunavatar.FieldBizID:
  2993. return m.BizID()
  2994. case aliyunavatar.FieldAccessKeyID:
  2995. return m.AccessKeyID()
  2996. case aliyunavatar.FieldAccessKeySecret:
  2997. return m.AccessKeySecret()
  2998. case aliyunavatar.FieldAppID:
  2999. return m.AppID()
  3000. case aliyunavatar.FieldTenantID:
  3001. return m.TenantID()
  3002. case aliyunavatar.FieldResponse:
  3003. return m.Response()
  3004. case aliyunavatar.FieldToken:
  3005. return m.Token()
  3006. case aliyunavatar.FieldSessionID:
  3007. return m.SessionID()
  3008. }
  3009. return nil, false
  3010. }
  3011. // OldField returns the old value of the field from the database. An error is
  3012. // returned if the mutation operation is not UpdateOne, or the query to the
  3013. // database failed.
  3014. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3015. switch name {
  3016. case aliyunavatar.FieldCreatedAt:
  3017. return m.OldCreatedAt(ctx)
  3018. case aliyunavatar.FieldUpdatedAt:
  3019. return m.OldUpdatedAt(ctx)
  3020. case aliyunavatar.FieldDeletedAt:
  3021. return m.OldDeletedAt(ctx)
  3022. case aliyunavatar.FieldUserID:
  3023. return m.OldUserID(ctx)
  3024. case aliyunavatar.FieldBizID:
  3025. return m.OldBizID(ctx)
  3026. case aliyunavatar.FieldAccessKeyID:
  3027. return m.OldAccessKeyID(ctx)
  3028. case aliyunavatar.FieldAccessKeySecret:
  3029. return m.OldAccessKeySecret(ctx)
  3030. case aliyunavatar.FieldAppID:
  3031. return m.OldAppID(ctx)
  3032. case aliyunavatar.FieldTenantID:
  3033. return m.OldTenantID(ctx)
  3034. case aliyunavatar.FieldResponse:
  3035. return m.OldResponse(ctx)
  3036. case aliyunavatar.FieldToken:
  3037. return m.OldToken(ctx)
  3038. case aliyunavatar.FieldSessionID:
  3039. return m.OldSessionID(ctx)
  3040. }
  3041. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  3042. }
  3043. // SetField sets the value of a field with the given name. It returns an error if
  3044. // the field is not defined in the schema, or if the type mismatched the field
  3045. // type.
  3046. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  3047. switch name {
  3048. case aliyunavatar.FieldCreatedAt:
  3049. v, ok := value.(time.Time)
  3050. if !ok {
  3051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3052. }
  3053. m.SetCreatedAt(v)
  3054. return nil
  3055. case aliyunavatar.FieldUpdatedAt:
  3056. v, ok := value.(time.Time)
  3057. if !ok {
  3058. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3059. }
  3060. m.SetUpdatedAt(v)
  3061. return nil
  3062. case aliyunavatar.FieldDeletedAt:
  3063. v, ok := value.(time.Time)
  3064. if !ok {
  3065. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3066. }
  3067. m.SetDeletedAt(v)
  3068. return nil
  3069. case aliyunavatar.FieldUserID:
  3070. v, ok := value.(uint64)
  3071. if !ok {
  3072. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3073. }
  3074. m.SetUserID(v)
  3075. return nil
  3076. case aliyunavatar.FieldBizID:
  3077. v, ok := value.(string)
  3078. if !ok {
  3079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3080. }
  3081. m.SetBizID(v)
  3082. return nil
  3083. case aliyunavatar.FieldAccessKeyID:
  3084. v, ok := value.(string)
  3085. if !ok {
  3086. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3087. }
  3088. m.SetAccessKeyID(v)
  3089. return nil
  3090. case aliyunavatar.FieldAccessKeySecret:
  3091. v, ok := value.(string)
  3092. if !ok {
  3093. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3094. }
  3095. m.SetAccessKeySecret(v)
  3096. return nil
  3097. case aliyunavatar.FieldAppID:
  3098. v, ok := value.(string)
  3099. if !ok {
  3100. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3101. }
  3102. m.SetAppID(v)
  3103. return nil
  3104. case aliyunavatar.FieldTenantID:
  3105. v, ok := value.(uint64)
  3106. if !ok {
  3107. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3108. }
  3109. m.SetTenantID(v)
  3110. return nil
  3111. case aliyunavatar.FieldResponse:
  3112. v, ok := value.(string)
  3113. if !ok {
  3114. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3115. }
  3116. m.SetResponse(v)
  3117. return nil
  3118. case aliyunavatar.FieldToken:
  3119. v, ok := value.(string)
  3120. if !ok {
  3121. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3122. }
  3123. m.SetToken(v)
  3124. return nil
  3125. case aliyunavatar.FieldSessionID:
  3126. v, ok := value.(string)
  3127. if !ok {
  3128. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3129. }
  3130. m.SetSessionID(v)
  3131. return nil
  3132. }
  3133. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3134. }
  3135. // AddedFields returns all numeric fields that were incremented/decremented during
  3136. // this mutation.
  3137. func (m *AliyunAvatarMutation) AddedFields() []string {
  3138. var fields []string
  3139. if m.adduser_id != nil {
  3140. fields = append(fields, aliyunavatar.FieldUserID)
  3141. }
  3142. if m.addtenant_id != nil {
  3143. fields = append(fields, aliyunavatar.FieldTenantID)
  3144. }
  3145. return fields
  3146. }
  3147. // AddedField returns the numeric value that was incremented/decremented on a field
  3148. // with the given name. The second boolean return value indicates that this field
  3149. // was not set, or was not defined in the schema.
  3150. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  3151. switch name {
  3152. case aliyunavatar.FieldUserID:
  3153. return m.AddedUserID()
  3154. case aliyunavatar.FieldTenantID:
  3155. return m.AddedTenantID()
  3156. }
  3157. return nil, false
  3158. }
  3159. // AddField adds the value to the field with the given name. It returns an error if
  3160. // the field is not defined in the schema, or if the type mismatched the field
  3161. // type.
  3162. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  3163. switch name {
  3164. case aliyunavatar.FieldUserID:
  3165. v, ok := value.(int64)
  3166. if !ok {
  3167. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3168. }
  3169. m.AddUserID(v)
  3170. return nil
  3171. case aliyunavatar.FieldTenantID:
  3172. v, ok := value.(int64)
  3173. if !ok {
  3174. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3175. }
  3176. m.AddTenantID(v)
  3177. return nil
  3178. }
  3179. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3180. }
  3181. // ClearedFields returns all nullable fields that were cleared during this
  3182. // mutation.
  3183. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3184. var fields []string
  3185. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3186. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3187. }
  3188. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3189. fields = append(fields, aliyunavatar.FieldAppID)
  3190. }
  3191. return fields
  3192. }
  3193. // FieldCleared returns a boolean indicating if a field with the given name was
  3194. // cleared in this mutation.
  3195. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3196. _, ok := m.clearedFields[name]
  3197. return ok
  3198. }
  3199. // ClearField clears the value of the field with the given name. It returns an
  3200. // error if the field is not defined in the schema.
  3201. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3202. switch name {
  3203. case aliyunavatar.FieldDeletedAt:
  3204. m.ClearDeletedAt()
  3205. return nil
  3206. case aliyunavatar.FieldAppID:
  3207. m.ClearAppID()
  3208. return nil
  3209. }
  3210. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3211. }
  3212. // ResetField resets all changes in the mutation for the field with the given name.
  3213. // It returns an error if the field is not defined in the schema.
  3214. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3215. switch name {
  3216. case aliyunavatar.FieldCreatedAt:
  3217. m.ResetCreatedAt()
  3218. return nil
  3219. case aliyunavatar.FieldUpdatedAt:
  3220. m.ResetUpdatedAt()
  3221. return nil
  3222. case aliyunavatar.FieldDeletedAt:
  3223. m.ResetDeletedAt()
  3224. return nil
  3225. case aliyunavatar.FieldUserID:
  3226. m.ResetUserID()
  3227. return nil
  3228. case aliyunavatar.FieldBizID:
  3229. m.ResetBizID()
  3230. return nil
  3231. case aliyunavatar.FieldAccessKeyID:
  3232. m.ResetAccessKeyID()
  3233. return nil
  3234. case aliyunavatar.FieldAccessKeySecret:
  3235. m.ResetAccessKeySecret()
  3236. return nil
  3237. case aliyunavatar.FieldAppID:
  3238. m.ResetAppID()
  3239. return nil
  3240. case aliyunavatar.FieldTenantID:
  3241. m.ResetTenantID()
  3242. return nil
  3243. case aliyunavatar.FieldResponse:
  3244. m.ResetResponse()
  3245. return nil
  3246. case aliyunavatar.FieldToken:
  3247. m.ResetToken()
  3248. return nil
  3249. case aliyunavatar.FieldSessionID:
  3250. m.ResetSessionID()
  3251. return nil
  3252. }
  3253. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3254. }
  3255. // AddedEdges returns all edge names that were set/added in this mutation.
  3256. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3257. edges := make([]string, 0, 0)
  3258. return edges
  3259. }
  3260. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3261. // name in this mutation.
  3262. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3263. return nil
  3264. }
  3265. // RemovedEdges returns all edge names that were removed in this mutation.
  3266. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3267. edges := make([]string, 0, 0)
  3268. return edges
  3269. }
  3270. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3271. // the given name in this mutation.
  3272. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3273. return nil
  3274. }
  3275. // ClearedEdges returns all edge names that were cleared in this mutation.
  3276. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3277. edges := make([]string, 0, 0)
  3278. return edges
  3279. }
  3280. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3281. // was cleared in this mutation.
  3282. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3283. return false
  3284. }
  3285. // ClearEdge clears the value of the edge with the given name. It returns an error
  3286. // if that edge is not defined in the schema.
  3287. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3288. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3289. }
  3290. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3291. // It returns an error if the edge is not defined in the schema.
  3292. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3293. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3294. }
  3295. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  3296. type AllocAgentMutation struct {
  3297. config
  3298. op Op
  3299. typ string
  3300. id *uint64
  3301. created_at *time.Time
  3302. updated_at *time.Time
  3303. deleted_at *time.Time
  3304. user_id *string
  3305. organization_id *uint64
  3306. addorganization_id *int64
  3307. agents *[]uint64
  3308. appendagents []uint64
  3309. status *int
  3310. addstatus *int
  3311. clearedFields map[string]struct{}
  3312. done bool
  3313. oldValue func(context.Context) (*AllocAgent, error)
  3314. predicates []predicate.AllocAgent
  3315. }
  3316. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  3317. // allocagentOption allows management of the mutation configuration using functional options.
  3318. type allocagentOption func(*AllocAgentMutation)
  3319. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  3320. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  3321. m := &AllocAgentMutation{
  3322. config: c,
  3323. op: op,
  3324. typ: TypeAllocAgent,
  3325. clearedFields: make(map[string]struct{}),
  3326. }
  3327. for _, opt := range opts {
  3328. opt(m)
  3329. }
  3330. return m
  3331. }
  3332. // withAllocAgentID sets the ID field of the mutation.
  3333. func withAllocAgentID(id uint64) allocagentOption {
  3334. return func(m *AllocAgentMutation) {
  3335. var (
  3336. err error
  3337. once sync.Once
  3338. value *AllocAgent
  3339. )
  3340. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  3341. once.Do(func() {
  3342. if m.done {
  3343. err = errors.New("querying old values post mutation is not allowed")
  3344. } else {
  3345. value, err = m.Client().AllocAgent.Get(ctx, id)
  3346. }
  3347. })
  3348. return value, err
  3349. }
  3350. m.id = &id
  3351. }
  3352. }
  3353. // withAllocAgent sets the old AllocAgent of the mutation.
  3354. func withAllocAgent(node *AllocAgent) allocagentOption {
  3355. return func(m *AllocAgentMutation) {
  3356. m.oldValue = func(context.Context) (*AllocAgent, error) {
  3357. return node, nil
  3358. }
  3359. m.id = &node.ID
  3360. }
  3361. }
  3362. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3363. // executed in a transaction (ent.Tx), a transactional client is returned.
  3364. func (m AllocAgentMutation) Client() *Client {
  3365. client := &Client{config: m.config}
  3366. client.init()
  3367. return client
  3368. }
  3369. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3370. // it returns an error otherwise.
  3371. func (m AllocAgentMutation) Tx() (*Tx, error) {
  3372. if _, ok := m.driver.(*txDriver); !ok {
  3373. return nil, errors.New("ent: mutation is not running in a transaction")
  3374. }
  3375. tx := &Tx{config: m.config}
  3376. tx.init()
  3377. return tx, nil
  3378. }
  3379. // SetID sets the value of the id field. Note that this
  3380. // operation is only accepted on creation of AllocAgent entities.
  3381. func (m *AllocAgentMutation) SetID(id uint64) {
  3382. m.id = &id
  3383. }
  3384. // ID returns the ID value in the mutation. Note that the ID is only available
  3385. // if it was provided to the builder or after it was returned from the database.
  3386. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  3387. if m.id == nil {
  3388. return
  3389. }
  3390. return *m.id, true
  3391. }
  3392. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3393. // That means, if the mutation is applied within a transaction with an isolation level such
  3394. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3395. // or updated by the mutation.
  3396. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  3397. switch {
  3398. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3399. id, exists := m.ID()
  3400. if exists {
  3401. return []uint64{id}, nil
  3402. }
  3403. fallthrough
  3404. case m.op.Is(OpUpdate | OpDelete):
  3405. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  3406. default:
  3407. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3408. }
  3409. }
  3410. // SetCreatedAt sets the "created_at" field.
  3411. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  3412. m.created_at = &t
  3413. }
  3414. // CreatedAt returns the value of the "created_at" field in the mutation.
  3415. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  3416. v := m.created_at
  3417. if v == nil {
  3418. return
  3419. }
  3420. return *v, true
  3421. }
  3422. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  3423. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3424. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3425. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3426. if !m.op.Is(OpUpdateOne) {
  3427. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3428. }
  3429. if m.id == nil || m.oldValue == nil {
  3430. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3431. }
  3432. oldValue, err := m.oldValue(ctx)
  3433. if err != nil {
  3434. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3435. }
  3436. return oldValue.CreatedAt, nil
  3437. }
  3438. // ResetCreatedAt resets all changes to the "created_at" field.
  3439. func (m *AllocAgentMutation) ResetCreatedAt() {
  3440. m.created_at = nil
  3441. }
  3442. // SetUpdatedAt sets the "updated_at" field.
  3443. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  3444. m.updated_at = &t
  3445. }
  3446. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3447. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  3448. v := m.updated_at
  3449. if v == nil {
  3450. return
  3451. }
  3452. return *v, true
  3453. }
  3454. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  3455. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3456. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3457. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3458. if !m.op.Is(OpUpdateOne) {
  3459. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3460. }
  3461. if m.id == nil || m.oldValue == nil {
  3462. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3463. }
  3464. oldValue, err := m.oldValue(ctx)
  3465. if err != nil {
  3466. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3467. }
  3468. return oldValue.UpdatedAt, nil
  3469. }
  3470. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3471. func (m *AllocAgentMutation) ResetUpdatedAt() {
  3472. m.updated_at = nil
  3473. }
  3474. // SetDeletedAt sets the "deleted_at" field.
  3475. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  3476. m.deleted_at = &t
  3477. }
  3478. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3479. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  3480. v := m.deleted_at
  3481. if v == nil {
  3482. return
  3483. }
  3484. return *v, true
  3485. }
  3486. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  3487. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3489. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3490. if !m.op.Is(OpUpdateOne) {
  3491. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3492. }
  3493. if m.id == nil || m.oldValue == nil {
  3494. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3495. }
  3496. oldValue, err := m.oldValue(ctx)
  3497. if err != nil {
  3498. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3499. }
  3500. return oldValue.DeletedAt, nil
  3501. }
  3502. // ClearDeletedAt clears the value of the "deleted_at" field.
  3503. func (m *AllocAgentMutation) ClearDeletedAt() {
  3504. m.deleted_at = nil
  3505. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  3506. }
  3507. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3508. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  3509. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  3510. return ok
  3511. }
  3512. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3513. func (m *AllocAgentMutation) ResetDeletedAt() {
  3514. m.deleted_at = nil
  3515. delete(m.clearedFields, allocagent.FieldDeletedAt)
  3516. }
  3517. // SetUserID sets the "user_id" field.
  3518. func (m *AllocAgentMutation) SetUserID(s string) {
  3519. m.user_id = &s
  3520. }
  3521. // UserID returns the value of the "user_id" field in the mutation.
  3522. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  3523. v := m.user_id
  3524. if v == nil {
  3525. return
  3526. }
  3527. return *v, true
  3528. }
  3529. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  3530. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3531. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3532. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  3533. if !m.op.Is(OpUpdateOne) {
  3534. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  3535. }
  3536. if m.id == nil || m.oldValue == nil {
  3537. return v, errors.New("OldUserID requires an ID field in the mutation")
  3538. }
  3539. oldValue, err := m.oldValue(ctx)
  3540. if err != nil {
  3541. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  3542. }
  3543. return oldValue.UserID, nil
  3544. }
  3545. // ClearUserID clears the value of the "user_id" field.
  3546. func (m *AllocAgentMutation) ClearUserID() {
  3547. m.user_id = nil
  3548. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  3549. }
  3550. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  3551. func (m *AllocAgentMutation) UserIDCleared() bool {
  3552. _, ok := m.clearedFields[allocagent.FieldUserID]
  3553. return ok
  3554. }
  3555. // ResetUserID resets all changes to the "user_id" field.
  3556. func (m *AllocAgentMutation) ResetUserID() {
  3557. m.user_id = nil
  3558. delete(m.clearedFields, allocagent.FieldUserID)
  3559. }
  3560. // SetOrganizationID sets the "organization_id" field.
  3561. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  3562. m.organization_id = &u
  3563. m.addorganization_id = nil
  3564. }
  3565. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3566. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  3567. v := m.organization_id
  3568. if v == nil {
  3569. return
  3570. }
  3571. return *v, true
  3572. }
  3573. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  3574. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3575. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3576. func (m *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3577. if !m.op.Is(OpUpdateOne) {
  3578. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3579. }
  3580. if m.id == nil || m.oldValue == nil {
  3581. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3582. }
  3583. oldValue, err := m.oldValue(ctx)
  3584. if err != nil {
  3585. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3586. }
  3587. return oldValue.OrganizationID, nil
  3588. }
  3589. // AddOrganizationID adds u to the "organization_id" field.
  3590. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  3591. if m.addorganization_id != nil {
  3592. *m.addorganization_id += u
  3593. } else {
  3594. m.addorganization_id = &u
  3595. }
  3596. }
  3597. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3598. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  3599. v := m.addorganization_id
  3600. if v == nil {
  3601. return
  3602. }
  3603. return *v, true
  3604. }
  3605. // ClearOrganizationID clears the value of the "organization_id" field.
  3606. func (m *AllocAgentMutation) ClearOrganizationID() {
  3607. m.organization_id = nil
  3608. m.addorganization_id = nil
  3609. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  3610. }
  3611. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3612. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  3613. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  3614. return ok
  3615. }
  3616. // ResetOrganizationID resets all changes to the "organization_id" field.
  3617. func (m *AllocAgentMutation) ResetOrganizationID() {
  3618. m.organization_id = nil
  3619. m.addorganization_id = nil
  3620. delete(m.clearedFields, allocagent.FieldOrganizationID)
  3621. }
  3622. // SetAgents sets the "agents" field.
  3623. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  3624. m.agents = &u
  3625. m.appendagents = nil
  3626. }
  3627. // Agents returns the value of the "agents" field in the mutation.
  3628. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  3629. v := m.agents
  3630. if v == nil {
  3631. return
  3632. }
  3633. return *v, true
  3634. }
  3635. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  3636. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3637. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3638. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  3639. if !m.op.Is(OpUpdateOne) {
  3640. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  3641. }
  3642. if m.id == nil || m.oldValue == nil {
  3643. return v, errors.New("OldAgents requires an ID field in the mutation")
  3644. }
  3645. oldValue, err := m.oldValue(ctx)
  3646. if err != nil {
  3647. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  3648. }
  3649. return oldValue.Agents, nil
  3650. }
  3651. // AppendAgents adds u to the "agents" field.
  3652. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  3653. m.appendagents = append(m.appendagents, u...)
  3654. }
  3655. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  3656. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  3657. if len(m.appendagents) == 0 {
  3658. return nil, false
  3659. }
  3660. return m.appendagents, true
  3661. }
  3662. // ResetAgents resets all changes to the "agents" field.
  3663. func (m *AllocAgentMutation) ResetAgents() {
  3664. m.agents = nil
  3665. m.appendagents = nil
  3666. }
  3667. // SetStatus sets the "status" field.
  3668. func (m *AllocAgentMutation) SetStatus(i int) {
  3669. m.status = &i
  3670. m.addstatus = nil
  3671. }
  3672. // Status returns the value of the "status" field in the mutation.
  3673. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  3674. v := m.status
  3675. if v == nil {
  3676. return
  3677. }
  3678. return *v, true
  3679. }
  3680. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  3681. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3682. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3683. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  3684. if !m.op.Is(OpUpdateOne) {
  3685. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3686. }
  3687. if m.id == nil || m.oldValue == nil {
  3688. return v, errors.New("OldStatus requires an ID field in the mutation")
  3689. }
  3690. oldValue, err := m.oldValue(ctx)
  3691. if err != nil {
  3692. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3693. }
  3694. return oldValue.Status, nil
  3695. }
  3696. // AddStatus adds i to the "status" field.
  3697. func (m *AllocAgentMutation) AddStatus(i int) {
  3698. if m.addstatus != nil {
  3699. *m.addstatus += i
  3700. } else {
  3701. m.addstatus = &i
  3702. }
  3703. }
  3704. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3705. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  3706. v := m.addstatus
  3707. if v == nil {
  3708. return
  3709. }
  3710. return *v, true
  3711. }
  3712. // ClearStatus clears the value of the "status" field.
  3713. func (m *AllocAgentMutation) ClearStatus() {
  3714. m.status = nil
  3715. m.addstatus = nil
  3716. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  3717. }
  3718. // StatusCleared returns if the "status" field was cleared in this mutation.
  3719. func (m *AllocAgentMutation) StatusCleared() bool {
  3720. _, ok := m.clearedFields[allocagent.FieldStatus]
  3721. return ok
  3722. }
  3723. // ResetStatus resets all changes to the "status" field.
  3724. func (m *AllocAgentMutation) ResetStatus() {
  3725. m.status = nil
  3726. m.addstatus = nil
  3727. delete(m.clearedFields, allocagent.FieldStatus)
  3728. }
  3729. // Where appends a list predicates to the AllocAgentMutation builder.
  3730. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  3731. m.predicates = append(m.predicates, ps...)
  3732. }
  3733. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  3734. // users can use type-assertion to append predicates that do not depend on any generated package.
  3735. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  3736. p := make([]predicate.AllocAgent, len(ps))
  3737. for i := range ps {
  3738. p[i] = ps[i]
  3739. }
  3740. m.Where(p...)
  3741. }
  3742. // Op returns the operation name.
  3743. func (m *AllocAgentMutation) Op() Op {
  3744. return m.op
  3745. }
  3746. // SetOp allows setting the mutation operation.
  3747. func (m *AllocAgentMutation) SetOp(op Op) {
  3748. m.op = op
  3749. }
  3750. // Type returns the node type of this mutation (AllocAgent).
  3751. func (m *AllocAgentMutation) Type() string {
  3752. return m.typ
  3753. }
  3754. // Fields returns all fields that were changed during this mutation. Note that in
  3755. // order to get all numeric fields that were incremented/decremented, call
  3756. // AddedFields().
  3757. func (m *AllocAgentMutation) Fields() []string {
  3758. fields := make([]string, 0, 7)
  3759. if m.created_at != nil {
  3760. fields = append(fields, allocagent.FieldCreatedAt)
  3761. }
  3762. if m.updated_at != nil {
  3763. fields = append(fields, allocagent.FieldUpdatedAt)
  3764. }
  3765. if m.deleted_at != nil {
  3766. fields = append(fields, allocagent.FieldDeletedAt)
  3767. }
  3768. if m.user_id != nil {
  3769. fields = append(fields, allocagent.FieldUserID)
  3770. }
  3771. if m.organization_id != nil {
  3772. fields = append(fields, allocagent.FieldOrganizationID)
  3773. }
  3774. if m.agents != nil {
  3775. fields = append(fields, allocagent.FieldAgents)
  3776. }
  3777. if m.status != nil {
  3778. fields = append(fields, allocagent.FieldStatus)
  3779. }
  3780. return fields
  3781. }
  3782. // Field returns the value of a field with the given name. The second boolean
  3783. // return value indicates that this field was not set, or was not defined in the
  3784. // schema.
  3785. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  3786. switch name {
  3787. case allocagent.FieldCreatedAt:
  3788. return m.CreatedAt()
  3789. case allocagent.FieldUpdatedAt:
  3790. return m.UpdatedAt()
  3791. case allocagent.FieldDeletedAt:
  3792. return m.DeletedAt()
  3793. case allocagent.FieldUserID:
  3794. return m.UserID()
  3795. case allocagent.FieldOrganizationID:
  3796. return m.OrganizationID()
  3797. case allocagent.FieldAgents:
  3798. return m.Agents()
  3799. case allocagent.FieldStatus:
  3800. return m.Status()
  3801. }
  3802. return nil, false
  3803. }
  3804. // OldField returns the old value of the field from the database. An error is
  3805. // returned if the mutation operation is not UpdateOne, or the query to the
  3806. // database failed.
  3807. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3808. switch name {
  3809. case allocagent.FieldCreatedAt:
  3810. return m.OldCreatedAt(ctx)
  3811. case allocagent.FieldUpdatedAt:
  3812. return m.OldUpdatedAt(ctx)
  3813. case allocagent.FieldDeletedAt:
  3814. return m.OldDeletedAt(ctx)
  3815. case allocagent.FieldUserID:
  3816. return m.OldUserID(ctx)
  3817. case allocagent.FieldOrganizationID:
  3818. return m.OldOrganizationID(ctx)
  3819. case allocagent.FieldAgents:
  3820. return m.OldAgents(ctx)
  3821. case allocagent.FieldStatus:
  3822. return m.OldStatus(ctx)
  3823. }
  3824. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  3825. }
  3826. // SetField sets the value of a field with the given name. It returns an error if
  3827. // the field is not defined in the schema, or if the type mismatched the field
  3828. // type.
  3829. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  3830. switch name {
  3831. case allocagent.FieldCreatedAt:
  3832. v, ok := value.(time.Time)
  3833. if !ok {
  3834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3835. }
  3836. m.SetCreatedAt(v)
  3837. return nil
  3838. case allocagent.FieldUpdatedAt:
  3839. v, ok := value.(time.Time)
  3840. if !ok {
  3841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3842. }
  3843. m.SetUpdatedAt(v)
  3844. return nil
  3845. case allocagent.FieldDeletedAt:
  3846. v, ok := value.(time.Time)
  3847. if !ok {
  3848. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3849. }
  3850. m.SetDeletedAt(v)
  3851. return nil
  3852. case allocagent.FieldUserID:
  3853. v, ok := value.(string)
  3854. if !ok {
  3855. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3856. }
  3857. m.SetUserID(v)
  3858. return nil
  3859. case allocagent.FieldOrganizationID:
  3860. v, ok := value.(uint64)
  3861. if !ok {
  3862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3863. }
  3864. m.SetOrganizationID(v)
  3865. return nil
  3866. case allocagent.FieldAgents:
  3867. v, ok := value.([]uint64)
  3868. if !ok {
  3869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3870. }
  3871. m.SetAgents(v)
  3872. return nil
  3873. case allocagent.FieldStatus:
  3874. v, ok := value.(int)
  3875. if !ok {
  3876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3877. }
  3878. m.SetStatus(v)
  3879. return nil
  3880. }
  3881. return fmt.Errorf("unknown AllocAgent field %s", name)
  3882. }
  3883. // AddedFields returns all numeric fields that were incremented/decremented during
  3884. // this mutation.
  3885. func (m *AllocAgentMutation) AddedFields() []string {
  3886. var fields []string
  3887. if m.addorganization_id != nil {
  3888. fields = append(fields, allocagent.FieldOrganizationID)
  3889. }
  3890. if m.addstatus != nil {
  3891. fields = append(fields, allocagent.FieldStatus)
  3892. }
  3893. return fields
  3894. }
  3895. // AddedField returns the numeric value that was incremented/decremented on a field
  3896. // with the given name. The second boolean return value indicates that this field
  3897. // was not set, or was not defined in the schema.
  3898. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  3899. switch name {
  3900. case allocagent.FieldOrganizationID:
  3901. return m.AddedOrganizationID()
  3902. case allocagent.FieldStatus:
  3903. return m.AddedStatus()
  3904. }
  3905. return nil, false
  3906. }
  3907. // AddField adds the value to the field with the given name. It returns an error if
  3908. // the field is not defined in the schema, or if the type mismatched the field
  3909. // type.
  3910. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  3911. switch name {
  3912. case allocagent.FieldOrganizationID:
  3913. v, ok := value.(int64)
  3914. if !ok {
  3915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3916. }
  3917. m.AddOrganizationID(v)
  3918. return nil
  3919. case allocagent.FieldStatus:
  3920. v, ok := value.(int)
  3921. if !ok {
  3922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3923. }
  3924. m.AddStatus(v)
  3925. return nil
  3926. }
  3927. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  3928. }
  3929. // ClearedFields returns all nullable fields that were cleared during this
  3930. // mutation.
  3931. func (m *AllocAgentMutation) ClearedFields() []string {
  3932. var fields []string
  3933. if m.FieldCleared(allocagent.FieldDeletedAt) {
  3934. fields = append(fields, allocagent.FieldDeletedAt)
  3935. }
  3936. if m.FieldCleared(allocagent.FieldUserID) {
  3937. fields = append(fields, allocagent.FieldUserID)
  3938. }
  3939. if m.FieldCleared(allocagent.FieldOrganizationID) {
  3940. fields = append(fields, allocagent.FieldOrganizationID)
  3941. }
  3942. if m.FieldCleared(allocagent.FieldStatus) {
  3943. fields = append(fields, allocagent.FieldStatus)
  3944. }
  3945. return fields
  3946. }
  3947. // FieldCleared returns a boolean indicating if a field with the given name was
  3948. // cleared in this mutation.
  3949. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  3950. _, ok := m.clearedFields[name]
  3951. return ok
  3952. }
  3953. // ClearField clears the value of the field with the given name. It returns an
  3954. // error if the field is not defined in the schema.
  3955. func (m *AllocAgentMutation) ClearField(name string) error {
  3956. switch name {
  3957. case allocagent.FieldDeletedAt:
  3958. m.ClearDeletedAt()
  3959. return nil
  3960. case allocagent.FieldUserID:
  3961. m.ClearUserID()
  3962. return nil
  3963. case allocagent.FieldOrganizationID:
  3964. m.ClearOrganizationID()
  3965. return nil
  3966. case allocagent.FieldStatus:
  3967. m.ClearStatus()
  3968. return nil
  3969. }
  3970. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  3971. }
  3972. // ResetField resets all changes in the mutation for the field with the given name.
  3973. // It returns an error if the field is not defined in the schema.
  3974. func (m *AllocAgentMutation) ResetField(name string) error {
  3975. switch name {
  3976. case allocagent.FieldCreatedAt:
  3977. m.ResetCreatedAt()
  3978. return nil
  3979. case allocagent.FieldUpdatedAt:
  3980. m.ResetUpdatedAt()
  3981. return nil
  3982. case allocagent.FieldDeletedAt:
  3983. m.ResetDeletedAt()
  3984. return nil
  3985. case allocagent.FieldUserID:
  3986. m.ResetUserID()
  3987. return nil
  3988. case allocagent.FieldOrganizationID:
  3989. m.ResetOrganizationID()
  3990. return nil
  3991. case allocagent.FieldAgents:
  3992. m.ResetAgents()
  3993. return nil
  3994. case allocagent.FieldStatus:
  3995. m.ResetStatus()
  3996. return nil
  3997. }
  3998. return fmt.Errorf("unknown AllocAgent field %s", name)
  3999. }
  4000. // AddedEdges returns all edge names that were set/added in this mutation.
  4001. func (m *AllocAgentMutation) AddedEdges() []string {
  4002. edges := make([]string, 0, 0)
  4003. return edges
  4004. }
  4005. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4006. // name in this mutation.
  4007. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  4008. return nil
  4009. }
  4010. // RemovedEdges returns all edge names that were removed in this mutation.
  4011. func (m *AllocAgentMutation) RemovedEdges() []string {
  4012. edges := make([]string, 0, 0)
  4013. return edges
  4014. }
  4015. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4016. // the given name in this mutation.
  4017. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  4018. return nil
  4019. }
  4020. // ClearedEdges returns all edge names that were cleared in this mutation.
  4021. func (m *AllocAgentMutation) ClearedEdges() []string {
  4022. edges := make([]string, 0, 0)
  4023. return edges
  4024. }
  4025. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4026. // was cleared in this mutation.
  4027. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  4028. return false
  4029. }
  4030. // ClearEdge clears the value of the edge with the given name. It returns an error
  4031. // if that edge is not defined in the schema.
  4032. func (m *AllocAgentMutation) ClearEdge(name string) error {
  4033. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  4034. }
  4035. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4036. // It returns an error if the edge is not defined in the schema.
  4037. func (m *AllocAgentMutation) ResetEdge(name string) error {
  4038. return fmt.Errorf("unknown AllocAgent edge %s", name)
  4039. }
  4040. // ApiKeyMutation represents an operation that mutates the ApiKey nodes in the graph.
  4041. type ApiKeyMutation struct {
  4042. config
  4043. op Op
  4044. typ string
  4045. id *uint64
  4046. created_at *time.Time
  4047. updated_at *time.Time
  4048. deleted_at *time.Time
  4049. title *string
  4050. key *string
  4051. organization_id *uint64
  4052. addorganization_id *int64
  4053. custom_agent_base *string
  4054. custom_agent_key *string
  4055. openai_base *string
  4056. openai_key *string
  4057. clearedFields map[string]struct{}
  4058. agent *uint64
  4059. clearedagent bool
  4060. done bool
  4061. oldValue func(context.Context) (*ApiKey, error)
  4062. predicates []predicate.ApiKey
  4063. }
  4064. var _ ent.Mutation = (*ApiKeyMutation)(nil)
  4065. // apikeyOption allows management of the mutation configuration using functional options.
  4066. type apikeyOption func(*ApiKeyMutation)
  4067. // newApiKeyMutation creates new mutation for the ApiKey entity.
  4068. func newApiKeyMutation(c config, op Op, opts ...apikeyOption) *ApiKeyMutation {
  4069. m := &ApiKeyMutation{
  4070. config: c,
  4071. op: op,
  4072. typ: TypeApiKey,
  4073. clearedFields: make(map[string]struct{}),
  4074. }
  4075. for _, opt := range opts {
  4076. opt(m)
  4077. }
  4078. return m
  4079. }
  4080. // withApiKeyID sets the ID field of the mutation.
  4081. func withApiKeyID(id uint64) apikeyOption {
  4082. return func(m *ApiKeyMutation) {
  4083. var (
  4084. err error
  4085. once sync.Once
  4086. value *ApiKey
  4087. )
  4088. m.oldValue = func(ctx context.Context) (*ApiKey, error) {
  4089. once.Do(func() {
  4090. if m.done {
  4091. err = errors.New("querying old values post mutation is not allowed")
  4092. } else {
  4093. value, err = m.Client().ApiKey.Get(ctx, id)
  4094. }
  4095. })
  4096. return value, err
  4097. }
  4098. m.id = &id
  4099. }
  4100. }
  4101. // withApiKey sets the old ApiKey of the mutation.
  4102. func withApiKey(node *ApiKey) apikeyOption {
  4103. return func(m *ApiKeyMutation) {
  4104. m.oldValue = func(context.Context) (*ApiKey, error) {
  4105. return node, nil
  4106. }
  4107. m.id = &node.ID
  4108. }
  4109. }
  4110. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4111. // executed in a transaction (ent.Tx), a transactional client is returned.
  4112. func (m ApiKeyMutation) Client() *Client {
  4113. client := &Client{config: m.config}
  4114. client.init()
  4115. return client
  4116. }
  4117. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4118. // it returns an error otherwise.
  4119. func (m ApiKeyMutation) Tx() (*Tx, error) {
  4120. if _, ok := m.driver.(*txDriver); !ok {
  4121. return nil, errors.New("ent: mutation is not running in a transaction")
  4122. }
  4123. tx := &Tx{config: m.config}
  4124. tx.init()
  4125. return tx, nil
  4126. }
  4127. // SetID sets the value of the id field. Note that this
  4128. // operation is only accepted on creation of ApiKey entities.
  4129. func (m *ApiKeyMutation) SetID(id uint64) {
  4130. m.id = &id
  4131. }
  4132. // ID returns the ID value in the mutation. Note that the ID is only available
  4133. // if it was provided to the builder or after it was returned from the database.
  4134. func (m *ApiKeyMutation) ID() (id uint64, exists bool) {
  4135. if m.id == nil {
  4136. return
  4137. }
  4138. return *m.id, true
  4139. }
  4140. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4141. // That means, if the mutation is applied within a transaction with an isolation level such
  4142. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4143. // or updated by the mutation.
  4144. func (m *ApiKeyMutation) IDs(ctx context.Context) ([]uint64, error) {
  4145. switch {
  4146. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4147. id, exists := m.ID()
  4148. if exists {
  4149. return []uint64{id}, nil
  4150. }
  4151. fallthrough
  4152. case m.op.Is(OpUpdate | OpDelete):
  4153. return m.Client().ApiKey.Query().Where(m.predicates...).IDs(ctx)
  4154. default:
  4155. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4156. }
  4157. }
  4158. // SetCreatedAt sets the "created_at" field.
  4159. func (m *ApiKeyMutation) SetCreatedAt(t time.Time) {
  4160. m.created_at = &t
  4161. }
  4162. // CreatedAt returns the value of the "created_at" field in the mutation.
  4163. func (m *ApiKeyMutation) CreatedAt() (r time.Time, exists bool) {
  4164. v := m.created_at
  4165. if v == nil {
  4166. return
  4167. }
  4168. return *v, true
  4169. }
  4170. // OldCreatedAt returns the old "created_at" field's value of the ApiKey entity.
  4171. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4172. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4173. func (m *ApiKeyMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4174. if !m.op.Is(OpUpdateOne) {
  4175. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4176. }
  4177. if m.id == nil || m.oldValue == nil {
  4178. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4179. }
  4180. oldValue, err := m.oldValue(ctx)
  4181. if err != nil {
  4182. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4183. }
  4184. return oldValue.CreatedAt, nil
  4185. }
  4186. // ResetCreatedAt resets all changes to the "created_at" field.
  4187. func (m *ApiKeyMutation) ResetCreatedAt() {
  4188. m.created_at = nil
  4189. }
  4190. // SetUpdatedAt sets the "updated_at" field.
  4191. func (m *ApiKeyMutation) SetUpdatedAt(t time.Time) {
  4192. m.updated_at = &t
  4193. }
  4194. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4195. func (m *ApiKeyMutation) UpdatedAt() (r time.Time, exists bool) {
  4196. v := m.updated_at
  4197. if v == nil {
  4198. return
  4199. }
  4200. return *v, true
  4201. }
  4202. // OldUpdatedAt returns the old "updated_at" field's value of the ApiKey entity.
  4203. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4204. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4205. func (m *ApiKeyMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4206. if !m.op.Is(OpUpdateOne) {
  4207. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4208. }
  4209. if m.id == nil || m.oldValue == nil {
  4210. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4211. }
  4212. oldValue, err := m.oldValue(ctx)
  4213. if err != nil {
  4214. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4215. }
  4216. return oldValue.UpdatedAt, nil
  4217. }
  4218. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4219. func (m *ApiKeyMutation) ResetUpdatedAt() {
  4220. m.updated_at = nil
  4221. }
  4222. // SetDeletedAt sets the "deleted_at" field.
  4223. func (m *ApiKeyMutation) SetDeletedAt(t time.Time) {
  4224. m.deleted_at = &t
  4225. }
  4226. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4227. func (m *ApiKeyMutation) DeletedAt() (r time.Time, exists bool) {
  4228. v := m.deleted_at
  4229. if v == nil {
  4230. return
  4231. }
  4232. return *v, true
  4233. }
  4234. // OldDeletedAt returns the old "deleted_at" field's value of the ApiKey entity.
  4235. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4236. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4237. func (m *ApiKeyMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4238. if !m.op.Is(OpUpdateOne) {
  4239. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4240. }
  4241. if m.id == nil || m.oldValue == nil {
  4242. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4243. }
  4244. oldValue, err := m.oldValue(ctx)
  4245. if err != nil {
  4246. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4247. }
  4248. return oldValue.DeletedAt, nil
  4249. }
  4250. // ClearDeletedAt clears the value of the "deleted_at" field.
  4251. func (m *ApiKeyMutation) ClearDeletedAt() {
  4252. m.deleted_at = nil
  4253. m.clearedFields[apikey.FieldDeletedAt] = struct{}{}
  4254. }
  4255. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4256. func (m *ApiKeyMutation) DeletedAtCleared() bool {
  4257. _, ok := m.clearedFields[apikey.FieldDeletedAt]
  4258. return ok
  4259. }
  4260. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4261. func (m *ApiKeyMutation) ResetDeletedAt() {
  4262. m.deleted_at = nil
  4263. delete(m.clearedFields, apikey.FieldDeletedAt)
  4264. }
  4265. // SetTitle sets the "title" field.
  4266. func (m *ApiKeyMutation) SetTitle(s string) {
  4267. m.title = &s
  4268. }
  4269. // Title returns the value of the "title" field in the mutation.
  4270. func (m *ApiKeyMutation) Title() (r string, exists bool) {
  4271. v := m.title
  4272. if v == nil {
  4273. return
  4274. }
  4275. return *v, true
  4276. }
  4277. // OldTitle returns the old "title" field's value of the ApiKey entity.
  4278. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4279. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4280. func (m *ApiKeyMutation) OldTitle(ctx context.Context) (v string, err error) {
  4281. if !m.op.Is(OpUpdateOne) {
  4282. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  4283. }
  4284. if m.id == nil || m.oldValue == nil {
  4285. return v, errors.New("OldTitle requires an ID field in the mutation")
  4286. }
  4287. oldValue, err := m.oldValue(ctx)
  4288. if err != nil {
  4289. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  4290. }
  4291. return oldValue.Title, nil
  4292. }
  4293. // ClearTitle clears the value of the "title" field.
  4294. func (m *ApiKeyMutation) ClearTitle() {
  4295. m.title = nil
  4296. m.clearedFields[apikey.FieldTitle] = struct{}{}
  4297. }
  4298. // TitleCleared returns if the "title" field was cleared in this mutation.
  4299. func (m *ApiKeyMutation) TitleCleared() bool {
  4300. _, ok := m.clearedFields[apikey.FieldTitle]
  4301. return ok
  4302. }
  4303. // ResetTitle resets all changes to the "title" field.
  4304. func (m *ApiKeyMutation) ResetTitle() {
  4305. m.title = nil
  4306. delete(m.clearedFields, apikey.FieldTitle)
  4307. }
  4308. // SetKey sets the "key" field.
  4309. func (m *ApiKeyMutation) SetKey(s string) {
  4310. m.key = &s
  4311. }
  4312. // Key returns the value of the "key" field in the mutation.
  4313. func (m *ApiKeyMutation) Key() (r string, exists bool) {
  4314. v := m.key
  4315. if v == nil {
  4316. return
  4317. }
  4318. return *v, true
  4319. }
  4320. // OldKey returns the old "key" field's value of the ApiKey entity.
  4321. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4322. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4323. func (m *ApiKeyMutation) OldKey(ctx context.Context) (v string, err error) {
  4324. if !m.op.Is(OpUpdateOne) {
  4325. return v, errors.New("OldKey is only allowed on UpdateOne operations")
  4326. }
  4327. if m.id == nil || m.oldValue == nil {
  4328. return v, errors.New("OldKey requires an ID field in the mutation")
  4329. }
  4330. oldValue, err := m.oldValue(ctx)
  4331. if err != nil {
  4332. return v, fmt.Errorf("querying old value for OldKey: %w", err)
  4333. }
  4334. return oldValue.Key, nil
  4335. }
  4336. // ClearKey clears the value of the "key" field.
  4337. func (m *ApiKeyMutation) ClearKey() {
  4338. m.key = nil
  4339. m.clearedFields[apikey.FieldKey] = struct{}{}
  4340. }
  4341. // KeyCleared returns if the "key" field was cleared in this mutation.
  4342. func (m *ApiKeyMutation) KeyCleared() bool {
  4343. _, ok := m.clearedFields[apikey.FieldKey]
  4344. return ok
  4345. }
  4346. // ResetKey resets all changes to the "key" field.
  4347. func (m *ApiKeyMutation) ResetKey() {
  4348. m.key = nil
  4349. delete(m.clearedFields, apikey.FieldKey)
  4350. }
  4351. // SetOrganizationID sets the "organization_id" field.
  4352. func (m *ApiKeyMutation) SetOrganizationID(u uint64) {
  4353. m.organization_id = &u
  4354. m.addorganization_id = nil
  4355. }
  4356. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4357. func (m *ApiKeyMutation) OrganizationID() (r uint64, exists bool) {
  4358. v := m.organization_id
  4359. if v == nil {
  4360. return
  4361. }
  4362. return *v, true
  4363. }
  4364. // OldOrganizationID returns the old "organization_id" field's value of the ApiKey entity.
  4365. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4366. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4367. func (m *ApiKeyMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4368. if !m.op.Is(OpUpdateOne) {
  4369. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4370. }
  4371. if m.id == nil || m.oldValue == nil {
  4372. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4373. }
  4374. oldValue, err := m.oldValue(ctx)
  4375. if err != nil {
  4376. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4377. }
  4378. return oldValue.OrganizationID, nil
  4379. }
  4380. // AddOrganizationID adds u to the "organization_id" field.
  4381. func (m *ApiKeyMutation) AddOrganizationID(u int64) {
  4382. if m.addorganization_id != nil {
  4383. *m.addorganization_id += u
  4384. } else {
  4385. m.addorganization_id = &u
  4386. }
  4387. }
  4388. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4389. func (m *ApiKeyMutation) AddedOrganizationID() (r int64, exists bool) {
  4390. v := m.addorganization_id
  4391. if v == nil {
  4392. return
  4393. }
  4394. return *v, true
  4395. }
  4396. // ResetOrganizationID resets all changes to the "organization_id" field.
  4397. func (m *ApiKeyMutation) ResetOrganizationID() {
  4398. m.organization_id = nil
  4399. m.addorganization_id = nil
  4400. }
  4401. // SetAgentID sets the "agent_id" field.
  4402. func (m *ApiKeyMutation) SetAgentID(u uint64) {
  4403. m.agent = &u
  4404. }
  4405. // AgentID returns the value of the "agent_id" field in the mutation.
  4406. func (m *ApiKeyMutation) AgentID() (r uint64, exists bool) {
  4407. v := m.agent
  4408. if v == nil {
  4409. return
  4410. }
  4411. return *v, true
  4412. }
  4413. // OldAgentID returns the old "agent_id" field's value of the ApiKey entity.
  4414. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4415. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4416. func (m *ApiKeyMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  4417. if !m.op.Is(OpUpdateOne) {
  4418. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  4419. }
  4420. if m.id == nil || m.oldValue == nil {
  4421. return v, errors.New("OldAgentID requires an ID field in the mutation")
  4422. }
  4423. oldValue, err := m.oldValue(ctx)
  4424. if err != nil {
  4425. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  4426. }
  4427. return oldValue.AgentID, nil
  4428. }
  4429. // ResetAgentID resets all changes to the "agent_id" field.
  4430. func (m *ApiKeyMutation) ResetAgentID() {
  4431. m.agent = nil
  4432. }
  4433. // SetCustomAgentBase sets the "custom_agent_base" field.
  4434. func (m *ApiKeyMutation) SetCustomAgentBase(s string) {
  4435. m.custom_agent_base = &s
  4436. }
  4437. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  4438. func (m *ApiKeyMutation) CustomAgentBase() (r string, exists bool) {
  4439. v := m.custom_agent_base
  4440. if v == nil {
  4441. return
  4442. }
  4443. return *v, true
  4444. }
  4445. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the ApiKey entity.
  4446. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4447. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4448. func (m *ApiKeyMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  4449. if !m.op.Is(OpUpdateOne) {
  4450. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  4451. }
  4452. if m.id == nil || m.oldValue == nil {
  4453. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  4454. }
  4455. oldValue, err := m.oldValue(ctx)
  4456. if err != nil {
  4457. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  4458. }
  4459. return oldValue.CustomAgentBase, nil
  4460. }
  4461. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  4462. func (m *ApiKeyMutation) ClearCustomAgentBase() {
  4463. m.custom_agent_base = nil
  4464. m.clearedFields[apikey.FieldCustomAgentBase] = struct{}{}
  4465. }
  4466. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  4467. func (m *ApiKeyMutation) CustomAgentBaseCleared() bool {
  4468. _, ok := m.clearedFields[apikey.FieldCustomAgentBase]
  4469. return ok
  4470. }
  4471. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  4472. func (m *ApiKeyMutation) ResetCustomAgentBase() {
  4473. m.custom_agent_base = nil
  4474. delete(m.clearedFields, apikey.FieldCustomAgentBase)
  4475. }
  4476. // SetCustomAgentKey sets the "custom_agent_key" field.
  4477. func (m *ApiKeyMutation) SetCustomAgentKey(s string) {
  4478. m.custom_agent_key = &s
  4479. }
  4480. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  4481. func (m *ApiKeyMutation) CustomAgentKey() (r string, exists bool) {
  4482. v := m.custom_agent_key
  4483. if v == nil {
  4484. return
  4485. }
  4486. return *v, true
  4487. }
  4488. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the ApiKey entity.
  4489. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4490. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4491. func (m *ApiKeyMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  4492. if !m.op.Is(OpUpdateOne) {
  4493. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  4494. }
  4495. if m.id == nil || m.oldValue == nil {
  4496. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  4497. }
  4498. oldValue, err := m.oldValue(ctx)
  4499. if err != nil {
  4500. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  4501. }
  4502. return oldValue.CustomAgentKey, nil
  4503. }
  4504. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  4505. func (m *ApiKeyMutation) ClearCustomAgentKey() {
  4506. m.custom_agent_key = nil
  4507. m.clearedFields[apikey.FieldCustomAgentKey] = struct{}{}
  4508. }
  4509. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  4510. func (m *ApiKeyMutation) CustomAgentKeyCleared() bool {
  4511. _, ok := m.clearedFields[apikey.FieldCustomAgentKey]
  4512. return ok
  4513. }
  4514. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  4515. func (m *ApiKeyMutation) ResetCustomAgentKey() {
  4516. m.custom_agent_key = nil
  4517. delete(m.clearedFields, apikey.FieldCustomAgentKey)
  4518. }
  4519. // SetOpenaiBase sets the "openai_base" field.
  4520. func (m *ApiKeyMutation) SetOpenaiBase(s string) {
  4521. m.openai_base = &s
  4522. }
  4523. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  4524. func (m *ApiKeyMutation) OpenaiBase() (r string, exists bool) {
  4525. v := m.openai_base
  4526. if v == nil {
  4527. return
  4528. }
  4529. return *v, true
  4530. }
  4531. // OldOpenaiBase returns the old "openai_base" field's value of the ApiKey entity.
  4532. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4533. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4534. func (m *ApiKeyMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  4535. if !m.op.Is(OpUpdateOne) {
  4536. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  4537. }
  4538. if m.id == nil || m.oldValue == nil {
  4539. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  4540. }
  4541. oldValue, err := m.oldValue(ctx)
  4542. if err != nil {
  4543. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  4544. }
  4545. return oldValue.OpenaiBase, nil
  4546. }
  4547. // ClearOpenaiBase clears the value of the "openai_base" field.
  4548. func (m *ApiKeyMutation) ClearOpenaiBase() {
  4549. m.openai_base = nil
  4550. m.clearedFields[apikey.FieldOpenaiBase] = struct{}{}
  4551. }
  4552. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  4553. func (m *ApiKeyMutation) OpenaiBaseCleared() bool {
  4554. _, ok := m.clearedFields[apikey.FieldOpenaiBase]
  4555. return ok
  4556. }
  4557. // ResetOpenaiBase resets all changes to the "openai_base" field.
  4558. func (m *ApiKeyMutation) ResetOpenaiBase() {
  4559. m.openai_base = nil
  4560. delete(m.clearedFields, apikey.FieldOpenaiBase)
  4561. }
  4562. // SetOpenaiKey sets the "openai_key" field.
  4563. func (m *ApiKeyMutation) SetOpenaiKey(s string) {
  4564. m.openai_key = &s
  4565. }
  4566. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  4567. func (m *ApiKeyMutation) OpenaiKey() (r string, exists bool) {
  4568. v := m.openai_key
  4569. if v == nil {
  4570. return
  4571. }
  4572. return *v, true
  4573. }
  4574. // OldOpenaiKey returns the old "openai_key" field's value of the ApiKey entity.
  4575. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4576. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4577. func (m *ApiKeyMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  4578. if !m.op.Is(OpUpdateOne) {
  4579. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  4580. }
  4581. if m.id == nil || m.oldValue == nil {
  4582. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  4583. }
  4584. oldValue, err := m.oldValue(ctx)
  4585. if err != nil {
  4586. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  4587. }
  4588. return oldValue.OpenaiKey, nil
  4589. }
  4590. // ClearOpenaiKey clears the value of the "openai_key" field.
  4591. func (m *ApiKeyMutation) ClearOpenaiKey() {
  4592. m.openai_key = nil
  4593. m.clearedFields[apikey.FieldOpenaiKey] = struct{}{}
  4594. }
  4595. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  4596. func (m *ApiKeyMutation) OpenaiKeyCleared() bool {
  4597. _, ok := m.clearedFields[apikey.FieldOpenaiKey]
  4598. return ok
  4599. }
  4600. // ResetOpenaiKey resets all changes to the "openai_key" field.
  4601. func (m *ApiKeyMutation) ResetOpenaiKey() {
  4602. m.openai_key = nil
  4603. delete(m.clearedFields, apikey.FieldOpenaiKey)
  4604. }
  4605. // ClearAgent clears the "agent" edge to the Agent entity.
  4606. func (m *ApiKeyMutation) ClearAgent() {
  4607. m.clearedagent = true
  4608. m.clearedFields[apikey.FieldAgentID] = struct{}{}
  4609. }
  4610. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  4611. func (m *ApiKeyMutation) AgentCleared() bool {
  4612. return m.clearedagent
  4613. }
  4614. // AgentIDs returns the "agent" edge IDs in the mutation.
  4615. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  4616. // AgentID instead. It exists only for internal usage by the builders.
  4617. func (m *ApiKeyMutation) AgentIDs() (ids []uint64) {
  4618. if id := m.agent; id != nil {
  4619. ids = append(ids, *id)
  4620. }
  4621. return
  4622. }
  4623. // ResetAgent resets all changes to the "agent" edge.
  4624. func (m *ApiKeyMutation) ResetAgent() {
  4625. m.agent = nil
  4626. m.clearedagent = false
  4627. }
  4628. // Where appends a list predicates to the ApiKeyMutation builder.
  4629. func (m *ApiKeyMutation) Where(ps ...predicate.ApiKey) {
  4630. m.predicates = append(m.predicates, ps...)
  4631. }
  4632. // WhereP appends storage-level predicates to the ApiKeyMutation builder. Using this method,
  4633. // users can use type-assertion to append predicates that do not depend on any generated package.
  4634. func (m *ApiKeyMutation) WhereP(ps ...func(*sql.Selector)) {
  4635. p := make([]predicate.ApiKey, len(ps))
  4636. for i := range ps {
  4637. p[i] = ps[i]
  4638. }
  4639. m.Where(p...)
  4640. }
  4641. // Op returns the operation name.
  4642. func (m *ApiKeyMutation) Op() Op {
  4643. return m.op
  4644. }
  4645. // SetOp allows setting the mutation operation.
  4646. func (m *ApiKeyMutation) SetOp(op Op) {
  4647. m.op = op
  4648. }
  4649. // Type returns the node type of this mutation (ApiKey).
  4650. func (m *ApiKeyMutation) Type() string {
  4651. return m.typ
  4652. }
  4653. // Fields returns all fields that were changed during this mutation. Note that in
  4654. // order to get all numeric fields that were incremented/decremented, call
  4655. // AddedFields().
  4656. func (m *ApiKeyMutation) Fields() []string {
  4657. fields := make([]string, 0, 11)
  4658. if m.created_at != nil {
  4659. fields = append(fields, apikey.FieldCreatedAt)
  4660. }
  4661. if m.updated_at != nil {
  4662. fields = append(fields, apikey.FieldUpdatedAt)
  4663. }
  4664. if m.deleted_at != nil {
  4665. fields = append(fields, apikey.FieldDeletedAt)
  4666. }
  4667. if m.title != nil {
  4668. fields = append(fields, apikey.FieldTitle)
  4669. }
  4670. if m.key != nil {
  4671. fields = append(fields, apikey.FieldKey)
  4672. }
  4673. if m.organization_id != nil {
  4674. fields = append(fields, apikey.FieldOrganizationID)
  4675. }
  4676. if m.agent != nil {
  4677. fields = append(fields, apikey.FieldAgentID)
  4678. }
  4679. if m.custom_agent_base != nil {
  4680. fields = append(fields, apikey.FieldCustomAgentBase)
  4681. }
  4682. if m.custom_agent_key != nil {
  4683. fields = append(fields, apikey.FieldCustomAgentKey)
  4684. }
  4685. if m.openai_base != nil {
  4686. fields = append(fields, apikey.FieldOpenaiBase)
  4687. }
  4688. if m.openai_key != nil {
  4689. fields = append(fields, apikey.FieldOpenaiKey)
  4690. }
  4691. return fields
  4692. }
  4693. // Field returns the value of a field with the given name. The second boolean
  4694. // return value indicates that this field was not set, or was not defined in the
  4695. // schema.
  4696. func (m *ApiKeyMutation) Field(name string) (ent.Value, bool) {
  4697. switch name {
  4698. case apikey.FieldCreatedAt:
  4699. return m.CreatedAt()
  4700. case apikey.FieldUpdatedAt:
  4701. return m.UpdatedAt()
  4702. case apikey.FieldDeletedAt:
  4703. return m.DeletedAt()
  4704. case apikey.FieldTitle:
  4705. return m.Title()
  4706. case apikey.FieldKey:
  4707. return m.Key()
  4708. case apikey.FieldOrganizationID:
  4709. return m.OrganizationID()
  4710. case apikey.FieldAgentID:
  4711. return m.AgentID()
  4712. case apikey.FieldCustomAgentBase:
  4713. return m.CustomAgentBase()
  4714. case apikey.FieldCustomAgentKey:
  4715. return m.CustomAgentKey()
  4716. case apikey.FieldOpenaiBase:
  4717. return m.OpenaiBase()
  4718. case apikey.FieldOpenaiKey:
  4719. return m.OpenaiKey()
  4720. }
  4721. return nil, false
  4722. }
  4723. // OldField returns the old value of the field from the database. An error is
  4724. // returned if the mutation operation is not UpdateOne, or the query to the
  4725. // database failed.
  4726. func (m *ApiKeyMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4727. switch name {
  4728. case apikey.FieldCreatedAt:
  4729. return m.OldCreatedAt(ctx)
  4730. case apikey.FieldUpdatedAt:
  4731. return m.OldUpdatedAt(ctx)
  4732. case apikey.FieldDeletedAt:
  4733. return m.OldDeletedAt(ctx)
  4734. case apikey.FieldTitle:
  4735. return m.OldTitle(ctx)
  4736. case apikey.FieldKey:
  4737. return m.OldKey(ctx)
  4738. case apikey.FieldOrganizationID:
  4739. return m.OldOrganizationID(ctx)
  4740. case apikey.FieldAgentID:
  4741. return m.OldAgentID(ctx)
  4742. case apikey.FieldCustomAgentBase:
  4743. return m.OldCustomAgentBase(ctx)
  4744. case apikey.FieldCustomAgentKey:
  4745. return m.OldCustomAgentKey(ctx)
  4746. case apikey.FieldOpenaiBase:
  4747. return m.OldOpenaiBase(ctx)
  4748. case apikey.FieldOpenaiKey:
  4749. return m.OldOpenaiKey(ctx)
  4750. }
  4751. return nil, fmt.Errorf("unknown ApiKey field %s", name)
  4752. }
  4753. // SetField sets the value of a field with the given name. It returns an error if
  4754. // the field is not defined in the schema, or if the type mismatched the field
  4755. // type.
  4756. func (m *ApiKeyMutation) SetField(name string, value ent.Value) error {
  4757. switch name {
  4758. case apikey.FieldCreatedAt:
  4759. v, ok := value.(time.Time)
  4760. if !ok {
  4761. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4762. }
  4763. m.SetCreatedAt(v)
  4764. return nil
  4765. case apikey.FieldUpdatedAt:
  4766. v, ok := value.(time.Time)
  4767. if !ok {
  4768. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4769. }
  4770. m.SetUpdatedAt(v)
  4771. return nil
  4772. case apikey.FieldDeletedAt:
  4773. v, ok := value.(time.Time)
  4774. if !ok {
  4775. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4776. }
  4777. m.SetDeletedAt(v)
  4778. return nil
  4779. case apikey.FieldTitle:
  4780. v, ok := value.(string)
  4781. if !ok {
  4782. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4783. }
  4784. m.SetTitle(v)
  4785. return nil
  4786. case apikey.FieldKey:
  4787. v, ok := value.(string)
  4788. if !ok {
  4789. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4790. }
  4791. m.SetKey(v)
  4792. return nil
  4793. case apikey.FieldOrganizationID:
  4794. v, ok := value.(uint64)
  4795. if !ok {
  4796. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4797. }
  4798. m.SetOrganizationID(v)
  4799. return nil
  4800. case apikey.FieldAgentID:
  4801. v, ok := value.(uint64)
  4802. if !ok {
  4803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4804. }
  4805. m.SetAgentID(v)
  4806. return nil
  4807. case apikey.FieldCustomAgentBase:
  4808. v, ok := value.(string)
  4809. if !ok {
  4810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4811. }
  4812. m.SetCustomAgentBase(v)
  4813. return nil
  4814. case apikey.FieldCustomAgentKey:
  4815. v, ok := value.(string)
  4816. if !ok {
  4817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4818. }
  4819. m.SetCustomAgentKey(v)
  4820. return nil
  4821. case apikey.FieldOpenaiBase:
  4822. v, ok := value.(string)
  4823. if !ok {
  4824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4825. }
  4826. m.SetOpenaiBase(v)
  4827. return nil
  4828. case apikey.FieldOpenaiKey:
  4829. v, ok := value.(string)
  4830. if !ok {
  4831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4832. }
  4833. m.SetOpenaiKey(v)
  4834. return nil
  4835. }
  4836. return fmt.Errorf("unknown ApiKey field %s", name)
  4837. }
  4838. // AddedFields returns all numeric fields that were incremented/decremented during
  4839. // this mutation.
  4840. func (m *ApiKeyMutation) AddedFields() []string {
  4841. var fields []string
  4842. if m.addorganization_id != nil {
  4843. fields = append(fields, apikey.FieldOrganizationID)
  4844. }
  4845. return fields
  4846. }
  4847. // AddedField returns the numeric value that was incremented/decremented on a field
  4848. // with the given name. The second boolean return value indicates that this field
  4849. // was not set, or was not defined in the schema.
  4850. func (m *ApiKeyMutation) AddedField(name string) (ent.Value, bool) {
  4851. switch name {
  4852. case apikey.FieldOrganizationID:
  4853. return m.AddedOrganizationID()
  4854. }
  4855. return nil, false
  4856. }
  4857. // AddField adds the value to the field with the given name. It returns an error if
  4858. // the field is not defined in the schema, or if the type mismatched the field
  4859. // type.
  4860. func (m *ApiKeyMutation) AddField(name string, value ent.Value) error {
  4861. switch name {
  4862. case apikey.FieldOrganizationID:
  4863. v, ok := value.(int64)
  4864. if !ok {
  4865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4866. }
  4867. m.AddOrganizationID(v)
  4868. return nil
  4869. }
  4870. return fmt.Errorf("unknown ApiKey numeric field %s", name)
  4871. }
  4872. // ClearedFields returns all nullable fields that were cleared during this
  4873. // mutation.
  4874. func (m *ApiKeyMutation) ClearedFields() []string {
  4875. var fields []string
  4876. if m.FieldCleared(apikey.FieldDeletedAt) {
  4877. fields = append(fields, apikey.FieldDeletedAt)
  4878. }
  4879. if m.FieldCleared(apikey.FieldTitle) {
  4880. fields = append(fields, apikey.FieldTitle)
  4881. }
  4882. if m.FieldCleared(apikey.FieldKey) {
  4883. fields = append(fields, apikey.FieldKey)
  4884. }
  4885. if m.FieldCleared(apikey.FieldCustomAgentBase) {
  4886. fields = append(fields, apikey.FieldCustomAgentBase)
  4887. }
  4888. if m.FieldCleared(apikey.FieldCustomAgentKey) {
  4889. fields = append(fields, apikey.FieldCustomAgentKey)
  4890. }
  4891. if m.FieldCleared(apikey.FieldOpenaiBase) {
  4892. fields = append(fields, apikey.FieldOpenaiBase)
  4893. }
  4894. if m.FieldCleared(apikey.FieldOpenaiKey) {
  4895. fields = append(fields, apikey.FieldOpenaiKey)
  4896. }
  4897. return fields
  4898. }
  4899. // FieldCleared returns a boolean indicating if a field with the given name was
  4900. // cleared in this mutation.
  4901. func (m *ApiKeyMutation) FieldCleared(name string) bool {
  4902. _, ok := m.clearedFields[name]
  4903. return ok
  4904. }
  4905. // ClearField clears the value of the field with the given name. It returns an
  4906. // error if the field is not defined in the schema.
  4907. func (m *ApiKeyMutation) ClearField(name string) error {
  4908. switch name {
  4909. case apikey.FieldDeletedAt:
  4910. m.ClearDeletedAt()
  4911. return nil
  4912. case apikey.FieldTitle:
  4913. m.ClearTitle()
  4914. return nil
  4915. case apikey.FieldKey:
  4916. m.ClearKey()
  4917. return nil
  4918. case apikey.FieldCustomAgentBase:
  4919. m.ClearCustomAgentBase()
  4920. return nil
  4921. case apikey.FieldCustomAgentKey:
  4922. m.ClearCustomAgentKey()
  4923. return nil
  4924. case apikey.FieldOpenaiBase:
  4925. m.ClearOpenaiBase()
  4926. return nil
  4927. case apikey.FieldOpenaiKey:
  4928. m.ClearOpenaiKey()
  4929. return nil
  4930. }
  4931. return fmt.Errorf("unknown ApiKey nullable field %s", name)
  4932. }
  4933. // ResetField resets all changes in the mutation for the field with the given name.
  4934. // It returns an error if the field is not defined in the schema.
  4935. func (m *ApiKeyMutation) ResetField(name string) error {
  4936. switch name {
  4937. case apikey.FieldCreatedAt:
  4938. m.ResetCreatedAt()
  4939. return nil
  4940. case apikey.FieldUpdatedAt:
  4941. m.ResetUpdatedAt()
  4942. return nil
  4943. case apikey.FieldDeletedAt:
  4944. m.ResetDeletedAt()
  4945. return nil
  4946. case apikey.FieldTitle:
  4947. m.ResetTitle()
  4948. return nil
  4949. case apikey.FieldKey:
  4950. m.ResetKey()
  4951. return nil
  4952. case apikey.FieldOrganizationID:
  4953. m.ResetOrganizationID()
  4954. return nil
  4955. case apikey.FieldAgentID:
  4956. m.ResetAgentID()
  4957. return nil
  4958. case apikey.FieldCustomAgentBase:
  4959. m.ResetCustomAgentBase()
  4960. return nil
  4961. case apikey.FieldCustomAgentKey:
  4962. m.ResetCustomAgentKey()
  4963. return nil
  4964. case apikey.FieldOpenaiBase:
  4965. m.ResetOpenaiBase()
  4966. return nil
  4967. case apikey.FieldOpenaiKey:
  4968. m.ResetOpenaiKey()
  4969. return nil
  4970. }
  4971. return fmt.Errorf("unknown ApiKey field %s", name)
  4972. }
  4973. // AddedEdges returns all edge names that were set/added in this mutation.
  4974. func (m *ApiKeyMutation) AddedEdges() []string {
  4975. edges := make([]string, 0, 1)
  4976. if m.agent != nil {
  4977. edges = append(edges, apikey.EdgeAgent)
  4978. }
  4979. return edges
  4980. }
  4981. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4982. // name in this mutation.
  4983. func (m *ApiKeyMutation) AddedIDs(name string) []ent.Value {
  4984. switch name {
  4985. case apikey.EdgeAgent:
  4986. if id := m.agent; id != nil {
  4987. return []ent.Value{*id}
  4988. }
  4989. }
  4990. return nil
  4991. }
  4992. // RemovedEdges returns all edge names that were removed in this mutation.
  4993. func (m *ApiKeyMutation) RemovedEdges() []string {
  4994. edges := make([]string, 0, 1)
  4995. return edges
  4996. }
  4997. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4998. // the given name in this mutation.
  4999. func (m *ApiKeyMutation) RemovedIDs(name string) []ent.Value {
  5000. return nil
  5001. }
  5002. // ClearedEdges returns all edge names that were cleared in this mutation.
  5003. func (m *ApiKeyMutation) ClearedEdges() []string {
  5004. edges := make([]string, 0, 1)
  5005. if m.clearedagent {
  5006. edges = append(edges, apikey.EdgeAgent)
  5007. }
  5008. return edges
  5009. }
  5010. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5011. // was cleared in this mutation.
  5012. func (m *ApiKeyMutation) EdgeCleared(name string) bool {
  5013. switch name {
  5014. case apikey.EdgeAgent:
  5015. return m.clearedagent
  5016. }
  5017. return false
  5018. }
  5019. // ClearEdge clears the value of the edge with the given name. It returns an error
  5020. // if that edge is not defined in the schema.
  5021. func (m *ApiKeyMutation) ClearEdge(name string) error {
  5022. switch name {
  5023. case apikey.EdgeAgent:
  5024. m.ClearAgent()
  5025. return nil
  5026. }
  5027. return fmt.Errorf("unknown ApiKey unique edge %s", name)
  5028. }
  5029. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5030. // It returns an error if the edge is not defined in the schema.
  5031. func (m *ApiKeyMutation) ResetEdge(name string) error {
  5032. switch name {
  5033. case apikey.EdgeAgent:
  5034. m.ResetAgent()
  5035. return nil
  5036. }
  5037. return fmt.Errorf("unknown ApiKey edge %s", name)
  5038. }
  5039. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  5040. type BatchMsgMutation struct {
  5041. config
  5042. op Op
  5043. typ string
  5044. id *uint64
  5045. created_at *time.Time
  5046. updated_at *time.Time
  5047. deleted_at *time.Time
  5048. status *uint8
  5049. addstatus *int8
  5050. batch_no *string
  5051. task_name *string
  5052. fromwxid *string
  5053. msg *string
  5054. tag *string
  5055. tagids *string
  5056. total *int32
  5057. addtotal *int32
  5058. success *int32
  5059. addsuccess *int32
  5060. fail *int32
  5061. addfail *int32
  5062. start_time *time.Time
  5063. stop_time *time.Time
  5064. send_time *time.Time
  5065. _type *int32
  5066. add_type *int32
  5067. organization_id *uint64
  5068. addorganization_id *int64
  5069. ctype *uint64
  5070. addctype *int64
  5071. cc *string
  5072. phone *string
  5073. template_name *string
  5074. template_code *string
  5075. lang *string
  5076. clearedFields map[string]struct{}
  5077. done bool
  5078. oldValue func(context.Context) (*BatchMsg, error)
  5079. predicates []predicate.BatchMsg
  5080. }
  5081. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  5082. // batchmsgOption allows management of the mutation configuration using functional options.
  5083. type batchmsgOption func(*BatchMsgMutation)
  5084. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  5085. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  5086. m := &BatchMsgMutation{
  5087. config: c,
  5088. op: op,
  5089. typ: TypeBatchMsg,
  5090. clearedFields: make(map[string]struct{}),
  5091. }
  5092. for _, opt := range opts {
  5093. opt(m)
  5094. }
  5095. return m
  5096. }
  5097. // withBatchMsgID sets the ID field of the mutation.
  5098. func withBatchMsgID(id uint64) batchmsgOption {
  5099. return func(m *BatchMsgMutation) {
  5100. var (
  5101. err error
  5102. once sync.Once
  5103. value *BatchMsg
  5104. )
  5105. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  5106. once.Do(func() {
  5107. if m.done {
  5108. err = errors.New("querying old values post mutation is not allowed")
  5109. } else {
  5110. value, err = m.Client().BatchMsg.Get(ctx, id)
  5111. }
  5112. })
  5113. return value, err
  5114. }
  5115. m.id = &id
  5116. }
  5117. }
  5118. // withBatchMsg sets the old BatchMsg of the mutation.
  5119. func withBatchMsg(node *BatchMsg) batchmsgOption {
  5120. return func(m *BatchMsgMutation) {
  5121. m.oldValue = func(context.Context) (*BatchMsg, error) {
  5122. return node, nil
  5123. }
  5124. m.id = &node.ID
  5125. }
  5126. }
  5127. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5128. // executed in a transaction (ent.Tx), a transactional client is returned.
  5129. func (m BatchMsgMutation) Client() *Client {
  5130. client := &Client{config: m.config}
  5131. client.init()
  5132. return client
  5133. }
  5134. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5135. // it returns an error otherwise.
  5136. func (m BatchMsgMutation) Tx() (*Tx, error) {
  5137. if _, ok := m.driver.(*txDriver); !ok {
  5138. return nil, errors.New("ent: mutation is not running in a transaction")
  5139. }
  5140. tx := &Tx{config: m.config}
  5141. tx.init()
  5142. return tx, nil
  5143. }
  5144. // SetID sets the value of the id field. Note that this
  5145. // operation is only accepted on creation of BatchMsg entities.
  5146. func (m *BatchMsgMutation) SetID(id uint64) {
  5147. m.id = &id
  5148. }
  5149. // ID returns the ID value in the mutation. Note that the ID is only available
  5150. // if it was provided to the builder or after it was returned from the database.
  5151. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  5152. if m.id == nil {
  5153. return
  5154. }
  5155. return *m.id, true
  5156. }
  5157. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5158. // That means, if the mutation is applied within a transaction with an isolation level such
  5159. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5160. // or updated by the mutation.
  5161. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  5162. switch {
  5163. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5164. id, exists := m.ID()
  5165. if exists {
  5166. return []uint64{id}, nil
  5167. }
  5168. fallthrough
  5169. case m.op.Is(OpUpdate | OpDelete):
  5170. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  5171. default:
  5172. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5173. }
  5174. }
  5175. // SetCreatedAt sets the "created_at" field.
  5176. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  5177. m.created_at = &t
  5178. }
  5179. // CreatedAt returns the value of the "created_at" field in the mutation.
  5180. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  5181. v := m.created_at
  5182. if v == nil {
  5183. return
  5184. }
  5185. return *v, true
  5186. }
  5187. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  5188. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5189. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5190. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5191. if !m.op.Is(OpUpdateOne) {
  5192. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5193. }
  5194. if m.id == nil || m.oldValue == nil {
  5195. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5196. }
  5197. oldValue, err := m.oldValue(ctx)
  5198. if err != nil {
  5199. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5200. }
  5201. return oldValue.CreatedAt, nil
  5202. }
  5203. // ResetCreatedAt resets all changes to the "created_at" field.
  5204. func (m *BatchMsgMutation) ResetCreatedAt() {
  5205. m.created_at = nil
  5206. }
  5207. // SetUpdatedAt sets the "updated_at" field.
  5208. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  5209. m.updated_at = &t
  5210. }
  5211. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5212. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  5213. v := m.updated_at
  5214. if v == nil {
  5215. return
  5216. }
  5217. return *v, true
  5218. }
  5219. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  5220. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5221. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5222. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5223. if !m.op.Is(OpUpdateOne) {
  5224. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5225. }
  5226. if m.id == nil || m.oldValue == nil {
  5227. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5228. }
  5229. oldValue, err := m.oldValue(ctx)
  5230. if err != nil {
  5231. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5232. }
  5233. return oldValue.UpdatedAt, nil
  5234. }
  5235. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5236. func (m *BatchMsgMutation) ResetUpdatedAt() {
  5237. m.updated_at = nil
  5238. }
  5239. // SetDeletedAt sets the "deleted_at" field.
  5240. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  5241. m.deleted_at = &t
  5242. }
  5243. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5244. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  5245. v := m.deleted_at
  5246. if v == nil {
  5247. return
  5248. }
  5249. return *v, true
  5250. }
  5251. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  5252. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5253. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5254. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5255. if !m.op.Is(OpUpdateOne) {
  5256. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5257. }
  5258. if m.id == nil || m.oldValue == nil {
  5259. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5260. }
  5261. oldValue, err := m.oldValue(ctx)
  5262. if err != nil {
  5263. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5264. }
  5265. return oldValue.DeletedAt, nil
  5266. }
  5267. // ClearDeletedAt clears the value of the "deleted_at" field.
  5268. func (m *BatchMsgMutation) ClearDeletedAt() {
  5269. m.deleted_at = nil
  5270. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  5271. }
  5272. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5273. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  5274. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  5275. return ok
  5276. }
  5277. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5278. func (m *BatchMsgMutation) ResetDeletedAt() {
  5279. m.deleted_at = nil
  5280. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  5281. }
  5282. // SetStatus sets the "status" field.
  5283. func (m *BatchMsgMutation) SetStatus(u uint8) {
  5284. m.status = &u
  5285. m.addstatus = nil
  5286. }
  5287. // Status returns the value of the "status" field in the mutation.
  5288. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  5289. v := m.status
  5290. if v == nil {
  5291. return
  5292. }
  5293. return *v, true
  5294. }
  5295. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  5296. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5298. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  5299. if !m.op.Is(OpUpdateOne) {
  5300. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  5301. }
  5302. if m.id == nil || m.oldValue == nil {
  5303. return v, errors.New("OldStatus requires an ID field in the mutation")
  5304. }
  5305. oldValue, err := m.oldValue(ctx)
  5306. if err != nil {
  5307. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  5308. }
  5309. return oldValue.Status, nil
  5310. }
  5311. // AddStatus adds u to the "status" field.
  5312. func (m *BatchMsgMutation) AddStatus(u int8) {
  5313. if m.addstatus != nil {
  5314. *m.addstatus += u
  5315. } else {
  5316. m.addstatus = &u
  5317. }
  5318. }
  5319. // AddedStatus returns the value that was added to the "status" field in this mutation.
  5320. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  5321. v := m.addstatus
  5322. if v == nil {
  5323. return
  5324. }
  5325. return *v, true
  5326. }
  5327. // ClearStatus clears the value of the "status" field.
  5328. func (m *BatchMsgMutation) ClearStatus() {
  5329. m.status = nil
  5330. m.addstatus = nil
  5331. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  5332. }
  5333. // StatusCleared returns if the "status" field was cleared in this mutation.
  5334. func (m *BatchMsgMutation) StatusCleared() bool {
  5335. _, ok := m.clearedFields[batchmsg.FieldStatus]
  5336. return ok
  5337. }
  5338. // ResetStatus resets all changes to the "status" field.
  5339. func (m *BatchMsgMutation) ResetStatus() {
  5340. m.status = nil
  5341. m.addstatus = nil
  5342. delete(m.clearedFields, batchmsg.FieldStatus)
  5343. }
  5344. // SetBatchNo sets the "batch_no" field.
  5345. func (m *BatchMsgMutation) SetBatchNo(s string) {
  5346. m.batch_no = &s
  5347. }
  5348. // BatchNo returns the value of the "batch_no" field in the mutation.
  5349. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  5350. v := m.batch_no
  5351. if v == nil {
  5352. return
  5353. }
  5354. return *v, true
  5355. }
  5356. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  5357. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5358. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5359. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  5360. if !m.op.Is(OpUpdateOne) {
  5361. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  5362. }
  5363. if m.id == nil || m.oldValue == nil {
  5364. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  5365. }
  5366. oldValue, err := m.oldValue(ctx)
  5367. if err != nil {
  5368. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  5369. }
  5370. return oldValue.BatchNo, nil
  5371. }
  5372. // ClearBatchNo clears the value of the "batch_no" field.
  5373. func (m *BatchMsgMutation) ClearBatchNo() {
  5374. m.batch_no = nil
  5375. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  5376. }
  5377. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  5378. func (m *BatchMsgMutation) BatchNoCleared() bool {
  5379. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  5380. return ok
  5381. }
  5382. // ResetBatchNo resets all changes to the "batch_no" field.
  5383. func (m *BatchMsgMutation) ResetBatchNo() {
  5384. m.batch_no = nil
  5385. delete(m.clearedFields, batchmsg.FieldBatchNo)
  5386. }
  5387. // SetTaskName sets the "task_name" field.
  5388. func (m *BatchMsgMutation) SetTaskName(s string) {
  5389. m.task_name = &s
  5390. }
  5391. // TaskName returns the value of the "task_name" field in the mutation.
  5392. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  5393. v := m.task_name
  5394. if v == nil {
  5395. return
  5396. }
  5397. return *v, true
  5398. }
  5399. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  5400. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5402. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  5403. if !m.op.Is(OpUpdateOne) {
  5404. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  5405. }
  5406. if m.id == nil || m.oldValue == nil {
  5407. return v, errors.New("OldTaskName requires an ID field in the mutation")
  5408. }
  5409. oldValue, err := m.oldValue(ctx)
  5410. if err != nil {
  5411. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  5412. }
  5413. return oldValue.TaskName, nil
  5414. }
  5415. // ClearTaskName clears the value of the "task_name" field.
  5416. func (m *BatchMsgMutation) ClearTaskName() {
  5417. m.task_name = nil
  5418. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  5419. }
  5420. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  5421. func (m *BatchMsgMutation) TaskNameCleared() bool {
  5422. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  5423. return ok
  5424. }
  5425. // ResetTaskName resets all changes to the "task_name" field.
  5426. func (m *BatchMsgMutation) ResetTaskName() {
  5427. m.task_name = nil
  5428. delete(m.clearedFields, batchmsg.FieldTaskName)
  5429. }
  5430. // SetFromwxid sets the "fromwxid" field.
  5431. func (m *BatchMsgMutation) SetFromwxid(s string) {
  5432. m.fromwxid = &s
  5433. }
  5434. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  5435. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  5436. v := m.fromwxid
  5437. if v == nil {
  5438. return
  5439. }
  5440. return *v, true
  5441. }
  5442. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  5443. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5444. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5445. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  5446. if !m.op.Is(OpUpdateOne) {
  5447. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  5448. }
  5449. if m.id == nil || m.oldValue == nil {
  5450. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  5451. }
  5452. oldValue, err := m.oldValue(ctx)
  5453. if err != nil {
  5454. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  5455. }
  5456. return oldValue.Fromwxid, nil
  5457. }
  5458. // ClearFromwxid clears the value of the "fromwxid" field.
  5459. func (m *BatchMsgMutation) ClearFromwxid() {
  5460. m.fromwxid = nil
  5461. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  5462. }
  5463. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  5464. func (m *BatchMsgMutation) FromwxidCleared() bool {
  5465. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  5466. return ok
  5467. }
  5468. // ResetFromwxid resets all changes to the "fromwxid" field.
  5469. func (m *BatchMsgMutation) ResetFromwxid() {
  5470. m.fromwxid = nil
  5471. delete(m.clearedFields, batchmsg.FieldFromwxid)
  5472. }
  5473. // SetMsg sets the "msg" field.
  5474. func (m *BatchMsgMutation) SetMsg(s string) {
  5475. m.msg = &s
  5476. }
  5477. // Msg returns the value of the "msg" field in the mutation.
  5478. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  5479. v := m.msg
  5480. if v == nil {
  5481. return
  5482. }
  5483. return *v, true
  5484. }
  5485. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  5486. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5487. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5488. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  5489. if !m.op.Is(OpUpdateOne) {
  5490. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  5491. }
  5492. if m.id == nil || m.oldValue == nil {
  5493. return v, errors.New("OldMsg requires an ID field in the mutation")
  5494. }
  5495. oldValue, err := m.oldValue(ctx)
  5496. if err != nil {
  5497. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  5498. }
  5499. return oldValue.Msg, nil
  5500. }
  5501. // ClearMsg clears the value of the "msg" field.
  5502. func (m *BatchMsgMutation) ClearMsg() {
  5503. m.msg = nil
  5504. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  5505. }
  5506. // MsgCleared returns if the "msg" field was cleared in this mutation.
  5507. func (m *BatchMsgMutation) MsgCleared() bool {
  5508. _, ok := m.clearedFields[batchmsg.FieldMsg]
  5509. return ok
  5510. }
  5511. // ResetMsg resets all changes to the "msg" field.
  5512. func (m *BatchMsgMutation) ResetMsg() {
  5513. m.msg = nil
  5514. delete(m.clearedFields, batchmsg.FieldMsg)
  5515. }
  5516. // SetTag sets the "tag" field.
  5517. func (m *BatchMsgMutation) SetTag(s string) {
  5518. m.tag = &s
  5519. }
  5520. // Tag returns the value of the "tag" field in the mutation.
  5521. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  5522. v := m.tag
  5523. if v == nil {
  5524. return
  5525. }
  5526. return *v, true
  5527. }
  5528. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  5529. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5530. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5531. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  5532. if !m.op.Is(OpUpdateOne) {
  5533. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  5534. }
  5535. if m.id == nil || m.oldValue == nil {
  5536. return v, errors.New("OldTag requires an ID field in the mutation")
  5537. }
  5538. oldValue, err := m.oldValue(ctx)
  5539. if err != nil {
  5540. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  5541. }
  5542. return oldValue.Tag, nil
  5543. }
  5544. // ClearTag clears the value of the "tag" field.
  5545. func (m *BatchMsgMutation) ClearTag() {
  5546. m.tag = nil
  5547. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  5548. }
  5549. // TagCleared returns if the "tag" field was cleared in this mutation.
  5550. func (m *BatchMsgMutation) TagCleared() bool {
  5551. _, ok := m.clearedFields[batchmsg.FieldTag]
  5552. return ok
  5553. }
  5554. // ResetTag resets all changes to the "tag" field.
  5555. func (m *BatchMsgMutation) ResetTag() {
  5556. m.tag = nil
  5557. delete(m.clearedFields, batchmsg.FieldTag)
  5558. }
  5559. // SetTagids sets the "tagids" field.
  5560. func (m *BatchMsgMutation) SetTagids(s string) {
  5561. m.tagids = &s
  5562. }
  5563. // Tagids returns the value of the "tagids" field in the mutation.
  5564. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  5565. v := m.tagids
  5566. if v == nil {
  5567. return
  5568. }
  5569. return *v, true
  5570. }
  5571. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  5572. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5573. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5574. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  5575. if !m.op.Is(OpUpdateOne) {
  5576. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  5577. }
  5578. if m.id == nil || m.oldValue == nil {
  5579. return v, errors.New("OldTagids requires an ID field in the mutation")
  5580. }
  5581. oldValue, err := m.oldValue(ctx)
  5582. if err != nil {
  5583. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  5584. }
  5585. return oldValue.Tagids, nil
  5586. }
  5587. // ClearTagids clears the value of the "tagids" field.
  5588. func (m *BatchMsgMutation) ClearTagids() {
  5589. m.tagids = nil
  5590. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  5591. }
  5592. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  5593. func (m *BatchMsgMutation) TagidsCleared() bool {
  5594. _, ok := m.clearedFields[batchmsg.FieldTagids]
  5595. return ok
  5596. }
  5597. // ResetTagids resets all changes to the "tagids" field.
  5598. func (m *BatchMsgMutation) ResetTagids() {
  5599. m.tagids = nil
  5600. delete(m.clearedFields, batchmsg.FieldTagids)
  5601. }
  5602. // SetTotal sets the "total" field.
  5603. func (m *BatchMsgMutation) SetTotal(i int32) {
  5604. m.total = &i
  5605. m.addtotal = nil
  5606. }
  5607. // Total returns the value of the "total" field in the mutation.
  5608. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  5609. v := m.total
  5610. if v == nil {
  5611. return
  5612. }
  5613. return *v, true
  5614. }
  5615. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  5616. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5617. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5618. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  5619. if !m.op.Is(OpUpdateOne) {
  5620. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  5621. }
  5622. if m.id == nil || m.oldValue == nil {
  5623. return v, errors.New("OldTotal requires an ID field in the mutation")
  5624. }
  5625. oldValue, err := m.oldValue(ctx)
  5626. if err != nil {
  5627. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  5628. }
  5629. return oldValue.Total, nil
  5630. }
  5631. // AddTotal adds i to the "total" field.
  5632. func (m *BatchMsgMutation) AddTotal(i int32) {
  5633. if m.addtotal != nil {
  5634. *m.addtotal += i
  5635. } else {
  5636. m.addtotal = &i
  5637. }
  5638. }
  5639. // AddedTotal returns the value that was added to the "total" field in this mutation.
  5640. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  5641. v := m.addtotal
  5642. if v == nil {
  5643. return
  5644. }
  5645. return *v, true
  5646. }
  5647. // ClearTotal clears the value of the "total" field.
  5648. func (m *BatchMsgMutation) ClearTotal() {
  5649. m.total = nil
  5650. m.addtotal = nil
  5651. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  5652. }
  5653. // TotalCleared returns if the "total" field was cleared in this mutation.
  5654. func (m *BatchMsgMutation) TotalCleared() bool {
  5655. _, ok := m.clearedFields[batchmsg.FieldTotal]
  5656. return ok
  5657. }
  5658. // ResetTotal resets all changes to the "total" field.
  5659. func (m *BatchMsgMutation) ResetTotal() {
  5660. m.total = nil
  5661. m.addtotal = nil
  5662. delete(m.clearedFields, batchmsg.FieldTotal)
  5663. }
  5664. // SetSuccess sets the "success" field.
  5665. func (m *BatchMsgMutation) SetSuccess(i int32) {
  5666. m.success = &i
  5667. m.addsuccess = nil
  5668. }
  5669. // Success returns the value of the "success" field in the mutation.
  5670. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  5671. v := m.success
  5672. if v == nil {
  5673. return
  5674. }
  5675. return *v, true
  5676. }
  5677. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  5678. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5680. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  5681. if !m.op.Is(OpUpdateOne) {
  5682. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  5683. }
  5684. if m.id == nil || m.oldValue == nil {
  5685. return v, errors.New("OldSuccess requires an ID field in the mutation")
  5686. }
  5687. oldValue, err := m.oldValue(ctx)
  5688. if err != nil {
  5689. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  5690. }
  5691. return oldValue.Success, nil
  5692. }
  5693. // AddSuccess adds i to the "success" field.
  5694. func (m *BatchMsgMutation) AddSuccess(i int32) {
  5695. if m.addsuccess != nil {
  5696. *m.addsuccess += i
  5697. } else {
  5698. m.addsuccess = &i
  5699. }
  5700. }
  5701. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  5702. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  5703. v := m.addsuccess
  5704. if v == nil {
  5705. return
  5706. }
  5707. return *v, true
  5708. }
  5709. // ClearSuccess clears the value of the "success" field.
  5710. func (m *BatchMsgMutation) ClearSuccess() {
  5711. m.success = nil
  5712. m.addsuccess = nil
  5713. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  5714. }
  5715. // SuccessCleared returns if the "success" field was cleared in this mutation.
  5716. func (m *BatchMsgMutation) SuccessCleared() bool {
  5717. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  5718. return ok
  5719. }
  5720. // ResetSuccess resets all changes to the "success" field.
  5721. func (m *BatchMsgMutation) ResetSuccess() {
  5722. m.success = nil
  5723. m.addsuccess = nil
  5724. delete(m.clearedFields, batchmsg.FieldSuccess)
  5725. }
  5726. // SetFail sets the "fail" field.
  5727. func (m *BatchMsgMutation) SetFail(i int32) {
  5728. m.fail = &i
  5729. m.addfail = nil
  5730. }
  5731. // Fail returns the value of the "fail" field in the mutation.
  5732. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  5733. v := m.fail
  5734. if v == nil {
  5735. return
  5736. }
  5737. return *v, true
  5738. }
  5739. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  5740. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5741. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5742. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  5743. if !m.op.Is(OpUpdateOne) {
  5744. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  5745. }
  5746. if m.id == nil || m.oldValue == nil {
  5747. return v, errors.New("OldFail requires an ID field in the mutation")
  5748. }
  5749. oldValue, err := m.oldValue(ctx)
  5750. if err != nil {
  5751. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  5752. }
  5753. return oldValue.Fail, nil
  5754. }
  5755. // AddFail adds i to the "fail" field.
  5756. func (m *BatchMsgMutation) AddFail(i int32) {
  5757. if m.addfail != nil {
  5758. *m.addfail += i
  5759. } else {
  5760. m.addfail = &i
  5761. }
  5762. }
  5763. // AddedFail returns the value that was added to the "fail" field in this mutation.
  5764. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  5765. v := m.addfail
  5766. if v == nil {
  5767. return
  5768. }
  5769. return *v, true
  5770. }
  5771. // ClearFail clears the value of the "fail" field.
  5772. func (m *BatchMsgMutation) ClearFail() {
  5773. m.fail = nil
  5774. m.addfail = nil
  5775. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  5776. }
  5777. // FailCleared returns if the "fail" field was cleared in this mutation.
  5778. func (m *BatchMsgMutation) FailCleared() bool {
  5779. _, ok := m.clearedFields[batchmsg.FieldFail]
  5780. return ok
  5781. }
  5782. // ResetFail resets all changes to the "fail" field.
  5783. func (m *BatchMsgMutation) ResetFail() {
  5784. m.fail = nil
  5785. m.addfail = nil
  5786. delete(m.clearedFields, batchmsg.FieldFail)
  5787. }
  5788. // SetStartTime sets the "start_time" field.
  5789. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  5790. m.start_time = &t
  5791. }
  5792. // StartTime returns the value of the "start_time" field in the mutation.
  5793. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  5794. v := m.start_time
  5795. if v == nil {
  5796. return
  5797. }
  5798. return *v, true
  5799. }
  5800. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  5801. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5802. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5803. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  5804. if !m.op.Is(OpUpdateOne) {
  5805. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  5806. }
  5807. if m.id == nil || m.oldValue == nil {
  5808. return v, errors.New("OldStartTime requires an ID field in the mutation")
  5809. }
  5810. oldValue, err := m.oldValue(ctx)
  5811. if err != nil {
  5812. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  5813. }
  5814. return oldValue.StartTime, nil
  5815. }
  5816. // ClearStartTime clears the value of the "start_time" field.
  5817. func (m *BatchMsgMutation) ClearStartTime() {
  5818. m.start_time = nil
  5819. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  5820. }
  5821. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  5822. func (m *BatchMsgMutation) StartTimeCleared() bool {
  5823. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  5824. return ok
  5825. }
  5826. // ResetStartTime resets all changes to the "start_time" field.
  5827. func (m *BatchMsgMutation) ResetStartTime() {
  5828. m.start_time = nil
  5829. delete(m.clearedFields, batchmsg.FieldStartTime)
  5830. }
  5831. // SetStopTime sets the "stop_time" field.
  5832. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  5833. m.stop_time = &t
  5834. }
  5835. // StopTime returns the value of the "stop_time" field in the mutation.
  5836. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  5837. v := m.stop_time
  5838. if v == nil {
  5839. return
  5840. }
  5841. return *v, true
  5842. }
  5843. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  5844. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5846. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  5847. if !m.op.Is(OpUpdateOne) {
  5848. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  5849. }
  5850. if m.id == nil || m.oldValue == nil {
  5851. return v, errors.New("OldStopTime requires an ID field in the mutation")
  5852. }
  5853. oldValue, err := m.oldValue(ctx)
  5854. if err != nil {
  5855. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  5856. }
  5857. return oldValue.StopTime, nil
  5858. }
  5859. // ClearStopTime clears the value of the "stop_time" field.
  5860. func (m *BatchMsgMutation) ClearStopTime() {
  5861. m.stop_time = nil
  5862. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  5863. }
  5864. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  5865. func (m *BatchMsgMutation) StopTimeCleared() bool {
  5866. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  5867. return ok
  5868. }
  5869. // ResetStopTime resets all changes to the "stop_time" field.
  5870. func (m *BatchMsgMutation) ResetStopTime() {
  5871. m.stop_time = nil
  5872. delete(m.clearedFields, batchmsg.FieldStopTime)
  5873. }
  5874. // SetSendTime sets the "send_time" field.
  5875. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  5876. m.send_time = &t
  5877. }
  5878. // SendTime returns the value of the "send_time" field in the mutation.
  5879. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  5880. v := m.send_time
  5881. if v == nil {
  5882. return
  5883. }
  5884. return *v, true
  5885. }
  5886. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  5887. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5888. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5889. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  5890. if !m.op.Is(OpUpdateOne) {
  5891. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  5892. }
  5893. if m.id == nil || m.oldValue == nil {
  5894. return v, errors.New("OldSendTime requires an ID field in the mutation")
  5895. }
  5896. oldValue, err := m.oldValue(ctx)
  5897. if err != nil {
  5898. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  5899. }
  5900. return oldValue.SendTime, nil
  5901. }
  5902. // ClearSendTime clears the value of the "send_time" field.
  5903. func (m *BatchMsgMutation) ClearSendTime() {
  5904. m.send_time = nil
  5905. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  5906. }
  5907. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  5908. func (m *BatchMsgMutation) SendTimeCleared() bool {
  5909. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  5910. return ok
  5911. }
  5912. // ResetSendTime resets all changes to the "send_time" field.
  5913. func (m *BatchMsgMutation) ResetSendTime() {
  5914. m.send_time = nil
  5915. delete(m.clearedFields, batchmsg.FieldSendTime)
  5916. }
  5917. // SetType sets the "type" field.
  5918. func (m *BatchMsgMutation) SetType(i int32) {
  5919. m._type = &i
  5920. m.add_type = nil
  5921. }
  5922. // GetType returns the value of the "type" field in the mutation.
  5923. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  5924. v := m._type
  5925. if v == nil {
  5926. return
  5927. }
  5928. return *v, true
  5929. }
  5930. // OldType returns the old "type" field's value of the BatchMsg entity.
  5931. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5932. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5933. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  5934. if !m.op.Is(OpUpdateOne) {
  5935. return v, errors.New("OldType is only allowed on UpdateOne operations")
  5936. }
  5937. if m.id == nil || m.oldValue == nil {
  5938. return v, errors.New("OldType requires an ID field in the mutation")
  5939. }
  5940. oldValue, err := m.oldValue(ctx)
  5941. if err != nil {
  5942. return v, fmt.Errorf("querying old value for OldType: %w", err)
  5943. }
  5944. return oldValue.Type, nil
  5945. }
  5946. // AddType adds i to the "type" field.
  5947. func (m *BatchMsgMutation) AddType(i int32) {
  5948. if m.add_type != nil {
  5949. *m.add_type += i
  5950. } else {
  5951. m.add_type = &i
  5952. }
  5953. }
  5954. // AddedType returns the value that was added to the "type" field in this mutation.
  5955. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  5956. v := m.add_type
  5957. if v == nil {
  5958. return
  5959. }
  5960. return *v, true
  5961. }
  5962. // ClearType clears the value of the "type" field.
  5963. func (m *BatchMsgMutation) ClearType() {
  5964. m._type = nil
  5965. m.add_type = nil
  5966. m.clearedFields[batchmsg.FieldType] = struct{}{}
  5967. }
  5968. // TypeCleared returns if the "type" field was cleared in this mutation.
  5969. func (m *BatchMsgMutation) TypeCleared() bool {
  5970. _, ok := m.clearedFields[batchmsg.FieldType]
  5971. return ok
  5972. }
  5973. // ResetType resets all changes to the "type" field.
  5974. func (m *BatchMsgMutation) ResetType() {
  5975. m._type = nil
  5976. m.add_type = nil
  5977. delete(m.clearedFields, batchmsg.FieldType)
  5978. }
  5979. // SetOrganizationID sets the "organization_id" field.
  5980. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  5981. m.organization_id = &u
  5982. m.addorganization_id = nil
  5983. }
  5984. // OrganizationID returns the value of the "organization_id" field in the mutation.
  5985. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  5986. v := m.organization_id
  5987. if v == nil {
  5988. return
  5989. }
  5990. return *v, true
  5991. }
  5992. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  5993. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5994. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5995. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5996. if !m.op.Is(OpUpdateOne) {
  5997. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5998. }
  5999. if m.id == nil || m.oldValue == nil {
  6000. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  6001. }
  6002. oldValue, err := m.oldValue(ctx)
  6003. if err != nil {
  6004. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6005. }
  6006. return oldValue.OrganizationID, nil
  6007. }
  6008. // AddOrganizationID adds u to the "organization_id" field.
  6009. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  6010. if m.addorganization_id != nil {
  6011. *m.addorganization_id += u
  6012. } else {
  6013. m.addorganization_id = &u
  6014. }
  6015. }
  6016. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6017. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  6018. v := m.addorganization_id
  6019. if v == nil {
  6020. return
  6021. }
  6022. return *v, true
  6023. }
  6024. // ResetOrganizationID resets all changes to the "organization_id" field.
  6025. func (m *BatchMsgMutation) ResetOrganizationID() {
  6026. m.organization_id = nil
  6027. m.addorganization_id = nil
  6028. }
  6029. // SetCtype sets the "ctype" field.
  6030. func (m *BatchMsgMutation) SetCtype(u uint64) {
  6031. m.ctype = &u
  6032. m.addctype = nil
  6033. }
  6034. // Ctype returns the value of the "ctype" field in the mutation.
  6035. func (m *BatchMsgMutation) Ctype() (r uint64, exists bool) {
  6036. v := m.ctype
  6037. if v == nil {
  6038. return
  6039. }
  6040. return *v, true
  6041. }
  6042. // OldCtype returns the old "ctype" field's value of the BatchMsg entity.
  6043. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6045. func (m *BatchMsgMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  6046. if !m.op.Is(OpUpdateOne) {
  6047. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  6048. }
  6049. if m.id == nil || m.oldValue == nil {
  6050. return v, errors.New("OldCtype requires an ID field in the mutation")
  6051. }
  6052. oldValue, err := m.oldValue(ctx)
  6053. if err != nil {
  6054. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  6055. }
  6056. return oldValue.Ctype, nil
  6057. }
  6058. // AddCtype adds u to the "ctype" field.
  6059. func (m *BatchMsgMutation) AddCtype(u int64) {
  6060. if m.addctype != nil {
  6061. *m.addctype += u
  6062. } else {
  6063. m.addctype = &u
  6064. }
  6065. }
  6066. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  6067. func (m *BatchMsgMutation) AddedCtype() (r int64, exists bool) {
  6068. v := m.addctype
  6069. if v == nil {
  6070. return
  6071. }
  6072. return *v, true
  6073. }
  6074. // ResetCtype resets all changes to the "ctype" field.
  6075. func (m *BatchMsgMutation) ResetCtype() {
  6076. m.ctype = nil
  6077. m.addctype = nil
  6078. }
  6079. // SetCc sets the "cc" field.
  6080. func (m *BatchMsgMutation) SetCc(s string) {
  6081. m.cc = &s
  6082. }
  6083. // Cc returns the value of the "cc" field in the mutation.
  6084. func (m *BatchMsgMutation) Cc() (r string, exists bool) {
  6085. v := m.cc
  6086. if v == nil {
  6087. return
  6088. }
  6089. return *v, true
  6090. }
  6091. // OldCc returns the old "cc" field's value of the BatchMsg entity.
  6092. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6093. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6094. func (m *BatchMsgMutation) OldCc(ctx context.Context) (v string, err error) {
  6095. if !m.op.Is(OpUpdateOne) {
  6096. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  6097. }
  6098. if m.id == nil || m.oldValue == nil {
  6099. return v, errors.New("OldCc requires an ID field in the mutation")
  6100. }
  6101. oldValue, err := m.oldValue(ctx)
  6102. if err != nil {
  6103. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  6104. }
  6105. return oldValue.Cc, nil
  6106. }
  6107. // ClearCc clears the value of the "cc" field.
  6108. func (m *BatchMsgMutation) ClearCc() {
  6109. m.cc = nil
  6110. m.clearedFields[batchmsg.FieldCc] = struct{}{}
  6111. }
  6112. // CcCleared returns if the "cc" field was cleared in this mutation.
  6113. func (m *BatchMsgMutation) CcCleared() bool {
  6114. _, ok := m.clearedFields[batchmsg.FieldCc]
  6115. return ok
  6116. }
  6117. // ResetCc resets all changes to the "cc" field.
  6118. func (m *BatchMsgMutation) ResetCc() {
  6119. m.cc = nil
  6120. delete(m.clearedFields, batchmsg.FieldCc)
  6121. }
  6122. // SetPhone sets the "phone" field.
  6123. func (m *BatchMsgMutation) SetPhone(s string) {
  6124. m.phone = &s
  6125. }
  6126. // Phone returns the value of the "phone" field in the mutation.
  6127. func (m *BatchMsgMutation) Phone() (r string, exists bool) {
  6128. v := m.phone
  6129. if v == nil {
  6130. return
  6131. }
  6132. return *v, true
  6133. }
  6134. // OldPhone returns the old "phone" field's value of the BatchMsg entity.
  6135. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6136. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6137. func (m *BatchMsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  6138. if !m.op.Is(OpUpdateOne) {
  6139. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  6140. }
  6141. if m.id == nil || m.oldValue == nil {
  6142. return v, errors.New("OldPhone requires an ID field in the mutation")
  6143. }
  6144. oldValue, err := m.oldValue(ctx)
  6145. if err != nil {
  6146. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  6147. }
  6148. return oldValue.Phone, nil
  6149. }
  6150. // ClearPhone clears the value of the "phone" field.
  6151. func (m *BatchMsgMutation) ClearPhone() {
  6152. m.phone = nil
  6153. m.clearedFields[batchmsg.FieldPhone] = struct{}{}
  6154. }
  6155. // PhoneCleared returns if the "phone" field was cleared in this mutation.
  6156. func (m *BatchMsgMutation) PhoneCleared() bool {
  6157. _, ok := m.clearedFields[batchmsg.FieldPhone]
  6158. return ok
  6159. }
  6160. // ResetPhone resets all changes to the "phone" field.
  6161. func (m *BatchMsgMutation) ResetPhone() {
  6162. m.phone = nil
  6163. delete(m.clearedFields, batchmsg.FieldPhone)
  6164. }
  6165. // SetTemplateName sets the "template_name" field.
  6166. func (m *BatchMsgMutation) SetTemplateName(s string) {
  6167. m.template_name = &s
  6168. }
  6169. // TemplateName returns the value of the "template_name" field in the mutation.
  6170. func (m *BatchMsgMutation) TemplateName() (r string, exists bool) {
  6171. v := m.template_name
  6172. if v == nil {
  6173. return
  6174. }
  6175. return *v, true
  6176. }
  6177. // OldTemplateName returns the old "template_name" field's value of the BatchMsg entity.
  6178. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6179. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6180. func (m *BatchMsgMutation) OldTemplateName(ctx context.Context) (v string, err error) {
  6181. if !m.op.Is(OpUpdateOne) {
  6182. return v, errors.New("OldTemplateName is only allowed on UpdateOne operations")
  6183. }
  6184. if m.id == nil || m.oldValue == nil {
  6185. return v, errors.New("OldTemplateName requires an ID field in the mutation")
  6186. }
  6187. oldValue, err := m.oldValue(ctx)
  6188. if err != nil {
  6189. return v, fmt.Errorf("querying old value for OldTemplateName: %w", err)
  6190. }
  6191. return oldValue.TemplateName, nil
  6192. }
  6193. // ClearTemplateName clears the value of the "template_name" field.
  6194. func (m *BatchMsgMutation) ClearTemplateName() {
  6195. m.template_name = nil
  6196. m.clearedFields[batchmsg.FieldTemplateName] = struct{}{}
  6197. }
  6198. // TemplateNameCleared returns if the "template_name" field was cleared in this mutation.
  6199. func (m *BatchMsgMutation) TemplateNameCleared() bool {
  6200. _, ok := m.clearedFields[batchmsg.FieldTemplateName]
  6201. return ok
  6202. }
  6203. // ResetTemplateName resets all changes to the "template_name" field.
  6204. func (m *BatchMsgMutation) ResetTemplateName() {
  6205. m.template_name = nil
  6206. delete(m.clearedFields, batchmsg.FieldTemplateName)
  6207. }
  6208. // SetTemplateCode sets the "template_code" field.
  6209. func (m *BatchMsgMutation) SetTemplateCode(s string) {
  6210. m.template_code = &s
  6211. }
  6212. // TemplateCode returns the value of the "template_code" field in the mutation.
  6213. func (m *BatchMsgMutation) TemplateCode() (r string, exists bool) {
  6214. v := m.template_code
  6215. if v == nil {
  6216. return
  6217. }
  6218. return *v, true
  6219. }
  6220. // OldTemplateCode returns the old "template_code" field's value of the BatchMsg entity.
  6221. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6222. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6223. func (m *BatchMsgMutation) OldTemplateCode(ctx context.Context) (v string, err error) {
  6224. if !m.op.Is(OpUpdateOne) {
  6225. return v, errors.New("OldTemplateCode is only allowed on UpdateOne operations")
  6226. }
  6227. if m.id == nil || m.oldValue == nil {
  6228. return v, errors.New("OldTemplateCode requires an ID field in the mutation")
  6229. }
  6230. oldValue, err := m.oldValue(ctx)
  6231. if err != nil {
  6232. return v, fmt.Errorf("querying old value for OldTemplateCode: %w", err)
  6233. }
  6234. return oldValue.TemplateCode, nil
  6235. }
  6236. // ClearTemplateCode clears the value of the "template_code" field.
  6237. func (m *BatchMsgMutation) ClearTemplateCode() {
  6238. m.template_code = nil
  6239. m.clearedFields[batchmsg.FieldTemplateCode] = struct{}{}
  6240. }
  6241. // TemplateCodeCleared returns if the "template_code" field was cleared in this mutation.
  6242. func (m *BatchMsgMutation) TemplateCodeCleared() bool {
  6243. _, ok := m.clearedFields[batchmsg.FieldTemplateCode]
  6244. return ok
  6245. }
  6246. // ResetTemplateCode resets all changes to the "template_code" field.
  6247. func (m *BatchMsgMutation) ResetTemplateCode() {
  6248. m.template_code = nil
  6249. delete(m.clearedFields, batchmsg.FieldTemplateCode)
  6250. }
  6251. // SetLang sets the "lang" field.
  6252. func (m *BatchMsgMutation) SetLang(s string) {
  6253. m.lang = &s
  6254. }
  6255. // Lang returns the value of the "lang" field in the mutation.
  6256. func (m *BatchMsgMutation) Lang() (r string, exists bool) {
  6257. v := m.lang
  6258. if v == nil {
  6259. return
  6260. }
  6261. return *v, true
  6262. }
  6263. // OldLang returns the old "lang" field's value of the BatchMsg entity.
  6264. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6266. func (m *BatchMsgMutation) OldLang(ctx context.Context) (v string, err error) {
  6267. if !m.op.Is(OpUpdateOne) {
  6268. return v, errors.New("OldLang is only allowed on UpdateOne operations")
  6269. }
  6270. if m.id == nil || m.oldValue == nil {
  6271. return v, errors.New("OldLang requires an ID field in the mutation")
  6272. }
  6273. oldValue, err := m.oldValue(ctx)
  6274. if err != nil {
  6275. return v, fmt.Errorf("querying old value for OldLang: %w", err)
  6276. }
  6277. return oldValue.Lang, nil
  6278. }
  6279. // ClearLang clears the value of the "lang" field.
  6280. func (m *BatchMsgMutation) ClearLang() {
  6281. m.lang = nil
  6282. m.clearedFields[batchmsg.FieldLang] = struct{}{}
  6283. }
  6284. // LangCleared returns if the "lang" field was cleared in this mutation.
  6285. func (m *BatchMsgMutation) LangCleared() bool {
  6286. _, ok := m.clearedFields[batchmsg.FieldLang]
  6287. return ok
  6288. }
  6289. // ResetLang resets all changes to the "lang" field.
  6290. func (m *BatchMsgMutation) ResetLang() {
  6291. m.lang = nil
  6292. delete(m.clearedFields, batchmsg.FieldLang)
  6293. }
  6294. // Where appends a list predicates to the BatchMsgMutation builder.
  6295. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  6296. m.predicates = append(m.predicates, ps...)
  6297. }
  6298. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  6299. // users can use type-assertion to append predicates that do not depend on any generated package.
  6300. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  6301. p := make([]predicate.BatchMsg, len(ps))
  6302. for i := range ps {
  6303. p[i] = ps[i]
  6304. }
  6305. m.Where(p...)
  6306. }
  6307. // Op returns the operation name.
  6308. func (m *BatchMsgMutation) Op() Op {
  6309. return m.op
  6310. }
  6311. // SetOp allows setting the mutation operation.
  6312. func (m *BatchMsgMutation) SetOp(op Op) {
  6313. m.op = op
  6314. }
  6315. // Type returns the node type of this mutation (BatchMsg).
  6316. func (m *BatchMsgMutation) Type() string {
  6317. return m.typ
  6318. }
  6319. // Fields returns all fields that were changed during this mutation. Note that in
  6320. // order to get all numeric fields that were incremented/decremented, call
  6321. // AddedFields().
  6322. func (m *BatchMsgMutation) Fields() []string {
  6323. fields := make([]string, 0, 24)
  6324. if m.created_at != nil {
  6325. fields = append(fields, batchmsg.FieldCreatedAt)
  6326. }
  6327. if m.updated_at != nil {
  6328. fields = append(fields, batchmsg.FieldUpdatedAt)
  6329. }
  6330. if m.deleted_at != nil {
  6331. fields = append(fields, batchmsg.FieldDeletedAt)
  6332. }
  6333. if m.status != nil {
  6334. fields = append(fields, batchmsg.FieldStatus)
  6335. }
  6336. if m.batch_no != nil {
  6337. fields = append(fields, batchmsg.FieldBatchNo)
  6338. }
  6339. if m.task_name != nil {
  6340. fields = append(fields, batchmsg.FieldTaskName)
  6341. }
  6342. if m.fromwxid != nil {
  6343. fields = append(fields, batchmsg.FieldFromwxid)
  6344. }
  6345. if m.msg != nil {
  6346. fields = append(fields, batchmsg.FieldMsg)
  6347. }
  6348. if m.tag != nil {
  6349. fields = append(fields, batchmsg.FieldTag)
  6350. }
  6351. if m.tagids != nil {
  6352. fields = append(fields, batchmsg.FieldTagids)
  6353. }
  6354. if m.total != nil {
  6355. fields = append(fields, batchmsg.FieldTotal)
  6356. }
  6357. if m.success != nil {
  6358. fields = append(fields, batchmsg.FieldSuccess)
  6359. }
  6360. if m.fail != nil {
  6361. fields = append(fields, batchmsg.FieldFail)
  6362. }
  6363. if m.start_time != nil {
  6364. fields = append(fields, batchmsg.FieldStartTime)
  6365. }
  6366. if m.stop_time != nil {
  6367. fields = append(fields, batchmsg.FieldStopTime)
  6368. }
  6369. if m.send_time != nil {
  6370. fields = append(fields, batchmsg.FieldSendTime)
  6371. }
  6372. if m._type != nil {
  6373. fields = append(fields, batchmsg.FieldType)
  6374. }
  6375. if m.organization_id != nil {
  6376. fields = append(fields, batchmsg.FieldOrganizationID)
  6377. }
  6378. if m.ctype != nil {
  6379. fields = append(fields, batchmsg.FieldCtype)
  6380. }
  6381. if m.cc != nil {
  6382. fields = append(fields, batchmsg.FieldCc)
  6383. }
  6384. if m.phone != nil {
  6385. fields = append(fields, batchmsg.FieldPhone)
  6386. }
  6387. if m.template_name != nil {
  6388. fields = append(fields, batchmsg.FieldTemplateName)
  6389. }
  6390. if m.template_code != nil {
  6391. fields = append(fields, batchmsg.FieldTemplateCode)
  6392. }
  6393. if m.lang != nil {
  6394. fields = append(fields, batchmsg.FieldLang)
  6395. }
  6396. return fields
  6397. }
  6398. // Field returns the value of a field with the given name. The second boolean
  6399. // return value indicates that this field was not set, or was not defined in the
  6400. // schema.
  6401. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  6402. switch name {
  6403. case batchmsg.FieldCreatedAt:
  6404. return m.CreatedAt()
  6405. case batchmsg.FieldUpdatedAt:
  6406. return m.UpdatedAt()
  6407. case batchmsg.FieldDeletedAt:
  6408. return m.DeletedAt()
  6409. case batchmsg.FieldStatus:
  6410. return m.Status()
  6411. case batchmsg.FieldBatchNo:
  6412. return m.BatchNo()
  6413. case batchmsg.FieldTaskName:
  6414. return m.TaskName()
  6415. case batchmsg.FieldFromwxid:
  6416. return m.Fromwxid()
  6417. case batchmsg.FieldMsg:
  6418. return m.Msg()
  6419. case batchmsg.FieldTag:
  6420. return m.Tag()
  6421. case batchmsg.FieldTagids:
  6422. return m.Tagids()
  6423. case batchmsg.FieldTotal:
  6424. return m.Total()
  6425. case batchmsg.FieldSuccess:
  6426. return m.Success()
  6427. case batchmsg.FieldFail:
  6428. return m.Fail()
  6429. case batchmsg.FieldStartTime:
  6430. return m.StartTime()
  6431. case batchmsg.FieldStopTime:
  6432. return m.StopTime()
  6433. case batchmsg.FieldSendTime:
  6434. return m.SendTime()
  6435. case batchmsg.FieldType:
  6436. return m.GetType()
  6437. case batchmsg.FieldOrganizationID:
  6438. return m.OrganizationID()
  6439. case batchmsg.FieldCtype:
  6440. return m.Ctype()
  6441. case batchmsg.FieldCc:
  6442. return m.Cc()
  6443. case batchmsg.FieldPhone:
  6444. return m.Phone()
  6445. case batchmsg.FieldTemplateName:
  6446. return m.TemplateName()
  6447. case batchmsg.FieldTemplateCode:
  6448. return m.TemplateCode()
  6449. case batchmsg.FieldLang:
  6450. return m.Lang()
  6451. }
  6452. return nil, false
  6453. }
  6454. // OldField returns the old value of the field from the database. An error is
  6455. // returned if the mutation operation is not UpdateOne, or the query to the
  6456. // database failed.
  6457. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6458. switch name {
  6459. case batchmsg.FieldCreatedAt:
  6460. return m.OldCreatedAt(ctx)
  6461. case batchmsg.FieldUpdatedAt:
  6462. return m.OldUpdatedAt(ctx)
  6463. case batchmsg.FieldDeletedAt:
  6464. return m.OldDeletedAt(ctx)
  6465. case batchmsg.FieldStatus:
  6466. return m.OldStatus(ctx)
  6467. case batchmsg.FieldBatchNo:
  6468. return m.OldBatchNo(ctx)
  6469. case batchmsg.FieldTaskName:
  6470. return m.OldTaskName(ctx)
  6471. case batchmsg.FieldFromwxid:
  6472. return m.OldFromwxid(ctx)
  6473. case batchmsg.FieldMsg:
  6474. return m.OldMsg(ctx)
  6475. case batchmsg.FieldTag:
  6476. return m.OldTag(ctx)
  6477. case batchmsg.FieldTagids:
  6478. return m.OldTagids(ctx)
  6479. case batchmsg.FieldTotal:
  6480. return m.OldTotal(ctx)
  6481. case batchmsg.FieldSuccess:
  6482. return m.OldSuccess(ctx)
  6483. case batchmsg.FieldFail:
  6484. return m.OldFail(ctx)
  6485. case batchmsg.FieldStartTime:
  6486. return m.OldStartTime(ctx)
  6487. case batchmsg.FieldStopTime:
  6488. return m.OldStopTime(ctx)
  6489. case batchmsg.FieldSendTime:
  6490. return m.OldSendTime(ctx)
  6491. case batchmsg.FieldType:
  6492. return m.OldType(ctx)
  6493. case batchmsg.FieldOrganizationID:
  6494. return m.OldOrganizationID(ctx)
  6495. case batchmsg.FieldCtype:
  6496. return m.OldCtype(ctx)
  6497. case batchmsg.FieldCc:
  6498. return m.OldCc(ctx)
  6499. case batchmsg.FieldPhone:
  6500. return m.OldPhone(ctx)
  6501. case batchmsg.FieldTemplateName:
  6502. return m.OldTemplateName(ctx)
  6503. case batchmsg.FieldTemplateCode:
  6504. return m.OldTemplateCode(ctx)
  6505. case batchmsg.FieldLang:
  6506. return m.OldLang(ctx)
  6507. }
  6508. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  6509. }
  6510. // SetField sets the value of a field with the given name. It returns an error if
  6511. // the field is not defined in the schema, or if the type mismatched the field
  6512. // type.
  6513. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  6514. switch name {
  6515. case batchmsg.FieldCreatedAt:
  6516. v, ok := value.(time.Time)
  6517. if !ok {
  6518. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6519. }
  6520. m.SetCreatedAt(v)
  6521. return nil
  6522. case batchmsg.FieldUpdatedAt:
  6523. v, ok := value.(time.Time)
  6524. if !ok {
  6525. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6526. }
  6527. m.SetUpdatedAt(v)
  6528. return nil
  6529. case batchmsg.FieldDeletedAt:
  6530. v, ok := value.(time.Time)
  6531. if !ok {
  6532. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6533. }
  6534. m.SetDeletedAt(v)
  6535. return nil
  6536. case batchmsg.FieldStatus:
  6537. v, ok := value.(uint8)
  6538. if !ok {
  6539. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6540. }
  6541. m.SetStatus(v)
  6542. return nil
  6543. case batchmsg.FieldBatchNo:
  6544. v, ok := value.(string)
  6545. if !ok {
  6546. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6547. }
  6548. m.SetBatchNo(v)
  6549. return nil
  6550. case batchmsg.FieldTaskName:
  6551. v, ok := value.(string)
  6552. if !ok {
  6553. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6554. }
  6555. m.SetTaskName(v)
  6556. return nil
  6557. case batchmsg.FieldFromwxid:
  6558. v, ok := value.(string)
  6559. if !ok {
  6560. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6561. }
  6562. m.SetFromwxid(v)
  6563. return nil
  6564. case batchmsg.FieldMsg:
  6565. v, ok := value.(string)
  6566. if !ok {
  6567. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6568. }
  6569. m.SetMsg(v)
  6570. return nil
  6571. case batchmsg.FieldTag:
  6572. v, ok := value.(string)
  6573. if !ok {
  6574. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6575. }
  6576. m.SetTag(v)
  6577. return nil
  6578. case batchmsg.FieldTagids:
  6579. v, ok := value.(string)
  6580. if !ok {
  6581. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6582. }
  6583. m.SetTagids(v)
  6584. return nil
  6585. case batchmsg.FieldTotal:
  6586. v, ok := value.(int32)
  6587. if !ok {
  6588. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6589. }
  6590. m.SetTotal(v)
  6591. return nil
  6592. case batchmsg.FieldSuccess:
  6593. v, ok := value.(int32)
  6594. if !ok {
  6595. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6596. }
  6597. m.SetSuccess(v)
  6598. return nil
  6599. case batchmsg.FieldFail:
  6600. v, ok := value.(int32)
  6601. if !ok {
  6602. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6603. }
  6604. m.SetFail(v)
  6605. return nil
  6606. case batchmsg.FieldStartTime:
  6607. v, ok := value.(time.Time)
  6608. if !ok {
  6609. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6610. }
  6611. m.SetStartTime(v)
  6612. return nil
  6613. case batchmsg.FieldStopTime:
  6614. v, ok := value.(time.Time)
  6615. if !ok {
  6616. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6617. }
  6618. m.SetStopTime(v)
  6619. return nil
  6620. case batchmsg.FieldSendTime:
  6621. v, ok := value.(time.Time)
  6622. if !ok {
  6623. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6624. }
  6625. m.SetSendTime(v)
  6626. return nil
  6627. case batchmsg.FieldType:
  6628. v, ok := value.(int32)
  6629. if !ok {
  6630. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6631. }
  6632. m.SetType(v)
  6633. return nil
  6634. case batchmsg.FieldOrganizationID:
  6635. v, ok := value.(uint64)
  6636. if !ok {
  6637. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6638. }
  6639. m.SetOrganizationID(v)
  6640. return nil
  6641. case batchmsg.FieldCtype:
  6642. v, ok := value.(uint64)
  6643. if !ok {
  6644. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6645. }
  6646. m.SetCtype(v)
  6647. return nil
  6648. case batchmsg.FieldCc:
  6649. v, ok := value.(string)
  6650. if !ok {
  6651. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6652. }
  6653. m.SetCc(v)
  6654. return nil
  6655. case batchmsg.FieldPhone:
  6656. v, ok := value.(string)
  6657. if !ok {
  6658. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6659. }
  6660. m.SetPhone(v)
  6661. return nil
  6662. case batchmsg.FieldTemplateName:
  6663. v, ok := value.(string)
  6664. if !ok {
  6665. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6666. }
  6667. m.SetTemplateName(v)
  6668. return nil
  6669. case batchmsg.FieldTemplateCode:
  6670. v, ok := value.(string)
  6671. if !ok {
  6672. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6673. }
  6674. m.SetTemplateCode(v)
  6675. return nil
  6676. case batchmsg.FieldLang:
  6677. v, ok := value.(string)
  6678. if !ok {
  6679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6680. }
  6681. m.SetLang(v)
  6682. return nil
  6683. }
  6684. return fmt.Errorf("unknown BatchMsg field %s", name)
  6685. }
  6686. // AddedFields returns all numeric fields that were incremented/decremented during
  6687. // this mutation.
  6688. func (m *BatchMsgMutation) AddedFields() []string {
  6689. var fields []string
  6690. if m.addstatus != nil {
  6691. fields = append(fields, batchmsg.FieldStatus)
  6692. }
  6693. if m.addtotal != nil {
  6694. fields = append(fields, batchmsg.FieldTotal)
  6695. }
  6696. if m.addsuccess != nil {
  6697. fields = append(fields, batchmsg.FieldSuccess)
  6698. }
  6699. if m.addfail != nil {
  6700. fields = append(fields, batchmsg.FieldFail)
  6701. }
  6702. if m.add_type != nil {
  6703. fields = append(fields, batchmsg.FieldType)
  6704. }
  6705. if m.addorganization_id != nil {
  6706. fields = append(fields, batchmsg.FieldOrganizationID)
  6707. }
  6708. if m.addctype != nil {
  6709. fields = append(fields, batchmsg.FieldCtype)
  6710. }
  6711. return fields
  6712. }
  6713. // AddedField returns the numeric value that was incremented/decremented on a field
  6714. // with the given name. The second boolean return value indicates that this field
  6715. // was not set, or was not defined in the schema.
  6716. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  6717. switch name {
  6718. case batchmsg.FieldStatus:
  6719. return m.AddedStatus()
  6720. case batchmsg.FieldTotal:
  6721. return m.AddedTotal()
  6722. case batchmsg.FieldSuccess:
  6723. return m.AddedSuccess()
  6724. case batchmsg.FieldFail:
  6725. return m.AddedFail()
  6726. case batchmsg.FieldType:
  6727. return m.AddedType()
  6728. case batchmsg.FieldOrganizationID:
  6729. return m.AddedOrganizationID()
  6730. case batchmsg.FieldCtype:
  6731. return m.AddedCtype()
  6732. }
  6733. return nil, false
  6734. }
  6735. // AddField adds the value to the field with the given name. It returns an error if
  6736. // the field is not defined in the schema, or if the type mismatched the field
  6737. // type.
  6738. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  6739. switch name {
  6740. case batchmsg.FieldStatus:
  6741. v, ok := value.(int8)
  6742. if !ok {
  6743. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6744. }
  6745. m.AddStatus(v)
  6746. return nil
  6747. case batchmsg.FieldTotal:
  6748. v, ok := value.(int32)
  6749. if !ok {
  6750. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6751. }
  6752. m.AddTotal(v)
  6753. return nil
  6754. case batchmsg.FieldSuccess:
  6755. v, ok := value.(int32)
  6756. if !ok {
  6757. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6758. }
  6759. m.AddSuccess(v)
  6760. return nil
  6761. case batchmsg.FieldFail:
  6762. v, ok := value.(int32)
  6763. if !ok {
  6764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6765. }
  6766. m.AddFail(v)
  6767. return nil
  6768. case batchmsg.FieldType:
  6769. v, ok := value.(int32)
  6770. if !ok {
  6771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6772. }
  6773. m.AddType(v)
  6774. return nil
  6775. case batchmsg.FieldOrganizationID:
  6776. v, ok := value.(int64)
  6777. if !ok {
  6778. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6779. }
  6780. m.AddOrganizationID(v)
  6781. return nil
  6782. case batchmsg.FieldCtype:
  6783. v, ok := value.(int64)
  6784. if !ok {
  6785. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6786. }
  6787. m.AddCtype(v)
  6788. return nil
  6789. }
  6790. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  6791. }
  6792. // ClearedFields returns all nullable fields that were cleared during this
  6793. // mutation.
  6794. func (m *BatchMsgMutation) ClearedFields() []string {
  6795. var fields []string
  6796. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  6797. fields = append(fields, batchmsg.FieldDeletedAt)
  6798. }
  6799. if m.FieldCleared(batchmsg.FieldStatus) {
  6800. fields = append(fields, batchmsg.FieldStatus)
  6801. }
  6802. if m.FieldCleared(batchmsg.FieldBatchNo) {
  6803. fields = append(fields, batchmsg.FieldBatchNo)
  6804. }
  6805. if m.FieldCleared(batchmsg.FieldTaskName) {
  6806. fields = append(fields, batchmsg.FieldTaskName)
  6807. }
  6808. if m.FieldCleared(batchmsg.FieldFromwxid) {
  6809. fields = append(fields, batchmsg.FieldFromwxid)
  6810. }
  6811. if m.FieldCleared(batchmsg.FieldMsg) {
  6812. fields = append(fields, batchmsg.FieldMsg)
  6813. }
  6814. if m.FieldCleared(batchmsg.FieldTag) {
  6815. fields = append(fields, batchmsg.FieldTag)
  6816. }
  6817. if m.FieldCleared(batchmsg.FieldTagids) {
  6818. fields = append(fields, batchmsg.FieldTagids)
  6819. }
  6820. if m.FieldCleared(batchmsg.FieldTotal) {
  6821. fields = append(fields, batchmsg.FieldTotal)
  6822. }
  6823. if m.FieldCleared(batchmsg.FieldSuccess) {
  6824. fields = append(fields, batchmsg.FieldSuccess)
  6825. }
  6826. if m.FieldCleared(batchmsg.FieldFail) {
  6827. fields = append(fields, batchmsg.FieldFail)
  6828. }
  6829. if m.FieldCleared(batchmsg.FieldStartTime) {
  6830. fields = append(fields, batchmsg.FieldStartTime)
  6831. }
  6832. if m.FieldCleared(batchmsg.FieldStopTime) {
  6833. fields = append(fields, batchmsg.FieldStopTime)
  6834. }
  6835. if m.FieldCleared(batchmsg.FieldSendTime) {
  6836. fields = append(fields, batchmsg.FieldSendTime)
  6837. }
  6838. if m.FieldCleared(batchmsg.FieldType) {
  6839. fields = append(fields, batchmsg.FieldType)
  6840. }
  6841. if m.FieldCleared(batchmsg.FieldCc) {
  6842. fields = append(fields, batchmsg.FieldCc)
  6843. }
  6844. if m.FieldCleared(batchmsg.FieldPhone) {
  6845. fields = append(fields, batchmsg.FieldPhone)
  6846. }
  6847. if m.FieldCleared(batchmsg.FieldTemplateName) {
  6848. fields = append(fields, batchmsg.FieldTemplateName)
  6849. }
  6850. if m.FieldCleared(batchmsg.FieldTemplateCode) {
  6851. fields = append(fields, batchmsg.FieldTemplateCode)
  6852. }
  6853. if m.FieldCleared(batchmsg.FieldLang) {
  6854. fields = append(fields, batchmsg.FieldLang)
  6855. }
  6856. return fields
  6857. }
  6858. // FieldCleared returns a boolean indicating if a field with the given name was
  6859. // cleared in this mutation.
  6860. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  6861. _, ok := m.clearedFields[name]
  6862. return ok
  6863. }
  6864. // ClearField clears the value of the field with the given name. It returns an
  6865. // error if the field is not defined in the schema.
  6866. func (m *BatchMsgMutation) ClearField(name string) error {
  6867. switch name {
  6868. case batchmsg.FieldDeletedAt:
  6869. m.ClearDeletedAt()
  6870. return nil
  6871. case batchmsg.FieldStatus:
  6872. m.ClearStatus()
  6873. return nil
  6874. case batchmsg.FieldBatchNo:
  6875. m.ClearBatchNo()
  6876. return nil
  6877. case batchmsg.FieldTaskName:
  6878. m.ClearTaskName()
  6879. return nil
  6880. case batchmsg.FieldFromwxid:
  6881. m.ClearFromwxid()
  6882. return nil
  6883. case batchmsg.FieldMsg:
  6884. m.ClearMsg()
  6885. return nil
  6886. case batchmsg.FieldTag:
  6887. m.ClearTag()
  6888. return nil
  6889. case batchmsg.FieldTagids:
  6890. m.ClearTagids()
  6891. return nil
  6892. case batchmsg.FieldTotal:
  6893. m.ClearTotal()
  6894. return nil
  6895. case batchmsg.FieldSuccess:
  6896. m.ClearSuccess()
  6897. return nil
  6898. case batchmsg.FieldFail:
  6899. m.ClearFail()
  6900. return nil
  6901. case batchmsg.FieldStartTime:
  6902. m.ClearStartTime()
  6903. return nil
  6904. case batchmsg.FieldStopTime:
  6905. m.ClearStopTime()
  6906. return nil
  6907. case batchmsg.FieldSendTime:
  6908. m.ClearSendTime()
  6909. return nil
  6910. case batchmsg.FieldType:
  6911. m.ClearType()
  6912. return nil
  6913. case batchmsg.FieldCc:
  6914. m.ClearCc()
  6915. return nil
  6916. case batchmsg.FieldPhone:
  6917. m.ClearPhone()
  6918. return nil
  6919. case batchmsg.FieldTemplateName:
  6920. m.ClearTemplateName()
  6921. return nil
  6922. case batchmsg.FieldTemplateCode:
  6923. m.ClearTemplateCode()
  6924. return nil
  6925. case batchmsg.FieldLang:
  6926. m.ClearLang()
  6927. return nil
  6928. }
  6929. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  6930. }
  6931. // ResetField resets all changes in the mutation for the field with the given name.
  6932. // It returns an error if the field is not defined in the schema.
  6933. func (m *BatchMsgMutation) ResetField(name string) error {
  6934. switch name {
  6935. case batchmsg.FieldCreatedAt:
  6936. m.ResetCreatedAt()
  6937. return nil
  6938. case batchmsg.FieldUpdatedAt:
  6939. m.ResetUpdatedAt()
  6940. return nil
  6941. case batchmsg.FieldDeletedAt:
  6942. m.ResetDeletedAt()
  6943. return nil
  6944. case batchmsg.FieldStatus:
  6945. m.ResetStatus()
  6946. return nil
  6947. case batchmsg.FieldBatchNo:
  6948. m.ResetBatchNo()
  6949. return nil
  6950. case batchmsg.FieldTaskName:
  6951. m.ResetTaskName()
  6952. return nil
  6953. case batchmsg.FieldFromwxid:
  6954. m.ResetFromwxid()
  6955. return nil
  6956. case batchmsg.FieldMsg:
  6957. m.ResetMsg()
  6958. return nil
  6959. case batchmsg.FieldTag:
  6960. m.ResetTag()
  6961. return nil
  6962. case batchmsg.FieldTagids:
  6963. m.ResetTagids()
  6964. return nil
  6965. case batchmsg.FieldTotal:
  6966. m.ResetTotal()
  6967. return nil
  6968. case batchmsg.FieldSuccess:
  6969. m.ResetSuccess()
  6970. return nil
  6971. case batchmsg.FieldFail:
  6972. m.ResetFail()
  6973. return nil
  6974. case batchmsg.FieldStartTime:
  6975. m.ResetStartTime()
  6976. return nil
  6977. case batchmsg.FieldStopTime:
  6978. m.ResetStopTime()
  6979. return nil
  6980. case batchmsg.FieldSendTime:
  6981. m.ResetSendTime()
  6982. return nil
  6983. case batchmsg.FieldType:
  6984. m.ResetType()
  6985. return nil
  6986. case batchmsg.FieldOrganizationID:
  6987. m.ResetOrganizationID()
  6988. return nil
  6989. case batchmsg.FieldCtype:
  6990. m.ResetCtype()
  6991. return nil
  6992. case batchmsg.FieldCc:
  6993. m.ResetCc()
  6994. return nil
  6995. case batchmsg.FieldPhone:
  6996. m.ResetPhone()
  6997. return nil
  6998. case batchmsg.FieldTemplateName:
  6999. m.ResetTemplateName()
  7000. return nil
  7001. case batchmsg.FieldTemplateCode:
  7002. m.ResetTemplateCode()
  7003. return nil
  7004. case batchmsg.FieldLang:
  7005. m.ResetLang()
  7006. return nil
  7007. }
  7008. return fmt.Errorf("unknown BatchMsg field %s", name)
  7009. }
  7010. // AddedEdges returns all edge names that were set/added in this mutation.
  7011. func (m *BatchMsgMutation) AddedEdges() []string {
  7012. edges := make([]string, 0, 0)
  7013. return edges
  7014. }
  7015. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7016. // name in this mutation.
  7017. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  7018. return nil
  7019. }
  7020. // RemovedEdges returns all edge names that were removed in this mutation.
  7021. func (m *BatchMsgMutation) RemovedEdges() []string {
  7022. edges := make([]string, 0, 0)
  7023. return edges
  7024. }
  7025. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7026. // the given name in this mutation.
  7027. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  7028. return nil
  7029. }
  7030. // ClearedEdges returns all edge names that were cleared in this mutation.
  7031. func (m *BatchMsgMutation) ClearedEdges() []string {
  7032. edges := make([]string, 0, 0)
  7033. return edges
  7034. }
  7035. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7036. // was cleared in this mutation.
  7037. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  7038. return false
  7039. }
  7040. // ClearEdge clears the value of the edge with the given name. It returns an error
  7041. // if that edge is not defined in the schema.
  7042. func (m *BatchMsgMutation) ClearEdge(name string) error {
  7043. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  7044. }
  7045. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7046. // It returns an error if the edge is not defined in the schema.
  7047. func (m *BatchMsgMutation) ResetEdge(name string) error {
  7048. return fmt.Errorf("unknown BatchMsg edge %s", name)
  7049. }
  7050. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  7051. type CategoryMutation struct {
  7052. config
  7053. op Op
  7054. typ string
  7055. id *uint64
  7056. created_at *time.Time
  7057. updated_at *time.Time
  7058. deleted_at *time.Time
  7059. name *string
  7060. organization_id *uint64
  7061. addorganization_id *int64
  7062. clearedFields map[string]struct{}
  7063. done bool
  7064. oldValue func(context.Context) (*Category, error)
  7065. predicates []predicate.Category
  7066. }
  7067. var _ ent.Mutation = (*CategoryMutation)(nil)
  7068. // categoryOption allows management of the mutation configuration using functional options.
  7069. type categoryOption func(*CategoryMutation)
  7070. // newCategoryMutation creates new mutation for the Category entity.
  7071. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  7072. m := &CategoryMutation{
  7073. config: c,
  7074. op: op,
  7075. typ: TypeCategory,
  7076. clearedFields: make(map[string]struct{}),
  7077. }
  7078. for _, opt := range opts {
  7079. opt(m)
  7080. }
  7081. return m
  7082. }
  7083. // withCategoryID sets the ID field of the mutation.
  7084. func withCategoryID(id uint64) categoryOption {
  7085. return func(m *CategoryMutation) {
  7086. var (
  7087. err error
  7088. once sync.Once
  7089. value *Category
  7090. )
  7091. m.oldValue = func(ctx context.Context) (*Category, error) {
  7092. once.Do(func() {
  7093. if m.done {
  7094. err = errors.New("querying old values post mutation is not allowed")
  7095. } else {
  7096. value, err = m.Client().Category.Get(ctx, id)
  7097. }
  7098. })
  7099. return value, err
  7100. }
  7101. m.id = &id
  7102. }
  7103. }
  7104. // withCategory sets the old Category of the mutation.
  7105. func withCategory(node *Category) categoryOption {
  7106. return func(m *CategoryMutation) {
  7107. m.oldValue = func(context.Context) (*Category, error) {
  7108. return node, nil
  7109. }
  7110. m.id = &node.ID
  7111. }
  7112. }
  7113. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7114. // executed in a transaction (ent.Tx), a transactional client is returned.
  7115. func (m CategoryMutation) Client() *Client {
  7116. client := &Client{config: m.config}
  7117. client.init()
  7118. return client
  7119. }
  7120. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7121. // it returns an error otherwise.
  7122. func (m CategoryMutation) Tx() (*Tx, error) {
  7123. if _, ok := m.driver.(*txDriver); !ok {
  7124. return nil, errors.New("ent: mutation is not running in a transaction")
  7125. }
  7126. tx := &Tx{config: m.config}
  7127. tx.init()
  7128. return tx, nil
  7129. }
  7130. // SetID sets the value of the id field. Note that this
  7131. // operation is only accepted on creation of Category entities.
  7132. func (m *CategoryMutation) SetID(id uint64) {
  7133. m.id = &id
  7134. }
  7135. // ID returns the ID value in the mutation. Note that the ID is only available
  7136. // if it was provided to the builder or after it was returned from the database.
  7137. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  7138. if m.id == nil {
  7139. return
  7140. }
  7141. return *m.id, true
  7142. }
  7143. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7144. // That means, if the mutation is applied within a transaction with an isolation level such
  7145. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7146. // or updated by the mutation.
  7147. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  7148. switch {
  7149. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7150. id, exists := m.ID()
  7151. if exists {
  7152. return []uint64{id}, nil
  7153. }
  7154. fallthrough
  7155. case m.op.Is(OpUpdate | OpDelete):
  7156. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  7157. default:
  7158. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7159. }
  7160. }
  7161. // SetCreatedAt sets the "created_at" field.
  7162. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  7163. m.created_at = &t
  7164. }
  7165. // CreatedAt returns the value of the "created_at" field in the mutation.
  7166. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  7167. v := m.created_at
  7168. if v == nil {
  7169. return
  7170. }
  7171. return *v, true
  7172. }
  7173. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  7174. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7175. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7176. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7177. if !m.op.Is(OpUpdateOne) {
  7178. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7179. }
  7180. if m.id == nil || m.oldValue == nil {
  7181. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7182. }
  7183. oldValue, err := m.oldValue(ctx)
  7184. if err != nil {
  7185. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7186. }
  7187. return oldValue.CreatedAt, nil
  7188. }
  7189. // ResetCreatedAt resets all changes to the "created_at" field.
  7190. func (m *CategoryMutation) ResetCreatedAt() {
  7191. m.created_at = nil
  7192. }
  7193. // SetUpdatedAt sets the "updated_at" field.
  7194. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  7195. m.updated_at = &t
  7196. }
  7197. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7198. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  7199. v := m.updated_at
  7200. if v == nil {
  7201. return
  7202. }
  7203. return *v, true
  7204. }
  7205. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  7206. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7207. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7208. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7209. if !m.op.Is(OpUpdateOne) {
  7210. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7211. }
  7212. if m.id == nil || m.oldValue == nil {
  7213. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7214. }
  7215. oldValue, err := m.oldValue(ctx)
  7216. if err != nil {
  7217. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7218. }
  7219. return oldValue.UpdatedAt, nil
  7220. }
  7221. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7222. func (m *CategoryMutation) ResetUpdatedAt() {
  7223. m.updated_at = nil
  7224. }
  7225. // SetDeletedAt sets the "deleted_at" field.
  7226. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  7227. m.deleted_at = &t
  7228. }
  7229. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7230. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  7231. v := m.deleted_at
  7232. if v == nil {
  7233. return
  7234. }
  7235. return *v, true
  7236. }
  7237. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  7238. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7239. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7240. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7241. if !m.op.Is(OpUpdateOne) {
  7242. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7243. }
  7244. if m.id == nil || m.oldValue == nil {
  7245. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7246. }
  7247. oldValue, err := m.oldValue(ctx)
  7248. if err != nil {
  7249. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7250. }
  7251. return oldValue.DeletedAt, nil
  7252. }
  7253. // ClearDeletedAt clears the value of the "deleted_at" field.
  7254. func (m *CategoryMutation) ClearDeletedAt() {
  7255. m.deleted_at = nil
  7256. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  7257. }
  7258. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7259. func (m *CategoryMutation) DeletedAtCleared() bool {
  7260. _, ok := m.clearedFields[category.FieldDeletedAt]
  7261. return ok
  7262. }
  7263. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7264. func (m *CategoryMutation) ResetDeletedAt() {
  7265. m.deleted_at = nil
  7266. delete(m.clearedFields, category.FieldDeletedAt)
  7267. }
  7268. // SetName sets the "name" field.
  7269. func (m *CategoryMutation) SetName(s string) {
  7270. m.name = &s
  7271. }
  7272. // Name returns the value of the "name" field in the mutation.
  7273. func (m *CategoryMutation) Name() (r string, exists bool) {
  7274. v := m.name
  7275. if v == nil {
  7276. return
  7277. }
  7278. return *v, true
  7279. }
  7280. // OldName returns the old "name" field's value of the Category entity.
  7281. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7282. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7283. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  7284. if !m.op.Is(OpUpdateOne) {
  7285. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7286. }
  7287. if m.id == nil || m.oldValue == nil {
  7288. return v, errors.New("OldName requires an ID field in the mutation")
  7289. }
  7290. oldValue, err := m.oldValue(ctx)
  7291. if err != nil {
  7292. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7293. }
  7294. return oldValue.Name, nil
  7295. }
  7296. // ResetName resets all changes to the "name" field.
  7297. func (m *CategoryMutation) ResetName() {
  7298. m.name = nil
  7299. }
  7300. // SetOrganizationID sets the "organization_id" field.
  7301. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  7302. m.organization_id = &u
  7303. m.addorganization_id = nil
  7304. }
  7305. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7306. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  7307. v := m.organization_id
  7308. if v == nil {
  7309. return
  7310. }
  7311. return *v, true
  7312. }
  7313. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  7314. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7316. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7317. if !m.op.Is(OpUpdateOne) {
  7318. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7319. }
  7320. if m.id == nil || m.oldValue == nil {
  7321. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  7322. }
  7323. oldValue, err := m.oldValue(ctx)
  7324. if err != nil {
  7325. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  7326. }
  7327. return oldValue.OrganizationID, nil
  7328. }
  7329. // AddOrganizationID adds u to the "organization_id" field.
  7330. func (m *CategoryMutation) AddOrganizationID(u int64) {
  7331. if m.addorganization_id != nil {
  7332. *m.addorganization_id += u
  7333. } else {
  7334. m.addorganization_id = &u
  7335. }
  7336. }
  7337. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7338. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  7339. v := m.addorganization_id
  7340. if v == nil {
  7341. return
  7342. }
  7343. return *v, true
  7344. }
  7345. // ResetOrganizationID resets all changes to the "organization_id" field.
  7346. func (m *CategoryMutation) ResetOrganizationID() {
  7347. m.organization_id = nil
  7348. m.addorganization_id = nil
  7349. }
  7350. // Where appends a list predicates to the CategoryMutation builder.
  7351. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  7352. m.predicates = append(m.predicates, ps...)
  7353. }
  7354. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  7355. // users can use type-assertion to append predicates that do not depend on any generated package.
  7356. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  7357. p := make([]predicate.Category, len(ps))
  7358. for i := range ps {
  7359. p[i] = ps[i]
  7360. }
  7361. m.Where(p...)
  7362. }
  7363. // Op returns the operation name.
  7364. func (m *CategoryMutation) Op() Op {
  7365. return m.op
  7366. }
  7367. // SetOp allows setting the mutation operation.
  7368. func (m *CategoryMutation) SetOp(op Op) {
  7369. m.op = op
  7370. }
  7371. // Type returns the node type of this mutation (Category).
  7372. func (m *CategoryMutation) Type() string {
  7373. return m.typ
  7374. }
  7375. // Fields returns all fields that were changed during this mutation. Note that in
  7376. // order to get all numeric fields that were incremented/decremented, call
  7377. // AddedFields().
  7378. func (m *CategoryMutation) Fields() []string {
  7379. fields := make([]string, 0, 5)
  7380. if m.created_at != nil {
  7381. fields = append(fields, category.FieldCreatedAt)
  7382. }
  7383. if m.updated_at != nil {
  7384. fields = append(fields, category.FieldUpdatedAt)
  7385. }
  7386. if m.deleted_at != nil {
  7387. fields = append(fields, category.FieldDeletedAt)
  7388. }
  7389. if m.name != nil {
  7390. fields = append(fields, category.FieldName)
  7391. }
  7392. if m.organization_id != nil {
  7393. fields = append(fields, category.FieldOrganizationID)
  7394. }
  7395. return fields
  7396. }
  7397. // Field returns the value of a field with the given name. The second boolean
  7398. // return value indicates that this field was not set, or was not defined in the
  7399. // schema.
  7400. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  7401. switch name {
  7402. case category.FieldCreatedAt:
  7403. return m.CreatedAt()
  7404. case category.FieldUpdatedAt:
  7405. return m.UpdatedAt()
  7406. case category.FieldDeletedAt:
  7407. return m.DeletedAt()
  7408. case category.FieldName:
  7409. return m.Name()
  7410. case category.FieldOrganizationID:
  7411. return m.OrganizationID()
  7412. }
  7413. return nil, false
  7414. }
  7415. // OldField returns the old value of the field from the database. An error is
  7416. // returned if the mutation operation is not UpdateOne, or the query to the
  7417. // database failed.
  7418. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7419. switch name {
  7420. case category.FieldCreatedAt:
  7421. return m.OldCreatedAt(ctx)
  7422. case category.FieldUpdatedAt:
  7423. return m.OldUpdatedAt(ctx)
  7424. case category.FieldDeletedAt:
  7425. return m.OldDeletedAt(ctx)
  7426. case category.FieldName:
  7427. return m.OldName(ctx)
  7428. case category.FieldOrganizationID:
  7429. return m.OldOrganizationID(ctx)
  7430. }
  7431. return nil, fmt.Errorf("unknown Category field %s", name)
  7432. }
  7433. // SetField sets the value of a field with the given name. It returns an error if
  7434. // the field is not defined in the schema, or if the type mismatched the field
  7435. // type.
  7436. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  7437. switch name {
  7438. case category.FieldCreatedAt:
  7439. v, ok := value.(time.Time)
  7440. if !ok {
  7441. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7442. }
  7443. m.SetCreatedAt(v)
  7444. return nil
  7445. case category.FieldUpdatedAt:
  7446. v, ok := value.(time.Time)
  7447. if !ok {
  7448. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7449. }
  7450. m.SetUpdatedAt(v)
  7451. return nil
  7452. case category.FieldDeletedAt:
  7453. v, ok := value.(time.Time)
  7454. if !ok {
  7455. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7456. }
  7457. m.SetDeletedAt(v)
  7458. return nil
  7459. case category.FieldName:
  7460. v, ok := value.(string)
  7461. if !ok {
  7462. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7463. }
  7464. m.SetName(v)
  7465. return nil
  7466. case category.FieldOrganizationID:
  7467. v, ok := value.(uint64)
  7468. if !ok {
  7469. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7470. }
  7471. m.SetOrganizationID(v)
  7472. return nil
  7473. }
  7474. return fmt.Errorf("unknown Category field %s", name)
  7475. }
  7476. // AddedFields returns all numeric fields that were incremented/decremented during
  7477. // this mutation.
  7478. func (m *CategoryMutation) AddedFields() []string {
  7479. var fields []string
  7480. if m.addorganization_id != nil {
  7481. fields = append(fields, category.FieldOrganizationID)
  7482. }
  7483. return fields
  7484. }
  7485. // AddedField returns the numeric value that was incremented/decremented on a field
  7486. // with the given name. The second boolean return value indicates that this field
  7487. // was not set, or was not defined in the schema.
  7488. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  7489. switch name {
  7490. case category.FieldOrganizationID:
  7491. return m.AddedOrganizationID()
  7492. }
  7493. return nil, false
  7494. }
  7495. // AddField adds the value to the field with the given name. It returns an error if
  7496. // the field is not defined in the schema, or if the type mismatched the field
  7497. // type.
  7498. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  7499. switch name {
  7500. case category.FieldOrganizationID:
  7501. v, ok := value.(int64)
  7502. if !ok {
  7503. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7504. }
  7505. m.AddOrganizationID(v)
  7506. return nil
  7507. }
  7508. return fmt.Errorf("unknown Category numeric field %s", name)
  7509. }
  7510. // ClearedFields returns all nullable fields that were cleared during this
  7511. // mutation.
  7512. func (m *CategoryMutation) ClearedFields() []string {
  7513. var fields []string
  7514. if m.FieldCleared(category.FieldDeletedAt) {
  7515. fields = append(fields, category.FieldDeletedAt)
  7516. }
  7517. return fields
  7518. }
  7519. // FieldCleared returns a boolean indicating if a field with the given name was
  7520. // cleared in this mutation.
  7521. func (m *CategoryMutation) FieldCleared(name string) bool {
  7522. _, ok := m.clearedFields[name]
  7523. return ok
  7524. }
  7525. // ClearField clears the value of the field with the given name. It returns an
  7526. // error if the field is not defined in the schema.
  7527. func (m *CategoryMutation) ClearField(name string) error {
  7528. switch name {
  7529. case category.FieldDeletedAt:
  7530. m.ClearDeletedAt()
  7531. return nil
  7532. }
  7533. return fmt.Errorf("unknown Category nullable field %s", name)
  7534. }
  7535. // ResetField resets all changes in the mutation for the field with the given name.
  7536. // It returns an error if the field is not defined in the schema.
  7537. func (m *CategoryMutation) ResetField(name string) error {
  7538. switch name {
  7539. case category.FieldCreatedAt:
  7540. m.ResetCreatedAt()
  7541. return nil
  7542. case category.FieldUpdatedAt:
  7543. m.ResetUpdatedAt()
  7544. return nil
  7545. case category.FieldDeletedAt:
  7546. m.ResetDeletedAt()
  7547. return nil
  7548. case category.FieldName:
  7549. m.ResetName()
  7550. return nil
  7551. case category.FieldOrganizationID:
  7552. m.ResetOrganizationID()
  7553. return nil
  7554. }
  7555. return fmt.Errorf("unknown Category field %s", name)
  7556. }
  7557. // AddedEdges returns all edge names that were set/added in this mutation.
  7558. func (m *CategoryMutation) AddedEdges() []string {
  7559. edges := make([]string, 0, 0)
  7560. return edges
  7561. }
  7562. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7563. // name in this mutation.
  7564. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  7565. return nil
  7566. }
  7567. // RemovedEdges returns all edge names that were removed in this mutation.
  7568. func (m *CategoryMutation) RemovedEdges() []string {
  7569. edges := make([]string, 0, 0)
  7570. return edges
  7571. }
  7572. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7573. // the given name in this mutation.
  7574. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  7575. return nil
  7576. }
  7577. // ClearedEdges returns all edge names that were cleared in this mutation.
  7578. func (m *CategoryMutation) ClearedEdges() []string {
  7579. edges := make([]string, 0, 0)
  7580. return edges
  7581. }
  7582. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7583. // was cleared in this mutation.
  7584. func (m *CategoryMutation) EdgeCleared(name string) bool {
  7585. return false
  7586. }
  7587. // ClearEdge clears the value of the edge with the given name. It returns an error
  7588. // if that edge is not defined in the schema.
  7589. func (m *CategoryMutation) ClearEdge(name string) error {
  7590. return fmt.Errorf("unknown Category unique edge %s", name)
  7591. }
  7592. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7593. // It returns an error if the edge is not defined in the schema.
  7594. func (m *CategoryMutation) ResetEdge(name string) error {
  7595. return fmt.Errorf("unknown Category edge %s", name)
  7596. }
  7597. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  7598. type ChatRecordsMutation struct {
  7599. config
  7600. op Op
  7601. typ string
  7602. id *uint64
  7603. created_at *time.Time
  7604. updated_at *time.Time
  7605. deleted_at *time.Time
  7606. content *string
  7607. content_type *uint8
  7608. addcontent_type *int8
  7609. session_id *uint64
  7610. addsession_id *int64
  7611. user_id *uint64
  7612. adduser_id *int64
  7613. bot_id *uint64
  7614. addbot_id *int64
  7615. bot_type *uint8
  7616. addbot_type *int8
  7617. clearedFields map[string]struct{}
  7618. done bool
  7619. oldValue func(context.Context) (*ChatRecords, error)
  7620. predicates []predicate.ChatRecords
  7621. }
  7622. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  7623. // chatrecordsOption allows management of the mutation configuration using functional options.
  7624. type chatrecordsOption func(*ChatRecordsMutation)
  7625. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  7626. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  7627. m := &ChatRecordsMutation{
  7628. config: c,
  7629. op: op,
  7630. typ: TypeChatRecords,
  7631. clearedFields: make(map[string]struct{}),
  7632. }
  7633. for _, opt := range opts {
  7634. opt(m)
  7635. }
  7636. return m
  7637. }
  7638. // withChatRecordsID sets the ID field of the mutation.
  7639. func withChatRecordsID(id uint64) chatrecordsOption {
  7640. return func(m *ChatRecordsMutation) {
  7641. var (
  7642. err error
  7643. once sync.Once
  7644. value *ChatRecords
  7645. )
  7646. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  7647. once.Do(func() {
  7648. if m.done {
  7649. err = errors.New("querying old values post mutation is not allowed")
  7650. } else {
  7651. value, err = m.Client().ChatRecords.Get(ctx, id)
  7652. }
  7653. })
  7654. return value, err
  7655. }
  7656. m.id = &id
  7657. }
  7658. }
  7659. // withChatRecords sets the old ChatRecords of the mutation.
  7660. func withChatRecords(node *ChatRecords) chatrecordsOption {
  7661. return func(m *ChatRecordsMutation) {
  7662. m.oldValue = func(context.Context) (*ChatRecords, error) {
  7663. return node, nil
  7664. }
  7665. m.id = &node.ID
  7666. }
  7667. }
  7668. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7669. // executed in a transaction (ent.Tx), a transactional client is returned.
  7670. func (m ChatRecordsMutation) Client() *Client {
  7671. client := &Client{config: m.config}
  7672. client.init()
  7673. return client
  7674. }
  7675. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7676. // it returns an error otherwise.
  7677. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  7678. if _, ok := m.driver.(*txDriver); !ok {
  7679. return nil, errors.New("ent: mutation is not running in a transaction")
  7680. }
  7681. tx := &Tx{config: m.config}
  7682. tx.init()
  7683. return tx, nil
  7684. }
  7685. // SetID sets the value of the id field. Note that this
  7686. // operation is only accepted on creation of ChatRecords entities.
  7687. func (m *ChatRecordsMutation) SetID(id uint64) {
  7688. m.id = &id
  7689. }
  7690. // ID returns the ID value in the mutation. Note that the ID is only available
  7691. // if it was provided to the builder or after it was returned from the database.
  7692. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  7693. if m.id == nil {
  7694. return
  7695. }
  7696. return *m.id, true
  7697. }
  7698. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7699. // That means, if the mutation is applied within a transaction with an isolation level such
  7700. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7701. // or updated by the mutation.
  7702. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  7703. switch {
  7704. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7705. id, exists := m.ID()
  7706. if exists {
  7707. return []uint64{id}, nil
  7708. }
  7709. fallthrough
  7710. case m.op.Is(OpUpdate | OpDelete):
  7711. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  7712. default:
  7713. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7714. }
  7715. }
  7716. // SetCreatedAt sets the "created_at" field.
  7717. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  7718. m.created_at = &t
  7719. }
  7720. // CreatedAt returns the value of the "created_at" field in the mutation.
  7721. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  7722. v := m.created_at
  7723. if v == nil {
  7724. return
  7725. }
  7726. return *v, true
  7727. }
  7728. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  7729. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7730. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7731. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7732. if !m.op.Is(OpUpdateOne) {
  7733. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7734. }
  7735. if m.id == nil || m.oldValue == nil {
  7736. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7737. }
  7738. oldValue, err := m.oldValue(ctx)
  7739. if err != nil {
  7740. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7741. }
  7742. return oldValue.CreatedAt, nil
  7743. }
  7744. // ResetCreatedAt resets all changes to the "created_at" field.
  7745. func (m *ChatRecordsMutation) ResetCreatedAt() {
  7746. m.created_at = nil
  7747. }
  7748. // SetUpdatedAt sets the "updated_at" field.
  7749. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  7750. m.updated_at = &t
  7751. }
  7752. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7753. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  7754. v := m.updated_at
  7755. if v == nil {
  7756. return
  7757. }
  7758. return *v, true
  7759. }
  7760. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  7761. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7762. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7763. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7764. if !m.op.Is(OpUpdateOne) {
  7765. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7766. }
  7767. if m.id == nil || m.oldValue == nil {
  7768. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7769. }
  7770. oldValue, err := m.oldValue(ctx)
  7771. if err != nil {
  7772. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7773. }
  7774. return oldValue.UpdatedAt, nil
  7775. }
  7776. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7777. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  7778. m.updated_at = nil
  7779. }
  7780. // SetDeletedAt sets the "deleted_at" field.
  7781. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  7782. m.deleted_at = &t
  7783. }
  7784. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7785. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  7786. v := m.deleted_at
  7787. if v == nil {
  7788. return
  7789. }
  7790. return *v, true
  7791. }
  7792. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  7793. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7794. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7795. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7796. if !m.op.Is(OpUpdateOne) {
  7797. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7798. }
  7799. if m.id == nil || m.oldValue == nil {
  7800. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7801. }
  7802. oldValue, err := m.oldValue(ctx)
  7803. if err != nil {
  7804. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7805. }
  7806. return oldValue.DeletedAt, nil
  7807. }
  7808. // ClearDeletedAt clears the value of the "deleted_at" field.
  7809. func (m *ChatRecordsMutation) ClearDeletedAt() {
  7810. m.deleted_at = nil
  7811. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  7812. }
  7813. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7814. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  7815. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  7816. return ok
  7817. }
  7818. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7819. func (m *ChatRecordsMutation) ResetDeletedAt() {
  7820. m.deleted_at = nil
  7821. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  7822. }
  7823. // SetContent sets the "content" field.
  7824. func (m *ChatRecordsMutation) SetContent(s string) {
  7825. m.content = &s
  7826. }
  7827. // Content returns the value of the "content" field in the mutation.
  7828. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  7829. v := m.content
  7830. if v == nil {
  7831. return
  7832. }
  7833. return *v, true
  7834. }
  7835. // OldContent returns the old "content" field's value of the ChatRecords entity.
  7836. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7837. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7838. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  7839. if !m.op.Is(OpUpdateOne) {
  7840. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  7841. }
  7842. if m.id == nil || m.oldValue == nil {
  7843. return v, errors.New("OldContent requires an ID field in the mutation")
  7844. }
  7845. oldValue, err := m.oldValue(ctx)
  7846. if err != nil {
  7847. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  7848. }
  7849. return oldValue.Content, nil
  7850. }
  7851. // ResetContent resets all changes to the "content" field.
  7852. func (m *ChatRecordsMutation) ResetContent() {
  7853. m.content = nil
  7854. }
  7855. // SetContentType sets the "content_type" field.
  7856. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  7857. m.content_type = &u
  7858. m.addcontent_type = nil
  7859. }
  7860. // ContentType returns the value of the "content_type" field in the mutation.
  7861. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  7862. v := m.content_type
  7863. if v == nil {
  7864. return
  7865. }
  7866. return *v, true
  7867. }
  7868. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  7869. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7870. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7871. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  7872. if !m.op.Is(OpUpdateOne) {
  7873. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  7874. }
  7875. if m.id == nil || m.oldValue == nil {
  7876. return v, errors.New("OldContentType requires an ID field in the mutation")
  7877. }
  7878. oldValue, err := m.oldValue(ctx)
  7879. if err != nil {
  7880. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  7881. }
  7882. return oldValue.ContentType, nil
  7883. }
  7884. // AddContentType adds u to the "content_type" field.
  7885. func (m *ChatRecordsMutation) AddContentType(u int8) {
  7886. if m.addcontent_type != nil {
  7887. *m.addcontent_type += u
  7888. } else {
  7889. m.addcontent_type = &u
  7890. }
  7891. }
  7892. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  7893. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  7894. v := m.addcontent_type
  7895. if v == nil {
  7896. return
  7897. }
  7898. return *v, true
  7899. }
  7900. // ResetContentType resets all changes to the "content_type" field.
  7901. func (m *ChatRecordsMutation) ResetContentType() {
  7902. m.content_type = nil
  7903. m.addcontent_type = nil
  7904. }
  7905. // SetSessionID sets the "session_id" field.
  7906. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  7907. m.session_id = &u
  7908. m.addsession_id = nil
  7909. }
  7910. // SessionID returns the value of the "session_id" field in the mutation.
  7911. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  7912. v := m.session_id
  7913. if v == nil {
  7914. return
  7915. }
  7916. return *v, true
  7917. }
  7918. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  7919. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7920. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7921. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  7922. if !m.op.Is(OpUpdateOne) {
  7923. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  7924. }
  7925. if m.id == nil || m.oldValue == nil {
  7926. return v, errors.New("OldSessionID requires an ID field in the mutation")
  7927. }
  7928. oldValue, err := m.oldValue(ctx)
  7929. if err != nil {
  7930. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  7931. }
  7932. return oldValue.SessionID, nil
  7933. }
  7934. // AddSessionID adds u to the "session_id" field.
  7935. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  7936. if m.addsession_id != nil {
  7937. *m.addsession_id += u
  7938. } else {
  7939. m.addsession_id = &u
  7940. }
  7941. }
  7942. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  7943. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  7944. v := m.addsession_id
  7945. if v == nil {
  7946. return
  7947. }
  7948. return *v, true
  7949. }
  7950. // ResetSessionID resets all changes to the "session_id" field.
  7951. func (m *ChatRecordsMutation) ResetSessionID() {
  7952. m.session_id = nil
  7953. m.addsession_id = nil
  7954. }
  7955. // SetUserID sets the "user_id" field.
  7956. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  7957. m.user_id = &u
  7958. m.adduser_id = nil
  7959. }
  7960. // UserID returns the value of the "user_id" field in the mutation.
  7961. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  7962. v := m.user_id
  7963. if v == nil {
  7964. return
  7965. }
  7966. return *v, true
  7967. }
  7968. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  7969. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7970. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7971. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  7972. if !m.op.Is(OpUpdateOne) {
  7973. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  7974. }
  7975. if m.id == nil || m.oldValue == nil {
  7976. return v, errors.New("OldUserID requires an ID field in the mutation")
  7977. }
  7978. oldValue, err := m.oldValue(ctx)
  7979. if err != nil {
  7980. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  7981. }
  7982. return oldValue.UserID, nil
  7983. }
  7984. // AddUserID adds u to the "user_id" field.
  7985. func (m *ChatRecordsMutation) AddUserID(u int64) {
  7986. if m.adduser_id != nil {
  7987. *m.adduser_id += u
  7988. } else {
  7989. m.adduser_id = &u
  7990. }
  7991. }
  7992. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  7993. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  7994. v := m.adduser_id
  7995. if v == nil {
  7996. return
  7997. }
  7998. return *v, true
  7999. }
  8000. // ResetUserID resets all changes to the "user_id" field.
  8001. func (m *ChatRecordsMutation) ResetUserID() {
  8002. m.user_id = nil
  8003. m.adduser_id = nil
  8004. }
  8005. // SetBotID sets the "bot_id" field.
  8006. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  8007. m.bot_id = &u
  8008. m.addbot_id = nil
  8009. }
  8010. // BotID returns the value of the "bot_id" field in the mutation.
  8011. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  8012. v := m.bot_id
  8013. if v == nil {
  8014. return
  8015. }
  8016. return *v, true
  8017. }
  8018. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  8019. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8020. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8021. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  8022. if !m.op.Is(OpUpdateOne) {
  8023. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  8024. }
  8025. if m.id == nil || m.oldValue == nil {
  8026. return v, errors.New("OldBotID requires an ID field in the mutation")
  8027. }
  8028. oldValue, err := m.oldValue(ctx)
  8029. if err != nil {
  8030. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  8031. }
  8032. return oldValue.BotID, nil
  8033. }
  8034. // AddBotID adds u to the "bot_id" field.
  8035. func (m *ChatRecordsMutation) AddBotID(u int64) {
  8036. if m.addbot_id != nil {
  8037. *m.addbot_id += u
  8038. } else {
  8039. m.addbot_id = &u
  8040. }
  8041. }
  8042. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  8043. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  8044. v := m.addbot_id
  8045. if v == nil {
  8046. return
  8047. }
  8048. return *v, true
  8049. }
  8050. // ResetBotID resets all changes to the "bot_id" field.
  8051. func (m *ChatRecordsMutation) ResetBotID() {
  8052. m.bot_id = nil
  8053. m.addbot_id = nil
  8054. }
  8055. // SetBotType sets the "bot_type" field.
  8056. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  8057. m.bot_type = &u
  8058. m.addbot_type = nil
  8059. }
  8060. // BotType returns the value of the "bot_type" field in the mutation.
  8061. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  8062. v := m.bot_type
  8063. if v == nil {
  8064. return
  8065. }
  8066. return *v, true
  8067. }
  8068. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  8069. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8070. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8071. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  8072. if !m.op.Is(OpUpdateOne) {
  8073. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  8074. }
  8075. if m.id == nil || m.oldValue == nil {
  8076. return v, errors.New("OldBotType requires an ID field in the mutation")
  8077. }
  8078. oldValue, err := m.oldValue(ctx)
  8079. if err != nil {
  8080. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  8081. }
  8082. return oldValue.BotType, nil
  8083. }
  8084. // AddBotType adds u to the "bot_type" field.
  8085. func (m *ChatRecordsMutation) AddBotType(u int8) {
  8086. if m.addbot_type != nil {
  8087. *m.addbot_type += u
  8088. } else {
  8089. m.addbot_type = &u
  8090. }
  8091. }
  8092. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  8093. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  8094. v := m.addbot_type
  8095. if v == nil {
  8096. return
  8097. }
  8098. return *v, true
  8099. }
  8100. // ResetBotType resets all changes to the "bot_type" field.
  8101. func (m *ChatRecordsMutation) ResetBotType() {
  8102. m.bot_type = nil
  8103. m.addbot_type = nil
  8104. }
  8105. // Where appends a list predicates to the ChatRecordsMutation builder.
  8106. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  8107. m.predicates = append(m.predicates, ps...)
  8108. }
  8109. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  8110. // users can use type-assertion to append predicates that do not depend on any generated package.
  8111. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  8112. p := make([]predicate.ChatRecords, len(ps))
  8113. for i := range ps {
  8114. p[i] = ps[i]
  8115. }
  8116. m.Where(p...)
  8117. }
  8118. // Op returns the operation name.
  8119. func (m *ChatRecordsMutation) Op() Op {
  8120. return m.op
  8121. }
  8122. // SetOp allows setting the mutation operation.
  8123. func (m *ChatRecordsMutation) SetOp(op Op) {
  8124. m.op = op
  8125. }
  8126. // Type returns the node type of this mutation (ChatRecords).
  8127. func (m *ChatRecordsMutation) Type() string {
  8128. return m.typ
  8129. }
  8130. // Fields returns all fields that were changed during this mutation. Note that in
  8131. // order to get all numeric fields that were incremented/decremented, call
  8132. // AddedFields().
  8133. func (m *ChatRecordsMutation) Fields() []string {
  8134. fields := make([]string, 0, 9)
  8135. if m.created_at != nil {
  8136. fields = append(fields, chatrecords.FieldCreatedAt)
  8137. }
  8138. if m.updated_at != nil {
  8139. fields = append(fields, chatrecords.FieldUpdatedAt)
  8140. }
  8141. if m.deleted_at != nil {
  8142. fields = append(fields, chatrecords.FieldDeletedAt)
  8143. }
  8144. if m.content != nil {
  8145. fields = append(fields, chatrecords.FieldContent)
  8146. }
  8147. if m.content_type != nil {
  8148. fields = append(fields, chatrecords.FieldContentType)
  8149. }
  8150. if m.session_id != nil {
  8151. fields = append(fields, chatrecords.FieldSessionID)
  8152. }
  8153. if m.user_id != nil {
  8154. fields = append(fields, chatrecords.FieldUserID)
  8155. }
  8156. if m.bot_id != nil {
  8157. fields = append(fields, chatrecords.FieldBotID)
  8158. }
  8159. if m.bot_type != nil {
  8160. fields = append(fields, chatrecords.FieldBotType)
  8161. }
  8162. return fields
  8163. }
  8164. // Field returns the value of a field with the given name. The second boolean
  8165. // return value indicates that this field was not set, or was not defined in the
  8166. // schema.
  8167. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  8168. switch name {
  8169. case chatrecords.FieldCreatedAt:
  8170. return m.CreatedAt()
  8171. case chatrecords.FieldUpdatedAt:
  8172. return m.UpdatedAt()
  8173. case chatrecords.FieldDeletedAt:
  8174. return m.DeletedAt()
  8175. case chatrecords.FieldContent:
  8176. return m.Content()
  8177. case chatrecords.FieldContentType:
  8178. return m.ContentType()
  8179. case chatrecords.FieldSessionID:
  8180. return m.SessionID()
  8181. case chatrecords.FieldUserID:
  8182. return m.UserID()
  8183. case chatrecords.FieldBotID:
  8184. return m.BotID()
  8185. case chatrecords.FieldBotType:
  8186. return m.BotType()
  8187. }
  8188. return nil, false
  8189. }
  8190. // OldField returns the old value of the field from the database. An error is
  8191. // returned if the mutation operation is not UpdateOne, or the query to the
  8192. // database failed.
  8193. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8194. switch name {
  8195. case chatrecords.FieldCreatedAt:
  8196. return m.OldCreatedAt(ctx)
  8197. case chatrecords.FieldUpdatedAt:
  8198. return m.OldUpdatedAt(ctx)
  8199. case chatrecords.FieldDeletedAt:
  8200. return m.OldDeletedAt(ctx)
  8201. case chatrecords.FieldContent:
  8202. return m.OldContent(ctx)
  8203. case chatrecords.FieldContentType:
  8204. return m.OldContentType(ctx)
  8205. case chatrecords.FieldSessionID:
  8206. return m.OldSessionID(ctx)
  8207. case chatrecords.FieldUserID:
  8208. return m.OldUserID(ctx)
  8209. case chatrecords.FieldBotID:
  8210. return m.OldBotID(ctx)
  8211. case chatrecords.FieldBotType:
  8212. return m.OldBotType(ctx)
  8213. }
  8214. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  8215. }
  8216. // SetField sets the value of a field with the given name. It returns an error if
  8217. // the field is not defined in the schema, or if the type mismatched the field
  8218. // type.
  8219. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  8220. switch name {
  8221. case chatrecords.FieldCreatedAt:
  8222. v, ok := value.(time.Time)
  8223. if !ok {
  8224. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8225. }
  8226. m.SetCreatedAt(v)
  8227. return nil
  8228. case chatrecords.FieldUpdatedAt:
  8229. v, ok := value.(time.Time)
  8230. if !ok {
  8231. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8232. }
  8233. m.SetUpdatedAt(v)
  8234. return nil
  8235. case chatrecords.FieldDeletedAt:
  8236. v, ok := value.(time.Time)
  8237. if !ok {
  8238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8239. }
  8240. m.SetDeletedAt(v)
  8241. return nil
  8242. case chatrecords.FieldContent:
  8243. v, ok := value.(string)
  8244. if !ok {
  8245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8246. }
  8247. m.SetContent(v)
  8248. return nil
  8249. case chatrecords.FieldContentType:
  8250. v, ok := value.(uint8)
  8251. if !ok {
  8252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8253. }
  8254. m.SetContentType(v)
  8255. return nil
  8256. case chatrecords.FieldSessionID:
  8257. v, ok := value.(uint64)
  8258. if !ok {
  8259. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8260. }
  8261. m.SetSessionID(v)
  8262. return nil
  8263. case chatrecords.FieldUserID:
  8264. v, ok := value.(uint64)
  8265. if !ok {
  8266. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8267. }
  8268. m.SetUserID(v)
  8269. return nil
  8270. case chatrecords.FieldBotID:
  8271. v, ok := value.(uint64)
  8272. if !ok {
  8273. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8274. }
  8275. m.SetBotID(v)
  8276. return nil
  8277. case chatrecords.FieldBotType:
  8278. v, ok := value.(uint8)
  8279. if !ok {
  8280. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8281. }
  8282. m.SetBotType(v)
  8283. return nil
  8284. }
  8285. return fmt.Errorf("unknown ChatRecords field %s", name)
  8286. }
  8287. // AddedFields returns all numeric fields that were incremented/decremented during
  8288. // this mutation.
  8289. func (m *ChatRecordsMutation) AddedFields() []string {
  8290. var fields []string
  8291. if m.addcontent_type != nil {
  8292. fields = append(fields, chatrecords.FieldContentType)
  8293. }
  8294. if m.addsession_id != nil {
  8295. fields = append(fields, chatrecords.FieldSessionID)
  8296. }
  8297. if m.adduser_id != nil {
  8298. fields = append(fields, chatrecords.FieldUserID)
  8299. }
  8300. if m.addbot_id != nil {
  8301. fields = append(fields, chatrecords.FieldBotID)
  8302. }
  8303. if m.addbot_type != nil {
  8304. fields = append(fields, chatrecords.FieldBotType)
  8305. }
  8306. return fields
  8307. }
  8308. // AddedField returns the numeric value that was incremented/decremented on a field
  8309. // with the given name. The second boolean return value indicates that this field
  8310. // was not set, or was not defined in the schema.
  8311. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  8312. switch name {
  8313. case chatrecords.FieldContentType:
  8314. return m.AddedContentType()
  8315. case chatrecords.FieldSessionID:
  8316. return m.AddedSessionID()
  8317. case chatrecords.FieldUserID:
  8318. return m.AddedUserID()
  8319. case chatrecords.FieldBotID:
  8320. return m.AddedBotID()
  8321. case chatrecords.FieldBotType:
  8322. return m.AddedBotType()
  8323. }
  8324. return nil, false
  8325. }
  8326. // AddField adds the value to the field with the given name. It returns an error if
  8327. // the field is not defined in the schema, or if the type mismatched the field
  8328. // type.
  8329. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  8330. switch name {
  8331. case chatrecords.FieldContentType:
  8332. v, ok := value.(int8)
  8333. if !ok {
  8334. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8335. }
  8336. m.AddContentType(v)
  8337. return nil
  8338. case chatrecords.FieldSessionID:
  8339. v, ok := value.(int64)
  8340. if !ok {
  8341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8342. }
  8343. m.AddSessionID(v)
  8344. return nil
  8345. case chatrecords.FieldUserID:
  8346. v, ok := value.(int64)
  8347. if !ok {
  8348. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8349. }
  8350. m.AddUserID(v)
  8351. return nil
  8352. case chatrecords.FieldBotID:
  8353. v, ok := value.(int64)
  8354. if !ok {
  8355. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8356. }
  8357. m.AddBotID(v)
  8358. return nil
  8359. case chatrecords.FieldBotType:
  8360. v, ok := value.(int8)
  8361. if !ok {
  8362. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8363. }
  8364. m.AddBotType(v)
  8365. return nil
  8366. }
  8367. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  8368. }
  8369. // ClearedFields returns all nullable fields that were cleared during this
  8370. // mutation.
  8371. func (m *ChatRecordsMutation) ClearedFields() []string {
  8372. var fields []string
  8373. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  8374. fields = append(fields, chatrecords.FieldDeletedAt)
  8375. }
  8376. return fields
  8377. }
  8378. // FieldCleared returns a boolean indicating if a field with the given name was
  8379. // cleared in this mutation.
  8380. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  8381. _, ok := m.clearedFields[name]
  8382. return ok
  8383. }
  8384. // ClearField clears the value of the field with the given name. It returns an
  8385. // error if the field is not defined in the schema.
  8386. func (m *ChatRecordsMutation) ClearField(name string) error {
  8387. switch name {
  8388. case chatrecords.FieldDeletedAt:
  8389. m.ClearDeletedAt()
  8390. return nil
  8391. }
  8392. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  8393. }
  8394. // ResetField resets all changes in the mutation for the field with the given name.
  8395. // It returns an error if the field is not defined in the schema.
  8396. func (m *ChatRecordsMutation) ResetField(name string) error {
  8397. switch name {
  8398. case chatrecords.FieldCreatedAt:
  8399. m.ResetCreatedAt()
  8400. return nil
  8401. case chatrecords.FieldUpdatedAt:
  8402. m.ResetUpdatedAt()
  8403. return nil
  8404. case chatrecords.FieldDeletedAt:
  8405. m.ResetDeletedAt()
  8406. return nil
  8407. case chatrecords.FieldContent:
  8408. m.ResetContent()
  8409. return nil
  8410. case chatrecords.FieldContentType:
  8411. m.ResetContentType()
  8412. return nil
  8413. case chatrecords.FieldSessionID:
  8414. m.ResetSessionID()
  8415. return nil
  8416. case chatrecords.FieldUserID:
  8417. m.ResetUserID()
  8418. return nil
  8419. case chatrecords.FieldBotID:
  8420. m.ResetBotID()
  8421. return nil
  8422. case chatrecords.FieldBotType:
  8423. m.ResetBotType()
  8424. return nil
  8425. }
  8426. return fmt.Errorf("unknown ChatRecords field %s", name)
  8427. }
  8428. // AddedEdges returns all edge names that were set/added in this mutation.
  8429. func (m *ChatRecordsMutation) AddedEdges() []string {
  8430. edges := make([]string, 0, 0)
  8431. return edges
  8432. }
  8433. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8434. // name in this mutation.
  8435. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  8436. return nil
  8437. }
  8438. // RemovedEdges returns all edge names that were removed in this mutation.
  8439. func (m *ChatRecordsMutation) RemovedEdges() []string {
  8440. edges := make([]string, 0, 0)
  8441. return edges
  8442. }
  8443. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8444. // the given name in this mutation.
  8445. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  8446. return nil
  8447. }
  8448. // ClearedEdges returns all edge names that were cleared in this mutation.
  8449. func (m *ChatRecordsMutation) ClearedEdges() []string {
  8450. edges := make([]string, 0, 0)
  8451. return edges
  8452. }
  8453. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8454. // was cleared in this mutation.
  8455. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  8456. return false
  8457. }
  8458. // ClearEdge clears the value of the edge with the given name. It returns an error
  8459. // if that edge is not defined in the schema.
  8460. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  8461. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  8462. }
  8463. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8464. // It returns an error if the edge is not defined in the schema.
  8465. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  8466. return fmt.Errorf("unknown ChatRecords edge %s", name)
  8467. }
  8468. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  8469. type ChatSessionMutation struct {
  8470. config
  8471. op Op
  8472. typ string
  8473. id *uint64
  8474. created_at *time.Time
  8475. updated_at *time.Time
  8476. deleted_at *time.Time
  8477. name *string
  8478. user_id *uint64
  8479. adduser_id *int64
  8480. bot_id *uint64
  8481. addbot_id *int64
  8482. bot_type *uint8
  8483. addbot_type *int8
  8484. clearedFields map[string]struct{}
  8485. done bool
  8486. oldValue func(context.Context) (*ChatSession, error)
  8487. predicates []predicate.ChatSession
  8488. }
  8489. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  8490. // chatsessionOption allows management of the mutation configuration using functional options.
  8491. type chatsessionOption func(*ChatSessionMutation)
  8492. // newChatSessionMutation creates new mutation for the ChatSession entity.
  8493. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  8494. m := &ChatSessionMutation{
  8495. config: c,
  8496. op: op,
  8497. typ: TypeChatSession,
  8498. clearedFields: make(map[string]struct{}),
  8499. }
  8500. for _, opt := range opts {
  8501. opt(m)
  8502. }
  8503. return m
  8504. }
  8505. // withChatSessionID sets the ID field of the mutation.
  8506. func withChatSessionID(id uint64) chatsessionOption {
  8507. return func(m *ChatSessionMutation) {
  8508. var (
  8509. err error
  8510. once sync.Once
  8511. value *ChatSession
  8512. )
  8513. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  8514. once.Do(func() {
  8515. if m.done {
  8516. err = errors.New("querying old values post mutation is not allowed")
  8517. } else {
  8518. value, err = m.Client().ChatSession.Get(ctx, id)
  8519. }
  8520. })
  8521. return value, err
  8522. }
  8523. m.id = &id
  8524. }
  8525. }
  8526. // withChatSession sets the old ChatSession of the mutation.
  8527. func withChatSession(node *ChatSession) chatsessionOption {
  8528. return func(m *ChatSessionMutation) {
  8529. m.oldValue = func(context.Context) (*ChatSession, error) {
  8530. return node, nil
  8531. }
  8532. m.id = &node.ID
  8533. }
  8534. }
  8535. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8536. // executed in a transaction (ent.Tx), a transactional client is returned.
  8537. func (m ChatSessionMutation) Client() *Client {
  8538. client := &Client{config: m.config}
  8539. client.init()
  8540. return client
  8541. }
  8542. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8543. // it returns an error otherwise.
  8544. func (m ChatSessionMutation) Tx() (*Tx, error) {
  8545. if _, ok := m.driver.(*txDriver); !ok {
  8546. return nil, errors.New("ent: mutation is not running in a transaction")
  8547. }
  8548. tx := &Tx{config: m.config}
  8549. tx.init()
  8550. return tx, nil
  8551. }
  8552. // SetID sets the value of the id field. Note that this
  8553. // operation is only accepted on creation of ChatSession entities.
  8554. func (m *ChatSessionMutation) SetID(id uint64) {
  8555. m.id = &id
  8556. }
  8557. // ID returns the ID value in the mutation. Note that the ID is only available
  8558. // if it was provided to the builder or after it was returned from the database.
  8559. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  8560. if m.id == nil {
  8561. return
  8562. }
  8563. return *m.id, true
  8564. }
  8565. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8566. // That means, if the mutation is applied within a transaction with an isolation level such
  8567. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8568. // or updated by the mutation.
  8569. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  8570. switch {
  8571. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8572. id, exists := m.ID()
  8573. if exists {
  8574. return []uint64{id}, nil
  8575. }
  8576. fallthrough
  8577. case m.op.Is(OpUpdate | OpDelete):
  8578. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  8579. default:
  8580. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8581. }
  8582. }
  8583. // SetCreatedAt sets the "created_at" field.
  8584. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  8585. m.created_at = &t
  8586. }
  8587. // CreatedAt returns the value of the "created_at" field in the mutation.
  8588. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  8589. v := m.created_at
  8590. if v == nil {
  8591. return
  8592. }
  8593. return *v, true
  8594. }
  8595. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  8596. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8597. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8598. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8599. if !m.op.Is(OpUpdateOne) {
  8600. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8601. }
  8602. if m.id == nil || m.oldValue == nil {
  8603. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8604. }
  8605. oldValue, err := m.oldValue(ctx)
  8606. if err != nil {
  8607. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8608. }
  8609. return oldValue.CreatedAt, nil
  8610. }
  8611. // ResetCreatedAt resets all changes to the "created_at" field.
  8612. func (m *ChatSessionMutation) ResetCreatedAt() {
  8613. m.created_at = nil
  8614. }
  8615. // SetUpdatedAt sets the "updated_at" field.
  8616. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  8617. m.updated_at = &t
  8618. }
  8619. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8620. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  8621. v := m.updated_at
  8622. if v == nil {
  8623. return
  8624. }
  8625. return *v, true
  8626. }
  8627. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  8628. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8629. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8630. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8631. if !m.op.Is(OpUpdateOne) {
  8632. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8633. }
  8634. if m.id == nil || m.oldValue == nil {
  8635. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8636. }
  8637. oldValue, err := m.oldValue(ctx)
  8638. if err != nil {
  8639. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8640. }
  8641. return oldValue.UpdatedAt, nil
  8642. }
  8643. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8644. func (m *ChatSessionMutation) ResetUpdatedAt() {
  8645. m.updated_at = nil
  8646. }
  8647. // SetDeletedAt sets the "deleted_at" field.
  8648. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  8649. m.deleted_at = &t
  8650. }
  8651. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8652. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  8653. v := m.deleted_at
  8654. if v == nil {
  8655. return
  8656. }
  8657. return *v, true
  8658. }
  8659. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  8660. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8661. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8662. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8663. if !m.op.Is(OpUpdateOne) {
  8664. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8665. }
  8666. if m.id == nil || m.oldValue == nil {
  8667. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8668. }
  8669. oldValue, err := m.oldValue(ctx)
  8670. if err != nil {
  8671. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8672. }
  8673. return oldValue.DeletedAt, nil
  8674. }
  8675. // ClearDeletedAt clears the value of the "deleted_at" field.
  8676. func (m *ChatSessionMutation) ClearDeletedAt() {
  8677. m.deleted_at = nil
  8678. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  8679. }
  8680. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8681. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  8682. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  8683. return ok
  8684. }
  8685. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8686. func (m *ChatSessionMutation) ResetDeletedAt() {
  8687. m.deleted_at = nil
  8688. delete(m.clearedFields, chatsession.FieldDeletedAt)
  8689. }
  8690. // SetName sets the "name" field.
  8691. func (m *ChatSessionMutation) SetName(s string) {
  8692. m.name = &s
  8693. }
  8694. // Name returns the value of the "name" field in the mutation.
  8695. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  8696. v := m.name
  8697. if v == nil {
  8698. return
  8699. }
  8700. return *v, true
  8701. }
  8702. // OldName returns the old "name" field's value of the ChatSession entity.
  8703. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8704. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8705. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  8706. if !m.op.Is(OpUpdateOne) {
  8707. return v, errors.New("OldName is only allowed on UpdateOne operations")
  8708. }
  8709. if m.id == nil || m.oldValue == nil {
  8710. return v, errors.New("OldName requires an ID field in the mutation")
  8711. }
  8712. oldValue, err := m.oldValue(ctx)
  8713. if err != nil {
  8714. return v, fmt.Errorf("querying old value for OldName: %w", err)
  8715. }
  8716. return oldValue.Name, nil
  8717. }
  8718. // ResetName resets all changes to the "name" field.
  8719. func (m *ChatSessionMutation) ResetName() {
  8720. m.name = nil
  8721. }
  8722. // SetUserID sets the "user_id" field.
  8723. func (m *ChatSessionMutation) SetUserID(u uint64) {
  8724. m.user_id = &u
  8725. m.adduser_id = nil
  8726. }
  8727. // UserID returns the value of the "user_id" field in the mutation.
  8728. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  8729. v := m.user_id
  8730. if v == nil {
  8731. return
  8732. }
  8733. return *v, true
  8734. }
  8735. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  8736. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8737. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8738. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  8739. if !m.op.Is(OpUpdateOne) {
  8740. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  8741. }
  8742. if m.id == nil || m.oldValue == nil {
  8743. return v, errors.New("OldUserID requires an ID field in the mutation")
  8744. }
  8745. oldValue, err := m.oldValue(ctx)
  8746. if err != nil {
  8747. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  8748. }
  8749. return oldValue.UserID, nil
  8750. }
  8751. // AddUserID adds u to the "user_id" field.
  8752. func (m *ChatSessionMutation) AddUserID(u int64) {
  8753. if m.adduser_id != nil {
  8754. *m.adduser_id += u
  8755. } else {
  8756. m.adduser_id = &u
  8757. }
  8758. }
  8759. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  8760. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  8761. v := m.adduser_id
  8762. if v == nil {
  8763. return
  8764. }
  8765. return *v, true
  8766. }
  8767. // ResetUserID resets all changes to the "user_id" field.
  8768. func (m *ChatSessionMutation) ResetUserID() {
  8769. m.user_id = nil
  8770. m.adduser_id = nil
  8771. }
  8772. // SetBotID sets the "bot_id" field.
  8773. func (m *ChatSessionMutation) SetBotID(u uint64) {
  8774. m.bot_id = &u
  8775. m.addbot_id = nil
  8776. }
  8777. // BotID returns the value of the "bot_id" field in the mutation.
  8778. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  8779. v := m.bot_id
  8780. if v == nil {
  8781. return
  8782. }
  8783. return *v, true
  8784. }
  8785. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  8786. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8787. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8788. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  8789. if !m.op.Is(OpUpdateOne) {
  8790. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  8791. }
  8792. if m.id == nil || m.oldValue == nil {
  8793. return v, errors.New("OldBotID requires an ID field in the mutation")
  8794. }
  8795. oldValue, err := m.oldValue(ctx)
  8796. if err != nil {
  8797. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  8798. }
  8799. return oldValue.BotID, nil
  8800. }
  8801. // AddBotID adds u to the "bot_id" field.
  8802. func (m *ChatSessionMutation) AddBotID(u int64) {
  8803. if m.addbot_id != nil {
  8804. *m.addbot_id += u
  8805. } else {
  8806. m.addbot_id = &u
  8807. }
  8808. }
  8809. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  8810. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  8811. v := m.addbot_id
  8812. if v == nil {
  8813. return
  8814. }
  8815. return *v, true
  8816. }
  8817. // ResetBotID resets all changes to the "bot_id" field.
  8818. func (m *ChatSessionMutation) ResetBotID() {
  8819. m.bot_id = nil
  8820. m.addbot_id = nil
  8821. }
  8822. // SetBotType sets the "bot_type" field.
  8823. func (m *ChatSessionMutation) SetBotType(u uint8) {
  8824. m.bot_type = &u
  8825. m.addbot_type = nil
  8826. }
  8827. // BotType returns the value of the "bot_type" field in the mutation.
  8828. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  8829. v := m.bot_type
  8830. if v == nil {
  8831. return
  8832. }
  8833. return *v, true
  8834. }
  8835. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  8836. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8837. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8838. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  8839. if !m.op.Is(OpUpdateOne) {
  8840. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  8841. }
  8842. if m.id == nil || m.oldValue == nil {
  8843. return v, errors.New("OldBotType requires an ID field in the mutation")
  8844. }
  8845. oldValue, err := m.oldValue(ctx)
  8846. if err != nil {
  8847. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  8848. }
  8849. return oldValue.BotType, nil
  8850. }
  8851. // AddBotType adds u to the "bot_type" field.
  8852. func (m *ChatSessionMutation) AddBotType(u int8) {
  8853. if m.addbot_type != nil {
  8854. *m.addbot_type += u
  8855. } else {
  8856. m.addbot_type = &u
  8857. }
  8858. }
  8859. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  8860. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  8861. v := m.addbot_type
  8862. if v == nil {
  8863. return
  8864. }
  8865. return *v, true
  8866. }
  8867. // ResetBotType resets all changes to the "bot_type" field.
  8868. func (m *ChatSessionMutation) ResetBotType() {
  8869. m.bot_type = nil
  8870. m.addbot_type = nil
  8871. }
  8872. // Where appends a list predicates to the ChatSessionMutation builder.
  8873. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  8874. m.predicates = append(m.predicates, ps...)
  8875. }
  8876. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  8877. // users can use type-assertion to append predicates that do not depend on any generated package.
  8878. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  8879. p := make([]predicate.ChatSession, len(ps))
  8880. for i := range ps {
  8881. p[i] = ps[i]
  8882. }
  8883. m.Where(p...)
  8884. }
  8885. // Op returns the operation name.
  8886. func (m *ChatSessionMutation) Op() Op {
  8887. return m.op
  8888. }
  8889. // SetOp allows setting the mutation operation.
  8890. func (m *ChatSessionMutation) SetOp(op Op) {
  8891. m.op = op
  8892. }
  8893. // Type returns the node type of this mutation (ChatSession).
  8894. func (m *ChatSessionMutation) Type() string {
  8895. return m.typ
  8896. }
  8897. // Fields returns all fields that were changed during this mutation. Note that in
  8898. // order to get all numeric fields that were incremented/decremented, call
  8899. // AddedFields().
  8900. func (m *ChatSessionMutation) Fields() []string {
  8901. fields := make([]string, 0, 7)
  8902. if m.created_at != nil {
  8903. fields = append(fields, chatsession.FieldCreatedAt)
  8904. }
  8905. if m.updated_at != nil {
  8906. fields = append(fields, chatsession.FieldUpdatedAt)
  8907. }
  8908. if m.deleted_at != nil {
  8909. fields = append(fields, chatsession.FieldDeletedAt)
  8910. }
  8911. if m.name != nil {
  8912. fields = append(fields, chatsession.FieldName)
  8913. }
  8914. if m.user_id != nil {
  8915. fields = append(fields, chatsession.FieldUserID)
  8916. }
  8917. if m.bot_id != nil {
  8918. fields = append(fields, chatsession.FieldBotID)
  8919. }
  8920. if m.bot_type != nil {
  8921. fields = append(fields, chatsession.FieldBotType)
  8922. }
  8923. return fields
  8924. }
  8925. // Field returns the value of a field with the given name. The second boolean
  8926. // return value indicates that this field was not set, or was not defined in the
  8927. // schema.
  8928. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  8929. switch name {
  8930. case chatsession.FieldCreatedAt:
  8931. return m.CreatedAt()
  8932. case chatsession.FieldUpdatedAt:
  8933. return m.UpdatedAt()
  8934. case chatsession.FieldDeletedAt:
  8935. return m.DeletedAt()
  8936. case chatsession.FieldName:
  8937. return m.Name()
  8938. case chatsession.FieldUserID:
  8939. return m.UserID()
  8940. case chatsession.FieldBotID:
  8941. return m.BotID()
  8942. case chatsession.FieldBotType:
  8943. return m.BotType()
  8944. }
  8945. return nil, false
  8946. }
  8947. // OldField returns the old value of the field from the database. An error is
  8948. // returned if the mutation operation is not UpdateOne, or the query to the
  8949. // database failed.
  8950. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8951. switch name {
  8952. case chatsession.FieldCreatedAt:
  8953. return m.OldCreatedAt(ctx)
  8954. case chatsession.FieldUpdatedAt:
  8955. return m.OldUpdatedAt(ctx)
  8956. case chatsession.FieldDeletedAt:
  8957. return m.OldDeletedAt(ctx)
  8958. case chatsession.FieldName:
  8959. return m.OldName(ctx)
  8960. case chatsession.FieldUserID:
  8961. return m.OldUserID(ctx)
  8962. case chatsession.FieldBotID:
  8963. return m.OldBotID(ctx)
  8964. case chatsession.FieldBotType:
  8965. return m.OldBotType(ctx)
  8966. }
  8967. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  8968. }
  8969. // SetField sets the value of a field with the given name. It returns an error if
  8970. // the field is not defined in the schema, or if the type mismatched the field
  8971. // type.
  8972. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  8973. switch name {
  8974. case chatsession.FieldCreatedAt:
  8975. v, ok := value.(time.Time)
  8976. if !ok {
  8977. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8978. }
  8979. m.SetCreatedAt(v)
  8980. return nil
  8981. case chatsession.FieldUpdatedAt:
  8982. v, ok := value.(time.Time)
  8983. if !ok {
  8984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8985. }
  8986. m.SetUpdatedAt(v)
  8987. return nil
  8988. case chatsession.FieldDeletedAt:
  8989. v, ok := value.(time.Time)
  8990. if !ok {
  8991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8992. }
  8993. m.SetDeletedAt(v)
  8994. return nil
  8995. case chatsession.FieldName:
  8996. v, ok := value.(string)
  8997. if !ok {
  8998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8999. }
  9000. m.SetName(v)
  9001. return nil
  9002. case chatsession.FieldUserID:
  9003. v, ok := value.(uint64)
  9004. if !ok {
  9005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9006. }
  9007. m.SetUserID(v)
  9008. return nil
  9009. case chatsession.FieldBotID:
  9010. v, ok := value.(uint64)
  9011. if !ok {
  9012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9013. }
  9014. m.SetBotID(v)
  9015. return nil
  9016. case chatsession.FieldBotType:
  9017. v, ok := value.(uint8)
  9018. if !ok {
  9019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9020. }
  9021. m.SetBotType(v)
  9022. return nil
  9023. }
  9024. return fmt.Errorf("unknown ChatSession field %s", name)
  9025. }
  9026. // AddedFields returns all numeric fields that were incremented/decremented during
  9027. // this mutation.
  9028. func (m *ChatSessionMutation) AddedFields() []string {
  9029. var fields []string
  9030. if m.adduser_id != nil {
  9031. fields = append(fields, chatsession.FieldUserID)
  9032. }
  9033. if m.addbot_id != nil {
  9034. fields = append(fields, chatsession.FieldBotID)
  9035. }
  9036. if m.addbot_type != nil {
  9037. fields = append(fields, chatsession.FieldBotType)
  9038. }
  9039. return fields
  9040. }
  9041. // AddedField returns the numeric value that was incremented/decremented on a field
  9042. // with the given name. The second boolean return value indicates that this field
  9043. // was not set, or was not defined in the schema.
  9044. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  9045. switch name {
  9046. case chatsession.FieldUserID:
  9047. return m.AddedUserID()
  9048. case chatsession.FieldBotID:
  9049. return m.AddedBotID()
  9050. case chatsession.FieldBotType:
  9051. return m.AddedBotType()
  9052. }
  9053. return nil, false
  9054. }
  9055. // AddField adds the value to the field with the given name. It returns an error if
  9056. // the field is not defined in the schema, or if the type mismatched the field
  9057. // type.
  9058. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  9059. switch name {
  9060. case chatsession.FieldUserID:
  9061. v, ok := value.(int64)
  9062. if !ok {
  9063. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9064. }
  9065. m.AddUserID(v)
  9066. return nil
  9067. case chatsession.FieldBotID:
  9068. v, ok := value.(int64)
  9069. if !ok {
  9070. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9071. }
  9072. m.AddBotID(v)
  9073. return nil
  9074. case chatsession.FieldBotType:
  9075. v, ok := value.(int8)
  9076. if !ok {
  9077. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9078. }
  9079. m.AddBotType(v)
  9080. return nil
  9081. }
  9082. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  9083. }
  9084. // ClearedFields returns all nullable fields that were cleared during this
  9085. // mutation.
  9086. func (m *ChatSessionMutation) ClearedFields() []string {
  9087. var fields []string
  9088. if m.FieldCleared(chatsession.FieldDeletedAt) {
  9089. fields = append(fields, chatsession.FieldDeletedAt)
  9090. }
  9091. return fields
  9092. }
  9093. // FieldCleared returns a boolean indicating if a field with the given name was
  9094. // cleared in this mutation.
  9095. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  9096. _, ok := m.clearedFields[name]
  9097. return ok
  9098. }
  9099. // ClearField clears the value of the field with the given name. It returns an
  9100. // error if the field is not defined in the schema.
  9101. func (m *ChatSessionMutation) ClearField(name string) error {
  9102. switch name {
  9103. case chatsession.FieldDeletedAt:
  9104. m.ClearDeletedAt()
  9105. return nil
  9106. }
  9107. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  9108. }
  9109. // ResetField resets all changes in the mutation for the field with the given name.
  9110. // It returns an error if the field is not defined in the schema.
  9111. func (m *ChatSessionMutation) ResetField(name string) error {
  9112. switch name {
  9113. case chatsession.FieldCreatedAt:
  9114. m.ResetCreatedAt()
  9115. return nil
  9116. case chatsession.FieldUpdatedAt:
  9117. m.ResetUpdatedAt()
  9118. return nil
  9119. case chatsession.FieldDeletedAt:
  9120. m.ResetDeletedAt()
  9121. return nil
  9122. case chatsession.FieldName:
  9123. m.ResetName()
  9124. return nil
  9125. case chatsession.FieldUserID:
  9126. m.ResetUserID()
  9127. return nil
  9128. case chatsession.FieldBotID:
  9129. m.ResetBotID()
  9130. return nil
  9131. case chatsession.FieldBotType:
  9132. m.ResetBotType()
  9133. return nil
  9134. }
  9135. return fmt.Errorf("unknown ChatSession field %s", name)
  9136. }
  9137. // AddedEdges returns all edge names that were set/added in this mutation.
  9138. func (m *ChatSessionMutation) AddedEdges() []string {
  9139. edges := make([]string, 0, 0)
  9140. return edges
  9141. }
  9142. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9143. // name in this mutation.
  9144. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  9145. return nil
  9146. }
  9147. // RemovedEdges returns all edge names that were removed in this mutation.
  9148. func (m *ChatSessionMutation) RemovedEdges() []string {
  9149. edges := make([]string, 0, 0)
  9150. return edges
  9151. }
  9152. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9153. // the given name in this mutation.
  9154. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  9155. return nil
  9156. }
  9157. // ClearedEdges returns all edge names that were cleared in this mutation.
  9158. func (m *ChatSessionMutation) ClearedEdges() []string {
  9159. edges := make([]string, 0, 0)
  9160. return edges
  9161. }
  9162. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9163. // was cleared in this mutation.
  9164. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  9165. return false
  9166. }
  9167. // ClearEdge clears the value of the edge with the given name. It returns an error
  9168. // if that edge is not defined in the schema.
  9169. func (m *ChatSessionMutation) ClearEdge(name string) error {
  9170. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  9171. }
  9172. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9173. // It returns an error if the edge is not defined in the schema.
  9174. func (m *ChatSessionMutation) ResetEdge(name string) error {
  9175. return fmt.Errorf("unknown ChatSession edge %s", name)
  9176. }
  9177. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  9178. type ContactMutation struct {
  9179. config
  9180. op Op
  9181. typ string
  9182. id *uint64
  9183. created_at *time.Time
  9184. updated_at *time.Time
  9185. status *uint8
  9186. addstatus *int8
  9187. deleted_at *time.Time
  9188. wx_wxid *string
  9189. _type *int
  9190. add_type *int
  9191. wxid *string
  9192. account *string
  9193. nickname *string
  9194. markname *string
  9195. headimg *string
  9196. sex *int
  9197. addsex *int
  9198. starrole *string
  9199. dontseeit *int
  9200. adddontseeit *int
  9201. dontseeme *int
  9202. adddontseeme *int
  9203. lag *string
  9204. gid *string
  9205. gname *string
  9206. v3 *string
  9207. organization_id *uint64
  9208. addorganization_id *int64
  9209. ctype *uint64
  9210. addctype *int64
  9211. cage *int
  9212. addcage *int
  9213. cname *string
  9214. carea *string
  9215. cbirthday *string
  9216. cbirtharea *string
  9217. cidcard_no *string
  9218. ctitle *string
  9219. cc *string
  9220. phone *string
  9221. clearedFields map[string]struct{}
  9222. contact_relationships map[uint64]struct{}
  9223. removedcontact_relationships map[uint64]struct{}
  9224. clearedcontact_relationships bool
  9225. contact_fields map[uint64]struct{}
  9226. removedcontact_fields map[uint64]struct{}
  9227. clearedcontact_fields bool
  9228. contact_messages map[uint64]struct{}
  9229. removedcontact_messages map[uint64]struct{}
  9230. clearedcontact_messages bool
  9231. done bool
  9232. oldValue func(context.Context) (*Contact, error)
  9233. predicates []predicate.Contact
  9234. }
  9235. var _ ent.Mutation = (*ContactMutation)(nil)
  9236. // contactOption allows management of the mutation configuration using functional options.
  9237. type contactOption func(*ContactMutation)
  9238. // newContactMutation creates new mutation for the Contact entity.
  9239. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  9240. m := &ContactMutation{
  9241. config: c,
  9242. op: op,
  9243. typ: TypeContact,
  9244. clearedFields: make(map[string]struct{}),
  9245. }
  9246. for _, opt := range opts {
  9247. opt(m)
  9248. }
  9249. return m
  9250. }
  9251. // withContactID sets the ID field of the mutation.
  9252. func withContactID(id uint64) contactOption {
  9253. return func(m *ContactMutation) {
  9254. var (
  9255. err error
  9256. once sync.Once
  9257. value *Contact
  9258. )
  9259. m.oldValue = func(ctx context.Context) (*Contact, error) {
  9260. once.Do(func() {
  9261. if m.done {
  9262. err = errors.New("querying old values post mutation is not allowed")
  9263. } else {
  9264. value, err = m.Client().Contact.Get(ctx, id)
  9265. }
  9266. })
  9267. return value, err
  9268. }
  9269. m.id = &id
  9270. }
  9271. }
  9272. // withContact sets the old Contact of the mutation.
  9273. func withContact(node *Contact) contactOption {
  9274. return func(m *ContactMutation) {
  9275. m.oldValue = func(context.Context) (*Contact, error) {
  9276. return node, nil
  9277. }
  9278. m.id = &node.ID
  9279. }
  9280. }
  9281. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9282. // executed in a transaction (ent.Tx), a transactional client is returned.
  9283. func (m ContactMutation) Client() *Client {
  9284. client := &Client{config: m.config}
  9285. client.init()
  9286. return client
  9287. }
  9288. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9289. // it returns an error otherwise.
  9290. func (m ContactMutation) Tx() (*Tx, error) {
  9291. if _, ok := m.driver.(*txDriver); !ok {
  9292. return nil, errors.New("ent: mutation is not running in a transaction")
  9293. }
  9294. tx := &Tx{config: m.config}
  9295. tx.init()
  9296. return tx, nil
  9297. }
  9298. // SetID sets the value of the id field. Note that this
  9299. // operation is only accepted on creation of Contact entities.
  9300. func (m *ContactMutation) SetID(id uint64) {
  9301. m.id = &id
  9302. }
  9303. // ID returns the ID value in the mutation. Note that the ID is only available
  9304. // if it was provided to the builder or after it was returned from the database.
  9305. func (m *ContactMutation) ID() (id uint64, exists bool) {
  9306. if m.id == nil {
  9307. return
  9308. }
  9309. return *m.id, true
  9310. }
  9311. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9312. // That means, if the mutation is applied within a transaction with an isolation level such
  9313. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9314. // or updated by the mutation.
  9315. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  9316. switch {
  9317. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9318. id, exists := m.ID()
  9319. if exists {
  9320. return []uint64{id}, nil
  9321. }
  9322. fallthrough
  9323. case m.op.Is(OpUpdate | OpDelete):
  9324. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  9325. default:
  9326. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9327. }
  9328. }
  9329. // SetCreatedAt sets the "created_at" field.
  9330. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  9331. m.created_at = &t
  9332. }
  9333. // CreatedAt returns the value of the "created_at" field in the mutation.
  9334. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  9335. v := m.created_at
  9336. if v == nil {
  9337. return
  9338. }
  9339. return *v, true
  9340. }
  9341. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  9342. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9343. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9344. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9345. if !m.op.Is(OpUpdateOne) {
  9346. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9347. }
  9348. if m.id == nil || m.oldValue == nil {
  9349. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9350. }
  9351. oldValue, err := m.oldValue(ctx)
  9352. if err != nil {
  9353. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9354. }
  9355. return oldValue.CreatedAt, nil
  9356. }
  9357. // ResetCreatedAt resets all changes to the "created_at" field.
  9358. func (m *ContactMutation) ResetCreatedAt() {
  9359. m.created_at = nil
  9360. }
  9361. // SetUpdatedAt sets the "updated_at" field.
  9362. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  9363. m.updated_at = &t
  9364. }
  9365. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9366. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  9367. v := m.updated_at
  9368. if v == nil {
  9369. return
  9370. }
  9371. return *v, true
  9372. }
  9373. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  9374. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9376. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9377. if !m.op.Is(OpUpdateOne) {
  9378. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9379. }
  9380. if m.id == nil || m.oldValue == nil {
  9381. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9382. }
  9383. oldValue, err := m.oldValue(ctx)
  9384. if err != nil {
  9385. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9386. }
  9387. return oldValue.UpdatedAt, nil
  9388. }
  9389. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9390. func (m *ContactMutation) ResetUpdatedAt() {
  9391. m.updated_at = nil
  9392. }
  9393. // SetStatus sets the "status" field.
  9394. func (m *ContactMutation) SetStatus(u uint8) {
  9395. m.status = &u
  9396. m.addstatus = nil
  9397. }
  9398. // Status returns the value of the "status" field in the mutation.
  9399. func (m *ContactMutation) Status() (r uint8, exists bool) {
  9400. v := m.status
  9401. if v == nil {
  9402. return
  9403. }
  9404. return *v, true
  9405. }
  9406. // OldStatus returns the old "status" field's value of the Contact entity.
  9407. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9408. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9409. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  9410. if !m.op.Is(OpUpdateOne) {
  9411. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9412. }
  9413. if m.id == nil || m.oldValue == nil {
  9414. return v, errors.New("OldStatus requires an ID field in the mutation")
  9415. }
  9416. oldValue, err := m.oldValue(ctx)
  9417. if err != nil {
  9418. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  9419. }
  9420. return oldValue.Status, nil
  9421. }
  9422. // AddStatus adds u to the "status" field.
  9423. func (m *ContactMutation) AddStatus(u int8) {
  9424. if m.addstatus != nil {
  9425. *m.addstatus += u
  9426. } else {
  9427. m.addstatus = &u
  9428. }
  9429. }
  9430. // AddedStatus returns the value that was added to the "status" field in this mutation.
  9431. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  9432. v := m.addstatus
  9433. if v == nil {
  9434. return
  9435. }
  9436. return *v, true
  9437. }
  9438. // ClearStatus clears the value of the "status" field.
  9439. func (m *ContactMutation) ClearStatus() {
  9440. m.status = nil
  9441. m.addstatus = nil
  9442. m.clearedFields[contact.FieldStatus] = struct{}{}
  9443. }
  9444. // StatusCleared returns if the "status" field was cleared in this mutation.
  9445. func (m *ContactMutation) StatusCleared() bool {
  9446. _, ok := m.clearedFields[contact.FieldStatus]
  9447. return ok
  9448. }
  9449. // ResetStatus resets all changes to the "status" field.
  9450. func (m *ContactMutation) ResetStatus() {
  9451. m.status = nil
  9452. m.addstatus = nil
  9453. delete(m.clearedFields, contact.FieldStatus)
  9454. }
  9455. // SetDeletedAt sets the "deleted_at" field.
  9456. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  9457. m.deleted_at = &t
  9458. }
  9459. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9460. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  9461. v := m.deleted_at
  9462. if v == nil {
  9463. return
  9464. }
  9465. return *v, true
  9466. }
  9467. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  9468. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9469. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9470. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9471. if !m.op.Is(OpUpdateOne) {
  9472. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9473. }
  9474. if m.id == nil || m.oldValue == nil {
  9475. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9476. }
  9477. oldValue, err := m.oldValue(ctx)
  9478. if err != nil {
  9479. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9480. }
  9481. return oldValue.DeletedAt, nil
  9482. }
  9483. // ClearDeletedAt clears the value of the "deleted_at" field.
  9484. func (m *ContactMutation) ClearDeletedAt() {
  9485. m.deleted_at = nil
  9486. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  9487. }
  9488. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9489. func (m *ContactMutation) DeletedAtCleared() bool {
  9490. _, ok := m.clearedFields[contact.FieldDeletedAt]
  9491. return ok
  9492. }
  9493. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9494. func (m *ContactMutation) ResetDeletedAt() {
  9495. m.deleted_at = nil
  9496. delete(m.clearedFields, contact.FieldDeletedAt)
  9497. }
  9498. // SetWxWxid sets the "wx_wxid" field.
  9499. func (m *ContactMutation) SetWxWxid(s string) {
  9500. m.wx_wxid = &s
  9501. }
  9502. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  9503. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  9504. v := m.wx_wxid
  9505. if v == nil {
  9506. return
  9507. }
  9508. return *v, true
  9509. }
  9510. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  9511. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9512. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9513. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  9514. if !m.op.Is(OpUpdateOne) {
  9515. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  9516. }
  9517. if m.id == nil || m.oldValue == nil {
  9518. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  9519. }
  9520. oldValue, err := m.oldValue(ctx)
  9521. if err != nil {
  9522. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  9523. }
  9524. return oldValue.WxWxid, nil
  9525. }
  9526. // ResetWxWxid resets all changes to the "wx_wxid" field.
  9527. func (m *ContactMutation) ResetWxWxid() {
  9528. m.wx_wxid = nil
  9529. }
  9530. // SetType sets the "type" field.
  9531. func (m *ContactMutation) SetType(i int) {
  9532. m._type = &i
  9533. m.add_type = nil
  9534. }
  9535. // GetType returns the value of the "type" field in the mutation.
  9536. func (m *ContactMutation) GetType() (r int, exists bool) {
  9537. v := m._type
  9538. if v == nil {
  9539. return
  9540. }
  9541. return *v, true
  9542. }
  9543. // OldType returns the old "type" field's value of the Contact entity.
  9544. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9545. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9546. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  9547. if !m.op.Is(OpUpdateOne) {
  9548. return v, errors.New("OldType is only allowed on UpdateOne operations")
  9549. }
  9550. if m.id == nil || m.oldValue == nil {
  9551. return v, errors.New("OldType requires an ID field in the mutation")
  9552. }
  9553. oldValue, err := m.oldValue(ctx)
  9554. if err != nil {
  9555. return v, fmt.Errorf("querying old value for OldType: %w", err)
  9556. }
  9557. return oldValue.Type, nil
  9558. }
  9559. // AddType adds i to the "type" field.
  9560. func (m *ContactMutation) AddType(i int) {
  9561. if m.add_type != nil {
  9562. *m.add_type += i
  9563. } else {
  9564. m.add_type = &i
  9565. }
  9566. }
  9567. // AddedType returns the value that was added to the "type" field in this mutation.
  9568. func (m *ContactMutation) AddedType() (r int, exists bool) {
  9569. v := m.add_type
  9570. if v == nil {
  9571. return
  9572. }
  9573. return *v, true
  9574. }
  9575. // ClearType clears the value of the "type" field.
  9576. func (m *ContactMutation) ClearType() {
  9577. m._type = nil
  9578. m.add_type = nil
  9579. m.clearedFields[contact.FieldType] = struct{}{}
  9580. }
  9581. // TypeCleared returns if the "type" field was cleared in this mutation.
  9582. func (m *ContactMutation) TypeCleared() bool {
  9583. _, ok := m.clearedFields[contact.FieldType]
  9584. return ok
  9585. }
  9586. // ResetType resets all changes to the "type" field.
  9587. func (m *ContactMutation) ResetType() {
  9588. m._type = nil
  9589. m.add_type = nil
  9590. delete(m.clearedFields, contact.FieldType)
  9591. }
  9592. // SetWxid sets the "wxid" field.
  9593. func (m *ContactMutation) SetWxid(s string) {
  9594. m.wxid = &s
  9595. }
  9596. // Wxid returns the value of the "wxid" field in the mutation.
  9597. func (m *ContactMutation) Wxid() (r string, exists bool) {
  9598. v := m.wxid
  9599. if v == nil {
  9600. return
  9601. }
  9602. return *v, true
  9603. }
  9604. // OldWxid returns the old "wxid" field's value of the Contact entity.
  9605. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9606. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9607. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  9608. if !m.op.Is(OpUpdateOne) {
  9609. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  9610. }
  9611. if m.id == nil || m.oldValue == nil {
  9612. return v, errors.New("OldWxid requires an ID field in the mutation")
  9613. }
  9614. oldValue, err := m.oldValue(ctx)
  9615. if err != nil {
  9616. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  9617. }
  9618. return oldValue.Wxid, nil
  9619. }
  9620. // ResetWxid resets all changes to the "wxid" field.
  9621. func (m *ContactMutation) ResetWxid() {
  9622. m.wxid = nil
  9623. }
  9624. // SetAccount sets the "account" field.
  9625. func (m *ContactMutation) SetAccount(s string) {
  9626. m.account = &s
  9627. }
  9628. // Account returns the value of the "account" field in the mutation.
  9629. func (m *ContactMutation) Account() (r string, exists bool) {
  9630. v := m.account
  9631. if v == nil {
  9632. return
  9633. }
  9634. return *v, true
  9635. }
  9636. // OldAccount returns the old "account" field's value of the Contact entity.
  9637. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9638. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9639. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  9640. if !m.op.Is(OpUpdateOne) {
  9641. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  9642. }
  9643. if m.id == nil || m.oldValue == nil {
  9644. return v, errors.New("OldAccount requires an ID field in the mutation")
  9645. }
  9646. oldValue, err := m.oldValue(ctx)
  9647. if err != nil {
  9648. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  9649. }
  9650. return oldValue.Account, nil
  9651. }
  9652. // ResetAccount resets all changes to the "account" field.
  9653. func (m *ContactMutation) ResetAccount() {
  9654. m.account = nil
  9655. }
  9656. // SetNickname sets the "nickname" field.
  9657. func (m *ContactMutation) SetNickname(s string) {
  9658. m.nickname = &s
  9659. }
  9660. // Nickname returns the value of the "nickname" field in the mutation.
  9661. func (m *ContactMutation) Nickname() (r string, exists bool) {
  9662. v := m.nickname
  9663. if v == nil {
  9664. return
  9665. }
  9666. return *v, true
  9667. }
  9668. // OldNickname returns the old "nickname" field's value of the Contact entity.
  9669. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9670. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9671. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  9672. if !m.op.Is(OpUpdateOne) {
  9673. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  9674. }
  9675. if m.id == nil || m.oldValue == nil {
  9676. return v, errors.New("OldNickname requires an ID field in the mutation")
  9677. }
  9678. oldValue, err := m.oldValue(ctx)
  9679. if err != nil {
  9680. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  9681. }
  9682. return oldValue.Nickname, nil
  9683. }
  9684. // ResetNickname resets all changes to the "nickname" field.
  9685. func (m *ContactMutation) ResetNickname() {
  9686. m.nickname = nil
  9687. }
  9688. // SetMarkname sets the "markname" field.
  9689. func (m *ContactMutation) SetMarkname(s string) {
  9690. m.markname = &s
  9691. }
  9692. // Markname returns the value of the "markname" field in the mutation.
  9693. func (m *ContactMutation) Markname() (r string, exists bool) {
  9694. v := m.markname
  9695. if v == nil {
  9696. return
  9697. }
  9698. return *v, true
  9699. }
  9700. // OldMarkname returns the old "markname" field's value of the Contact entity.
  9701. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9702. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9703. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  9704. if !m.op.Is(OpUpdateOne) {
  9705. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  9706. }
  9707. if m.id == nil || m.oldValue == nil {
  9708. return v, errors.New("OldMarkname requires an ID field in the mutation")
  9709. }
  9710. oldValue, err := m.oldValue(ctx)
  9711. if err != nil {
  9712. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  9713. }
  9714. return oldValue.Markname, nil
  9715. }
  9716. // ResetMarkname resets all changes to the "markname" field.
  9717. func (m *ContactMutation) ResetMarkname() {
  9718. m.markname = nil
  9719. }
  9720. // SetHeadimg sets the "headimg" field.
  9721. func (m *ContactMutation) SetHeadimg(s string) {
  9722. m.headimg = &s
  9723. }
  9724. // Headimg returns the value of the "headimg" field in the mutation.
  9725. func (m *ContactMutation) Headimg() (r string, exists bool) {
  9726. v := m.headimg
  9727. if v == nil {
  9728. return
  9729. }
  9730. return *v, true
  9731. }
  9732. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  9733. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9734. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9735. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  9736. if !m.op.Is(OpUpdateOne) {
  9737. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  9738. }
  9739. if m.id == nil || m.oldValue == nil {
  9740. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  9741. }
  9742. oldValue, err := m.oldValue(ctx)
  9743. if err != nil {
  9744. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  9745. }
  9746. return oldValue.Headimg, nil
  9747. }
  9748. // ResetHeadimg resets all changes to the "headimg" field.
  9749. func (m *ContactMutation) ResetHeadimg() {
  9750. m.headimg = nil
  9751. }
  9752. // SetSex sets the "sex" field.
  9753. func (m *ContactMutation) SetSex(i int) {
  9754. m.sex = &i
  9755. m.addsex = nil
  9756. }
  9757. // Sex returns the value of the "sex" field in the mutation.
  9758. func (m *ContactMutation) Sex() (r int, exists bool) {
  9759. v := m.sex
  9760. if v == nil {
  9761. return
  9762. }
  9763. return *v, true
  9764. }
  9765. // OldSex returns the old "sex" field's value of the Contact entity.
  9766. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9767. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9768. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  9769. if !m.op.Is(OpUpdateOne) {
  9770. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  9771. }
  9772. if m.id == nil || m.oldValue == nil {
  9773. return v, errors.New("OldSex requires an ID field in the mutation")
  9774. }
  9775. oldValue, err := m.oldValue(ctx)
  9776. if err != nil {
  9777. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  9778. }
  9779. return oldValue.Sex, nil
  9780. }
  9781. // AddSex adds i to the "sex" field.
  9782. func (m *ContactMutation) AddSex(i int) {
  9783. if m.addsex != nil {
  9784. *m.addsex += i
  9785. } else {
  9786. m.addsex = &i
  9787. }
  9788. }
  9789. // AddedSex returns the value that was added to the "sex" field in this mutation.
  9790. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  9791. v := m.addsex
  9792. if v == nil {
  9793. return
  9794. }
  9795. return *v, true
  9796. }
  9797. // ResetSex resets all changes to the "sex" field.
  9798. func (m *ContactMutation) ResetSex() {
  9799. m.sex = nil
  9800. m.addsex = nil
  9801. }
  9802. // SetStarrole sets the "starrole" field.
  9803. func (m *ContactMutation) SetStarrole(s string) {
  9804. m.starrole = &s
  9805. }
  9806. // Starrole returns the value of the "starrole" field in the mutation.
  9807. func (m *ContactMutation) Starrole() (r string, exists bool) {
  9808. v := m.starrole
  9809. if v == nil {
  9810. return
  9811. }
  9812. return *v, true
  9813. }
  9814. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  9815. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9816. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9817. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  9818. if !m.op.Is(OpUpdateOne) {
  9819. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  9820. }
  9821. if m.id == nil || m.oldValue == nil {
  9822. return v, errors.New("OldStarrole requires an ID field in the mutation")
  9823. }
  9824. oldValue, err := m.oldValue(ctx)
  9825. if err != nil {
  9826. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  9827. }
  9828. return oldValue.Starrole, nil
  9829. }
  9830. // ResetStarrole resets all changes to the "starrole" field.
  9831. func (m *ContactMutation) ResetStarrole() {
  9832. m.starrole = nil
  9833. }
  9834. // SetDontseeit sets the "dontseeit" field.
  9835. func (m *ContactMutation) SetDontseeit(i int) {
  9836. m.dontseeit = &i
  9837. m.adddontseeit = nil
  9838. }
  9839. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  9840. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  9841. v := m.dontseeit
  9842. if v == nil {
  9843. return
  9844. }
  9845. return *v, true
  9846. }
  9847. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  9848. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9849. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9850. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  9851. if !m.op.Is(OpUpdateOne) {
  9852. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  9853. }
  9854. if m.id == nil || m.oldValue == nil {
  9855. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  9856. }
  9857. oldValue, err := m.oldValue(ctx)
  9858. if err != nil {
  9859. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  9860. }
  9861. return oldValue.Dontseeit, nil
  9862. }
  9863. // AddDontseeit adds i to the "dontseeit" field.
  9864. func (m *ContactMutation) AddDontseeit(i int) {
  9865. if m.adddontseeit != nil {
  9866. *m.adddontseeit += i
  9867. } else {
  9868. m.adddontseeit = &i
  9869. }
  9870. }
  9871. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  9872. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  9873. v := m.adddontseeit
  9874. if v == nil {
  9875. return
  9876. }
  9877. return *v, true
  9878. }
  9879. // ResetDontseeit resets all changes to the "dontseeit" field.
  9880. func (m *ContactMutation) ResetDontseeit() {
  9881. m.dontseeit = nil
  9882. m.adddontseeit = nil
  9883. }
  9884. // SetDontseeme sets the "dontseeme" field.
  9885. func (m *ContactMutation) SetDontseeme(i int) {
  9886. m.dontseeme = &i
  9887. m.adddontseeme = nil
  9888. }
  9889. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  9890. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  9891. v := m.dontseeme
  9892. if v == nil {
  9893. return
  9894. }
  9895. return *v, true
  9896. }
  9897. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  9898. // If the Contact 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 *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  9901. if !m.op.Is(OpUpdateOne) {
  9902. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  9903. }
  9904. if m.id == nil || m.oldValue == nil {
  9905. return v, errors.New("OldDontseeme 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 OldDontseeme: %w", err)
  9910. }
  9911. return oldValue.Dontseeme, nil
  9912. }
  9913. // AddDontseeme adds i to the "dontseeme" field.
  9914. func (m *ContactMutation) AddDontseeme(i int) {
  9915. if m.adddontseeme != nil {
  9916. *m.adddontseeme += i
  9917. } else {
  9918. m.adddontseeme = &i
  9919. }
  9920. }
  9921. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  9922. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  9923. v := m.adddontseeme
  9924. if v == nil {
  9925. return
  9926. }
  9927. return *v, true
  9928. }
  9929. // ResetDontseeme resets all changes to the "dontseeme" field.
  9930. func (m *ContactMutation) ResetDontseeme() {
  9931. m.dontseeme = nil
  9932. m.adddontseeme = nil
  9933. }
  9934. // SetLag sets the "lag" field.
  9935. func (m *ContactMutation) SetLag(s string) {
  9936. m.lag = &s
  9937. }
  9938. // Lag returns the value of the "lag" field in the mutation.
  9939. func (m *ContactMutation) Lag() (r string, exists bool) {
  9940. v := m.lag
  9941. if v == nil {
  9942. return
  9943. }
  9944. return *v, true
  9945. }
  9946. // OldLag returns the old "lag" field's value of the Contact entity.
  9947. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9948. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9949. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  9950. if !m.op.Is(OpUpdateOne) {
  9951. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  9952. }
  9953. if m.id == nil || m.oldValue == nil {
  9954. return v, errors.New("OldLag requires an ID field in the mutation")
  9955. }
  9956. oldValue, err := m.oldValue(ctx)
  9957. if err != nil {
  9958. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  9959. }
  9960. return oldValue.Lag, nil
  9961. }
  9962. // ResetLag resets all changes to the "lag" field.
  9963. func (m *ContactMutation) ResetLag() {
  9964. m.lag = nil
  9965. }
  9966. // SetGid sets the "gid" field.
  9967. func (m *ContactMutation) SetGid(s string) {
  9968. m.gid = &s
  9969. }
  9970. // Gid returns the value of the "gid" field in the mutation.
  9971. func (m *ContactMutation) Gid() (r string, exists bool) {
  9972. v := m.gid
  9973. if v == nil {
  9974. return
  9975. }
  9976. return *v, true
  9977. }
  9978. // OldGid returns the old "gid" field's value of the Contact entity.
  9979. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9980. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9981. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  9982. if !m.op.Is(OpUpdateOne) {
  9983. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  9984. }
  9985. if m.id == nil || m.oldValue == nil {
  9986. return v, errors.New("OldGid requires an ID field in the mutation")
  9987. }
  9988. oldValue, err := m.oldValue(ctx)
  9989. if err != nil {
  9990. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  9991. }
  9992. return oldValue.Gid, nil
  9993. }
  9994. // ResetGid resets all changes to the "gid" field.
  9995. func (m *ContactMutation) ResetGid() {
  9996. m.gid = nil
  9997. }
  9998. // SetGname sets the "gname" field.
  9999. func (m *ContactMutation) SetGname(s string) {
  10000. m.gname = &s
  10001. }
  10002. // Gname returns the value of the "gname" field in the mutation.
  10003. func (m *ContactMutation) Gname() (r string, exists bool) {
  10004. v := m.gname
  10005. if v == nil {
  10006. return
  10007. }
  10008. return *v, true
  10009. }
  10010. // OldGname returns the old "gname" field's value of the Contact entity.
  10011. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10013. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  10014. if !m.op.Is(OpUpdateOne) {
  10015. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  10016. }
  10017. if m.id == nil || m.oldValue == nil {
  10018. return v, errors.New("OldGname requires an ID field in the mutation")
  10019. }
  10020. oldValue, err := m.oldValue(ctx)
  10021. if err != nil {
  10022. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  10023. }
  10024. return oldValue.Gname, nil
  10025. }
  10026. // ResetGname resets all changes to the "gname" field.
  10027. func (m *ContactMutation) ResetGname() {
  10028. m.gname = nil
  10029. }
  10030. // SetV3 sets the "v3" field.
  10031. func (m *ContactMutation) SetV3(s string) {
  10032. m.v3 = &s
  10033. }
  10034. // V3 returns the value of the "v3" field in the mutation.
  10035. func (m *ContactMutation) V3() (r string, exists bool) {
  10036. v := m.v3
  10037. if v == nil {
  10038. return
  10039. }
  10040. return *v, true
  10041. }
  10042. // OldV3 returns the old "v3" field's value of the Contact entity.
  10043. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10045. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  10046. if !m.op.Is(OpUpdateOne) {
  10047. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  10048. }
  10049. if m.id == nil || m.oldValue == nil {
  10050. return v, errors.New("OldV3 requires an ID field in the mutation")
  10051. }
  10052. oldValue, err := m.oldValue(ctx)
  10053. if err != nil {
  10054. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  10055. }
  10056. return oldValue.V3, nil
  10057. }
  10058. // ResetV3 resets all changes to the "v3" field.
  10059. func (m *ContactMutation) ResetV3() {
  10060. m.v3 = nil
  10061. }
  10062. // SetOrganizationID sets the "organization_id" field.
  10063. func (m *ContactMutation) SetOrganizationID(u uint64) {
  10064. m.organization_id = &u
  10065. m.addorganization_id = nil
  10066. }
  10067. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10068. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  10069. v := m.organization_id
  10070. if v == nil {
  10071. return
  10072. }
  10073. return *v, true
  10074. }
  10075. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  10076. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10077. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10078. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10079. if !m.op.Is(OpUpdateOne) {
  10080. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10081. }
  10082. if m.id == nil || m.oldValue == nil {
  10083. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10084. }
  10085. oldValue, err := m.oldValue(ctx)
  10086. if err != nil {
  10087. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10088. }
  10089. return oldValue.OrganizationID, nil
  10090. }
  10091. // AddOrganizationID adds u to the "organization_id" field.
  10092. func (m *ContactMutation) AddOrganizationID(u int64) {
  10093. if m.addorganization_id != nil {
  10094. *m.addorganization_id += u
  10095. } else {
  10096. m.addorganization_id = &u
  10097. }
  10098. }
  10099. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10100. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  10101. v := m.addorganization_id
  10102. if v == nil {
  10103. return
  10104. }
  10105. return *v, true
  10106. }
  10107. // ClearOrganizationID clears the value of the "organization_id" field.
  10108. func (m *ContactMutation) ClearOrganizationID() {
  10109. m.organization_id = nil
  10110. m.addorganization_id = nil
  10111. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  10112. }
  10113. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  10114. func (m *ContactMutation) OrganizationIDCleared() bool {
  10115. _, ok := m.clearedFields[contact.FieldOrganizationID]
  10116. return ok
  10117. }
  10118. // ResetOrganizationID resets all changes to the "organization_id" field.
  10119. func (m *ContactMutation) ResetOrganizationID() {
  10120. m.organization_id = nil
  10121. m.addorganization_id = nil
  10122. delete(m.clearedFields, contact.FieldOrganizationID)
  10123. }
  10124. // SetCtype sets the "ctype" field.
  10125. func (m *ContactMutation) SetCtype(u uint64) {
  10126. m.ctype = &u
  10127. m.addctype = nil
  10128. }
  10129. // Ctype returns the value of the "ctype" field in the mutation.
  10130. func (m *ContactMutation) Ctype() (r uint64, exists bool) {
  10131. v := m.ctype
  10132. if v == nil {
  10133. return
  10134. }
  10135. return *v, true
  10136. }
  10137. // OldCtype returns the old "ctype" field's value of the Contact entity.
  10138. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10139. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10140. func (m *ContactMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  10141. if !m.op.Is(OpUpdateOne) {
  10142. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  10143. }
  10144. if m.id == nil || m.oldValue == nil {
  10145. return v, errors.New("OldCtype requires an ID field in the mutation")
  10146. }
  10147. oldValue, err := m.oldValue(ctx)
  10148. if err != nil {
  10149. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  10150. }
  10151. return oldValue.Ctype, nil
  10152. }
  10153. // AddCtype adds u to the "ctype" field.
  10154. func (m *ContactMutation) AddCtype(u int64) {
  10155. if m.addctype != nil {
  10156. *m.addctype += u
  10157. } else {
  10158. m.addctype = &u
  10159. }
  10160. }
  10161. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  10162. func (m *ContactMutation) AddedCtype() (r int64, exists bool) {
  10163. v := m.addctype
  10164. if v == nil {
  10165. return
  10166. }
  10167. return *v, true
  10168. }
  10169. // ResetCtype resets all changes to the "ctype" field.
  10170. func (m *ContactMutation) ResetCtype() {
  10171. m.ctype = nil
  10172. m.addctype = nil
  10173. }
  10174. // SetCage sets the "cage" field.
  10175. func (m *ContactMutation) SetCage(i int) {
  10176. m.cage = &i
  10177. m.addcage = nil
  10178. }
  10179. // Cage returns the value of the "cage" field in the mutation.
  10180. func (m *ContactMutation) Cage() (r int, exists bool) {
  10181. v := m.cage
  10182. if v == nil {
  10183. return
  10184. }
  10185. return *v, true
  10186. }
  10187. // OldCage returns the old "cage" field's value of the Contact entity.
  10188. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10189. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10190. func (m *ContactMutation) OldCage(ctx context.Context) (v int, err error) {
  10191. if !m.op.Is(OpUpdateOne) {
  10192. return v, errors.New("OldCage is only allowed on UpdateOne operations")
  10193. }
  10194. if m.id == nil || m.oldValue == nil {
  10195. return v, errors.New("OldCage requires an ID field in the mutation")
  10196. }
  10197. oldValue, err := m.oldValue(ctx)
  10198. if err != nil {
  10199. return v, fmt.Errorf("querying old value for OldCage: %w", err)
  10200. }
  10201. return oldValue.Cage, nil
  10202. }
  10203. // AddCage adds i to the "cage" field.
  10204. func (m *ContactMutation) AddCage(i int) {
  10205. if m.addcage != nil {
  10206. *m.addcage += i
  10207. } else {
  10208. m.addcage = &i
  10209. }
  10210. }
  10211. // AddedCage returns the value that was added to the "cage" field in this mutation.
  10212. func (m *ContactMutation) AddedCage() (r int, exists bool) {
  10213. v := m.addcage
  10214. if v == nil {
  10215. return
  10216. }
  10217. return *v, true
  10218. }
  10219. // ResetCage resets all changes to the "cage" field.
  10220. func (m *ContactMutation) ResetCage() {
  10221. m.cage = nil
  10222. m.addcage = nil
  10223. }
  10224. // SetCname sets the "cname" field.
  10225. func (m *ContactMutation) SetCname(s string) {
  10226. m.cname = &s
  10227. }
  10228. // Cname returns the value of the "cname" field in the mutation.
  10229. func (m *ContactMutation) Cname() (r string, exists bool) {
  10230. v := m.cname
  10231. if v == nil {
  10232. return
  10233. }
  10234. return *v, true
  10235. }
  10236. // OldCname returns the old "cname" field's value of the Contact entity.
  10237. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10238. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10239. func (m *ContactMutation) OldCname(ctx context.Context) (v string, err error) {
  10240. if !m.op.Is(OpUpdateOne) {
  10241. return v, errors.New("OldCname is only allowed on UpdateOne operations")
  10242. }
  10243. if m.id == nil || m.oldValue == nil {
  10244. return v, errors.New("OldCname requires an ID field in the mutation")
  10245. }
  10246. oldValue, err := m.oldValue(ctx)
  10247. if err != nil {
  10248. return v, fmt.Errorf("querying old value for OldCname: %w", err)
  10249. }
  10250. return oldValue.Cname, nil
  10251. }
  10252. // ResetCname resets all changes to the "cname" field.
  10253. func (m *ContactMutation) ResetCname() {
  10254. m.cname = nil
  10255. }
  10256. // SetCarea sets the "carea" field.
  10257. func (m *ContactMutation) SetCarea(s string) {
  10258. m.carea = &s
  10259. }
  10260. // Carea returns the value of the "carea" field in the mutation.
  10261. func (m *ContactMutation) Carea() (r string, exists bool) {
  10262. v := m.carea
  10263. if v == nil {
  10264. return
  10265. }
  10266. return *v, true
  10267. }
  10268. // OldCarea returns the old "carea" field's value of the Contact entity.
  10269. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10270. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10271. func (m *ContactMutation) OldCarea(ctx context.Context) (v string, err error) {
  10272. if !m.op.Is(OpUpdateOne) {
  10273. return v, errors.New("OldCarea is only allowed on UpdateOne operations")
  10274. }
  10275. if m.id == nil || m.oldValue == nil {
  10276. return v, errors.New("OldCarea requires an ID field in the mutation")
  10277. }
  10278. oldValue, err := m.oldValue(ctx)
  10279. if err != nil {
  10280. return v, fmt.Errorf("querying old value for OldCarea: %w", err)
  10281. }
  10282. return oldValue.Carea, nil
  10283. }
  10284. // ResetCarea resets all changes to the "carea" field.
  10285. func (m *ContactMutation) ResetCarea() {
  10286. m.carea = nil
  10287. }
  10288. // SetCbirthday sets the "cbirthday" field.
  10289. func (m *ContactMutation) SetCbirthday(s string) {
  10290. m.cbirthday = &s
  10291. }
  10292. // Cbirthday returns the value of the "cbirthday" field in the mutation.
  10293. func (m *ContactMutation) Cbirthday() (r string, exists bool) {
  10294. v := m.cbirthday
  10295. if v == nil {
  10296. return
  10297. }
  10298. return *v, true
  10299. }
  10300. // OldCbirthday returns the old "cbirthday" field's value of the Contact entity.
  10301. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10302. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10303. func (m *ContactMutation) OldCbirthday(ctx context.Context) (v string, err error) {
  10304. if !m.op.Is(OpUpdateOne) {
  10305. return v, errors.New("OldCbirthday is only allowed on UpdateOne operations")
  10306. }
  10307. if m.id == nil || m.oldValue == nil {
  10308. return v, errors.New("OldCbirthday requires an ID field in the mutation")
  10309. }
  10310. oldValue, err := m.oldValue(ctx)
  10311. if err != nil {
  10312. return v, fmt.Errorf("querying old value for OldCbirthday: %w", err)
  10313. }
  10314. return oldValue.Cbirthday, nil
  10315. }
  10316. // ResetCbirthday resets all changes to the "cbirthday" field.
  10317. func (m *ContactMutation) ResetCbirthday() {
  10318. m.cbirthday = nil
  10319. }
  10320. // SetCbirtharea sets the "cbirtharea" field.
  10321. func (m *ContactMutation) SetCbirtharea(s string) {
  10322. m.cbirtharea = &s
  10323. }
  10324. // Cbirtharea returns the value of the "cbirtharea" field in the mutation.
  10325. func (m *ContactMutation) Cbirtharea() (r string, exists bool) {
  10326. v := m.cbirtharea
  10327. if v == nil {
  10328. return
  10329. }
  10330. return *v, true
  10331. }
  10332. // OldCbirtharea returns the old "cbirtharea" field's value of the Contact entity.
  10333. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10334. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10335. func (m *ContactMutation) OldCbirtharea(ctx context.Context) (v string, err error) {
  10336. if !m.op.Is(OpUpdateOne) {
  10337. return v, errors.New("OldCbirtharea is only allowed on UpdateOne operations")
  10338. }
  10339. if m.id == nil || m.oldValue == nil {
  10340. return v, errors.New("OldCbirtharea requires an ID field in the mutation")
  10341. }
  10342. oldValue, err := m.oldValue(ctx)
  10343. if err != nil {
  10344. return v, fmt.Errorf("querying old value for OldCbirtharea: %w", err)
  10345. }
  10346. return oldValue.Cbirtharea, nil
  10347. }
  10348. // ResetCbirtharea resets all changes to the "cbirtharea" field.
  10349. func (m *ContactMutation) ResetCbirtharea() {
  10350. m.cbirtharea = nil
  10351. }
  10352. // SetCidcardNo sets the "cidcard_no" field.
  10353. func (m *ContactMutation) SetCidcardNo(s string) {
  10354. m.cidcard_no = &s
  10355. }
  10356. // CidcardNo returns the value of the "cidcard_no" field in the mutation.
  10357. func (m *ContactMutation) CidcardNo() (r string, exists bool) {
  10358. v := m.cidcard_no
  10359. if v == nil {
  10360. return
  10361. }
  10362. return *v, true
  10363. }
  10364. // OldCidcardNo returns the old "cidcard_no" field's value of the Contact entity.
  10365. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10366. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10367. func (m *ContactMutation) OldCidcardNo(ctx context.Context) (v string, err error) {
  10368. if !m.op.Is(OpUpdateOne) {
  10369. return v, errors.New("OldCidcardNo is only allowed on UpdateOne operations")
  10370. }
  10371. if m.id == nil || m.oldValue == nil {
  10372. return v, errors.New("OldCidcardNo requires an ID field in the mutation")
  10373. }
  10374. oldValue, err := m.oldValue(ctx)
  10375. if err != nil {
  10376. return v, fmt.Errorf("querying old value for OldCidcardNo: %w", err)
  10377. }
  10378. return oldValue.CidcardNo, nil
  10379. }
  10380. // ResetCidcardNo resets all changes to the "cidcard_no" field.
  10381. func (m *ContactMutation) ResetCidcardNo() {
  10382. m.cidcard_no = nil
  10383. }
  10384. // SetCtitle sets the "ctitle" field.
  10385. func (m *ContactMutation) SetCtitle(s string) {
  10386. m.ctitle = &s
  10387. }
  10388. // Ctitle returns the value of the "ctitle" field in the mutation.
  10389. func (m *ContactMutation) Ctitle() (r string, exists bool) {
  10390. v := m.ctitle
  10391. if v == nil {
  10392. return
  10393. }
  10394. return *v, true
  10395. }
  10396. // OldCtitle returns the old "ctitle" field's value of the Contact entity.
  10397. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10398. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10399. func (m *ContactMutation) OldCtitle(ctx context.Context) (v string, err error) {
  10400. if !m.op.Is(OpUpdateOne) {
  10401. return v, errors.New("OldCtitle is only allowed on UpdateOne operations")
  10402. }
  10403. if m.id == nil || m.oldValue == nil {
  10404. return v, errors.New("OldCtitle requires an ID field in the mutation")
  10405. }
  10406. oldValue, err := m.oldValue(ctx)
  10407. if err != nil {
  10408. return v, fmt.Errorf("querying old value for OldCtitle: %w", err)
  10409. }
  10410. return oldValue.Ctitle, nil
  10411. }
  10412. // ResetCtitle resets all changes to the "ctitle" field.
  10413. func (m *ContactMutation) ResetCtitle() {
  10414. m.ctitle = nil
  10415. }
  10416. // SetCc sets the "cc" field.
  10417. func (m *ContactMutation) SetCc(s string) {
  10418. m.cc = &s
  10419. }
  10420. // Cc returns the value of the "cc" field in the mutation.
  10421. func (m *ContactMutation) Cc() (r string, exists bool) {
  10422. v := m.cc
  10423. if v == nil {
  10424. return
  10425. }
  10426. return *v, true
  10427. }
  10428. // OldCc returns the old "cc" field's value of the Contact entity.
  10429. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10430. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10431. func (m *ContactMutation) OldCc(ctx context.Context) (v string, err error) {
  10432. if !m.op.Is(OpUpdateOne) {
  10433. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  10434. }
  10435. if m.id == nil || m.oldValue == nil {
  10436. return v, errors.New("OldCc requires an ID field in the mutation")
  10437. }
  10438. oldValue, err := m.oldValue(ctx)
  10439. if err != nil {
  10440. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  10441. }
  10442. return oldValue.Cc, nil
  10443. }
  10444. // ResetCc resets all changes to the "cc" field.
  10445. func (m *ContactMutation) ResetCc() {
  10446. m.cc = nil
  10447. }
  10448. // SetPhone sets the "phone" field.
  10449. func (m *ContactMutation) SetPhone(s string) {
  10450. m.phone = &s
  10451. }
  10452. // Phone returns the value of the "phone" field in the mutation.
  10453. func (m *ContactMutation) Phone() (r string, exists bool) {
  10454. v := m.phone
  10455. if v == nil {
  10456. return
  10457. }
  10458. return *v, true
  10459. }
  10460. // OldPhone returns the old "phone" field's value of the Contact entity.
  10461. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10462. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10463. func (m *ContactMutation) OldPhone(ctx context.Context) (v string, err error) {
  10464. if !m.op.Is(OpUpdateOne) {
  10465. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  10466. }
  10467. if m.id == nil || m.oldValue == nil {
  10468. return v, errors.New("OldPhone requires an ID field in the mutation")
  10469. }
  10470. oldValue, err := m.oldValue(ctx)
  10471. if err != nil {
  10472. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  10473. }
  10474. return oldValue.Phone, nil
  10475. }
  10476. // ResetPhone resets all changes to the "phone" field.
  10477. func (m *ContactMutation) ResetPhone() {
  10478. m.phone = nil
  10479. }
  10480. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  10481. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  10482. if m.contact_relationships == nil {
  10483. m.contact_relationships = make(map[uint64]struct{})
  10484. }
  10485. for i := range ids {
  10486. m.contact_relationships[ids[i]] = struct{}{}
  10487. }
  10488. }
  10489. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  10490. func (m *ContactMutation) ClearContactRelationships() {
  10491. m.clearedcontact_relationships = true
  10492. }
  10493. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  10494. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  10495. return m.clearedcontact_relationships
  10496. }
  10497. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  10498. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  10499. if m.removedcontact_relationships == nil {
  10500. m.removedcontact_relationships = make(map[uint64]struct{})
  10501. }
  10502. for i := range ids {
  10503. delete(m.contact_relationships, ids[i])
  10504. m.removedcontact_relationships[ids[i]] = struct{}{}
  10505. }
  10506. }
  10507. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  10508. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  10509. for id := range m.removedcontact_relationships {
  10510. ids = append(ids, id)
  10511. }
  10512. return
  10513. }
  10514. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  10515. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  10516. for id := range m.contact_relationships {
  10517. ids = append(ids, id)
  10518. }
  10519. return
  10520. }
  10521. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  10522. func (m *ContactMutation) ResetContactRelationships() {
  10523. m.contact_relationships = nil
  10524. m.clearedcontact_relationships = false
  10525. m.removedcontact_relationships = nil
  10526. }
  10527. // AddContactFieldIDs adds the "contact_fields" edge to the ContactField entity by ids.
  10528. func (m *ContactMutation) AddContactFieldIDs(ids ...uint64) {
  10529. if m.contact_fields == nil {
  10530. m.contact_fields = make(map[uint64]struct{})
  10531. }
  10532. for i := range ids {
  10533. m.contact_fields[ids[i]] = struct{}{}
  10534. }
  10535. }
  10536. // ClearContactFields clears the "contact_fields" edge to the ContactField entity.
  10537. func (m *ContactMutation) ClearContactFields() {
  10538. m.clearedcontact_fields = true
  10539. }
  10540. // ContactFieldsCleared reports if the "contact_fields" edge to the ContactField entity was cleared.
  10541. func (m *ContactMutation) ContactFieldsCleared() bool {
  10542. return m.clearedcontact_fields
  10543. }
  10544. // RemoveContactFieldIDs removes the "contact_fields" edge to the ContactField entity by IDs.
  10545. func (m *ContactMutation) RemoveContactFieldIDs(ids ...uint64) {
  10546. if m.removedcontact_fields == nil {
  10547. m.removedcontact_fields = make(map[uint64]struct{})
  10548. }
  10549. for i := range ids {
  10550. delete(m.contact_fields, ids[i])
  10551. m.removedcontact_fields[ids[i]] = struct{}{}
  10552. }
  10553. }
  10554. // RemovedContactFields returns the removed IDs of the "contact_fields" edge to the ContactField entity.
  10555. func (m *ContactMutation) RemovedContactFieldsIDs() (ids []uint64) {
  10556. for id := range m.removedcontact_fields {
  10557. ids = append(ids, id)
  10558. }
  10559. return
  10560. }
  10561. // ContactFieldsIDs returns the "contact_fields" edge IDs in the mutation.
  10562. func (m *ContactMutation) ContactFieldsIDs() (ids []uint64) {
  10563. for id := range m.contact_fields {
  10564. ids = append(ids, id)
  10565. }
  10566. return
  10567. }
  10568. // ResetContactFields resets all changes to the "contact_fields" edge.
  10569. func (m *ContactMutation) ResetContactFields() {
  10570. m.contact_fields = nil
  10571. m.clearedcontact_fields = false
  10572. m.removedcontact_fields = nil
  10573. }
  10574. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  10575. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  10576. if m.contact_messages == nil {
  10577. m.contact_messages = make(map[uint64]struct{})
  10578. }
  10579. for i := range ids {
  10580. m.contact_messages[ids[i]] = struct{}{}
  10581. }
  10582. }
  10583. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  10584. func (m *ContactMutation) ClearContactMessages() {
  10585. m.clearedcontact_messages = true
  10586. }
  10587. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  10588. func (m *ContactMutation) ContactMessagesCleared() bool {
  10589. return m.clearedcontact_messages
  10590. }
  10591. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  10592. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  10593. if m.removedcontact_messages == nil {
  10594. m.removedcontact_messages = make(map[uint64]struct{})
  10595. }
  10596. for i := range ids {
  10597. delete(m.contact_messages, ids[i])
  10598. m.removedcontact_messages[ids[i]] = struct{}{}
  10599. }
  10600. }
  10601. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  10602. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  10603. for id := range m.removedcontact_messages {
  10604. ids = append(ids, id)
  10605. }
  10606. return
  10607. }
  10608. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  10609. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  10610. for id := range m.contact_messages {
  10611. ids = append(ids, id)
  10612. }
  10613. return
  10614. }
  10615. // ResetContactMessages resets all changes to the "contact_messages" edge.
  10616. func (m *ContactMutation) ResetContactMessages() {
  10617. m.contact_messages = nil
  10618. m.clearedcontact_messages = false
  10619. m.removedcontact_messages = nil
  10620. }
  10621. // Where appends a list predicates to the ContactMutation builder.
  10622. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  10623. m.predicates = append(m.predicates, ps...)
  10624. }
  10625. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  10626. // users can use type-assertion to append predicates that do not depend on any generated package.
  10627. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  10628. p := make([]predicate.Contact, len(ps))
  10629. for i := range ps {
  10630. p[i] = ps[i]
  10631. }
  10632. m.Where(p...)
  10633. }
  10634. // Op returns the operation name.
  10635. func (m *ContactMutation) Op() Op {
  10636. return m.op
  10637. }
  10638. // SetOp allows setting the mutation operation.
  10639. func (m *ContactMutation) SetOp(op Op) {
  10640. m.op = op
  10641. }
  10642. // Type returns the node type of this mutation (Contact).
  10643. func (m *ContactMutation) Type() string {
  10644. return m.typ
  10645. }
  10646. // Fields returns all fields that were changed during this mutation. Note that in
  10647. // order to get all numeric fields that were incremented/decremented, call
  10648. // AddedFields().
  10649. func (m *ContactMutation) Fields() []string {
  10650. fields := make([]string, 0, 30)
  10651. if m.created_at != nil {
  10652. fields = append(fields, contact.FieldCreatedAt)
  10653. }
  10654. if m.updated_at != nil {
  10655. fields = append(fields, contact.FieldUpdatedAt)
  10656. }
  10657. if m.status != nil {
  10658. fields = append(fields, contact.FieldStatus)
  10659. }
  10660. if m.deleted_at != nil {
  10661. fields = append(fields, contact.FieldDeletedAt)
  10662. }
  10663. if m.wx_wxid != nil {
  10664. fields = append(fields, contact.FieldWxWxid)
  10665. }
  10666. if m._type != nil {
  10667. fields = append(fields, contact.FieldType)
  10668. }
  10669. if m.wxid != nil {
  10670. fields = append(fields, contact.FieldWxid)
  10671. }
  10672. if m.account != nil {
  10673. fields = append(fields, contact.FieldAccount)
  10674. }
  10675. if m.nickname != nil {
  10676. fields = append(fields, contact.FieldNickname)
  10677. }
  10678. if m.markname != nil {
  10679. fields = append(fields, contact.FieldMarkname)
  10680. }
  10681. if m.headimg != nil {
  10682. fields = append(fields, contact.FieldHeadimg)
  10683. }
  10684. if m.sex != nil {
  10685. fields = append(fields, contact.FieldSex)
  10686. }
  10687. if m.starrole != nil {
  10688. fields = append(fields, contact.FieldStarrole)
  10689. }
  10690. if m.dontseeit != nil {
  10691. fields = append(fields, contact.FieldDontseeit)
  10692. }
  10693. if m.dontseeme != nil {
  10694. fields = append(fields, contact.FieldDontseeme)
  10695. }
  10696. if m.lag != nil {
  10697. fields = append(fields, contact.FieldLag)
  10698. }
  10699. if m.gid != nil {
  10700. fields = append(fields, contact.FieldGid)
  10701. }
  10702. if m.gname != nil {
  10703. fields = append(fields, contact.FieldGname)
  10704. }
  10705. if m.v3 != nil {
  10706. fields = append(fields, contact.FieldV3)
  10707. }
  10708. if m.organization_id != nil {
  10709. fields = append(fields, contact.FieldOrganizationID)
  10710. }
  10711. if m.ctype != nil {
  10712. fields = append(fields, contact.FieldCtype)
  10713. }
  10714. if m.cage != nil {
  10715. fields = append(fields, contact.FieldCage)
  10716. }
  10717. if m.cname != nil {
  10718. fields = append(fields, contact.FieldCname)
  10719. }
  10720. if m.carea != nil {
  10721. fields = append(fields, contact.FieldCarea)
  10722. }
  10723. if m.cbirthday != nil {
  10724. fields = append(fields, contact.FieldCbirthday)
  10725. }
  10726. if m.cbirtharea != nil {
  10727. fields = append(fields, contact.FieldCbirtharea)
  10728. }
  10729. if m.cidcard_no != nil {
  10730. fields = append(fields, contact.FieldCidcardNo)
  10731. }
  10732. if m.ctitle != nil {
  10733. fields = append(fields, contact.FieldCtitle)
  10734. }
  10735. if m.cc != nil {
  10736. fields = append(fields, contact.FieldCc)
  10737. }
  10738. if m.phone != nil {
  10739. fields = append(fields, contact.FieldPhone)
  10740. }
  10741. return fields
  10742. }
  10743. // Field returns the value of a field with the given name. The second boolean
  10744. // return value indicates that this field was not set, or was not defined in the
  10745. // schema.
  10746. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  10747. switch name {
  10748. case contact.FieldCreatedAt:
  10749. return m.CreatedAt()
  10750. case contact.FieldUpdatedAt:
  10751. return m.UpdatedAt()
  10752. case contact.FieldStatus:
  10753. return m.Status()
  10754. case contact.FieldDeletedAt:
  10755. return m.DeletedAt()
  10756. case contact.FieldWxWxid:
  10757. return m.WxWxid()
  10758. case contact.FieldType:
  10759. return m.GetType()
  10760. case contact.FieldWxid:
  10761. return m.Wxid()
  10762. case contact.FieldAccount:
  10763. return m.Account()
  10764. case contact.FieldNickname:
  10765. return m.Nickname()
  10766. case contact.FieldMarkname:
  10767. return m.Markname()
  10768. case contact.FieldHeadimg:
  10769. return m.Headimg()
  10770. case contact.FieldSex:
  10771. return m.Sex()
  10772. case contact.FieldStarrole:
  10773. return m.Starrole()
  10774. case contact.FieldDontseeit:
  10775. return m.Dontseeit()
  10776. case contact.FieldDontseeme:
  10777. return m.Dontseeme()
  10778. case contact.FieldLag:
  10779. return m.Lag()
  10780. case contact.FieldGid:
  10781. return m.Gid()
  10782. case contact.FieldGname:
  10783. return m.Gname()
  10784. case contact.FieldV3:
  10785. return m.V3()
  10786. case contact.FieldOrganizationID:
  10787. return m.OrganizationID()
  10788. case contact.FieldCtype:
  10789. return m.Ctype()
  10790. case contact.FieldCage:
  10791. return m.Cage()
  10792. case contact.FieldCname:
  10793. return m.Cname()
  10794. case contact.FieldCarea:
  10795. return m.Carea()
  10796. case contact.FieldCbirthday:
  10797. return m.Cbirthday()
  10798. case contact.FieldCbirtharea:
  10799. return m.Cbirtharea()
  10800. case contact.FieldCidcardNo:
  10801. return m.CidcardNo()
  10802. case contact.FieldCtitle:
  10803. return m.Ctitle()
  10804. case contact.FieldCc:
  10805. return m.Cc()
  10806. case contact.FieldPhone:
  10807. return m.Phone()
  10808. }
  10809. return nil, false
  10810. }
  10811. // OldField returns the old value of the field from the database. An error is
  10812. // returned if the mutation operation is not UpdateOne, or the query to the
  10813. // database failed.
  10814. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10815. switch name {
  10816. case contact.FieldCreatedAt:
  10817. return m.OldCreatedAt(ctx)
  10818. case contact.FieldUpdatedAt:
  10819. return m.OldUpdatedAt(ctx)
  10820. case contact.FieldStatus:
  10821. return m.OldStatus(ctx)
  10822. case contact.FieldDeletedAt:
  10823. return m.OldDeletedAt(ctx)
  10824. case contact.FieldWxWxid:
  10825. return m.OldWxWxid(ctx)
  10826. case contact.FieldType:
  10827. return m.OldType(ctx)
  10828. case contact.FieldWxid:
  10829. return m.OldWxid(ctx)
  10830. case contact.FieldAccount:
  10831. return m.OldAccount(ctx)
  10832. case contact.FieldNickname:
  10833. return m.OldNickname(ctx)
  10834. case contact.FieldMarkname:
  10835. return m.OldMarkname(ctx)
  10836. case contact.FieldHeadimg:
  10837. return m.OldHeadimg(ctx)
  10838. case contact.FieldSex:
  10839. return m.OldSex(ctx)
  10840. case contact.FieldStarrole:
  10841. return m.OldStarrole(ctx)
  10842. case contact.FieldDontseeit:
  10843. return m.OldDontseeit(ctx)
  10844. case contact.FieldDontseeme:
  10845. return m.OldDontseeme(ctx)
  10846. case contact.FieldLag:
  10847. return m.OldLag(ctx)
  10848. case contact.FieldGid:
  10849. return m.OldGid(ctx)
  10850. case contact.FieldGname:
  10851. return m.OldGname(ctx)
  10852. case contact.FieldV3:
  10853. return m.OldV3(ctx)
  10854. case contact.FieldOrganizationID:
  10855. return m.OldOrganizationID(ctx)
  10856. case contact.FieldCtype:
  10857. return m.OldCtype(ctx)
  10858. case contact.FieldCage:
  10859. return m.OldCage(ctx)
  10860. case contact.FieldCname:
  10861. return m.OldCname(ctx)
  10862. case contact.FieldCarea:
  10863. return m.OldCarea(ctx)
  10864. case contact.FieldCbirthday:
  10865. return m.OldCbirthday(ctx)
  10866. case contact.FieldCbirtharea:
  10867. return m.OldCbirtharea(ctx)
  10868. case contact.FieldCidcardNo:
  10869. return m.OldCidcardNo(ctx)
  10870. case contact.FieldCtitle:
  10871. return m.OldCtitle(ctx)
  10872. case contact.FieldCc:
  10873. return m.OldCc(ctx)
  10874. case contact.FieldPhone:
  10875. return m.OldPhone(ctx)
  10876. }
  10877. return nil, fmt.Errorf("unknown Contact field %s", name)
  10878. }
  10879. // SetField sets the value of a field with the given name. It returns an error if
  10880. // the field is not defined in the schema, or if the type mismatched the field
  10881. // type.
  10882. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  10883. switch name {
  10884. case contact.FieldCreatedAt:
  10885. v, ok := value.(time.Time)
  10886. if !ok {
  10887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10888. }
  10889. m.SetCreatedAt(v)
  10890. return nil
  10891. case contact.FieldUpdatedAt:
  10892. v, ok := value.(time.Time)
  10893. if !ok {
  10894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10895. }
  10896. m.SetUpdatedAt(v)
  10897. return nil
  10898. case contact.FieldStatus:
  10899. v, ok := value.(uint8)
  10900. if !ok {
  10901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10902. }
  10903. m.SetStatus(v)
  10904. return nil
  10905. case contact.FieldDeletedAt:
  10906. v, ok := value.(time.Time)
  10907. if !ok {
  10908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10909. }
  10910. m.SetDeletedAt(v)
  10911. return nil
  10912. case contact.FieldWxWxid:
  10913. v, ok := value.(string)
  10914. if !ok {
  10915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10916. }
  10917. m.SetWxWxid(v)
  10918. return nil
  10919. case contact.FieldType:
  10920. v, ok := value.(int)
  10921. if !ok {
  10922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10923. }
  10924. m.SetType(v)
  10925. return nil
  10926. case contact.FieldWxid:
  10927. v, ok := value.(string)
  10928. if !ok {
  10929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10930. }
  10931. m.SetWxid(v)
  10932. return nil
  10933. case contact.FieldAccount:
  10934. v, ok := value.(string)
  10935. if !ok {
  10936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10937. }
  10938. m.SetAccount(v)
  10939. return nil
  10940. case contact.FieldNickname:
  10941. v, ok := value.(string)
  10942. if !ok {
  10943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10944. }
  10945. m.SetNickname(v)
  10946. return nil
  10947. case contact.FieldMarkname:
  10948. v, ok := value.(string)
  10949. if !ok {
  10950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10951. }
  10952. m.SetMarkname(v)
  10953. return nil
  10954. case contact.FieldHeadimg:
  10955. v, ok := value.(string)
  10956. if !ok {
  10957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10958. }
  10959. m.SetHeadimg(v)
  10960. return nil
  10961. case contact.FieldSex:
  10962. v, ok := value.(int)
  10963. if !ok {
  10964. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10965. }
  10966. m.SetSex(v)
  10967. return nil
  10968. case contact.FieldStarrole:
  10969. v, ok := value.(string)
  10970. if !ok {
  10971. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10972. }
  10973. m.SetStarrole(v)
  10974. return nil
  10975. case contact.FieldDontseeit:
  10976. v, ok := value.(int)
  10977. if !ok {
  10978. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10979. }
  10980. m.SetDontseeit(v)
  10981. return nil
  10982. case contact.FieldDontseeme:
  10983. v, ok := value.(int)
  10984. if !ok {
  10985. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10986. }
  10987. m.SetDontseeme(v)
  10988. return nil
  10989. case contact.FieldLag:
  10990. v, ok := value.(string)
  10991. if !ok {
  10992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10993. }
  10994. m.SetLag(v)
  10995. return nil
  10996. case contact.FieldGid:
  10997. v, ok := value.(string)
  10998. if !ok {
  10999. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11000. }
  11001. m.SetGid(v)
  11002. return nil
  11003. case contact.FieldGname:
  11004. v, ok := value.(string)
  11005. if !ok {
  11006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11007. }
  11008. m.SetGname(v)
  11009. return nil
  11010. case contact.FieldV3:
  11011. v, ok := value.(string)
  11012. if !ok {
  11013. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11014. }
  11015. m.SetV3(v)
  11016. return nil
  11017. case contact.FieldOrganizationID:
  11018. v, ok := value.(uint64)
  11019. if !ok {
  11020. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11021. }
  11022. m.SetOrganizationID(v)
  11023. return nil
  11024. case contact.FieldCtype:
  11025. v, ok := value.(uint64)
  11026. if !ok {
  11027. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11028. }
  11029. m.SetCtype(v)
  11030. return nil
  11031. case contact.FieldCage:
  11032. v, ok := value.(int)
  11033. if !ok {
  11034. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11035. }
  11036. m.SetCage(v)
  11037. return nil
  11038. case contact.FieldCname:
  11039. v, ok := value.(string)
  11040. if !ok {
  11041. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11042. }
  11043. m.SetCname(v)
  11044. return nil
  11045. case contact.FieldCarea:
  11046. v, ok := value.(string)
  11047. if !ok {
  11048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11049. }
  11050. m.SetCarea(v)
  11051. return nil
  11052. case contact.FieldCbirthday:
  11053. v, ok := value.(string)
  11054. if !ok {
  11055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11056. }
  11057. m.SetCbirthday(v)
  11058. return nil
  11059. case contact.FieldCbirtharea:
  11060. v, ok := value.(string)
  11061. if !ok {
  11062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11063. }
  11064. m.SetCbirtharea(v)
  11065. return nil
  11066. case contact.FieldCidcardNo:
  11067. v, ok := value.(string)
  11068. if !ok {
  11069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11070. }
  11071. m.SetCidcardNo(v)
  11072. return nil
  11073. case contact.FieldCtitle:
  11074. v, ok := value.(string)
  11075. if !ok {
  11076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11077. }
  11078. m.SetCtitle(v)
  11079. return nil
  11080. case contact.FieldCc:
  11081. v, ok := value.(string)
  11082. if !ok {
  11083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11084. }
  11085. m.SetCc(v)
  11086. return nil
  11087. case contact.FieldPhone:
  11088. v, ok := value.(string)
  11089. if !ok {
  11090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11091. }
  11092. m.SetPhone(v)
  11093. return nil
  11094. }
  11095. return fmt.Errorf("unknown Contact field %s", name)
  11096. }
  11097. // AddedFields returns all numeric fields that were incremented/decremented during
  11098. // this mutation.
  11099. func (m *ContactMutation) AddedFields() []string {
  11100. var fields []string
  11101. if m.addstatus != nil {
  11102. fields = append(fields, contact.FieldStatus)
  11103. }
  11104. if m.add_type != nil {
  11105. fields = append(fields, contact.FieldType)
  11106. }
  11107. if m.addsex != nil {
  11108. fields = append(fields, contact.FieldSex)
  11109. }
  11110. if m.adddontseeit != nil {
  11111. fields = append(fields, contact.FieldDontseeit)
  11112. }
  11113. if m.adddontseeme != nil {
  11114. fields = append(fields, contact.FieldDontseeme)
  11115. }
  11116. if m.addorganization_id != nil {
  11117. fields = append(fields, contact.FieldOrganizationID)
  11118. }
  11119. if m.addctype != nil {
  11120. fields = append(fields, contact.FieldCtype)
  11121. }
  11122. if m.addcage != nil {
  11123. fields = append(fields, contact.FieldCage)
  11124. }
  11125. return fields
  11126. }
  11127. // AddedField returns the numeric value that was incremented/decremented on a field
  11128. // with the given name. The second boolean return value indicates that this field
  11129. // was not set, or was not defined in the schema.
  11130. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  11131. switch name {
  11132. case contact.FieldStatus:
  11133. return m.AddedStatus()
  11134. case contact.FieldType:
  11135. return m.AddedType()
  11136. case contact.FieldSex:
  11137. return m.AddedSex()
  11138. case contact.FieldDontseeit:
  11139. return m.AddedDontseeit()
  11140. case contact.FieldDontseeme:
  11141. return m.AddedDontseeme()
  11142. case contact.FieldOrganizationID:
  11143. return m.AddedOrganizationID()
  11144. case contact.FieldCtype:
  11145. return m.AddedCtype()
  11146. case contact.FieldCage:
  11147. return m.AddedCage()
  11148. }
  11149. return nil, false
  11150. }
  11151. // AddField adds the value to the field with the given name. It returns an error if
  11152. // the field is not defined in the schema, or if the type mismatched the field
  11153. // type.
  11154. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  11155. switch name {
  11156. case contact.FieldStatus:
  11157. v, ok := value.(int8)
  11158. if !ok {
  11159. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11160. }
  11161. m.AddStatus(v)
  11162. return nil
  11163. case contact.FieldType:
  11164. v, ok := value.(int)
  11165. if !ok {
  11166. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11167. }
  11168. m.AddType(v)
  11169. return nil
  11170. case contact.FieldSex:
  11171. v, ok := value.(int)
  11172. if !ok {
  11173. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11174. }
  11175. m.AddSex(v)
  11176. return nil
  11177. case contact.FieldDontseeit:
  11178. v, ok := value.(int)
  11179. if !ok {
  11180. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11181. }
  11182. m.AddDontseeit(v)
  11183. return nil
  11184. case contact.FieldDontseeme:
  11185. v, ok := value.(int)
  11186. if !ok {
  11187. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11188. }
  11189. m.AddDontseeme(v)
  11190. return nil
  11191. case contact.FieldOrganizationID:
  11192. v, ok := value.(int64)
  11193. if !ok {
  11194. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11195. }
  11196. m.AddOrganizationID(v)
  11197. return nil
  11198. case contact.FieldCtype:
  11199. v, ok := value.(int64)
  11200. if !ok {
  11201. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11202. }
  11203. m.AddCtype(v)
  11204. return nil
  11205. case contact.FieldCage:
  11206. v, ok := value.(int)
  11207. if !ok {
  11208. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11209. }
  11210. m.AddCage(v)
  11211. return nil
  11212. }
  11213. return fmt.Errorf("unknown Contact numeric field %s", name)
  11214. }
  11215. // ClearedFields returns all nullable fields that were cleared during this
  11216. // mutation.
  11217. func (m *ContactMutation) ClearedFields() []string {
  11218. var fields []string
  11219. if m.FieldCleared(contact.FieldStatus) {
  11220. fields = append(fields, contact.FieldStatus)
  11221. }
  11222. if m.FieldCleared(contact.FieldDeletedAt) {
  11223. fields = append(fields, contact.FieldDeletedAt)
  11224. }
  11225. if m.FieldCleared(contact.FieldType) {
  11226. fields = append(fields, contact.FieldType)
  11227. }
  11228. if m.FieldCleared(contact.FieldOrganizationID) {
  11229. fields = append(fields, contact.FieldOrganizationID)
  11230. }
  11231. return fields
  11232. }
  11233. // FieldCleared returns a boolean indicating if a field with the given name was
  11234. // cleared in this mutation.
  11235. func (m *ContactMutation) FieldCleared(name string) bool {
  11236. _, ok := m.clearedFields[name]
  11237. return ok
  11238. }
  11239. // ClearField clears the value of the field with the given name. It returns an
  11240. // error if the field is not defined in the schema.
  11241. func (m *ContactMutation) ClearField(name string) error {
  11242. switch name {
  11243. case contact.FieldStatus:
  11244. m.ClearStatus()
  11245. return nil
  11246. case contact.FieldDeletedAt:
  11247. m.ClearDeletedAt()
  11248. return nil
  11249. case contact.FieldType:
  11250. m.ClearType()
  11251. return nil
  11252. case contact.FieldOrganizationID:
  11253. m.ClearOrganizationID()
  11254. return nil
  11255. }
  11256. return fmt.Errorf("unknown Contact nullable field %s", name)
  11257. }
  11258. // ResetField resets all changes in the mutation for the field with the given name.
  11259. // It returns an error if the field is not defined in the schema.
  11260. func (m *ContactMutation) ResetField(name string) error {
  11261. switch name {
  11262. case contact.FieldCreatedAt:
  11263. m.ResetCreatedAt()
  11264. return nil
  11265. case contact.FieldUpdatedAt:
  11266. m.ResetUpdatedAt()
  11267. return nil
  11268. case contact.FieldStatus:
  11269. m.ResetStatus()
  11270. return nil
  11271. case contact.FieldDeletedAt:
  11272. m.ResetDeletedAt()
  11273. return nil
  11274. case contact.FieldWxWxid:
  11275. m.ResetWxWxid()
  11276. return nil
  11277. case contact.FieldType:
  11278. m.ResetType()
  11279. return nil
  11280. case contact.FieldWxid:
  11281. m.ResetWxid()
  11282. return nil
  11283. case contact.FieldAccount:
  11284. m.ResetAccount()
  11285. return nil
  11286. case contact.FieldNickname:
  11287. m.ResetNickname()
  11288. return nil
  11289. case contact.FieldMarkname:
  11290. m.ResetMarkname()
  11291. return nil
  11292. case contact.FieldHeadimg:
  11293. m.ResetHeadimg()
  11294. return nil
  11295. case contact.FieldSex:
  11296. m.ResetSex()
  11297. return nil
  11298. case contact.FieldStarrole:
  11299. m.ResetStarrole()
  11300. return nil
  11301. case contact.FieldDontseeit:
  11302. m.ResetDontseeit()
  11303. return nil
  11304. case contact.FieldDontseeme:
  11305. m.ResetDontseeme()
  11306. return nil
  11307. case contact.FieldLag:
  11308. m.ResetLag()
  11309. return nil
  11310. case contact.FieldGid:
  11311. m.ResetGid()
  11312. return nil
  11313. case contact.FieldGname:
  11314. m.ResetGname()
  11315. return nil
  11316. case contact.FieldV3:
  11317. m.ResetV3()
  11318. return nil
  11319. case contact.FieldOrganizationID:
  11320. m.ResetOrganizationID()
  11321. return nil
  11322. case contact.FieldCtype:
  11323. m.ResetCtype()
  11324. return nil
  11325. case contact.FieldCage:
  11326. m.ResetCage()
  11327. return nil
  11328. case contact.FieldCname:
  11329. m.ResetCname()
  11330. return nil
  11331. case contact.FieldCarea:
  11332. m.ResetCarea()
  11333. return nil
  11334. case contact.FieldCbirthday:
  11335. m.ResetCbirthday()
  11336. return nil
  11337. case contact.FieldCbirtharea:
  11338. m.ResetCbirtharea()
  11339. return nil
  11340. case contact.FieldCidcardNo:
  11341. m.ResetCidcardNo()
  11342. return nil
  11343. case contact.FieldCtitle:
  11344. m.ResetCtitle()
  11345. return nil
  11346. case contact.FieldCc:
  11347. m.ResetCc()
  11348. return nil
  11349. case contact.FieldPhone:
  11350. m.ResetPhone()
  11351. return nil
  11352. }
  11353. return fmt.Errorf("unknown Contact field %s", name)
  11354. }
  11355. // AddedEdges returns all edge names that were set/added in this mutation.
  11356. func (m *ContactMutation) AddedEdges() []string {
  11357. edges := make([]string, 0, 3)
  11358. if m.contact_relationships != nil {
  11359. edges = append(edges, contact.EdgeContactRelationships)
  11360. }
  11361. if m.contact_fields != nil {
  11362. edges = append(edges, contact.EdgeContactFields)
  11363. }
  11364. if m.contact_messages != nil {
  11365. edges = append(edges, contact.EdgeContactMessages)
  11366. }
  11367. return edges
  11368. }
  11369. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11370. // name in this mutation.
  11371. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  11372. switch name {
  11373. case contact.EdgeContactRelationships:
  11374. ids := make([]ent.Value, 0, len(m.contact_relationships))
  11375. for id := range m.contact_relationships {
  11376. ids = append(ids, id)
  11377. }
  11378. return ids
  11379. case contact.EdgeContactFields:
  11380. ids := make([]ent.Value, 0, len(m.contact_fields))
  11381. for id := range m.contact_fields {
  11382. ids = append(ids, id)
  11383. }
  11384. return ids
  11385. case contact.EdgeContactMessages:
  11386. ids := make([]ent.Value, 0, len(m.contact_messages))
  11387. for id := range m.contact_messages {
  11388. ids = append(ids, id)
  11389. }
  11390. return ids
  11391. }
  11392. return nil
  11393. }
  11394. // RemovedEdges returns all edge names that were removed in this mutation.
  11395. func (m *ContactMutation) RemovedEdges() []string {
  11396. edges := make([]string, 0, 3)
  11397. if m.removedcontact_relationships != nil {
  11398. edges = append(edges, contact.EdgeContactRelationships)
  11399. }
  11400. if m.removedcontact_fields != nil {
  11401. edges = append(edges, contact.EdgeContactFields)
  11402. }
  11403. if m.removedcontact_messages != nil {
  11404. edges = append(edges, contact.EdgeContactMessages)
  11405. }
  11406. return edges
  11407. }
  11408. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11409. // the given name in this mutation.
  11410. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  11411. switch name {
  11412. case contact.EdgeContactRelationships:
  11413. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  11414. for id := range m.removedcontact_relationships {
  11415. ids = append(ids, id)
  11416. }
  11417. return ids
  11418. case contact.EdgeContactFields:
  11419. ids := make([]ent.Value, 0, len(m.removedcontact_fields))
  11420. for id := range m.removedcontact_fields {
  11421. ids = append(ids, id)
  11422. }
  11423. return ids
  11424. case contact.EdgeContactMessages:
  11425. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  11426. for id := range m.removedcontact_messages {
  11427. ids = append(ids, id)
  11428. }
  11429. return ids
  11430. }
  11431. return nil
  11432. }
  11433. // ClearedEdges returns all edge names that were cleared in this mutation.
  11434. func (m *ContactMutation) ClearedEdges() []string {
  11435. edges := make([]string, 0, 3)
  11436. if m.clearedcontact_relationships {
  11437. edges = append(edges, contact.EdgeContactRelationships)
  11438. }
  11439. if m.clearedcontact_fields {
  11440. edges = append(edges, contact.EdgeContactFields)
  11441. }
  11442. if m.clearedcontact_messages {
  11443. edges = append(edges, contact.EdgeContactMessages)
  11444. }
  11445. return edges
  11446. }
  11447. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11448. // was cleared in this mutation.
  11449. func (m *ContactMutation) EdgeCleared(name string) bool {
  11450. switch name {
  11451. case contact.EdgeContactRelationships:
  11452. return m.clearedcontact_relationships
  11453. case contact.EdgeContactFields:
  11454. return m.clearedcontact_fields
  11455. case contact.EdgeContactMessages:
  11456. return m.clearedcontact_messages
  11457. }
  11458. return false
  11459. }
  11460. // ClearEdge clears the value of the edge with the given name. It returns an error
  11461. // if that edge is not defined in the schema.
  11462. func (m *ContactMutation) ClearEdge(name string) error {
  11463. switch name {
  11464. }
  11465. return fmt.Errorf("unknown Contact unique edge %s", name)
  11466. }
  11467. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11468. // It returns an error if the edge is not defined in the schema.
  11469. func (m *ContactMutation) ResetEdge(name string) error {
  11470. switch name {
  11471. case contact.EdgeContactRelationships:
  11472. m.ResetContactRelationships()
  11473. return nil
  11474. case contact.EdgeContactFields:
  11475. m.ResetContactFields()
  11476. return nil
  11477. case contact.EdgeContactMessages:
  11478. m.ResetContactMessages()
  11479. return nil
  11480. }
  11481. return fmt.Errorf("unknown Contact edge %s", name)
  11482. }
  11483. // ContactFieldMutation represents an operation that mutates the ContactField nodes in the graph.
  11484. type ContactFieldMutation struct {
  11485. config
  11486. op Op
  11487. typ string
  11488. id *uint64
  11489. created_at *time.Time
  11490. updated_at *time.Time
  11491. status *uint8
  11492. addstatus *int8
  11493. deleted_at *time.Time
  11494. form_id *string
  11495. value *[]string
  11496. appendvalue []string
  11497. clearedFields map[string]struct{}
  11498. field_contact *uint64
  11499. clearedfield_contact bool
  11500. done bool
  11501. oldValue func(context.Context) (*ContactField, error)
  11502. predicates []predicate.ContactField
  11503. }
  11504. var _ ent.Mutation = (*ContactFieldMutation)(nil)
  11505. // contactfieldOption allows management of the mutation configuration using functional options.
  11506. type contactfieldOption func(*ContactFieldMutation)
  11507. // newContactFieldMutation creates new mutation for the ContactField entity.
  11508. func newContactFieldMutation(c config, op Op, opts ...contactfieldOption) *ContactFieldMutation {
  11509. m := &ContactFieldMutation{
  11510. config: c,
  11511. op: op,
  11512. typ: TypeContactField,
  11513. clearedFields: make(map[string]struct{}),
  11514. }
  11515. for _, opt := range opts {
  11516. opt(m)
  11517. }
  11518. return m
  11519. }
  11520. // withContactFieldID sets the ID field of the mutation.
  11521. func withContactFieldID(id uint64) contactfieldOption {
  11522. return func(m *ContactFieldMutation) {
  11523. var (
  11524. err error
  11525. once sync.Once
  11526. value *ContactField
  11527. )
  11528. m.oldValue = func(ctx context.Context) (*ContactField, error) {
  11529. once.Do(func() {
  11530. if m.done {
  11531. err = errors.New("querying old values post mutation is not allowed")
  11532. } else {
  11533. value, err = m.Client().ContactField.Get(ctx, id)
  11534. }
  11535. })
  11536. return value, err
  11537. }
  11538. m.id = &id
  11539. }
  11540. }
  11541. // withContactField sets the old ContactField of the mutation.
  11542. func withContactField(node *ContactField) contactfieldOption {
  11543. return func(m *ContactFieldMutation) {
  11544. m.oldValue = func(context.Context) (*ContactField, error) {
  11545. return node, nil
  11546. }
  11547. m.id = &node.ID
  11548. }
  11549. }
  11550. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11551. // executed in a transaction (ent.Tx), a transactional client is returned.
  11552. func (m ContactFieldMutation) Client() *Client {
  11553. client := &Client{config: m.config}
  11554. client.init()
  11555. return client
  11556. }
  11557. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11558. // it returns an error otherwise.
  11559. func (m ContactFieldMutation) Tx() (*Tx, error) {
  11560. if _, ok := m.driver.(*txDriver); !ok {
  11561. return nil, errors.New("ent: mutation is not running in a transaction")
  11562. }
  11563. tx := &Tx{config: m.config}
  11564. tx.init()
  11565. return tx, nil
  11566. }
  11567. // SetID sets the value of the id field. Note that this
  11568. // operation is only accepted on creation of ContactField entities.
  11569. func (m *ContactFieldMutation) SetID(id uint64) {
  11570. m.id = &id
  11571. }
  11572. // ID returns the ID value in the mutation. Note that the ID is only available
  11573. // if it was provided to the builder or after it was returned from the database.
  11574. func (m *ContactFieldMutation) ID() (id uint64, exists bool) {
  11575. if m.id == nil {
  11576. return
  11577. }
  11578. return *m.id, true
  11579. }
  11580. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11581. // That means, if the mutation is applied within a transaction with an isolation level such
  11582. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11583. // or updated by the mutation.
  11584. func (m *ContactFieldMutation) IDs(ctx context.Context) ([]uint64, error) {
  11585. switch {
  11586. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11587. id, exists := m.ID()
  11588. if exists {
  11589. return []uint64{id}, nil
  11590. }
  11591. fallthrough
  11592. case m.op.Is(OpUpdate | OpDelete):
  11593. return m.Client().ContactField.Query().Where(m.predicates...).IDs(ctx)
  11594. default:
  11595. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11596. }
  11597. }
  11598. // SetCreatedAt sets the "created_at" field.
  11599. func (m *ContactFieldMutation) SetCreatedAt(t time.Time) {
  11600. m.created_at = &t
  11601. }
  11602. // CreatedAt returns the value of the "created_at" field in the mutation.
  11603. func (m *ContactFieldMutation) CreatedAt() (r time.Time, exists bool) {
  11604. v := m.created_at
  11605. if v == nil {
  11606. return
  11607. }
  11608. return *v, true
  11609. }
  11610. // OldCreatedAt returns the old "created_at" field's value of the ContactField entity.
  11611. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  11612. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11613. func (m *ContactFieldMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11614. if !m.op.Is(OpUpdateOne) {
  11615. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11616. }
  11617. if m.id == nil || m.oldValue == nil {
  11618. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11619. }
  11620. oldValue, err := m.oldValue(ctx)
  11621. if err != nil {
  11622. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11623. }
  11624. return oldValue.CreatedAt, nil
  11625. }
  11626. // ResetCreatedAt resets all changes to the "created_at" field.
  11627. func (m *ContactFieldMutation) ResetCreatedAt() {
  11628. m.created_at = nil
  11629. }
  11630. // SetUpdatedAt sets the "updated_at" field.
  11631. func (m *ContactFieldMutation) SetUpdatedAt(t time.Time) {
  11632. m.updated_at = &t
  11633. }
  11634. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11635. func (m *ContactFieldMutation) UpdatedAt() (r time.Time, exists bool) {
  11636. v := m.updated_at
  11637. if v == nil {
  11638. return
  11639. }
  11640. return *v, true
  11641. }
  11642. // OldUpdatedAt returns the old "updated_at" field's value of the ContactField entity.
  11643. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  11644. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11645. func (m *ContactFieldMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11646. if !m.op.Is(OpUpdateOne) {
  11647. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11648. }
  11649. if m.id == nil || m.oldValue == nil {
  11650. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11651. }
  11652. oldValue, err := m.oldValue(ctx)
  11653. if err != nil {
  11654. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11655. }
  11656. return oldValue.UpdatedAt, nil
  11657. }
  11658. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11659. func (m *ContactFieldMutation) ResetUpdatedAt() {
  11660. m.updated_at = nil
  11661. }
  11662. // SetStatus sets the "status" field.
  11663. func (m *ContactFieldMutation) SetStatus(u uint8) {
  11664. m.status = &u
  11665. m.addstatus = nil
  11666. }
  11667. // Status returns the value of the "status" field in the mutation.
  11668. func (m *ContactFieldMutation) Status() (r uint8, exists bool) {
  11669. v := m.status
  11670. if v == nil {
  11671. return
  11672. }
  11673. return *v, true
  11674. }
  11675. // OldStatus returns the old "status" field's value of the ContactField entity.
  11676. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  11677. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11678. func (m *ContactFieldMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  11679. if !m.op.Is(OpUpdateOne) {
  11680. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11681. }
  11682. if m.id == nil || m.oldValue == nil {
  11683. return v, errors.New("OldStatus requires an ID field in the mutation")
  11684. }
  11685. oldValue, err := m.oldValue(ctx)
  11686. if err != nil {
  11687. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11688. }
  11689. return oldValue.Status, nil
  11690. }
  11691. // AddStatus adds u to the "status" field.
  11692. func (m *ContactFieldMutation) AddStatus(u int8) {
  11693. if m.addstatus != nil {
  11694. *m.addstatus += u
  11695. } else {
  11696. m.addstatus = &u
  11697. }
  11698. }
  11699. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11700. func (m *ContactFieldMutation) AddedStatus() (r int8, exists bool) {
  11701. v := m.addstatus
  11702. if v == nil {
  11703. return
  11704. }
  11705. return *v, true
  11706. }
  11707. // ClearStatus clears the value of the "status" field.
  11708. func (m *ContactFieldMutation) ClearStatus() {
  11709. m.status = nil
  11710. m.addstatus = nil
  11711. m.clearedFields[contactfield.FieldStatus] = struct{}{}
  11712. }
  11713. // StatusCleared returns if the "status" field was cleared in this mutation.
  11714. func (m *ContactFieldMutation) StatusCleared() bool {
  11715. _, ok := m.clearedFields[contactfield.FieldStatus]
  11716. return ok
  11717. }
  11718. // ResetStatus resets all changes to the "status" field.
  11719. func (m *ContactFieldMutation) ResetStatus() {
  11720. m.status = nil
  11721. m.addstatus = nil
  11722. delete(m.clearedFields, contactfield.FieldStatus)
  11723. }
  11724. // SetDeletedAt sets the "deleted_at" field.
  11725. func (m *ContactFieldMutation) SetDeletedAt(t time.Time) {
  11726. m.deleted_at = &t
  11727. }
  11728. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11729. func (m *ContactFieldMutation) DeletedAt() (r time.Time, exists bool) {
  11730. v := m.deleted_at
  11731. if v == nil {
  11732. return
  11733. }
  11734. return *v, true
  11735. }
  11736. // OldDeletedAt returns the old "deleted_at" field's value of the ContactField entity.
  11737. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  11738. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11739. func (m *ContactFieldMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11740. if !m.op.Is(OpUpdateOne) {
  11741. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11742. }
  11743. if m.id == nil || m.oldValue == nil {
  11744. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11745. }
  11746. oldValue, err := m.oldValue(ctx)
  11747. if err != nil {
  11748. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11749. }
  11750. return oldValue.DeletedAt, nil
  11751. }
  11752. // ClearDeletedAt clears the value of the "deleted_at" field.
  11753. func (m *ContactFieldMutation) ClearDeletedAt() {
  11754. m.deleted_at = nil
  11755. m.clearedFields[contactfield.FieldDeletedAt] = struct{}{}
  11756. }
  11757. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11758. func (m *ContactFieldMutation) DeletedAtCleared() bool {
  11759. _, ok := m.clearedFields[contactfield.FieldDeletedAt]
  11760. return ok
  11761. }
  11762. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11763. func (m *ContactFieldMutation) ResetDeletedAt() {
  11764. m.deleted_at = nil
  11765. delete(m.clearedFields, contactfield.FieldDeletedAt)
  11766. }
  11767. // SetContactID sets the "contact_id" field.
  11768. func (m *ContactFieldMutation) SetContactID(u uint64) {
  11769. m.field_contact = &u
  11770. }
  11771. // ContactID returns the value of the "contact_id" field in the mutation.
  11772. func (m *ContactFieldMutation) ContactID() (r uint64, exists bool) {
  11773. v := m.field_contact
  11774. if v == nil {
  11775. return
  11776. }
  11777. return *v, true
  11778. }
  11779. // OldContactID returns the old "contact_id" field's value of the ContactField entity.
  11780. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  11781. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11782. func (m *ContactFieldMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  11783. if !m.op.Is(OpUpdateOne) {
  11784. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  11785. }
  11786. if m.id == nil || m.oldValue == nil {
  11787. return v, errors.New("OldContactID requires an ID field in the mutation")
  11788. }
  11789. oldValue, err := m.oldValue(ctx)
  11790. if err != nil {
  11791. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  11792. }
  11793. return oldValue.ContactID, nil
  11794. }
  11795. // ResetContactID resets all changes to the "contact_id" field.
  11796. func (m *ContactFieldMutation) ResetContactID() {
  11797. m.field_contact = nil
  11798. }
  11799. // SetFormID sets the "form_id" field.
  11800. func (m *ContactFieldMutation) SetFormID(s string) {
  11801. m.form_id = &s
  11802. }
  11803. // FormID returns the value of the "form_id" field in the mutation.
  11804. func (m *ContactFieldMutation) FormID() (r string, exists bool) {
  11805. v := m.form_id
  11806. if v == nil {
  11807. return
  11808. }
  11809. return *v, true
  11810. }
  11811. // OldFormID returns the old "form_id" field's value of the ContactField entity.
  11812. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  11813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11814. func (m *ContactFieldMutation) OldFormID(ctx context.Context) (v string, err error) {
  11815. if !m.op.Is(OpUpdateOne) {
  11816. return v, errors.New("OldFormID is only allowed on UpdateOne operations")
  11817. }
  11818. if m.id == nil || m.oldValue == nil {
  11819. return v, errors.New("OldFormID requires an ID field in the mutation")
  11820. }
  11821. oldValue, err := m.oldValue(ctx)
  11822. if err != nil {
  11823. return v, fmt.Errorf("querying old value for OldFormID: %w", err)
  11824. }
  11825. return oldValue.FormID, nil
  11826. }
  11827. // ResetFormID resets all changes to the "form_id" field.
  11828. func (m *ContactFieldMutation) ResetFormID() {
  11829. m.form_id = nil
  11830. }
  11831. // SetValue sets the "value" field.
  11832. func (m *ContactFieldMutation) SetValue(s []string) {
  11833. m.value = &s
  11834. m.appendvalue = nil
  11835. }
  11836. // Value returns the value of the "value" field in the mutation.
  11837. func (m *ContactFieldMutation) Value() (r []string, exists bool) {
  11838. v := m.value
  11839. if v == nil {
  11840. return
  11841. }
  11842. return *v, true
  11843. }
  11844. // OldValue returns the old "value" field's value of the ContactField entity.
  11845. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  11846. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11847. func (m *ContactFieldMutation) OldValue(ctx context.Context) (v []string, err error) {
  11848. if !m.op.Is(OpUpdateOne) {
  11849. return v, errors.New("OldValue is only allowed on UpdateOne operations")
  11850. }
  11851. if m.id == nil || m.oldValue == nil {
  11852. return v, errors.New("OldValue requires an ID field in the mutation")
  11853. }
  11854. oldValue, err := m.oldValue(ctx)
  11855. if err != nil {
  11856. return v, fmt.Errorf("querying old value for OldValue: %w", err)
  11857. }
  11858. return oldValue.Value, nil
  11859. }
  11860. // AppendValue adds s to the "value" field.
  11861. func (m *ContactFieldMutation) AppendValue(s []string) {
  11862. m.appendvalue = append(m.appendvalue, s...)
  11863. }
  11864. // AppendedValue returns the list of values that were appended to the "value" field in this mutation.
  11865. func (m *ContactFieldMutation) AppendedValue() ([]string, bool) {
  11866. if len(m.appendvalue) == 0 {
  11867. return nil, false
  11868. }
  11869. return m.appendvalue, true
  11870. }
  11871. // ResetValue resets all changes to the "value" field.
  11872. func (m *ContactFieldMutation) ResetValue() {
  11873. m.value = nil
  11874. m.appendvalue = nil
  11875. }
  11876. // SetFieldContactID sets the "field_contact" edge to the Contact entity by id.
  11877. func (m *ContactFieldMutation) SetFieldContactID(id uint64) {
  11878. m.field_contact = &id
  11879. }
  11880. // ClearFieldContact clears the "field_contact" edge to the Contact entity.
  11881. func (m *ContactFieldMutation) ClearFieldContact() {
  11882. m.clearedfield_contact = true
  11883. m.clearedFields[contactfield.FieldContactID] = struct{}{}
  11884. }
  11885. // FieldContactCleared reports if the "field_contact" edge to the Contact entity was cleared.
  11886. func (m *ContactFieldMutation) FieldContactCleared() bool {
  11887. return m.clearedfield_contact
  11888. }
  11889. // FieldContactID returns the "field_contact" edge ID in the mutation.
  11890. func (m *ContactFieldMutation) FieldContactID() (id uint64, exists bool) {
  11891. if m.field_contact != nil {
  11892. return *m.field_contact, true
  11893. }
  11894. return
  11895. }
  11896. // FieldContactIDs returns the "field_contact" edge IDs in the mutation.
  11897. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  11898. // FieldContactID instead. It exists only for internal usage by the builders.
  11899. func (m *ContactFieldMutation) FieldContactIDs() (ids []uint64) {
  11900. if id := m.field_contact; id != nil {
  11901. ids = append(ids, *id)
  11902. }
  11903. return
  11904. }
  11905. // ResetFieldContact resets all changes to the "field_contact" edge.
  11906. func (m *ContactFieldMutation) ResetFieldContact() {
  11907. m.field_contact = nil
  11908. m.clearedfield_contact = false
  11909. }
  11910. // Where appends a list predicates to the ContactFieldMutation builder.
  11911. func (m *ContactFieldMutation) Where(ps ...predicate.ContactField) {
  11912. m.predicates = append(m.predicates, ps...)
  11913. }
  11914. // WhereP appends storage-level predicates to the ContactFieldMutation builder. Using this method,
  11915. // users can use type-assertion to append predicates that do not depend on any generated package.
  11916. func (m *ContactFieldMutation) WhereP(ps ...func(*sql.Selector)) {
  11917. p := make([]predicate.ContactField, len(ps))
  11918. for i := range ps {
  11919. p[i] = ps[i]
  11920. }
  11921. m.Where(p...)
  11922. }
  11923. // Op returns the operation name.
  11924. func (m *ContactFieldMutation) Op() Op {
  11925. return m.op
  11926. }
  11927. // SetOp allows setting the mutation operation.
  11928. func (m *ContactFieldMutation) SetOp(op Op) {
  11929. m.op = op
  11930. }
  11931. // Type returns the node type of this mutation (ContactField).
  11932. func (m *ContactFieldMutation) Type() string {
  11933. return m.typ
  11934. }
  11935. // Fields returns all fields that were changed during this mutation. Note that in
  11936. // order to get all numeric fields that were incremented/decremented, call
  11937. // AddedFields().
  11938. func (m *ContactFieldMutation) Fields() []string {
  11939. fields := make([]string, 0, 7)
  11940. if m.created_at != nil {
  11941. fields = append(fields, contactfield.FieldCreatedAt)
  11942. }
  11943. if m.updated_at != nil {
  11944. fields = append(fields, contactfield.FieldUpdatedAt)
  11945. }
  11946. if m.status != nil {
  11947. fields = append(fields, contactfield.FieldStatus)
  11948. }
  11949. if m.deleted_at != nil {
  11950. fields = append(fields, contactfield.FieldDeletedAt)
  11951. }
  11952. if m.field_contact != nil {
  11953. fields = append(fields, contactfield.FieldContactID)
  11954. }
  11955. if m.form_id != nil {
  11956. fields = append(fields, contactfield.FieldFormID)
  11957. }
  11958. if m.value != nil {
  11959. fields = append(fields, contactfield.FieldValue)
  11960. }
  11961. return fields
  11962. }
  11963. // Field returns the value of a field with the given name. The second boolean
  11964. // return value indicates that this field was not set, or was not defined in the
  11965. // schema.
  11966. func (m *ContactFieldMutation) Field(name string) (ent.Value, bool) {
  11967. switch name {
  11968. case contactfield.FieldCreatedAt:
  11969. return m.CreatedAt()
  11970. case contactfield.FieldUpdatedAt:
  11971. return m.UpdatedAt()
  11972. case contactfield.FieldStatus:
  11973. return m.Status()
  11974. case contactfield.FieldDeletedAt:
  11975. return m.DeletedAt()
  11976. case contactfield.FieldContactID:
  11977. return m.ContactID()
  11978. case contactfield.FieldFormID:
  11979. return m.FormID()
  11980. case contactfield.FieldValue:
  11981. return m.Value()
  11982. }
  11983. return nil, false
  11984. }
  11985. // OldField returns the old value of the field from the database. An error is
  11986. // returned if the mutation operation is not UpdateOne, or the query to the
  11987. // database failed.
  11988. func (m *ContactFieldMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11989. switch name {
  11990. case contactfield.FieldCreatedAt:
  11991. return m.OldCreatedAt(ctx)
  11992. case contactfield.FieldUpdatedAt:
  11993. return m.OldUpdatedAt(ctx)
  11994. case contactfield.FieldStatus:
  11995. return m.OldStatus(ctx)
  11996. case contactfield.FieldDeletedAt:
  11997. return m.OldDeletedAt(ctx)
  11998. case contactfield.FieldContactID:
  11999. return m.OldContactID(ctx)
  12000. case contactfield.FieldFormID:
  12001. return m.OldFormID(ctx)
  12002. case contactfield.FieldValue:
  12003. return m.OldValue(ctx)
  12004. }
  12005. return nil, fmt.Errorf("unknown ContactField field %s", name)
  12006. }
  12007. // SetField sets the value of a field with the given name. It returns an error if
  12008. // the field is not defined in the schema, or if the type mismatched the field
  12009. // type.
  12010. func (m *ContactFieldMutation) SetField(name string, value ent.Value) error {
  12011. switch name {
  12012. case contactfield.FieldCreatedAt:
  12013. v, ok := value.(time.Time)
  12014. if !ok {
  12015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12016. }
  12017. m.SetCreatedAt(v)
  12018. return nil
  12019. case contactfield.FieldUpdatedAt:
  12020. v, ok := value.(time.Time)
  12021. if !ok {
  12022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12023. }
  12024. m.SetUpdatedAt(v)
  12025. return nil
  12026. case contactfield.FieldStatus:
  12027. v, ok := value.(uint8)
  12028. if !ok {
  12029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12030. }
  12031. m.SetStatus(v)
  12032. return nil
  12033. case contactfield.FieldDeletedAt:
  12034. v, ok := value.(time.Time)
  12035. if !ok {
  12036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12037. }
  12038. m.SetDeletedAt(v)
  12039. return nil
  12040. case contactfield.FieldContactID:
  12041. v, ok := value.(uint64)
  12042. if !ok {
  12043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12044. }
  12045. m.SetContactID(v)
  12046. return nil
  12047. case contactfield.FieldFormID:
  12048. v, ok := value.(string)
  12049. if !ok {
  12050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12051. }
  12052. m.SetFormID(v)
  12053. return nil
  12054. case contactfield.FieldValue:
  12055. v, ok := value.([]string)
  12056. if !ok {
  12057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12058. }
  12059. m.SetValue(v)
  12060. return nil
  12061. }
  12062. return fmt.Errorf("unknown ContactField field %s", name)
  12063. }
  12064. // AddedFields returns all numeric fields that were incremented/decremented during
  12065. // this mutation.
  12066. func (m *ContactFieldMutation) AddedFields() []string {
  12067. var fields []string
  12068. if m.addstatus != nil {
  12069. fields = append(fields, contactfield.FieldStatus)
  12070. }
  12071. return fields
  12072. }
  12073. // AddedField returns the numeric value that was incremented/decremented on a field
  12074. // with the given name. The second boolean return value indicates that this field
  12075. // was not set, or was not defined in the schema.
  12076. func (m *ContactFieldMutation) AddedField(name string) (ent.Value, bool) {
  12077. switch name {
  12078. case contactfield.FieldStatus:
  12079. return m.AddedStatus()
  12080. }
  12081. return nil, false
  12082. }
  12083. // AddField adds the value to the field with the given name. It returns an error if
  12084. // the field is not defined in the schema, or if the type mismatched the field
  12085. // type.
  12086. func (m *ContactFieldMutation) AddField(name string, value ent.Value) error {
  12087. switch name {
  12088. case contactfield.FieldStatus:
  12089. v, ok := value.(int8)
  12090. if !ok {
  12091. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12092. }
  12093. m.AddStatus(v)
  12094. return nil
  12095. }
  12096. return fmt.Errorf("unknown ContactField numeric field %s", name)
  12097. }
  12098. // ClearedFields returns all nullable fields that were cleared during this
  12099. // mutation.
  12100. func (m *ContactFieldMutation) ClearedFields() []string {
  12101. var fields []string
  12102. if m.FieldCleared(contactfield.FieldStatus) {
  12103. fields = append(fields, contactfield.FieldStatus)
  12104. }
  12105. if m.FieldCleared(contactfield.FieldDeletedAt) {
  12106. fields = append(fields, contactfield.FieldDeletedAt)
  12107. }
  12108. return fields
  12109. }
  12110. // FieldCleared returns a boolean indicating if a field with the given name was
  12111. // cleared in this mutation.
  12112. func (m *ContactFieldMutation) FieldCleared(name string) bool {
  12113. _, ok := m.clearedFields[name]
  12114. return ok
  12115. }
  12116. // ClearField clears the value of the field with the given name. It returns an
  12117. // error if the field is not defined in the schema.
  12118. func (m *ContactFieldMutation) ClearField(name string) error {
  12119. switch name {
  12120. case contactfield.FieldStatus:
  12121. m.ClearStatus()
  12122. return nil
  12123. case contactfield.FieldDeletedAt:
  12124. m.ClearDeletedAt()
  12125. return nil
  12126. }
  12127. return fmt.Errorf("unknown ContactField nullable field %s", name)
  12128. }
  12129. // ResetField resets all changes in the mutation for the field with the given name.
  12130. // It returns an error if the field is not defined in the schema.
  12131. func (m *ContactFieldMutation) ResetField(name string) error {
  12132. switch name {
  12133. case contactfield.FieldCreatedAt:
  12134. m.ResetCreatedAt()
  12135. return nil
  12136. case contactfield.FieldUpdatedAt:
  12137. m.ResetUpdatedAt()
  12138. return nil
  12139. case contactfield.FieldStatus:
  12140. m.ResetStatus()
  12141. return nil
  12142. case contactfield.FieldDeletedAt:
  12143. m.ResetDeletedAt()
  12144. return nil
  12145. case contactfield.FieldContactID:
  12146. m.ResetContactID()
  12147. return nil
  12148. case contactfield.FieldFormID:
  12149. m.ResetFormID()
  12150. return nil
  12151. case contactfield.FieldValue:
  12152. m.ResetValue()
  12153. return nil
  12154. }
  12155. return fmt.Errorf("unknown ContactField field %s", name)
  12156. }
  12157. // AddedEdges returns all edge names that were set/added in this mutation.
  12158. func (m *ContactFieldMutation) AddedEdges() []string {
  12159. edges := make([]string, 0, 1)
  12160. if m.field_contact != nil {
  12161. edges = append(edges, contactfield.EdgeFieldContact)
  12162. }
  12163. return edges
  12164. }
  12165. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12166. // name in this mutation.
  12167. func (m *ContactFieldMutation) AddedIDs(name string) []ent.Value {
  12168. switch name {
  12169. case contactfield.EdgeFieldContact:
  12170. if id := m.field_contact; id != nil {
  12171. return []ent.Value{*id}
  12172. }
  12173. }
  12174. return nil
  12175. }
  12176. // RemovedEdges returns all edge names that were removed in this mutation.
  12177. func (m *ContactFieldMutation) RemovedEdges() []string {
  12178. edges := make([]string, 0, 1)
  12179. return edges
  12180. }
  12181. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12182. // the given name in this mutation.
  12183. func (m *ContactFieldMutation) RemovedIDs(name string) []ent.Value {
  12184. return nil
  12185. }
  12186. // ClearedEdges returns all edge names that were cleared in this mutation.
  12187. func (m *ContactFieldMutation) ClearedEdges() []string {
  12188. edges := make([]string, 0, 1)
  12189. if m.clearedfield_contact {
  12190. edges = append(edges, contactfield.EdgeFieldContact)
  12191. }
  12192. return edges
  12193. }
  12194. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12195. // was cleared in this mutation.
  12196. func (m *ContactFieldMutation) EdgeCleared(name string) bool {
  12197. switch name {
  12198. case contactfield.EdgeFieldContact:
  12199. return m.clearedfield_contact
  12200. }
  12201. return false
  12202. }
  12203. // ClearEdge clears the value of the edge with the given name. It returns an error
  12204. // if that edge is not defined in the schema.
  12205. func (m *ContactFieldMutation) ClearEdge(name string) error {
  12206. switch name {
  12207. case contactfield.EdgeFieldContact:
  12208. m.ClearFieldContact()
  12209. return nil
  12210. }
  12211. return fmt.Errorf("unknown ContactField unique edge %s", name)
  12212. }
  12213. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12214. // It returns an error if the edge is not defined in the schema.
  12215. func (m *ContactFieldMutation) ResetEdge(name string) error {
  12216. switch name {
  12217. case contactfield.EdgeFieldContact:
  12218. m.ResetFieldContact()
  12219. return nil
  12220. }
  12221. return fmt.Errorf("unknown ContactField edge %s", name)
  12222. }
  12223. // ContactFieldTemplateMutation represents an operation that mutates the ContactFieldTemplate nodes in the graph.
  12224. type ContactFieldTemplateMutation struct {
  12225. config
  12226. op Op
  12227. typ string
  12228. id *uint64
  12229. created_at *time.Time
  12230. updated_at *time.Time
  12231. status *uint8
  12232. addstatus *int8
  12233. deleted_at *time.Time
  12234. organization_id *uint64
  12235. addorganization_id *int64
  12236. template *[]custom_types.ContactFieldTemplate
  12237. appendtemplate []custom_types.ContactFieldTemplate
  12238. clearedFields map[string]struct{}
  12239. done bool
  12240. oldValue func(context.Context) (*ContactFieldTemplate, error)
  12241. predicates []predicate.ContactFieldTemplate
  12242. }
  12243. var _ ent.Mutation = (*ContactFieldTemplateMutation)(nil)
  12244. // contactfieldtemplateOption allows management of the mutation configuration using functional options.
  12245. type contactfieldtemplateOption func(*ContactFieldTemplateMutation)
  12246. // newContactFieldTemplateMutation creates new mutation for the ContactFieldTemplate entity.
  12247. func newContactFieldTemplateMutation(c config, op Op, opts ...contactfieldtemplateOption) *ContactFieldTemplateMutation {
  12248. m := &ContactFieldTemplateMutation{
  12249. config: c,
  12250. op: op,
  12251. typ: TypeContactFieldTemplate,
  12252. clearedFields: make(map[string]struct{}),
  12253. }
  12254. for _, opt := range opts {
  12255. opt(m)
  12256. }
  12257. return m
  12258. }
  12259. // withContactFieldTemplateID sets the ID field of the mutation.
  12260. func withContactFieldTemplateID(id uint64) contactfieldtemplateOption {
  12261. return func(m *ContactFieldTemplateMutation) {
  12262. var (
  12263. err error
  12264. once sync.Once
  12265. value *ContactFieldTemplate
  12266. )
  12267. m.oldValue = func(ctx context.Context) (*ContactFieldTemplate, error) {
  12268. once.Do(func() {
  12269. if m.done {
  12270. err = errors.New("querying old values post mutation is not allowed")
  12271. } else {
  12272. value, err = m.Client().ContactFieldTemplate.Get(ctx, id)
  12273. }
  12274. })
  12275. return value, err
  12276. }
  12277. m.id = &id
  12278. }
  12279. }
  12280. // withContactFieldTemplate sets the old ContactFieldTemplate of the mutation.
  12281. func withContactFieldTemplate(node *ContactFieldTemplate) contactfieldtemplateOption {
  12282. return func(m *ContactFieldTemplateMutation) {
  12283. m.oldValue = func(context.Context) (*ContactFieldTemplate, error) {
  12284. return node, nil
  12285. }
  12286. m.id = &node.ID
  12287. }
  12288. }
  12289. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12290. // executed in a transaction (ent.Tx), a transactional client is returned.
  12291. func (m ContactFieldTemplateMutation) Client() *Client {
  12292. client := &Client{config: m.config}
  12293. client.init()
  12294. return client
  12295. }
  12296. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12297. // it returns an error otherwise.
  12298. func (m ContactFieldTemplateMutation) Tx() (*Tx, error) {
  12299. if _, ok := m.driver.(*txDriver); !ok {
  12300. return nil, errors.New("ent: mutation is not running in a transaction")
  12301. }
  12302. tx := &Tx{config: m.config}
  12303. tx.init()
  12304. return tx, nil
  12305. }
  12306. // SetID sets the value of the id field. Note that this
  12307. // operation is only accepted on creation of ContactFieldTemplate entities.
  12308. func (m *ContactFieldTemplateMutation) SetID(id uint64) {
  12309. m.id = &id
  12310. }
  12311. // ID returns the ID value in the mutation. Note that the ID is only available
  12312. // if it was provided to the builder or after it was returned from the database.
  12313. func (m *ContactFieldTemplateMutation) ID() (id uint64, exists bool) {
  12314. if m.id == nil {
  12315. return
  12316. }
  12317. return *m.id, true
  12318. }
  12319. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12320. // That means, if the mutation is applied within a transaction with an isolation level such
  12321. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12322. // or updated by the mutation.
  12323. func (m *ContactFieldTemplateMutation) IDs(ctx context.Context) ([]uint64, error) {
  12324. switch {
  12325. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12326. id, exists := m.ID()
  12327. if exists {
  12328. return []uint64{id}, nil
  12329. }
  12330. fallthrough
  12331. case m.op.Is(OpUpdate | OpDelete):
  12332. return m.Client().ContactFieldTemplate.Query().Where(m.predicates...).IDs(ctx)
  12333. default:
  12334. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12335. }
  12336. }
  12337. // SetCreatedAt sets the "created_at" field.
  12338. func (m *ContactFieldTemplateMutation) SetCreatedAt(t time.Time) {
  12339. m.created_at = &t
  12340. }
  12341. // CreatedAt returns the value of the "created_at" field in the mutation.
  12342. func (m *ContactFieldTemplateMutation) CreatedAt() (r time.Time, exists bool) {
  12343. v := m.created_at
  12344. if v == nil {
  12345. return
  12346. }
  12347. return *v, true
  12348. }
  12349. // OldCreatedAt returns the old "created_at" field's value of the ContactFieldTemplate entity.
  12350. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  12351. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12352. func (m *ContactFieldTemplateMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12353. if !m.op.Is(OpUpdateOne) {
  12354. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12355. }
  12356. if m.id == nil || m.oldValue == nil {
  12357. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12358. }
  12359. oldValue, err := m.oldValue(ctx)
  12360. if err != nil {
  12361. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12362. }
  12363. return oldValue.CreatedAt, nil
  12364. }
  12365. // ResetCreatedAt resets all changes to the "created_at" field.
  12366. func (m *ContactFieldTemplateMutation) ResetCreatedAt() {
  12367. m.created_at = nil
  12368. }
  12369. // SetUpdatedAt sets the "updated_at" field.
  12370. func (m *ContactFieldTemplateMutation) SetUpdatedAt(t time.Time) {
  12371. m.updated_at = &t
  12372. }
  12373. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12374. func (m *ContactFieldTemplateMutation) UpdatedAt() (r time.Time, exists bool) {
  12375. v := m.updated_at
  12376. if v == nil {
  12377. return
  12378. }
  12379. return *v, true
  12380. }
  12381. // OldUpdatedAt returns the old "updated_at" field's value of the ContactFieldTemplate entity.
  12382. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  12383. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12384. func (m *ContactFieldTemplateMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12385. if !m.op.Is(OpUpdateOne) {
  12386. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12387. }
  12388. if m.id == nil || m.oldValue == nil {
  12389. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12390. }
  12391. oldValue, err := m.oldValue(ctx)
  12392. if err != nil {
  12393. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12394. }
  12395. return oldValue.UpdatedAt, nil
  12396. }
  12397. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12398. func (m *ContactFieldTemplateMutation) ResetUpdatedAt() {
  12399. m.updated_at = nil
  12400. }
  12401. // SetStatus sets the "status" field.
  12402. func (m *ContactFieldTemplateMutation) SetStatus(u uint8) {
  12403. m.status = &u
  12404. m.addstatus = nil
  12405. }
  12406. // Status returns the value of the "status" field in the mutation.
  12407. func (m *ContactFieldTemplateMutation) Status() (r uint8, exists bool) {
  12408. v := m.status
  12409. if v == nil {
  12410. return
  12411. }
  12412. return *v, true
  12413. }
  12414. // OldStatus returns the old "status" field's value of the ContactFieldTemplate entity.
  12415. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  12416. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12417. func (m *ContactFieldTemplateMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12418. if !m.op.Is(OpUpdateOne) {
  12419. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12420. }
  12421. if m.id == nil || m.oldValue == nil {
  12422. return v, errors.New("OldStatus requires an ID field in the mutation")
  12423. }
  12424. oldValue, err := m.oldValue(ctx)
  12425. if err != nil {
  12426. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12427. }
  12428. return oldValue.Status, nil
  12429. }
  12430. // AddStatus adds u to the "status" field.
  12431. func (m *ContactFieldTemplateMutation) AddStatus(u int8) {
  12432. if m.addstatus != nil {
  12433. *m.addstatus += u
  12434. } else {
  12435. m.addstatus = &u
  12436. }
  12437. }
  12438. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12439. func (m *ContactFieldTemplateMutation) AddedStatus() (r int8, exists bool) {
  12440. v := m.addstatus
  12441. if v == nil {
  12442. return
  12443. }
  12444. return *v, true
  12445. }
  12446. // ClearStatus clears the value of the "status" field.
  12447. func (m *ContactFieldTemplateMutation) ClearStatus() {
  12448. m.status = nil
  12449. m.addstatus = nil
  12450. m.clearedFields[contactfieldtemplate.FieldStatus] = struct{}{}
  12451. }
  12452. // StatusCleared returns if the "status" field was cleared in this mutation.
  12453. func (m *ContactFieldTemplateMutation) StatusCleared() bool {
  12454. _, ok := m.clearedFields[contactfieldtemplate.FieldStatus]
  12455. return ok
  12456. }
  12457. // ResetStatus resets all changes to the "status" field.
  12458. func (m *ContactFieldTemplateMutation) ResetStatus() {
  12459. m.status = nil
  12460. m.addstatus = nil
  12461. delete(m.clearedFields, contactfieldtemplate.FieldStatus)
  12462. }
  12463. // SetDeletedAt sets the "deleted_at" field.
  12464. func (m *ContactFieldTemplateMutation) SetDeletedAt(t time.Time) {
  12465. m.deleted_at = &t
  12466. }
  12467. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12468. func (m *ContactFieldTemplateMutation) DeletedAt() (r time.Time, exists bool) {
  12469. v := m.deleted_at
  12470. if v == nil {
  12471. return
  12472. }
  12473. return *v, true
  12474. }
  12475. // OldDeletedAt returns the old "deleted_at" field's value of the ContactFieldTemplate entity.
  12476. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  12477. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12478. func (m *ContactFieldTemplateMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12479. if !m.op.Is(OpUpdateOne) {
  12480. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12481. }
  12482. if m.id == nil || m.oldValue == nil {
  12483. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12484. }
  12485. oldValue, err := m.oldValue(ctx)
  12486. if err != nil {
  12487. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12488. }
  12489. return oldValue.DeletedAt, nil
  12490. }
  12491. // ClearDeletedAt clears the value of the "deleted_at" field.
  12492. func (m *ContactFieldTemplateMutation) ClearDeletedAt() {
  12493. m.deleted_at = nil
  12494. m.clearedFields[contactfieldtemplate.FieldDeletedAt] = struct{}{}
  12495. }
  12496. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12497. func (m *ContactFieldTemplateMutation) DeletedAtCleared() bool {
  12498. _, ok := m.clearedFields[contactfieldtemplate.FieldDeletedAt]
  12499. return ok
  12500. }
  12501. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12502. func (m *ContactFieldTemplateMutation) ResetDeletedAt() {
  12503. m.deleted_at = nil
  12504. delete(m.clearedFields, contactfieldtemplate.FieldDeletedAt)
  12505. }
  12506. // SetOrganizationID sets the "organization_id" field.
  12507. func (m *ContactFieldTemplateMutation) SetOrganizationID(u uint64) {
  12508. m.organization_id = &u
  12509. m.addorganization_id = nil
  12510. }
  12511. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12512. func (m *ContactFieldTemplateMutation) OrganizationID() (r uint64, exists bool) {
  12513. v := m.organization_id
  12514. if v == nil {
  12515. return
  12516. }
  12517. return *v, true
  12518. }
  12519. // OldOrganizationID returns the old "organization_id" field's value of the ContactFieldTemplate entity.
  12520. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  12521. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12522. func (m *ContactFieldTemplateMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12523. if !m.op.Is(OpUpdateOne) {
  12524. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12525. }
  12526. if m.id == nil || m.oldValue == nil {
  12527. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12528. }
  12529. oldValue, err := m.oldValue(ctx)
  12530. if err != nil {
  12531. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12532. }
  12533. return oldValue.OrganizationID, nil
  12534. }
  12535. // AddOrganizationID adds u to the "organization_id" field.
  12536. func (m *ContactFieldTemplateMutation) AddOrganizationID(u int64) {
  12537. if m.addorganization_id != nil {
  12538. *m.addorganization_id += u
  12539. } else {
  12540. m.addorganization_id = &u
  12541. }
  12542. }
  12543. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12544. func (m *ContactFieldTemplateMutation) AddedOrganizationID() (r int64, exists bool) {
  12545. v := m.addorganization_id
  12546. if v == nil {
  12547. return
  12548. }
  12549. return *v, true
  12550. }
  12551. // ResetOrganizationID resets all changes to the "organization_id" field.
  12552. func (m *ContactFieldTemplateMutation) ResetOrganizationID() {
  12553. m.organization_id = nil
  12554. m.addorganization_id = nil
  12555. }
  12556. // SetTemplate sets the "template" field.
  12557. func (m *ContactFieldTemplateMutation) SetTemplate(ctft []custom_types.ContactFieldTemplate) {
  12558. m.template = &ctft
  12559. m.appendtemplate = nil
  12560. }
  12561. // Template returns the value of the "template" field in the mutation.
  12562. func (m *ContactFieldTemplateMutation) Template() (r []custom_types.ContactFieldTemplate, exists bool) {
  12563. v := m.template
  12564. if v == nil {
  12565. return
  12566. }
  12567. return *v, true
  12568. }
  12569. // OldTemplate returns the old "template" field's value of the ContactFieldTemplate entity.
  12570. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  12571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12572. func (m *ContactFieldTemplateMutation) OldTemplate(ctx context.Context) (v []custom_types.ContactFieldTemplate, err error) {
  12573. if !m.op.Is(OpUpdateOne) {
  12574. return v, errors.New("OldTemplate is only allowed on UpdateOne operations")
  12575. }
  12576. if m.id == nil || m.oldValue == nil {
  12577. return v, errors.New("OldTemplate requires an ID field in the mutation")
  12578. }
  12579. oldValue, err := m.oldValue(ctx)
  12580. if err != nil {
  12581. return v, fmt.Errorf("querying old value for OldTemplate: %w", err)
  12582. }
  12583. return oldValue.Template, nil
  12584. }
  12585. // AppendTemplate adds ctft to the "template" field.
  12586. func (m *ContactFieldTemplateMutation) AppendTemplate(ctft []custom_types.ContactFieldTemplate) {
  12587. m.appendtemplate = append(m.appendtemplate, ctft...)
  12588. }
  12589. // AppendedTemplate returns the list of values that were appended to the "template" field in this mutation.
  12590. func (m *ContactFieldTemplateMutation) AppendedTemplate() ([]custom_types.ContactFieldTemplate, bool) {
  12591. if len(m.appendtemplate) == 0 {
  12592. return nil, false
  12593. }
  12594. return m.appendtemplate, true
  12595. }
  12596. // ResetTemplate resets all changes to the "template" field.
  12597. func (m *ContactFieldTemplateMutation) ResetTemplate() {
  12598. m.template = nil
  12599. m.appendtemplate = nil
  12600. }
  12601. // Where appends a list predicates to the ContactFieldTemplateMutation builder.
  12602. func (m *ContactFieldTemplateMutation) Where(ps ...predicate.ContactFieldTemplate) {
  12603. m.predicates = append(m.predicates, ps...)
  12604. }
  12605. // WhereP appends storage-level predicates to the ContactFieldTemplateMutation builder. Using this method,
  12606. // users can use type-assertion to append predicates that do not depend on any generated package.
  12607. func (m *ContactFieldTemplateMutation) WhereP(ps ...func(*sql.Selector)) {
  12608. p := make([]predicate.ContactFieldTemplate, len(ps))
  12609. for i := range ps {
  12610. p[i] = ps[i]
  12611. }
  12612. m.Where(p...)
  12613. }
  12614. // Op returns the operation name.
  12615. func (m *ContactFieldTemplateMutation) Op() Op {
  12616. return m.op
  12617. }
  12618. // SetOp allows setting the mutation operation.
  12619. func (m *ContactFieldTemplateMutation) SetOp(op Op) {
  12620. m.op = op
  12621. }
  12622. // Type returns the node type of this mutation (ContactFieldTemplate).
  12623. func (m *ContactFieldTemplateMutation) Type() string {
  12624. return m.typ
  12625. }
  12626. // Fields returns all fields that were changed during this mutation. Note that in
  12627. // order to get all numeric fields that were incremented/decremented, call
  12628. // AddedFields().
  12629. func (m *ContactFieldTemplateMutation) Fields() []string {
  12630. fields := make([]string, 0, 6)
  12631. if m.created_at != nil {
  12632. fields = append(fields, contactfieldtemplate.FieldCreatedAt)
  12633. }
  12634. if m.updated_at != nil {
  12635. fields = append(fields, contactfieldtemplate.FieldUpdatedAt)
  12636. }
  12637. if m.status != nil {
  12638. fields = append(fields, contactfieldtemplate.FieldStatus)
  12639. }
  12640. if m.deleted_at != nil {
  12641. fields = append(fields, contactfieldtemplate.FieldDeletedAt)
  12642. }
  12643. if m.organization_id != nil {
  12644. fields = append(fields, contactfieldtemplate.FieldOrganizationID)
  12645. }
  12646. if m.template != nil {
  12647. fields = append(fields, contactfieldtemplate.FieldTemplate)
  12648. }
  12649. return fields
  12650. }
  12651. // Field returns the value of a field with the given name. The second boolean
  12652. // return value indicates that this field was not set, or was not defined in the
  12653. // schema.
  12654. func (m *ContactFieldTemplateMutation) Field(name string) (ent.Value, bool) {
  12655. switch name {
  12656. case contactfieldtemplate.FieldCreatedAt:
  12657. return m.CreatedAt()
  12658. case contactfieldtemplate.FieldUpdatedAt:
  12659. return m.UpdatedAt()
  12660. case contactfieldtemplate.FieldStatus:
  12661. return m.Status()
  12662. case contactfieldtemplate.FieldDeletedAt:
  12663. return m.DeletedAt()
  12664. case contactfieldtemplate.FieldOrganizationID:
  12665. return m.OrganizationID()
  12666. case contactfieldtemplate.FieldTemplate:
  12667. return m.Template()
  12668. }
  12669. return nil, false
  12670. }
  12671. // OldField returns the old value of the field from the database. An error is
  12672. // returned if the mutation operation is not UpdateOne, or the query to the
  12673. // database failed.
  12674. func (m *ContactFieldTemplateMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12675. switch name {
  12676. case contactfieldtemplate.FieldCreatedAt:
  12677. return m.OldCreatedAt(ctx)
  12678. case contactfieldtemplate.FieldUpdatedAt:
  12679. return m.OldUpdatedAt(ctx)
  12680. case contactfieldtemplate.FieldStatus:
  12681. return m.OldStatus(ctx)
  12682. case contactfieldtemplate.FieldDeletedAt:
  12683. return m.OldDeletedAt(ctx)
  12684. case contactfieldtemplate.FieldOrganizationID:
  12685. return m.OldOrganizationID(ctx)
  12686. case contactfieldtemplate.FieldTemplate:
  12687. return m.OldTemplate(ctx)
  12688. }
  12689. return nil, fmt.Errorf("unknown ContactFieldTemplate field %s", name)
  12690. }
  12691. // SetField sets the value of a field with the given name. It returns an error if
  12692. // the field is not defined in the schema, or if the type mismatched the field
  12693. // type.
  12694. func (m *ContactFieldTemplateMutation) SetField(name string, value ent.Value) error {
  12695. switch name {
  12696. case contactfieldtemplate.FieldCreatedAt:
  12697. v, ok := value.(time.Time)
  12698. if !ok {
  12699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12700. }
  12701. m.SetCreatedAt(v)
  12702. return nil
  12703. case contactfieldtemplate.FieldUpdatedAt:
  12704. v, ok := value.(time.Time)
  12705. if !ok {
  12706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12707. }
  12708. m.SetUpdatedAt(v)
  12709. return nil
  12710. case contactfieldtemplate.FieldStatus:
  12711. v, ok := value.(uint8)
  12712. if !ok {
  12713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12714. }
  12715. m.SetStatus(v)
  12716. return nil
  12717. case contactfieldtemplate.FieldDeletedAt:
  12718. v, ok := value.(time.Time)
  12719. if !ok {
  12720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12721. }
  12722. m.SetDeletedAt(v)
  12723. return nil
  12724. case contactfieldtemplate.FieldOrganizationID:
  12725. v, ok := value.(uint64)
  12726. if !ok {
  12727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12728. }
  12729. m.SetOrganizationID(v)
  12730. return nil
  12731. case contactfieldtemplate.FieldTemplate:
  12732. v, ok := value.([]custom_types.ContactFieldTemplate)
  12733. if !ok {
  12734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12735. }
  12736. m.SetTemplate(v)
  12737. return nil
  12738. }
  12739. return fmt.Errorf("unknown ContactFieldTemplate field %s", name)
  12740. }
  12741. // AddedFields returns all numeric fields that were incremented/decremented during
  12742. // this mutation.
  12743. func (m *ContactFieldTemplateMutation) AddedFields() []string {
  12744. var fields []string
  12745. if m.addstatus != nil {
  12746. fields = append(fields, contactfieldtemplate.FieldStatus)
  12747. }
  12748. if m.addorganization_id != nil {
  12749. fields = append(fields, contactfieldtemplate.FieldOrganizationID)
  12750. }
  12751. return fields
  12752. }
  12753. // AddedField returns the numeric value that was incremented/decremented on a field
  12754. // with the given name. The second boolean return value indicates that this field
  12755. // was not set, or was not defined in the schema.
  12756. func (m *ContactFieldTemplateMutation) AddedField(name string) (ent.Value, bool) {
  12757. switch name {
  12758. case contactfieldtemplate.FieldStatus:
  12759. return m.AddedStatus()
  12760. case contactfieldtemplate.FieldOrganizationID:
  12761. return m.AddedOrganizationID()
  12762. }
  12763. return nil, false
  12764. }
  12765. // AddField adds the value to the field with the given name. It returns an error if
  12766. // the field is not defined in the schema, or if the type mismatched the field
  12767. // type.
  12768. func (m *ContactFieldTemplateMutation) AddField(name string, value ent.Value) error {
  12769. switch name {
  12770. case contactfieldtemplate.FieldStatus:
  12771. v, ok := value.(int8)
  12772. if !ok {
  12773. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12774. }
  12775. m.AddStatus(v)
  12776. return nil
  12777. case contactfieldtemplate.FieldOrganizationID:
  12778. v, ok := value.(int64)
  12779. if !ok {
  12780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12781. }
  12782. m.AddOrganizationID(v)
  12783. return nil
  12784. }
  12785. return fmt.Errorf("unknown ContactFieldTemplate numeric field %s", name)
  12786. }
  12787. // ClearedFields returns all nullable fields that were cleared during this
  12788. // mutation.
  12789. func (m *ContactFieldTemplateMutation) ClearedFields() []string {
  12790. var fields []string
  12791. if m.FieldCleared(contactfieldtemplate.FieldStatus) {
  12792. fields = append(fields, contactfieldtemplate.FieldStatus)
  12793. }
  12794. if m.FieldCleared(contactfieldtemplate.FieldDeletedAt) {
  12795. fields = append(fields, contactfieldtemplate.FieldDeletedAt)
  12796. }
  12797. return fields
  12798. }
  12799. // FieldCleared returns a boolean indicating if a field with the given name was
  12800. // cleared in this mutation.
  12801. func (m *ContactFieldTemplateMutation) FieldCleared(name string) bool {
  12802. _, ok := m.clearedFields[name]
  12803. return ok
  12804. }
  12805. // ClearField clears the value of the field with the given name. It returns an
  12806. // error if the field is not defined in the schema.
  12807. func (m *ContactFieldTemplateMutation) ClearField(name string) error {
  12808. switch name {
  12809. case contactfieldtemplate.FieldStatus:
  12810. m.ClearStatus()
  12811. return nil
  12812. case contactfieldtemplate.FieldDeletedAt:
  12813. m.ClearDeletedAt()
  12814. return nil
  12815. }
  12816. return fmt.Errorf("unknown ContactFieldTemplate nullable field %s", name)
  12817. }
  12818. // ResetField resets all changes in the mutation for the field with the given name.
  12819. // It returns an error if the field is not defined in the schema.
  12820. func (m *ContactFieldTemplateMutation) ResetField(name string) error {
  12821. switch name {
  12822. case contactfieldtemplate.FieldCreatedAt:
  12823. m.ResetCreatedAt()
  12824. return nil
  12825. case contactfieldtemplate.FieldUpdatedAt:
  12826. m.ResetUpdatedAt()
  12827. return nil
  12828. case contactfieldtemplate.FieldStatus:
  12829. m.ResetStatus()
  12830. return nil
  12831. case contactfieldtemplate.FieldDeletedAt:
  12832. m.ResetDeletedAt()
  12833. return nil
  12834. case contactfieldtemplate.FieldOrganizationID:
  12835. m.ResetOrganizationID()
  12836. return nil
  12837. case contactfieldtemplate.FieldTemplate:
  12838. m.ResetTemplate()
  12839. return nil
  12840. }
  12841. return fmt.Errorf("unknown ContactFieldTemplate field %s", name)
  12842. }
  12843. // AddedEdges returns all edge names that were set/added in this mutation.
  12844. func (m *ContactFieldTemplateMutation) AddedEdges() []string {
  12845. edges := make([]string, 0, 0)
  12846. return edges
  12847. }
  12848. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12849. // name in this mutation.
  12850. func (m *ContactFieldTemplateMutation) AddedIDs(name string) []ent.Value {
  12851. return nil
  12852. }
  12853. // RemovedEdges returns all edge names that were removed in this mutation.
  12854. func (m *ContactFieldTemplateMutation) RemovedEdges() []string {
  12855. edges := make([]string, 0, 0)
  12856. return edges
  12857. }
  12858. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12859. // the given name in this mutation.
  12860. func (m *ContactFieldTemplateMutation) RemovedIDs(name string) []ent.Value {
  12861. return nil
  12862. }
  12863. // ClearedEdges returns all edge names that were cleared in this mutation.
  12864. func (m *ContactFieldTemplateMutation) ClearedEdges() []string {
  12865. edges := make([]string, 0, 0)
  12866. return edges
  12867. }
  12868. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12869. // was cleared in this mutation.
  12870. func (m *ContactFieldTemplateMutation) EdgeCleared(name string) bool {
  12871. return false
  12872. }
  12873. // ClearEdge clears the value of the edge with the given name. It returns an error
  12874. // if that edge is not defined in the schema.
  12875. func (m *ContactFieldTemplateMutation) ClearEdge(name string) error {
  12876. return fmt.Errorf("unknown ContactFieldTemplate unique edge %s", name)
  12877. }
  12878. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12879. // It returns an error if the edge is not defined in the schema.
  12880. func (m *ContactFieldTemplateMutation) ResetEdge(name string) error {
  12881. return fmt.Errorf("unknown ContactFieldTemplate edge %s", name)
  12882. }
  12883. // CreditBalanceMutation represents an operation that mutates the CreditBalance nodes in the graph.
  12884. type CreditBalanceMutation struct {
  12885. config
  12886. op Op
  12887. typ string
  12888. id *uint64
  12889. created_at *time.Time
  12890. updated_at *time.Time
  12891. deleted_at *time.Time
  12892. user_id *string
  12893. balance *float32
  12894. addbalance *float32
  12895. status *int
  12896. addstatus *int
  12897. organization_id *uint64
  12898. addorganization_id *int64
  12899. clearedFields map[string]struct{}
  12900. done bool
  12901. oldValue func(context.Context) (*CreditBalance, error)
  12902. predicates []predicate.CreditBalance
  12903. }
  12904. var _ ent.Mutation = (*CreditBalanceMutation)(nil)
  12905. // creditbalanceOption allows management of the mutation configuration using functional options.
  12906. type creditbalanceOption func(*CreditBalanceMutation)
  12907. // newCreditBalanceMutation creates new mutation for the CreditBalance entity.
  12908. func newCreditBalanceMutation(c config, op Op, opts ...creditbalanceOption) *CreditBalanceMutation {
  12909. m := &CreditBalanceMutation{
  12910. config: c,
  12911. op: op,
  12912. typ: TypeCreditBalance,
  12913. clearedFields: make(map[string]struct{}),
  12914. }
  12915. for _, opt := range opts {
  12916. opt(m)
  12917. }
  12918. return m
  12919. }
  12920. // withCreditBalanceID sets the ID field of the mutation.
  12921. func withCreditBalanceID(id uint64) creditbalanceOption {
  12922. return func(m *CreditBalanceMutation) {
  12923. var (
  12924. err error
  12925. once sync.Once
  12926. value *CreditBalance
  12927. )
  12928. m.oldValue = func(ctx context.Context) (*CreditBalance, error) {
  12929. once.Do(func() {
  12930. if m.done {
  12931. err = errors.New("querying old values post mutation is not allowed")
  12932. } else {
  12933. value, err = m.Client().CreditBalance.Get(ctx, id)
  12934. }
  12935. })
  12936. return value, err
  12937. }
  12938. m.id = &id
  12939. }
  12940. }
  12941. // withCreditBalance sets the old CreditBalance of the mutation.
  12942. func withCreditBalance(node *CreditBalance) creditbalanceOption {
  12943. return func(m *CreditBalanceMutation) {
  12944. m.oldValue = func(context.Context) (*CreditBalance, error) {
  12945. return node, nil
  12946. }
  12947. m.id = &node.ID
  12948. }
  12949. }
  12950. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12951. // executed in a transaction (ent.Tx), a transactional client is returned.
  12952. func (m CreditBalanceMutation) Client() *Client {
  12953. client := &Client{config: m.config}
  12954. client.init()
  12955. return client
  12956. }
  12957. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12958. // it returns an error otherwise.
  12959. func (m CreditBalanceMutation) Tx() (*Tx, error) {
  12960. if _, ok := m.driver.(*txDriver); !ok {
  12961. return nil, errors.New("ent: mutation is not running in a transaction")
  12962. }
  12963. tx := &Tx{config: m.config}
  12964. tx.init()
  12965. return tx, nil
  12966. }
  12967. // SetID sets the value of the id field. Note that this
  12968. // operation is only accepted on creation of CreditBalance entities.
  12969. func (m *CreditBalanceMutation) SetID(id uint64) {
  12970. m.id = &id
  12971. }
  12972. // ID returns the ID value in the mutation. Note that the ID is only available
  12973. // if it was provided to the builder or after it was returned from the database.
  12974. func (m *CreditBalanceMutation) ID() (id uint64, exists bool) {
  12975. if m.id == nil {
  12976. return
  12977. }
  12978. return *m.id, true
  12979. }
  12980. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12981. // That means, if the mutation is applied within a transaction with an isolation level such
  12982. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12983. // or updated by the mutation.
  12984. func (m *CreditBalanceMutation) IDs(ctx context.Context) ([]uint64, error) {
  12985. switch {
  12986. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12987. id, exists := m.ID()
  12988. if exists {
  12989. return []uint64{id}, nil
  12990. }
  12991. fallthrough
  12992. case m.op.Is(OpUpdate | OpDelete):
  12993. return m.Client().CreditBalance.Query().Where(m.predicates...).IDs(ctx)
  12994. default:
  12995. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12996. }
  12997. }
  12998. // SetCreatedAt sets the "created_at" field.
  12999. func (m *CreditBalanceMutation) SetCreatedAt(t time.Time) {
  13000. m.created_at = &t
  13001. }
  13002. // CreatedAt returns the value of the "created_at" field in the mutation.
  13003. func (m *CreditBalanceMutation) CreatedAt() (r time.Time, exists bool) {
  13004. v := m.created_at
  13005. if v == nil {
  13006. return
  13007. }
  13008. return *v, true
  13009. }
  13010. // OldCreatedAt returns the old "created_at" field's value of the CreditBalance entity.
  13011. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  13012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13013. func (m *CreditBalanceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13014. if !m.op.Is(OpUpdateOne) {
  13015. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13016. }
  13017. if m.id == nil || m.oldValue == nil {
  13018. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13019. }
  13020. oldValue, err := m.oldValue(ctx)
  13021. if err != nil {
  13022. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13023. }
  13024. return oldValue.CreatedAt, nil
  13025. }
  13026. // ResetCreatedAt resets all changes to the "created_at" field.
  13027. func (m *CreditBalanceMutation) ResetCreatedAt() {
  13028. m.created_at = nil
  13029. }
  13030. // SetUpdatedAt sets the "updated_at" field.
  13031. func (m *CreditBalanceMutation) SetUpdatedAt(t time.Time) {
  13032. m.updated_at = &t
  13033. }
  13034. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13035. func (m *CreditBalanceMutation) UpdatedAt() (r time.Time, exists bool) {
  13036. v := m.updated_at
  13037. if v == nil {
  13038. return
  13039. }
  13040. return *v, true
  13041. }
  13042. // OldUpdatedAt returns the old "updated_at" field's value of the CreditBalance entity.
  13043. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  13044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13045. func (m *CreditBalanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13046. if !m.op.Is(OpUpdateOne) {
  13047. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13048. }
  13049. if m.id == nil || m.oldValue == nil {
  13050. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13051. }
  13052. oldValue, err := m.oldValue(ctx)
  13053. if err != nil {
  13054. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13055. }
  13056. return oldValue.UpdatedAt, nil
  13057. }
  13058. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13059. func (m *CreditBalanceMutation) ResetUpdatedAt() {
  13060. m.updated_at = nil
  13061. }
  13062. // SetDeletedAt sets the "deleted_at" field.
  13063. func (m *CreditBalanceMutation) SetDeletedAt(t time.Time) {
  13064. m.deleted_at = &t
  13065. }
  13066. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13067. func (m *CreditBalanceMutation) DeletedAt() (r time.Time, exists bool) {
  13068. v := m.deleted_at
  13069. if v == nil {
  13070. return
  13071. }
  13072. return *v, true
  13073. }
  13074. // OldDeletedAt returns the old "deleted_at" field's value of the CreditBalance entity.
  13075. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  13076. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13077. func (m *CreditBalanceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13078. if !m.op.Is(OpUpdateOne) {
  13079. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13080. }
  13081. if m.id == nil || m.oldValue == nil {
  13082. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13083. }
  13084. oldValue, err := m.oldValue(ctx)
  13085. if err != nil {
  13086. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13087. }
  13088. return oldValue.DeletedAt, nil
  13089. }
  13090. // ClearDeletedAt clears the value of the "deleted_at" field.
  13091. func (m *CreditBalanceMutation) ClearDeletedAt() {
  13092. m.deleted_at = nil
  13093. m.clearedFields[creditbalance.FieldDeletedAt] = struct{}{}
  13094. }
  13095. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13096. func (m *CreditBalanceMutation) DeletedAtCleared() bool {
  13097. _, ok := m.clearedFields[creditbalance.FieldDeletedAt]
  13098. return ok
  13099. }
  13100. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13101. func (m *CreditBalanceMutation) ResetDeletedAt() {
  13102. m.deleted_at = nil
  13103. delete(m.clearedFields, creditbalance.FieldDeletedAt)
  13104. }
  13105. // SetUserID sets the "user_id" field.
  13106. func (m *CreditBalanceMutation) SetUserID(s string) {
  13107. m.user_id = &s
  13108. }
  13109. // UserID returns the value of the "user_id" field in the mutation.
  13110. func (m *CreditBalanceMutation) UserID() (r string, exists bool) {
  13111. v := m.user_id
  13112. if v == nil {
  13113. return
  13114. }
  13115. return *v, true
  13116. }
  13117. // OldUserID returns the old "user_id" field's value of the CreditBalance entity.
  13118. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  13119. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13120. func (m *CreditBalanceMutation) OldUserID(ctx context.Context) (v string, err error) {
  13121. if !m.op.Is(OpUpdateOne) {
  13122. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  13123. }
  13124. if m.id == nil || m.oldValue == nil {
  13125. return v, errors.New("OldUserID requires an ID field in the mutation")
  13126. }
  13127. oldValue, err := m.oldValue(ctx)
  13128. if err != nil {
  13129. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  13130. }
  13131. return oldValue.UserID, nil
  13132. }
  13133. // ClearUserID clears the value of the "user_id" field.
  13134. func (m *CreditBalanceMutation) ClearUserID() {
  13135. m.user_id = nil
  13136. m.clearedFields[creditbalance.FieldUserID] = struct{}{}
  13137. }
  13138. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  13139. func (m *CreditBalanceMutation) UserIDCleared() bool {
  13140. _, ok := m.clearedFields[creditbalance.FieldUserID]
  13141. return ok
  13142. }
  13143. // ResetUserID resets all changes to the "user_id" field.
  13144. func (m *CreditBalanceMutation) ResetUserID() {
  13145. m.user_id = nil
  13146. delete(m.clearedFields, creditbalance.FieldUserID)
  13147. }
  13148. // SetBalance sets the "balance" field.
  13149. func (m *CreditBalanceMutation) SetBalance(f float32) {
  13150. m.balance = &f
  13151. m.addbalance = nil
  13152. }
  13153. // Balance returns the value of the "balance" field in the mutation.
  13154. func (m *CreditBalanceMutation) Balance() (r float32, exists bool) {
  13155. v := m.balance
  13156. if v == nil {
  13157. return
  13158. }
  13159. return *v, true
  13160. }
  13161. // OldBalance returns the old "balance" field's value of the CreditBalance entity.
  13162. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  13163. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13164. func (m *CreditBalanceMutation) OldBalance(ctx context.Context) (v float32, err error) {
  13165. if !m.op.Is(OpUpdateOne) {
  13166. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  13167. }
  13168. if m.id == nil || m.oldValue == nil {
  13169. return v, errors.New("OldBalance requires an ID field in the mutation")
  13170. }
  13171. oldValue, err := m.oldValue(ctx)
  13172. if err != nil {
  13173. return v, fmt.Errorf("querying old value for OldBalance: %w", err)
  13174. }
  13175. return oldValue.Balance, nil
  13176. }
  13177. // AddBalance adds f to the "balance" field.
  13178. func (m *CreditBalanceMutation) AddBalance(f float32) {
  13179. if m.addbalance != nil {
  13180. *m.addbalance += f
  13181. } else {
  13182. m.addbalance = &f
  13183. }
  13184. }
  13185. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  13186. func (m *CreditBalanceMutation) AddedBalance() (r float32, exists bool) {
  13187. v := m.addbalance
  13188. if v == nil {
  13189. return
  13190. }
  13191. return *v, true
  13192. }
  13193. // ResetBalance resets all changes to the "balance" field.
  13194. func (m *CreditBalanceMutation) ResetBalance() {
  13195. m.balance = nil
  13196. m.addbalance = nil
  13197. }
  13198. // SetStatus sets the "status" field.
  13199. func (m *CreditBalanceMutation) SetStatus(i int) {
  13200. m.status = &i
  13201. m.addstatus = nil
  13202. }
  13203. // Status returns the value of the "status" field in the mutation.
  13204. func (m *CreditBalanceMutation) Status() (r int, exists bool) {
  13205. v := m.status
  13206. if v == nil {
  13207. return
  13208. }
  13209. return *v, true
  13210. }
  13211. // OldStatus returns the old "status" field's value of the CreditBalance entity.
  13212. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  13213. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13214. func (m *CreditBalanceMutation) OldStatus(ctx context.Context) (v int, err error) {
  13215. if !m.op.Is(OpUpdateOne) {
  13216. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13217. }
  13218. if m.id == nil || m.oldValue == nil {
  13219. return v, errors.New("OldStatus requires an ID field in the mutation")
  13220. }
  13221. oldValue, err := m.oldValue(ctx)
  13222. if err != nil {
  13223. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13224. }
  13225. return oldValue.Status, nil
  13226. }
  13227. // AddStatus adds i to the "status" field.
  13228. func (m *CreditBalanceMutation) AddStatus(i int) {
  13229. if m.addstatus != nil {
  13230. *m.addstatus += i
  13231. } else {
  13232. m.addstatus = &i
  13233. }
  13234. }
  13235. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13236. func (m *CreditBalanceMutation) AddedStatus() (r int, exists bool) {
  13237. v := m.addstatus
  13238. if v == nil {
  13239. return
  13240. }
  13241. return *v, true
  13242. }
  13243. // ClearStatus clears the value of the "status" field.
  13244. func (m *CreditBalanceMutation) ClearStatus() {
  13245. m.status = nil
  13246. m.addstatus = nil
  13247. m.clearedFields[creditbalance.FieldStatus] = struct{}{}
  13248. }
  13249. // StatusCleared returns if the "status" field was cleared in this mutation.
  13250. func (m *CreditBalanceMutation) StatusCleared() bool {
  13251. _, ok := m.clearedFields[creditbalance.FieldStatus]
  13252. return ok
  13253. }
  13254. // ResetStatus resets all changes to the "status" field.
  13255. func (m *CreditBalanceMutation) ResetStatus() {
  13256. m.status = nil
  13257. m.addstatus = nil
  13258. delete(m.clearedFields, creditbalance.FieldStatus)
  13259. }
  13260. // SetOrganizationID sets the "organization_id" field.
  13261. func (m *CreditBalanceMutation) SetOrganizationID(u uint64) {
  13262. m.organization_id = &u
  13263. m.addorganization_id = nil
  13264. }
  13265. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13266. func (m *CreditBalanceMutation) OrganizationID() (r uint64, exists bool) {
  13267. v := m.organization_id
  13268. if v == nil {
  13269. return
  13270. }
  13271. return *v, true
  13272. }
  13273. // OldOrganizationID returns the old "organization_id" field's value of the CreditBalance entity.
  13274. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  13275. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13276. func (m *CreditBalanceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13277. if !m.op.Is(OpUpdateOne) {
  13278. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13279. }
  13280. if m.id == nil || m.oldValue == nil {
  13281. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13282. }
  13283. oldValue, err := m.oldValue(ctx)
  13284. if err != nil {
  13285. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13286. }
  13287. return oldValue.OrganizationID, nil
  13288. }
  13289. // AddOrganizationID adds u to the "organization_id" field.
  13290. func (m *CreditBalanceMutation) AddOrganizationID(u int64) {
  13291. if m.addorganization_id != nil {
  13292. *m.addorganization_id += u
  13293. } else {
  13294. m.addorganization_id = &u
  13295. }
  13296. }
  13297. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13298. func (m *CreditBalanceMutation) AddedOrganizationID() (r int64, exists bool) {
  13299. v := m.addorganization_id
  13300. if v == nil {
  13301. return
  13302. }
  13303. return *v, true
  13304. }
  13305. // ClearOrganizationID clears the value of the "organization_id" field.
  13306. func (m *CreditBalanceMutation) ClearOrganizationID() {
  13307. m.organization_id = nil
  13308. m.addorganization_id = nil
  13309. m.clearedFields[creditbalance.FieldOrganizationID] = struct{}{}
  13310. }
  13311. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  13312. func (m *CreditBalanceMutation) OrganizationIDCleared() bool {
  13313. _, ok := m.clearedFields[creditbalance.FieldOrganizationID]
  13314. return ok
  13315. }
  13316. // ResetOrganizationID resets all changes to the "organization_id" field.
  13317. func (m *CreditBalanceMutation) ResetOrganizationID() {
  13318. m.organization_id = nil
  13319. m.addorganization_id = nil
  13320. delete(m.clearedFields, creditbalance.FieldOrganizationID)
  13321. }
  13322. // Where appends a list predicates to the CreditBalanceMutation builder.
  13323. func (m *CreditBalanceMutation) Where(ps ...predicate.CreditBalance) {
  13324. m.predicates = append(m.predicates, ps...)
  13325. }
  13326. // WhereP appends storage-level predicates to the CreditBalanceMutation builder. Using this method,
  13327. // users can use type-assertion to append predicates that do not depend on any generated package.
  13328. func (m *CreditBalanceMutation) WhereP(ps ...func(*sql.Selector)) {
  13329. p := make([]predicate.CreditBalance, len(ps))
  13330. for i := range ps {
  13331. p[i] = ps[i]
  13332. }
  13333. m.Where(p...)
  13334. }
  13335. // Op returns the operation name.
  13336. func (m *CreditBalanceMutation) Op() Op {
  13337. return m.op
  13338. }
  13339. // SetOp allows setting the mutation operation.
  13340. func (m *CreditBalanceMutation) SetOp(op Op) {
  13341. m.op = op
  13342. }
  13343. // Type returns the node type of this mutation (CreditBalance).
  13344. func (m *CreditBalanceMutation) Type() string {
  13345. return m.typ
  13346. }
  13347. // Fields returns all fields that were changed during this mutation. Note that in
  13348. // order to get all numeric fields that were incremented/decremented, call
  13349. // AddedFields().
  13350. func (m *CreditBalanceMutation) Fields() []string {
  13351. fields := make([]string, 0, 7)
  13352. if m.created_at != nil {
  13353. fields = append(fields, creditbalance.FieldCreatedAt)
  13354. }
  13355. if m.updated_at != nil {
  13356. fields = append(fields, creditbalance.FieldUpdatedAt)
  13357. }
  13358. if m.deleted_at != nil {
  13359. fields = append(fields, creditbalance.FieldDeletedAt)
  13360. }
  13361. if m.user_id != nil {
  13362. fields = append(fields, creditbalance.FieldUserID)
  13363. }
  13364. if m.balance != nil {
  13365. fields = append(fields, creditbalance.FieldBalance)
  13366. }
  13367. if m.status != nil {
  13368. fields = append(fields, creditbalance.FieldStatus)
  13369. }
  13370. if m.organization_id != nil {
  13371. fields = append(fields, creditbalance.FieldOrganizationID)
  13372. }
  13373. return fields
  13374. }
  13375. // Field returns the value of a field with the given name. The second boolean
  13376. // return value indicates that this field was not set, or was not defined in the
  13377. // schema.
  13378. func (m *CreditBalanceMutation) Field(name string) (ent.Value, bool) {
  13379. switch name {
  13380. case creditbalance.FieldCreatedAt:
  13381. return m.CreatedAt()
  13382. case creditbalance.FieldUpdatedAt:
  13383. return m.UpdatedAt()
  13384. case creditbalance.FieldDeletedAt:
  13385. return m.DeletedAt()
  13386. case creditbalance.FieldUserID:
  13387. return m.UserID()
  13388. case creditbalance.FieldBalance:
  13389. return m.Balance()
  13390. case creditbalance.FieldStatus:
  13391. return m.Status()
  13392. case creditbalance.FieldOrganizationID:
  13393. return m.OrganizationID()
  13394. }
  13395. return nil, false
  13396. }
  13397. // OldField returns the old value of the field from the database. An error is
  13398. // returned if the mutation operation is not UpdateOne, or the query to the
  13399. // database failed.
  13400. func (m *CreditBalanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13401. switch name {
  13402. case creditbalance.FieldCreatedAt:
  13403. return m.OldCreatedAt(ctx)
  13404. case creditbalance.FieldUpdatedAt:
  13405. return m.OldUpdatedAt(ctx)
  13406. case creditbalance.FieldDeletedAt:
  13407. return m.OldDeletedAt(ctx)
  13408. case creditbalance.FieldUserID:
  13409. return m.OldUserID(ctx)
  13410. case creditbalance.FieldBalance:
  13411. return m.OldBalance(ctx)
  13412. case creditbalance.FieldStatus:
  13413. return m.OldStatus(ctx)
  13414. case creditbalance.FieldOrganizationID:
  13415. return m.OldOrganizationID(ctx)
  13416. }
  13417. return nil, fmt.Errorf("unknown CreditBalance field %s", name)
  13418. }
  13419. // SetField sets the value of a field with the given name. It returns an error if
  13420. // the field is not defined in the schema, or if the type mismatched the field
  13421. // type.
  13422. func (m *CreditBalanceMutation) SetField(name string, value ent.Value) error {
  13423. switch name {
  13424. case creditbalance.FieldCreatedAt:
  13425. v, ok := value.(time.Time)
  13426. if !ok {
  13427. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13428. }
  13429. m.SetCreatedAt(v)
  13430. return nil
  13431. case creditbalance.FieldUpdatedAt:
  13432. v, ok := value.(time.Time)
  13433. if !ok {
  13434. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13435. }
  13436. m.SetUpdatedAt(v)
  13437. return nil
  13438. case creditbalance.FieldDeletedAt:
  13439. v, ok := value.(time.Time)
  13440. if !ok {
  13441. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13442. }
  13443. m.SetDeletedAt(v)
  13444. return nil
  13445. case creditbalance.FieldUserID:
  13446. v, ok := value.(string)
  13447. if !ok {
  13448. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13449. }
  13450. m.SetUserID(v)
  13451. return nil
  13452. case creditbalance.FieldBalance:
  13453. v, ok := value.(float32)
  13454. if !ok {
  13455. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13456. }
  13457. m.SetBalance(v)
  13458. return nil
  13459. case creditbalance.FieldStatus:
  13460. v, ok := value.(int)
  13461. if !ok {
  13462. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13463. }
  13464. m.SetStatus(v)
  13465. return nil
  13466. case creditbalance.FieldOrganizationID:
  13467. v, ok := value.(uint64)
  13468. if !ok {
  13469. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13470. }
  13471. m.SetOrganizationID(v)
  13472. return nil
  13473. }
  13474. return fmt.Errorf("unknown CreditBalance field %s", name)
  13475. }
  13476. // AddedFields returns all numeric fields that were incremented/decremented during
  13477. // this mutation.
  13478. func (m *CreditBalanceMutation) AddedFields() []string {
  13479. var fields []string
  13480. if m.addbalance != nil {
  13481. fields = append(fields, creditbalance.FieldBalance)
  13482. }
  13483. if m.addstatus != nil {
  13484. fields = append(fields, creditbalance.FieldStatus)
  13485. }
  13486. if m.addorganization_id != nil {
  13487. fields = append(fields, creditbalance.FieldOrganizationID)
  13488. }
  13489. return fields
  13490. }
  13491. // AddedField returns the numeric value that was incremented/decremented on a field
  13492. // with the given name. The second boolean return value indicates that this field
  13493. // was not set, or was not defined in the schema.
  13494. func (m *CreditBalanceMutation) AddedField(name string) (ent.Value, bool) {
  13495. switch name {
  13496. case creditbalance.FieldBalance:
  13497. return m.AddedBalance()
  13498. case creditbalance.FieldStatus:
  13499. return m.AddedStatus()
  13500. case creditbalance.FieldOrganizationID:
  13501. return m.AddedOrganizationID()
  13502. }
  13503. return nil, false
  13504. }
  13505. // AddField adds the value to the field with the given name. It returns an error if
  13506. // the field is not defined in the schema, or if the type mismatched the field
  13507. // type.
  13508. func (m *CreditBalanceMutation) AddField(name string, value ent.Value) error {
  13509. switch name {
  13510. case creditbalance.FieldBalance:
  13511. v, ok := value.(float32)
  13512. if !ok {
  13513. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13514. }
  13515. m.AddBalance(v)
  13516. return nil
  13517. case creditbalance.FieldStatus:
  13518. v, ok := value.(int)
  13519. if !ok {
  13520. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13521. }
  13522. m.AddStatus(v)
  13523. return nil
  13524. case creditbalance.FieldOrganizationID:
  13525. v, ok := value.(int64)
  13526. if !ok {
  13527. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13528. }
  13529. m.AddOrganizationID(v)
  13530. return nil
  13531. }
  13532. return fmt.Errorf("unknown CreditBalance numeric field %s", name)
  13533. }
  13534. // ClearedFields returns all nullable fields that were cleared during this
  13535. // mutation.
  13536. func (m *CreditBalanceMutation) ClearedFields() []string {
  13537. var fields []string
  13538. if m.FieldCleared(creditbalance.FieldDeletedAt) {
  13539. fields = append(fields, creditbalance.FieldDeletedAt)
  13540. }
  13541. if m.FieldCleared(creditbalance.FieldUserID) {
  13542. fields = append(fields, creditbalance.FieldUserID)
  13543. }
  13544. if m.FieldCleared(creditbalance.FieldStatus) {
  13545. fields = append(fields, creditbalance.FieldStatus)
  13546. }
  13547. if m.FieldCleared(creditbalance.FieldOrganizationID) {
  13548. fields = append(fields, creditbalance.FieldOrganizationID)
  13549. }
  13550. return fields
  13551. }
  13552. // FieldCleared returns a boolean indicating if a field with the given name was
  13553. // cleared in this mutation.
  13554. func (m *CreditBalanceMutation) FieldCleared(name string) bool {
  13555. _, ok := m.clearedFields[name]
  13556. return ok
  13557. }
  13558. // ClearField clears the value of the field with the given name. It returns an
  13559. // error if the field is not defined in the schema.
  13560. func (m *CreditBalanceMutation) ClearField(name string) error {
  13561. switch name {
  13562. case creditbalance.FieldDeletedAt:
  13563. m.ClearDeletedAt()
  13564. return nil
  13565. case creditbalance.FieldUserID:
  13566. m.ClearUserID()
  13567. return nil
  13568. case creditbalance.FieldStatus:
  13569. m.ClearStatus()
  13570. return nil
  13571. case creditbalance.FieldOrganizationID:
  13572. m.ClearOrganizationID()
  13573. return nil
  13574. }
  13575. return fmt.Errorf("unknown CreditBalance nullable field %s", name)
  13576. }
  13577. // ResetField resets all changes in the mutation for the field with the given name.
  13578. // It returns an error if the field is not defined in the schema.
  13579. func (m *CreditBalanceMutation) ResetField(name string) error {
  13580. switch name {
  13581. case creditbalance.FieldCreatedAt:
  13582. m.ResetCreatedAt()
  13583. return nil
  13584. case creditbalance.FieldUpdatedAt:
  13585. m.ResetUpdatedAt()
  13586. return nil
  13587. case creditbalance.FieldDeletedAt:
  13588. m.ResetDeletedAt()
  13589. return nil
  13590. case creditbalance.FieldUserID:
  13591. m.ResetUserID()
  13592. return nil
  13593. case creditbalance.FieldBalance:
  13594. m.ResetBalance()
  13595. return nil
  13596. case creditbalance.FieldStatus:
  13597. m.ResetStatus()
  13598. return nil
  13599. case creditbalance.FieldOrganizationID:
  13600. m.ResetOrganizationID()
  13601. return nil
  13602. }
  13603. return fmt.Errorf("unknown CreditBalance field %s", name)
  13604. }
  13605. // AddedEdges returns all edge names that were set/added in this mutation.
  13606. func (m *CreditBalanceMutation) AddedEdges() []string {
  13607. edges := make([]string, 0, 0)
  13608. return edges
  13609. }
  13610. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13611. // name in this mutation.
  13612. func (m *CreditBalanceMutation) AddedIDs(name string) []ent.Value {
  13613. return nil
  13614. }
  13615. // RemovedEdges returns all edge names that were removed in this mutation.
  13616. func (m *CreditBalanceMutation) RemovedEdges() []string {
  13617. edges := make([]string, 0, 0)
  13618. return edges
  13619. }
  13620. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13621. // the given name in this mutation.
  13622. func (m *CreditBalanceMutation) RemovedIDs(name string) []ent.Value {
  13623. return nil
  13624. }
  13625. // ClearedEdges returns all edge names that were cleared in this mutation.
  13626. func (m *CreditBalanceMutation) ClearedEdges() []string {
  13627. edges := make([]string, 0, 0)
  13628. return edges
  13629. }
  13630. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13631. // was cleared in this mutation.
  13632. func (m *CreditBalanceMutation) EdgeCleared(name string) bool {
  13633. return false
  13634. }
  13635. // ClearEdge clears the value of the edge with the given name. It returns an error
  13636. // if that edge is not defined in the schema.
  13637. func (m *CreditBalanceMutation) ClearEdge(name string) error {
  13638. return fmt.Errorf("unknown CreditBalance unique edge %s", name)
  13639. }
  13640. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13641. // It returns an error if the edge is not defined in the schema.
  13642. func (m *CreditBalanceMutation) ResetEdge(name string) error {
  13643. return fmt.Errorf("unknown CreditBalance edge %s", name)
  13644. }
  13645. // CreditUsageMutation represents an operation that mutates the CreditUsage nodes in the graph.
  13646. type CreditUsageMutation struct {
  13647. config
  13648. op Op
  13649. typ string
  13650. id *uint64
  13651. created_at *time.Time
  13652. updated_at *time.Time
  13653. deleted_at *time.Time
  13654. user_id *string
  13655. number *float32
  13656. addnumber *float32
  13657. status *int
  13658. addstatus *int
  13659. ntype *int
  13660. addntype *int
  13661. table *string
  13662. organization_id *uint64
  13663. addorganization_id *int64
  13664. nid *uint64
  13665. addnid *int64
  13666. reason *string
  13667. operator *string
  13668. clearedFields map[string]struct{}
  13669. done bool
  13670. oldValue func(context.Context) (*CreditUsage, error)
  13671. predicates []predicate.CreditUsage
  13672. }
  13673. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  13674. // creditusageOption allows management of the mutation configuration using functional options.
  13675. type creditusageOption func(*CreditUsageMutation)
  13676. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  13677. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  13678. m := &CreditUsageMutation{
  13679. config: c,
  13680. op: op,
  13681. typ: TypeCreditUsage,
  13682. clearedFields: make(map[string]struct{}),
  13683. }
  13684. for _, opt := range opts {
  13685. opt(m)
  13686. }
  13687. return m
  13688. }
  13689. // withCreditUsageID sets the ID field of the mutation.
  13690. func withCreditUsageID(id uint64) creditusageOption {
  13691. return func(m *CreditUsageMutation) {
  13692. var (
  13693. err error
  13694. once sync.Once
  13695. value *CreditUsage
  13696. )
  13697. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  13698. once.Do(func() {
  13699. if m.done {
  13700. err = errors.New("querying old values post mutation is not allowed")
  13701. } else {
  13702. value, err = m.Client().CreditUsage.Get(ctx, id)
  13703. }
  13704. })
  13705. return value, err
  13706. }
  13707. m.id = &id
  13708. }
  13709. }
  13710. // withCreditUsage sets the old CreditUsage of the mutation.
  13711. func withCreditUsage(node *CreditUsage) creditusageOption {
  13712. return func(m *CreditUsageMutation) {
  13713. m.oldValue = func(context.Context) (*CreditUsage, error) {
  13714. return node, nil
  13715. }
  13716. m.id = &node.ID
  13717. }
  13718. }
  13719. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13720. // executed in a transaction (ent.Tx), a transactional client is returned.
  13721. func (m CreditUsageMutation) Client() *Client {
  13722. client := &Client{config: m.config}
  13723. client.init()
  13724. return client
  13725. }
  13726. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13727. // it returns an error otherwise.
  13728. func (m CreditUsageMutation) Tx() (*Tx, error) {
  13729. if _, ok := m.driver.(*txDriver); !ok {
  13730. return nil, errors.New("ent: mutation is not running in a transaction")
  13731. }
  13732. tx := &Tx{config: m.config}
  13733. tx.init()
  13734. return tx, nil
  13735. }
  13736. // SetID sets the value of the id field. Note that this
  13737. // operation is only accepted on creation of CreditUsage entities.
  13738. func (m *CreditUsageMutation) SetID(id uint64) {
  13739. m.id = &id
  13740. }
  13741. // ID returns the ID value in the mutation. Note that the ID is only available
  13742. // if it was provided to the builder or after it was returned from the database.
  13743. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  13744. if m.id == nil {
  13745. return
  13746. }
  13747. return *m.id, true
  13748. }
  13749. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13750. // That means, if the mutation is applied within a transaction with an isolation level such
  13751. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13752. // or updated by the mutation.
  13753. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  13754. switch {
  13755. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13756. id, exists := m.ID()
  13757. if exists {
  13758. return []uint64{id}, nil
  13759. }
  13760. fallthrough
  13761. case m.op.Is(OpUpdate | OpDelete):
  13762. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  13763. default:
  13764. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13765. }
  13766. }
  13767. // SetCreatedAt sets the "created_at" field.
  13768. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  13769. m.created_at = &t
  13770. }
  13771. // CreatedAt returns the value of the "created_at" field in the mutation.
  13772. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  13773. v := m.created_at
  13774. if v == nil {
  13775. return
  13776. }
  13777. return *v, true
  13778. }
  13779. // OldCreatedAt returns the old "created_at" field's value of the CreditUsage entity.
  13780. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13781. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13782. func (m *CreditUsageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13783. if !m.op.Is(OpUpdateOne) {
  13784. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13785. }
  13786. if m.id == nil || m.oldValue == nil {
  13787. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13788. }
  13789. oldValue, err := m.oldValue(ctx)
  13790. if err != nil {
  13791. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13792. }
  13793. return oldValue.CreatedAt, nil
  13794. }
  13795. // ResetCreatedAt resets all changes to the "created_at" field.
  13796. func (m *CreditUsageMutation) ResetCreatedAt() {
  13797. m.created_at = nil
  13798. }
  13799. // SetUpdatedAt sets the "updated_at" field.
  13800. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  13801. m.updated_at = &t
  13802. }
  13803. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13804. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  13805. v := m.updated_at
  13806. if v == nil {
  13807. return
  13808. }
  13809. return *v, true
  13810. }
  13811. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  13812. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13814. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13815. if !m.op.Is(OpUpdateOne) {
  13816. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13817. }
  13818. if m.id == nil || m.oldValue == nil {
  13819. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13820. }
  13821. oldValue, err := m.oldValue(ctx)
  13822. if err != nil {
  13823. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13824. }
  13825. return oldValue.UpdatedAt, nil
  13826. }
  13827. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13828. func (m *CreditUsageMutation) ResetUpdatedAt() {
  13829. m.updated_at = nil
  13830. }
  13831. // SetDeletedAt sets the "deleted_at" field.
  13832. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  13833. m.deleted_at = &t
  13834. }
  13835. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13836. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  13837. v := m.deleted_at
  13838. if v == nil {
  13839. return
  13840. }
  13841. return *v, true
  13842. }
  13843. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  13844. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13846. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13847. if !m.op.Is(OpUpdateOne) {
  13848. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13849. }
  13850. if m.id == nil || m.oldValue == nil {
  13851. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13852. }
  13853. oldValue, err := m.oldValue(ctx)
  13854. if err != nil {
  13855. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13856. }
  13857. return oldValue.DeletedAt, nil
  13858. }
  13859. // ClearDeletedAt clears the value of the "deleted_at" field.
  13860. func (m *CreditUsageMutation) ClearDeletedAt() {
  13861. m.deleted_at = nil
  13862. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  13863. }
  13864. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13865. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  13866. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  13867. return ok
  13868. }
  13869. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13870. func (m *CreditUsageMutation) ResetDeletedAt() {
  13871. m.deleted_at = nil
  13872. delete(m.clearedFields, creditusage.FieldDeletedAt)
  13873. }
  13874. // SetUserID sets the "user_id" field.
  13875. func (m *CreditUsageMutation) SetUserID(s string) {
  13876. m.user_id = &s
  13877. }
  13878. // UserID returns the value of the "user_id" field in the mutation.
  13879. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  13880. v := m.user_id
  13881. if v == nil {
  13882. return
  13883. }
  13884. return *v, true
  13885. }
  13886. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  13887. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13888. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13889. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  13890. if !m.op.Is(OpUpdateOne) {
  13891. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  13892. }
  13893. if m.id == nil || m.oldValue == nil {
  13894. return v, errors.New("OldUserID requires an ID field in the mutation")
  13895. }
  13896. oldValue, err := m.oldValue(ctx)
  13897. if err != nil {
  13898. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  13899. }
  13900. return oldValue.UserID, nil
  13901. }
  13902. // ClearUserID clears the value of the "user_id" field.
  13903. func (m *CreditUsageMutation) ClearUserID() {
  13904. m.user_id = nil
  13905. m.clearedFields[creditusage.FieldUserID] = struct{}{}
  13906. }
  13907. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  13908. func (m *CreditUsageMutation) UserIDCleared() bool {
  13909. _, ok := m.clearedFields[creditusage.FieldUserID]
  13910. return ok
  13911. }
  13912. // ResetUserID resets all changes to the "user_id" field.
  13913. func (m *CreditUsageMutation) ResetUserID() {
  13914. m.user_id = nil
  13915. delete(m.clearedFields, creditusage.FieldUserID)
  13916. }
  13917. // SetNumber sets the "number" field.
  13918. func (m *CreditUsageMutation) SetNumber(f float32) {
  13919. m.number = &f
  13920. m.addnumber = nil
  13921. }
  13922. // Number returns the value of the "number" field in the mutation.
  13923. func (m *CreditUsageMutation) Number() (r float32, exists bool) {
  13924. v := m.number
  13925. if v == nil {
  13926. return
  13927. }
  13928. return *v, true
  13929. }
  13930. // OldNumber returns the old "number" field's value of the CreditUsage entity.
  13931. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13932. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13933. func (m *CreditUsageMutation) OldNumber(ctx context.Context) (v float32, err error) {
  13934. if !m.op.Is(OpUpdateOne) {
  13935. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  13936. }
  13937. if m.id == nil || m.oldValue == nil {
  13938. return v, errors.New("OldNumber requires an ID field in the mutation")
  13939. }
  13940. oldValue, err := m.oldValue(ctx)
  13941. if err != nil {
  13942. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  13943. }
  13944. return oldValue.Number, nil
  13945. }
  13946. // AddNumber adds f to the "number" field.
  13947. func (m *CreditUsageMutation) AddNumber(f float32) {
  13948. if m.addnumber != nil {
  13949. *m.addnumber += f
  13950. } else {
  13951. m.addnumber = &f
  13952. }
  13953. }
  13954. // AddedNumber returns the value that was added to the "number" field in this mutation.
  13955. func (m *CreditUsageMutation) AddedNumber() (r float32, exists bool) {
  13956. v := m.addnumber
  13957. if v == nil {
  13958. return
  13959. }
  13960. return *v, true
  13961. }
  13962. // ResetNumber resets all changes to the "number" field.
  13963. func (m *CreditUsageMutation) ResetNumber() {
  13964. m.number = nil
  13965. m.addnumber = nil
  13966. }
  13967. // SetStatus sets the "status" field.
  13968. func (m *CreditUsageMutation) SetStatus(i int) {
  13969. m.status = &i
  13970. m.addstatus = nil
  13971. }
  13972. // Status returns the value of the "status" field in the mutation.
  13973. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  13974. v := m.status
  13975. if v == nil {
  13976. return
  13977. }
  13978. return *v, true
  13979. }
  13980. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  13981. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13982. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13983. func (m *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  13984. if !m.op.Is(OpUpdateOne) {
  13985. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13986. }
  13987. if m.id == nil || m.oldValue == nil {
  13988. return v, errors.New("OldStatus requires an ID field in the mutation")
  13989. }
  13990. oldValue, err := m.oldValue(ctx)
  13991. if err != nil {
  13992. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13993. }
  13994. return oldValue.Status, nil
  13995. }
  13996. // AddStatus adds i to the "status" field.
  13997. func (m *CreditUsageMutation) AddStatus(i int) {
  13998. if m.addstatus != nil {
  13999. *m.addstatus += i
  14000. } else {
  14001. m.addstatus = &i
  14002. }
  14003. }
  14004. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14005. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  14006. v := m.addstatus
  14007. if v == nil {
  14008. return
  14009. }
  14010. return *v, true
  14011. }
  14012. // ClearStatus clears the value of the "status" field.
  14013. func (m *CreditUsageMutation) ClearStatus() {
  14014. m.status = nil
  14015. m.addstatus = nil
  14016. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  14017. }
  14018. // StatusCleared returns if the "status" field was cleared in this mutation.
  14019. func (m *CreditUsageMutation) StatusCleared() bool {
  14020. _, ok := m.clearedFields[creditusage.FieldStatus]
  14021. return ok
  14022. }
  14023. // ResetStatus resets all changes to the "status" field.
  14024. func (m *CreditUsageMutation) ResetStatus() {
  14025. m.status = nil
  14026. m.addstatus = nil
  14027. delete(m.clearedFields, creditusage.FieldStatus)
  14028. }
  14029. // SetNtype sets the "ntype" field.
  14030. func (m *CreditUsageMutation) SetNtype(i int) {
  14031. m.ntype = &i
  14032. m.addntype = nil
  14033. }
  14034. // Ntype returns the value of the "ntype" field in the mutation.
  14035. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  14036. v := m.ntype
  14037. if v == nil {
  14038. return
  14039. }
  14040. return *v, true
  14041. }
  14042. // OldNtype returns the old "ntype" field's value of the CreditUsage entity.
  14043. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14045. func (m *CreditUsageMutation) OldNtype(ctx context.Context) (v int, err error) {
  14046. if !m.op.Is(OpUpdateOne) {
  14047. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  14048. }
  14049. if m.id == nil || m.oldValue == nil {
  14050. return v, errors.New("OldNtype requires an ID field in the mutation")
  14051. }
  14052. oldValue, err := m.oldValue(ctx)
  14053. if err != nil {
  14054. return v, fmt.Errorf("querying old value for OldNtype: %w", err)
  14055. }
  14056. return oldValue.Ntype, nil
  14057. }
  14058. // AddNtype adds i to the "ntype" field.
  14059. func (m *CreditUsageMutation) AddNtype(i int) {
  14060. if m.addntype != nil {
  14061. *m.addntype += i
  14062. } else {
  14063. m.addntype = &i
  14064. }
  14065. }
  14066. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  14067. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  14068. v := m.addntype
  14069. if v == nil {
  14070. return
  14071. }
  14072. return *v, true
  14073. }
  14074. // ResetNtype resets all changes to the "ntype" field.
  14075. func (m *CreditUsageMutation) ResetNtype() {
  14076. m.ntype = nil
  14077. m.addntype = nil
  14078. }
  14079. // SetTable sets the "table" field.
  14080. func (m *CreditUsageMutation) SetTable(s string) {
  14081. m.table = &s
  14082. }
  14083. // Table returns the value of the "table" field in the mutation.
  14084. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  14085. v := m.table
  14086. if v == nil {
  14087. return
  14088. }
  14089. return *v, true
  14090. }
  14091. // OldTable returns the old "table" field's value of the CreditUsage entity.
  14092. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14093. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14094. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  14095. if !m.op.Is(OpUpdateOne) {
  14096. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  14097. }
  14098. if m.id == nil || m.oldValue == nil {
  14099. return v, errors.New("OldTable requires an ID field in the mutation")
  14100. }
  14101. oldValue, err := m.oldValue(ctx)
  14102. if err != nil {
  14103. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  14104. }
  14105. return oldValue.Table, nil
  14106. }
  14107. // ResetTable resets all changes to the "table" field.
  14108. func (m *CreditUsageMutation) ResetTable() {
  14109. m.table = nil
  14110. }
  14111. // SetOrganizationID sets the "organization_id" field.
  14112. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  14113. m.organization_id = &u
  14114. m.addorganization_id = nil
  14115. }
  14116. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14117. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  14118. v := m.organization_id
  14119. if v == nil {
  14120. return
  14121. }
  14122. return *v, true
  14123. }
  14124. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  14125. // If the CreditUsage 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 *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14128. if !m.op.Is(OpUpdateOne) {
  14129. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14130. }
  14131. if m.id == nil || m.oldValue == nil {
  14132. return v, errors.New("OldOrganizationID 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 OldOrganizationID: %w", err)
  14137. }
  14138. return oldValue.OrganizationID, nil
  14139. }
  14140. // AddOrganizationID adds u to the "organization_id" field.
  14141. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  14142. if m.addorganization_id != nil {
  14143. *m.addorganization_id += u
  14144. } else {
  14145. m.addorganization_id = &u
  14146. }
  14147. }
  14148. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14149. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  14150. v := m.addorganization_id
  14151. if v == nil {
  14152. return
  14153. }
  14154. return *v, true
  14155. }
  14156. // ClearOrganizationID clears the value of the "organization_id" field.
  14157. func (m *CreditUsageMutation) ClearOrganizationID() {
  14158. m.organization_id = nil
  14159. m.addorganization_id = nil
  14160. m.clearedFields[creditusage.FieldOrganizationID] = struct{}{}
  14161. }
  14162. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14163. func (m *CreditUsageMutation) OrganizationIDCleared() bool {
  14164. _, ok := m.clearedFields[creditusage.FieldOrganizationID]
  14165. return ok
  14166. }
  14167. // ResetOrganizationID resets all changes to the "organization_id" field.
  14168. func (m *CreditUsageMutation) ResetOrganizationID() {
  14169. m.organization_id = nil
  14170. m.addorganization_id = nil
  14171. delete(m.clearedFields, creditusage.FieldOrganizationID)
  14172. }
  14173. // SetNid sets the "nid" field.
  14174. func (m *CreditUsageMutation) SetNid(u uint64) {
  14175. m.nid = &u
  14176. m.addnid = nil
  14177. }
  14178. // Nid returns the value of the "nid" field in the mutation.
  14179. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  14180. v := m.nid
  14181. if v == nil {
  14182. return
  14183. }
  14184. return *v, true
  14185. }
  14186. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  14187. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14189. func (m *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  14190. if !m.op.Is(OpUpdateOne) {
  14191. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  14192. }
  14193. if m.id == nil || m.oldValue == nil {
  14194. return v, errors.New("OldNid requires an ID field in the mutation")
  14195. }
  14196. oldValue, err := m.oldValue(ctx)
  14197. if err != nil {
  14198. return v, fmt.Errorf("querying old value for OldNid: %w", err)
  14199. }
  14200. return oldValue.Nid, nil
  14201. }
  14202. // AddNid adds u to the "nid" field.
  14203. func (m *CreditUsageMutation) AddNid(u int64) {
  14204. if m.addnid != nil {
  14205. *m.addnid += u
  14206. } else {
  14207. m.addnid = &u
  14208. }
  14209. }
  14210. // AddedNid returns the value that was added to the "nid" field in this mutation.
  14211. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  14212. v := m.addnid
  14213. if v == nil {
  14214. return
  14215. }
  14216. return *v, true
  14217. }
  14218. // ResetNid resets all changes to the "nid" field.
  14219. func (m *CreditUsageMutation) ResetNid() {
  14220. m.nid = nil
  14221. m.addnid = nil
  14222. }
  14223. // SetReason sets the "reason" field.
  14224. func (m *CreditUsageMutation) SetReason(s string) {
  14225. m.reason = &s
  14226. }
  14227. // Reason returns the value of the "reason" field in the mutation.
  14228. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  14229. v := m.reason
  14230. if v == nil {
  14231. return
  14232. }
  14233. return *v, true
  14234. }
  14235. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  14236. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14237. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14238. func (m *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  14239. if !m.op.Is(OpUpdateOne) {
  14240. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  14241. }
  14242. if m.id == nil || m.oldValue == nil {
  14243. return v, errors.New("OldReason requires an ID field in the mutation")
  14244. }
  14245. oldValue, err := m.oldValue(ctx)
  14246. if err != nil {
  14247. return v, fmt.Errorf("querying old value for OldReason: %w", err)
  14248. }
  14249. return oldValue.Reason, nil
  14250. }
  14251. // ResetReason resets all changes to the "reason" field.
  14252. func (m *CreditUsageMutation) ResetReason() {
  14253. m.reason = nil
  14254. }
  14255. // SetOperator sets the "operator" field.
  14256. func (m *CreditUsageMutation) SetOperator(s string) {
  14257. m.operator = &s
  14258. }
  14259. // Operator returns the value of the "operator" field in the mutation.
  14260. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  14261. v := m.operator
  14262. if v == nil {
  14263. return
  14264. }
  14265. return *v, true
  14266. }
  14267. // OldOperator returns the old "operator" field's value of the CreditUsage entity.
  14268. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14269. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14270. func (m *CreditUsageMutation) OldOperator(ctx context.Context) (v string, err error) {
  14271. if !m.op.Is(OpUpdateOne) {
  14272. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  14273. }
  14274. if m.id == nil || m.oldValue == nil {
  14275. return v, errors.New("OldOperator requires an ID field in the mutation")
  14276. }
  14277. oldValue, err := m.oldValue(ctx)
  14278. if err != nil {
  14279. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  14280. }
  14281. return oldValue.Operator, nil
  14282. }
  14283. // ResetOperator resets all changes to the "operator" field.
  14284. func (m *CreditUsageMutation) ResetOperator() {
  14285. m.operator = nil
  14286. }
  14287. // Where appends a list predicates to the CreditUsageMutation builder.
  14288. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  14289. m.predicates = append(m.predicates, ps...)
  14290. }
  14291. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  14292. // users can use type-assertion to append predicates that do not depend on any generated package.
  14293. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  14294. p := make([]predicate.CreditUsage, len(ps))
  14295. for i := range ps {
  14296. p[i] = ps[i]
  14297. }
  14298. m.Where(p...)
  14299. }
  14300. // Op returns the operation name.
  14301. func (m *CreditUsageMutation) Op() Op {
  14302. return m.op
  14303. }
  14304. // SetOp allows setting the mutation operation.
  14305. func (m *CreditUsageMutation) SetOp(op Op) {
  14306. m.op = op
  14307. }
  14308. // Type returns the node type of this mutation (CreditUsage).
  14309. func (m *CreditUsageMutation) Type() string {
  14310. return m.typ
  14311. }
  14312. // Fields returns all fields that were changed during this mutation. Note that in
  14313. // order to get all numeric fields that were incremented/decremented, call
  14314. // AddedFields().
  14315. func (m *CreditUsageMutation) Fields() []string {
  14316. fields := make([]string, 0, 12)
  14317. if m.created_at != nil {
  14318. fields = append(fields, creditusage.FieldCreatedAt)
  14319. }
  14320. if m.updated_at != nil {
  14321. fields = append(fields, creditusage.FieldUpdatedAt)
  14322. }
  14323. if m.deleted_at != nil {
  14324. fields = append(fields, creditusage.FieldDeletedAt)
  14325. }
  14326. if m.user_id != nil {
  14327. fields = append(fields, creditusage.FieldUserID)
  14328. }
  14329. if m.number != nil {
  14330. fields = append(fields, creditusage.FieldNumber)
  14331. }
  14332. if m.status != nil {
  14333. fields = append(fields, creditusage.FieldStatus)
  14334. }
  14335. if m.ntype != nil {
  14336. fields = append(fields, creditusage.FieldNtype)
  14337. }
  14338. if m.table != nil {
  14339. fields = append(fields, creditusage.FieldTable)
  14340. }
  14341. if m.organization_id != nil {
  14342. fields = append(fields, creditusage.FieldOrganizationID)
  14343. }
  14344. if m.nid != nil {
  14345. fields = append(fields, creditusage.FieldNid)
  14346. }
  14347. if m.reason != nil {
  14348. fields = append(fields, creditusage.FieldReason)
  14349. }
  14350. if m.operator != nil {
  14351. fields = append(fields, creditusage.FieldOperator)
  14352. }
  14353. return fields
  14354. }
  14355. // Field returns the value of a field with the given name. The second boolean
  14356. // return value indicates that this field was not set, or was not defined in the
  14357. // schema.
  14358. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  14359. switch name {
  14360. case creditusage.FieldCreatedAt:
  14361. return m.CreatedAt()
  14362. case creditusage.FieldUpdatedAt:
  14363. return m.UpdatedAt()
  14364. case creditusage.FieldDeletedAt:
  14365. return m.DeletedAt()
  14366. case creditusage.FieldUserID:
  14367. return m.UserID()
  14368. case creditusage.FieldNumber:
  14369. return m.Number()
  14370. case creditusage.FieldStatus:
  14371. return m.Status()
  14372. case creditusage.FieldNtype:
  14373. return m.Ntype()
  14374. case creditusage.FieldTable:
  14375. return m.Table()
  14376. case creditusage.FieldOrganizationID:
  14377. return m.OrganizationID()
  14378. case creditusage.FieldNid:
  14379. return m.Nid()
  14380. case creditusage.FieldReason:
  14381. return m.Reason()
  14382. case creditusage.FieldOperator:
  14383. return m.Operator()
  14384. }
  14385. return nil, false
  14386. }
  14387. // OldField returns the old value of the field from the database. An error is
  14388. // returned if the mutation operation is not UpdateOne, or the query to the
  14389. // database failed.
  14390. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14391. switch name {
  14392. case creditusage.FieldCreatedAt:
  14393. return m.OldCreatedAt(ctx)
  14394. case creditusage.FieldUpdatedAt:
  14395. return m.OldUpdatedAt(ctx)
  14396. case creditusage.FieldDeletedAt:
  14397. return m.OldDeletedAt(ctx)
  14398. case creditusage.FieldUserID:
  14399. return m.OldUserID(ctx)
  14400. case creditusage.FieldNumber:
  14401. return m.OldNumber(ctx)
  14402. case creditusage.FieldStatus:
  14403. return m.OldStatus(ctx)
  14404. case creditusage.FieldNtype:
  14405. return m.OldNtype(ctx)
  14406. case creditusage.FieldTable:
  14407. return m.OldTable(ctx)
  14408. case creditusage.FieldOrganizationID:
  14409. return m.OldOrganizationID(ctx)
  14410. case creditusage.FieldNid:
  14411. return m.OldNid(ctx)
  14412. case creditusage.FieldReason:
  14413. return m.OldReason(ctx)
  14414. case creditusage.FieldOperator:
  14415. return m.OldOperator(ctx)
  14416. }
  14417. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  14418. }
  14419. // SetField sets the value of a field with the given name. It returns an error if
  14420. // the field is not defined in the schema, or if the type mismatched the field
  14421. // type.
  14422. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  14423. switch name {
  14424. case creditusage.FieldCreatedAt:
  14425. v, ok := value.(time.Time)
  14426. if !ok {
  14427. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14428. }
  14429. m.SetCreatedAt(v)
  14430. return nil
  14431. case creditusage.FieldUpdatedAt:
  14432. v, ok := value.(time.Time)
  14433. if !ok {
  14434. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14435. }
  14436. m.SetUpdatedAt(v)
  14437. return nil
  14438. case creditusage.FieldDeletedAt:
  14439. v, ok := value.(time.Time)
  14440. if !ok {
  14441. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14442. }
  14443. m.SetDeletedAt(v)
  14444. return nil
  14445. case creditusage.FieldUserID:
  14446. v, ok := value.(string)
  14447. if !ok {
  14448. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14449. }
  14450. m.SetUserID(v)
  14451. return nil
  14452. case creditusage.FieldNumber:
  14453. v, ok := value.(float32)
  14454. if !ok {
  14455. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14456. }
  14457. m.SetNumber(v)
  14458. return nil
  14459. case creditusage.FieldStatus:
  14460. v, ok := value.(int)
  14461. if !ok {
  14462. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14463. }
  14464. m.SetStatus(v)
  14465. return nil
  14466. case creditusage.FieldNtype:
  14467. v, ok := value.(int)
  14468. if !ok {
  14469. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14470. }
  14471. m.SetNtype(v)
  14472. return nil
  14473. case creditusage.FieldTable:
  14474. v, ok := value.(string)
  14475. if !ok {
  14476. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14477. }
  14478. m.SetTable(v)
  14479. return nil
  14480. case creditusage.FieldOrganizationID:
  14481. v, ok := value.(uint64)
  14482. if !ok {
  14483. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14484. }
  14485. m.SetOrganizationID(v)
  14486. return nil
  14487. case creditusage.FieldNid:
  14488. v, ok := value.(uint64)
  14489. if !ok {
  14490. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14491. }
  14492. m.SetNid(v)
  14493. return nil
  14494. case creditusage.FieldReason:
  14495. v, ok := value.(string)
  14496. if !ok {
  14497. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14498. }
  14499. m.SetReason(v)
  14500. return nil
  14501. case creditusage.FieldOperator:
  14502. v, ok := value.(string)
  14503. if !ok {
  14504. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14505. }
  14506. m.SetOperator(v)
  14507. return nil
  14508. }
  14509. return fmt.Errorf("unknown CreditUsage field %s", name)
  14510. }
  14511. // AddedFields returns all numeric fields that were incremented/decremented during
  14512. // this mutation.
  14513. func (m *CreditUsageMutation) AddedFields() []string {
  14514. var fields []string
  14515. if m.addnumber != nil {
  14516. fields = append(fields, creditusage.FieldNumber)
  14517. }
  14518. if m.addstatus != nil {
  14519. fields = append(fields, creditusage.FieldStatus)
  14520. }
  14521. if m.addntype != nil {
  14522. fields = append(fields, creditusage.FieldNtype)
  14523. }
  14524. if m.addorganization_id != nil {
  14525. fields = append(fields, creditusage.FieldOrganizationID)
  14526. }
  14527. if m.addnid != nil {
  14528. fields = append(fields, creditusage.FieldNid)
  14529. }
  14530. return fields
  14531. }
  14532. // AddedField returns the numeric value that was incremented/decremented on a field
  14533. // with the given name. The second boolean return value indicates that this field
  14534. // was not set, or was not defined in the schema.
  14535. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  14536. switch name {
  14537. case creditusage.FieldNumber:
  14538. return m.AddedNumber()
  14539. case creditusage.FieldStatus:
  14540. return m.AddedStatus()
  14541. case creditusage.FieldNtype:
  14542. return m.AddedNtype()
  14543. case creditusage.FieldOrganizationID:
  14544. return m.AddedOrganizationID()
  14545. case creditusage.FieldNid:
  14546. return m.AddedNid()
  14547. }
  14548. return nil, false
  14549. }
  14550. // AddField adds the value to the field with the given name. It returns an error if
  14551. // the field is not defined in the schema, or if the type mismatched the field
  14552. // type.
  14553. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  14554. switch name {
  14555. case creditusage.FieldNumber:
  14556. v, ok := value.(float32)
  14557. if !ok {
  14558. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14559. }
  14560. m.AddNumber(v)
  14561. return nil
  14562. case creditusage.FieldStatus:
  14563. v, ok := value.(int)
  14564. if !ok {
  14565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14566. }
  14567. m.AddStatus(v)
  14568. return nil
  14569. case creditusage.FieldNtype:
  14570. v, ok := value.(int)
  14571. if !ok {
  14572. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14573. }
  14574. m.AddNtype(v)
  14575. return nil
  14576. case creditusage.FieldOrganizationID:
  14577. v, ok := value.(int64)
  14578. if !ok {
  14579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14580. }
  14581. m.AddOrganizationID(v)
  14582. return nil
  14583. case creditusage.FieldNid:
  14584. v, ok := value.(int64)
  14585. if !ok {
  14586. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14587. }
  14588. m.AddNid(v)
  14589. return nil
  14590. }
  14591. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  14592. }
  14593. // ClearedFields returns all nullable fields that were cleared during this
  14594. // mutation.
  14595. func (m *CreditUsageMutation) ClearedFields() []string {
  14596. var fields []string
  14597. if m.FieldCleared(creditusage.FieldDeletedAt) {
  14598. fields = append(fields, creditusage.FieldDeletedAt)
  14599. }
  14600. if m.FieldCleared(creditusage.FieldUserID) {
  14601. fields = append(fields, creditusage.FieldUserID)
  14602. }
  14603. if m.FieldCleared(creditusage.FieldStatus) {
  14604. fields = append(fields, creditusage.FieldStatus)
  14605. }
  14606. if m.FieldCleared(creditusage.FieldOrganizationID) {
  14607. fields = append(fields, creditusage.FieldOrganizationID)
  14608. }
  14609. return fields
  14610. }
  14611. // FieldCleared returns a boolean indicating if a field with the given name was
  14612. // cleared in this mutation.
  14613. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  14614. _, ok := m.clearedFields[name]
  14615. return ok
  14616. }
  14617. // ClearField clears the value of the field with the given name. It returns an
  14618. // error if the field is not defined in the schema.
  14619. func (m *CreditUsageMutation) ClearField(name string) error {
  14620. switch name {
  14621. case creditusage.FieldDeletedAt:
  14622. m.ClearDeletedAt()
  14623. return nil
  14624. case creditusage.FieldUserID:
  14625. m.ClearUserID()
  14626. return nil
  14627. case creditusage.FieldStatus:
  14628. m.ClearStatus()
  14629. return nil
  14630. case creditusage.FieldOrganizationID:
  14631. m.ClearOrganizationID()
  14632. return nil
  14633. }
  14634. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  14635. }
  14636. // ResetField resets all changes in the mutation for the field with the given name.
  14637. // It returns an error if the field is not defined in the schema.
  14638. func (m *CreditUsageMutation) ResetField(name string) error {
  14639. switch name {
  14640. case creditusage.FieldCreatedAt:
  14641. m.ResetCreatedAt()
  14642. return nil
  14643. case creditusage.FieldUpdatedAt:
  14644. m.ResetUpdatedAt()
  14645. return nil
  14646. case creditusage.FieldDeletedAt:
  14647. m.ResetDeletedAt()
  14648. return nil
  14649. case creditusage.FieldUserID:
  14650. m.ResetUserID()
  14651. return nil
  14652. case creditusage.FieldNumber:
  14653. m.ResetNumber()
  14654. return nil
  14655. case creditusage.FieldStatus:
  14656. m.ResetStatus()
  14657. return nil
  14658. case creditusage.FieldNtype:
  14659. m.ResetNtype()
  14660. return nil
  14661. case creditusage.FieldTable:
  14662. m.ResetTable()
  14663. return nil
  14664. case creditusage.FieldOrganizationID:
  14665. m.ResetOrganizationID()
  14666. return nil
  14667. case creditusage.FieldNid:
  14668. m.ResetNid()
  14669. return nil
  14670. case creditusage.FieldReason:
  14671. m.ResetReason()
  14672. return nil
  14673. case creditusage.FieldOperator:
  14674. m.ResetOperator()
  14675. return nil
  14676. }
  14677. return fmt.Errorf("unknown CreditUsage field %s", name)
  14678. }
  14679. // AddedEdges returns all edge names that were set/added in this mutation.
  14680. func (m *CreditUsageMutation) AddedEdges() []string {
  14681. edges := make([]string, 0, 0)
  14682. return edges
  14683. }
  14684. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14685. // name in this mutation.
  14686. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  14687. return nil
  14688. }
  14689. // RemovedEdges returns all edge names that were removed in this mutation.
  14690. func (m *CreditUsageMutation) RemovedEdges() []string {
  14691. edges := make([]string, 0, 0)
  14692. return edges
  14693. }
  14694. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14695. // the given name in this mutation.
  14696. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  14697. return nil
  14698. }
  14699. // ClearedEdges returns all edge names that were cleared in this mutation.
  14700. func (m *CreditUsageMutation) ClearedEdges() []string {
  14701. edges := make([]string, 0, 0)
  14702. return edges
  14703. }
  14704. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14705. // was cleared in this mutation.
  14706. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  14707. return false
  14708. }
  14709. // ClearEdge clears the value of the edge with the given name. It returns an error
  14710. // if that edge is not defined in the schema.
  14711. func (m *CreditUsageMutation) ClearEdge(name string) error {
  14712. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  14713. }
  14714. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14715. // It returns an error if the edge is not defined in the schema.
  14716. func (m *CreditUsageMutation) ResetEdge(name string) error {
  14717. return fmt.Errorf("unknown CreditUsage edge %s", name)
  14718. }
  14719. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  14720. type EmployeeMutation struct {
  14721. config
  14722. op Op
  14723. typ string
  14724. id *uint64
  14725. created_at *time.Time
  14726. updated_at *time.Time
  14727. deleted_at *time.Time
  14728. title *string
  14729. avatar *string
  14730. tags *string
  14731. hire_count *int
  14732. addhire_count *int
  14733. service_count *int
  14734. addservice_count *int
  14735. achievement_count *int
  14736. addachievement_count *int
  14737. intro *string
  14738. estimate *string
  14739. skill *string
  14740. ability_type *string
  14741. scene *string
  14742. switch_in *string
  14743. video_url *string
  14744. organization_id *uint64
  14745. addorganization_id *int64
  14746. category_id *uint64
  14747. addcategory_id *int64
  14748. api_base *string
  14749. api_key *string
  14750. ai_info *string
  14751. is_vip *int
  14752. addis_vip *int
  14753. chat_url *string
  14754. clearedFields map[string]struct{}
  14755. em_work_experiences map[uint64]struct{}
  14756. removedem_work_experiences map[uint64]struct{}
  14757. clearedem_work_experiences bool
  14758. em_tutorial map[uint64]struct{}
  14759. removedem_tutorial map[uint64]struct{}
  14760. clearedem_tutorial bool
  14761. done bool
  14762. oldValue func(context.Context) (*Employee, error)
  14763. predicates []predicate.Employee
  14764. }
  14765. var _ ent.Mutation = (*EmployeeMutation)(nil)
  14766. // employeeOption allows management of the mutation configuration using functional options.
  14767. type employeeOption func(*EmployeeMutation)
  14768. // newEmployeeMutation creates new mutation for the Employee entity.
  14769. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  14770. m := &EmployeeMutation{
  14771. config: c,
  14772. op: op,
  14773. typ: TypeEmployee,
  14774. clearedFields: make(map[string]struct{}),
  14775. }
  14776. for _, opt := range opts {
  14777. opt(m)
  14778. }
  14779. return m
  14780. }
  14781. // withEmployeeID sets the ID field of the mutation.
  14782. func withEmployeeID(id uint64) employeeOption {
  14783. return func(m *EmployeeMutation) {
  14784. var (
  14785. err error
  14786. once sync.Once
  14787. value *Employee
  14788. )
  14789. m.oldValue = func(ctx context.Context) (*Employee, error) {
  14790. once.Do(func() {
  14791. if m.done {
  14792. err = errors.New("querying old values post mutation is not allowed")
  14793. } else {
  14794. value, err = m.Client().Employee.Get(ctx, id)
  14795. }
  14796. })
  14797. return value, err
  14798. }
  14799. m.id = &id
  14800. }
  14801. }
  14802. // withEmployee sets the old Employee of the mutation.
  14803. func withEmployee(node *Employee) employeeOption {
  14804. return func(m *EmployeeMutation) {
  14805. m.oldValue = func(context.Context) (*Employee, error) {
  14806. return node, nil
  14807. }
  14808. m.id = &node.ID
  14809. }
  14810. }
  14811. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14812. // executed in a transaction (ent.Tx), a transactional client is returned.
  14813. func (m EmployeeMutation) Client() *Client {
  14814. client := &Client{config: m.config}
  14815. client.init()
  14816. return client
  14817. }
  14818. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14819. // it returns an error otherwise.
  14820. func (m EmployeeMutation) Tx() (*Tx, error) {
  14821. if _, ok := m.driver.(*txDriver); !ok {
  14822. return nil, errors.New("ent: mutation is not running in a transaction")
  14823. }
  14824. tx := &Tx{config: m.config}
  14825. tx.init()
  14826. return tx, nil
  14827. }
  14828. // SetID sets the value of the id field. Note that this
  14829. // operation is only accepted on creation of Employee entities.
  14830. func (m *EmployeeMutation) SetID(id uint64) {
  14831. m.id = &id
  14832. }
  14833. // ID returns the ID value in the mutation. Note that the ID is only available
  14834. // if it was provided to the builder or after it was returned from the database.
  14835. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  14836. if m.id == nil {
  14837. return
  14838. }
  14839. return *m.id, true
  14840. }
  14841. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14842. // That means, if the mutation is applied within a transaction with an isolation level such
  14843. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14844. // or updated by the mutation.
  14845. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  14846. switch {
  14847. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14848. id, exists := m.ID()
  14849. if exists {
  14850. return []uint64{id}, nil
  14851. }
  14852. fallthrough
  14853. case m.op.Is(OpUpdate | OpDelete):
  14854. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  14855. default:
  14856. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14857. }
  14858. }
  14859. // SetCreatedAt sets the "created_at" field.
  14860. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  14861. m.created_at = &t
  14862. }
  14863. // CreatedAt returns the value of the "created_at" field in the mutation.
  14864. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  14865. v := m.created_at
  14866. if v == nil {
  14867. return
  14868. }
  14869. return *v, true
  14870. }
  14871. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  14872. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14873. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14874. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14875. if !m.op.Is(OpUpdateOne) {
  14876. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14877. }
  14878. if m.id == nil || m.oldValue == nil {
  14879. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14880. }
  14881. oldValue, err := m.oldValue(ctx)
  14882. if err != nil {
  14883. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14884. }
  14885. return oldValue.CreatedAt, nil
  14886. }
  14887. // ResetCreatedAt resets all changes to the "created_at" field.
  14888. func (m *EmployeeMutation) ResetCreatedAt() {
  14889. m.created_at = nil
  14890. }
  14891. // SetUpdatedAt sets the "updated_at" field.
  14892. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  14893. m.updated_at = &t
  14894. }
  14895. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14896. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  14897. v := m.updated_at
  14898. if v == nil {
  14899. return
  14900. }
  14901. return *v, true
  14902. }
  14903. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  14904. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14905. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14906. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14907. if !m.op.Is(OpUpdateOne) {
  14908. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14909. }
  14910. if m.id == nil || m.oldValue == nil {
  14911. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14912. }
  14913. oldValue, err := m.oldValue(ctx)
  14914. if err != nil {
  14915. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14916. }
  14917. return oldValue.UpdatedAt, nil
  14918. }
  14919. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14920. func (m *EmployeeMutation) ResetUpdatedAt() {
  14921. m.updated_at = nil
  14922. }
  14923. // SetDeletedAt sets the "deleted_at" field.
  14924. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  14925. m.deleted_at = &t
  14926. }
  14927. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14928. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  14929. v := m.deleted_at
  14930. if v == nil {
  14931. return
  14932. }
  14933. return *v, true
  14934. }
  14935. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  14936. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14937. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14938. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14939. if !m.op.Is(OpUpdateOne) {
  14940. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14941. }
  14942. if m.id == nil || m.oldValue == nil {
  14943. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14944. }
  14945. oldValue, err := m.oldValue(ctx)
  14946. if err != nil {
  14947. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14948. }
  14949. return oldValue.DeletedAt, nil
  14950. }
  14951. // ClearDeletedAt clears the value of the "deleted_at" field.
  14952. func (m *EmployeeMutation) ClearDeletedAt() {
  14953. m.deleted_at = nil
  14954. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  14955. }
  14956. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14957. func (m *EmployeeMutation) DeletedAtCleared() bool {
  14958. _, ok := m.clearedFields[employee.FieldDeletedAt]
  14959. return ok
  14960. }
  14961. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14962. func (m *EmployeeMutation) ResetDeletedAt() {
  14963. m.deleted_at = nil
  14964. delete(m.clearedFields, employee.FieldDeletedAt)
  14965. }
  14966. // SetTitle sets the "title" field.
  14967. func (m *EmployeeMutation) SetTitle(s string) {
  14968. m.title = &s
  14969. }
  14970. // Title returns the value of the "title" field in the mutation.
  14971. func (m *EmployeeMutation) Title() (r string, exists bool) {
  14972. v := m.title
  14973. if v == nil {
  14974. return
  14975. }
  14976. return *v, true
  14977. }
  14978. // OldTitle returns the old "title" field's value of the Employee entity.
  14979. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14980. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14981. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  14982. if !m.op.Is(OpUpdateOne) {
  14983. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  14984. }
  14985. if m.id == nil || m.oldValue == nil {
  14986. return v, errors.New("OldTitle requires an ID field in the mutation")
  14987. }
  14988. oldValue, err := m.oldValue(ctx)
  14989. if err != nil {
  14990. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  14991. }
  14992. return oldValue.Title, nil
  14993. }
  14994. // ResetTitle resets all changes to the "title" field.
  14995. func (m *EmployeeMutation) ResetTitle() {
  14996. m.title = nil
  14997. }
  14998. // SetAvatar sets the "avatar" field.
  14999. func (m *EmployeeMutation) SetAvatar(s string) {
  15000. m.avatar = &s
  15001. }
  15002. // Avatar returns the value of the "avatar" field in the mutation.
  15003. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  15004. v := m.avatar
  15005. if v == nil {
  15006. return
  15007. }
  15008. return *v, true
  15009. }
  15010. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  15011. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15013. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  15014. if !m.op.Is(OpUpdateOne) {
  15015. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  15016. }
  15017. if m.id == nil || m.oldValue == nil {
  15018. return v, errors.New("OldAvatar requires an ID field in the mutation")
  15019. }
  15020. oldValue, err := m.oldValue(ctx)
  15021. if err != nil {
  15022. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  15023. }
  15024. return oldValue.Avatar, nil
  15025. }
  15026. // ResetAvatar resets all changes to the "avatar" field.
  15027. func (m *EmployeeMutation) ResetAvatar() {
  15028. m.avatar = nil
  15029. }
  15030. // SetTags sets the "tags" field.
  15031. func (m *EmployeeMutation) SetTags(s string) {
  15032. m.tags = &s
  15033. }
  15034. // Tags returns the value of the "tags" field in the mutation.
  15035. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  15036. v := m.tags
  15037. if v == nil {
  15038. return
  15039. }
  15040. return *v, true
  15041. }
  15042. // OldTags returns the old "tags" field's value of the Employee entity.
  15043. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15045. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  15046. if !m.op.Is(OpUpdateOne) {
  15047. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  15048. }
  15049. if m.id == nil || m.oldValue == nil {
  15050. return v, errors.New("OldTags requires an ID field in the mutation")
  15051. }
  15052. oldValue, err := m.oldValue(ctx)
  15053. if err != nil {
  15054. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  15055. }
  15056. return oldValue.Tags, nil
  15057. }
  15058. // ResetTags resets all changes to the "tags" field.
  15059. func (m *EmployeeMutation) ResetTags() {
  15060. m.tags = nil
  15061. }
  15062. // SetHireCount sets the "hire_count" field.
  15063. func (m *EmployeeMutation) SetHireCount(i int) {
  15064. m.hire_count = &i
  15065. m.addhire_count = nil
  15066. }
  15067. // HireCount returns the value of the "hire_count" field in the mutation.
  15068. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  15069. v := m.hire_count
  15070. if v == nil {
  15071. return
  15072. }
  15073. return *v, true
  15074. }
  15075. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  15076. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15077. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15078. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  15079. if !m.op.Is(OpUpdateOne) {
  15080. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  15081. }
  15082. if m.id == nil || m.oldValue == nil {
  15083. return v, errors.New("OldHireCount requires an ID field in the mutation")
  15084. }
  15085. oldValue, err := m.oldValue(ctx)
  15086. if err != nil {
  15087. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  15088. }
  15089. return oldValue.HireCount, nil
  15090. }
  15091. // AddHireCount adds i to the "hire_count" field.
  15092. func (m *EmployeeMutation) AddHireCount(i int) {
  15093. if m.addhire_count != nil {
  15094. *m.addhire_count += i
  15095. } else {
  15096. m.addhire_count = &i
  15097. }
  15098. }
  15099. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  15100. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  15101. v := m.addhire_count
  15102. if v == nil {
  15103. return
  15104. }
  15105. return *v, true
  15106. }
  15107. // ResetHireCount resets all changes to the "hire_count" field.
  15108. func (m *EmployeeMutation) ResetHireCount() {
  15109. m.hire_count = nil
  15110. m.addhire_count = nil
  15111. }
  15112. // SetServiceCount sets the "service_count" field.
  15113. func (m *EmployeeMutation) SetServiceCount(i int) {
  15114. m.service_count = &i
  15115. m.addservice_count = nil
  15116. }
  15117. // ServiceCount returns the value of the "service_count" field in the mutation.
  15118. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  15119. v := m.service_count
  15120. if v == nil {
  15121. return
  15122. }
  15123. return *v, true
  15124. }
  15125. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  15126. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15127. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15128. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  15129. if !m.op.Is(OpUpdateOne) {
  15130. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  15131. }
  15132. if m.id == nil || m.oldValue == nil {
  15133. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  15134. }
  15135. oldValue, err := m.oldValue(ctx)
  15136. if err != nil {
  15137. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  15138. }
  15139. return oldValue.ServiceCount, nil
  15140. }
  15141. // AddServiceCount adds i to the "service_count" field.
  15142. func (m *EmployeeMutation) AddServiceCount(i int) {
  15143. if m.addservice_count != nil {
  15144. *m.addservice_count += i
  15145. } else {
  15146. m.addservice_count = &i
  15147. }
  15148. }
  15149. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  15150. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  15151. v := m.addservice_count
  15152. if v == nil {
  15153. return
  15154. }
  15155. return *v, true
  15156. }
  15157. // ResetServiceCount resets all changes to the "service_count" field.
  15158. func (m *EmployeeMutation) ResetServiceCount() {
  15159. m.service_count = nil
  15160. m.addservice_count = nil
  15161. }
  15162. // SetAchievementCount sets the "achievement_count" field.
  15163. func (m *EmployeeMutation) SetAchievementCount(i int) {
  15164. m.achievement_count = &i
  15165. m.addachievement_count = nil
  15166. }
  15167. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  15168. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  15169. v := m.achievement_count
  15170. if v == nil {
  15171. return
  15172. }
  15173. return *v, true
  15174. }
  15175. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  15176. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15177. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15178. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  15179. if !m.op.Is(OpUpdateOne) {
  15180. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  15181. }
  15182. if m.id == nil || m.oldValue == nil {
  15183. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  15184. }
  15185. oldValue, err := m.oldValue(ctx)
  15186. if err != nil {
  15187. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  15188. }
  15189. return oldValue.AchievementCount, nil
  15190. }
  15191. // AddAchievementCount adds i to the "achievement_count" field.
  15192. func (m *EmployeeMutation) AddAchievementCount(i int) {
  15193. if m.addachievement_count != nil {
  15194. *m.addachievement_count += i
  15195. } else {
  15196. m.addachievement_count = &i
  15197. }
  15198. }
  15199. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  15200. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  15201. v := m.addachievement_count
  15202. if v == nil {
  15203. return
  15204. }
  15205. return *v, true
  15206. }
  15207. // ResetAchievementCount resets all changes to the "achievement_count" field.
  15208. func (m *EmployeeMutation) ResetAchievementCount() {
  15209. m.achievement_count = nil
  15210. m.addachievement_count = nil
  15211. }
  15212. // SetIntro sets the "intro" field.
  15213. func (m *EmployeeMutation) SetIntro(s string) {
  15214. m.intro = &s
  15215. }
  15216. // Intro returns the value of the "intro" field in the mutation.
  15217. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  15218. v := m.intro
  15219. if v == nil {
  15220. return
  15221. }
  15222. return *v, true
  15223. }
  15224. // OldIntro returns the old "intro" field's value of the Employee entity.
  15225. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15226. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15227. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  15228. if !m.op.Is(OpUpdateOne) {
  15229. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  15230. }
  15231. if m.id == nil || m.oldValue == nil {
  15232. return v, errors.New("OldIntro requires an ID field in the mutation")
  15233. }
  15234. oldValue, err := m.oldValue(ctx)
  15235. if err != nil {
  15236. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  15237. }
  15238. return oldValue.Intro, nil
  15239. }
  15240. // ResetIntro resets all changes to the "intro" field.
  15241. func (m *EmployeeMutation) ResetIntro() {
  15242. m.intro = nil
  15243. }
  15244. // SetEstimate sets the "estimate" field.
  15245. func (m *EmployeeMutation) SetEstimate(s string) {
  15246. m.estimate = &s
  15247. }
  15248. // Estimate returns the value of the "estimate" field in the mutation.
  15249. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  15250. v := m.estimate
  15251. if v == nil {
  15252. return
  15253. }
  15254. return *v, true
  15255. }
  15256. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  15257. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15258. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15259. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  15260. if !m.op.Is(OpUpdateOne) {
  15261. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  15262. }
  15263. if m.id == nil || m.oldValue == nil {
  15264. return v, errors.New("OldEstimate requires an ID field in the mutation")
  15265. }
  15266. oldValue, err := m.oldValue(ctx)
  15267. if err != nil {
  15268. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  15269. }
  15270. return oldValue.Estimate, nil
  15271. }
  15272. // ResetEstimate resets all changes to the "estimate" field.
  15273. func (m *EmployeeMutation) ResetEstimate() {
  15274. m.estimate = nil
  15275. }
  15276. // SetSkill sets the "skill" field.
  15277. func (m *EmployeeMutation) SetSkill(s string) {
  15278. m.skill = &s
  15279. }
  15280. // Skill returns the value of the "skill" field in the mutation.
  15281. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  15282. v := m.skill
  15283. if v == nil {
  15284. return
  15285. }
  15286. return *v, true
  15287. }
  15288. // OldSkill returns the old "skill" field's value of the Employee entity.
  15289. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15290. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15291. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  15292. if !m.op.Is(OpUpdateOne) {
  15293. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  15294. }
  15295. if m.id == nil || m.oldValue == nil {
  15296. return v, errors.New("OldSkill requires an ID field in the mutation")
  15297. }
  15298. oldValue, err := m.oldValue(ctx)
  15299. if err != nil {
  15300. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  15301. }
  15302. return oldValue.Skill, nil
  15303. }
  15304. // ResetSkill resets all changes to the "skill" field.
  15305. func (m *EmployeeMutation) ResetSkill() {
  15306. m.skill = nil
  15307. }
  15308. // SetAbilityType sets the "ability_type" field.
  15309. func (m *EmployeeMutation) SetAbilityType(s string) {
  15310. m.ability_type = &s
  15311. }
  15312. // AbilityType returns the value of the "ability_type" field in the mutation.
  15313. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  15314. v := m.ability_type
  15315. if v == nil {
  15316. return
  15317. }
  15318. return *v, true
  15319. }
  15320. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  15321. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15322. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15323. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  15324. if !m.op.Is(OpUpdateOne) {
  15325. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  15326. }
  15327. if m.id == nil || m.oldValue == nil {
  15328. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  15329. }
  15330. oldValue, err := m.oldValue(ctx)
  15331. if err != nil {
  15332. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  15333. }
  15334. return oldValue.AbilityType, nil
  15335. }
  15336. // ResetAbilityType resets all changes to the "ability_type" field.
  15337. func (m *EmployeeMutation) ResetAbilityType() {
  15338. m.ability_type = nil
  15339. }
  15340. // SetScene sets the "scene" field.
  15341. func (m *EmployeeMutation) SetScene(s string) {
  15342. m.scene = &s
  15343. }
  15344. // Scene returns the value of the "scene" field in the mutation.
  15345. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  15346. v := m.scene
  15347. if v == nil {
  15348. return
  15349. }
  15350. return *v, true
  15351. }
  15352. // OldScene returns the old "scene" field's value of the Employee entity.
  15353. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15354. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15355. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  15356. if !m.op.Is(OpUpdateOne) {
  15357. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  15358. }
  15359. if m.id == nil || m.oldValue == nil {
  15360. return v, errors.New("OldScene requires an ID field in the mutation")
  15361. }
  15362. oldValue, err := m.oldValue(ctx)
  15363. if err != nil {
  15364. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  15365. }
  15366. return oldValue.Scene, nil
  15367. }
  15368. // ResetScene resets all changes to the "scene" field.
  15369. func (m *EmployeeMutation) ResetScene() {
  15370. m.scene = nil
  15371. }
  15372. // SetSwitchIn sets the "switch_in" field.
  15373. func (m *EmployeeMutation) SetSwitchIn(s string) {
  15374. m.switch_in = &s
  15375. }
  15376. // SwitchIn returns the value of the "switch_in" field in the mutation.
  15377. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  15378. v := m.switch_in
  15379. if v == nil {
  15380. return
  15381. }
  15382. return *v, true
  15383. }
  15384. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  15385. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15386. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15387. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  15388. if !m.op.Is(OpUpdateOne) {
  15389. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  15390. }
  15391. if m.id == nil || m.oldValue == nil {
  15392. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  15393. }
  15394. oldValue, err := m.oldValue(ctx)
  15395. if err != nil {
  15396. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  15397. }
  15398. return oldValue.SwitchIn, nil
  15399. }
  15400. // ResetSwitchIn resets all changes to the "switch_in" field.
  15401. func (m *EmployeeMutation) ResetSwitchIn() {
  15402. m.switch_in = nil
  15403. }
  15404. // SetVideoURL sets the "video_url" field.
  15405. func (m *EmployeeMutation) SetVideoURL(s string) {
  15406. m.video_url = &s
  15407. }
  15408. // VideoURL returns the value of the "video_url" field in the mutation.
  15409. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  15410. v := m.video_url
  15411. if v == nil {
  15412. return
  15413. }
  15414. return *v, true
  15415. }
  15416. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  15417. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15418. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15419. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  15420. if !m.op.Is(OpUpdateOne) {
  15421. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  15422. }
  15423. if m.id == nil || m.oldValue == nil {
  15424. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  15425. }
  15426. oldValue, err := m.oldValue(ctx)
  15427. if err != nil {
  15428. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  15429. }
  15430. return oldValue.VideoURL, nil
  15431. }
  15432. // ResetVideoURL resets all changes to the "video_url" field.
  15433. func (m *EmployeeMutation) ResetVideoURL() {
  15434. m.video_url = nil
  15435. }
  15436. // SetOrganizationID sets the "organization_id" field.
  15437. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  15438. m.organization_id = &u
  15439. m.addorganization_id = nil
  15440. }
  15441. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15442. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  15443. v := m.organization_id
  15444. if v == nil {
  15445. return
  15446. }
  15447. return *v, true
  15448. }
  15449. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  15450. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15451. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15452. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15453. if !m.op.Is(OpUpdateOne) {
  15454. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15455. }
  15456. if m.id == nil || m.oldValue == nil {
  15457. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15458. }
  15459. oldValue, err := m.oldValue(ctx)
  15460. if err != nil {
  15461. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15462. }
  15463. return oldValue.OrganizationID, nil
  15464. }
  15465. // AddOrganizationID adds u to the "organization_id" field.
  15466. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  15467. if m.addorganization_id != nil {
  15468. *m.addorganization_id += u
  15469. } else {
  15470. m.addorganization_id = &u
  15471. }
  15472. }
  15473. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15474. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  15475. v := m.addorganization_id
  15476. if v == nil {
  15477. return
  15478. }
  15479. return *v, true
  15480. }
  15481. // ResetOrganizationID resets all changes to the "organization_id" field.
  15482. func (m *EmployeeMutation) ResetOrganizationID() {
  15483. m.organization_id = nil
  15484. m.addorganization_id = nil
  15485. }
  15486. // SetCategoryID sets the "category_id" field.
  15487. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  15488. m.category_id = &u
  15489. m.addcategory_id = nil
  15490. }
  15491. // CategoryID returns the value of the "category_id" field in the mutation.
  15492. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  15493. v := m.category_id
  15494. if v == nil {
  15495. return
  15496. }
  15497. return *v, true
  15498. }
  15499. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  15500. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15501. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15502. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  15503. if !m.op.Is(OpUpdateOne) {
  15504. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  15505. }
  15506. if m.id == nil || m.oldValue == nil {
  15507. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  15508. }
  15509. oldValue, err := m.oldValue(ctx)
  15510. if err != nil {
  15511. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  15512. }
  15513. return oldValue.CategoryID, nil
  15514. }
  15515. // AddCategoryID adds u to the "category_id" field.
  15516. func (m *EmployeeMutation) AddCategoryID(u int64) {
  15517. if m.addcategory_id != nil {
  15518. *m.addcategory_id += u
  15519. } else {
  15520. m.addcategory_id = &u
  15521. }
  15522. }
  15523. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  15524. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  15525. v := m.addcategory_id
  15526. if v == nil {
  15527. return
  15528. }
  15529. return *v, true
  15530. }
  15531. // ResetCategoryID resets all changes to the "category_id" field.
  15532. func (m *EmployeeMutation) ResetCategoryID() {
  15533. m.category_id = nil
  15534. m.addcategory_id = nil
  15535. }
  15536. // SetAPIBase sets the "api_base" field.
  15537. func (m *EmployeeMutation) SetAPIBase(s string) {
  15538. m.api_base = &s
  15539. }
  15540. // APIBase returns the value of the "api_base" field in the mutation.
  15541. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  15542. v := m.api_base
  15543. if v == nil {
  15544. return
  15545. }
  15546. return *v, true
  15547. }
  15548. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  15549. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15550. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15551. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  15552. if !m.op.Is(OpUpdateOne) {
  15553. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  15554. }
  15555. if m.id == nil || m.oldValue == nil {
  15556. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  15557. }
  15558. oldValue, err := m.oldValue(ctx)
  15559. if err != nil {
  15560. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  15561. }
  15562. return oldValue.APIBase, nil
  15563. }
  15564. // ResetAPIBase resets all changes to the "api_base" field.
  15565. func (m *EmployeeMutation) ResetAPIBase() {
  15566. m.api_base = nil
  15567. }
  15568. // SetAPIKey sets the "api_key" field.
  15569. func (m *EmployeeMutation) SetAPIKey(s string) {
  15570. m.api_key = &s
  15571. }
  15572. // APIKey returns the value of the "api_key" field in the mutation.
  15573. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  15574. v := m.api_key
  15575. if v == nil {
  15576. return
  15577. }
  15578. return *v, true
  15579. }
  15580. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  15581. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15582. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15583. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  15584. if !m.op.Is(OpUpdateOne) {
  15585. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  15586. }
  15587. if m.id == nil || m.oldValue == nil {
  15588. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  15589. }
  15590. oldValue, err := m.oldValue(ctx)
  15591. if err != nil {
  15592. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  15593. }
  15594. return oldValue.APIKey, nil
  15595. }
  15596. // ResetAPIKey resets all changes to the "api_key" field.
  15597. func (m *EmployeeMutation) ResetAPIKey() {
  15598. m.api_key = nil
  15599. }
  15600. // SetAiInfo sets the "ai_info" field.
  15601. func (m *EmployeeMutation) SetAiInfo(s string) {
  15602. m.ai_info = &s
  15603. }
  15604. // AiInfo returns the value of the "ai_info" field in the mutation.
  15605. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  15606. v := m.ai_info
  15607. if v == nil {
  15608. return
  15609. }
  15610. return *v, true
  15611. }
  15612. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  15613. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15614. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15615. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  15616. if !m.op.Is(OpUpdateOne) {
  15617. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  15618. }
  15619. if m.id == nil || m.oldValue == nil {
  15620. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  15621. }
  15622. oldValue, err := m.oldValue(ctx)
  15623. if err != nil {
  15624. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  15625. }
  15626. return oldValue.AiInfo, nil
  15627. }
  15628. // ClearAiInfo clears the value of the "ai_info" field.
  15629. func (m *EmployeeMutation) ClearAiInfo() {
  15630. m.ai_info = nil
  15631. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  15632. }
  15633. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  15634. func (m *EmployeeMutation) AiInfoCleared() bool {
  15635. _, ok := m.clearedFields[employee.FieldAiInfo]
  15636. return ok
  15637. }
  15638. // ResetAiInfo resets all changes to the "ai_info" field.
  15639. func (m *EmployeeMutation) ResetAiInfo() {
  15640. m.ai_info = nil
  15641. delete(m.clearedFields, employee.FieldAiInfo)
  15642. }
  15643. // SetIsVip sets the "is_vip" field.
  15644. func (m *EmployeeMutation) SetIsVip(i int) {
  15645. m.is_vip = &i
  15646. m.addis_vip = nil
  15647. }
  15648. // IsVip returns the value of the "is_vip" field in the mutation.
  15649. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  15650. v := m.is_vip
  15651. if v == nil {
  15652. return
  15653. }
  15654. return *v, true
  15655. }
  15656. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  15657. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15658. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15659. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  15660. if !m.op.Is(OpUpdateOne) {
  15661. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  15662. }
  15663. if m.id == nil || m.oldValue == nil {
  15664. return v, errors.New("OldIsVip requires an ID field in the mutation")
  15665. }
  15666. oldValue, err := m.oldValue(ctx)
  15667. if err != nil {
  15668. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  15669. }
  15670. return oldValue.IsVip, nil
  15671. }
  15672. // AddIsVip adds i to the "is_vip" field.
  15673. func (m *EmployeeMutation) AddIsVip(i int) {
  15674. if m.addis_vip != nil {
  15675. *m.addis_vip += i
  15676. } else {
  15677. m.addis_vip = &i
  15678. }
  15679. }
  15680. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  15681. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  15682. v := m.addis_vip
  15683. if v == nil {
  15684. return
  15685. }
  15686. return *v, true
  15687. }
  15688. // ResetIsVip resets all changes to the "is_vip" field.
  15689. func (m *EmployeeMutation) ResetIsVip() {
  15690. m.is_vip = nil
  15691. m.addis_vip = nil
  15692. }
  15693. // SetChatURL sets the "chat_url" field.
  15694. func (m *EmployeeMutation) SetChatURL(s string) {
  15695. m.chat_url = &s
  15696. }
  15697. // ChatURL returns the value of the "chat_url" field in the mutation.
  15698. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  15699. v := m.chat_url
  15700. if v == nil {
  15701. return
  15702. }
  15703. return *v, true
  15704. }
  15705. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  15706. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15707. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15708. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  15709. if !m.op.Is(OpUpdateOne) {
  15710. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  15711. }
  15712. if m.id == nil || m.oldValue == nil {
  15713. return v, errors.New("OldChatURL requires an ID field in the mutation")
  15714. }
  15715. oldValue, err := m.oldValue(ctx)
  15716. if err != nil {
  15717. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  15718. }
  15719. return oldValue.ChatURL, nil
  15720. }
  15721. // ResetChatURL resets all changes to the "chat_url" field.
  15722. func (m *EmployeeMutation) ResetChatURL() {
  15723. m.chat_url = nil
  15724. }
  15725. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  15726. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  15727. if m.em_work_experiences == nil {
  15728. m.em_work_experiences = make(map[uint64]struct{})
  15729. }
  15730. for i := range ids {
  15731. m.em_work_experiences[ids[i]] = struct{}{}
  15732. }
  15733. }
  15734. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  15735. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  15736. m.clearedem_work_experiences = true
  15737. }
  15738. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  15739. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  15740. return m.clearedem_work_experiences
  15741. }
  15742. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  15743. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  15744. if m.removedem_work_experiences == nil {
  15745. m.removedem_work_experiences = make(map[uint64]struct{})
  15746. }
  15747. for i := range ids {
  15748. delete(m.em_work_experiences, ids[i])
  15749. m.removedem_work_experiences[ids[i]] = struct{}{}
  15750. }
  15751. }
  15752. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  15753. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  15754. for id := range m.removedem_work_experiences {
  15755. ids = append(ids, id)
  15756. }
  15757. return
  15758. }
  15759. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  15760. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  15761. for id := range m.em_work_experiences {
  15762. ids = append(ids, id)
  15763. }
  15764. return
  15765. }
  15766. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  15767. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  15768. m.em_work_experiences = nil
  15769. m.clearedem_work_experiences = false
  15770. m.removedem_work_experiences = nil
  15771. }
  15772. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  15773. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  15774. if m.em_tutorial == nil {
  15775. m.em_tutorial = make(map[uint64]struct{})
  15776. }
  15777. for i := range ids {
  15778. m.em_tutorial[ids[i]] = struct{}{}
  15779. }
  15780. }
  15781. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  15782. func (m *EmployeeMutation) ClearEmTutorial() {
  15783. m.clearedem_tutorial = true
  15784. }
  15785. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  15786. func (m *EmployeeMutation) EmTutorialCleared() bool {
  15787. return m.clearedem_tutorial
  15788. }
  15789. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  15790. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  15791. if m.removedem_tutorial == nil {
  15792. m.removedem_tutorial = make(map[uint64]struct{})
  15793. }
  15794. for i := range ids {
  15795. delete(m.em_tutorial, ids[i])
  15796. m.removedem_tutorial[ids[i]] = struct{}{}
  15797. }
  15798. }
  15799. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  15800. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  15801. for id := range m.removedem_tutorial {
  15802. ids = append(ids, id)
  15803. }
  15804. return
  15805. }
  15806. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  15807. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  15808. for id := range m.em_tutorial {
  15809. ids = append(ids, id)
  15810. }
  15811. return
  15812. }
  15813. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  15814. func (m *EmployeeMutation) ResetEmTutorial() {
  15815. m.em_tutorial = nil
  15816. m.clearedem_tutorial = false
  15817. m.removedem_tutorial = nil
  15818. }
  15819. // Where appends a list predicates to the EmployeeMutation builder.
  15820. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  15821. m.predicates = append(m.predicates, ps...)
  15822. }
  15823. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  15824. // users can use type-assertion to append predicates that do not depend on any generated package.
  15825. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  15826. p := make([]predicate.Employee, len(ps))
  15827. for i := range ps {
  15828. p[i] = ps[i]
  15829. }
  15830. m.Where(p...)
  15831. }
  15832. // Op returns the operation name.
  15833. func (m *EmployeeMutation) Op() Op {
  15834. return m.op
  15835. }
  15836. // SetOp allows setting the mutation operation.
  15837. func (m *EmployeeMutation) SetOp(op Op) {
  15838. m.op = op
  15839. }
  15840. // Type returns the node type of this mutation (Employee).
  15841. func (m *EmployeeMutation) Type() string {
  15842. return m.typ
  15843. }
  15844. // Fields returns all fields that were changed during this mutation. Note that in
  15845. // order to get all numeric fields that were incremented/decremented, call
  15846. // AddedFields().
  15847. func (m *EmployeeMutation) Fields() []string {
  15848. fields := make([]string, 0, 23)
  15849. if m.created_at != nil {
  15850. fields = append(fields, employee.FieldCreatedAt)
  15851. }
  15852. if m.updated_at != nil {
  15853. fields = append(fields, employee.FieldUpdatedAt)
  15854. }
  15855. if m.deleted_at != nil {
  15856. fields = append(fields, employee.FieldDeletedAt)
  15857. }
  15858. if m.title != nil {
  15859. fields = append(fields, employee.FieldTitle)
  15860. }
  15861. if m.avatar != nil {
  15862. fields = append(fields, employee.FieldAvatar)
  15863. }
  15864. if m.tags != nil {
  15865. fields = append(fields, employee.FieldTags)
  15866. }
  15867. if m.hire_count != nil {
  15868. fields = append(fields, employee.FieldHireCount)
  15869. }
  15870. if m.service_count != nil {
  15871. fields = append(fields, employee.FieldServiceCount)
  15872. }
  15873. if m.achievement_count != nil {
  15874. fields = append(fields, employee.FieldAchievementCount)
  15875. }
  15876. if m.intro != nil {
  15877. fields = append(fields, employee.FieldIntro)
  15878. }
  15879. if m.estimate != nil {
  15880. fields = append(fields, employee.FieldEstimate)
  15881. }
  15882. if m.skill != nil {
  15883. fields = append(fields, employee.FieldSkill)
  15884. }
  15885. if m.ability_type != nil {
  15886. fields = append(fields, employee.FieldAbilityType)
  15887. }
  15888. if m.scene != nil {
  15889. fields = append(fields, employee.FieldScene)
  15890. }
  15891. if m.switch_in != nil {
  15892. fields = append(fields, employee.FieldSwitchIn)
  15893. }
  15894. if m.video_url != nil {
  15895. fields = append(fields, employee.FieldVideoURL)
  15896. }
  15897. if m.organization_id != nil {
  15898. fields = append(fields, employee.FieldOrganizationID)
  15899. }
  15900. if m.category_id != nil {
  15901. fields = append(fields, employee.FieldCategoryID)
  15902. }
  15903. if m.api_base != nil {
  15904. fields = append(fields, employee.FieldAPIBase)
  15905. }
  15906. if m.api_key != nil {
  15907. fields = append(fields, employee.FieldAPIKey)
  15908. }
  15909. if m.ai_info != nil {
  15910. fields = append(fields, employee.FieldAiInfo)
  15911. }
  15912. if m.is_vip != nil {
  15913. fields = append(fields, employee.FieldIsVip)
  15914. }
  15915. if m.chat_url != nil {
  15916. fields = append(fields, employee.FieldChatURL)
  15917. }
  15918. return fields
  15919. }
  15920. // Field returns the value of a field with the given name. The second boolean
  15921. // return value indicates that this field was not set, or was not defined in the
  15922. // schema.
  15923. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  15924. switch name {
  15925. case employee.FieldCreatedAt:
  15926. return m.CreatedAt()
  15927. case employee.FieldUpdatedAt:
  15928. return m.UpdatedAt()
  15929. case employee.FieldDeletedAt:
  15930. return m.DeletedAt()
  15931. case employee.FieldTitle:
  15932. return m.Title()
  15933. case employee.FieldAvatar:
  15934. return m.Avatar()
  15935. case employee.FieldTags:
  15936. return m.Tags()
  15937. case employee.FieldHireCount:
  15938. return m.HireCount()
  15939. case employee.FieldServiceCount:
  15940. return m.ServiceCount()
  15941. case employee.FieldAchievementCount:
  15942. return m.AchievementCount()
  15943. case employee.FieldIntro:
  15944. return m.Intro()
  15945. case employee.FieldEstimate:
  15946. return m.Estimate()
  15947. case employee.FieldSkill:
  15948. return m.Skill()
  15949. case employee.FieldAbilityType:
  15950. return m.AbilityType()
  15951. case employee.FieldScene:
  15952. return m.Scene()
  15953. case employee.FieldSwitchIn:
  15954. return m.SwitchIn()
  15955. case employee.FieldVideoURL:
  15956. return m.VideoURL()
  15957. case employee.FieldOrganizationID:
  15958. return m.OrganizationID()
  15959. case employee.FieldCategoryID:
  15960. return m.CategoryID()
  15961. case employee.FieldAPIBase:
  15962. return m.APIBase()
  15963. case employee.FieldAPIKey:
  15964. return m.APIKey()
  15965. case employee.FieldAiInfo:
  15966. return m.AiInfo()
  15967. case employee.FieldIsVip:
  15968. return m.IsVip()
  15969. case employee.FieldChatURL:
  15970. return m.ChatURL()
  15971. }
  15972. return nil, false
  15973. }
  15974. // OldField returns the old value of the field from the database. An error is
  15975. // returned if the mutation operation is not UpdateOne, or the query to the
  15976. // database failed.
  15977. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15978. switch name {
  15979. case employee.FieldCreatedAt:
  15980. return m.OldCreatedAt(ctx)
  15981. case employee.FieldUpdatedAt:
  15982. return m.OldUpdatedAt(ctx)
  15983. case employee.FieldDeletedAt:
  15984. return m.OldDeletedAt(ctx)
  15985. case employee.FieldTitle:
  15986. return m.OldTitle(ctx)
  15987. case employee.FieldAvatar:
  15988. return m.OldAvatar(ctx)
  15989. case employee.FieldTags:
  15990. return m.OldTags(ctx)
  15991. case employee.FieldHireCount:
  15992. return m.OldHireCount(ctx)
  15993. case employee.FieldServiceCount:
  15994. return m.OldServiceCount(ctx)
  15995. case employee.FieldAchievementCount:
  15996. return m.OldAchievementCount(ctx)
  15997. case employee.FieldIntro:
  15998. return m.OldIntro(ctx)
  15999. case employee.FieldEstimate:
  16000. return m.OldEstimate(ctx)
  16001. case employee.FieldSkill:
  16002. return m.OldSkill(ctx)
  16003. case employee.FieldAbilityType:
  16004. return m.OldAbilityType(ctx)
  16005. case employee.FieldScene:
  16006. return m.OldScene(ctx)
  16007. case employee.FieldSwitchIn:
  16008. return m.OldSwitchIn(ctx)
  16009. case employee.FieldVideoURL:
  16010. return m.OldVideoURL(ctx)
  16011. case employee.FieldOrganizationID:
  16012. return m.OldOrganizationID(ctx)
  16013. case employee.FieldCategoryID:
  16014. return m.OldCategoryID(ctx)
  16015. case employee.FieldAPIBase:
  16016. return m.OldAPIBase(ctx)
  16017. case employee.FieldAPIKey:
  16018. return m.OldAPIKey(ctx)
  16019. case employee.FieldAiInfo:
  16020. return m.OldAiInfo(ctx)
  16021. case employee.FieldIsVip:
  16022. return m.OldIsVip(ctx)
  16023. case employee.FieldChatURL:
  16024. return m.OldChatURL(ctx)
  16025. }
  16026. return nil, fmt.Errorf("unknown Employee field %s", name)
  16027. }
  16028. // SetField sets the value of a field with the given name. It returns an error if
  16029. // the field is not defined in the schema, or if the type mismatched the field
  16030. // type.
  16031. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  16032. switch name {
  16033. case employee.FieldCreatedAt:
  16034. v, ok := value.(time.Time)
  16035. if !ok {
  16036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16037. }
  16038. m.SetCreatedAt(v)
  16039. return nil
  16040. case employee.FieldUpdatedAt:
  16041. v, ok := value.(time.Time)
  16042. if !ok {
  16043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16044. }
  16045. m.SetUpdatedAt(v)
  16046. return nil
  16047. case employee.FieldDeletedAt:
  16048. v, ok := value.(time.Time)
  16049. if !ok {
  16050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16051. }
  16052. m.SetDeletedAt(v)
  16053. return nil
  16054. case employee.FieldTitle:
  16055. v, ok := value.(string)
  16056. if !ok {
  16057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16058. }
  16059. m.SetTitle(v)
  16060. return nil
  16061. case employee.FieldAvatar:
  16062. v, ok := value.(string)
  16063. if !ok {
  16064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16065. }
  16066. m.SetAvatar(v)
  16067. return nil
  16068. case employee.FieldTags:
  16069. v, ok := value.(string)
  16070. if !ok {
  16071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16072. }
  16073. m.SetTags(v)
  16074. return nil
  16075. case employee.FieldHireCount:
  16076. v, ok := value.(int)
  16077. if !ok {
  16078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16079. }
  16080. m.SetHireCount(v)
  16081. return nil
  16082. case employee.FieldServiceCount:
  16083. v, ok := value.(int)
  16084. if !ok {
  16085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16086. }
  16087. m.SetServiceCount(v)
  16088. return nil
  16089. case employee.FieldAchievementCount:
  16090. v, ok := value.(int)
  16091. if !ok {
  16092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16093. }
  16094. m.SetAchievementCount(v)
  16095. return nil
  16096. case employee.FieldIntro:
  16097. v, ok := value.(string)
  16098. if !ok {
  16099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16100. }
  16101. m.SetIntro(v)
  16102. return nil
  16103. case employee.FieldEstimate:
  16104. v, ok := value.(string)
  16105. if !ok {
  16106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16107. }
  16108. m.SetEstimate(v)
  16109. return nil
  16110. case employee.FieldSkill:
  16111. v, ok := value.(string)
  16112. if !ok {
  16113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16114. }
  16115. m.SetSkill(v)
  16116. return nil
  16117. case employee.FieldAbilityType:
  16118. v, ok := value.(string)
  16119. if !ok {
  16120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16121. }
  16122. m.SetAbilityType(v)
  16123. return nil
  16124. case employee.FieldScene:
  16125. v, ok := value.(string)
  16126. if !ok {
  16127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16128. }
  16129. m.SetScene(v)
  16130. return nil
  16131. case employee.FieldSwitchIn:
  16132. v, ok := value.(string)
  16133. if !ok {
  16134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16135. }
  16136. m.SetSwitchIn(v)
  16137. return nil
  16138. case employee.FieldVideoURL:
  16139. v, ok := value.(string)
  16140. if !ok {
  16141. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16142. }
  16143. m.SetVideoURL(v)
  16144. return nil
  16145. case employee.FieldOrganizationID:
  16146. v, ok := value.(uint64)
  16147. if !ok {
  16148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16149. }
  16150. m.SetOrganizationID(v)
  16151. return nil
  16152. case employee.FieldCategoryID:
  16153. v, ok := value.(uint64)
  16154. if !ok {
  16155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16156. }
  16157. m.SetCategoryID(v)
  16158. return nil
  16159. case employee.FieldAPIBase:
  16160. v, ok := value.(string)
  16161. if !ok {
  16162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16163. }
  16164. m.SetAPIBase(v)
  16165. return nil
  16166. case employee.FieldAPIKey:
  16167. v, ok := value.(string)
  16168. if !ok {
  16169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16170. }
  16171. m.SetAPIKey(v)
  16172. return nil
  16173. case employee.FieldAiInfo:
  16174. v, ok := value.(string)
  16175. if !ok {
  16176. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16177. }
  16178. m.SetAiInfo(v)
  16179. return nil
  16180. case employee.FieldIsVip:
  16181. v, ok := value.(int)
  16182. if !ok {
  16183. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16184. }
  16185. m.SetIsVip(v)
  16186. return nil
  16187. case employee.FieldChatURL:
  16188. v, ok := value.(string)
  16189. if !ok {
  16190. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16191. }
  16192. m.SetChatURL(v)
  16193. return nil
  16194. }
  16195. return fmt.Errorf("unknown Employee field %s", name)
  16196. }
  16197. // AddedFields returns all numeric fields that were incremented/decremented during
  16198. // this mutation.
  16199. func (m *EmployeeMutation) AddedFields() []string {
  16200. var fields []string
  16201. if m.addhire_count != nil {
  16202. fields = append(fields, employee.FieldHireCount)
  16203. }
  16204. if m.addservice_count != nil {
  16205. fields = append(fields, employee.FieldServiceCount)
  16206. }
  16207. if m.addachievement_count != nil {
  16208. fields = append(fields, employee.FieldAchievementCount)
  16209. }
  16210. if m.addorganization_id != nil {
  16211. fields = append(fields, employee.FieldOrganizationID)
  16212. }
  16213. if m.addcategory_id != nil {
  16214. fields = append(fields, employee.FieldCategoryID)
  16215. }
  16216. if m.addis_vip != nil {
  16217. fields = append(fields, employee.FieldIsVip)
  16218. }
  16219. return fields
  16220. }
  16221. // AddedField returns the numeric value that was incremented/decremented on a field
  16222. // with the given name. The second boolean return value indicates that this field
  16223. // was not set, or was not defined in the schema.
  16224. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  16225. switch name {
  16226. case employee.FieldHireCount:
  16227. return m.AddedHireCount()
  16228. case employee.FieldServiceCount:
  16229. return m.AddedServiceCount()
  16230. case employee.FieldAchievementCount:
  16231. return m.AddedAchievementCount()
  16232. case employee.FieldOrganizationID:
  16233. return m.AddedOrganizationID()
  16234. case employee.FieldCategoryID:
  16235. return m.AddedCategoryID()
  16236. case employee.FieldIsVip:
  16237. return m.AddedIsVip()
  16238. }
  16239. return nil, false
  16240. }
  16241. // AddField adds the value to the field with the given name. It returns an error if
  16242. // the field is not defined in the schema, or if the type mismatched the field
  16243. // type.
  16244. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  16245. switch name {
  16246. case employee.FieldHireCount:
  16247. v, ok := value.(int)
  16248. if !ok {
  16249. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16250. }
  16251. m.AddHireCount(v)
  16252. return nil
  16253. case employee.FieldServiceCount:
  16254. v, ok := value.(int)
  16255. if !ok {
  16256. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16257. }
  16258. m.AddServiceCount(v)
  16259. return nil
  16260. case employee.FieldAchievementCount:
  16261. v, ok := value.(int)
  16262. if !ok {
  16263. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16264. }
  16265. m.AddAchievementCount(v)
  16266. return nil
  16267. case employee.FieldOrganizationID:
  16268. v, ok := value.(int64)
  16269. if !ok {
  16270. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16271. }
  16272. m.AddOrganizationID(v)
  16273. return nil
  16274. case employee.FieldCategoryID:
  16275. v, ok := value.(int64)
  16276. if !ok {
  16277. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16278. }
  16279. m.AddCategoryID(v)
  16280. return nil
  16281. case employee.FieldIsVip:
  16282. v, ok := value.(int)
  16283. if !ok {
  16284. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16285. }
  16286. m.AddIsVip(v)
  16287. return nil
  16288. }
  16289. return fmt.Errorf("unknown Employee numeric field %s", name)
  16290. }
  16291. // ClearedFields returns all nullable fields that were cleared during this
  16292. // mutation.
  16293. func (m *EmployeeMutation) ClearedFields() []string {
  16294. var fields []string
  16295. if m.FieldCleared(employee.FieldDeletedAt) {
  16296. fields = append(fields, employee.FieldDeletedAt)
  16297. }
  16298. if m.FieldCleared(employee.FieldAiInfo) {
  16299. fields = append(fields, employee.FieldAiInfo)
  16300. }
  16301. return fields
  16302. }
  16303. // FieldCleared returns a boolean indicating if a field with the given name was
  16304. // cleared in this mutation.
  16305. func (m *EmployeeMutation) FieldCleared(name string) bool {
  16306. _, ok := m.clearedFields[name]
  16307. return ok
  16308. }
  16309. // ClearField clears the value of the field with the given name. It returns an
  16310. // error if the field is not defined in the schema.
  16311. func (m *EmployeeMutation) ClearField(name string) error {
  16312. switch name {
  16313. case employee.FieldDeletedAt:
  16314. m.ClearDeletedAt()
  16315. return nil
  16316. case employee.FieldAiInfo:
  16317. m.ClearAiInfo()
  16318. return nil
  16319. }
  16320. return fmt.Errorf("unknown Employee nullable field %s", name)
  16321. }
  16322. // ResetField resets all changes in the mutation for the field with the given name.
  16323. // It returns an error if the field is not defined in the schema.
  16324. func (m *EmployeeMutation) ResetField(name string) error {
  16325. switch name {
  16326. case employee.FieldCreatedAt:
  16327. m.ResetCreatedAt()
  16328. return nil
  16329. case employee.FieldUpdatedAt:
  16330. m.ResetUpdatedAt()
  16331. return nil
  16332. case employee.FieldDeletedAt:
  16333. m.ResetDeletedAt()
  16334. return nil
  16335. case employee.FieldTitle:
  16336. m.ResetTitle()
  16337. return nil
  16338. case employee.FieldAvatar:
  16339. m.ResetAvatar()
  16340. return nil
  16341. case employee.FieldTags:
  16342. m.ResetTags()
  16343. return nil
  16344. case employee.FieldHireCount:
  16345. m.ResetHireCount()
  16346. return nil
  16347. case employee.FieldServiceCount:
  16348. m.ResetServiceCount()
  16349. return nil
  16350. case employee.FieldAchievementCount:
  16351. m.ResetAchievementCount()
  16352. return nil
  16353. case employee.FieldIntro:
  16354. m.ResetIntro()
  16355. return nil
  16356. case employee.FieldEstimate:
  16357. m.ResetEstimate()
  16358. return nil
  16359. case employee.FieldSkill:
  16360. m.ResetSkill()
  16361. return nil
  16362. case employee.FieldAbilityType:
  16363. m.ResetAbilityType()
  16364. return nil
  16365. case employee.FieldScene:
  16366. m.ResetScene()
  16367. return nil
  16368. case employee.FieldSwitchIn:
  16369. m.ResetSwitchIn()
  16370. return nil
  16371. case employee.FieldVideoURL:
  16372. m.ResetVideoURL()
  16373. return nil
  16374. case employee.FieldOrganizationID:
  16375. m.ResetOrganizationID()
  16376. return nil
  16377. case employee.FieldCategoryID:
  16378. m.ResetCategoryID()
  16379. return nil
  16380. case employee.FieldAPIBase:
  16381. m.ResetAPIBase()
  16382. return nil
  16383. case employee.FieldAPIKey:
  16384. m.ResetAPIKey()
  16385. return nil
  16386. case employee.FieldAiInfo:
  16387. m.ResetAiInfo()
  16388. return nil
  16389. case employee.FieldIsVip:
  16390. m.ResetIsVip()
  16391. return nil
  16392. case employee.FieldChatURL:
  16393. m.ResetChatURL()
  16394. return nil
  16395. }
  16396. return fmt.Errorf("unknown Employee field %s", name)
  16397. }
  16398. // AddedEdges returns all edge names that were set/added in this mutation.
  16399. func (m *EmployeeMutation) AddedEdges() []string {
  16400. edges := make([]string, 0, 2)
  16401. if m.em_work_experiences != nil {
  16402. edges = append(edges, employee.EdgeEmWorkExperiences)
  16403. }
  16404. if m.em_tutorial != nil {
  16405. edges = append(edges, employee.EdgeEmTutorial)
  16406. }
  16407. return edges
  16408. }
  16409. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16410. // name in this mutation.
  16411. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  16412. switch name {
  16413. case employee.EdgeEmWorkExperiences:
  16414. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  16415. for id := range m.em_work_experiences {
  16416. ids = append(ids, id)
  16417. }
  16418. return ids
  16419. case employee.EdgeEmTutorial:
  16420. ids := make([]ent.Value, 0, len(m.em_tutorial))
  16421. for id := range m.em_tutorial {
  16422. ids = append(ids, id)
  16423. }
  16424. return ids
  16425. }
  16426. return nil
  16427. }
  16428. // RemovedEdges returns all edge names that were removed in this mutation.
  16429. func (m *EmployeeMutation) RemovedEdges() []string {
  16430. edges := make([]string, 0, 2)
  16431. if m.removedem_work_experiences != nil {
  16432. edges = append(edges, employee.EdgeEmWorkExperiences)
  16433. }
  16434. if m.removedem_tutorial != nil {
  16435. edges = append(edges, employee.EdgeEmTutorial)
  16436. }
  16437. return edges
  16438. }
  16439. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16440. // the given name in this mutation.
  16441. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  16442. switch name {
  16443. case employee.EdgeEmWorkExperiences:
  16444. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  16445. for id := range m.removedem_work_experiences {
  16446. ids = append(ids, id)
  16447. }
  16448. return ids
  16449. case employee.EdgeEmTutorial:
  16450. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  16451. for id := range m.removedem_tutorial {
  16452. ids = append(ids, id)
  16453. }
  16454. return ids
  16455. }
  16456. return nil
  16457. }
  16458. // ClearedEdges returns all edge names that were cleared in this mutation.
  16459. func (m *EmployeeMutation) ClearedEdges() []string {
  16460. edges := make([]string, 0, 2)
  16461. if m.clearedem_work_experiences {
  16462. edges = append(edges, employee.EdgeEmWorkExperiences)
  16463. }
  16464. if m.clearedem_tutorial {
  16465. edges = append(edges, employee.EdgeEmTutorial)
  16466. }
  16467. return edges
  16468. }
  16469. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16470. // was cleared in this mutation.
  16471. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  16472. switch name {
  16473. case employee.EdgeEmWorkExperiences:
  16474. return m.clearedem_work_experiences
  16475. case employee.EdgeEmTutorial:
  16476. return m.clearedem_tutorial
  16477. }
  16478. return false
  16479. }
  16480. // ClearEdge clears the value of the edge with the given name. It returns an error
  16481. // if that edge is not defined in the schema.
  16482. func (m *EmployeeMutation) ClearEdge(name string) error {
  16483. switch name {
  16484. }
  16485. return fmt.Errorf("unknown Employee unique edge %s", name)
  16486. }
  16487. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16488. // It returns an error if the edge is not defined in the schema.
  16489. func (m *EmployeeMutation) ResetEdge(name string) error {
  16490. switch name {
  16491. case employee.EdgeEmWorkExperiences:
  16492. m.ResetEmWorkExperiences()
  16493. return nil
  16494. case employee.EdgeEmTutorial:
  16495. m.ResetEmTutorial()
  16496. return nil
  16497. }
  16498. return fmt.Errorf("unknown Employee edge %s", name)
  16499. }
  16500. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  16501. type EmployeeConfigMutation struct {
  16502. config
  16503. op Op
  16504. typ string
  16505. id *uint64
  16506. created_at *time.Time
  16507. updated_at *time.Time
  16508. deleted_at *time.Time
  16509. stype *string
  16510. title *string
  16511. photo *string
  16512. organization_id *uint64
  16513. addorganization_id *int64
  16514. clearedFields map[string]struct{}
  16515. done bool
  16516. oldValue func(context.Context) (*EmployeeConfig, error)
  16517. predicates []predicate.EmployeeConfig
  16518. }
  16519. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  16520. // employeeconfigOption allows management of the mutation configuration using functional options.
  16521. type employeeconfigOption func(*EmployeeConfigMutation)
  16522. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  16523. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  16524. m := &EmployeeConfigMutation{
  16525. config: c,
  16526. op: op,
  16527. typ: TypeEmployeeConfig,
  16528. clearedFields: make(map[string]struct{}),
  16529. }
  16530. for _, opt := range opts {
  16531. opt(m)
  16532. }
  16533. return m
  16534. }
  16535. // withEmployeeConfigID sets the ID field of the mutation.
  16536. func withEmployeeConfigID(id uint64) employeeconfigOption {
  16537. return func(m *EmployeeConfigMutation) {
  16538. var (
  16539. err error
  16540. once sync.Once
  16541. value *EmployeeConfig
  16542. )
  16543. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  16544. once.Do(func() {
  16545. if m.done {
  16546. err = errors.New("querying old values post mutation is not allowed")
  16547. } else {
  16548. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  16549. }
  16550. })
  16551. return value, err
  16552. }
  16553. m.id = &id
  16554. }
  16555. }
  16556. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  16557. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  16558. return func(m *EmployeeConfigMutation) {
  16559. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  16560. return node, nil
  16561. }
  16562. m.id = &node.ID
  16563. }
  16564. }
  16565. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16566. // executed in a transaction (ent.Tx), a transactional client is returned.
  16567. func (m EmployeeConfigMutation) Client() *Client {
  16568. client := &Client{config: m.config}
  16569. client.init()
  16570. return client
  16571. }
  16572. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16573. // it returns an error otherwise.
  16574. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  16575. if _, ok := m.driver.(*txDriver); !ok {
  16576. return nil, errors.New("ent: mutation is not running in a transaction")
  16577. }
  16578. tx := &Tx{config: m.config}
  16579. tx.init()
  16580. return tx, nil
  16581. }
  16582. // SetID sets the value of the id field. Note that this
  16583. // operation is only accepted on creation of EmployeeConfig entities.
  16584. func (m *EmployeeConfigMutation) SetID(id uint64) {
  16585. m.id = &id
  16586. }
  16587. // ID returns the ID value in the mutation. Note that the ID is only available
  16588. // if it was provided to the builder or after it was returned from the database.
  16589. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  16590. if m.id == nil {
  16591. return
  16592. }
  16593. return *m.id, true
  16594. }
  16595. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16596. // That means, if the mutation is applied within a transaction with an isolation level such
  16597. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16598. // or updated by the mutation.
  16599. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  16600. switch {
  16601. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16602. id, exists := m.ID()
  16603. if exists {
  16604. return []uint64{id}, nil
  16605. }
  16606. fallthrough
  16607. case m.op.Is(OpUpdate | OpDelete):
  16608. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  16609. default:
  16610. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16611. }
  16612. }
  16613. // SetCreatedAt sets the "created_at" field.
  16614. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  16615. m.created_at = &t
  16616. }
  16617. // CreatedAt returns the value of the "created_at" field in the mutation.
  16618. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  16619. v := m.created_at
  16620. if v == nil {
  16621. return
  16622. }
  16623. return *v, true
  16624. }
  16625. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  16626. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  16627. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16628. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16629. if !m.op.Is(OpUpdateOne) {
  16630. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16631. }
  16632. if m.id == nil || m.oldValue == nil {
  16633. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16634. }
  16635. oldValue, err := m.oldValue(ctx)
  16636. if err != nil {
  16637. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16638. }
  16639. return oldValue.CreatedAt, nil
  16640. }
  16641. // ResetCreatedAt resets all changes to the "created_at" field.
  16642. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  16643. m.created_at = nil
  16644. }
  16645. // SetUpdatedAt sets the "updated_at" field.
  16646. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  16647. m.updated_at = &t
  16648. }
  16649. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16650. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  16651. v := m.updated_at
  16652. if v == nil {
  16653. return
  16654. }
  16655. return *v, true
  16656. }
  16657. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  16658. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  16659. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16660. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16661. if !m.op.Is(OpUpdateOne) {
  16662. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16663. }
  16664. if m.id == nil || m.oldValue == nil {
  16665. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16666. }
  16667. oldValue, err := m.oldValue(ctx)
  16668. if err != nil {
  16669. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16670. }
  16671. return oldValue.UpdatedAt, nil
  16672. }
  16673. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16674. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  16675. m.updated_at = nil
  16676. }
  16677. // SetDeletedAt sets the "deleted_at" field.
  16678. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  16679. m.deleted_at = &t
  16680. }
  16681. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16682. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  16683. v := m.deleted_at
  16684. if v == nil {
  16685. return
  16686. }
  16687. return *v, true
  16688. }
  16689. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  16690. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  16691. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16692. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16693. if !m.op.Is(OpUpdateOne) {
  16694. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16695. }
  16696. if m.id == nil || m.oldValue == nil {
  16697. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16698. }
  16699. oldValue, err := m.oldValue(ctx)
  16700. if err != nil {
  16701. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16702. }
  16703. return oldValue.DeletedAt, nil
  16704. }
  16705. // ClearDeletedAt clears the value of the "deleted_at" field.
  16706. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  16707. m.deleted_at = nil
  16708. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  16709. }
  16710. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16711. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  16712. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  16713. return ok
  16714. }
  16715. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16716. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  16717. m.deleted_at = nil
  16718. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  16719. }
  16720. // SetStype sets the "stype" field.
  16721. func (m *EmployeeConfigMutation) SetStype(s string) {
  16722. m.stype = &s
  16723. }
  16724. // Stype returns the value of the "stype" field in the mutation.
  16725. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  16726. v := m.stype
  16727. if v == nil {
  16728. return
  16729. }
  16730. return *v, true
  16731. }
  16732. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  16733. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  16734. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16735. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  16736. if !m.op.Is(OpUpdateOne) {
  16737. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  16738. }
  16739. if m.id == nil || m.oldValue == nil {
  16740. return v, errors.New("OldStype requires an ID field in the mutation")
  16741. }
  16742. oldValue, err := m.oldValue(ctx)
  16743. if err != nil {
  16744. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  16745. }
  16746. return oldValue.Stype, nil
  16747. }
  16748. // ResetStype resets all changes to the "stype" field.
  16749. func (m *EmployeeConfigMutation) ResetStype() {
  16750. m.stype = nil
  16751. }
  16752. // SetTitle sets the "title" field.
  16753. func (m *EmployeeConfigMutation) SetTitle(s string) {
  16754. m.title = &s
  16755. }
  16756. // Title returns the value of the "title" field in the mutation.
  16757. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  16758. v := m.title
  16759. if v == nil {
  16760. return
  16761. }
  16762. return *v, true
  16763. }
  16764. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  16765. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  16766. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16767. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  16768. if !m.op.Is(OpUpdateOne) {
  16769. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  16770. }
  16771. if m.id == nil || m.oldValue == nil {
  16772. return v, errors.New("OldTitle requires an ID field in the mutation")
  16773. }
  16774. oldValue, err := m.oldValue(ctx)
  16775. if err != nil {
  16776. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  16777. }
  16778. return oldValue.Title, nil
  16779. }
  16780. // ResetTitle resets all changes to the "title" field.
  16781. func (m *EmployeeConfigMutation) ResetTitle() {
  16782. m.title = nil
  16783. }
  16784. // SetPhoto sets the "photo" field.
  16785. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  16786. m.photo = &s
  16787. }
  16788. // Photo returns the value of the "photo" field in the mutation.
  16789. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  16790. v := m.photo
  16791. if v == nil {
  16792. return
  16793. }
  16794. return *v, true
  16795. }
  16796. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  16797. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  16798. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16799. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  16800. if !m.op.Is(OpUpdateOne) {
  16801. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  16802. }
  16803. if m.id == nil || m.oldValue == nil {
  16804. return v, errors.New("OldPhoto requires an ID field in the mutation")
  16805. }
  16806. oldValue, err := m.oldValue(ctx)
  16807. if err != nil {
  16808. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  16809. }
  16810. return oldValue.Photo, nil
  16811. }
  16812. // ResetPhoto resets all changes to the "photo" field.
  16813. func (m *EmployeeConfigMutation) ResetPhoto() {
  16814. m.photo = nil
  16815. }
  16816. // SetOrganizationID sets the "organization_id" field.
  16817. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  16818. m.organization_id = &u
  16819. m.addorganization_id = nil
  16820. }
  16821. // OrganizationID returns the value of the "organization_id" field in the mutation.
  16822. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  16823. v := m.organization_id
  16824. if v == nil {
  16825. return
  16826. }
  16827. return *v, true
  16828. }
  16829. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  16830. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  16831. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16832. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  16833. if !m.op.Is(OpUpdateOne) {
  16834. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  16835. }
  16836. if m.id == nil || m.oldValue == nil {
  16837. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  16838. }
  16839. oldValue, err := m.oldValue(ctx)
  16840. if err != nil {
  16841. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  16842. }
  16843. return oldValue.OrganizationID, nil
  16844. }
  16845. // AddOrganizationID adds u to the "organization_id" field.
  16846. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  16847. if m.addorganization_id != nil {
  16848. *m.addorganization_id += u
  16849. } else {
  16850. m.addorganization_id = &u
  16851. }
  16852. }
  16853. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  16854. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  16855. v := m.addorganization_id
  16856. if v == nil {
  16857. return
  16858. }
  16859. return *v, true
  16860. }
  16861. // ClearOrganizationID clears the value of the "organization_id" field.
  16862. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  16863. m.organization_id = nil
  16864. m.addorganization_id = nil
  16865. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  16866. }
  16867. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  16868. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  16869. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  16870. return ok
  16871. }
  16872. // ResetOrganizationID resets all changes to the "organization_id" field.
  16873. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  16874. m.organization_id = nil
  16875. m.addorganization_id = nil
  16876. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  16877. }
  16878. // Where appends a list predicates to the EmployeeConfigMutation builder.
  16879. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  16880. m.predicates = append(m.predicates, ps...)
  16881. }
  16882. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  16883. // users can use type-assertion to append predicates that do not depend on any generated package.
  16884. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  16885. p := make([]predicate.EmployeeConfig, len(ps))
  16886. for i := range ps {
  16887. p[i] = ps[i]
  16888. }
  16889. m.Where(p...)
  16890. }
  16891. // Op returns the operation name.
  16892. func (m *EmployeeConfigMutation) Op() Op {
  16893. return m.op
  16894. }
  16895. // SetOp allows setting the mutation operation.
  16896. func (m *EmployeeConfigMutation) SetOp(op Op) {
  16897. m.op = op
  16898. }
  16899. // Type returns the node type of this mutation (EmployeeConfig).
  16900. func (m *EmployeeConfigMutation) Type() string {
  16901. return m.typ
  16902. }
  16903. // Fields returns all fields that were changed during this mutation. Note that in
  16904. // order to get all numeric fields that were incremented/decremented, call
  16905. // AddedFields().
  16906. func (m *EmployeeConfigMutation) Fields() []string {
  16907. fields := make([]string, 0, 7)
  16908. if m.created_at != nil {
  16909. fields = append(fields, employeeconfig.FieldCreatedAt)
  16910. }
  16911. if m.updated_at != nil {
  16912. fields = append(fields, employeeconfig.FieldUpdatedAt)
  16913. }
  16914. if m.deleted_at != nil {
  16915. fields = append(fields, employeeconfig.FieldDeletedAt)
  16916. }
  16917. if m.stype != nil {
  16918. fields = append(fields, employeeconfig.FieldStype)
  16919. }
  16920. if m.title != nil {
  16921. fields = append(fields, employeeconfig.FieldTitle)
  16922. }
  16923. if m.photo != nil {
  16924. fields = append(fields, employeeconfig.FieldPhoto)
  16925. }
  16926. if m.organization_id != nil {
  16927. fields = append(fields, employeeconfig.FieldOrganizationID)
  16928. }
  16929. return fields
  16930. }
  16931. // Field returns the value of a field with the given name. The second boolean
  16932. // return value indicates that this field was not set, or was not defined in the
  16933. // schema.
  16934. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  16935. switch name {
  16936. case employeeconfig.FieldCreatedAt:
  16937. return m.CreatedAt()
  16938. case employeeconfig.FieldUpdatedAt:
  16939. return m.UpdatedAt()
  16940. case employeeconfig.FieldDeletedAt:
  16941. return m.DeletedAt()
  16942. case employeeconfig.FieldStype:
  16943. return m.Stype()
  16944. case employeeconfig.FieldTitle:
  16945. return m.Title()
  16946. case employeeconfig.FieldPhoto:
  16947. return m.Photo()
  16948. case employeeconfig.FieldOrganizationID:
  16949. return m.OrganizationID()
  16950. }
  16951. return nil, false
  16952. }
  16953. // OldField returns the old value of the field from the database. An error is
  16954. // returned if the mutation operation is not UpdateOne, or the query to the
  16955. // database failed.
  16956. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16957. switch name {
  16958. case employeeconfig.FieldCreatedAt:
  16959. return m.OldCreatedAt(ctx)
  16960. case employeeconfig.FieldUpdatedAt:
  16961. return m.OldUpdatedAt(ctx)
  16962. case employeeconfig.FieldDeletedAt:
  16963. return m.OldDeletedAt(ctx)
  16964. case employeeconfig.FieldStype:
  16965. return m.OldStype(ctx)
  16966. case employeeconfig.FieldTitle:
  16967. return m.OldTitle(ctx)
  16968. case employeeconfig.FieldPhoto:
  16969. return m.OldPhoto(ctx)
  16970. case employeeconfig.FieldOrganizationID:
  16971. return m.OldOrganizationID(ctx)
  16972. }
  16973. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  16974. }
  16975. // SetField sets the value of a field with the given name. It returns an error if
  16976. // the field is not defined in the schema, or if the type mismatched the field
  16977. // type.
  16978. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  16979. switch name {
  16980. case employeeconfig.FieldCreatedAt:
  16981. v, ok := value.(time.Time)
  16982. if !ok {
  16983. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16984. }
  16985. m.SetCreatedAt(v)
  16986. return nil
  16987. case employeeconfig.FieldUpdatedAt:
  16988. v, ok := value.(time.Time)
  16989. if !ok {
  16990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16991. }
  16992. m.SetUpdatedAt(v)
  16993. return nil
  16994. case employeeconfig.FieldDeletedAt:
  16995. v, ok := value.(time.Time)
  16996. if !ok {
  16997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16998. }
  16999. m.SetDeletedAt(v)
  17000. return nil
  17001. case employeeconfig.FieldStype:
  17002. v, ok := value.(string)
  17003. if !ok {
  17004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17005. }
  17006. m.SetStype(v)
  17007. return nil
  17008. case employeeconfig.FieldTitle:
  17009. v, ok := value.(string)
  17010. if !ok {
  17011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17012. }
  17013. m.SetTitle(v)
  17014. return nil
  17015. case employeeconfig.FieldPhoto:
  17016. v, ok := value.(string)
  17017. if !ok {
  17018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17019. }
  17020. m.SetPhoto(v)
  17021. return nil
  17022. case employeeconfig.FieldOrganizationID:
  17023. v, ok := value.(uint64)
  17024. if !ok {
  17025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17026. }
  17027. m.SetOrganizationID(v)
  17028. return nil
  17029. }
  17030. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  17031. }
  17032. // AddedFields returns all numeric fields that were incremented/decremented during
  17033. // this mutation.
  17034. func (m *EmployeeConfigMutation) AddedFields() []string {
  17035. var fields []string
  17036. if m.addorganization_id != nil {
  17037. fields = append(fields, employeeconfig.FieldOrganizationID)
  17038. }
  17039. return fields
  17040. }
  17041. // AddedField returns the numeric value that was incremented/decremented on a field
  17042. // with the given name. The second boolean return value indicates that this field
  17043. // was not set, or was not defined in the schema.
  17044. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  17045. switch name {
  17046. case employeeconfig.FieldOrganizationID:
  17047. return m.AddedOrganizationID()
  17048. }
  17049. return nil, false
  17050. }
  17051. // AddField adds the value to the field with the given name. It returns an error if
  17052. // the field is not defined in the schema, or if the type mismatched the field
  17053. // type.
  17054. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  17055. switch name {
  17056. case employeeconfig.FieldOrganizationID:
  17057. v, ok := value.(int64)
  17058. if !ok {
  17059. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17060. }
  17061. m.AddOrganizationID(v)
  17062. return nil
  17063. }
  17064. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  17065. }
  17066. // ClearedFields returns all nullable fields that were cleared during this
  17067. // mutation.
  17068. func (m *EmployeeConfigMutation) ClearedFields() []string {
  17069. var fields []string
  17070. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  17071. fields = append(fields, employeeconfig.FieldDeletedAt)
  17072. }
  17073. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  17074. fields = append(fields, employeeconfig.FieldOrganizationID)
  17075. }
  17076. return fields
  17077. }
  17078. // FieldCleared returns a boolean indicating if a field with the given name was
  17079. // cleared in this mutation.
  17080. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  17081. _, ok := m.clearedFields[name]
  17082. return ok
  17083. }
  17084. // ClearField clears the value of the field with the given name. It returns an
  17085. // error if the field is not defined in the schema.
  17086. func (m *EmployeeConfigMutation) ClearField(name string) error {
  17087. switch name {
  17088. case employeeconfig.FieldDeletedAt:
  17089. m.ClearDeletedAt()
  17090. return nil
  17091. case employeeconfig.FieldOrganizationID:
  17092. m.ClearOrganizationID()
  17093. return nil
  17094. }
  17095. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  17096. }
  17097. // ResetField resets all changes in the mutation for the field with the given name.
  17098. // It returns an error if the field is not defined in the schema.
  17099. func (m *EmployeeConfigMutation) ResetField(name string) error {
  17100. switch name {
  17101. case employeeconfig.FieldCreatedAt:
  17102. m.ResetCreatedAt()
  17103. return nil
  17104. case employeeconfig.FieldUpdatedAt:
  17105. m.ResetUpdatedAt()
  17106. return nil
  17107. case employeeconfig.FieldDeletedAt:
  17108. m.ResetDeletedAt()
  17109. return nil
  17110. case employeeconfig.FieldStype:
  17111. m.ResetStype()
  17112. return nil
  17113. case employeeconfig.FieldTitle:
  17114. m.ResetTitle()
  17115. return nil
  17116. case employeeconfig.FieldPhoto:
  17117. m.ResetPhoto()
  17118. return nil
  17119. case employeeconfig.FieldOrganizationID:
  17120. m.ResetOrganizationID()
  17121. return nil
  17122. }
  17123. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  17124. }
  17125. // AddedEdges returns all edge names that were set/added in this mutation.
  17126. func (m *EmployeeConfigMutation) AddedEdges() []string {
  17127. edges := make([]string, 0, 0)
  17128. return edges
  17129. }
  17130. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17131. // name in this mutation.
  17132. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  17133. return nil
  17134. }
  17135. // RemovedEdges returns all edge names that were removed in this mutation.
  17136. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  17137. edges := make([]string, 0, 0)
  17138. return edges
  17139. }
  17140. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17141. // the given name in this mutation.
  17142. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  17143. return nil
  17144. }
  17145. // ClearedEdges returns all edge names that were cleared in this mutation.
  17146. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  17147. edges := make([]string, 0, 0)
  17148. return edges
  17149. }
  17150. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17151. // was cleared in this mutation.
  17152. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  17153. return false
  17154. }
  17155. // ClearEdge clears the value of the edge with the given name. It returns an error
  17156. // if that edge is not defined in the schema.
  17157. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  17158. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  17159. }
  17160. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17161. // It returns an error if the edge is not defined in the schema.
  17162. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  17163. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  17164. }
  17165. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  17166. type LabelMutation struct {
  17167. config
  17168. op Op
  17169. typ string
  17170. id *uint64
  17171. created_at *time.Time
  17172. updated_at *time.Time
  17173. status *uint8
  17174. addstatus *int8
  17175. _type *int
  17176. add_type *int
  17177. name *string
  17178. from *int
  17179. addfrom *int
  17180. mode *int
  17181. addmode *int
  17182. conditions *string
  17183. organization_id *uint64
  17184. addorganization_id *int64
  17185. clearedFields map[string]struct{}
  17186. label_relationships map[uint64]struct{}
  17187. removedlabel_relationships map[uint64]struct{}
  17188. clearedlabel_relationships bool
  17189. done bool
  17190. oldValue func(context.Context) (*Label, error)
  17191. predicates []predicate.Label
  17192. }
  17193. var _ ent.Mutation = (*LabelMutation)(nil)
  17194. // labelOption allows management of the mutation configuration using functional options.
  17195. type labelOption func(*LabelMutation)
  17196. // newLabelMutation creates new mutation for the Label entity.
  17197. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  17198. m := &LabelMutation{
  17199. config: c,
  17200. op: op,
  17201. typ: TypeLabel,
  17202. clearedFields: make(map[string]struct{}),
  17203. }
  17204. for _, opt := range opts {
  17205. opt(m)
  17206. }
  17207. return m
  17208. }
  17209. // withLabelID sets the ID field of the mutation.
  17210. func withLabelID(id uint64) labelOption {
  17211. return func(m *LabelMutation) {
  17212. var (
  17213. err error
  17214. once sync.Once
  17215. value *Label
  17216. )
  17217. m.oldValue = func(ctx context.Context) (*Label, error) {
  17218. once.Do(func() {
  17219. if m.done {
  17220. err = errors.New("querying old values post mutation is not allowed")
  17221. } else {
  17222. value, err = m.Client().Label.Get(ctx, id)
  17223. }
  17224. })
  17225. return value, err
  17226. }
  17227. m.id = &id
  17228. }
  17229. }
  17230. // withLabel sets the old Label of the mutation.
  17231. func withLabel(node *Label) labelOption {
  17232. return func(m *LabelMutation) {
  17233. m.oldValue = func(context.Context) (*Label, error) {
  17234. return node, nil
  17235. }
  17236. m.id = &node.ID
  17237. }
  17238. }
  17239. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17240. // executed in a transaction (ent.Tx), a transactional client is returned.
  17241. func (m LabelMutation) Client() *Client {
  17242. client := &Client{config: m.config}
  17243. client.init()
  17244. return client
  17245. }
  17246. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17247. // it returns an error otherwise.
  17248. func (m LabelMutation) Tx() (*Tx, error) {
  17249. if _, ok := m.driver.(*txDriver); !ok {
  17250. return nil, errors.New("ent: mutation is not running in a transaction")
  17251. }
  17252. tx := &Tx{config: m.config}
  17253. tx.init()
  17254. return tx, nil
  17255. }
  17256. // SetID sets the value of the id field. Note that this
  17257. // operation is only accepted on creation of Label entities.
  17258. func (m *LabelMutation) SetID(id uint64) {
  17259. m.id = &id
  17260. }
  17261. // ID returns the ID value in the mutation. Note that the ID is only available
  17262. // if it was provided to the builder or after it was returned from the database.
  17263. func (m *LabelMutation) ID() (id uint64, exists bool) {
  17264. if m.id == nil {
  17265. return
  17266. }
  17267. return *m.id, true
  17268. }
  17269. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17270. // That means, if the mutation is applied within a transaction with an isolation level such
  17271. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17272. // or updated by the mutation.
  17273. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  17274. switch {
  17275. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17276. id, exists := m.ID()
  17277. if exists {
  17278. return []uint64{id}, nil
  17279. }
  17280. fallthrough
  17281. case m.op.Is(OpUpdate | OpDelete):
  17282. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  17283. default:
  17284. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17285. }
  17286. }
  17287. // SetCreatedAt sets the "created_at" field.
  17288. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  17289. m.created_at = &t
  17290. }
  17291. // CreatedAt returns the value of the "created_at" field in the mutation.
  17292. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  17293. v := m.created_at
  17294. if v == nil {
  17295. return
  17296. }
  17297. return *v, true
  17298. }
  17299. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  17300. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  17301. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17302. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17303. if !m.op.Is(OpUpdateOne) {
  17304. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17305. }
  17306. if m.id == nil || m.oldValue == nil {
  17307. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17308. }
  17309. oldValue, err := m.oldValue(ctx)
  17310. if err != nil {
  17311. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17312. }
  17313. return oldValue.CreatedAt, nil
  17314. }
  17315. // ResetCreatedAt resets all changes to the "created_at" field.
  17316. func (m *LabelMutation) ResetCreatedAt() {
  17317. m.created_at = nil
  17318. }
  17319. // SetUpdatedAt sets the "updated_at" field.
  17320. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  17321. m.updated_at = &t
  17322. }
  17323. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17324. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  17325. v := m.updated_at
  17326. if v == nil {
  17327. return
  17328. }
  17329. return *v, true
  17330. }
  17331. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  17332. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  17333. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17334. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17335. if !m.op.Is(OpUpdateOne) {
  17336. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17337. }
  17338. if m.id == nil || m.oldValue == nil {
  17339. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17340. }
  17341. oldValue, err := m.oldValue(ctx)
  17342. if err != nil {
  17343. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17344. }
  17345. return oldValue.UpdatedAt, nil
  17346. }
  17347. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17348. func (m *LabelMutation) ResetUpdatedAt() {
  17349. m.updated_at = nil
  17350. }
  17351. // SetStatus sets the "status" field.
  17352. func (m *LabelMutation) SetStatus(u uint8) {
  17353. m.status = &u
  17354. m.addstatus = nil
  17355. }
  17356. // Status returns the value of the "status" field in the mutation.
  17357. func (m *LabelMutation) Status() (r uint8, exists bool) {
  17358. v := m.status
  17359. if v == nil {
  17360. return
  17361. }
  17362. return *v, true
  17363. }
  17364. // OldStatus returns the old "status" field's value of the Label entity.
  17365. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  17366. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17367. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  17368. if !m.op.Is(OpUpdateOne) {
  17369. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  17370. }
  17371. if m.id == nil || m.oldValue == nil {
  17372. return v, errors.New("OldStatus requires an ID field in the mutation")
  17373. }
  17374. oldValue, err := m.oldValue(ctx)
  17375. if err != nil {
  17376. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  17377. }
  17378. return oldValue.Status, nil
  17379. }
  17380. // AddStatus adds u to the "status" field.
  17381. func (m *LabelMutation) AddStatus(u int8) {
  17382. if m.addstatus != nil {
  17383. *m.addstatus += u
  17384. } else {
  17385. m.addstatus = &u
  17386. }
  17387. }
  17388. // AddedStatus returns the value that was added to the "status" field in this mutation.
  17389. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  17390. v := m.addstatus
  17391. if v == nil {
  17392. return
  17393. }
  17394. return *v, true
  17395. }
  17396. // ClearStatus clears the value of the "status" field.
  17397. func (m *LabelMutation) ClearStatus() {
  17398. m.status = nil
  17399. m.addstatus = nil
  17400. m.clearedFields[label.FieldStatus] = struct{}{}
  17401. }
  17402. // StatusCleared returns if the "status" field was cleared in this mutation.
  17403. func (m *LabelMutation) StatusCleared() bool {
  17404. _, ok := m.clearedFields[label.FieldStatus]
  17405. return ok
  17406. }
  17407. // ResetStatus resets all changes to the "status" field.
  17408. func (m *LabelMutation) ResetStatus() {
  17409. m.status = nil
  17410. m.addstatus = nil
  17411. delete(m.clearedFields, label.FieldStatus)
  17412. }
  17413. // SetType sets the "type" field.
  17414. func (m *LabelMutation) SetType(i int) {
  17415. m._type = &i
  17416. m.add_type = nil
  17417. }
  17418. // GetType returns the value of the "type" field in the mutation.
  17419. func (m *LabelMutation) GetType() (r int, exists bool) {
  17420. v := m._type
  17421. if v == nil {
  17422. return
  17423. }
  17424. return *v, true
  17425. }
  17426. // OldType returns the old "type" field's value of the Label entity.
  17427. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  17428. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17429. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  17430. if !m.op.Is(OpUpdateOne) {
  17431. return v, errors.New("OldType is only allowed on UpdateOne operations")
  17432. }
  17433. if m.id == nil || m.oldValue == nil {
  17434. return v, errors.New("OldType requires an ID field in the mutation")
  17435. }
  17436. oldValue, err := m.oldValue(ctx)
  17437. if err != nil {
  17438. return v, fmt.Errorf("querying old value for OldType: %w", err)
  17439. }
  17440. return oldValue.Type, nil
  17441. }
  17442. // AddType adds i to the "type" field.
  17443. func (m *LabelMutation) AddType(i int) {
  17444. if m.add_type != nil {
  17445. *m.add_type += i
  17446. } else {
  17447. m.add_type = &i
  17448. }
  17449. }
  17450. // AddedType returns the value that was added to the "type" field in this mutation.
  17451. func (m *LabelMutation) AddedType() (r int, exists bool) {
  17452. v := m.add_type
  17453. if v == nil {
  17454. return
  17455. }
  17456. return *v, true
  17457. }
  17458. // ResetType resets all changes to the "type" field.
  17459. func (m *LabelMutation) ResetType() {
  17460. m._type = nil
  17461. m.add_type = nil
  17462. }
  17463. // SetName sets the "name" field.
  17464. func (m *LabelMutation) SetName(s string) {
  17465. m.name = &s
  17466. }
  17467. // Name returns the value of the "name" field in the mutation.
  17468. func (m *LabelMutation) Name() (r string, exists bool) {
  17469. v := m.name
  17470. if v == nil {
  17471. return
  17472. }
  17473. return *v, true
  17474. }
  17475. // OldName returns the old "name" field's value of the Label entity.
  17476. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  17477. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17478. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  17479. if !m.op.Is(OpUpdateOne) {
  17480. return v, errors.New("OldName is only allowed on UpdateOne operations")
  17481. }
  17482. if m.id == nil || m.oldValue == nil {
  17483. return v, errors.New("OldName requires an ID field in the mutation")
  17484. }
  17485. oldValue, err := m.oldValue(ctx)
  17486. if err != nil {
  17487. return v, fmt.Errorf("querying old value for OldName: %w", err)
  17488. }
  17489. return oldValue.Name, nil
  17490. }
  17491. // ResetName resets all changes to the "name" field.
  17492. func (m *LabelMutation) ResetName() {
  17493. m.name = nil
  17494. }
  17495. // SetFrom sets the "from" field.
  17496. func (m *LabelMutation) SetFrom(i int) {
  17497. m.from = &i
  17498. m.addfrom = nil
  17499. }
  17500. // From returns the value of the "from" field in the mutation.
  17501. func (m *LabelMutation) From() (r int, exists bool) {
  17502. v := m.from
  17503. if v == nil {
  17504. return
  17505. }
  17506. return *v, true
  17507. }
  17508. // OldFrom returns the old "from" field's value of the Label entity.
  17509. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  17510. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17511. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  17512. if !m.op.Is(OpUpdateOne) {
  17513. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  17514. }
  17515. if m.id == nil || m.oldValue == nil {
  17516. return v, errors.New("OldFrom requires an ID field in the mutation")
  17517. }
  17518. oldValue, err := m.oldValue(ctx)
  17519. if err != nil {
  17520. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  17521. }
  17522. return oldValue.From, nil
  17523. }
  17524. // AddFrom adds i to the "from" field.
  17525. func (m *LabelMutation) AddFrom(i int) {
  17526. if m.addfrom != nil {
  17527. *m.addfrom += i
  17528. } else {
  17529. m.addfrom = &i
  17530. }
  17531. }
  17532. // AddedFrom returns the value that was added to the "from" field in this mutation.
  17533. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  17534. v := m.addfrom
  17535. if v == nil {
  17536. return
  17537. }
  17538. return *v, true
  17539. }
  17540. // ResetFrom resets all changes to the "from" field.
  17541. func (m *LabelMutation) ResetFrom() {
  17542. m.from = nil
  17543. m.addfrom = nil
  17544. }
  17545. // SetMode sets the "mode" field.
  17546. func (m *LabelMutation) SetMode(i int) {
  17547. m.mode = &i
  17548. m.addmode = nil
  17549. }
  17550. // Mode returns the value of the "mode" field in the mutation.
  17551. func (m *LabelMutation) Mode() (r int, exists bool) {
  17552. v := m.mode
  17553. if v == nil {
  17554. return
  17555. }
  17556. return *v, true
  17557. }
  17558. // OldMode returns the old "mode" field's value of the Label entity.
  17559. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  17560. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17561. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  17562. if !m.op.Is(OpUpdateOne) {
  17563. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  17564. }
  17565. if m.id == nil || m.oldValue == nil {
  17566. return v, errors.New("OldMode requires an ID field in the mutation")
  17567. }
  17568. oldValue, err := m.oldValue(ctx)
  17569. if err != nil {
  17570. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  17571. }
  17572. return oldValue.Mode, nil
  17573. }
  17574. // AddMode adds i to the "mode" field.
  17575. func (m *LabelMutation) AddMode(i int) {
  17576. if m.addmode != nil {
  17577. *m.addmode += i
  17578. } else {
  17579. m.addmode = &i
  17580. }
  17581. }
  17582. // AddedMode returns the value that was added to the "mode" field in this mutation.
  17583. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  17584. v := m.addmode
  17585. if v == nil {
  17586. return
  17587. }
  17588. return *v, true
  17589. }
  17590. // ResetMode resets all changes to the "mode" field.
  17591. func (m *LabelMutation) ResetMode() {
  17592. m.mode = nil
  17593. m.addmode = nil
  17594. }
  17595. // SetConditions sets the "conditions" field.
  17596. func (m *LabelMutation) SetConditions(s string) {
  17597. m.conditions = &s
  17598. }
  17599. // Conditions returns the value of the "conditions" field in the mutation.
  17600. func (m *LabelMutation) Conditions() (r string, exists bool) {
  17601. v := m.conditions
  17602. if v == nil {
  17603. return
  17604. }
  17605. return *v, true
  17606. }
  17607. // OldConditions returns the old "conditions" field's value of the Label entity.
  17608. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  17609. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17610. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  17611. if !m.op.Is(OpUpdateOne) {
  17612. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  17613. }
  17614. if m.id == nil || m.oldValue == nil {
  17615. return v, errors.New("OldConditions requires an ID field in the mutation")
  17616. }
  17617. oldValue, err := m.oldValue(ctx)
  17618. if err != nil {
  17619. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  17620. }
  17621. return oldValue.Conditions, nil
  17622. }
  17623. // ClearConditions clears the value of the "conditions" field.
  17624. func (m *LabelMutation) ClearConditions() {
  17625. m.conditions = nil
  17626. m.clearedFields[label.FieldConditions] = struct{}{}
  17627. }
  17628. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  17629. func (m *LabelMutation) ConditionsCleared() bool {
  17630. _, ok := m.clearedFields[label.FieldConditions]
  17631. return ok
  17632. }
  17633. // ResetConditions resets all changes to the "conditions" field.
  17634. func (m *LabelMutation) ResetConditions() {
  17635. m.conditions = nil
  17636. delete(m.clearedFields, label.FieldConditions)
  17637. }
  17638. // SetOrganizationID sets the "organization_id" field.
  17639. func (m *LabelMutation) SetOrganizationID(u uint64) {
  17640. m.organization_id = &u
  17641. m.addorganization_id = nil
  17642. }
  17643. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17644. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  17645. v := m.organization_id
  17646. if v == nil {
  17647. return
  17648. }
  17649. return *v, true
  17650. }
  17651. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  17652. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  17653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17654. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17655. if !m.op.Is(OpUpdateOne) {
  17656. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17657. }
  17658. if m.id == nil || m.oldValue == nil {
  17659. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17660. }
  17661. oldValue, err := m.oldValue(ctx)
  17662. if err != nil {
  17663. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17664. }
  17665. return oldValue.OrganizationID, nil
  17666. }
  17667. // AddOrganizationID adds u to the "organization_id" field.
  17668. func (m *LabelMutation) AddOrganizationID(u int64) {
  17669. if m.addorganization_id != nil {
  17670. *m.addorganization_id += u
  17671. } else {
  17672. m.addorganization_id = &u
  17673. }
  17674. }
  17675. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17676. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  17677. v := m.addorganization_id
  17678. if v == nil {
  17679. return
  17680. }
  17681. return *v, true
  17682. }
  17683. // ClearOrganizationID clears the value of the "organization_id" field.
  17684. func (m *LabelMutation) ClearOrganizationID() {
  17685. m.organization_id = nil
  17686. m.addorganization_id = nil
  17687. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  17688. }
  17689. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  17690. func (m *LabelMutation) OrganizationIDCleared() bool {
  17691. _, ok := m.clearedFields[label.FieldOrganizationID]
  17692. return ok
  17693. }
  17694. // ResetOrganizationID resets all changes to the "organization_id" field.
  17695. func (m *LabelMutation) ResetOrganizationID() {
  17696. m.organization_id = nil
  17697. m.addorganization_id = nil
  17698. delete(m.clearedFields, label.FieldOrganizationID)
  17699. }
  17700. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  17701. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  17702. if m.label_relationships == nil {
  17703. m.label_relationships = make(map[uint64]struct{})
  17704. }
  17705. for i := range ids {
  17706. m.label_relationships[ids[i]] = struct{}{}
  17707. }
  17708. }
  17709. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  17710. func (m *LabelMutation) ClearLabelRelationships() {
  17711. m.clearedlabel_relationships = true
  17712. }
  17713. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  17714. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  17715. return m.clearedlabel_relationships
  17716. }
  17717. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  17718. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  17719. if m.removedlabel_relationships == nil {
  17720. m.removedlabel_relationships = make(map[uint64]struct{})
  17721. }
  17722. for i := range ids {
  17723. delete(m.label_relationships, ids[i])
  17724. m.removedlabel_relationships[ids[i]] = struct{}{}
  17725. }
  17726. }
  17727. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  17728. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  17729. for id := range m.removedlabel_relationships {
  17730. ids = append(ids, id)
  17731. }
  17732. return
  17733. }
  17734. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  17735. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  17736. for id := range m.label_relationships {
  17737. ids = append(ids, id)
  17738. }
  17739. return
  17740. }
  17741. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  17742. func (m *LabelMutation) ResetLabelRelationships() {
  17743. m.label_relationships = nil
  17744. m.clearedlabel_relationships = false
  17745. m.removedlabel_relationships = nil
  17746. }
  17747. // Where appends a list predicates to the LabelMutation builder.
  17748. func (m *LabelMutation) Where(ps ...predicate.Label) {
  17749. m.predicates = append(m.predicates, ps...)
  17750. }
  17751. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  17752. // users can use type-assertion to append predicates that do not depend on any generated package.
  17753. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  17754. p := make([]predicate.Label, len(ps))
  17755. for i := range ps {
  17756. p[i] = ps[i]
  17757. }
  17758. m.Where(p...)
  17759. }
  17760. // Op returns the operation name.
  17761. func (m *LabelMutation) Op() Op {
  17762. return m.op
  17763. }
  17764. // SetOp allows setting the mutation operation.
  17765. func (m *LabelMutation) SetOp(op Op) {
  17766. m.op = op
  17767. }
  17768. // Type returns the node type of this mutation (Label).
  17769. func (m *LabelMutation) Type() string {
  17770. return m.typ
  17771. }
  17772. // Fields returns all fields that were changed during this mutation. Note that in
  17773. // order to get all numeric fields that were incremented/decremented, call
  17774. // AddedFields().
  17775. func (m *LabelMutation) Fields() []string {
  17776. fields := make([]string, 0, 9)
  17777. if m.created_at != nil {
  17778. fields = append(fields, label.FieldCreatedAt)
  17779. }
  17780. if m.updated_at != nil {
  17781. fields = append(fields, label.FieldUpdatedAt)
  17782. }
  17783. if m.status != nil {
  17784. fields = append(fields, label.FieldStatus)
  17785. }
  17786. if m._type != nil {
  17787. fields = append(fields, label.FieldType)
  17788. }
  17789. if m.name != nil {
  17790. fields = append(fields, label.FieldName)
  17791. }
  17792. if m.from != nil {
  17793. fields = append(fields, label.FieldFrom)
  17794. }
  17795. if m.mode != nil {
  17796. fields = append(fields, label.FieldMode)
  17797. }
  17798. if m.conditions != nil {
  17799. fields = append(fields, label.FieldConditions)
  17800. }
  17801. if m.organization_id != nil {
  17802. fields = append(fields, label.FieldOrganizationID)
  17803. }
  17804. return fields
  17805. }
  17806. // Field returns the value of a field with the given name. The second boolean
  17807. // return value indicates that this field was not set, or was not defined in the
  17808. // schema.
  17809. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  17810. switch name {
  17811. case label.FieldCreatedAt:
  17812. return m.CreatedAt()
  17813. case label.FieldUpdatedAt:
  17814. return m.UpdatedAt()
  17815. case label.FieldStatus:
  17816. return m.Status()
  17817. case label.FieldType:
  17818. return m.GetType()
  17819. case label.FieldName:
  17820. return m.Name()
  17821. case label.FieldFrom:
  17822. return m.From()
  17823. case label.FieldMode:
  17824. return m.Mode()
  17825. case label.FieldConditions:
  17826. return m.Conditions()
  17827. case label.FieldOrganizationID:
  17828. return m.OrganizationID()
  17829. }
  17830. return nil, false
  17831. }
  17832. // OldField returns the old value of the field from the database. An error is
  17833. // returned if the mutation operation is not UpdateOne, or the query to the
  17834. // database failed.
  17835. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17836. switch name {
  17837. case label.FieldCreatedAt:
  17838. return m.OldCreatedAt(ctx)
  17839. case label.FieldUpdatedAt:
  17840. return m.OldUpdatedAt(ctx)
  17841. case label.FieldStatus:
  17842. return m.OldStatus(ctx)
  17843. case label.FieldType:
  17844. return m.OldType(ctx)
  17845. case label.FieldName:
  17846. return m.OldName(ctx)
  17847. case label.FieldFrom:
  17848. return m.OldFrom(ctx)
  17849. case label.FieldMode:
  17850. return m.OldMode(ctx)
  17851. case label.FieldConditions:
  17852. return m.OldConditions(ctx)
  17853. case label.FieldOrganizationID:
  17854. return m.OldOrganizationID(ctx)
  17855. }
  17856. return nil, fmt.Errorf("unknown Label field %s", name)
  17857. }
  17858. // SetField sets the value of a field with the given name. It returns an error if
  17859. // the field is not defined in the schema, or if the type mismatched the field
  17860. // type.
  17861. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  17862. switch name {
  17863. case label.FieldCreatedAt:
  17864. v, ok := value.(time.Time)
  17865. if !ok {
  17866. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17867. }
  17868. m.SetCreatedAt(v)
  17869. return nil
  17870. case label.FieldUpdatedAt:
  17871. v, ok := value.(time.Time)
  17872. if !ok {
  17873. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17874. }
  17875. m.SetUpdatedAt(v)
  17876. return nil
  17877. case label.FieldStatus:
  17878. v, ok := value.(uint8)
  17879. if !ok {
  17880. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17881. }
  17882. m.SetStatus(v)
  17883. return nil
  17884. case label.FieldType:
  17885. v, ok := value.(int)
  17886. if !ok {
  17887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17888. }
  17889. m.SetType(v)
  17890. return nil
  17891. case label.FieldName:
  17892. v, ok := value.(string)
  17893. if !ok {
  17894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17895. }
  17896. m.SetName(v)
  17897. return nil
  17898. case label.FieldFrom:
  17899. v, ok := value.(int)
  17900. if !ok {
  17901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17902. }
  17903. m.SetFrom(v)
  17904. return nil
  17905. case label.FieldMode:
  17906. v, ok := value.(int)
  17907. if !ok {
  17908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17909. }
  17910. m.SetMode(v)
  17911. return nil
  17912. case label.FieldConditions:
  17913. v, ok := value.(string)
  17914. if !ok {
  17915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17916. }
  17917. m.SetConditions(v)
  17918. return nil
  17919. case label.FieldOrganizationID:
  17920. v, ok := value.(uint64)
  17921. if !ok {
  17922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17923. }
  17924. m.SetOrganizationID(v)
  17925. return nil
  17926. }
  17927. return fmt.Errorf("unknown Label field %s", name)
  17928. }
  17929. // AddedFields returns all numeric fields that were incremented/decremented during
  17930. // this mutation.
  17931. func (m *LabelMutation) AddedFields() []string {
  17932. var fields []string
  17933. if m.addstatus != nil {
  17934. fields = append(fields, label.FieldStatus)
  17935. }
  17936. if m.add_type != nil {
  17937. fields = append(fields, label.FieldType)
  17938. }
  17939. if m.addfrom != nil {
  17940. fields = append(fields, label.FieldFrom)
  17941. }
  17942. if m.addmode != nil {
  17943. fields = append(fields, label.FieldMode)
  17944. }
  17945. if m.addorganization_id != nil {
  17946. fields = append(fields, label.FieldOrganizationID)
  17947. }
  17948. return fields
  17949. }
  17950. // AddedField returns the numeric value that was incremented/decremented on a field
  17951. // with the given name. The second boolean return value indicates that this field
  17952. // was not set, or was not defined in the schema.
  17953. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  17954. switch name {
  17955. case label.FieldStatus:
  17956. return m.AddedStatus()
  17957. case label.FieldType:
  17958. return m.AddedType()
  17959. case label.FieldFrom:
  17960. return m.AddedFrom()
  17961. case label.FieldMode:
  17962. return m.AddedMode()
  17963. case label.FieldOrganizationID:
  17964. return m.AddedOrganizationID()
  17965. }
  17966. return nil, false
  17967. }
  17968. // AddField adds the value to the field with the given name. It returns an error if
  17969. // the field is not defined in the schema, or if the type mismatched the field
  17970. // type.
  17971. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  17972. switch name {
  17973. case label.FieldStatus:
  17974. v, ok := value.(int8)
  17975. if !ok {
  17976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17977. }
  17978. m.AddStatus(v)
  17979. return nil
  17980. case label.FieldType:
  17981. v, ok := value.(int)
  17982. if !ok {
  17983. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17984. }
  17985. m.AddType(v)
  17986. return nil
  17987. case label.FieldFrom:
  17988. v, ok := value.(int)
  17989. if !ok {
  17990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17991. }
  17992. m.AddFrom(v)
  17993. return nil
  17994. case label.FieldMode:
  17995. v, ok := value.(int)
  17996. if !ok {
  17997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17998. }
  17999. m.AddMode(v)
  18000. return nil
  18001. case label.FieldOrganizationID:
  18002. v, ok := value.(int64)
  18003. if !ok {
  18004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18005. }
  18006. m.AddOrganizationID(v)
  18007. return nil
  18008. }
  18009. return fmt.Errorf("unknown Label numeric field %s", name)
  18010. }
  18011. // ClearedFields returns all nullable fields that were cleared during this
  18012. // mutation.
  18013. func (m *LabelMutation) ClearedFields() []string {
  18014. var fields []string
  18015. if m.FieldCleared(label.FieldStatus) {
  18016. fields = append(fields, label.FieldStatus)
  18017. }
  18018. if m.FieldCleared(label.FieldConditions) {
  18019. fields = append(fields, label.FieldConditions)
  18020. }
  18021. if m.FieldCleared(label.FieldOrganizationID) {
  18022. fields = append(fields, label.FieldOrganizationID)
  18023. }
  18024. return fields
  18025. }
  18026. // FieldCleared returns a boolean indicating if a field with the given name was
  18027. // cleared in this mutation.
  18028. func (m *LabelMutation) FieldCleared(name string) bool {
  18029. _, ok := m.clearedFields[name]
  18030. return ok
  18031. }
  18032. // ClearField clears the value of the field with the given name. It returns an
  18033. // error if the field is not defined in the schema.
  18034. func (m *LabelMutation) ClearField(name string) error {
  18035. switch name {
  18036. case label.FieldStatus:
  18037. m.ClearStatus()
  18038. return nil
  18039. case label.FieldConditions:
  18040. m.ClearConditions()
  18041. return nil
  18042. case label.FieldOrganizationID:
  18043. m.ClearOrganizationID()
  18044. return nil
  18045. }
  18046. return fmt.Errorf("unknown Label nullable field %s", name)
  18047. }
  18048. // ResetField resets all changes in the mutation for the field with the given name.
  18049. // It returns an error if the field is not defined in the schema.
  18050. func (m *LabelMutation) ResetField(name string) error {
  18051. switch name {
  18052. case label.FieldCreatedAt:
  18053. m.ResetCreatedAt()
  18054. return nil
  18055. case label.FieldUpdatedAt:
  18056. m.ResetUpdatedAt()
  18057. return nil
  18058. case label.FieldStatus:
  18059. m.ResetStatus()
  18060. return nil
  18061. case label.FieldType:
  18062. m.ResetType()
  18063. return nil
  18064. case label.FieldName:
  18065. m.ResetName()
  18066. return nil
  18067. case label.FieldFrom:
  18068. m.ResetFrom()
  18069. return nil
  18070. case label.FieldMode:
  18071. m.ResetMode()
  18072. return nil
  18073. case label.FieldConditions:
  18074. m.ResetConditions()
  18075. return nil
  18076. case label.FieldOrganizationID:
  18077. m.ResetOrganizationID()
  18078. return nil
  18079. }
  18080. return fmt.Errorf("unknown Label field %s", name)
  18081. }
  18082. // AddedEdges returns all edge names that were set/added in this mutation.
  18083. func (m *LabelMutation) AddedEdges() []string {
  18084. edges := make([]string, 0, 1)
  18085. if m.label_relationships != nil {
  18086. edges = append(edges, label.EdgeLabelRelationships)
  18087. }
  18088. return edges
  18089. }
  18090. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18091. // name in this mutation.
  18092. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  18093. switch name {
  18094. case label.EdgeLabelRelationships:
  18095. ids := make([]ent.Value, 0, len(m.label_relationships))
  18096. for id := range m.label_relationships {
  18097. ids = append(ids, id)
  18098. }
  18099. return ids
  18100. }
  18101. return nil
  18102. }
  18103. // RemovedEdges returns all edge names that were removed in this mutation.
  18104. func (m *LabelMutation) RemovedEdges() []string {
  18105. edges := make([]string, 0, 1)
  18106. if m.removedlabel_relationships != nil {
  18107. edges = append(edges, label.EdgeLabelRelationships)
  18108. }
  18109. return edges
  18110. }
  18111. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18112. // the given name in this mutation.
  18113. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  18114. switch name {
  18115. case label.EdgeLabelRelationships:
  18116. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  18117. for id := range m.removedlabel_relationships {
  18118. ids = append(ids, id)
  18119. }
  18120. return ids
  18121. }
  18122. return nil
  18123. }
  18124. // ClearedEdges returns all edge names that were cleared in this mutation.
  18125. func (m *LabelMutation) ClearedEdges() []string {
  18126. edges := make([]string, 0, 1)
  18127. if m.clearedlabel_relationships {
  18128. edges = append(edges, label.EdgeLabelRelationships)
  18129. }
  18130. return edges
  18131. }
  18132. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18133. // was cleared in this mutation.
  18134. func (m *LabelMutation) EdgeCleared(name string) bool {
  18135. switch name {
  18136. case label.EdgeLabelRelationships:
  18137. return m.clearedlabel_relationships
  18138. }
  18139. return false
  18140. }
  18141. // ClearEdge clears the value of the edge with the given name. It returns an error
  18142. // if that edge is not defined in the schema.
  18143. func (m *LabelMutation) ClearEdge(name string) error {
  18144. switch name {
  18145. }
  18146. return fmt.Errorf("unknown Label unique edge %s", name)
  18147. }
  18148. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18149. // It returns an error if the edge is not defined in the schema.
  18150. func (m *LabelMutation) ResetEdge(name string) error {
  18151. switch name {
  18152. case label.EdgeLabelRelationships:
  18153. m.ResetLabelRelationships()
  18154. return nil
  18155. }
  18156. return fmt.Errorf("unknown Label edge %s", name)
  18157. }
  18158. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  18159. type LabelRelationshipMutation struct {
  18160. config
  18161. op Op
  18162. typ string
  18163. id *uint64
  18164. created_at *time.Time
  18165. updated_at *time.Time
  18166. status *uint8
  18167. addstatus *int8
  18168. organization_id *uint64
  18169. addorganization_id *int64
  18170. clearedFields map[string]struct{}
  18171. contacts *uint64
  18172. clearedcontacts bool
  18173. labels *uint64
  18174. clearedlabels bool
  18175. done bool
  18176. oldValue func(context.Context) (*LabelRelationship, error)
  18177. predicates []predicate.LabelRelationship
  18178. }
  18179. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  18180. // labelrelationshipOption allows management of the mutation configuration using functional options.
  18181. type labelrelationshipOption func(*LabelRelationshipMutation)
  18182. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  18183. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  18184. m := &LabelRelationshipMutation{
  18185. config: c,
  18186. op: op,
  18187. typ: TypeLabelRelationship,
  18188. clearedFields: make(map[string]struct{}),
  18189. }
  18190. for _, opt := range opts {
  18191. opt(m)
  18192. }
  18193. return m
  18194. }
  18195. // withLabelRelationshipID sets the ID field of the mutation.
  18196. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  18197. return func(m *LabelRelationshipMutation) {
  18198. var (
  18199. err error
  18200. once sync.Once
  18201. value *LabelRelationship
  18202. )
  18203. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  18204. once.Do(func() {
  18205. if m.done {
  18206. err = errors.New("querying old values post mutation is not allowed")
  18207. } else {
  18208. value, err = m.Client().LabelRelationship.Get(ctx, id)
  18209. }
  18210. })
  18211. return value, err
  18212. }
  18213. m.id = &id
  18214. }
  18215. }
  18216. // withLabelRelationship sets the old LabelRelationship of the mutation.
  18217. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  18218. return func(m *LabelRelationshipMutation) {
  18219. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  18220. return node, nil
  18221. }
  18222. m.id = &node.ID
  18223. }
  18224. }
  18225. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18226. // executed in a transaction (ent.Tx), a transactional client is returned.
  18227. func (m LabelRelationshipMutation) Client() *Client {
  18228. client := &Client{config: m.config}
  18229. client.init()
  18230. return client
  18231. }
  18232. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18233. // it returns an error otherwise.
  18234. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  18235. if _, ok := m.driver.(*txDriver); !ok {
  18236. return nil, errors.New("ent: mutation is not running in a transaction")
  18237. }
  18238. tx := &Tx{config: m.config}
  18239. tx.init()
  18240. return tx, nil
  18241. }
  18242. // SetID sets the value of the id field. Note that this
  18243. // operation is only accepted on creation of LabelRelationship entities.
  18244. func (m *LabelRelationshipMutation) SetID(id uint64) {
  18245. m.id = &id
  18246. }
  18247. // ID returns the ID value in the mutation. Note that the ID is only available
  18248. // if it was provided to the builder or after it was returned from the database.
  18249. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  18250. if m.id == nil {
  18251. return
  18252. }
  18253. return *m.id, true
  18254. }
  18255. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18256. // That means, if the mutation is applied within a transaction with an isolation level such
  18257. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18258. // or updated by the mutation.
  18259. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  18260. switch {
  18261. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18262. id, exists := m.ID()
  18263. if exists {
  18264. return []uint64{id}, nil
  18265. }
  18266. fallthrough
  18267. case m.op.Is(OpUpdate | OpDelete):
  18268. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  18269. default:
  18270. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18271. }
  18272. }
  18273. // SetCreatedAt sets the "created_at" field.
  18274. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  18275. m.created_at = &t
  18276. }
  18277. // CreatedAt returns the value of the "created_at" field in the mutation.
  18278. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  18279. v := m.created_at
  18280. if v == nil {
  18281. return
  18282. }
  18283. return *v, true
  18284. }
  18285. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  18286. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  18287. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18288. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18289. if !m.op.Is(OpUpdateOne) {
  18290. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18291. }
  18292. if m.id == nil || m.oldValue == nil {
  18293. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18294. }
  18295. oldValue, err := m.oldValue(ctx)
  18296. if err != nil {
  18297. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18298. }
  18299. return oldValue.CreatedAt, nil
  18300. }
  18301. // ResetCreatedAt resets all changes to the "created_at" field.
  18302. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  18303. m.created_at = nil
  18304. }
  18305. // SetUpdatedAt sets the "updated_at" field.
  18306. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  18307. m.updated_at = &t
  18308. }
  18309. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18310. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  18311. v := m.updated_at
  18312. if v == nil {
  18313. return
  18314. }
  18315. return *v, true
  18316. }
  18317. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  18318. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  18319. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18320. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18321. if !m.op.Is(OpUpdateOne) {
  18322. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18323. }
  18324. if m.id == nil || m.oldValue == nil {
  18325. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18326. }
  18327. oldValue, err := m.oldValue(ctx)
  18328. if err != nil {
  18329. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18330. }
  18331. return oldValue.UpdatedAt, nil
  18332. }
  18333. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18334. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  18335. m.updated_at = nil
  18336. }
  18337. // SetStatus sets the "status" field.
  18338. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  18339. m.status = &u
  18340. m.addstatus = nil
  18341. }
  18342. // Status returns the value of the "status" field in the mutation.
  18343. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  18344. v := m.status
  18345. if v == nil {
  18346. return
  18347. }
  18348. return *v, true
  18349. }
  18350. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  18351. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  18352. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18353. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  18354. if !m.op.Is(OpUpdateOne) {
  18355. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  18356. }
  18357. if m.id == nil || m.oldValue == nil {
  18358. return v, errors.New("OldStatus requires an ID field in the mutation")
  18359. }
  18360. oldValue, err := m.oldValue(ctx)
  18361. if err != nil {
  18362. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  18363. }
  18364. return oldValue.Status, nil
  18365. }
  18366. // AddStatus adds u to the "status" field.
  18367. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  18368. if m.addstatus != nil {
  18369. *m.addstatus += u
  18370. } else {
  18371. m.addstatus = &u
  18372. }
  18373. }
  18374. // AddedStatus returns the value that was added to the "status" field in this mutation.
  18375. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  18376. v := m.addstatus
  18377. if v == nil {
  18378. return
  18379. }
  18380. return *v, true
  18381. }
  18382. // ClearStatus clears the value of the "status" field.
  18383. func (m *LabelRelationshipMutation) ClearStatus() {
  18384. m.status = nil
  18385. m.addstatus = nil
  18386. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  18387. }
  18388. // StatusCleared returns if the "status" field was cleared in this mutation.
  18389. func (m *LabelRelationshipMutation) StatusCleared() bool {
  18390. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  18391. return ok
  18392. }
  18393. // ResetStatus resets all changes to the "status" field.
  18394. func (m *LabelRelationshipMutation) ResetStatus() {
  18395. m.status = nil
  18396. m.addstatus = nil
  18397. delete(m.clearedFields, labelrelationship.FieldStatus)
  18398. }
  18399. // SetLabelID sets the "label_id" field.
  18400. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  18401. m.labels = &u
  18402. }
  18403. // LabelID returns the value of the "label_id" field in the mutation.
  18404. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  18405. v := m.labels
  18406. if v == nil {
  18407. return
  18408. }
  18409. return *v, true
  18410. }
  18411. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  18412. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  18413. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18414. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  18415. if !m.op.Is(OpUpdateOne) {
  18416. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  18417. }
  18418. if m.id == nil || m.oldValue == nil {
  18419. return v, errors.New("OldLabelID requires an ID field in the mutation")
  18420. }
  18421. oldValue, err := m.oldValue(ctx)
  18422. if err != nil {
  18423. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  18424. }
  18425. return oldValue.LabelID, nil
  18426. }
  18427. // ResetLabelID resets all changes to the "label_id" field.
  18428. func (m *LabelRelationshipMutation) ResetLabelID() {
  18429. m.labels = nil
  18430. }
  18431. // SetContactID sets the "contact_id" field.
  18432. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  18433. m.contacts = &u
  18434. }
  18435. // ContactID returns the value of the "contact_id" field in the mutation.
  18436. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  18437. v := m.contacts
  18438. if v == nil {
  18439. return
  18440. }
  18441. return *v, true
  18442. }
  18443. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  18444. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  18445. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18446. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  18447. if !m.op.Is(OpUpdateOne) {
  18448. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  18449. }
  18450. if m.id == nil || m.oldValue == nil {
  18451. return v, errors.New("OldContactID requires an ID field in the mutation")
  18452. }
  18453. oldValue, err := m.oldValue(ctx)
  18454. if err != nil {
  18455. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  18456. }
  18457. return oldValue.ContactID, nil
  18458. }
  18459. // ResetContactID resets all changes to the "contact_id" field.
  18460. func (m *LabelRelationshipMutation) ResetContactID() {
  18461. m.contacts = nil
  18462. }
  18463. // SetOrganizationID sets the "organization_id" field.
  18464. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  18465. m.organization_id = &u
  18466. m.addorganization_id = nil
  18467. }
  18468. // OrganizationID returns the value of the "organization_id" field in the mutation.
  18469. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  18470. v := m.organization_id
  18471. if v == nil {
  18472. return
  18473. }
  18474. return *v, true
  18475. }
  18476. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  18477. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  18478. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18479. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  18480. if !m.op.Is(OpUpdateOne) {
  18481. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  18482. }
  18483. if m.id == nil || m.oldValue == nil {
  18484. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  18485. }
  18486. oldValue, err := m.oldValue(ctx)
  18487. if err != nil {
  18488. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  18489. }
  18490. return oldValue.OrganizationID, nil
  18491. }
  18492. // AddOrganizationID adds u to the "organization_id" field.
  18493. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  18494. if m.addorganization_id != nil {
  18495. *m.addorganization_id += u
  18496. } else {
  18497. m.addorganization_id = &u
  18498. }
  18499. }
  18500. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  18501. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  18502. v := m.addorganization_id
  18503. if v == nil {
  18504. return
  18505. }
  18506. return *v, true
  18507. }
  18508. // ClearOrganizationID clears the value of the "organization_id" field.
  18509. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  18510. m.organization_id = nil
  18511. m.addorganization_id = nil
  18512. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  18513. }
  18514. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  18515. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  18516. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  18517. return ok
  18518. }
  18519. // ResetOrganizationID resets all changes to the "organization_id" field.
  18520. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  18521. m.organization_id = nil
  18522. m.addorganization_id = nil
  18523. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  18524. }
  18525. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  18526. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  18527. m.contacts = &id
  18528. }
  18529. // ClearContacts clears the "contacts" edge to the Contact entity.
  18530. func (m *LabelRelationshipMutation) ClearContacts() {
  18531. m.clearedcontacts = true
  18532. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  18533. }
  18534. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  18535. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  18536. return m.clearedcontacts
  18537. }
  18538. // ContactsID returns the "contacts" edge ID in the mutation.
  18539. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  18540. if m.contacts != nil {
  18541. return *m.contacts, true
  18542. }
  18543. return
  18544. }
  18545. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  18546. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18547. // ContactsID instead. It exists only for internal usage by the builders.
  18548. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  18549. if id := m.contacts; id != nil {
  18550. ids = append(ids, *id)
  18551. }
  18552. return
  18553. }
  18554. // ResetContacts resets all changes to the "contacts" edge.
  18555. func (m *LabelRelationshipMutation) ResetContacts() {
  18556. m.contacts = nil
  18557. m.clearedcontacts = false
  18558. }
  18559. // SetLabelsID sets the "labels" edge to the Label entity by id.
  18560. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  18561. m.labels = &id
  18562. }
  18563. // ClearLabels clears the "labels" edge to the Label entity.
  18564. func (m *LabelRelationshipMutation) ClearLabels() {
  18565. m.clearedlabels = true
  18566. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  18567. }
  18568. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  18569. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  18570. return m.clearedlabels
  18571. }
  18572. // LabelsID returns the "labels" edge ID in the mutation.
  18573. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  18574. if m.labels != nil {
  18575. return *m.labels, true
  18576. }
  18577. return
  18578. }
  18579. // LabelsIDs returns the "labels" edge IDs in the mutation.
  18580. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18581. // LabelsID instead. It exists only for internal usage by the builders.
  18582. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  18583. if id := m.labels; id != nil {
  18584. ids = append(ids, *id)
  18585. }
  18586. return
  18587. }
  18588. // ResetLabels resets all changes to the "labels" edge.
  18589. func (m *LabelRelationshipMutation) ResetLabels() {
  18590. m.labels = nil
  18591. m.clearedlabels = false
  18592. }
  18593. // Where appends a list predicates to the LabelRelationshipMutation builder.
  18594. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  18595. m.predicates = append(m.predicates, ps...)
  18596. }
  18597. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  18598. // users can use type-assertion to append predicates that do not depend on any generated package.
  18599. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  18600. p := make([]predicate.LabelRelationship, len(ps))
  18601. for i := range ps {
  18602. p[i] = ps[i]
  18603. }
  18604. m.Where(p...)
  18605. }
  18606. // Op returns the operation name.
  18607. func (m *LabelRelationshipMutation) Op() Op {
  18608. return m.op
  18609. }
  18610. // SetOp allows setting the mutation operation.
  18611. func (m *LabelRelationshipMutation) SetOp(op Op) {
  18612. m.op = op
  18613. }
  18614. // Type returns the node type of this mutation (LabelRelationship).
  18615. func (m *LabelRelationshipMutation) Type() string {
  18616. return m.typ
  18617. }
  18618. // Fields returns all fields that were changed during this mutation. Note that in
  18619. // order to get all numeric fields that were incremented/decremented, call
  18620. // AddedFields().
  18621. func (m *LabelRelationshipMutation) Fields() []string {
  18622. fields := make([]string, 0, 6)
  18623. if m.created_at != nil {
  18624. fields = append(fields, labelrelationship.FieldCreatedAt)
  18625. }
  18626. if m.updated_at != nil {
  18627. fields = append(fields, labelrelationship.FieldUpdatedAt)
  18628. }
  18629. if m.status != nil {
  18630. fields = append(fields, labelrelationship.FieldStatus)
  18631. }
  18632. if m.labels != nil {
  18633. fields = append(fields, labelrelationship.FieldLabelID)
  18634. }
  18635. if m.contacts != nil {
  18636. fields = append(fields, labelrelationship.FieldContactID)
  18637. }
  18638. if m.organization_id != nil {
  18639. fields = append(fields, labelrelationship.FieldOrganizationID)
  18640. }
  18641. return fields
  18642. }
  18643. // Field returns the value of a field with the given name. The second boolean
  18644. // return value indicates that this field was not set, or was not defined in the
  18645. // schema.
  18646. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  18647. switch name {
  18648. case labelrelationship.FieldCreatedAt:
  18649. return m.CreatedAt()
  18650. case labelrelationship.FieldUpdatedAt:
  18651. return m.UpdatedAt()
  18652. case labelrelationship.FieldStatus:
  18653. return m.Status()
  18654. case labelrelationship.FieldLabelID:
  18655. return m.LabelID()
  18656. case labelrelationship.FieldContactID:
  18657. return m.ContactID()
  18658. case labelrelationship.FieldOrganizationID:
  18659. return m.OrganizationID()
  18660. }
  18661. return nil, false
  18662. }
  18663. // OldField returns the old value of the field from the database. An error is
  18664. // returned if the mutation operation is not UpdateOne, or the query to the
  18665. // database failed.
  18666. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18667. switch name {
  18668. case labelrelationship.FieldCreatedAt:
  18669. return m.OldCreatedAt(ctx)
  18670. case labelrelationship.FieldUpdatedAt:
  18671. return m.OldUpdatedAt(ctx)
  18672. case labelrelationship.FieldStatus:
  18673. return m.OldStatus(ctx)
  18674. case labelrelationship.FieldLabelID:
  18675. return m.OldLabelID(ctx)
  18676. case labelrelationship.FieldContactID:
  18677. return m.OldContactID(ctx)
  18678. case labelrelationship.FieldOrganizationID:
  18679. return m.OldOrganizationID(ctx)
  18680. }
  18681. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  18682. }
  18683. // SetField sets the value of a field with the given name. It returns an error if
  18684. // the field is not defined in the schema, or if the type mismatched the field
  18685. // type.
  18686. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  18687. switch name {
  18688. case labelrelationship.FieldCreatedAt:
  18689. v, ok := value.(time.Time)
  18690. if !ok {
  18691. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18692. }
  18693. m.SetCreatedAt(v)
  18694. return nil
  18695. case labelrelationship.FieldUpdatedAt:
  18696. v, ok := value.(time.Time)
  18697. if !ok {
  18698. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18699. }
  18700. m.SetUpdatedAt(v)
  18701. return nil
  18702. case labelrelationship.FieldStatus:
  18703. v, ok := value.(uint8)
  18704. if !ok {
  18705. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18706. }
  18707. m.SetStatus(v)
  18708. return nil
  18709. case labelrelationship.FieldLabelID:
  18710. v, ok := value.(uint64)
  18711. if !ok {
  18712. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18713. }
  18714. m.SetLabelID(v)
  18715. return nil
  18716. case labelrelationship.FieldContactID:
  18717. v, ok := value.(uint64)
  18718. if !ok {
  18719. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18720. }
  18721. m.SetContactID(v)
  18722. return nil
  18723. case labelrelationship.FieldOrganizationID:
  18724. v, ok := value.(uint64)
  18725. if !ok {
  18726. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18727. }
  18728. m.SetOrganizationID(v)
  18729. return nil
  18730. }
  18731. return fmt.Errorf("unknown LabelRelationship field %s", name)
  18732. }
  18733. // AddedFields returns all numeric fields that were incremented/decremented during
  18734. // this mutation.
  18735. func (m *LabelRelationshipMutation) AddedFields() []string {
  18736. var fields []string
  18737. if m.addstatus != nil {
  18738. fields = append(fields, labelrelationship.FieldStatus)
  18739. }
  18740. if m.addorganization_id != nil {
  18741. fields = append(fields, labelrelationship.FieldOrganizationID)
  18742. }
  18743. return fields
  18744. }
  18745. // AddedField returns the numeric value that was incremented/decremented on a field
  18746. // with the given name. The second boolean return value indicates that this field
  18747. // was not set, or was not defined in the schema.
  18748. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  18749. switch name {
  18750. case labelrelationship.FieldStatus:
  18751. return m.AddedStatus()
  18752. case labelrelationship.FieldOrganizationID:
  18753. return m.AddedOrganizationID()
  18754. }
  18755. return nil, false
  18756. }
  18757. // AddField adds the value to the field with the given name. It returns an error if
  18758. // the field is not defined in the schema, or if the type mismatched the field
  18759. // type.
  18760. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  18761. switch name {
  18762. case labelrelationship.FieldStatus:
  18763. v, ok := value.(int8)
  18764. if !ok {
  18765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18766. }
  18767. m.AddStatus(v)
  18768. return nil
  18769. case labelrelationship.FieldOrganizationID:
  18770. v, ok := value.(int64)
  18771. if !ok {
  18772. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18773. }
  18774. m.AddOrganizationID(v)
  18775. return nil
  18776. }
  18777. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  18778. }
  18779. // ClearedFields returns all nullable fields that were cleared during this
  18780. // mutation.
  18781. func (m *LabelRelationshipMutation) ClearedFields() []string {
  18782. var fields []string
  18783. if m.FieldCleared(labelrelationship.FieldStatus) {
  18784. fields = append(fields, labelrelationship.FieldStatus)
  18785. }
  18786. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  18787. fields = append(fields, labelrelationship.FieldOrganizationID)
  18788. }
  18789. return fields
  18790. }
  18791. // FieldCleared returns a boolean indicating if a field with the given name was
  18792. // cleared in this mutation.
  18793. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  18794. _, ok := m.clearedFields[name]
  18795. return ok
  18796. }
  18797. // ClearField clears the value of the field with the given name. It returns an
  18798. // error if the field is not defined in the schema.
  18799. func (m *LabelRelationshipMutation) ClearField(name string) error {
  18800. switch name {
  18801. case labelrelationship.FieldStatus:
  18802. m.ClearStatus()
  18803. return nil
  18804. case labelrelationship.FieldOrganizationID:
  18805. m.ClearOrganizationID()
  18806. return nil
  18807. }
  18808. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  18809. }
  18810. // ResetField resets all changes in the mutation for the field with the given name.
  18811. // It returns an error if the field is not defined in the schema.
  18812. func (m *LabelRelationshipMutation) ResetField(name string) error {
  18813. switch name {
  18814. case labelrelationship.FieldCreatedAt:
  18815. m.ResetCreatedAt()
  18816. return nil
  18817. case labelrelationship.FieldUpdatedAt:
  18818. m.ResetUpdatedAt()
  18819. return nil
  18820. case labelrelationship.FieldStatus:
  18821. m.ResetStatus()
  18822. return nil
  18823. case labelrelationship.FieldLabelID:
  18824. m.ResetLabelID()
  18825. return nil
  18826. case labelrelationship.FieldContactID:
  18827. m.ResetContactID()
  18828. return nil
  18829. case labelrelationship.FieldOrganizationID:
  18830. m.ResetOrganizationID()
  18831. return nil
  18832. }
  18833. return fmt.Errorf("unknown LabelRelationship field %s", name)
  18834. }
  18835. // AddedEdges returns all edge names that were set/added in this mutation.
  18836. func (m *LabelRelationshipMutation) AddedEdges() []string {
  18837. edges := make([]string, 0, 2)
  18838. if m.contacts != nil {
  18839. edges = append(edges, labelrelationship.EdgeContacts)
  18840. }
  18841. if m.labels != nil {
  18842. edges = append(edges, labelrelationship.EdgeLabels)
  18843. }
  18844. return edges
  18845. }
  18846. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18847. // name in this mutation.
  18848. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  18849. switch name {
  18850. case labelrelationship.EdgeContacts:
  18851. if id := m.contacts; id != nil {
  18852. return []ent.Value{*id}
  18853. }
  18854. case labelrelationship.EdgeLabels:
  18855. if id := m.labels; id != nil {
  18856. return []ent.Value{*id}
  18857. }
  18858. }
  18859. return nil
  18860. }
  18861. // RemovedEdges returns all edge names that were removed in this mutation.
  18862. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  18863. edges := make([]string, 0, 2)
  18864. return edges
  18865. }
  18866. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18867. // the given name in this mutation.
  18868. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  18869. return nil
  18870. }
  18871. // ClearedEdges returns all edge names that were cleared in this mutation.
  18872. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  18873. edges := make([]string, 0, 2)
  18874. if m.clearedcontacts {
  18875. edges = append(edges, labelrelationship.EdgeContacts)
  18876. }
  18877. if m.clearedlabels {
  18878. edges = append(edges, labelrelationship.EdgeLabels)
  18879. }
  18880. return edges
  18881. }
  18882. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18883. // was cleared in this mutation.
  18884. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  18885. switch name {
  18886. case labelrelationship.EdgeContacts:
  18887. return m.clearedcontacts
  18888. case labelrelationship.EdgeLabels:
  18889. return m.clearedlabels
  18890. }
  18891. return false
  18892. }
  18893. // ClearEdge clears the value of the edge with the given name. It returns an error
  18894. // if that edge is not defined in the schema.
  18895. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  18896. switch name {
  18897. case labelrelationship.EdgeContacts:
  18898. m.ClearContacts()
  18899. return nil
  18900. case labelrelationship.EdgeLabels:
  18901. m.ClearLabels()
  18902. return nil
  18903. }
  18904. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  18905. }
  18906. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18907. // It returns an error if the edge is not defined in the schema.
  18908. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  18909. switch name {
  18910. case labelrelationship.EdgeContacts:
  18911. m.ResetContacts()
  18912. return nil
  18913. case labelrelationship.EdgeLabels:
  18914. m.ResetLabels()
  18915. return nil
  18916. }
  18917. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  18918. }
  18919. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  18920. type LabelTaggingMutation struct {
  18921. config
  18922. op Op
  18923. typ string
  18924. id *uint64
  18925. created_at *time.Time
  18926. updated_at *time.Time
  18927. status *uint8
  18928. addstatus *int8
  18929. deleted_at *time.Time
  18930. organization_id *uint64
  18931. addorganization_id *int64
  18932. _type *int
  18933. add_type *int
  18934. conditions *string
  18935. action_label_add *[]uint64
  18936. appendaction_label_add []uint64
  18937. action_label_del *[]uint64
  18938. appendaction_label_del []uint64
  18939. clearedFields map[string]struct{}
  18940. done bool
  18941. oldValue func(context.Context) (*LabelTagging, error)
  18942. predicates []predicate.LabelTagging
  18943. }
  18944. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  18945. // labeltaggingOption allows management of the mutation configuration using functional options.
  18946. type labeltaggingOption func(*LabelTaggingMutation)
  18947. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  18948. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  18949. m := &LabelTaggingMutation{
  18950. config: c,
  18951. op: op,
  18952. typ: TypeLabelTagging,
  18953. clearedFields: make(map[string]struct{}),
  18954. }
  18955. for _, opt := range opts {
  18956. opt(m)
  18957. }
  18958. return m
  18959. }
  18960. // withLabelTaggingID sets the ID field of the mutation.
  18961. func withLabelTaggingID(id uint64) labeltaggingOption {
  18962. return func(m *LabelTaggingMutation) {
  18963. var (
  18964. err error
  18965. once sync.Once
  18966. value *LabelTagging
  18967. )
  18968. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  18969. once.Do(func() {
  18970. if m.done {
  18971. err = errors.New("querying old values post mutation is not allowed")
  18972. } else {
  18973. value, err = m.Client().LabelTagging.Get(ctx, id)
  18974. }
  18975. })
  18976. return value, err
  18977. }
  18978. m.id = &id
  18979. }
  18980. }
  18981. // withLabelTagging sets the old LabelTagging of the mutation.
  18982. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  18983. return func(m *LabelTaggingMutation) {
  18984. m.oldValue = func(context.Context) (*LabelTagging, error) {
  18985. return node, nil
  18986. }
  18987. m.id = &node.ID
  18988. }
  18989. }
  18990. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18991. // executed in a transaction (ent.Tx), a transactional client is returned.
  18992. func (m LabelTaggingMutation) Client() *Client {
  18993. client := &Client{config: m.config}
  18994. client.init()
  18995. return client
  18996. }
  18997. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18998. // it returns an error otherwise.
  18999. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  19000. if _, ok := m.driver.(*txDriver); !ok {
  19001. return nil, errors.New("ent: mutation is not running in a transaction")
  19002. }
  19003. tx := &Tx{config: m.config}
  19004. tx.init()
  19005. return tx, nil
  19006. }
  19007. // SetID sets the value of the id field. Note that this
  19008. // operation is only accepted on creation of LabelTagging entities.
  19009. func (m *LabelTaggingMutation) SetID(id uint64) {
  19010. m.id = &id
  19011. }
  19012. // ID returns the ID value in the mutation. Note that the ID is only available
  19013. // if it was provided to the builder or after it was returned from the database.
  19014. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  19015. if m.id == nil {
  19016. return
  19017. }
  19018. return *m.id, true
  19019. }
  19020. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19021. // That means, if the mutation is applied within a transaction with an isolation level such
  19022. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19023. // or updated by the mutation.
  19024. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  19025. switch {
  19026. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19027. id, exists := m.ID()
  19028. if exists {
  19029. return []uint64{id}, nil
  19030. }
  19031. fallthrough
  19032. case m.op.Is(OpUpdate | OpDelete):
  19033. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  19034. default:
  19035. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19036. }
  19037. }
  19038. // SetCreatedAt sets the "created_at" field.
  19039. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  19040. m.created_at = &t
  19041. }
  19042. // CreatedAt returns the value of the "created_at" field in the mutation.
  19043. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  19044. v := m.created_at
  19045. if v == nil {
  19046. return
  19047. }
  19048. return *v, true
  19049. }
  19050. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  19051. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  19052. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19053. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19054. if !m.op.Is(OpUpdateOne) {
  19055. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19056. }
  19057. if m.id == nil || m.oldValue == nil {
  19058. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19059. }
  19060. oldValue, err := m.oldValue(ctx)
  19061. if err != nil {
  19062. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19063. }
  19064. return oldValue.CreatedAt, nil
  19065. }
  19066. // ResetCreatedAt resets all changes to the "created_at" field.
  19067. func (m *LabelTaggingMutation) ResetCreatedAt() {
  19068. m.created_at = nil
  19069. }
  19070. // SetUpdatedAt sets the "updated_at" field.
  19071. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  19072. m.updated_at = &t
  19073. }
  19074. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19075. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  19076. v := m.updated_at
  19077. if v == nil {
  19078. return
  19079. }
  19080. return *v, true
  19081. }
  19082. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  19083. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  19084. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19085. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19086. if !m.op.Is(OpUpdateOne) {
  19087. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19088. }
  19089. if m.id == nil || m.oldValue == nil {
  19090. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19091. }
  19092. oldValue, err := m.oldValue(ctx)
  19093. if err != nil {
  19094. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19095. }
  19096. return oldValue.UpdatedAt, nil
  19097. }
  19098. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19099. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  19100. m.updated_at = nil
  19101. }
  19102. // SetStatus sets the "status" field.
  19103. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  19104. m.status = &u
  19105. m.addstatus = nil
  19106. }
  19107. // Status returns the value of the "status" field in the mutation.
  19108. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  19109. v := m.status
  19110. if v == nil {
  19111. return
  19112. }
  19113. return *v, true
  19114. }
  19115. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  19116. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  19117. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19118. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  19119. if !m.op.Is(OpUpdateOne) {
  19120. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19121. }
  19122. if m.id == nil || m.oldValue == nil {
  19123. return v, errors.New("OldStatus requires an ID field in the mutation")
  19124. }
  19125. oldValue, err := m.oldValue(ctx)
  19126. if err != nil {
  19127. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19128. }
  19129. return oldValue.Status, nil
  19130. }
  19131. // AddStatus adds u to the "status" field.
  19132. func (m *LabelTaggingMutation) AddStatus(u int8) {
  19133. if m.addstatus != nil {
  19134. *m.addstatus += u
  19135. } else {
  19136. m.addstatus = &u
  19137. }
  19138. }
  19139. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19140. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  19141. v := m.addstatus
  19142. if v == nil {
  19143. return
  19144. }
  19145. return *v, true
  19146. }
  19147. // ClearStatus clears the value of the "status" field.
  19148. func (m *LabelTaggingMutation) ClearStatus() {
  19149. m.status = nil
  19150. m.addstatus = nil
  19151. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  19152. }
  19153. // StatusCleared returns if the "status" field was cleared in this mutation.
  19154. func (m *LabelTaggingMutation) StatusCleared() bool {
  19155. _, ok := m.clearedFields[labeltagging.FieldStatus]
  19156. return ok
  19157. }
  19158. // ResetStatus resets all changes to the "status" field.
  19159. func (m *LabelTaggingMutation) ResetStatus() {
  19160. m.status = nil
  19161. m.addstatus = nil
  19162. delete(m.clearedFields, labeltagging.FieldStatus)
  19163. }
  19164. // SetDeletedAt sets the "deleted_at" field.
  19165. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  19166. m.deleted_at = &t
  19167. }
  19168. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19169. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  19170. v := m.deleted_at
  19171. if v == nil {
  19172. return
  19173. }
  19174. return *v, true
  19175. }
  19176. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  19177. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  19178. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19179. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19180. if !m.op.Is(OpUpdateOne) {
  19181. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19182. }
  19183. if m.id == nil || m.oldValue == nil {
  19184. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19185. }
  19186. oldValue, err := m.oldValue(ctx)
  19187. if err != nil {
  19188. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19189. }
  19190. return oldValue.DeletedAt, nil
  19191. }
  19192. // ClearDeletedAt clears the value of the "deleted_at" field.
  19193. func (m *LabelTaggingMutation) ClearDeletedAt() {
  19194. m.deleted_at = nil
  19195. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  19196. }
  19197. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19198. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  19199. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  19200. return ok
  19201. }
  19202. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19203. func (m *LabelTaggingMutation) ResetDeletedAt() {
  19204. m.deleted_at = nil
  19205. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  19206. }
  19207. // SetOrganizationID sets the "organization_id" field.
  19208. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  19209. m.organization_id = &u
  19210. m.addorganization_id = nil
  19211. }
  19212. // OrganizationID returns the value of the "organization_id" field in the mutation.
  19213. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  19214. v := m.organization_id
  19215. if v == nil {
  19216. return
  19217. }
  19218. return *v, true
  19219. }
  19220. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  19221. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  19222. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19223. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  19224. if !m.op.Is(OpUpdateOne) {
  19225. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  19226. }
  19227. if m.id == nil || m.oldValue == nil {
  19228. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  19229. }
  19230. oldValue, err := m.oldValue(ctx)
  19231. if err != nil {
  19232. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  19233. }
  19234. return oldValue.OrganizationID, nil
  19235. }
  19236. // AddOrganizationID adds u to the "organization_id" field.
  19237. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  19238. if m.addorganization_id != nil {
  19239. *m.addorganization_id += u
  19240. } else {
  19241. m.addorganization_id = &u
  19242. }
  19243. }
  19244. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  19245. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  19246. v := m.addorganization_id
  19247. if v == nil {
  19248. return
  19249. }
  19250. return *v, true
  19251. }
  19252. // ResetOrganizationID resets all changes to the "organization_id" field.
  19253. func (m *LabelTaggingMutation) ResetOrganizationID() {
  19254. m.organization_id = nil
  19255. m.addorganization_id = nil
  19256. }
  19257. // SetType sets the "type" field.
  19258. func (m *LabelTaggingMutation) SetType(i int) {
  19259. m._type = &i
  19260. m.add_type = nil
  19261. }
  19262. // GetType returns the value of the "type" field in the mutation.
  19263. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  19264. v := m._type
  19265. if v == nil {
  19266. return
  19267. }
  19268. return *v, true
  19269. }
  19270. // OldType returns the old "type" field's value of the LabelTagging entity.
  19271. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  19272. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19273. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  19274. if !m.op.Is(OpUpdateOne) {
  19275. return v, errors.New("OldType is only allowed on UpdateOne operations")
  19276. }
  19277. if m.id == nil || m.oldValue == nil {
  19278. return v, errors.New("OldType requires an ID field in the mutation")
  19279. }
  19280. oldValue, err := m.oldValue(ctx)
  19281. if err != nil {
  19282. return v, fmt.Errorf("querying old value for OldType: %w", err)
  19283. }
  19284. return oldValue.Type, nil
  19285. }
  19286. // AddType adds i to the "type" field.
  19287. func (m *LabelTaggingMutation) AddType(i int) {
  19288. if m.add_type != nil {
  19289. *m.add_type += i
  19290. } else {
  19291. m.add_type = &i
  19292. }
  19293. }
  19294. // AddedType returns the value that was added to the "type" field in this mutation.
  19295. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  19296. v := m.add_type
  19297. if v == nil {
  19298. return
  19299. }
  19300. return *v, true
  19301. }
  19302. // ResetType resets all changes to the "type" field.
  19303. func (m *LabelTaggingMutation) ResetType() {
  19304. m._type = nil
  19305. m.add_type = nil
  19306. }
  19307. // SetConditions sets the "conditions" field.
  19308. func (m *LabelTaggingMutation) SetConditions(s string) {
  19309. m.conditions = &s
  19310. }
  19311. // Conditions returns the value of the "conditions" field in the mutation.
  19312. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  19313. v := m.conditions
  19314. if v == nil {
  19315. return
  19316. }
  19317. return *v, true
  19318. }
  19319. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  19320. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  19321. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19322. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  19323. if !m.op.Is(OpUpdateOne) {
  19324. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  19325. }
  19326. if m.id == nil || m.oldValue == nil {
  19327. return v, errors.New("OldConditions requires an ID field in the mutation")
  19328. }
  19329. oldValue, err := m.oldValue(ctx)
  19330. if err != nil {
  19331. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  19332. }
  19333. return oldValue.Conditions, nil
  19334. }
  19335. // ResetConditions resets all changes to the "conditions" field.
  19336. func (m *LabelTaggingMutation) ResetConditions() {
  19337. m.conditions = nil
  19338. }
  19339. // SetActionLabelAdd sets the "action_label_add" field.
  19340. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  19341. m.action_label_add = &u
  19342. m.appendaction_label_add = nil
  19343. }
  19344. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  19345. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  19346. v := m.action_label_add
  19347. if v == nil {
  19348. return
  19349. }
  19350. return *v, true
  19351. }
  19352. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  19353. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  19354. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19355. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  19356. if !m.op.Is(OpUpdateOne) {
  19357. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  19358. }
  19359. if m.id == nil || m.oldValue == nil {
  19360. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  19361. }
  19362. oldValue, err := m.oldValue(ctx)
  19363. if err != nil {
  19364. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  19365. }
  19366. return oldValue.ActionLabelAdd, nil
  19367. }
  19368. // AppendActionLabelAdd adds u to the "action_label_add" field.
  19369. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  19370. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  19371. }
  19372. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  19373. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  19374. if len(m.appendaction_label_add) == 0 {
  19375. return nil, false
  19376. }
  19377. return m.appendaction_label_add, true
  19378. }
  19379. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  19380. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  19381. m.action_label_add = nil
  19382. m.appendaction_label_add = nil
  19383. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  19384. }
  19385. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  19386. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  19387. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  19388. return ok
  19389. }
  19390. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  19391. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  19392. m.action_label_add = nil
  19393. m.appendaction_label_add = nil
  19394. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  19395. }
  19396. // SetActionLabelDel sets the "action_label_del" field.
  19397. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  19398. m.action_label_del = &u
  19399. m.appendaction_label_del = nil
  19400. }
  19401. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  19402. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  19403. v := m.action_label_del
  19404. if v == nil {
  19405. return
  19406. }
  19407. return *v, true
  19408. }
  19409. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  19410. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  19411. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19412. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  19413. if !m.op.Is(OpUpdateOne) {
  19414. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  19415. }
  19416. if m.id == nil || m.oldValue == nil {
  19417. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  19418. }
  19419. oldValue, err := m.oldValue(ctx)
  19420. if err != nil {
  19421. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  19422. }
  19423. return oldValue.ActionLabelDel, nil
  19424. }
  19425. // AppendActionLabelDel adds u to the "action_label_del" field.
  19426. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  19427. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  19428. }
  19429. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  19430. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  19431. if len(m.appendaction_label_del) == 0 {
  19432. return nil, false
  19433. }
  19434. return m.appendaction_label_del, true
  19435. }
  19436. // ClearActionLabelDel clears the value of the "action_label_del" field.
  19437. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  19438. m.action_label_del = nil
  19439. m.appendaction_label_del = nil
  19440. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  19441. }
  19442. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  19443. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  19444. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  19445. return ok
  19446. }
  19447. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  19448. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  19449. m.action_label_del = nil
  19450. m.appendaction_label_del = nil
  19451. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  19452. }
  19453. // Where appends a list predicates to the LabelTaggingMutation builder.
  19454. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  19455. m.predicates = append(m.predicates, ps...)
  19456. }
  19457. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  19458. // users can use type-assertion to append predicates that do not depend on any generated package.
  19459. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  19460. p := make([]predicate.LabelTagging, len(ps))
  19461. for i := range ps {
  19462. p[i] = ps[i]
  19463. }
  19464. m.Where(p...)
  19465. }
  19466. // Op returns the operation name.
  19467. func (m *LabelTaggingMutation) Op() Op {
  19468. return m.op
  19469. }
  19470. // SetOp allows setting the mutation operation.
  19471. func (m *LabelTaggingMutation) SetOp(op Op) {
  19472. m.op = op
  19473. }
  19474. // Type returns the node type of this mutation (LabelTagging).
  19475. func (m *LabelTaggingMutation) Type() string {
  19476. return m.typ
  19477. }
  19478. // Fields returns all fields that were changed during this mutation. Note that in
  19479. // order to get all numeric fields that were incremented/decremented, call
  19480. // AddedFields().
  19481. func (m *LabelTaggingMutation) Fields() []string {
  19482. fields := make([]string, 0, 9)
  19483. if m.created_at != nil {
  19484. fields = append(fields, labeltagging.FieldCreatedAt)
  19485. }
  19486. if m.updated_at != nil {
  19487. fields = append(fields, labeltagging.FieldUpdatedAt)
  19488. }
  19489. if m.status != nil {
  19490. fields = append(fields, labeltagging.FieldStatus)
  19491. }
  19492. if m.deleted_at != nil {
  19493. fields = append(fields, labeltagging.FieldDeletedAt)
  19494. }
  19495. if m.organization_id != nil {
  19496. fields = append(fields, labeltagging.FieldOrganizationID)
  19497. }
  19498. if m._type != nil {
  19499. fields = append(fields, labeltagging.FieldType)
  19500. }
  19501. if m.conditions != nil {
  19502. fields = append(fields, labeltagging.FieldConditions)
  19503. }
  19504. if m.action_label_add != nil {
  19505. fields = append(fields, labeltagging.FieldActionLabelAdd)
  19506. }
  19507. if m.action_label_del != nil {
  19508. fields = append(fields, labeltagging.FieldActionLabelDel)
  19509. }
  19510. return fields
  19511. }
  19512. // Field returns the value of a field with the given name. The second boolean
  19513. // return value indicates that this field was not set, or was not defined in the
  19514. // schema.
  19515. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  19516. switch name {
  19517. case labeltagging.FieldCreatedAt:
  19518. return m.CreatedAt()
  19519. case labeltagging.FieldUpdatedAt:
  19520. return m.UpdatedAt()
  19521. case labeltagging.FieldStatus:
  19522. return m.Status()
  19523. case labeltagging.FieldDeletedAt:
  19524. return m.DeletedAt()
  19525. case labeltagging.FieldOrganizationID:
  19526. return m.OrganizationID()
  19527. case labeltagging.FieldType:
  19528. return m.GetType()
  19529. case labeltagging.FieldConditions:
  19530. return m.Conditions()
  19531. case labeltagging.FieldActionLabelAdd:
  19532. return m.ActionLabelAdd()
  19533. case labeltagging.FieldActionLabelDel:
  19534. return m.ActionLabelDel()
  19535. }
  19536. return nil, false
  19537. }
  19538. // OldField returns the old value of the field from the database. An error is
  19539. // returned if the mutation operation is not UpdateOne, or the query to the
  19540. // database failed.
  19541. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19542. switch name {
  19543. case labeltagging.FieldCreatedAt:
  19544. return m.OldCreatedAt(ctx)
  19545. case labeltagging.FieldUpdatedAt:
  19546. return m.OldUpdatedAt(ctx)
  19547. case labeltagging.FieldStatus:
  19548. return m.OldStatus(ctx)
  19549. case labeltagging.FieldDeletedAt:
  19550. return m.OldDeletedAt(ctx)
  19551. case labeltagging.FieldOrganizationID:
  19552. return m.OldOrganizationID(ctx)
  19553. case labeltagging.FieldType:
  19554. return m.OldType(ctx)
  19555. case labeltagging.FieldConditions:
  19556. return m.OldConditions(ctx)
  19557. case labeltagging.FieldActionLabelAdd:
  19558. return m.OldActionLabelAdd(ctx)
  19559. case labeltagging.FieldActionLabelDel:
  19560. return m.OldActionLabelDel(ctx)
  19561. }
  19562. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  19563. }
  19564. // SetField sets the value of a field with the given name. It returns an error if
  19565. // the field is not defined in the schema, or if the type mismatched the field
  19566. // type.
  19567. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  19568. switch name {
  19569. case labeltagging.FieldCreatedAt:
  19570. v, ok := value.(time.Time)
  19571. if !ok {
  19572. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19573. }
  19574. m.SetCreatedAt(v)
  19575. return nil
  19576. case labeltagging.FieldUpdatedAt:
  19577. v, ok := value.(time.Time)
  19578. if !ok {
  19579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19580. }
  19581. m.SetUpdatedAt(v)
  19582. return nil
  19583. case labeltagging.FieldStatus:
  19584. v, ok := value.(uint8)
  19585. if !ok {
  19586. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19587. }
  19588. m.SetStatus(v)
  19589. return nil
  19590. case labeltagging.FieldDeletedAt:
  19591. v, ok := value.(time.Time)
  19592. if !ok {
  19593. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19594. }
  19595. m.SetDeletedAt(v)
  19596. return nil
  19597. case labeltagging.FieldOrganizationID:
  19598. v, ok := value.(uint64)
  19599. if !ok {
  19600. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19601. }
  19602. m.SetOrganizationID(v)
  19603. return nil
  19604. case labeltagging.FieldType:
  19605. v, ok := value.(int)
  19606. if !ok {
  19607. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19608. }
  19609. m.SetType(v)
  19610. return nil
  19611. case labeltagging.FieldConditions:
  19612. v, ok := value.(string)
  19613. if !ok {
  19614. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19615. }
  19616. m.SetConditions(v)
  19617. return nil
  19618. case labeltagging.FieldActionLabelAdd:
  19619. v, ok := value.([]uint64)
  19620. if !ok {
  19621. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19622. }
  19623. m.SetActionLabelAdd(v)
  19624. return nil
  19625. case labeltagging.FieldActionLabelDel:
  19626. v, ok := value.([]uint64)
  19627. if !ok {
  19628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19629. }
  19630. m.SetActionLabelDel(v)
  19631. return nil
  19632. }
  19633. return fmt.Errorf("unknown LabelTagging field %s", name)
  19634. }
  19635. // AddedFields returns all numeric fields that were incremented/decremented during
  19636. // this mutation.
  19637. func (m *LabelTaggingMutation) AddedFields() []string {
  19638. var fields []string
  19639. if m.addstatus != nil {
  19640. fields = append(fields, labeltagging.FieldStatus)
  19641. }
  19642. if m.addorganization_id != nil {
  19643. fields = append(fields, labeltagging.FieldOrganizationID)
  19644. }
  19645. if m.add_type != nil {
  19646. fields = append(fields, labeltagging.FieldType)
  19647. }
  19648. return fields
  19649. }
  19650. // AddedField returns the numeric value that was incremented/decremented on a field
  19651. // with the given name. The second boolean return value indicates that this field
  19652. // was not set, or was not defined in the schema.
  19653. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  19654. switch name {
  19655. case labeltagging.FieldStatus:
  19656. return m.AddedStatus()
  19657. case labeltagging.FieldOrganizationID:
  19658. return m.AddedOrganizationID()
  19659. case labeltagging.FieldType:
  19660. return m.AddedType()
  19661. }
  19662. return nil, false
  19663. }
  19664. // AddField adds the value to the field with the given name. It returns an error if
  19665. // the field is not defined in the schema, or if the type mismatched the field
  19666. // type.
  19667. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  19668. switch name {
  19669. case labeltagging.FieldStatus:
  19670. v, ok := value.(int8)
  19671. if !ok {
  19672. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19673. }
  19674. m.AddStatus(v)
  19675. return nil
  19676. case labeltagging.FieldOrganizationID:
  19677. v, ok := value.(int64)
  19678. if !ok {
  19679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19680. }
  19681. m.AddOrganizationID(v)
  19682. return nil
  19683. case labeltagging.FieldType:
  19684. v, ok := value.(int)
  19685. if !ok {
  19686. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19687. }
  19688. m.AddType(v)
  19689. return nil
  19690. }
  19691. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  19692. }
  19693. // ClearedFields returns all nullable fields that were cleared during this
  19694. // mutation.
  19695. func (m *LabelTaggingMutation) ClearedFields() []string {
  19696. var fields []string
  19697. if m.FieldCleared(labeltagging.FieldStatus) {
  19698. fields = append(fields, labeltagging.FieldStatus)
  19699. }
  19700. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  19701. fields = append(fields, labeltagging.FieldDeletedAt)
  19702. }
  19703. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  19704. fields = append(fields, labeltagging.FieldActionLabelAdd)
  19705. }
  19706. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  19707. fields = append(fields, labeltagging.FieldActionLabelDel)
  19708. }
  19709. return fields
  19710. }
  19711. // FieldCleared returns a boolean indicating if a field with the given name was
  19712. // cleared in this mutation.
  19713. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  19714. _, ok := m.clearedFields[name]
  19715. return ok
  19716. }
  19717. // ClearField clears the value of the field with the given name. It returns an
  19718. // error if the field is not defined in the schema.
  19719. func (m *LabelTaggingMutation) ClearField(name string) error {
  19720. switch name {
  19721. case labeltagging.FieldStatus:
  19722. m.ClearStatus()
  19723. return nil
  19724. case labeltagging.FieldDeletedAt:
  19725. m.ClearDeletedAt()
  19726. return nil
  19727. case labeltagging.FieldActionLabelAdd:
  19728. m.ClearActionLabelAdd()
  19729. return nil
  19730. case labeltagging.FieldActionLabelDel:
  19731. m.ClearActionLabelDel()
  19732. return nil
  19733. }
  19734. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  19735. }
  19736. // ResetField resets all changes in the mutation for the field with the given name.
  19737. // It returns an error if the field is not defined in the schema.
  19738. func (m *LabelTaggingMutation) ResetField(name string) error {
  19739. switch name {
  19740. case labeltagging.FieldCreatedAt:
  19741. m.ResetCreatedAt()
  19742. return nil
  19743. case labeltagging.FieldUpdatedAt:
  19744. m.ResetUpdatedAt()
  19745. return nil
  19746. case labeltagging.FieldStatus:
  19747. m.ResetStatus()
  19748. return nil
  19749. case labeltagging.FieldDeletedAt:
  19750. m.ResetDeletedAt()
  19751. return nil
  19752. case labeltagging.FieldOrganizationID:
  19753. m.ResetOrganizationID()
  19754. return nil
  19755. case labeltagging.FieldType:
  19756. m.ResetType()
  19757. return nil
  19758. case labeltagging.FieldConditions:
  19759. m.ResetConditions()
  19760. return nil
  19761. case labeltagging.FieldActionLabelAdd:
  19762. m.ResetActionLabelAdd()
  19763. return nil
  19764. case labeltagging.FieldActionLabelDel:
  19765. m.ResetActionLabelDel()
  19766. return nil
  19767. }
  19768. return fmt.Errorf("unknown LabelTagging field %s", name)
  19769. }
  19770. // AddedEdges returns all edge names that were set/added in this mutation.
  19771. func (m *LabelTaggingMutation) AddedEdges() []string {
  19772. edges := make([]string, 0, 0)
  19773. return edges
  19774. }
  19775. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19776. // name in this mutation.
  19777. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  19778. return nil
  19779. }
  19780. // RemovedEdges returns all edge names that were removed in this mutation.
  19781. func (m *LabelTaggingMutation) RemovedEdges() []string {
  19782. edges := make([]string, 0, 0)
  19783. return edges
  19784. }
  19785. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19786. // the given name in this mutation.
  19787. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  19788. return nil
  19789. }
  19790. // ClearedEdges returns all edge names that were cleared in this mutation.
  19791. func (m *LabelTaggingMutation) ClearedEdges() []string {
  19792. edges := make([]string, 0, 0)
  19793. return edges
  19794. }
  19795. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19796. // was cleared in this mutation.
  19797. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  19798. return false
  19799. }
  19800. // ClearEdge clears the value of the edge with the given name. It returns an error
  19801. // if that edge is not defined in the schema.
  19802. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  19803. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  19804. }
  19805. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19806. // It returns an error if the edge is not defined in the schema.
  19807. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  19808. return fmt.Errorf("unknown LabelTagging edge %s", name)
  19809. }
  19810. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  19811. type MessageMutation struct {
  19812. config
  19813. op Op
  19814. typ string
  19815. id *int
  19816. wx_wxid *string
  19817. wxid *string
  19818. content *string
  19819. clearedFields map[string]struct{}
  19820. done bool
  19821. oldValue func(context.Context) (*Message, error)
  19822. predicates []predicate.Message
  19823. }
  19824. var _ ent.Mutation = (*MessageMutation)(nil)
  19825. // messageOption allows management of the mutation configuration using functional options.
  19826. type messageOption func(*MessageMutation)
  19827. // newMessageMutation creates new mutation for the Message entity.
  19828. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  19829. m := &MessageMutation{
  19830. config: c,
  19831. op: op,
  19832. typ: TypeMessage,
  19833. clearedFields: make(map[string]struct{}),
  19834. }
  19835. for _, opt := range opts {
  19836. opt(m)
  19837. }
  19838. return m
  19839. }
  19840. // withMessageID sets the ID field of the mutation.
  19841. func withMessageID(id int) messageOption {
  19842. return func(m *MessageMutation) {
  19843. var (
  19844. err error
  19845. once sync.Once
  19846. value *Message
  19847. )
  19848. m.oldValue = func(ctx context.Context) (*Message, error) {
  19849. once.Do(func() {
  19850. if m.done {
  19851. err = errors.New("querying old values post mutation is not allowed")
  19852. } else {
  19853. value, err = m.Client().Message.Get(ctx, id)
  19854. }
  19855. })
  19856. return value, err
  19857. }
  19858. m.id = &id
  19859. }
  19860. }
  19861. // withMessage sets the old Message of the mutation.
  19862. func withMessage(node *Message) messageOption {
  19863. return func(m *MessageMutation) {
  19864. m.oldValue = func(context.Context) (*Message, error) {
  19865. return node, nil
  19866. }
  19867. m.id = &node.ID
  19868. }
  19869. }
  19870. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19871. // executed in a transaction (ent.Tx), a transactional client is returned.
  19872. func (m MessageMutation) Client() *Client {
  19873. client := &Client{config: m.config}
  19874. client.init()
  19875. return client
  19876. }
  19877. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19878. // it returns an error otherwise.
  19879. func (m MessageMutation) Tx() (*Tx, error) {
  19880. if _, ok := m.driver.(*txDriver); !ok {
  19881. return nil, errors.New("ent: mutation is not running in a transaction")
  19882. }
  19883. tx := &Tx{config: m.config}
  19884. tx.init()
  19885. return tx, nil
  19886. }
  19887. // ID returns the ID value in the mutation. Note that the ID is only available
  19888. // if it was provided to the builder or after it was returned from the database.
  19889. func (m *MessageMutation) ID() (id int, exists bool) {
  19890. if m.id == nil {
  19891. return
  19892. }
  19893. return *m.id, true
  19894. }
  19895. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19896. // That means, if the mutation is applied within a transaction with an isolation level such
  19897. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19898. // or updated by the mutation.
  19899. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  19900. switch {
  19901. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19902. id, exists := m.ID()
  19903. if exists {
  19904. return []int{id}, nil
  19905. }
  19906. fallthrough
  19907. case m.op.Is(OpUpdate | OpDelete):
  19908. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  19909. default:
  19910. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19911. }
  19912. }
  19913. // SetWxWxid sets the "wx_wxid" field.
  19914. func (m *MessageMutation) SetWxWxid(s string) {
  19915. m.wx_wxid = &s
  19916. }
  19917. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  19918. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  19919. v := m.wx_wxid
  19920. if v == nil {
  19921. return
  19922. }
  19923. return *v, true
  19924. }
  19925. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  19926. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  19927. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19928. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  19929. if !m.op.Is(OpUpdateOne) {
  19930. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  19931. }
  19932. if m.id == nil || m.oldValue == nil {
  19933. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  19934. }
  19935. oldValue, err := m.oldValue(ctx)
  19936. if err != nil {
  19937. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  19938. }
  19939. return oldValue.WxWxid, nil
  19940. }
  19941. // ClearWxWxid clears the value of the "wx_wxid" field.
  19942. func (m *MessageMutation) ClearWxWxid() {
  19943. m.wx_wxid = nil
  19944. m.clearedFields[message.FieldWxWxid] = struct{}{}
  19945. }
  19946. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  19947. func (m *MessageMutation) WxWxidCleared() bool {
  19948. _, ok := m.clearedFields[message.FieldWxWxid]
  19949. return ok
  19950. }
  19951. // ResetWxWxid resets all changes to the "wx_wxid" field.
  19952. func (m *MessageMutation) ResetWxWxid() {
  19953. m.wx_wxid = nil
  19954. delete(m.clearedFields, message.FieldWxWxid)
  19955. }
  19956. // SetWxid sets the "wxid" field.
  19957. func (m *MessageMutation) SetWxid(s string) {
  19958. m.wxid = &s
  19959. }
  19960. // Wxid returns the value of the "wxid" field in the mutation.
  19961. func (m *MessageMutation) Wxid() (r string, exists bool) {
  19962. v := m.wxid
  19963. if v == nil {
  19964. return
  19965. }
  19966. return *v, true
  19967. }
  19968. // OldWxid returns the old "wxid" field's value of the Message entity.
  19969. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  19970. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19971. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  19972. if !m.op.Is(OpUpdateOne) {
  19973. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  19974. }
  19975. if m.id == nil || m.oldValue == nil {
  19976. return v, errors.New("OldWxid requires an ID field in the mutation")
  19977. }
  19978. oldValue, err := m.oldValue(ctx)
  19979. if err != nil {
  19980. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  19981. }
  19982. return oldValue.Wxid, nil
  19983. }
  19984. // ResetWxid resets all changes to the "wxid" field.
  19985. func (m *MessageMutation) ResetWxid() {
  19986. m.wxid = nil
  19987. }
  19988. // SetContent sets the "content" field.
  19989. func (m *MessageMutation) SetContent(s string) {
  19990. m.content = &s
  19991. }
  19992. // Content returns the value of the "content" field in the mutation.
  19993. func (m *MessageMutation) Content() (r string, exists bool) {
  19994. v := m.content
  19995. if v == nil {
  19996. return
  19997. }
  19998. return *v, true
  19999. }
  20000. // OldContent returns the old "content" field's value of the Message entity.
  20001. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  20002. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20003. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  20004. if !m.op.Is(OpUpdateOne) {
  20005. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  20006. }
  20007. if m.id == nil || m.oldValue == nil {
  20008. return v, errors.New("OldContent requires an ID field in the mutation")
  20009. }
  20010. oldValue, err := m.oldValue(ctx)
  20011. if err != nil {
  20012. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  20013. }
  20014. return oldValue.Content, nil
  20015. }
  20016. // ResetContent resets all changes to the "content" field.
  20017. func (m *MessageMutation) ResetContent() {
  20018. m.content = nil
  20019. }
  20020. // Where appends a list predicates to the MessageMutation builder.
  20021. func (m *MessageMutation) Where(ps ...predicate.Message) {
  20022. m.predicates = append(m.predicates, ps...)
  20023. }
  20024. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  20025. // users can use type-assertion to append predicates that do not depend on any generated package.
  20026. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  20027. p := make([]predicate.Message, len(ps))
  20028. for i := range ps {
  20029. p[i] = ps[i]
  20030. }
  20031. m.Where(p...)
  20032. }
  20033. // Op returns the operation name.
  20034. func (m *MessageMutation) Op() Op {
  20035. return m.op
  20036. }
  20037. // SetOp allows setting the mutation operation.
  20038. func (m *MessageMutation) SetOp(op Op) {
  20039. m.op = op
  20040. }
  20041. // Type returns the node type of this mutation (Message).
  20042. func (m *MessageMutation) Type() string {
  20043. return m.typ
  20044. }
  20045. // Fields returns all fields that were changed during this mutation. Note that in
  20046. // order to get all numeric fields that were incremented/decremented, call
  20047. // AddedFields().
  20048. func (m *MessageMutation) Fields() []string {
  20049. fields := make([]string, 0, 3)
  20050. if m.wx_wxid != nil {
  20051. fields = append(fields, message.FieldWxWxid)
  20052. }
  20053. if m.wxid != nil {
  20054. fields = append(fields, message.FieldWxid)
  20055. }
  20056. if m.content != nil {
  20057. fields = append(fields, message.FieldContent)
  20058. }
  20059. return fields
  20060. }
  20061. // Field returns the value of a field with the given name. The second boolean
  20062. // return value indicates that this field was not set, or was not defined in the
  20063. // schema.
  20064. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  20065. switch name {
  20066. case message.FieldWxWxid:
  20067. return m.WxWxid()
  20068. case message.FieldWxid:
  20069. return m.Wxid()
  20070. case message.FieldContent:
  20071. return m.Content()
  20072. }
  20073. return nil, false
  20074. }
  20075. // OldField returns the old value of the field from the database. An error is
  20076. // returned if the mutation operation is not UpdateOne, or the query to the
  20077. // database failed.
  20078. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20079. switch name {
  20080. case message.FieldWxWxid:
  20081. return m.OldWxWxid(ctx)
  20082. case message.FieldWxid:
  20083. return m.OldWxid(ctx)
  20084. case message.FieldContent:
  20085. return m.OldContent(ctx)
  20086. }
  20087. return nil, fmt.Errorf("unknown Message field %s", name)
  20088. }
  20089. // SetField sets the value of a field with the given name. It returns an error if
  20090. // the field is not defined in the schema, or if the type mismatched the field
  20091. // type.
  20092. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  20093. switch name {
  20094. case message.FieldWxWxid:
  20095. v, ok := value.(string)
  20096. if !ok {
  20097. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20098. }
  20099. m.SetWxWxid(v)
  20100. return nil
  20101. case message.FieldWxid:
  20102. v, ok := value.(string)
  20103. if !ok {
  20104. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20105. }
  20106. m.SetWxid(v)
  20107. return nil
  20108. case message.FieldContent:
  20109. v, ok := value.(string)
  20110. if !ok {
  20111. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20112. }
  20113. m.SetContent(v)
  20114. return nil
  20115. }
  20116. return fmt.Errorf("unknown Message field %s", name)
  20117. }
  20118. // AddedFields returns all numeric fields that were incremented/decremented during
  20119. // this mutation.
  20120. func (m *MessageMutation) AddedFields() []string {
  20121. return nil
  20122. }
  20123. // AddedField returns the numeric value that was incremented/decremented on a field
  20124. // with the given name. The second boolean return value indicates that this field
  20125. // was not set, or was not defined in the schema.
  20126. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  20127. return nil, false
  20128. }
  20129. // AddField adds the value to the field with the given name. It returns an error if
  20130. // the field is not defined in the schema, or if the type mismatched the field
  20131. // type.
  20132. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  20133. switch name {
  20134. }
  20135. return fmt.Errorf("unknown Message numeric field %s", name)
  20136. }
  20137. // ClearedFields returns all nullable fields that were cleared during this
  20138. // mutation.
  20139. func (m *MessageMutation) ClearedFields() []string {
  20140. var fields []string
  20141. if m.FieldCleared(message.FieldWxWxid) {
  20142. fields = append(fields, message.FieldWxWxid)
  20143. }
  20144. return fields
  20145. }
  20146. // FieldCleared returns a boolean indicating if a field with the given name was
  20147. // cleared in this mutation.
  20148. func (m *MessageMutation) FieldCleared(name string) bool {
  20149. _, ok := m.clearedFields[name]
  20150. return ok
  20151. }
  20152. // ClearField clears the value of the field with the given name. It returns an
  20153. // error if the field is not defined in the schema.
  20154. func (m *MessageMutation) ClearField(name string) error {
  20155. switch name {
  20156. case message.FieldWxWxid:
  20157. m.ClearWxWxid()
  20158. return nil
  20159. }
  20160. return fmt.Errorf("unknown Message nullable field %s", name)
  20161. }
  20162. // ResetField resets all changes in the mutation for the field with the given name.
  20163. // It returns an error if the field is not defined in the schema.
  20164. func (m *MessageMutation) ResetField(name string) error {
  20165. switch name {
  20166. case message.FieldWxWxid:
  20167. m.ResetWxWxid()
  20168. return nil
  20169. case message.FieldWxid:
  20170. m.ResetWxid()
  20171. return nil
  20172. case message.FieldContent:
  20173. m.ResetContent()
  20174. return nil
  20175. }
  20176. return fmt.Errorf("unknown Message field %s", name)
  20177. }
  20178. // AddedEdges returns all edge names that were set/added in this mutation.
  20179. func (m *MessageMutation) AddedEdges() []string {
  20180. edges := make([]string, 0, 0)
  20181. return edges
  20182. }
  20183. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20184. // name in this mutation.
  20185. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  20186. return nil
  20187. }
  20188. // RemovedEdges returns all edge names that were removed in this mutation.
  20189. func (m *MessageMutation) RemovedEdges() []string {
  20190. edges := make([]string, 0, 0)
  20191. return edges
  20192. }
  20193. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20194. // the given name in this mutation.
  20195. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  20196. return nil
  20197. }
  20198. // ClearedEdges returns all edge names that were cleared in this mutation.
  20199. func (m *MessageMutation) ClearedEdges() []string {
  20200. edges := make([]string, 0, 0)
  20201. return edges
  20202. }
  20203. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20204. // was cleared in this mutation.
  20205. func (m *MessageMutation) EdgeCleared(name string) bool {
  20206. return false
  20207. }
  20208. // ClearEdge clears the value of the edge with the given name. It returns an error
  20209. // if that edge is not defined in the schema.
  20210. func (m *MessageMutation) ClearEdge(name string) error {
  20211. return fmt.Errorf("unknown Message unique edge %s", name)
  20212. }
  20213. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20214. // It returns an error if the edge is not defined in the schema.
  20215. func (m *MessageMutation) ResetEdge(name string) error {
  20216. return fmt.Errorf("unknown Message edge %s", name)
  20217. }
  20218. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  20219. type MessageRecordsMutation struct {
  20220. config
  20221. op Op
  20222. typ string
  20223. id *uint64
  20224. created_at *time.Time
  20225. updated_at *time.Time
  20226. status *uint8
  20227. addstatus *int8
  20228. bot_wxid *string
  20229. contact_type *int
  20230. addcontact_type *int
  20231. contact_wxid *string
  20232. content_type *int
  20233. addcontent_type *int
  20234. content *string
  20235. meta *custom_types.Meta
  20236. error_detail *string
  20237. send_time *time.Time
  20238. source_type *int
  20239. addsource_type *int
  20240. organization_id *uint64
  20241. addorganization_id *int64
  20242. clearedFields map[string]struct{}
  20243. sop_stage *uint64
  20244. clearedsop_stage bool
  20245. sop_node *uint64
  20246. clearedsop_node bool
  20247. message_contact *uint64
  20248. clearedmessage_contact bool
  20249. done bool
  20250. oldValue func(context.Context) (*MessageRecords, error)
  20251. predicates []predicate.MessageRecords
  20252. }
  20253. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  20254. // messagerecordsOption allows management of the mutation configuration using functional options.
  20255. type messagerecordsOption func(*MessageRecordsMutation)
  20256. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  20257. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  20258. m := &MessageRecordsMutation{
  20259. config: c,
  20260. op: op,
  20261. typ: TypeMessageRecords,
  20262. clearedFields: make(map[string]struct{}),
  20263. }
  20264. for _, opt := range opts {
  20265. opt(m)
  20266. }
  20267. return m
  20268. }
  20269. // withMessageRecordsID sets the ID field of the mutation.
  20270. func withMessageRecordsID(id uint64) messagerecordsOption {
  20271. return func(m *MessageRecordsMutation) {
  20272. var (
  20273. err error
  20274. once sync.Once
  20275. value *MessageRecords
  20276. )
  20277. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  20278. once.Do(func() {
  20279. if m.done {
  20280. err = errors.New("querying old values post mutation is not allowed")
  20281. } else {
  20282. value, err = m.Client().MessageRecords.Get(ctx, id)
  20283. }
  20284. })
  20285. return value, err
  20286. }
  20287. m.id = &id
  20288. }
  20289. }
  20290. // withMessageRecords sets the old MessageRecords of the mutation.
  20291. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  20292. return func(m *MessageRecordsMutation) {
  20293. m.oldValue = func(context.Context) (*MessageRecords, error) {
  20294. return node, nil
  20295. }
  20296. m.id = &node.ID
  20297. }
  20298. }
  20299. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20300. // executed in a transaction (ent.Tx), a transactional client is returned.
  20301. func (m MessageRecordsMutation) Client() *Client {
  20302. client := &Client{config: m.config}
  20303. client.init()
  20304. return client
  20305. }
  20306. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20307. // it returns an error otherwise.
  20308. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  20309. if _, ok := m.driver.(*txDriver); !ok {
  20310. return nil, errors.New("ent: mutation is not running in a transaction")
  20311. }
  20312. tx := &Tx{config: m.config}
  20313. tx.init()
  20314. return tx, nil
  20315. }
  20316. // SetID sets the value of the id field. Note that this
  20317. // operation is only accepted on creation of MessageRecords entities.
  20318. func (m *MessageRecordsMutation) SetID(id uint64) {
  20319. m.id = &id
  20320. }
  20321. // ID returns the ID value in the mutation. Note that the ID is only available
  20322. // if it was provided to the builder or after it was returned from the database.
  20323. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  20324. if m.id == nil {
  20325. return
  20326. }
  20327. return *m.id, true
  20328. }
  20329. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20330. // That means, if the mutation is applied within a transaction with an isolation level such
  20331. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20332. // or updated by the mutation.
  20333. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  20334. switch {
  20335. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20336. id, exists := m.ID()
  20337. if exists {
  20338. return []uint64{id}, nil
  20339. }
  20340. fallthrough
  20341. case m.op.Is(OpUpdate | OpDelete):
  20342. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  20343. default:
  20344. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20345. }
  20346. }
  20347. // SetCreatedAt sets the "created_at" field.
  20348. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  20349. m.created_at = &t
  20350. }
  20351. // CreatedAt returns the value of the "created_at" field in the mutation.
  20352. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  20353. v := m.created_at
  20354. if v == nil {
  20355. return
  20356. }
  20357. return *v, true
  20358. }
  20359. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  20360. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20362. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20363. if !m.op.Is(OpUpdateOne) {
  20364. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20365. }
  20366. if m.id == nil || m.oldValue == nil {
  20367. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20368. }
  20369. oldValue, err := m.oldValue(ctx)
  20370. if err != nil {
  20371. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20372. }
  20373. return oldValue.CreatedAt, nil
  20374. }
  20375. // ResetCreatedAt resets all changes to the "created_at" field.
  20376. func (m *MessageRecordsMutation) ResetCreatedAt() {
  20377. m.created_at = nil
  20378. }
  20379. // SetUpdatedAt sets the "updated_at" field.
  20380. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  20381. m.updated_at = &t
  20382. }
  20383. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20384. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  20385. v := m.updated_at
  20386. if v == nil {
  20387. return
  20388. }
  20389. return *v, true
  20390. }
  20391. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  20392. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20393. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20394. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20395. if !m.op.Is(OpUpdateOne) {
  20396. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20397. }
  20398. if m.id == nil || m.oldValue == nil {
  20399. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20400. }
  20401. oldValue, err := m.oldValue(ctx)
  20402. if err != nil {
  20403. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20404. }
  20405. return oldValue.UpdatedAt, nil
  20406. }
  20407. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20408. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  20409. m.updated_at = nil
  20410. }
  20411. // SetStatus sets the "status" field.
  20412. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  20413. m.status = &u
  20414. m.addstatus = nil
  20415. }
  20416. // Status returns the value of the "status" field in the mutation.
  20417. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  20418. v := m.status
  20419. if v == nil {
  20420. return
  20421. }
  20422. return *v, true
  20423. }
  20424. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  20425. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20426. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20427. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20428. if !m.op.Is(OpUpdateOne) {
  20429. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20430. }
  20431. if m.id == nil || m.oldValue == nil {
  20432. return v, errors.New("OldStatus requires an ID field in the mutation")
  20433. }
  20434. oldValue, err := m.oldValue(ctx)
  20435. if err != nil {
  20436. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20437. }
  20438. return oldValue.Status, nil
  20439. }
  20440. // AddStatus adds u to the "status" field.
  20441. func (m *MessageRecordsMutation) AddStatus(u int8) {
  20442. if m.addstatus != nil {
  20443. *m.addstatus += u
  20444. } else {
  20445. m.addstatus = &u
  20446. }
  20447. }
  20448. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20449. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  20450. v := m.addstatus
  20451. if v == nil {
  20452. return
  20453. }
  20454. return *v, true
  20455. }
  20456. // ClearStatus clears the value of the "status" field.
  20457. func (m *MessageRecordsMutation) ClearStatus() {
  20458. m.status = nil
  20459. m.addstatus = nil
  20460. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  20461. }
  20462. // StatusCleared returns if the "status" field was cleared in this mutation.
  20463. func (m *MessageRecordsMutation) StatusCleared() bool {
  20464. _, ok := m.clearedFields[messagerecords.FieldStatus]
  20465. return ok
  20466. }
  20467. // ResetStatus resets all changes to the "status" field.
  20468. func (m *MessageRecordsMutation) ResetStatus() {
  20469. m.status = nil
  20470. m.addstatus = nil
  20471. delete(m.clearedFields, messagerecords.FieldStatus)
  20472. }
  20473. // SetBotWxid sets the "bot_wxid" field.
  20474. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  20475. m.bot_wxid = &s
  20476. }
  20477. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  20478. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  20479. v := m.bot_wxid
  20480. if v == nil {
  20481. return
  20482. }
  20483. return *v, true
  20484. }
  20485. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  20486. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20487. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20488. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  20489. if !m.op.Is(OpUpdateOne) {
  20490. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  20491. }
  20492. if m.id == nil || m.oldValue == nil {
  20493. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  20494. }
  20495. oldValue, err := m.oldValue(ctx)
  20496. if err != nil {
  20497. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  20498. }
  20499. return oldValue.BotWxid, nil
  20500. }
  20501. // ResetBotWxid resets all changes to the "bot_wxid" field.
  20502. func (m *MessageRecordsMutation) ResetBotWxid() {
  20503. m.bot_wxid = nil
  20504. }
  20505. // SetContactID sets the "contact_id" field.
  20506. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  20507. m.message_contact = &u
  20508. }
  20509. // ContactID returns the value of the "contact_id" field in the mutation.
  20510. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  20511. v := m.message_contact
  20512. if v == nil {
  20513. return
  20514. }
  20515. return *v, true
  20516. }
  20517. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  20518. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20519. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20520. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  20521. if !m.op.Is(OpUpdateOne) {
  20522. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  20523. }
  20524. if m.id == nil || m.oldValue == nil {
  20525. return v, errors.New("OldContactID requires an ID field in the mutation")
  20526. }
  20527. oldValue, err := m.oldValue(ctx)
  20528. if err != nil {
  20529. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  20530. }
  20531. return oldValue.ContactID, nil
  20532. }
  20533. // ClearContactID clears the value of the "contact_id" field.
  20534. func (m *MessageRecordsMutation) ClearContactID() {
  20535. m.message_contact = nil
  20536. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  20537. }
  20538. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  20539. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  20540. _, ok := m.clearedFields[messagerecords.FieldContactID]
  20541. return ok
  20542. }
  20543. // ResetContactID resets all changes to the "contact_id" field.
  20544. func (m *MessageRecordsMutation) ResetContactID() {
  20545. m.message_contact = nil
  20546. delete(m.clearedFields, messagerecords.FieldContactID)
  20547. }
  20548. // SetContactType sets the "contact_type" field.
  20549. func (m *MessageRecordsMutation) SetContactType(i int) {
  20550. m.contact_type = &i
  20551. m.addcontact_type = nil
  20552. }
  20553. // ContactType returns the value of the "contact_type" field in the mutation.
  20554. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  20555. v := m.contact_type
  20556. if v == nil {
  20557. return
  20558. }
  20559. return *v, true
  20560. }
  20561. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  20562. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20563. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20564. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  20565. if !m.op.Is(OpUpdateOne) {
  20566. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  20567. }
  20568. if m.id == nil || m.oldValue == nil {
  20569. return v, errors.New("OldContactType requires an ID field in the mutation")
  20570. }
  20571. oldValue, err := m.oldValue(ctx)
  20572. if err != nil {
  20573. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  20574. }
  20575. return oldValue.ContactType, nil
  20576. }
  20577. // AddContactType adds i to the "contact_type" field.
  20578. func (m *MessageRecordsMutation) AddContactType(i int) {
  20579. if m.addcontact_type != nil {
  20580. *m.addcontact_type += i
  20581. } else {
  20582. m.addcontact_type = &i
  20583. }
  20584. }
  20585. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  20586. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  20587. v := m.addcontact_type
  20588. if v == nil {
  20589. return
  20590. }
  20591. return *v, true
  20592. }
  20593. // ResetContactType resets all changes to the "contact_type" field.
  20594. func (m *MessageRecordsMutation) ResetContactType() {
  20595. m.contact_type = nil
  20596. m.addcontact_type = nil
  20597. }
  20598. // SetContactWxid sets the "contact_wxid" field.
  20599. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  20600. m.contact_wxid = &s
  20601. }
  20602. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  20603. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  20604. v := m.contact_wxid
  20605. if v == nil {
  20606. return
  20607. }
  20608. return *v, true
  20609. }
  20610. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  20611. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20612. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20613. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  20614. if !m.op.Is(OpUpdateOne) {
  20615. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  20616. }
  20617. if m.id == nil || m.oldValue == nil {
  20618. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  20619. }
  20620. oldValue, err := m.oldValue(ctx)
  20621. if err != nil {
  20622. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  20623. }
  20624. return oldValue.ContactWxid, nil
  20625. }
  20626. // ResetContactWxid resets all changes to the "contact_wxid" field.
  20627. func (m *MessageRecordsMutation) ResetContactWxid() {
  20628. m.contact_wxid = nil
  20629. }
  20630. // SetContentType sets the "content_type" field.
  20631. func (m *MessageRecordsMutation) SetContentType(i int) {
  20632. m.content_type = &i
  20633. m.addcontent_type = nil
  20634. }
  20635. // ContentType returns the value of the "content_type" field in the mutation.
  20636. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  20637. v := m.content_type
  20638. if v == nil {
  20639. return
  20640. }
  20641. return *v, true
  20642. }
  20643. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  20644. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20645. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20646. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  20647. if !m.op.Is(OpUpdateOne) {
  20648. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  20649. }
  20650. if m.id == nil || m.oldValue == nil {
  20651. return v, errors.New("OldContentType requires an ID field in the mutation")
  20652. }
  20653. oldValue, err := m.oldValue(ctx)
  20654. if err != nil {
  20655. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  20656. }
  20657. return oldValue.ContentType, nil
  20658. }
  20659. // AddContentType adds i to the "content_type" field.
  20660. func (m *MessageRecordsMutation) AddContentType(i int) {
  20661. if m.addcontent_type != nil {
  20662. *m.addcontent_type += i
  20663. } else {
  20664. m.addcontent_type = &i
  20665. }
  20666. }
  20667. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  20668. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  20669. v := m.addcontent_type
  20670. if v == nil {
  20671. return
  20672. }
  20673. return *v, true
  20674. }
  20675. // ResetContentType resets all changes to the "content_type" field.
  20676. func (m *MessageRecordsMutation) ResetContentType() {
  20677. m.content_type = nil
  20678. m.addcontent_type = nil
  20679. }
  20680. // SetContent sets the "content" field.
  20681. func (m *MessageRecordsMutation) SetContent(s string) {
  20682. m.content = &s
  20683. }
  20684. // Content returns the value of the "content" field in the mutation.
  20685. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  20686. v := m.content
  20687. if v == nil {
  20688. return
  20689. }
  20690. return *v, true
  20691. }
  20692. // OldContent returns the old "content" field's value of the MessageRecords entity.
  20693. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20694. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20695. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  20696. if !m.op.Is(OpUpdateOne) {
  20697. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  20698. }
  20699. if m.id == nil || m.oldValue == nil {
  20700. return v, errors.New("OldContent requires an ID field in the mutation")
  20701. }
  20702. oldValue, err := m.oldValue(ctx)
  20703. if err != nil {
  20704. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  20705. }
  20706. return oldValue.Content, nil
  20707. }
  20708. // ResetContent resets all changes to the "content" field.
  20709. func (m *MessageRecordsMutation) ResetContent() {
  20710. m.content = nil
  20711. }
  20712. // SetMeta sets the "meta" field.
  20713. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  20714. m.meta = &ct
  20715. }
  20716. // Meta returns the value of the "meta" field in the mutation.
  20717. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  20718. v := m.meta
  20719. if v == nil {
  20720. return
  20721. }
  20722. return *v, true
  20723. }
  20724. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  20725. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20726. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20727. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  20728. if !m.op.Is(OpUpdateOne) {
  20729. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  20730. }
  20731. if m.id == nil || m.oldValue == nil {
  20732. return v, errors.New("OldMeta requires an ID field in the mutation")
  20733. }
  20734. oldValue, err := m.oldValue(ctx)
  20735. if err != nil {
  20736. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  20737. }
  20738. return oldValue.Meta, nil
  20739. }
  20740. // ClearMeta clears the value of the "meta" field.
  20741. func (m *MessageRecordsMutation) ClearMeta() {
  20742. m.meta = nil
  20743. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  20744. }
  20745. // MetaCleared returns if the "meta" field was cleared in this mutation.
  20746. func (m *MessageRecordsMutation) MetaCleared() bool {
  20747. _, ok := m.clearedFields[messagerecords.FieldMeta]
  20748. return ok
  20749. }
  20750. // ResetMeta resets all changes to the "meta" field.
  20751. func (m *MessageRecordsMutation) ResetMeta() {
  20752. m.meta = nil
  20753. delete(m.clearedFields, messagerecords.FieldMeta)
  20754. }
  20755. // SetErrorDetail sets the "error_detail" field.
  20756. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  20757. m.error_detail = &s
  20758. }
  20759. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  20760. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  20761. v := m.error_detail
  20762. if v == nil {
  20763. return
  20764. }
  20765. return *v, true
  20766. }
  20767. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  20768. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20769. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20770. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  20771. if !m.op.Is(OpUpdateOne) {
  20772. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  20773. }
  20774. if m.id == nil || m.oldValue == nil {
  20775. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  20776. }
  20777. oldValue, err := m.oldValue(ctx)
  20778. if err != nil {
  20779. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  20780. }
  20781. return oldValue.ErrorDetail, nil
  20782. }
  20783. // ResetErrorDetail resets all changes to the "error_detail" field.
  20784. func (m *MessageRecordsMutation) ResetErrorDetail() {
  20785. m.error_detail = nil
  20786. }
  20787. // SetSendTime sets the "send_time" field.
  20788. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  20789. m.send_time = &t
  20790. }
  20791. // SendTime returns the value of the "send_time" field in the mutation.
  20792. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  20793. v := m.send_time
  20794. if v == nil {
  20795. return
  20796. }
  20797. return *v, true
  20798. }
  20799. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  20800. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20801. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20802. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  20803. if !m.op.Is(OpUpdateOne) {
  20804. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  20805. }
  20806. if m.id == nil || m.oldValue == nil {
  20807. return v, errors.New("OldSendTime requires an ID field in the mutation")
  20808. }
  20809. oldValue, err := m.oldValue(ctx)
  20810. if err != nil {
  20811. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  20812. }
  20813. return oldValue.SendTime, nil
  20814. }
  20815. // ClearSendTime clears the value of the "send_time" field.
  20816. func (m *MessageRecordsMutation) ClearSendTime() {
  20817. m.send_time = nil
  20818. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  20819. }
  20820. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  20821. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  20822. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  20823. return ok
  20824. }
  20825. // ResetSendTime resets all changes to the "send_time" field.
  20826. func (m *MessageRecordsMutation) ResetSendTime() {
  20827. m.send_time = nil
  20828. delete(m.clearedFields, messagerecords.FieldSendTime)
  20829. }
  20830. // SetSourceType sets the "source_type" field.
  20831. func (m *MessageRecordsMutation) SetSourceType(i int) {
  20832. m.source_type = &i
  20833. m.addsource_type = nil
  20834. }
  20835. // SourceType returns the value of the "source_type" field in the mutation.
  20836. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  20837. v := m.source_type
  20838. if v == nil {
  20839. return
  20840. }
  20841. return *v, true
  20842. }
  20843. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  20844. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20846. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  20847. if !m.op.Is(OpUpdateOne) {
  20848. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  20849. }
  20850. if m.id == nil || m.oldValue == nil {
  20851. return v, errors.New("OldSourceType requires an ID field in the mutation")
  20852. }
  20853. oldValue, err := m.oldValue(ctx)
  20854. if err != nil {
  20855. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  20856. }
  20857. return oldValue.SourceType, nil
  20858. }
  20859. // AddSourceType adds i to the "source_type" field.
  20860. func (m *MessageRecordsMutation) AddSourceType(i int) {
  20861. if m.addsource_type != nil {
  20862. *m.addsource_type += i
  20863. } else {
  20864. m.addsource_type = &i
  20865. }
  20866. }
  20867. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  20868. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  20869. v := m.addsource_type
  20870. if v == nil {
  20871. return
  20872. }
  20873. return *v, true
  20874. }
  20875. // ResetSourceType resets all changes to the "source_type" field.
  20876. func (m *MessageRecordsMutation) ResetSourceType() {
  20877. m.source_type = nil
  20878. m.addsource_type = nil
  20879. }
  20880. // SetSourceID sets the "source_id" field.
  20881. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  20882. m.sop_stage = &u
  20883. }
  20884. // SourceID returns the value of the "source_id" field in the mutation.
  20885. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  20886. v := m.sop_stage
  20887. if v == nil {
  20888. return
  20889. }
  20890. return *v, true
  20891. }
  20892. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  20893. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20894. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20895. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  20896. if !m.op.Is(OpUpdateOne) {
  20897. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  20898. }
  20899. if m.id == nil || m.oldValue == nil {
  20900. return v, errors.New("OldSourceID requires an ID field in the mutation")
  20901. }
  20902. oldValue, err := m.oldValue(ctx)
  20903. if err != nil {
  20904. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  20905. }
  20906. return oldValue.SourceID, nil
  20907. }
  20908. // ClearSourceID clears the value of the "source_id" field.
  20909. func (m *MessageRecordsMutation) ClearSourceID() {
  20910. m.sop_stage = nil
  20911. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  20912. }
  20913. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  20914. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  20915. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  20916. return ok
  20917. }
  20918. // ResetSourceID resets all changes to the "source_id" field.
  20919. func (m *MessageRecordsMutation) ResetSourceID() {
  20920. m.sop_stage = nil
  20921. delete(m.clearedFields, messagerecords.FieldSourceID)
  20922. }
  20923. // SetSubSourceID sets the "sub_source_id" field.
  20924. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  20925. m.sop_node = &u
  20926. }
  20927. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  20928. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  20929. v := m.sop_node
  20930. if v == nil {
  20931. return
  20932. }
  20933. return *v, true
  20934. }
  20935. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  20936. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20937. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20938. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  20939. if !m.op.Is(OpUpdateOne) {
  20940. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  20941. }
  20942. if m.id == nil || m.oldValue == nil {
  20943. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  20944. }
  20945. oldValue, err := m.oldValue(ctx)
  20946. if err != nil {
  20947. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  20948. }
  20949. return oldValue.SubSourceID, nil
  20950. }
  20951. // ClearSubSourceID clears the value of the "sub_source_id" field.
  20952. func (m *MessageRecordsMutation) ClearSubSourceID() {
  20953. m.sop_node = nil
  20954. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  20955. }
  20956. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  20957. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  20958. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  20959. return ok
  20960. }
  20961. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  20962. func (m *MessageRecordsMutation) ResetSubSourceID() {
  20963. m.sop_node = nil
  20964. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  20965. }
  20966. // SetOrganizationID sets the "organization_id" field.
  20967. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  20968. m.organization_id = &u
  20969. m.addorganization_id = nil
  20970. }
  20971. // OrganizationID returns the value of the "organization_id" field in the mutation.
  20972. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  20973. v := m.organization_id
  20974. if v == nil {
  20975. return
  20976. }
  20977. return *v, true
  20978. }
  20979. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  20980. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20981. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20982. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  20983. if !m.op.Is(OpUpdateOne) {
  20984. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  20985. }
  20986. if m.id == nil || m.oldValue == nil {
  20987. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  20988. }
  20989. oldValue, err := m.oldValue(ctx)
  20990. if err != nil {
  20991. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  20992. }
  20993. return oldValue.OrganizationID, nil
  20994. }
  20995. // AddOrganizationID adds u to the "organization_id" field.
  20996. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  20997. if m.addorganization_id != nil {
  20998. *m.addorganization_id += u
  20999. } else {
  21000. m.addorganization_id = &u
  21001. }
  21002. }
  21003. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  21004. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  21005. v := m.addorganization_id
  21006. if v == nil {
  21007. return
  21008. }
  21009. return *v, true
  21010. }
  21011. // ClearOrganizationID clears the value of the "organization_id" field.
  21012. func (m *MessageRecordsMutation) ClearOrganizationID() {
  21013. m.organization_id = nil
  21014. m.addorganization_id = nil
  21015. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  21016. }
  21017. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  21018. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  21019. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  21020. return ok
  21021. }
  21022. // ResetOrganizationID resets all changes to the "organization_id" field.
  21023. func (m *MessageRecordsMutation) ResetOrganizationID() {
  21024. m.organization_id = nil
  21025. m.addorganization_id = nil
  21026. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  21027. }
  21028. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  21029. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  21030. m.sop_stage = &id
  21031. }
  21032. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  21033. func (m *MessageRecordsMutation) ClearSopStage() {
  21034. m.clearedsop_stage = true
  21035. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  21036. }
  21037. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  21038. func (m *MessageRecordsMutation) SopStageCleared() bool {
  21039. return m.SourceIDCleared() || m.clearedsop_stage
  21040. }
  21041. // SopStageID returns the "sop_stage" edge ID in the mutation.
  21042. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  21043. if m.sop_stage != nil {
  21044. return *m.sop_stage, true
  21045. }
  21046. return
  21047. }
  21048. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  21049. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21050. // SopStageID instead. It exists only for internal usage by the builders.
  21051. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  21052. if id := m.sop_stage; id != nil {
  21053. ids = append(ids, *id)
  21054. }
  21055. return
  21056. }
  21057. // ResetSopStage resets all changes to the "sop_stage" edge.
  21058. func (m *MessageRecordsMutation) ResetSopStage() {
  21059. m.sop_stage = nil
  21060. m.clearedsop_stage = false
  21061. }
  21062. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  21063. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  21064. m.sop_node = &id
  21065. }
  21066. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  21067. func (m *MessageRecordsMutation) ClearSopNode() {
  21068. m.clearedsop_node = true
  21069. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  21070. }
  21071. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  21072. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  21073. return m.SubSourceIDCleared() || m.clearedsop_node
  21074. }
  21075. // SopNodeID returns the "sop_node" edge ID in the mutation.
  21076. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  21077. if m.sop_node != nil {
  21078. return *m.sop_node, true
  21079. }
  21080. return
  21081. }
  21082. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  21083. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21084. // SopNodeID instead. It exists only for internal usage by the builders.
  21085. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  21086. if id := m.sop_node; id != nil {
  21087. ids = append(ids, *id)
  21088. }
  21089. return
  21090. }
  21091. // ResetSopNode resets all changes to the "sop_node" edge.
  21092. func (m *MessageRecordsMutation) ResetSopNode() {
  21093. m.sop_node = nil
  21094. m.clearedsop_node = false
  21095. }
  21096. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  21097. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  21098. m.message_contact = &id
  21099. }
  21100. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  21101. func (m *MessageRecordsMutation) ClearMessageContact() {
  21102. m.clearedmessage_contact = true
  21103. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  21104. }
  21105. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  21106. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  21107. return m.ContactIDCleared() || m.clearedmessage_contact
  21108. }
  21109. // MessageContactID returns the "message_contact" edge ID in the mutation.
  21110. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  21111. if m.message_contact != nil {
  21112. return *m.message_contact, true
  21113. }
  21114. return
  21115. }
  21116. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  21117. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21118. // MessageContactID instead. It exists only for internal usage by the builders.
  21119. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  21120. if id := m.message_contact; id != nil {
  21121. ids = append(ids, *id)
  21122. }
  21123. return
  21124. }
  21125. // ResetMessageContact resets all changes to the "message_contact" edge.
  21126. func (m *MessageRecordsMutation) ResetMessageContact() {
  21127. m.message_contact = nil
  21128. m.clearedmessage_contact = false
  21129. }
  21130. // Where appends a list predicates to the MessageRecordsMutation builder.
  21131. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  21132. m.predicates = append(m.predicates, ps...)
  21133. }
  21134. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  21135. // users can use type-assertion to append predicates that do not depend on any generated package.
  21136. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  21137. p := make([]predicate.MessageRecords, len(ps))
  21138. for i := range ps {
  21139. p[i] = ps[i]
  21140. }
  21141. m.Where(p...)
  21142. }
  21143. // Op returns the operation name.
  21144. func (m *MessageRecordsMutation) Op() Op {
  21145. return m.op
  21146. }
  21147. // SetOp allows setting the mutation operation.
  21148. func (m *MessageRecordsMutation) SetOp(op Op) {
  21149. m.op = op
  21150. }
  21151. // Type returns the node type of this mutation (MessageRecords).
  21152. func (m *MessageRecordsMutation) Type() string {
  21153. return m.typ
  21154. }
  21155. // Fields returns all fields that were changed during this mutation. Note that in
  21156. // order to get all numeric fields that were incremented/decremented, call
  21157. // AddedFields().
  21158. func (m *MessageRecordsMutation) Fields() []string {
  21159. fields := make([]string, 0, 16)
  21160. if m.created_at != nil {
  21161. fields = append(fields, messagerecords.FieldCreatedAt)
  21162. }
  21163. if m.updated_at != nil {
  21164. fields = append(fields, messagerecords.FieldUpdatedAt)
  21165. }
  21166. if m.status != nil {
  21167. fields = append(fields, messagerecords.FieldStatus)
  21168. }
  21169. if m.bot_wxid != nil {
  21170. fields = append(fields, messagerecords.FieldBotWxid)
  21171. }
  21172. if m.message_contact != nil {
  21173. fields = append(fields, messagerecords.FieldContactID)
  21174. }
  21175. if m.contact_type != nil {
  21176. fields = append(fields, messagerecords.FieldContactType)
  21177. }
  21178. if m.contact_wxid != nil {
  21179. fields = append(fields, messagerecords.FieldContactWxid)
  21180. }
  21181. if m.content_type != nil {
  21182. fields = append(fields, messagerecords.FieldContentType)
  21183. }
  21184. if m.content != nil {
  21185. fields = append(fields, messagerecords.FieldContent)
  21186. }
  21187. if m.meta != nil {
  21188. fields = append(fields, messagerecords.FieldMeta)
  21189. }
  21190. if m.error_detail != nil {
  21191. fields = append(fields, messagerecords.FieldErrorDetail)
  21192. }
  21193. if m.send_time != nil {
  21194. fields = append(fields, messagerecords.FieldSendTime)
  21195. }
  21196. if m.source_type != nil {
  21197. fields = append(fields, messagerecords.FieldSourceType)
  21198. }
  21199. if m.sop_stage != nil {
  21200. fields = append(fields, messagerecords.FieldSourceID)
  21201. }
  21202. if m.sop_node != nil {
  21203. fields = append(fields, messagerecords.FieldSubSourceID)
  21204. }
  21205. if m.organization_id != nil {
  21206. fields = append(fields, messagerecords.FieldOrganizationID)
  21207. }
  21208. return fields
  21209. }
  21210. // Field returns the value of a field with the given name. The second boolean
  21211. // return value indicates that this field was not set, or was not defined in the
  21212. // schema.
  21213. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  21214. switch name {
  21215. case messagerecords.FieldCreatedAt:
  21216. return m.CreatedAt()
  21217. case messagerecords.FieldUpdatedAt:
  21218. return m.UpdatedAt()
  21219. case messagerecords.FieldStatus:
  21220. return m.Status()
  21221. case messagerecords.FieldBotWxid:
  21222. return m.BotWxid()
  21223. case messagerecords.FieldContactID:
  21224. return m.ContactID()
  21225. case messagerecords.FieldContactType:
  21226. return m.ContactType()
  21227. case messagerecords.FieldContactWxid:
  21228. return m.ContactWxid()
  21229. case messagerecords.FieldContentType:
  21230. return m.ContentType()
  21231. case messagerecords.FieldContent:
  21232. return m.Content()
  21233. case messagerecords.FieldMeta:
  21234. return m.Meta()
  21235. case messagerecords.FieldErrorDetail:
  21236. return m.ErrorDetail()
  21237. case messagerecords.FieldSendTime:
  21238. return m.SendTime()
  21239. case messagerecords.FieldSourceType:
  21240. return m.SourceType()
  21241. case messagerecords.FieldSourceID:
  21242. return m.SourceID()
  21243. case messagerecords.FieldSubSourceID:
  21244. return m.SubSourceID()
  21245. case messagerecords.FieldOrganizationID:
  21246. return m.OrganizationID()
  21247. }
  21248. return nil, false
  21249. }
  21250. // OldField returns the old value of the field from the database. An error is
  21251. // returned if the mutation operation is not UpdateOne, or the query to the
  21252. // database failed.
  21253. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21254. switch name {
  21255. case messagerecords.FieldCreatedAt:
  21256. return m.OldCreatedAt(ctx)
  21257. case messagerecords.FieldUpdatedAt:
  21258. return m.OldUpdatedAt(ctx)
  21259. case messagerecords.FieldStatus:
  21260. return m.OldStatus(ctx)
  21261. case messagerecords.FieldBotWxid:
  21262. return m.OldBotWxid(ctx)
  21263. case messagerecords.FieldContactID:
  21264. return m.OldContactID(ctx)
  21265. case messagerecords.FieldContactType:
  21266. return m.OldContactType(ctx)
  21267. case messagerecords.FieldContactWxid:
  21268. return m.OldContactWxid(ctx)
  21269. case messagerecords.FieldContentType:
  21270. return m.OldContentType(ctx)
  21271. case messagerecords.FieldContent:
  21272. return m.OldContent(ctx)
  21273. case messagerecords.FieldMeta:
  21274. return m.OldMeta(ctx)
  21275. case messagerecords.FieldErrorDetail:
  21276. return m.OldErrorDetail(ctx)
  21277. case messagerecords.FieldSendTime:
  21278. return m.OldSendTime(ctx)
  21279. case messagerecords.FieldSourceType:
  21280. return m.OldSourceType(ctx)
  21281. case messagerecords.FieldSourceID:
  21282. return m.OldSourceID(ctx)
  21283. case messagerecords.FieldSubSourceID:
  21284. return m.OldSubSourceID(ctx)
  21285. case messagerecords.FieldOrganizationID:
  21286. return m.OldOrganizationID(ctx)
  21287. }
  21288. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  21289. }
  21290. // SetField sets the value of a field with the given name. It returns an error if
  21291. // the field is not defined in the schema, or if the type mismatched the field
  21292. // type.
  21293. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  21294. switch name {
  21295. case messagerecords.FieldCreatedAt:
  21296. v, ok := value.(time.Time)
  21297. if !ok {
  21298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21299. }
  21300. m.SetCreatedAt(v)
  21301. return nil
  21302. case messagerecords.FieldUpdatedAt:
  21303. v, ok := value.(time.Time)
  21304. if !ok {
  21305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21306. }
  21307. m.SetUpdatedAt(v)
  21308. return nil
  21309. case messagerecords.FieldStatus:
  21310. v, ok := value.(uint8)
  21311. if !ok {
  21312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21313. }
  21314. m.SetStatus(v)
  21315. return nil
  21316. case messagerecords.FieldBotWxid:
  21317. v, ok := value.(string)
  21318. if !ok {
  21319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21320. }
  21321. m.SetBotWxid(v)
  21322. return nil
  21323. case messagerecords.FieldContactID:
  21324. v, ok := value.(uint64)
  21325. if !ok {
  21326. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21327. }
  21328. m.SetContactID(v)
  21329. return nil
  21330. case messagerecords.FieldContactType:
  21331. v, ok := value.(int)
  21332. if !ok {
  21333. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21334. }
  21335. m.SetContactType(v)
  21336. return nil
  21337. case messagerecords.FieldContactWxid:
  21338. v, ok := value.(string)
  21339. if !ok {
  21340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21341. }
  21342. m.SetContactWxid(v)
  21343. return nil
  21344. case messagerecords.FieldContentType:
  21345. v, ok := value.(int)
  21346. if !ok {
  21347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21348. }
  21349. m.SetContentType(v)
  21350. return nil
  21351. case messagerecords.FieldContent:
  21352. v, ok := value.(string)
  21353. if !ok {
  21354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21355. }
  21356. m.SetContent(v)
  21357. return nil
  21358. case messagerecords.FieldMeta:
  21359. v, ok := value.(custom_types.Meta)
  21360. if !ok {
  21361. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21362. }
  21363. m.SetMeta(v)
  21364. return nil
  21365. case messagerecords.FieldErrorDetail:
  21366. v, ok := value.(string)
  21367. if !ok {
  21368. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21369. }
  21370. m.SetErrorDetail(v)
  21371. return nil
  21372. case messagerecords.FieldSendTime:
  21373. v, ok := value.(time.Time)
  21374. if !ok {
  21375. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21376. }
  21377. m.SetSendTime(v)
  21378. return nil
  21379. case messagerecords.FieldSourceType:
  21380. v, ok := value.(int)
  21381. if !ok {
  21382. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21383. }
  21384. m.SetSourceType(v)
  21385. return nil
  21386. case messagerecords.FieldSourceID:
  21387. v, ok := value.(uint64)
  21388. if !ok {
  21389. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21390. }
  21391. m.SetSourceID(v)
  21392. return nil
  21393. case messagerecords.FieldSubSourceID:
  21394. v, ok := value.(uint64)
  21395. if !ok {
  21396. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21397. }
  21398. m.SetSubSourceID(v)
  21399. return nil
  21400. case messagerecords.FieldOrganizationID:
  21401. v, ok := value.(uint64)
  21402. if !ok {
  21403. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21404. }
  21405. m.SetOrganizationID(v)
  21406. return nil
  21407. }
  21408. return fmt.Errorf("unknown MessageRecords field %s", name)
  21409. }
  21410. // AddedFields returns all numeric fields that were incremented/decremented during
  21411. // this mutation.
  21412. func (m *MessageRecordsMutation) AddedFields() []string {
  21413. var fields []string
  21414. if m.addstatus != nil {
  21415. fields = append(fields, messagerecords.FieldStatus)
  21416. }
  21417. if m.addcontact_type != nil {
  21418. fields = append(fields, messagerecords.FieldContactType)
  21419. }
  21420. if m.addcontent_type != nil {
  21421. fields = append(fields, messagerecords.FieldContentType)
  21422. }
  21423. if m.addsource_type != nil {
  21424. fields = append(fields, messagerecords.FieldSourceType)
  21425. }
  21426. if m.addorganization_id != nil {
  21427. fields = append(fields, messagerecords.FieldOrganizationID)
  21428. }
  21429. return fields
  21430. }
  21431. // AddedField returns the numeric value that was incremented/decremented on a field
  21432. // with the given name. The second boolean return value indicates that this field
  21433. // was not set, or was not defined in the schema.
  21434. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  21435. switch name {
  21436. case messagerecords.FieldStatus:
  21437. return m.AddedStatus()
  21438. case messagerecords.FieldContactType:
  21439. return m.AddedContactType()
  21440. case messagerecords.FieldContentType:
  21441. return m.AddedContentType()
  21442. case messagerecords.FieldSourceType:
  21443. return m.AddedSourceType()
  21444. case messagerecords.FieldOrganizationID:
  21445. return m.AddedOrganizationID()
  21446. }
  21447. return nil, false
  21448. }
  21449. // AddField adds the value to the field with the given name. It returns an error if
  21450. // the field is not defined in the schema, or if the type mismatched the field
  21451. // type.
  21452. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  21453. switch name {
  21454. case messagerecords.FieldStatus:
  21455. v, ok := value.(int8)
  21456. if !ok {
  21457. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21458. }
  21459. m.AddStatus(v)
  21460. return nil
  21461. case messagerecords.FieldContactType:
  21462. v, ok := value.(int)
  21463. if !ok {
  21464. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21465. }
  21466. m.AddContactType(v)
  21467. return nil
  21468. case messagerecords.FieldContentType:
  21469. v, ok := value.(int)
  21470. if !ok {
  21471. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21472. }
  21473. m.AddContentType(v)
  21474. return nil
  21475. case messagerecords.FieldSourceType:
  21476. v, ok := value.(int)
  21477. if !ok {
  21478. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21479. }
  21480. m.AddSourceType(v)
  21481. return nil
  21482. case messagerecords.FieldOrganizationID:
  21483. v, ok := value.(int64)
  21484. if !ok {
  21485. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21486. }
  21487. m.AddOrganizationID(v)
  21488. return nil
  21489. }
  21490. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  21491. }
  21492. // ClearedFields returns all nullable fields that were cleared during this
  21493. // mutation.
  21494. func (m *MessageRecordsMutation) ClearedFields() []string {
  21495. var fields []string
  21496. if m.FieldCleared(messagerecords.FieldStatus) {
  21497. fields = append(fields, messagerecords.FieldStatus)
  21498. }
  21499. if m.FieldCleared(messagerecords.FieldContactID) {
  21500. fields = append(fields, messagerecords.FieldContactID)
  21501. }
  21502. if m.FieldCleared(messagerecords.FieldMeta) {
  21503. fields = append(fields, messagerecords.FieldMeta)
  21504. }
  21505. if m.FieldCleared(messagerecords.FieldSendTime) {
  21506. fields = append(fields, messagerecords.FieldSendTime)
  21507. }
  21508. if m.FieldCleared(messagerecords.FieldSourceID) {
  21509. fields = append(fields, messagerecords.FieldSourceID)
  21510. }
  21511. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  21512. fields = append(fields, messagerecords.FieldSubSourceID)
  21513. }
  21514. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  21515. fields = append(fields, messagerecords.FieldOrganizationID)
  21516. }
  21517. return fields
  21518. }
  21519. // FieldCleared returns a boolean indicating if a field with the given name was
  21520. // cleared in this mutation.
  21521. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  21522. _, ok := m.clearedFields[name]
  21523. return ok
  21524. }
  21525. // ClearField clears the value of the field with the given name. It returns an
  21526. // error if the field is not defined in the schema.
  21527. func (m *MessageRecordsMutation) ClearField(name string) error {
  21528. switch name {
  21529. case messagerecords.FieldStatus:
  21530. m.ClearStatus()
  21531. return nil
  21532. case messagerecords.FieldContactID:
  21533. m.ClearContactID()
  21534. return nil
  21535. case messagerecords.FieldMeta:
  21536. m.ClearMeta()
  21537. return nil
  21538. case messagerecords.FieldSendTime:
  21539. m.ClearSendTime()
  21540. return nil
  21541. case messagerecords.FieldSourceID:
  21542. m.ClearSourceID()
  21543. return nil
  21544. case messagerecords.FieldSubSourceID:
  21545. m.ClearSubSourceID()
  21546. return nil
  21547. case messagerecords.FieldOrganizationID:
  21548. m.ClearOrganizationID()
  21549. return nil
  21550. }
  21551. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  21552. }
  21553. // ResetField resets all changes in the mutation for the field with the given name.
  21554. // It returns an error if the field is not defined in the schema.
  21555. func (m *MessageRecordsMutation) ResetField(name string) error {
  21556. switch name {
  21557. case messagerecords.FieldCreatedAt:
  21558. m.ResetCreatedAt()
  21559. return nil
  21560. case messagerecords.FieldUpdatedAt:
  21561. m.ResetUpdatedAt()
  21562. return nil
  21563. case messagerecords.FieldStatus:
  21564. m.ResetStatus()
  21565. return nil
  21566. case messagerecords.FieldBotWxid:
  21567. m.ResetBotWxid()
  21568. return nil
  21569. case messagerecords.FieldContactID:
  21570. m.ResetContactID()
  21571. return nil
  21572. case messagerecords.FieldContactType:
  21573. m.ResetContactType()
  21574. return nil
  21575. case messagerecords.FieldContactWxid:
  21576. m.ResetContactWxid()
  21577. return nil
  21578. case messagerecords.FieldContentType:
  21579. m.ResetContentType()
  21580. return nil
  21581. case messagerecords.FieldContent:
  21582. m.ResetContent()
  21583. return nil
  21584. case messagerecords.FieldMeta:
  21585. m.ResetMeta()
  21586. return nil
  21587. case messagerecords.FieldErrorDetail:
  21588. m.ResetErrorDetail()
  21589. return nil
  21590. case messagerecords.FieldSendTime:
  21591. m.ResetSendTime()
  21592. return nil
  21593. case messagerecords.FieldSourceType:
  21594. m.ResetSourceType()
  21595. return nil
  21596. case messagerecords.FieldSourceID:
  21597. m.ResetSourceID()
  21598. return nil
  21599. case messagerecords.FieldSubSourceID:
  21600. m.ResetSubSourceID()
  21601. return nil
  21602. case messagerecords.FieldOrganizationID:
  21603. m.ResetOrganizationID()
  21604. return nil
  21605. }
  21606. return fmt.Errorf("unknown MessageRecords field %s", name)
  21607. }
  21608. // AddedEdges returns all edge names that were set/added in this mutation.
  21609. func (m *MessageRecordsMutation) AddedEdges() []string {
  21610. edges := make([]string, 0, 3)
  21611. if m.sop_stage != nil {
  21612. edges = append(edges, messagerecords.EdgeSopStage)
  21613. }
  21614. if m.sop_node != nil {
  21615. edges = append(edges, messagerecords.EdgeSopNode)
  21616. }
  21617. if m.message_contact != nil {
  21618. edges = append(edges, messagerecords.EdgeMessageContact)
  21619. }
  21620. return edges
  21621. }
  21622. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21623. // name in this mutation.
  21624. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  21625. switch name {
  21626. case messagerecords.EdgeSopStage:
  21627. if id := m.sop_stage; id != nil {
  21628. return []ent.Value{*id}
  21629. }
  21630. case messagerecords.EdgeSopNode:
  21631. if id := m.sop_node; id != nil {
  21632. return []ent.Value{*id}
  21633. }
  21634. case messagerecords.EdgeMessageContact:
  21635. if id := m.message_contact; id != nil {
  21636. return []ent.Value{*id}
  21637. }
  21638. }
  21639. return nil
  21640. }
  21641. // RemovedEdges returns all edge names that were removed in this mutation.
  21642. func (m *MessageRecordsMutation) RemovedEdges() []string {
  21643. edges := make([]string, 0, 3)
  21644. return edges
  21645. }
  21646. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21647. // the given name in this mutation.
  21648. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  21649. return nil
  21650. }
  21651. // ClearedEdges returns all edge names that were cleared in this mutation.
  21652. func (m *MessageRecordsMutation) ClearedEdges() []string {
  21653. edges := make([]string, 0, 3)
  21654. if m.clearedsop_stage {
  21655. edges = append(edges, messagerecords.EdgeSopStage)
  21656. }
  21657. if m.clearedsop_node {
  21658. edges = append(edges, messagerecords.EdgeSopNode)
  21659. }
  21660. if m.clearedmessage_contact {
  21661. edges = append(edges, messagerecords.EdgeMessageContact)
  21662. }
  21663. return edges
  21664. }
  21665. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21666. // was cleared in this mutation.
  21667. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  21668. switch name {
  21669. case messagerecords.EdgeSopStage:
  21670. return m.clearedsop_stage
  21671. case messagerecords.EdgeSopNode:
  21672. return m.clearedsop_node
  21673. case messagerecords.EdgeMessageContact:
  21674. return m.clearedmessage_contact
  21675. }
  21676. return false
  21677. }
  21678. // ClearEdge clears the value of the edge with the given name. It returns an error
  21679. // if that edge is not defined in the schema.
  21680. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  21681. switch name {
  21682. case messagerecords.EdgeSopStage:
  21683. m.ClearSopStage()
  21684. return nil
  21685. case messagerecords.EdgeSopNode:
  21686. m.ClearSopNode()
  21687. return nil
  21688. case messagerecords.EdgeMessageContact:
  21689. m.ClearMessageContact()
  21690. return nil
  21691. }
  21692. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  21693. }
  21694. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21695. // It returns an error if the edge is not defined in the schema.
  21696. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  21697. switch name {
  21698. case messagerecords.EdgeSopStage:
  21699. m.ResetSopStage()
  21700. return nil
  21701. case messagerecords.EdgeSopNode:
  21702. m.ResetSopNode()
  21703. return nil
  21704. case messagerecords.EdgeMessageContact:
  21705. m.ResetMessageContact()
  21706. return nil
  21707. }
  21708. return fmt.Errorf("unknown MessageRecords edge %s", name)
  21709. }
  21710. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  21711. type MsgMutation struct {
  21712. config
  21713. op Op
  21714. typ string
  21715. id *uint64
  21716. created_at *time.Time
  21717. updated_at *time.Time
  21718. deleted_at *time.Time
  21719. status *uint8
  21720. addstatus *int8
  21721. fromwxid *string
  21722. toid *string
  21723. msgtype *int32
  21724. addmsgtype *int32
  21725. msg *string
  21726. batch_no *string
  21727. cc *string
  21728. phone *string
  21729. clearedFields map[string]struct{}
  21730. done bool
  21731. oldValue func(context.Context) (*Msg, error)
  21732. predicates []predicate.Msg
  21733. }
  21734. var _ ent.Mutation = (*MsgMutation)(nil)
  21735. // msgOption allows management of the mutation configuration using functional options.
  21736. type msgOption func(*MsgMutation)
  21737. // newMsgMutation creates new mutation for the Msg entity.
  21738. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  21739. m := &MsgMutation{
  21740. config: c,
  21741. op: op,
  21742. typ: TypeMsg,
  21743. clearedFields: make(map[string]struct{}),
  21744. }
  21745. for _, opt := range opts {
  21746. opt(m)
  21747. }
  21748. return m
  21749. }
  21750. // withMsgID sets the ID field of the mutation.
  21751. func withMsgID(id uint64) msgOption {
  21752. return func(m *MsgMutation) {
  21753. var (
  21754. err error
  21755. once sync.Once
  21756. value *Msg
  21757. )
  21758. m.oldValue = func(ctx context.Context) (*Msg, error) {
  21759. once.Do(func() {
  21760. if m.done {
  21761. err = errors.New("querying old values post mutation is not allowed")
  21762. } else {
  21763. value, err = m.Client().Msg.Get(ctx, id)
  21764. }
  21765. })
  21766. return value, err
  21767. }
  21768. m.id = &id
  21769. }
  21770. }
  21771. // withMsg sets the old Msg of the mutation.
  21772. func withMsg(node *Msg) msgOption {
  21773. return func(m *MsgMutation) {
  21774. m.oldValue = func(context.Context) (*Msg, error) {
  21775. return node, nil
  21776. }
  21777. m.id = &node.ID
  21778. }
  21779. }
  21780. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21781. // executed in a transaction (ent.Tx), a transactional client is returned.
  21782. func (m MsgMutation) Client() *Client {
  21783. client := &Client{config: m.config}
  21784. client.init()
  21785. return client
  21786. }
  21787. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21788. // it returns an error otherwise.
  21789. func (m MsgMutation) Tx() (*Tx, error) {
  21790. if _, ok := m.driver.(*txDriver); !ok {
  21791. return nil, errors.New("ent: mutation is not running in a transaction")
  21792. }
  21793. tx := &Tx{config: m.config}
  21794. tx.init()
  21795. return tx, nil
  21796. }
  21797. // SetID sets the value of the id field. Note that this
  21798. // operation is only accepted on creation of Msg entities.
  21799. func (m *MsgMutation) SetID(id uint64) {
  21800. m.id = &id
  21801. }
  21802. // ID returns the ID value in the mutation. Note that the ID is only available
  21803. // if it was provided to the builder or after it was returned from the database.
  21804. func (m *MsgMutation) ID() (id uint64, exists bool) {
  21805. if m.id == nil {
  21806. return
  21807. }
  21808. return *m.id, true
  21809. }
  21810. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21811. // That means, if the mutation is applied within a transaction with an isolation level such
  21812. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21813. // or updated by the mutation.
  21814. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  21815. switch {
  21816. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21817. id, exists := m.ID()
  21818. if exists {
  21819. return []uint64{id}, nil
  21820. }
  21821. fallthrough
  21822. case m.op.Is(OpUpdate | OpDelete):
  21823. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  21824. default:
  21825. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21826. }
  21827. }
  21828. // SetCreatedAt sets the "created_at" field.
  21829. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  21830. m.created_at = &t
  21831. }
  21832. // CreatedAt returns the value of the "created_at" field in the mutation.
  21833. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  21834. v := m.created_at
  21835. if v == nil {
  21836. return
  21837. }
  21838. return *v, true
  21839. }
  21840. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  21841. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  21842. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21843. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21844. if !m.op.Is(OpUpdateOne) {
  21845. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21846. }
  21847. if m.id == nil || m.oldValue == nil {
  21848. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21849. }
  21850. oldValue, err := m.oldValue(ctx)
  21851. if err != nil {
  21852. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21853. }
  21854. return oldValue.CreatedAt, nil
  21855. }
  21856. // ResetCreatedAt resets all changes to the "created_at" field.
  21857. func (m *MsgMutation) ResetCreatedAt() {
  21858. m.created_at = nil
  21859. }
  21860. // SetUpdatedAt sets the "updated_at" field.
  21861. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  21862. m.updated_at = &t
  21863. }
  21864. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21865. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  21866. v := m.updated_at
  21867. if v == nil {
  21868. return
  21869. }
  21870. return *v, true
  21871. }
  21872. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  21873. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  21874. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21875. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21876. if !m.op.Is(OpUpdateOne) {
  21877. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21878. }
  21879. if m.id == nil || m.oldValue == nil {
  21880. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21881. }
  21882. oldValue, err := m.oldValue(ctx)
  21883. if err != nil {
  21884. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21885. }
  21886. return oldValue.UpdatedAt, nil
  21887. }
  21888. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21889. func (m *MsgMutation) ResetUpdatedAt() {
  21890. m.updated_at = nil
  21891. }
  21892. // SetDeletedAt sets the "deleted_at" field.
  21893. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  21894. m.deleted_at = &t
  21895. }
  21896. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21897. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  21898. v := m.deleted_at
  21899. if v == nil {
  21900. return
  21901. }
  21902. return *v, true
  21903. }
  21904. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  21905. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  21906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21907. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21908. if !m.op.Is(OpUpdateOne) {
  21909. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21910. }
  21911. if m.id == nil || m.oldValue == nil {
  21912. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21913. }
  21914. oldValue, err := m.oldValue(ctx)
  21915. if err != nil {
  21916. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21917. }
  21918. return oldValue.DeletedAt, nil
  21919. }
  21920. // ClearDeletedAt clears the value of the "deleted_at" field.
  21921. func (m *MsgMutation) ClearDeletedAt() {
  21922. m.deleted_at = nil
  21923. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  21924. }
  21925. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21926. func (m *MsgMutation) DeletedAtCleared() bool {
  21927. _, ok := m.clearedFields[msg.FieldDeletedAt]
  21928. return ok
  21929. }
  21930. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21931. func (m *MsgMutation) ResetDeletedAt() {
  21932. m.deleted_at = nil
  21933. delete(m.clearedFields, msg.FieldDeletedAt)
  21934. }
  21935. // SetStatus sets the "status" field.
  21936. func (m *MsgMutation) SetStatus(u uint8) {
  21937. m.status = &u
  21938. m.addstatus = nil
  21939. }
  21940. // Status returns the value of the "status" field in the mutation.
  21941. func (m *MsgMutation) Status() (r uint8, exists bool) {
  21942. v := m.status
  21943. if v == nil {
  21944. return
  21945. }
  21946. return *v, true
  21947. }
  21948. // OldStatus returns the old "status" field's value of the Msg entity.
  21949. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  21950. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21951. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  21952. if !m.op.Is(OpUpdateOne) {
  21953. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  21954. }
  21955. if m.id == nil || m.oldValue == nil {
  21956. return v, errors.New("OldStatus requires an ID field in the mutation")
  21957. }
  21958. oldValue, err := m.oldValue(ctx)
  21959. if err != nil {
  21960. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  21961. }
  21962. return oldValue.Status, nil
  21963. }
  21964. // AddStatus adds u to the "status" field.
  21965. func (m *MsgMutation) AddStatus(u int8) {
  21966. if m.addstatus != nil {
  21967. *m.addstatus += u
  21968. } else {
  21969. m.addstatus = &u
  21970. }
  21971. }
  21972. // AddedStatus returns the value that was added to the "status" field in this mutation.
  21973. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  21974. v := m.addstatus
  21975. if v == nil {
  21976. return
  21977. }
  21978. return *v, true
  21979. }
  21980. // ClearStatus clears the value of the "status" field.
  21981. func (m *MsgMutation) ClearStatus() {
  21982. m.status = nil
  21983. m.addstatus = nil
  21984. m.clearedFields[msg.FieldStatus] = struct{}{}
  21985. }
  21986. // StatusCleared returns if the "status" field was cleared in this mutation.
  21987. func (m *MsgMutation) StatusCleared() bool {
  21988. _, ok := m.clearedFields[msg.FieldStatus]
  21989. return ok
  21990. }
  21991. // ResetStatus resets all changes to the "status" field.
  21992. func (m *MsgMutation) ResetStatus() {
  21993. m.status = nil
  21994. m.addstatus = nil
  21995. delete(m.clearedFields, msg.FieldStatus)
  21996. }
  21997. // SetFromwxid sets the "fromwxid" field.
  21998. func (m *MsgMutation) SetFromwxid(s string) {
  21999. m.fromwxid = &s
  22000. }
  22001. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  22002. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  22003. v := m.fromwxid
  22004. if v == nil {
  22005. return
  22006. }
  22007. return *v, true
  22008. }
  22009. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  22010. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22011. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22012. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  22013. if !m.op.Is(OpUpdateOne) {
  22014. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  22015. }
  22016. if m.id == nil || m.oldValue == nil {
  22017. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  22018. }
  22019. oldValue, err := m.oldValue(ctx)
  22020. if err != nil {
  22021. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  22022. }
  22023. return oldValue.Fromwxid, nil
  22024. }
  22025. // ClearFromwxid clears the value of the "fromwxid" field.
  22026. func (m *MsgMutation) ClearFromwxid() {
  22027. m.fromwxid = nil
  22028. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  22029. }
  22030. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  22031. func (m *MsgMutation) FromwxidCleared() bool {
  22032. _, ok := m.clearedFields[msg.FieldFromwxid]
  22033. return ok
  22034. }
  22035. // ResetFromwxid resets all changes to the "fromwxid" field.
  22036. func (m *MsgMutation) ResetFromwxid() {
  22037. m.fromwxid = nil
  22038. delete(m.clearedFields, msg.FieldFromwxid)
  22039. }
  22040. // SetToid sets the "toid" field.
  22041. func (m *MsgMutation) SetToid(s string) {
  22042. m.toid = &s
  22043. }
  22044. // Toid returns the value of the "toid" field in the mutation.
  22045. func (m *MsgMutation) Toid() (r string, exists bool) {
  22046. v := m.toid
  22047. if v == nil {
  22048. return
  22049. }
  22050. return *v, true
  22051. }
  22052. // OldToid returns the old "toid" field's value of the Msg entity.
  22053. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22054. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22055. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  22056. if !m.op.Is(OpUpdateOne) {
  22057. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  22058. }
  22059. if m.id == nil || m.oldValue == nil {
  22060. return v, errors.New("OldToid requires an ID field in the mutation")
  22061. }
  22062. oldValue, err := m.oldValue(ctx)
  22063. if err != nil {
  22064. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  22065. }
  22066. return oldValue.Toid, nil
  22067. }
  22068. // ClearToid clears the value of the "toid" field.
  22069. func (m *MsgMutation) ClearToid() {
  22070. m.toid = nil
  22071. m.clearedFields[msg.FieldToid] = struct{}{}
  22072. }
  22073. // ToidCleared returns if the "toid" field was cleared in this mutation.
  22074. func (m *MsgMutation) ToidCleared() bool {
  22075. _, ok := m.clearedFields[msg.FieldToid]
  22076. return ok
  22077. }
  22078. // ResetToid resets all changes to the "toid" field.
  22079. func (m *MsgMutation) ResetToid() {
  22080. m.toid = nil
  22081. delete(m.clearedFields, msg.FieldToid)
  22082. }
  22083. // SetMsgtype sets the "msgtype" field.
  22084. func (m *MsgMutation) SetMsgtype(i int32) {
  22085. m.msgtype = &i
  22086. m.addmsgtype = nil
  22087. }
  22088. // Msgtype returns the value of the "msgtype" field in the mutation.
  22089. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  22090. v := m.msgtype
  22091. if v == nil {
  22092. return
  22093. }
  22094. return *v, true
  22095. }
  22096. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  22097. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22098. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22099. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  22100. if !m.op.Is(OpUpdateOne) {
  22101. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  22102. }
  22103. if m.id == nil || m.oldValue == nil {
  22104. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  22105. }
  22106. oldValue, err := m.oldValue(ctx)
  22107. if err != nil {
  22108. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  22109. }
  22110. return oldValue.Msgtype, nil
  22111. }
  22112. // AddMsgtype adds i to the "msgtype" field.
  22113. func (m *MsgMutation) AddMsgtype(i int32) {
  22114. if m.addmsgtype != nil {
  22115. *m.addmsgtype += i
  22116. } else {
  22117. m.addmsgtype = &i
  22118. }
  22119. }
  22120. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  22121. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  22122. v := m.addmsgtype
  22123. if v == nil {
  22124. return
  22125. }
  22126. return *v, true
  22127. }
  22128. // ClearMsgtype clears the value of the "msgtype" field.
  22129. func (m *MsgMutation) ClearMsgtype() {
  22130. m.msgtype = nil
  22131. m.addmsgtype = nil
  22132. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  22133. }
  22134. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  22135. func (m *MsgMutation) MsgtypeCleared() bool {
  22136. _, ok := m.clearedFields[msg.FieldMsgtype]
  22137. return ok
  22138. }
  22139. // ResetMsgtype resets all changes to the "msgtype" field.
  22140. func (m *MsgMutation) ResetMsgtype() {
  22141. m.msgtype = nil
  22142. m.addmsgtype = nil
  22143. delete(m.clearedFields, msg.FieldMsgtype)
  22144. }
  22145. // SetMsg sets the "msg" field.
  22146. func (m *MsgMutation) SetMsg(s string) {
  22147. m.msg = &s
  22148. }
  22149. // Msg returns the value of the "msg" field in the mutation.
  22150. func (m *MsgMutation) Msg() (r string, exists bool) {
  22151. v := m.msg
  22152. if v == nil {
  22153. return
  22154. }
  22155. return *v, true
  22156. }
  22157. // OldMsg returns the old "msg" field's value of the Msg entity.
  22158. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22159. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22160. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  22161. if !m.op.Is(OpUpdateOne) {
  22162. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  22163. }
  22164. if m.id == nil || m.oldValue == nil {
  22165. return v, errors.New("OldMsg requires an ID field in the mutation")
  22166. }
  22167. oldValue, err := m.oldValue(ctx)
  22168. if err != nil {
  22169. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  22170. }
  22171. return oldValue.Msg, nil
  22172. }
  22173. // ClearMsg clears the value of the "msg" field.
  22174. func (m *MsgMutation) ClearMsg() {
  22175. m.msg = nil
  22176. m.clearedFields[msg.FieldMsg] = struct{}{}
  22177. }
  22178. // MsgCleared returns if the "msg" field was cleared in this mutation.
  22179. func (m *MsgMutation) MsgCleared() bool {
  22180. _, ok := m.clearedFields[msg.FieldMsg]
  22181. return ok
  22182. }
  22183. // ResetMsg resets all changes to the "msg" field.
  22184. func (m *MsgMutation) ResetMsg() {
  22185. m.msg = nil
  22186. delete(m.clearedFields, msg.FieldMsg)
  22187. }
  22188. // SetBatchNo sets the "batch_no" field.
  22189. func (m *MsgMutation) SetBatchNo(s string) {
  22190. m.batch_no = &s
  22191. }
  22192. // BatchNo returns the value of the "batch_no" field in the mutation.
  22193. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  22194. v := m.batch_no
  22195. if v == nil {
  22196. return
  22197. }
  22198. return *v, true
  22199. }
  22200. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  22201. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22202. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22203. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  22204. if !m.op.Is(OpUpdateOne) {
  22205. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  22206. }
  22207. if m.id == nil || m.oldValue == nil {
  22208. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  22209. }
  22210. oldValue, err := m.oldValue(ctx)
  22211. if err != nil {
  22212. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  22213. }
  22214. return oldValue.BatchNo, nil
  22215. }
  22216. // ClearBatchNo clears the value of the "batch_no" field.
  22217. func (m *MsgMutation) ClearBatchNo() {
  22218. m.batch_no = nil
  22219. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  22220. }
  22221. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  22222. func (m *MsgMutation) BatchNoCleared() bool {
  22223. _, ok := m.clearedFields[msg.FieldBatchNo]
  22224. return ok
  22225. }
  22226. // ResetBatchNo resets all changes to the "batch_no" field.
  22227. func (m *MsgMutation) ResetBatchNo() {
  22228. m.batch_no = nil
  22229. delete(m.clearedFields, msg.FieldBatchNo)
  22230. }
  22231. // SetCc sets the "cc" field.
  22232. func (m *MsgMutation) SetCc(s string) {
  22233. m.cc = &s
  22234. }
  22235. // Cc returns the value of the "cc" field in the mutation.
  22236. func (m *MsgMutation) Cc() (r string, exists bool) {
  22237. v := m.cc
  22238. if v == nil {
  22239. return
  22240. }
  22241. return *v, true
  22242. }
  22243. // OldCc returns the old "cc" field's value of the Msg entity.
  22244. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22245. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22246. func (m *MsgMutation) OldCc(ctx context.Context) (v string, err error) {
  22247. if !m.op.Is(OpUpdateOne) {
  22248. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  22249. }
  22250. if m.id == nil || m.oldValue == nil {
  22251. return v, errors.New("OldCc requires an ID field in the mutation")
  22252. }
  22253. oldValue, err := m.oldValue(ctx)
  22254. if err != nil {
  22255. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  22256. }
  22257. return oldValue.Cc, nil
  22258. }
  22259. // ResetCc resets all changes to the "cc" field.
  22260. func (m *MsgMutation) ResetCc() {
  22261. m.cc = nil
  22262. }
  22263. // SetPhone sets the "phone" field.
  22264. func (m *MsgMutation) SetPhone(s string) {
  22265. m.phone = &s
  22266. }
  22267. // Phone returns the value of the "phone" field in the mutation.
  22268. func (m *MsgMutation) Phone() (r string, exists bool) {
  22269. v := m.phone
  22270. if v == nil {
  22271. return
  22272. }
  22273. return *v, true
  22274. }
  22275. // OldPhone returns the old "phone" field's value of the Msg entity.
  22276. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22277. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22278. func (m *MsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  22279. if !m.op.Is(OpUpdateOne) {
  22280. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  22281. }
  22282. if m.id == nil || m.oldValue == nil {
  22283. return v, errors.New("OldPhone requires an ID field in the mutation")
  22284. }
  22285. oldValue, err := m.oldValue(ctx)
  22286. if err != nil {
  22287. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  22288. }
  22289. return oldValue.Phone, nil
  22290. }
  22291. // ResetPhone resets all changes to the "phone" field.
  22292. func (m *MsgMutation) ResetPhone() {
  22293. m.phone = nil
  22294. }
  22295. // Where appends a list predicates to the MsgMutation builder.
  22296. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  22297. m.predicates = append(m.predicates, ps...)
  22298. }
  22299. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  22300. // users can use type-assertion to append predicates that do not depend on any generated package.
  22301. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  22302. p := make([]predicate.Msg, len(ps))
  22303. for i := range ps {
  22304. p[i] = ps[i]
  22305. }
  22306. m.Where(p...)
  22307. }
  22308. // Op returns the operation name.
  22309. func (m *MsgMutation) Op() Op {
  22310. return m.op
  22311. }
  22312. // SetOp allows setting the mutation operation.
  22313. func (m *MsgMutation) SetOp(op Op) {
  22314. m.op = op
  22315. }
  22316. // Type returns the node type of this mutation (Msg).
  22317. func (m *MsgMutation) Type() string {
  22318. return m.typ
  22319. }
  22320. // Fields returns all fields that were changed during this mutation. Note that in
  22321. // order to get all numeric fields that were incremented/decremented, call
  22322. // AddedFields().
  22323. func (m *MsgMutation) Fields() []string {
  22324. fields := make([]string, 0, 11)
  22325. if m.created_at != nil {
  22326. fields = append(fields, msg.FieldCreatedAt)
  22327. }
  22328. if m.updated_at != nil {
  22329. fields = append(fields, msg.FieldUpdatedAt)
  22330. }
  22331. if m.deleted_at != nil {
  22332. fields = append(fields, msg.FieldDeletedAt)
  22333. }
  22334. if m.status != nil {
  22335. fields = append(fields, msg.FieldStatus)
  22336. }
  22337. if m.fromwxid != nil {
  22338. fields = append(fields, msg.FieldFromwxid)
  22339. }
  22340. if m.toid != nil {
  22341. fields = append(fields, msg.FieldToid)
  22342. }
  22343. if m.msgtype != nil {
  22344. fields = append(fields, msg.FieldMsgtype)
  22345. }
  22346. if m.msg != nil {
  22347. fields = append(fields, msg.FieldMsg)
  22348. }
  22349. if m.batch_no != nil {
  22350. fields = append(fields, msg.FieldBatchNo)
  22351. }
  22352. if m.cc != nil {
  22353. fields = append(fields, msg.FieldCc)
  22354. }
  22355. if m.phone != nil {
  22356. fields = append(fields, msg.FieldPhone)
  22357. }
  22358. return fields
  22359. }
  22360. // Field returns the value of a field with the given name. The second boolean
  22361. // return value indicates that this field was not set, or was not defined in the
  22362. // schema.
  22363. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  22364. switch name {
  22365. case msg.FieldCreatedAt:
  22366. return m.CreatedAt()
  22367. case msg.FieldUpdatedAt:
  22368. return m.UpdatedAt()
  22369. case msg.FieldDeletedAt:
  22370. return m.DeletedAt()
  22371. case msg.FieldStatus:
  22372. return m.Status()
  22373. case msg.FieldFromwxid:
  22374. return m.Fromwxid()
  22375. case msg.FieldToid:
  22376. return m.Toid()
  22377. case msg.FieldMsgtype:
  22378. return m.Msgtype()
  22379. case msg.FieldMsg:
  22380. return m.Msg()
  22381. case msg.FieldBatchNo:
  22382. return m.BatchNo()
  22383. case msg.FieldCc:
  22384. return m.Cc()
  22385. case msg.FieldPhone:
  22386. return m.Phone()
  22387. }
  22388. return nil, false
  22389. }
  22390. // OldField returns the old value of the field from the database. An error is
  22391. // returned if the mutation operation is not UpdateOne, or the query to the
  22392. // database failed.
  22393. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22394. switch name {
  22395. case msg.FieldCreatedAt:
  22396. return m.OldCreatedAt(ctx)
  22397. case msg.FieldUpdatedAt:
  22398. return m.OldUpdatedAt(ctx)
  22399. case msg.FieldDeletedAt:
  22400. return m.OldDeletedAt(ctx)
  22401. case msg.FieldStatus:
  22402. return m.OldStatus(ctx)
  22403. case msg.FieldFromwxid:
  22404. return m.OldFromwxid(ctx)
  22405. case msg.FieldToid:
  22406. return m.OldToid(ctx)
  22407. case msg.FieldMsgtype:
  22408. return m.OldMsgtype(ctx)
  22409. case msg.FieldMsg:
  22410. return m.OldMsg(ctx)
  22411. case msg.FieldBatchNo:
  22412. return m.OldBatchNo(ctx)
  22413. case msg.FieldCc:
  22414. return m.OldCc(ctx)
  22415. case msg.FieldPhone:
  22416. return m.OldPhone(ctx)
  22417. }
  22418. return nil, fmt.Errorf("unknown Msg field %s", name)
  22419. }
  22420. // SetField sets the value of a field with the given name. It returns an error if
  22421. // the field is not defined in the schema, or if the type mismatched the field
  22422. // type.
  22423. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  22424. switch name {
  22425. case msg.FieldCreatedAt:
  22426. v, ok := value.(time.Time)
  22427. if !ok {
  22428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22429. }
  22430. m.SetCreatedAt(v)
  22431. return nil
  22432. case msg.FieldUpdatedAt:
  22433. v, ok := value.(time.Time)
  22434. if !ok {
  22435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22436. }
  22437. m.SetUpdatedAt(v)
  22438. return nil
  22439. case msg.FieldDeletedAt:
  22440. v, ok := value.(time.Time)
  22441. if !ok {
  22442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22443. }
  22444. m.SetDeletedAt(v)
  22445. return nil
  22446. case msg.FieldStatus:
  22447. v, ok := value.(uint8)
  22448. if !ok {
  22449. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22450. }
  22451. m.SetStatus(v)
  22452. return nil
  22453. case msg.FieldFromwxid:
  22454. v, ok := value.(string)
  22455. if !ok {
  22456. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22457. }
  22458. m.SetFromwxid(v)
  22459. return nil
  22460. case msg.FieldToid:
  22461. v, ok := value.(string)
  22462. if !ok {
  22463. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22464. }
  22465. m.SetToid(v)
  22466. return nil
  22467. case msg.FieldMsgtype:
  22468. v, ok := value.(int32)
  22469. if !ok {
  22470. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22471. }
  22472. m.SetMsgtype(v)
  22473. return nil
  22474. case msg.FieldMsg:
  22475. v, ok := value.(string)
  22476. if !ok {
  22477. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22478. }
  22479. m.SetMsg(v)
  22480. return nil
  22481. case msg.FieldBatchNo:
  22482. v, ok := value.(string)
  22483. if !ok {
  22484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22485. }
  22486. m.SetBatchNo(v)
  22487. return nil
  22488. case msg.FieldCc:
  22489. v, ok := value.(string)
  22490. if !ok {
  22491. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22492. }
  22493. m.SetCc(v)
  22494. return nil
  22495. case msg.FieldPhone:
  22496. v, ok := value.(string)
  22497. if !ok {
  22498. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22499. }
  22500. m.SetPhone(v)
  22501. return nil
  22502. }
  22503. return fmt.Errorf("unknown Msg field %s", name)
  22504. }
  22505. // AddedFields returns all numeric fields that were incremented/decremented during
  22506. // this mutation.
  22507. func (m *MsgMutation) AddedFields() []string {
  22508. var fields []string
  22509. if m.addstatus != nil {
  22510. fields = append(fields, msg.FieldStatus)
  22511. }
  22512. if m.addmsgtype != nil {
  22513. fields = append(fields, msg.FieldMsgtype)
  22514. }
  22515. return fields
  22516. }
  22517. // AddedField returns the numeric value that was incremented/decremented on a field
  22518. // with the given name. The second boolean return value indicates that this field
  22519. // was not set, or was not defined in the schema.
  22520. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  22521. switch name {
  22522. case msg.FieldStatus:
  22523. return m.AddedStatus()
  22524. case msg.FieldMsgtype:
  22525. return m.AddedMsgtype()
  22526. }
  22527. return nil, false
  22528. }
  22529. // AddField adds the value to the field with the given name. It returns an error if
  22530. // the field is not defined in the schema, or if the type mismatched the field
  22531. // type.
  22532. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  22533. switch name {
  22534. case msg.FieldStatus:
  22535. v, ok := value.(int8)
  22536. if !ok {
  22537. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22538. }
  22539. m.AddStatus(v)
  22540. return nil
  22541. case msg.FieldMsgtype:
  22542. v, ok := value.(int32)
  22543. if !ok {
  22544. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22545. }
  22546. m.AddMsgtype(v)
  22547. return nil
  22548. }
  22549. return fmt.Errorf("unknown Msg numeric field %s", name)
  22550. }
  22551. // ClearedFields returns all nullable fields that were cleared during this
  22552. // mutation.
  22553. func (m *MsgMutation) ClearedFields() []string {
  22554. var fields []string
  22555. if m.FieldCleared(msg.FieldDeletedAt) {
  22556. fields = append(fields, msg.FieldDeletedAt)
  22557. }
  22558. if m.FieldCleared(msg.FieldStatus) {
  22559. fields = append(fields, msg.FieldStatus)
  22560. }
  22561. if m.FieldCleared(msg.FieldFromwxid) {
  22562. fields = append(fields, msg.FieldFromwxid)
  22563. }
  22564. if m.FieldCleared(msg.FieldToid) {
  22565. fields = append(fields, msg.FieldToid)
  22566. }
  22567. if m.FieldCleared(msg.FieldMsgtype) {
  22568. fields = append(fields, msg.FieldMsgtype)
  22569. }
  22570. if m.FieldCleared(msg.FieldMsg) {
  22571. fields = append(fields, msg.FieldMsg)
  22572. }
  22573. if m.FieldCleared(msg.FieldBatchNo) {
  22574. fields = append(fields, msg.FieldBatchNo)
  22575. }
  22576. return fields
  22577. }
  22578. // FieldCleared returns a boolean indicating if a field with the given name was
  22579. // cleared in this mutation.
  22580. func (m *MsgMutation) FieldCleared(name string) bool {
  22581. _, ok := m.clearedFields[name]
  22582. return ok
  22583. }
  22584. // ClearField clears the value of the field with the given name. It returns an
  22585. // error if the field is not defined in the schema.
  22586. func (m *MsgMutation) ClearField(name string) error {
  22587. switch name {
  22588. case msg.FieldDeletedAt:
  22589. m.ClearDeletedAt()
  22590. return nil
  22591. case msg.FieldStatus:
  22592. m.ClearStatus()
  22593. return nil
  22594. case msg.FieldFromwxid:
  22595. m.ClearFromwxid()
  22596. return nil
  22597. case msg.FieldToid:
  22598. m.ClearToid()
  22599. return nil
  22600. case msg.FieldMsgtype:
  22601. m.ClearMsgtype()
  22602. return nil
  22603. case msg.FieldMsg:
  22604. m.ClearMsg()
  22605. return nil
  22606. case msg.FieldBatchNo:
  22607. m.ClearBatchNo()
  22608. return nil
  22609. }
  22610. return fmt.Errorf("unknown Msg nullable field %s", name)
  22611. }
  22612. // ResetField resets all changes in the mutation for the field with the given name.
  22613. // It returns an error if the field is not defined in the schema.
  22614. func (m *MsgMutation) ResetField(name string) error {
  22615. switch name {
  22616. case msg.FieldCreatedAt:
  22617. m.ResetCreatedAt()
  22618. return nil
  22619. case msg.FieldUpdatedAt:
  22620. m.ResetUpdatedAt()
  22621. return nil
  22622. case msg.FieldDeletedAt:
  22623. m.ResetDeletedAt()
  22624. return nil
  22625. case msg.FieldStatus:
  22626. m.ResetStatus()
  22627. return nil
  22628. case msg.FieldFromwxid:
  22629. m.ResetFromwxid()
  22630. return nil
  22631. case msg.FieldToid:
  22632. m.ResetToid()
  22633. return nil
  22634. case msg.FieldMsgtype:
  22635. m.ResetMsgtype()
  22636. return nil
  22637. case msg.FieldMsg:
  22638. m.ResetMsg()
  22639. return nil
  22640. case msg.FieldBatchNo:
  22641. m.ResetBatchNo()
  22642. return nil
  22643. case msg.FieldCc:
  22644. m.ResetCc()
  22645. return nil
  22646. case msg.FieldPhone:
  22647. m.ResetPhone()
  22648. return nil
  22649. }
  22650. return fmt.Errorf("unknown Msg field %s", name)
  22651. }
  22652. // AddedEdges returns all edge names that were set/added in this mutation.
  22653. func (m *MsgMutation) AddedEdges() []string {
  22654. edges := make([]string, 0, 0)
  22655. return edges
  22656. }
  22657. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22658. // name in this mutation.
  22659. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  22660. return nil
  22661. }
  22662. // RemovedEdges returns all edge names that were removed in this mutation.
  22663. func (m *MsgMutation) RemovedEdges() []string {
  22664. edges := make([]string, 0, 0)
  22665. return edges
  22666. }
  22667. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22668. // the given name in this mutation.
  22669. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  22670. return nil
  22671. }
  22672. // ClearedEdges returns all edge names that were cleared in this mutation.
  22673. func (m *MsgMutation) ClearedEdges() []string {
  22674. edges := make([]string, 0, 0)
  22675. return edges
  22676. }
  22677. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22678. // was cleared in this mutation.
  22679. func (m *MsgMutation) EdgeCleared(name string) bool {
  22680. return false
  22681. }
  22682. // ClearEdge clears the value of the edge with the given name. It returns an error
  22683. // if that edge is not defined in the schema.
  22684. func (m *MsgMutation) ClearEdge(name string) error {
  22685. return fmt.Errorf("unknown Msg unique edge %s", name)
  22686. }
  22687. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22688. // It returns an error if the edge is not defined in the schema.
  22689. func (m *MsgMutation) ResetEdge(name string) error {
  22690. return fmt.Errorf("unknown Msg edge %s", name)
  22691. }
  22692. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  22693. type PayRechargeMutation struct {
  22694. config
  22695. op Op
  22696. typ string
  22697. id *uint64
  22698. created_at *time.Time
  22699. updated_at *time.Time
  22700. deleted_at *time.Time
  22701. user_id *string
  22702. number *float32
  22703. addnumber *float32
  22704. status *int
  22705. addstatus *int
  22706. money *float32
  22707. addmoney *float32
  22708. out_trade_no *string
  22709. organization_id *uint64
  22710. addorganization_id *int64
  22711. clearedFields map[string]struct{}
  22712. done bool
  22713. oldValue func(context.Context) (*PayRecharge, error)
  22714. predicates []predicate.PayRecharge
  22715. }
  22716. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  22717. // payrechargeOption allows management of the mutation configuration using functional options.
  22718. type payrechargeOption func(*PayRechargeMutation)
  22719. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  22720. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  22721. m := &PayRechargeMutation{
  22722. config: c,
  22723. op: op,
  22724. typ: TypePayRecharge,
  22725. clearedFields: make(map[string]struct{}),
  22726. }
  22727. for _, opt := range opts {
  22728. opt(m)
  22729. }
  22730. return m
  22731. }
  22732. // withPayRechargeID sets the ID field of the mutation.
  22733. func withPayRechargeID(id uint64) payrechargeOption {
  22734. return func(m *PayRechargeMutation) {
  22735. var (
  22736. err error
  22737. once sync.Once
  22738. value *PayRecharge
  22739. )
  22740. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  22741. once.Do(func() {
  22742. if m.done {
  22743. err = errors.New("querying old values post mutation is not allowed")
  22744. } else {
  22745. value, err = m.Client().PayRecharge.Get(ctx, id)
  22746. }
  22747. })
  22748. return value, err
  22749. }
  22750. m.id = &id
  22751. }
  22752. }
  22753. // withPayRecharge sets the old PayRecharge of the mutation.
  22754. func withPayRecharge(node *PayRecharge) payrechargeOption {
  22755. return func(m *PayRechargeMutation) {
  22756. m.oldValue = func(context.Context) (*PayRecharge, error) {
  22757. return node, nil
  22758. }
  22759. m.id = &node.ID
  22760. }
  22761. }
  22762. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22763. // executed in a transaction (ent.Tx), a transactional client is returned.
  22764. func (m PayRechargeMutation) Client() *Client {
  22765. client := &Client{config: m.config}
  22766. client.init()
  22767. return client
  22768. }
  22769. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22770. // it returns an error otherwise.
  22771. func (m PayRechargeMutation) Tx() (*Tx, error) {
  22772. if _, ok := m.driver.(*txDriver); !ok {
  22773. return nil, errors.New("ent: mutation is not running in a transaction")
  22774. }
  22775. tx := &Tx{config: m.config}
  22776. tx.init()
  22777. return tx, nil
  22778. }
  22779. // SetID sets the value of the id field. Note that this
  22780. // operation is only accepted on creation of PayRecharge entities.
  22781. func (m *PayRechargeMutation) SetID(id uint64) {
  22782. m.id = &id
  22783. }
  22784. // ID returns the ID value in the mutation. Note that the ID is only available
  22785. // if it was provided to the builder or after it was returned from the database.
  22786. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  22787. if m.id == nil {
  22788. return
  22789. }
  22790. return *m.id, true
  22791. }
  22792. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22793. // That means, if the mutation is applied within a transaction with an isolation level such
  22794. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22795. // or updated by the mutation.
  22796. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  22797. switch {
  22798. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22799. id, exists := m.ID()
  22800. if exists {
  22801. return []uint64{id}, nil
  22802. }
  22803. fallthrough
  22804. case m.op.Is(OpUpdate | OpDelete):
  22805. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  22806. default:
  22807. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22808. }
  22809. }
  22810. // SetCreatedAt sets the "created_at" field.
  22811. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  22812. m.created_at = &t
  22813. }
  22814. // CreatedAt returns the value of the "created_at" field in the mutation.
  22815. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  22816. v := m.created_at
  22817. if v == nil {
  22818. return
  22819. }
  22820. return *v, true
  22821. }
  22822. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  22823. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  22824. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22825. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22826. if !m.op.Is(OpUpdateOne) {
  22827. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22828. }
  22829. if m.id == nil || m.oldValue == nil {
  22830. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22831. }
  22832. oldValue, err := m.oldValue(ctx)
  22833. if err != nil {
  22834. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22835. }
  22836. return oldValue.CreatedAt, nil
  22837. }
  22838. // ResetCreatedAt resets all changes to the "created_at" field.
  22839. func (m *PayRechargeMutation) ResetCreatedAt() {
  22840. m.created_at = nil
  22841. }
  22842. // SetUpdatedAt sets the "updated_at" field.
  22843. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  22844. m.updated_at = &t
  22845. }
  22846. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22847. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  22848. v := m.updated_at
  22849. if v == nil {
  22850. return
  22851. }
  22852. return *v, true
  22853. }
  22854. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  22855. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  22856. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22857. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22858. if !m.op.Is(OpUpdateOne) {
  22859. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22860. }
  22861. if m.id == nil || m.oldValue == nil {
  22862. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22863. }
  22864. oldValue, err := m.oldValue(ctx)
  22865. if err != nil {
  22866. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22867. }
  22868. return oldValue.UpdatedAt, nil
  22869. }
  22870. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22871. func (m *PayRechargeMutation) ResetUpdatedAt() {
  22872. m.updated_at = nil
  22873. }
  22874. // SetDeletedAt sets the "deleted_at" field.
  22875. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  22876. m.deleted_at = &t
  22877. }
  22878. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22879. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  22880. v := m.deleted_at
  22881. if v == nil {
  22882. return
  22883. }
  22884. return *v, true
  22885. }
  22886. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  22887. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  22888. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22889. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22890. if !m.op.Is(OpUpdateOne) {
  22891. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22892. }
  22893. if m.id == nil || m.oldValue == nil {
  22894. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22895. }
  22896. oldValue, err := m.oldValue(ctx)
  22897. if err != nil {
  22898. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22899. }
  22900. return oldValue.DeletedAt, nil
  22901. }
  22902. // ClearDeletedAt clears the value of the "deleted_at" field.
  22903. func (m *PayRechargeMutation) ClearDeletedAt() {
  22904. m.deleted_at = nil
  22905. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  22906. }
  22907. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22908. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  22909. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  22910. return ok
  22911. }
  22912. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22913. func (m *PayRechargeMutation) ResetDeletedAt() {
  22914. m.deleted_at = nil
  22915. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  22916. }
  22917. // SetUserID sets the "user_id" field.
  22918. func (m *PayRechargeMutation) SetUserID(s string) {
  22919. m.user_id = &s
  22920. }
  22921. // UserID returns the value of the "user_id" field in the mutation.
  22922. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  22923. v := m.user_id
  22924. if v == nil {
  22925. return
  22926. }
  22927. return *v, true
  22928. }
  22929. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  22930. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  22931. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22932. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  22933. if !m.op.Is(OpUpdateOne) {
  22934. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  22935. }
  22936. if m.id == nil || m.oldValue == nil {
  22937. return v, errors.New("OldUserID requires an ID field in the mutation")
  22938. }
  22939. oldValue, err := m.oldValue(ctx)
  22940. if err != nil {
  22941. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  22942. }
  22943. return oldValue.UserID, nil
  22944. }
  22945. // ResetUserID resets all changes to the "user_id" field.
  22946. func (m *PayRechargeMutation) ResetUserID() {
  22947. m.user_id = nil
  22948. }
  22949. // SetNumber sets the "number" field.
  22950. func (m *PayRechargeMutation) SetNumber(f float32) {
  22951. m.number = &f
  22952. m.addnumber = nil
  22953. }
  22954. // Number returns the value of the "number" field in the mutation.
  22955. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  22956. v := m.number
  22957. if v == nil {
  22958. return
  22959. }
  22960. return *v, true
  22961. }
  22962. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  22963. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  22964. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22965. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  22966. if !m.op.Is(OpUpdateOne) {
  22967. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  22968. }
  22969. if m.id == nil || m.oldValue == nil {
  22970. return v, errors.New("OldNumber requires an ID field in the mutation")
  22971. }
  22972. oldValue, err := m.oldValue(ctx)
  22973. if err != nil {
  22974. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  22975. }
  22976. return oldValue.Number, nil
  22977. }
  22978. // AddNumber adds f to the "number" field.
  22979. func (m *PayRechargeMutation) AddNumber(f float32) {
  22980. if m.addnumber != nil {
  22981. *m.addnumber += f
  22982. } else {
  22983. m.addnumber = &f
  22984. }
  22985. }
  22986. // AddedNumber returns the value that was added to the "number" field in this mutation.
  22987. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  22988. v := m.addnumber
  22989. if v == nil {
  22990. return
  22991. }
  22992. return *v, true
  22993. }
  22994. // ResetNumber resets all changes to the "number" field.
  22995. func (m *PayRechargeMutation) ResetNumber() {
  22996. m.number = nil
  22997. m.addnumber = nil
  22998. }
  22999. // SetStatus sets the "status" field.
  23000. func (m *PayRechargeMutation) SetStatus(i int) {
  23001. m.status = &i
  23002. m.addstatus = nil
  23003. }
  23004. // Status returns the value of the "status" field in the mutation.
  23005. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  23006. v := m.status
  23007. if v == nil {
  23008. return
  23009. }
  23010. return *v, true
  23011. }
  23012. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  23013. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  23014. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23015. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  23016. if !m.op.Is(OpUpdateOne) {
  23017. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23018. }
  23019. if m.id == nil || m.oldValue == nil {
  23020. return v, errors.New("OldStatus requires an ID field in the mutation")
  23021. }
  23022. oldValue, err := m.oldValue(ctx)
  23023. if err != nil {
  23024. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23025. }
  23026. return oldValue.Status, nil
  23027. }
  23028. // AddStatus adds i to the "status" field.
  23029. func (m *PayRechargeMutation) AddStatus(i int) {
  23030. if m.addstatus != nil {
  23031. *m.addstatus += i
  23032. } else {
  23033. m.addstatus = &i
  23034. }
  23035. }
  23036. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23037. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  23038. v := m.addstatus
  23039. if v == nil {
  23040. return
  23041. }
  23042. return *v, true
  23043. }
  23044. // ClearStatus clears the value of the "status" field.
  23045. func (m *PayRechargeMutation) ClearStatus() {
  23046. m.status = nil
  23047. m.addstatus = nil
  23048. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  23049. }
  23050. // StatusCleared returns if the "status" field was cleared in this mutation.
  23051. func (m *PayRechargeMutation) StatusCleared() bool {
  23052. _, ok := m.clearedFields[payrecharge.FieldStatus]
  23053. return ok
  23054. }
  23055. // ResetStatus resets all changes to the "status" field.
  23056. func (m *PayRechargeMutation) ResetStatus() {
  23057. m.status = nil
  23058. m.addstatus = nil
  23059. delete(m.clearedFields, payrecharge.FieldStatus)
  23060. }
  23061. // SetMoney sets the "money" field.
  23062. func (m *PayRechargeMutation) SetMoney(f float32) {
  23063. m.money = &f
  23064. m.addmoney = nil
  23065. }
  23066. // Money returns the value of the "money" field in the mutation.
  23067. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  23068. v := m.money
  23069. if v == nil {
  23070. return
  23071. }
  23072. return *v, true
  23073. }
  23074. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  23075. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  23076. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23077. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  23078. if !m.op.Is(OpUpdateOne) {
  23079. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  23080. }
  23081. if m.id == nil || m.oldValue == nil {
  23082. return v, errors.New("OldMoney requires an ID field in the mutation")
  23083. }
  23084. oldValue, err := m.oldValue(ctx)
  23085. if err != nil {
  23086. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  23087. }
  23088. return oldValue.Money, nil
  23089. }
  23090. // AddMoney adds f to the "money" field.
  23091. func (m *PayRechargeMutation) AddMoney(f float32) {
  23092. if m.addmoney != nil {
  23093. *m.addmoney += f
  23094. } else {
  23095. m.addmoney = &f
  23096. }
  23097. }
  23098. // AddedMoney returns the value that was added to the "money" field in this mutation.
  23099. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  23100. v := m.addmoney
  23101. if v == nil {
  23102. return
  23103. }
  23104. return *v, true
  23105. }
  23106. // ClearMoney clears the value of the "money" field.
  23107. func (m *PayRechargeMutation) ClearMoney() {
  23108. m.money = nil
  23109. m.addmoney = nil
  23110. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  23111. }
  23112. // MoneyCleared returns if the "money" field was cleared in this mutation.
  23113. func (m *PayRechargeMutation) MoneyCleared() bool {
  23114. _, ok := m.clearedFields[payrecharge.FieldMoney]
  23115. return ok
  23116. }
  23117. // ResetMoney resets all changes to the "money" field.
  23118. func (m *PayRechargeMutation) ResetMoney() {
  23119. m.money = nil
  23120. m.addmoney = nil
  23121. delete(m.clearedFields, payrecharge.FieldMoney)
  23122. }
  23123. // SetOutTradeNo sets the "out_trade_no" field.
  23124. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  23125. m.out_trade_no = &s
  23126. }
  23127. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  23128. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  23129. v := m.out_trade_no
  23130. if v == nil {
  23131. return
  23132. }
  23133. return *v, true
  23134. }
  23135. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  23136. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  23137. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23138. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  23139. if !m.op.Is(OpUpdateOne) {
  23140. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  23141. }
  23142. if m.id == nil || m.oldValue == nil {
  23143. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  23144. }
  23145. oldValue, err := m.oldValue(ctx)
  23146. if err != nil {
  23147. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  23148. }
  23149. return oldValue.OutTradeNo, nil
  23150. }
  23151. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  23152. func (m *PayRechargeMutation) ClearOutTradeNo() {
  23153. m.out_trade_no = nil
  23154. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  23155. }
  23156. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  23157. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  23158. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  23159. return ok
  23160. }
  23161. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  23162. func (m *PayRechargeMutation) ResetOutTradeNo() {
  23163. m.out_trade_no = nil
  23164. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  23165. }
  23166. // SetOrganizationID sets the "organization_id" field.
  23167. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  23168. m.organization_id = &u
  23169. m.addorganization_id = nil
  23170. }
  23171. // OrganizationID returns the value of the "organization_id" field in the mutation.
  23172. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  23173. v := m.organization_id
  23174. if v == nil {
  23175. return
  23176. }
  23177. return *v, true
  23178. }
  23179. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  23180. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  23181. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23182. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  23183. if !m.op.Is(OpUpdateOne) {
  23184. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  23185. }
  23186. if m.id == nil || m.oldValue == nil {
  23187. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  23188. }
  23189. oldValue, err := m.oldValue(ctx)
  23190. if err != nil {
  23191. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  23192. }
  23193. return oldValue.OrganizationID, nil
  23194. }
  23195. // AddOrganizationID adds u to the "organization_id" field.
  23196. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  23197. if m.addorganization_id != nil {
  23198. *m.addorganization_id += u
  23199. } else {
  23200. m.addorganization_id = &u
  23201. }
  23202. }
  23203. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  23204. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  23205. v := m.addorganization_id
  23206. if v == nil {
  23207. return
  23208. }
  23209. return *v, true
  23210. }
  23211. // ResetOrganizationID resets all changes to the "organization_id" field.
  23212. func (m *PayRechargeMutation) ResetOrganizationID() {
  23213. m.organization_id = nil
  23214. m.addorganization_id = nil
  23215. }
  23216. // Where appends a list predicates to the PayRechargeMutation builder.
  23217. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  23218. m.predicates = append(m.predicates, ps...)
  23219. }
  23220. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  23221. // users can use type-assertion to append predicates that do not depend on any generated package.
  23222. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  23223. p := make([]predicate.PayRecharge, len(ps))
  23224. for i := range ps {
  23225. p[i] = ps[i]
  23226. }
  23227. m.Where(p...)
  23228. }
  23229. // Op returns the operation name.
  23230. func (m *PayRechargeMutation) Op() Op {
  23231. return m.op
  23232. }
  23233. // SetOp allows setting the mutation operation.
  23234. func (m *PayRechargeMutation) SetOp(op Op) {
  23235. m.op = op
  23236. }
  23237. // Type returns the node type of this mutation (PayRecharge).
  23238. func (m *PayRechargeMutation) Type() string {
  23239. return m.typ
  23240. }
  23241. // Fields returns all fields that were changed during this mutation. Note that in
  23242. // order to get all numeric fields that were incremented/decremented, call
  23243. // AddedFields().
  23244. func (m *PayRechargeMutation) Fields() []string {
  23245. fields := make([]string, 0, 9)
  23246. if m.created_at != nil {
  23247. fields = append(fields, payrecharge.FieldCreatedAt)
  23248. }
  23249. if m.updated_at != nil {
  23250. fields = append(fields, payrecharge.FieldUpdatedAt)
  23251. }
  23252. if m.deleted_at != nil {
  23253. fields = append(fields, payrecharge.FieldDeletedAt)
  23254. }
  23255. if m.user_id != nil {
  23256. fields = append(fields, payrecharge.FieldUserID)
  23257. }
  23258. if m.number != nil {
  23259. fields = append(fields, payrecharge.FieldNumber)
  23260. }
  23261. if m.status != nil {
  23262. fields = append(fields, payrecharge.FieldStatus)
  23263. }
  23264. if m.money != nil {
  23265. fields = append(fields, payrecharge.FieldMoney)
  23266. }
  23267. if m.out_trade_no != nil {
  23268. fields = append(fields, payrecharge.FieldOutTradeNo)
  23269. }
  23270. if m.organization_id != nil {
  23271. fields = append(fields, payrecharge.FieldOrganizationID)
  23272. }
  23273. return fields
  23274. }
  23275. // Field returns the value of a field with the given name. The second boolean
  23276. // return value indicates that this field was not set, or was not defined in the
  23277. // schema.
  23278. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  23279. switch name {
  23280. case payrecharge.FieldCreatedAt:
  23281. return m.CreatedAt()
  23282. case payrecharge.FieldUpdatedAt:
  23283. return m.UpdatedAt()
  23284. case payrecharge.FieldDeletedAt:
  23285. return m.DeletedAt()
  23286. case payrecharge.FieldUserID:
  23287. return m.UserID()
  23288. case payrecharge.FieldNumber:
  23289. return m.Number()
  23290. case payrecharge.FieldStatus:
  23291. return m.Status()
  23292. case payrecharge.FieldMoney:
  23293. return m.Money()
  23294. case payrecharge.FieldOutTradeNo:
  23295. return m.OutTradeNo()
  23296. case payrecharge.FieldOrganizationID:
  23297. return m.OrganizationID()
  23298. }
  23299. return nil, false
  23300. }
  23301. // OldField returns the old value of the field from the database. An error is
  23302. // returned if the mutation operation is not UpdateOne, or the query to the
  23303. // database failed.
  23304. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23305. switch name {
  23306. case payrecharge.FieldCreatedAt:
  23307. return m.OldCreatedAt(ctx)
  23308. case payrecharge.FieldUpdatedAt:
  23309. return m.OldUpdatedAt(ctx)
  23310. case payrecharge.FieldDeletedAt:
  23311. return m.OldDeletedAt(ctx)
  23312. case payrecharge.FieldUserID:
  23313. return m.OldUserID(ctx)
  23314. case payrecharge.FieldNumber:
  23315. return m.OldNumber(ctx)
  23316. case payrecharge.FieldStatus:
  23317. return m.OldStatus(ctx)
  23318. case payrecharge.FieldMoney:
  23319. return m.OldMoney(ctx)
  23320. case payrecharge.FieldOutTradeNo:
  23321. return m.OldOutTradeNo(ctx)
  23322. case payrecharge.FieldOrganizationID:
  23323. return m.OldOrganizationID(ctx)
  23324. }
  23325. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  23326. }
  23327. // SetField sets the value of a field with the given name. It returns an error if
  23328. // the field is not defined in the schema, or if the type mismatched the field
  23329. // type.
  23330. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  23331. switch name {
  23332. case payrecharge.FieldCreatedAt:
  23333. v, ok := value.(time.Time)
  23334. if !ok {
  23335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23336. }
  23337. m.SetCreatedAt(v)
  23338. return nil
  23339. case payrecharge.FieldUpdatedAt:
  23340. v, ok := value.(time.Time)
  23341. if !ok {
  23342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23343. }
  23344. m.SetUpdatedAt(v)
  23345. return nil
  23346. case payrecharge.FieldDeletedAt:
  23347. v, ok := value.(time.Time)
  23348. if !ok {
  23349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23350. }
  23351. m.SetDeletedAt(v)
  23352. return nil
  23353. case payrecharge.FieldUserID:
  23354. v, ok := value.(string)
  23355. if !ok {
  23356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23357. }
  23358. m.SetUserID(v)
  23359. return nil
  23360. case payrecharge.FieldNumber:
  23361. v, ok := value.(float32)
  23362. if !ok {
  23363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23364. }
  23365. m.SetNumber(v)
  23366. return nil
  23367. case payrecharge.FieldStatus:
  23368. v, ok := value.(int)
  23369. if !ok {
  23370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23371. }
  23372. m.SetStatus(v)
  23373. return nil
  23374. case payrecharge.FieldMoney:
  23375. v, ok := value.(float32)
  23376. if !ok {
  23377. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23378. }
  23379. m.SetMoney(v)
  23380. return nil
  23381. case payrecharge.FieldOutTradeNo:
  23382. v, ok := value.(string)
  23383. if !ok {
  23384. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23385. }
  23386. m.SetOutTradeNo(v)
  23387. return nil
  23388. case payrecharge.FieldOrganizationID:
  23389. v, ok := value.(uint64)
  23390. if !ok {
  23391. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23392. }
  23393. m.SetOrganizationID(v)
  23394. return nil
  23395. }
  23396. return fmt.Errorf("unknown PayRecharge field %s", name)
  23397. }
  23398. // AddedFields returns all numeric fields that were incremented/decremented during
  23399. // this mutation.
  23400. func (m *PayRechargeMutation) AddedFields() []string {
  23401. var fields []string
  23402. if m.addnumber != nil {
  23403. fields = append(fields, payrecharge.FieldNumber)
  23404. }
  23405. if m.addstatus != nil {
  23406. fields = append(fields, payrecharge.FieldStatus)
  23407. }
  23408. if m.addmoney != nil {
  23409. fields = append(fields, payrecharge.FieldMoney)
  23410. }
  23411. if m.addorganization_id != nil {
  23412. fields = append(fields, payrecharge.FieldOrganizationID)
  23413. }
  23414. return fields
  23415. }
  23416. // AddedField returns the numeric value that was incremented/decremented on a field
  23417. // with the given name. The second boolean return value indicates that this field
  23418. // was not set, or was not defined in the schema.
  23419. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  23420. switch name {
  23421. case payrecharge.FieldNumber:
  23422. return m.AddedNumber()
  23423. case payrecharge.FieldStatus:
  23424. return m.AddedStatus()
  23425. case payrecharge.FieldMoney:
  23426. return m.AddedMoney()
  23427. case payrecharge.FieldOrganizationID:
  23428. return m.AddedOrganizationID()
  23429. }
  23430. return nil, false
  23431. }
  23432. // AddField adds the value to the field with the given name. It returns an error if
  23433. // the field is not defined in the schema, or if the type mismatched the field
  23434. // type.
  23435. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  23436. switch name {
  23437. case payrecharge.FieldNumber:
  23438. v, ok := value.(float32)
  23439. if !ok {
  23440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23441. }
  23442. m.AddNumber(v)
  23443. return nil
  23444. case payrecharge.FieldStatus:
  23445. v, ok := value.(int)
  23446. if !ok {
  23447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23448. }
  23449. m.AddStatus(v)
  23450. return nil
  23451. case payrecharge.FieldMoney:
  23452. v, ok := value.(float32)
  23453. if !ok {
  23454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23455. }
  23456. m.AddMoney(v)
  23457. return nil
  23458. case payrecharge.FieldOrganizationID:
  23459. v, ok := value.(int64)
  23460. if !ok {
  23461. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23462. }
  23463. m.AddOrganizationID(v)
  23464. return nil
  23465. }
  23466. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  23467. }
  23468. // ClearedFields returns all nullable fields that were cleared during this
  23469. // mutation.
  23470. func (m *PayRechargeMutation) ClearedFields() []string {
  23471. var fields []string
  23472. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  23473. fields = append(fields, payrecharge.FieldDeletedAt)
  23474. }
  23475. if m.FieldCleared(payrecharge.FieldStatus) {
  23476. fields = append(fields, payrecharge.FieldStatus)
  23477. }
  23478. if m.FieldCleared(payrecharge.FieldMoney) {
  23479. fields = append(fields, payrecharge.FieldMoney)
  23480. }
  23481. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  23482. fields = append(fields, payrecharge.FieldOutTradeNo)
  23483. }
  23484. return fields
  23485. }
  23486. // FieldCleared returns a boolean indicating if a field with the given name was
  23487. // cleared in this mutation.
  23488. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  23489. _, ok := m.clearedFields[name]
  23490. return ok
  23491. }
  23492. // ClearField clears the value of the field with the given name. It returns an
  23493. // error if the field is not defined in the schema.
  23494. func (m *PayRechargeMutation) ClearField(name string) error {
  23495. switch name {
  23496. case payrecharge.FieldDeletedAt:
  23497. m.ClearDeletedAt()
  23498. return nil
  23499. case payrecharge.FieldStatus:
  23500. m.ClearStatus()
  23501. return nil
  23502. case payrecharge.FieldMoney:
  23503. m.ClearMoney()
  23504. return nil
  23505. case payrecharge.FieldOutTradeNo:
  23506. m.ClearOutTradeNo()
  23507. return nil
  23508. }
  23509. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  23510. }
  23511. // ResetField resets all changes in the mutation for the field with the given name.
  23512. // It returns an error if the field is not defined in the schema.
  23513. func (m *PayRechargeMutation) ResetField(name string) error {
  23514. switch name {
  23515. case payrecharge.FieldCreatedAt:
  23516. m.ResetCreatedAt()
  23517. return nil
  23518. case payrecharge.FieldUpdatedAt:
  23519. m.ResetUpdatedAt()
  23520. return nil
  23521. case payrecharge.FieldDeletedAt:
  23522. m.ResetDeletedAt()
  23523. return nil
  23524. case payrecharge.FieldUserID:
  23525. m.ResetUserID()
  23526. return nil
  23527. case payrecharge.FieldNumber:
  23528. m.ResetNumber()
  23529. return nil
  23530. case payrecharge.FieldStatus:
  23531. m.ResetStatus()
  23532. return nil
  23533. case payrecharge.FieldMoney:
  23534. m.ResetMoney()
  23535. return nil
  23536. case payrecharge.FieldOutTradeNo:
  23537. m.ResetOutTradeNo()
  23538. return nil
  23539. case payrecharge.FieldOrganizationID:
  23540. m.ResetOrganizationID()
  23541. return nil
  23542. }
  23543. return fmt.Errorf("unknown PayRecharge field %s", name)
  23544. }
  23545. // AddedEdges returns all edge names that were set/added in this mutation.
  23546. func (m *PayRechargeMutation) AddedEdges() []string {
  23547. edges := make([]string, 0, 0)
  23548. return edges
  23549. }
  23550. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23551. // name in this mutation.
  23552. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  23553. return nil
  23554. }
  23555. // RemovedEdges returns all edge names that were removed in this mutation.
  23556. func (m *PayRechargeMutation) RemovedEdges() []string {
  23557. edges := make([]string, 0, 0)
  23558. return edges
  23559. }
  23560. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23561. // the given name in this mutation.
  23562. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  23563. return nil
  23564. }
  23565. // ClearedEdges returns all edge names that were cleared in this mutation.
  23566. func (m *PayRechargeMutation) ClearedEdges() []string {
  23567. edges := make([]string, 0, 0)
  23568. return edges
  23569. }
  23570. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23571. // was cleared in this mutation.
  23572. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  23573. return false
  23574. }
  23575. // ClearEdge clears the value of the edge with the given name. It returns an error
  23576. // if that edge is not defined in the schema.
  23577. func (m *PayRechargeMutation) ClearEdge(name string) error {
  23578. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  23579. }
  23580. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23581. // It returns an error if the edge is not defined in the schema.
  23582. func (m *PayRechargeMutation) ResetEdge(name string) error {
  23583. return fmt.Errorf("unknown PayRecharge edge %s", name)
  23584. }
  23585. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  23586. type ServerMutation struct {
  23587. config
  23588. op Op
  23589. typ string
  23590. id *uint64
  23591. created_at *time.Time
  23592. updated_at *time.Time
  23593. status *uint8
  23594. addstatus *int8
  23595. deleted_at *time.Time
  23596. name *string
  23597. public_ip *string
  23598. private_ip *string
  23599. admin_port *string
  23600. clearedFields map[string]struct{}
  23601. wxs map[uint64]struct{}
  23602. removedwxs map[uint64]struct{}
  23603. clearedwxs bool
  23604. done bool
  23605. oldValue func(context.Context) (*Server, error)
  23606. predicates []predicate.Server
  23607. }
  23608. var _ ent.Mutation = (*ServerMutation)(nil)
  23609. // serverOption allows management of the mutation configuration using functional options.
  23610. type serverOption func(*ServerMutation)
  23611. // newServerMutation creates new mutation for the Server entity.
  23612. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  23613. m := &ServerMutation{
  23614. config: c,
  23615. op: op,
  23616. typ: TypeServer,
  23617. clearedFields: make(map[string]struct{}),
  23618. }
  23619. for _, opt := range opts {
  23620. opt(m)
  23621. }
  23622. return m
  23623. }
  23624. // withServerID sets the ID field of the mutation.
  23625. func withServerID(id uint64) serverOption {
  23626. return func(m *ServerMutation) {
  23627. var (
  23628. err error
  23629. once sync.Once
  23630. value *Server
  23631. )
  23632. m.oldValue = func(ctx context.Context) (*Server, error) {
  23633. once.Do(func() {
  23634. if m.done {
  23635. err = errors.New("querying old values post mutation is not allowed")
  23636. } else {
  23637. value, err = m.Client().Server.Get(ctx, id)
  23638. }
  23639. })
  23640. return value, err
  23641. }
  23642. m.id = &id
  23643. }
  23644. }
  23645. // withServer sets the old Server of the mutation.
  23646. func withServer(node *Server) serverOption {
  23647. return func(m *ServerMutation) {
  23648. m.oldValue = func(context.Context) (*Server, error) {
  23649. return node, nil
  23650. }
  23651. m.id = &node.ID
  23652. }
  23653. }
  23654. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23655. // executed in a transaction (ent.Tx), a transactional client is returned.
  23656. func (m ServerMutation) Client() *Client {
  23657. client := &Client{config: m.config}
  23658. client.init()
  23659. return client
  23660. }
  23661. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23662. // it returns an error otherwise.
  23663. func (m ServerMutation) Tx() (*Tx, error) {
  23664. if _, ok := m.driver.(*txDriver); !ok {
  23665. return nil, errors.New("ent: mutation is not running in a transaction")
  23666. }
  23667. tx := &Tx{config: m.config}
  23668. tx.init()
  23669. return tx, nil
  23670. }
  23671. // SetID sets the value of the id field. Note that this
  23672. // operation is only accepted on creation of Server entities.
  23673. func (m *ServerMutation) SetID(id uint64) {
  23674. m.id = &id
  23675. }
  23676. // ID returns the ID value in the mutation. Note that the ID is only available
  23677. // if it was provided to the builder or after it was returned from the database.
  23678. func (m *ServerMutation) ID() (id uint64, exists bool) {
  23679. if m.id == nil {
  23680. return
  23681. }
  23682. return *m.id, true
  23683. }
  23684. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23685. // That means, if the mutation is applied within a transaction with an isolation level such
  23686. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23687. // or updated by the mutation.
  23688. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  23689. switch {
  23690. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23691. id, exists := m.ID()
  23692. if exists {
  23693. return []uint64{id}, nil
  23694. }
  23695. fallthrough
  23696. case m.op.Is(OpUpdate | OpDelete):
  23697. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  23698. default:
  23699. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23700. }
  23701. }
  23702. // SetCreatedAt sets the "created_at" field.
  23703. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  23704. m.created_at = &t
  23705. }
  23706. // CreatedAt returns the value of the "created_at" field in the mutation.
  23707. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  23708. v := m.created_at
  23709. if v == nil {
  23710. return
  23711. }
  23712. return *v, true
  23713. }
  23714. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  23715. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  23716. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23717. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23718. if !m.op.Is(OpUpdateOne) {
  23719. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23720. }
  23721. if m.id == nil || m.oldValue == nil {
  23722. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23723. }
  23724. oldValue, err := m.oldValue(ctx)
  23725. if err != nil {
  23726. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23727. }
  23728. return oldValue.CreatedAt, nil
  23729. }
  23730. // ResetCreatedAt resets all changes to the "created_at" field.
  23731. func (m *ServerMutation) ResetCreatedAt() {
  23732. m.created_at = nil
  23733. }
  23734. // SetUpdatedAt sets the "updated_at" field.
  23735. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  23736. m.updated_at = &t
  23737. }
  23738. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23739. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  23740. v := m.updated_at
  23741. if v == nil {
  23742. return
  23743. }
  23744. return *v, true
  23745. }
  23746. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  23747. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  23748. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23749. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23750. if !m.op.Is(OpUpdateOne) {
  23751. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23752. }
  23753. if m.id == nil || m.oldValue == nil {
  23754. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23755. }
  23756. oldValue, err := m.oldValue(ctx)
  23757. if err != nil {
  23758. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23759. }
  23760. return oldValue.UpdatedAt, nil
  23761. }
  23762. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23763. func (m *ServerMutation) ResetUpdatedAt() {
  23764. m.updated_at = nil
  23765. }
  23766. // SetStatus sets the "status" field.
  23767. func (m *ServerMutation) SetStatus(u uint8) {
  23768. m.status = &u
  23769. m.addstatus = nil
  23770. }
  23771. // Status returns the value of the "status" field in the mutation.
  23772. func (m *ServerMutation) Status() (r uint8, exists bool) {
  23773. v := m.status
  23774. if v == nil {
  23775. return
  23776. }
  23777. return *v, true
  23778. }
  23779. // OldStatus returns the old "status" field's value of the Server entity.
  23780. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  23781. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23782. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23783. if !m.op.Is(OpUpdateOne) {
  23784. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23785. }
  23786. if m.id == nil || m.oldValue == nil {
  23787. return v, errors.New("OldStatus requires an ID field in the mutation")
  23788. }
  23789. oldValue, err := m.oldValue(ctx)
  23790. if err != nil {
  23791. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23792. }
  23793. return oldValue.Status, nil
  23794. }
  23795. // AddStatus adds u to the "status" field.
  23796. func (m *ServerMutation) AddStatus(u int8) {
  23797. if m.addstatus != nil {
  23798. *m.addstatus += u
  23799. } else {
  23800. m.addstatus = &u
  23801. }
  23802. }
  23803. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23804. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  23805. v := m.addstatus
  23806. if v == nil {
  23807. return
  23808. }
  23809. return *v, true
  23810. }
  23811. // ClearStatus clears the value of the "status" field.
  23812. func (m *ServerMutation) ClearStatus() {
  23813. m.status = nil
  23814. m.addstatus = nil
  23815. m.clearedFields[server.FieldStatus] = struct{}{}
  23816. }
  23817. // StatusCleared returns if the "status" field was cleared in this mutation.
  23818. func (m *ServerMutation) StatusCleared() bool {
  23819. _, ok := m.clearedFields[server.FieldStatus]
  23820. return ok
  23821. }
  23822. // ResetStatus resets all changes to the "status" field.
  23823. func (m *ServerMutation) ResetStatus() {
  23824. m.status = nil
  23825. m.addstatus = nil
  23826. delete(m.clearedFields, server.FieldStatus)
  23827. }
  23828. // SetDeletedAt sets the "deleted_at" field.
  23829. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  23830. m.deleted_at = &t
  23831. }
  23832. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23833. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  23834. v := m.deleted_at
  23835. if v == nil {
  23836. return
  23837. }
  23838. return *v, true
  23839. }
  23840. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  23841. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  23842. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23843. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23844. if !m.op.Is(OpUpdateOne) {
  23845. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23846. }
  23847. if m.id == nil || m.oldValue == nil {
  23848. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23849. }
  23850. oldValue, err := m.oldValue(ctx)
  23851. if err != nil {
  23852. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23853. }
  23854. return oldValue.DeletedAt, nil
  23855. }
  23856. // ClearDeletedAt clears the value of the "deleted_at" field.
  23857. func (m *ServerMutation) ClearDeletedAt() {
  23858. m.deleted_at = nil
  23859. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  23860. }
  23861. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23862. func (m *ServerMutation) DeletedAtCleared() bool {
  23863. _, ok := m.clearedFields[server.FieldDeletedAt]
  23864. return ok
  23865. }
  23866. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23867. func (m *ServerMutation) ResetDeletedAt() {
  23868. m.deleted_at = nil
  23869. delete(m.clearedFields, server.FieldDeletedAt)
  23870. }
  23871. // SetName sets the "name" field.
  23872. func (m *ServerMutation) SetName(s string) {
  23873. m.name = &s
  23874. }
  23875. // Name returns the value of the "name" field in the mutation.
  23876. func (m *ServerMutation) Name() (r string, exists bool) {
  23877. v := m.name
  23878. if v == nil {
  23879. return
  23880. }
  23881. return *v, true
  23882. }
  23883. // OldName returns the old "name" field's value of the Server entity.
  23884. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  23885. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23886. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  23887. if !m.op.Is(OpUpdateOne) {
  23888. return v, errors.New("OldName is only allowed on UpdateOne operations")
  23889. }
  23890. if m.id == nil || m.oldValue == nil {
  23891. return v, errors.New("OldName requires an ID field in the mutation")
  23892. }
  23893. oldValue, err := m.oldValue(ctx)
  23894. if err != nil {
  23895. return v, fmt.Errorf("querying old value for OldName: %w", err)
  23896. }
  23897. return oldValue.Name, nil
  23898. }
  23899. // ResetName resets all changes to the "name" field.
  23900. func (m *ServerMutation) ResetName() {
  23901. m.name = nil
  23902. }
  23903. // SetPublicIP sets the "public_ip" field.
  23904. func (m *ServerMutation) SetPublicIP(s string) {
  23905. m.public_ip = &s
  23906. }
  23907. // PublicIP returns the value of the "public_ip" field in the mutation.
  23908. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  23909. v := m.public_ip
  23910. if v == nil {
  23911. return
  23912. }
  23913. return *v, true
  23914. }
  23915. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  23916. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  23917. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23918. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  23919. if !m.op.Is(OpUpdateOne) {
  23920. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  23921. }
  23922. if m.id == nil || m.oldValue == nil {
  23923. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  23924. }
  23925. oldValue, err := m.oldValue(ctx)
  23926. if err != nil {
  23927. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  23928. }
  23929. return oldValue.PublicIP, nil
  23930. }
  23931. // ResetPublicIP resets all changes to the "public_ip" field.
  23932. func (m *ServerMutation) ResetPublicIP() {
  23933. m.public_ip = nil
  23934. }
  23935. // SetPrivateIP sets the "private_ip" field.
  23936. func (m *ServerMutation) SetPrivateIP(s string) {
  23937. m.private_ip = &s
  23938. }
  23939. // PrivateIP returns the value of the "private_ip" field in the mutation.
  23940. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  23941. v := m.private_ip
  23942. if v == nil {
  23943. return
  23944. }
  23945. return *v, true
  23946. }
  23947. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  23948. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  23949. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23950. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  23951. if !m.op.Is(OpUpdateOne) {
  23952. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  23953. }
  23954. if m.id == nil || m.oldValue == nil {
  23955. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  23956. }
  23957. oldValue, err := m.oldValue(ctx)
  23958. if err != nil {
  23959. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  23960. }
  23961. return oldValue.PrivateIP, nil
  23962. }
  23963. // ResetPrivateIP resets all changes to the "private_ip" field.
  23964. func (m *ServerMutation) ResetPrivateIP() {
  23965. m.private_ip = nil
  23966. }
  23967. // SetAdminPort sets the "admin_port" field.
  23968. func (m *ServerMutation) SetAdminPort(s string) {
  23969. m.admin_port = &s
  23970. }
  23971. // AdminPort returns the value of the "admin_port" field in the mutation.
  23972. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  23973. v := m.admin_port
  23974. if v == nil {
  23975. return
  23976. }
  23977. return *v, true
  23978. }
  23979. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  23980. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  23981. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23982. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  23983. if !m.op.Is(OpUpdateOne) {
  23984. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  23985. }
  23986. if m.id == nil || m.oldValue == nil {
  23987. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  23988. }
  23989. oldValue, err := m.oldValue(ctx)
  23990. if err != nil {
  23991. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  23992. }
  23993. return oldValue.AdminPort, nil
  23994. }
  23995. // ResetAdminPort resets all changes to the "admin_port" field.
  23996. func (m *ServerMutation) ResetAdminPort() {
  23997. m.admin_port = nil
  23998. }
  23999. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  24000. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  24001. if m.wxs == nil {
  24002. m.wxs = make(map[uint64]struct{})
  24003. }
  24004. for i := range ids {
  24005. m.wxs[ids[i]] = struct{}{}
  24006. }
  24007. }
  24008. // ClearWxs clears the "wxs" edge to the Wx entity.
  24009. func (m *ServerMutation) ClearWxs() {
  24010. m.clearedwxs = true
  24011. }
  24012. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  24013. func (m *ServerMutation) WxsCleared() bool {
  24014. return m.clearedwxs
  24015. }
  24016. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  24017. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  24018. if m.removedwxs == nil {
  24019. m.removedwxs = make(map[uint64]struct{})
  24020. }
  24021. for i := range ids {
  24022. delete(m.wxs, ids[i])
  24023. m.removedwxs[ids[i]] = struct{}{}
  24024. }
  24025. }
  24026. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  24027. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  24028. for id := range m.removedwxs {
  24029. ids = append(ids, id)
  24030. }
  24031. return
  24032. }
  24033. // WxsIDs returns the "wxs" edge IDs in the mutation.
  24034. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  24035. for id := range m.wxs {
  24036. ids = append(ids, id)
  24037. }
  24038. return
  24039. }
  24040. // ResetWxs resets all changes to the "wxs" edge.
  24041. func (m *ServerMutation) ResetWxs() {
  24042. m.wxs = nil
  24043. m.clearedwxs = false
  24044. m.removedwxs = nil
  24045. }
  24046. // Where appends a list predicates to the ServerMutation builder.
  24047. func (m *ServerMutation) Where(ps ...predicate.Server) {
  24048. m.predicates = append(m.predicates, ps...)
  24049. }
  24050. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  24051. // users can use type-assertion to append predicates that do not depend on any generated package.
  24052. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  24053. p := make([]predicate.Server, len(ps))
  24054. for i := range ps {
  24055. p[i] = ps[i]
  24056. }
  24057. m.Where(p...)
  24058. }
  24059. // Op returns the operation name.
  24060. func (m *ServerMutation) Op() Op {
  24061. return m.op
  24062. }
  24063. // SetOp allows setting the mutation operation.
  24064. func (m *ServerMutation) SetOp(op Op) {
  24065. m.op = op
  24066. }
  24067. // Type returns the node type of this mutation (Server).
  24068. func (m *ServerMutation) Type() string {
  24069. return m.typ
  24070. }
  24071. // Fields returns all fields that were changed during this mutation. Note that in
  24072. // order to get all numeric fields that were incremented/decremented, call
  24073. // AddedFields().
  24074. func (m *ServerMutation) Fields() []string {
  24075. fields := make([]string, 0, 8)
  24076. if m.created_at != nil {
  24077. fields = append(fields, server.FieldCreatedAt)
  24078. }
  24079. if m.updated_at != nil {
  24080. fields = append(fields, server.FieldUpdatedAt)
  24081. }
  24082. if m.status != nil {
  24083. fields = append(fields, server.FieldStatus)
  24084. }
  24085. if m.deleted_at != nil {
  24086. fields = append(fields, server.FieldDeletedAt)
  24087. }
  24088. if m.name != nil {
  24089. fields = append(fields, server.FieldName)
  24090. }
  24091. if m.public_ip != nil {
  24092. fields = append(fields, server.FieldPublicIP)
  24093. }
  24094. if m.private_ip != nil {
  24095. fields = append(fields, server.FieldPrivateIP)
  24096. }
  24097. if m.admin_port != nil {
  24098. fields = append(fields, server.FieldAdminPort)
  24099. }
  24100. return fields
  24101. }
  24102. // Field returns the value of a field with the given name. The second boolean
  24103. // return value indicates that this field was not set, or was not defined in the
  24104. // schema.
  24105. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  24106. switch name {
  24107. case server.FieldCreatedAt:
  24108. return m.CreatedAt()
  24109. case server.FieldUpdatedAt:
  24110. return m.UpdatedAt()
  24111. case server.FieldStatus:
  24112. return m.Status()
  24113. case server.FieldDeletedAt:
  24114. return m.DeletedAt()
  24115. case server.FieldName:
  24116. return m.Name()
  24117. case server.FieldPublicIP:
  24118. return m.PublicIP()
  24119. case server.FieldPrivateIP:
  24120. return m.PrivateIP()
  24121. case server.FieldAdminPort:
  24122. return m.AdminPort()
  24123. }
  24124. return nil, false
  24125. }
  24126. // OldField returns the old value of the field from the database. An error is
  24127. // returned if the mutation operation is not UpdateOne, or the query to the
  24128. // database failed.
  24129. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24130. switch name {
  24131. case server.FieldCreatedAt:
  24132. return m.OldCreatedAt(ctx)
  24133. case server.FieldUpdatedAt:
  24134. return m.OldUpdatedAt(ctx)
  24135. case server.FieldStatus:
  24136. return m.OldStatus(ctx)
  24137. case server.FieldDeletedAt:
  24138. return m.OldDeletedAt(ctx)
  24139. case server.FieldName:
  24140. return m.OldName(ctx)
  24141. case server.FieldPublicIP:
  24142. return m.OldPublicIP(ctx)
  24143. case server.FieldPrivateIP:
  24144. return m.OldPrivateIP(ctx)
  24145. case server.FieldAdminPort:
  24146. return m.OldAdminPort(ctx)
  24147. }
  24148. return nil, fmt.Errorf("unknown Server field %s", name)
  24149. }
  24150. // SetField sets the value of a field with the given name. It returns an error if
  24151. // the field is not defined in the schema, or if the type mismatched the field
  24152. // type.
  24153. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  24154. switch name {
  24155. case server.FieldCreatedAt:
  24156. v, ok := value.(time.Time)
  24157. if !ok {
  24158. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24159. }
  24160. m.SetCreatedAt(v)
  24161. return nil
  24162. case server.FieldUpdatedAt:
  24163. v, ok := value.(time.Time)
  24164. if !ok {
  24165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24166. }
  24167. m.SetUpdatedAt(v)
  24168. return nil
  24169. case server.FieldStatus:
  24170. v, ok := value.(uint8)
  24171. if !ok {
  24172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24173. }
  24174. m.SetStatus(v)
  24175. return nil
  24176. case server.FieldDeletedAt:
  24177. v, ok := value.(time.Time)
  24178. if !ok {
  24179. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24180. }
  24181. m.SetDeletedAt(v)
  24182. return nil
  24183. case server.FieldName:
  24184. v, ok := value.(string)
  24185. if !ok {
  24186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24187. }
  24188. m.SetName(v)
  24189. return nil
  24190. case server.FieldPublicIP:
  24191. v, ok := value.(string)
  24192. if !ok {
  24193. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24194. }
  24195. m.SetPublicIP(v)
  24196. return nil
  24197. case server.FieldPrivateIP:
  24198. v, ok := value.(string)
  24199. if !ok {
  24200. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24201. }
  24202. m.SetPrivateIP(v)
  24203. return nil
  24204. case server.FieldAdminPort:
  24205. v, ok := value.(string)
  24206. if !ok {
  24207. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24208. }
  24209. m.SetAdminPort(v)
  24210. return nil
  24211. }
  24212. return fmt.Errorf("unknown Server field %s", name)
  24213. }
  24214. // AddedFields returns all numeric fields that were incremented/decremented during
  24215. // this mutation.
  24216. func (m *ServerMutation) AddedFields() []string {
  24217. var fields []string
  24218. if m.addstatus != nil {
  24219. fields = append(fields, server.FieldStatus)
  24220. }
  24221. return fields
  24222. }
  24223. // AddedField returns the numeric value that was incremented/decremented on a field
  24224. // with the given name. The second boolean return value indicates that this field
  24225. // was not set, or was not defined in the schema.
  24226. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  24227. switch name {
  24228. case server.FieldStatus:
  24229. return m.AddedStatus()
  24230. }
  24231. return nil, false
  24232. }
  24233. // AddField adds the value to the field with the given name. It returns an error if
  24234. // the field is not defined in the schema, or if the type mismatched the field
  24235. // type.
  24236. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  24237. switch name {
  24238. case server.FieldStatus:
  24239. v, ok := value.(int8)
  24240. if !ok {
  24241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24242. }
  24243. m.AddStatus(v)
  24244. return nil
  24245. }
  24246. return fmt.Errorf("unknown Server numeric field %s", name)
  24247. }
  24248. // ClearedFields returns all nullable fields that were cleared during this
  24249. // mutation.
  24250. func (m *ServerMutation) ClearedFields() []string {
  24251. var fields []string
  24252. if m.FieldCleared(server.FieldStatus) {
  24253. fields = append(fields, server.FieldStatus)
  24254. }
  24255. if m.FieldCleared(server.FieldDeletedAt) {
  24256. fields = append(fields, server.FieldDeletedAt)
  24257. }
  24258. return fields
  24259. }
  24260. // FieldCleared returns a boolean indicating if a field with the given name was
  24261. // cleared in this mutation.
  24262. func (m *ServerMutation) FieldCleared(name string) bool {
  24263. _, ok := m.clearedFields[name]
  24264. return ok
  24265. }
  24266. // ClearField clears the value of the field with the given name. It returns an
  24267. // error if the field is not defined in the schema.
  24268. func (m *ServerMutation) ClearField(name string) error {
  24269. switch name {
  24270. case server.FieldStatus:
  24271. m.ClearStatus()
  24272. return nil
  24273. case server.FieldDeletedAt:
  24274. m.ClearDeletedAt()
  24275. return nil
  24276. }
  24277. return fmt.Errorf("unknown Server nullable field %s", name)
  24278. }
  24279. // ResetField resets all changes in the mutation for the field with the given name.
  24280. // It returns an error if the field is not defined in the schema.
  24281. func (m *ServerMutation) ResetField(name string) error {
  24282. switch name {
  24283. case server.FieldCreatedAt:
  24284. m.ResetCreatedAt()
  24285. return nil
  24286. case server.FieldUpdatedAt:
  24287. m.ResetUpdatedAt()
  24288. return nil
  24289. case server.FieldStatus:
  24290. m.ResetStatus()
  24291. return nil
  24292. case server.FieldDeletedAt:
  24293. m.ResetDeletedAt()
  24294. return nil
  24295. case server.FieldName:
  24296. m.ResetName()
  24297. return nil
  24298. case server.FieldPublicIP:
  24299. m.ResetPublicIP()
  24300. return nil
  24301. case server.FieldPrivateIP:
  24302. m.ResetPrivateIP()
  24303. return nil
  24304. case server.FieldAdminPort:
  24305. m.ResetAdminPort()
  24306. return nil
  24307. }
  24308. return fmt.Errorf("unknown Server field %s", name)
  24309. }
  24310. // AddedEdges returns all edge names that were set/added in this mutation.
  24311. func (m *ServerMutation) AddedEdges() []string {
  24312. edges := make([]string, 0, 1)
  24313. if m.wxs != nil {
  24314. edges = append(edges, server.EdgeWxs)
  24315. }
  24316. return edges
  24317. }
  24318. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24319. // name in this mutation.
  24320. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  24321. switch name {
  24322. case server.EdgeWxs:
  24323. ids := make([]ent.Value, 0, len(m.wxs))
  24324. for id := range m.wxs {
  24325. ids = append(ids, id)
  24326. }
  24327. return ids
  24328. }
  24329. return nil
  24330. }
  24331. // RemovedEdges returns all edge names that were removed in this mutation.
  24332. func (m *ServerMutation) RemovedEdges() []string {
  24333. edges := make([]string, 0, 1)
  24334. if m.removedwxs != nil {
  24335. edges = append(edges, server.EdgeWxs)
  24336. }
  24337. return edges
  24338. }
  24339. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24340. // the given name in this mutation.
  24341. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  24342. switch name {
  24343. case server.EdgeWxs:
  24344. ids := make([]ent.Value, 0, len(m.removedwxs))
  24345. for id := range m.removedwxs {
  24346. ids = append(ids, id)
  24347. }
  24348. return ids
  24349. }
  24350. return nil
  24351. }
  24352. // ClearedEdges returns all edge names that were cleared in this mutation.
  24353. func (m *ServerMutation) ClearedEdges() []string {
  24354. edges := make([]string, 0, 1)
  24355. if m.clearedwxs {
  24356. edges = append(edges, server.EdgeWxs)
  24357. }
  24358. return edges
  24359. }
  24360. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24361. // was cleared in this mutation.
  24362. func (m *ServerMutation) EdgeCleared(name string) bool {
  24363. switch name {
  24364. case server.EdgeWxs:
  24365. return m.clearedwxs
  24366. }
  24367. return false
  24368. }
  24369. // ClearEdge clears the value of the edge with the given name. It returns an error
  24370. // if that edge is not defined in the schema.
  24371. func (m *ServerMutation) ClearEdge(name string) error {
  24372. switch name {
  24373. }
  24374. return fmt.Errorf("unknown Server unique edge %s", name)
  24375. }
  24376. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24377. // It returns an error if the edge is not defined in the schema.
  24378. func (m *ServerMutation) ResetEdge(name string) error {
  24379. switch name {
  24380. case server.EdgeWxs:
  24381. m.ResetWxs()
  24382. return nil
  24383. }
  24384. return fmt.Errorf("unknown Server edge %s", name)
  24385. }
  24386. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  24387. type SopNodeMutation struct {
  24388. config
  24389. op Op
  24390. typ string
  24391. id *uint64
  24392. created_at *time.Time
  24393. updated_at *time.Time
  24394. status *uint8
  24395. addstatus *int8
  24396. deleted_at *time.Time
  24397. parent_id *uint64
  24398. addparent_id *int64
  24399. name *string
  24400. condition_type *int
  24401. addcondition_type *int
  24402. condition_list *[]string
  24403. appendcondition_list []string
  24404. no_reply_condition *uint64
  24405. addno_reply_condition *int64
  24406. no_reply_unit *string
  24407. action_message *[]custom_types.Action
  24408. appendaction_message []custom_types.Action
  24409. action_label_add *[]uint64
  24410. appendaction_label_add []uint64
  24411. action_label_del *[]uint64
  24412. appendaction_label_del []uint64
  24413. action_forward **custom_types.ActionForward
  24414. clearedFields map[string]struct{}
  24415. sop_stage *uint64
  24416. clearedsop_stage bool
  24417. node_messages map[uint64]struct{}
  24418. removednode_messages map[uint64]struct{}
  24419. clearednode_messages bool
  24420. done bool
  24421. oldValue func(context.Context) (*SopNode, error)
  24422. predicates []predicate.SopNode
  24423. }
  24424. var _ ent.Mutation = (*SopNodeMutation)(nil)
  24425. // sopnodeOption allows management of the mutation configuration using functional options.
  24426. type sopnodeOption func(*SopNodeMutation)
  24427. // newSopNodeMutation creates new mutation for the SopNode entity.
  24428. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  24429. m := &SopNodeMutation{
  24430. config: c,
  24431. op: op,
  24432. typ: TypeSopNode,
  24433. clearedFields: make(map[string]struct{}),
  24434. }
  24435. for _, opt := range opts {
  24436. opt(m)
  24437. }
  24438. return m
  24439. }
  24440. // withSopNodeID sets the ID field of the mutation.
  24441. func withSopNodeID(id uint64) sopnodeOption {
  24442. return func(m *SopNodeMutation) {
  24443. var (
  24444. err error
  24445. once sync.Once
  24446. value *SopNode
  24447. )
  24448. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  24449. once.Do(func() {
  24450. if m.done {
  24451. err = errors.New("querying old values post mutation is not allowed")
  24452. } else {
  24453. value, err = m.Client().SopNode.Get(ctx, id)
  24454. }
  24455. })
  24456. return value, err
  24457. }
  24458. m.id = &id
  24459. }
  24460. }
  24461. // withSopNode sets the old SopNode of the mutation.
  24462. func withSopNode(node *SopNode) sopnodeOption {
  24463. return func(m *SopNodeMutation) {
  24464. m.oldValue = func(context.Context) (*SopNode, error) {
  24465. return node, nil
  24466. }
  24467. m.id = &node.ID
  24468. }
  24469. }
  24470. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24471. // executed in a transaction (ent.Tx), a transactional client is returned.
  24472. func (m SopNodeMutation) Client() *Client {
  24473. client := &Client{config: m.config}
  24474. client.init()
  24475. return client
  24476. }
  24477. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24478. // it returns an error otherwise.
  24479. func (m SopNodeMutation) Tx() (*Tx, error) {
  24480. if _, ok := m.driver.(*txDriver); !ok {
  24481. return nil, errors.New("ent: mutation is not running in a transaction")
  24482. }
  24483. tx := &Tx{config: m.config}
  24484. tx.init()
  24485. return tx, nil
  24486. }
  24487. // SetID sets the value of the id field. Note that this
  24488. // operation is only accepted on creation of SopNode entities.
  24489. func (m *SopNodeMutation) SetID(id uint64) {
  24490. m.id = &id
  24491. }
  24492. // ID returns the ID value in the mutation. Note that the ID is only available
  24493. // if it was provided to the builder or after it was returned from the database.
  24494. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  24495. if m.id == nil {
  24496. return
  24497. }
  24498. return *m.id, true
  24499. }
  24500. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24501. // That means, if the mutation is applied within a transaction with an isolation level such
  24502. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24503. // or updated by the mutation.
  24504. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  24505. switch {
  24506. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24507. id, exists := m.ID()
  24508. if exists {
  24509. return []uint64{id}, nil
  24510. }
  24511. fallthrough
  24512. case m.op.Is(OpUpdate | OpDelete):
  24513. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  24514. default:
  24515. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24516. }
  24517. }
  24518. // SetCreatedAt sets the "created_at" field.
  24519. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  24520. m.created_at = &t
  24521. }
  24522. // CreatedAt returns the value of the "created_at" field in the mutation.
  24523. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  24524. v := m.created_at
  24525. if v == nil {
  24526. return
  24527. }
  24528. return *v, true
  24529. }
  24530. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  24531. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24532. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24533. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24534. if !m.op.Is(OpUpdateOne) {
  24535. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24536. }
  24537. if m.id == nil || m.oldValue == nil {
  24538. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24539. }
  24540. oldValue, err := m.oldValue(ctx)
  24541. if err != nil {
  24542. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24543. }
  24544. return oldValue.CreatedAt, nil
  24545. }
  24546. // ResetCreatedAt resets all changes to the "created_at" field.
  24547. func (m *SopNodeMutation) ResetCreatedAt() {
  24548. m.created_at = nil
  24549. }
  24550. // SetUpdatedAt sets the "updated_at" field.
  24551. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  24552. m.updated_at = &t
  24553. }
  24554. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24555. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  24556. v := m.updated_at
  24557. if v == nil {
  24558. return
  24559. }
  24560. return *v, true
  24561. }
  24562. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  24563. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24565. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24566. if !m.op.Is(OpUpdateOne) {
  24567. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24568. }
  24569. if m.id == nil || m.oldValue == nil {
  24570. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24571. }
  24572. oldValue, err := m.oldValue(ctx)
  24573. if err != nil {
  24574. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24575. }
  24576. return oldValue.UpdatedAt, nil
  24577. }
  24578. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24579. func (m *SopNodeMutation) ResetUpdatedAt() {
  24580. m.updated_at = nil
  24581. }
  24582. // SetStatus sets the "status" field.
  24583. func (m *SopNodeMutation) SetStatus(u uint8) {
  24584. m.status = &u
  24585. m.addstatus = nil
  24586. }
  24587. // Status returns the value of the "status" field in the mutation.
  24588. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  24589. v := m.status
  24590. if v == nil {
  24591. return
  24592. }
  24593. return *v, true
  24594. }
  24595. // OldStatus returns the old "status" field's value of the SopNode entity.
  24596. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24597. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24598. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  24599. if !m.op.Is(OpUpdateOne) {
  24600. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  24601. }
  24602. if m.id == nil || m.oldValue == nil {
  24603. return v, errors.New("OldStatus requires an ID field in the mutation")
  24604. }
  24605. oldValue, err := m.oldValue(ctx)
  24606. if err != nil {
  24607. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  24608. }
  24609. return oldValue.Status, nil
  24610. }
  24611. // AddStatus adds u to the "status" field.
  24612. func (m *SopNodeMutation) AddStatus(u int8) {
  24613. if m.addstatus != nil {
  24614. *m.addstatus += u
  24615. } else {
  24616. m.addstatus = &u
  24617. }
  24618. }
  24619. // AddedStatus returns the value that was added to the "status" field in this mutation.
  24620. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  24621. v := m.addstatus
  24622. if v == nil {
  24623. return
  24624. }
  24625. return *v, true
  24626. }
  24627. // ClearStatus clears the value of the "status" field.
  24628. func (m *SopNodeMutation) ClearStatus() {
  24629. m.status = nil
  24630. m.addstatus = nil
  24631. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  24632. }
  24633. // StatusCleared returns if the "status" field was cleared in this mutation.
  24634. func (m *SopNodeMutation) StatusCleared() bool {
  24635. _, ok := m.clearedFields[sopnode.FieldStatus]
  24636. return ok
  24637. }
  24638. // ResetStatus resets all changes to the "status" field.
  24639. func (m *SopNodeMutation) ResetStatus() {
  24640. m.status = nil
  24641. m.addstatus = nil
  24642. delete(m.clearedFields, sopnode.FieldStatus)
  24643. }
  24644. // SetDeletedAt sets the "deleted_at" field.
  24645. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  24646. m.deleted_at = &t
  24647. }
  24648. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  24649. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  24650. v := m.deleted_at
  24651. if v == nil {
  24652. return
  24653. }
  24654. return *v, true
  24655. }
  24656. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  24657. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24658. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24659. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  24660. if !m.op.Is(OpUpdateOne) {
  24661. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  24662. }
  24663. if m.id == nil || m.oldValue == nil {
  24664. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  24665. }
  24666. oldValue, err := m.oldValue(ctx)
  24667. if err != nil {
  24668. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  24669. }
  24670. return oldValue.DeletedAt, nil
  24671. }
  24672. // ClearDeletedAt clears the value of the "deleted_at" field.
  24673. func (m *SopNodeMutation) ClearDeletedAt() {
  24674. m.deleted_at = nil
  24675. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  24676. }
  24677. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  24678. func (m *SopNodeMutation) DeletedAtCleared() bool {
  24679. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  24680. return ok
  24681. }
  24682. // ResetDeletedAt resets all changes to the "deleted_at" field.
  24683. func (m *SopNodeMutation) ResetDeletedAt() {
  24684. m.deleted_at = nil
  24685. delete(m.clearedFields, sopnode.FieldDeletedAt)
  24686. }
  24687. // SetStageID sets the "stage_id" field.
  24688. func (m *SopNodeMutation) SetStageID(u uint64) {
  24689. m.sop_stage = &u
  24690. }
  24691. // StageID returns the value of the "stage_id" field in the mutation.
  24692. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  24693. v := m.sop_stage
  24694. if v == nil {
  24695. return
  24696. }
  24697. return *v, true
  24698. }
  24699. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  24700. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24701. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24702. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  24703. if !m.op.Is(OpUpdateOne) {
  24704. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  24705. }
  24706. if m.id == nil || m.oldValue == nil {
  24707. return v, errors.New("OldStageID requires an ID field in the mutation")
  24708. }
  24709. oldValue, err := m.oldValue(ctx)
  24710. if err != nil {
  24711. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  24712. }
  24713. return oldValue.StageID, nil
  24714. }
  24715. // ResetStageID resets all changes to the "stage_id" field.
  24716. func (m *SopNodeMutation) ResetStageID() {
  24717. m.sop_stage = nil
  24718. }
  24719. // SetParentID sets the "parent_id" field.
  24720. func (m *SopNodeMutation) SetParentID(u uint64) {
  24721. m.parent_id = &u
  24722. m.addparent_id = nil
  24723. }
  24724. // ParentID returns the value of the "parent_id" field in the mutation.
  24725. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  24726. v := m.parent_id
  24727. if v == nil {
  24728. return
  24729. }
  24730. return *v, true
  24731. }
  24732. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  24733. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24734. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24735. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  24736. if !m.op.Is(OpUpdateOne) {
  24737. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  24738. }
  24739. if m.id == nil || m.oldValue == nil {
  24740. return v, errors.New("OldParentID requires an ID field in the mutation")
  24741. }
  24742. oldValue, err := m.oldValue(ctx)
  24743. if err != nil {
  24744. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  24745. }
  24746. return oldValue.ParentID, nil
  24747. }
  24748. // AddParentID adds u to the "parent_id" field.
  24749. func (m *SopNodeMutation) AddParentID(u int64) {
  24750. if m.addparent_id != nil {
  24751. *m.addparent_id += u
  24752. } else {
  24753. m.addparent_id = &u
  24754. }
  24755. }
  24756. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  24757. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  24758. v := m.addparent_id
  24759. if v == nil {
  24760. return
  24761. }
  24762. return *v, true
  24763. }
  24764. // ResetParentID resets all changes to the "parent_id" field.
  24765. func (m *SopNodeMutation) ResetParentID() {
  24766. m.parent_id = nil
  24767. m.addparent_id = nil
  24768. }
  24769. // SetName sets the "name" field.
  24770. func (m *SopNodeMutation) SetName(s string) {
  24771. m.name = &s
  24772. }
  24773. // Name returns the value of the "name" field in the mutation.
  24774. func (m *SopNodeMutation) Name() (r string, exists bool) {
  24775. v := m.name
  24776. if v == nil {
  24777. return
  24778. }
  24779. return *v, true
  24780. }
  24781. // OldName returns the old "name" field's value of the SopNode entity.
  24782. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24783. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24784. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  24785. if !m.op.Is(OpUpdateOne) {
  24786. return v, errors.New("OldName is only allowed on UpdateOne operations")
  24787. }
  24788. if m.id == nil || m.oldValue == nil {
  24789. return v, errors.New("OldName requires an ID field in the mutation")
  24790. }
  24791. oldValue, err := m.oldValue(ctx)
  24792. if err != nil {
  24793. return v, fmt.Errorf("querying old value for OldName: %w", err)
  24794. }
  24795. return oldValue.Name, nil
  24796. }
  24797. // ResetName resets all changes to the "name" field.
  24798. func (m *SopNodeMutation) ResetName() {
  24799. m.name = nil
  24800. }
  24801. // SetConditionType sets the "condition_type" field.
  24802. func (m *SopNodeMutation) SetConditionType(i int) {
  24803. m.condition_type = &i
  24804. m.addcondition_type = nil
  24805. }
  24806. // ConditionType returns the value of the "condition_type" field in the mutation.
  24807. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  24808. v := m.condition_type
  24809. if v == nil {
  24810. return
  24811. }
  24812. return *v, true
  24813. }
  24814. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  24815. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24816. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24817. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  24818. if !m.op.Is(OpUpdateOne) {
  24819. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  24820. }
  24821. if m.id == nil || m.oldValue == nil {
  24822. return v, errors.New("OldConditionType requires an ID field in the mutation")
  24823. }
  24824. oldValue, err := m.oldValue(ctx)
  24825. if err != nil {
  24826. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  24827. }
  24828. return oldValue.ConditionType, nil
  24829. }
  24830. // AddConditionType adds i to the "condition_type" field.
  24831. func (m *SopNodeMutation) AddConditionType(i int) {
  24832. if m.addcondition_type != nil {
  24833. *m.addcondition_type += i
  24834. } else {
  24835. m.addcondition_type = &i
  24836. }
  24837. }
  24838. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  24839. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  24840. v := m.addcondition_type
  24841. if v == nil {
  24842. return
  24843. }
  24844. return *v, true
  24845. }
  24846. // ResetConditionType resets all changes to the "condition_type" field.
  24847. func (m *SopNodeMutation) ResetConditionType() {
  24848. m.condition_type = nil
  24849. m.addcondition_type = nil
  24850. }
  24851. // SetConditionList sets the "condition_list" field.
  24852. func (m *SopNodeMutation) SetConditionList(s []string) {
  24853. m.condition_list = &s
  24854. m.appendcondition_list = nil
  24855. }
  24856. // ConditionList returns the value of the "condition_list" field in the mutation.
  24857. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  24858. v := m.condition_list
  24859. if v == nil {
  24860. return
  24861. }
  24862. return *v, true
  24863. }
  24864. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  24865. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24866. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24867. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  24868. if !m.op.Is(OpUpdateOne) {
  24869. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  24870. }
  24871. if m.id == nil || m.oldValue == nil {
  24872. return v, errors.New("OldConditionList requires an ID field in the mutation")
  24873. }
  24874. oldValue, err := m.oldValue(ctx)
  24875. if err != nil {
  24876. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  24877. }
  24878. return oldValue.ConditionList, nil
  24879. }
  24880. // AppendConditionList adds s to the "condition_list" field.
  24881. func (m *SopNodeMutation) AppendConditionList(s []string) {
  24882. m.appendcondition_list = append(m.appendcondition_list, s...)
  24883. }
  24884. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  24885. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  24886. if len(m.appendcondition_list) == 0 {
  24887. return nil, false
  24888. }
  24889. return m.appendcondition_list, true
  24890. }
  24891. // ClearConditionList clears the value of the "condition_list" field.
  24892. func (m *SopNodeMutation) ClearConditionList() {
  24893. m.condition_list = nil
  24894. m.appendcondition_list = nil
  24895. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  24896. }
  24897. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  24898. func (m *SopNodeMutation) ConditionListCleared() bool {
  24899. _, ok := m.clearedFields[sopnode.FieldConditionList]
  24900. return ok
  24901. }
  24902. // ResetConditionList resets all changes to the "condition_list" field.
  24903. func (m *SopNodeMutation) ResetConditionList() {
  24904. m.condition_list = nil
  24905. m.appendcondition_list = nil
  24906. delete(m.clearedFields, sopnode.FieldConditionList)
  24907. }
  24908. // SetNoReplyCondition sets the "no_reply_condition" field.
  24909. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  24910. m.no_reply_condition = &u
  24911. m.addno_reply_condition = nil
  24912. }
  24913. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  24914. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  24915. v := m.no_reply_condition
  24916. if v == nil {
  24917. return
  24918. }
  24919. return *v, true
  24920. }
  24921. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  24922. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24923. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24924. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  24925. if !m.op.Is(OpUpdateOne) {
  24926. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  24927. }
  24928. if m.id == nil || m.oldValue == nil {
  24929. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  24930. }
  24931. oldValue, err := m.oldValue(ctx)
  24932. if err != nil {
  24933. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  24934. }
  24935. return oldValue.NoReplyCondition, nil
  24936. }
  24937. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  24938. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  24939. if m.addno_reply_condition != nil {
  24940. *m.addno_reply_condition += u
  24941. } else {
  24942. m.addno_reply_condition = &u
  24943. }
  24944. }
  24945. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  24946. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  24947. v := m.addno_reply_condition
  24948. if v == nil {
  24949. return
  24950. }
  24951. return *v, true
  24952. }
  24953. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  24954. func (m *SopNodeMutation) ResetNoReplyCondition() {
  24955. m.no_reply_condition = nil
  24956. m.addno_reply_condition = nil
  24957. }
  24958. // SetNoReplyUnit sets the "no_reply_unit" field.
  24959. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  24960. m.no_reply_unit = &s
  24961. }
  24962. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  24963. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  24964. v := m.no_reply_unit
  24965. if v == nil {
  24966. return
  24967. }
  24968. return *v, true
  24969. }
  24970. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  24971. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24972. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24973. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  24974. if !m.op.Is(OpUpdateOne) {
  24975. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  24976. }
  24977. if m.id == nil || m.oldValue == nil {
  24978. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  24979. }
  24980. oldValue, err := m.oldValue(ctx)
  24981. if err != nil {
  24982. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  24983. }
  24984. return oldValue.NoReplyUnit, nil
  24985. }
  24986. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  24987. func (m *SopNodeMutation) ResetNoReplyUnit() {
  24988. m.no_reply_unit = nil
  24989. }
  24990. // SetActionMessage sets the "action_message" field.
  24991. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  24992. m.action_message = &ct
  24993. m.appendaction_message = nil
  24994. }
  24995. // ActionMessage returns the value of the "action_message" field in the mutation.
  24996. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  24997. v := m.action_message
  24998. if v == nil {
  24999. return
  25000. }
  25001. return *v, true
  25002. }
  25003. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  25004. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25005. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25006. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  25007. if !m.op.Is(OpUpdateOne) {
  25008. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  25009. }
  25010. if m.id == nil || m.oldValue == nil {
  25011. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  25012. }
  25013. oldValue, err := m.oldValue(ctx)
  25014. if err != nil {
  25015. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  25016. }
  25017. return oldValue.ActionMessage, nil
  25018. }
  25019. // AppendActionMessage adds ct to the "action_message" field.
  25020. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  25021. m.appendaction_message = append(m.appendaction_message, ct...)
  25022. }
  25023. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  25024. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  25025. if len(m.appendaction_message) == 0 {
  25026. return nil, false
  25027. }
  25028. return m.appendaction_message, true
  25029. }
  25030. // ClearActionMessage clears the value of the "action_message" field.
  25031. func (m *SopNodeMutation) ClearActionMessage() {
  25032. m.action_message = nil
  25033. m.appendaction_message = nil
  25034. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  25035. }
  25036. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  25037. func (m *SopNodeMutation) ActionMessageCleared() bool {
  25038. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  25039. return ok
  25040. }
  25041. // ResetActionMessage resets all changes to the "action_message" field.
  25042. func (m *SopNodeMutation) ResetActionMessage() {
  25043. m.action_message = nil
  25044. m.appendaction_message = nil
  25045. delete(m.clearedFields, sopnode.FieldActionMessage)
  25046. }
  25047. // SetActionLabelAdd sets the "action_label_add" field.
  25048. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  25049. m.action_label_add = &u
  25050. m.appendaction_label_add = nil
  25051. }
  25052. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  25053. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  25054. v := m.action_label_add
  25055. if v == nil {
  25056. return
  25057. }
  25058. return *v, true
  25059. }
  25060. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  25061. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25062. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25063. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  25064. if !m.op.Is(OpUpdateOne) {
  25065. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  25066. }
  25067. if m.id == nil || m.oldValue == nil {
  25068. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  25069. }
  25070. oldValue, err := m.oldValue(ctx)
  25071. if err != nil {
  25072. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  25073. }
  25074. return oldValue.ActionLabelAdd, nil
  25075. }
  25076. // AppendActionLabelAdd adds u to the "action_label_add" field.
  25077. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  25078. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  25079. }
  25080. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  25081. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  25082. if len(m.appendaction_label_add) == 0 {
  25083. return nil, false
  25084. }
  25085. return m.appendaction_label_add, true
  25086. }
  25087. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  25088. func (m *SopNodeMutation) ClearActionLabelAdd() {
  25089. m.action_label_add = nil
  25090. m.appendaction_label_add = nil
  25091. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  25092. }
  25093. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  25094. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  25095. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  25096. return ok
  25097. }
  25098. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  25099. func (m *SopNodeMutation) ResetActionLabelAdd() {
  25100. m.action_label_add = nil
  25101. m.appendaction_label_add = nil
  25102. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  25103. }
  25104. // SetActionLabelDel sets the "action_label_del" field.
  25105. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  25106. m.action_label_del = &u
  25107. m.appendaction_label_del = nil
  25108. }
  25109. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  25110. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  25111. v := m.action_label_del
  25112. if v == nil {
  25113. return
  25114. }
  25115. return *v, true
  25116. }
  25117. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  25118. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25119. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25120. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  25121. if !m.op.Is(OpUpdateOne) {
  25122. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  25123. }
  25124. if m.id == nil || m.oldValue == nil {
  25125. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  25126. }
  25127. oldValue, err := m.oldValue(ctx)
  25128. if err != nil {
  25129. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  25130. }
  25131. return oldValue.ActionLabelDel, nil
  25132. }
  25133. // AppendActionLabelDel adds u to the "action_label_del" field.
  25134. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  25135. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  25136. }
  25137. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  25138. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  25139. if len(m.appendaction_label_del) == 0 {
  25140. return nil, false
  25141. }
  25142. return m.appendaction_label_del, true
  25143. }
  25144. // ClearActionLabelDel clears the value of the "action_label_del" field.
  25145. func (m *SopNodeMutation) ClearActionLabelDel() {
  25146. m.action_label_del = nil
  25147. m.appendaction_label_del = nil
  25148. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  25149. }
  25150. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  25151. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  25152. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  25153. return ok
  25154. }
  25155. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  25156. func (m *SopNodeMutation) ResetActionLabelDel() {
  25157. m.action_label_del = nil
  25158. m.appendaction_label_del = nil
  25159. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  25160. }
  25161. // SetActionForward sets the "action_forward" field.
  25162. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  25163. m.action_forward = &ctf
  25164. }
  25165. // ActionForward returns the value of the "action_forward" field in the mutation.
  25166. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  25167. v := m.action_forward
  25168. if v == nil {
  25169. return
  25170. }
  25171. return *v, true
  25172. }
  25173. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  25174. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25175. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25176. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  25177. if !m.op.Is(OpUpdateOne) {
  25178. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  25179. }
  25180. if m.id == nil || m.oldValue == nil {
  25181. return v, errors.New("OldActionForward requires an ID field in the mutation")
  25182. }
  25183. oldValue, err := m.oldValue(ctx)
  25184. if err != nil {
  25185. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  25186. }
  25187. return oldValue.ActionForward, nil
  25188. }
  25189. // ClearActionForward clears the value of the "action_forward" field.
  25190. func (m *SopNodeMutation) ClearActionForward() {
  25191. m.action_forward = nil
  25192. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  25193. }
  25194. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  25195. func (m *SopNodeMutation) ActionForwardCleared() bool {
  25196. _, ok := m.clearedFields[sopnode.FieldActionForward]
  25197. return ok
  25198. }
  25199. // ResetActionForward resets all changes to the "action_forward" field.
  25200. func (m *SopNodeMutation) ResetActionForward() {
  25201. m.action_forward = nil
  25202. delete(m.clearedFields, sopnode.FieldActionForward)
  25203. }
  25204. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  25205. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  25206. m.sop_stage = &id
  25207. }
  25208. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  25209. func (m *SopNodeMutation) ClearSopStage() {
  25210. m.clearedsop_stage = true
  25211. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  25212. }
  25213. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  25214. func (m *SopNodeMutation) SopStageCleared() bool {
  25215. return m.clearedsop_stage
  25216. }
  25217. // SopStageID returns the "sop_stage" edge ID in the mutation.
  25218. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  25219. if m.sop_stage != nil {
  25220. return *m.sop_stage, true
  25221. }
  25222. return
  25223. }
  25224. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  25225. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  25226. // SopStageID instead. It exists only for internal usage by the builders.
  25227. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  25228. if id := m.sop_stage; id != nil {
  25229. ids = append(ids, *id)
  25230. }
  25231. return
  25232. }
  25233. // ResetSopStage resets all changes to the "sop_stage" edge.
  25234. func (m *SopNodeMutation) ResetSopStage() {
  25235. m.sop_stage = nil
  25236. m.clearedsop_stage = false
  25237. }
  25238. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  25239. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  25240. if m.node_messages == nil {
  25241. m.node_messages = make(map[uint64]struct{})
  25242. }
  25243. for i := range ids {
  25244. m.node_messages[ids[i]] = struct{}{}
  25245. }
  25246. }
  25247. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  25248. func (m *SopNodeMutation) ClearNodeMessages() {
  25249. m.clearednode_messages = true
  25250. }
  25251. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  25252. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  25253. return m.clearednode_messages
  25254. }
  25255. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  25256. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  25257. if m.removednode_messages == nil {
  25258. m.removednode_messages = make(map[uint64]struct{})
  25259. }
  25260. for i := range ids {
  25261. delete(m.node_messages, ids[i])
  25262. m.removednode_messages[ids[i]] = struct{}{}
  25263. }
  25264. }
  25265. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  25266. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  25267. for id := range m.removednode_messages {
  25268. ids = append(ids, id)
  25269. }
  25270. return
  25271. }
  25272. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  25273. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  25274. for id := range m.node_messages {
  25275. ids = append(ids, id)
  25276. }
  25277. return
  25278. }
  25279. // ResetNodeMessages resets all changes to the "node_messages" edge.
  25280. func (m *SopNodeMutation) ResetNodeMessages() {
  25281. m.node_messages = nil
  25282. m.clearednode_messages = false
  25283. m.removednode_messages = nil
  25284. }
  25285. // Where appends a list predicates to the SopNodeMutation builder.
  25286. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  25287. m.predicates = append(m.predicates, ps...)
  25288. }
  25289. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  25290. // users can use type-assertion to append predicates that do not depend on any generated package.
  25291. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  25292. p := make([]predicate.SopNode, len(ps))
  25293. for i := range ps {
  25294. p[i] = ps[i]
  25295. }
  25296. m.Where(p...)
  25297. }
  25298. // Op returns the operation name.
  25299. func (m *SopNodeMutation) Op() Op {
  25300. return m.op
  25301. }
  25302. // SetOp allows setting the mutation operation.
  25303. func (m *SopNodeMutation) SetOp(op Op) {
  25304. m.op = op
  25305. }
  25306. // Type returns the node type of this mutation (SopNode).
  25307. func (m *SopNodeMutation) Type() string {
  25308. return m.typ
  25309. }
  25310. // Fields returns all fields that were changed during this mutation. Note that in
  25311. // order to get all numeric fields that were incremented/decremented, call
  25312. // AddedFields().
  25313. func (m *SopNodeMutation) Fields() []string {
  25314. fields := make([]string, 0, 15)
  25315. if m.created_at != nil {
  25316. fields = append(fields, sopnode.FieldCreatedAt)
  25317. }
  25318. if m.updated_at != nil {
  25319. fields = append(fields, sopnode.FieldUpdatedAt)
  25320. }
  25321. if m.status != nil {
  25322. fields = append(fields, sopnode.FieldStatus)
  25323. }
  25324. if m.deleted_at != nil {
  25325. fields = append(fields, sopnode.FieldDeletedAt)
  25326. }
  25327. if m.sop_stage != nil {
  25328. fields = append(fields, sopnode.FieldStageID)
  25329. }
  25330. if m.parent_id != nil {
  25331. fields = append(fields, sopnode.FieldParentID)
  25332. }
  25333. if m.name != nil {
  25334. fields = append(fields, sopnode.FieldName)
  25335. }
  25336. if m.condition_type != nil {
  25337. fields = append(fields, sopnode.FieldConditionType)
  25338. }
  25339. if m.condition_list != nil {
  25340. fields = append(fields, sopnode.FieldConditionList)
  25341. }
  25342. if m.no_reply_condition != nil {
  25343. fields = append(fields, sopnode.FieldNoReplyCondition)
  25344. }
  25345. if m.no_reply_unit != nil {
  25346. fields = append(fields, sopnode.FieldNoReplyUnit)
  25347. }
  25348. if m.action_message != nil {
  25349. fields = append(fields, sopnode.FieldActionMessage)
  25350. }
  25351. if m.action_label_add != nil {
  25352. fields = append(fields, sopnode.FieldActionLabelAdd)
  25353. }
  25354. if m.action_label_del != nil {
  25355. fields = append(fields, sopnode.FieldActionLabelDel)
  25356. }
  25357. if m.action_forward != nil {
  25358. fields = append(fields, sopnode.FieldActionForward)
  25359. }
  25360. return fields
  25361. }
  25362. // Field returns the value of a field with the given name. The second boolean
  25363. // return value indicates that this field was not set, or was not defined in the
  25364. // schema.
  25365. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  25366. switch name {
  25367. case sopnode.FieldCreatedAt:
  25368. return m.CreatedAt()
  25369. case sopnode.FieldUpdatedAt:
  25370. return m.UpdatedAt()
  25371. case sopnode.FieldStatus:
  25372. return m.Status()
  25373. case sopnode.FieldDeletedAt:
  25374. return m.DeletedAt()
  25375. case sopnode.FieldStageID:
  25376. return m.StageID()
  25377. case sopnode.FieldParentID:
  25378. return m.ParentID()
  25379. case sopnode.FieldName:
  25380. return m.Name()
  25381. case sopnode.FieldConditionType:
  25382. return m.ConditionType()
  25383. case sopnode.FieldConditionList:
  25384. return m.ConditionList()
  25385. case sopnode.FieldNoReplyCondition:
  25386. return m.NoReplyCondition()
  25387. case sopnode.FieldNoReplyUnit:
  25388. return m.NoReplyUnit()
  25389. case sopnode.FieldActionMessage:
  25390. return m.ActionMessage()
  25391. case sopnode.FieldActionLabelAdd:
  25392. return m.ActionLabelAdd()
  25393. case sopnode.FieldActionLabelDel:
  25394. return m.ActionLabelDel()
  25395. case sopnode.FieldActionForward:
  25396. return m.ActionForward()
  25397. }
  25398. return nil, false
  25399. }
  25400. // OldField returns the old value of the field from the database. An error is
  25401. // returned if the mutation operation is not UpdateOne, or the query to the
  25402. // database failed.
  25403. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25404. switch name {
  25405. case sopnode.FieldCreatedAt:
  25406. return m.OldCreatedAt(ctx)
  25407. case sopnode.FieldUpdatedAt:
  25408. return m.OldUpdatedAt(ctx)
  25409. case sopnode.FieldStatus:
  25410. return m.OldStatus(ctx)
  25411. case sopnode.FieldDeletedAt:
  25412. return m.OldDeletedAt(ctx)
  25413. case sopnode.FieldStageID:
  25414. return m.OldStageID(ctx)
  25415. case sopnode.FieldParentID:
  25416. return m.OldParentID(ctx)
  25417. case sopnode.FieldName:
  25418. return m.OldName(ctx)
  25419. case sopnode.FieldConditionType:
  25420. return m.OldConditionType(ctx)
  25421. case sopnode.FieldConditionList:
  25422. return m.OldConditionList(ctx)
  25423. case sopnode.FieldNoReplyCondition:
  25424. return m.OldNoReplyCondition(ctx)
  25425. case sopnode.FieldNoReplyUnit:
  25426. return m.OldNoReplyUnit(ctx)
  25427. case sopnode.FieldActionMessage:
  25428. return m.OldActionMessage(ctx)
  25429. case sopnode.FieldActionLabelAdd:
  25430. return m.OldActionLabelAdd(ctx)
  25431. case sopnode.FieldActionLabelDel:
  25432. return m.OldActionLabelDel(ctx)
  25433. case sopnode.FieldActionForward:
  25434. return m.OldActionForward(ctx)
  25435. }
  25436. return nil, fmt.Errorf("unknown SopNode field %s", name)
  25437. }
  25438. // SetField sets the value of a field with the given name. It returns an error if
  25439. // the field is not defined in the schema, or if the type mismatched the field
  25440. // type.
  25441. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  25442. switch name {
  25443. case sopnode.FieldCreatedAt:
  25444. v, ok := value.(time.Time)
  25445. if !ok {
  25446. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25447. }
  25448. m.SetCreatedAt(v)
  25449. return nil
  25450. case sopnode.FieldUpdatedAt:
  25451. v, ok := value.(time.Time)
  25452. if !ok {
  25453. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25454. }
  25455. m.SetUpdatedAt(v)
  25456. return nil
  25457. case sopnode.FieldStatus:
  25458. v, ok := value.(uint8)
  25459. if !ok {
  25460. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25461. }
  25462. m.SetStatus(v)
  25463. return nil
  25464. case sopnode.FieldDeletedAt:
  25465. v, ok := value.(time.Time)
  25466. if !ok {
  25467. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25468. }
  25469. m.SetDeletedAt(v)
  25470. return nil
  25471. case sopnode.FieldStageID:
  25472. v, ok := value.(uint64)
  25473. if !ok {
  25474. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25475. }
  25476. m.SetStageID(v)
  25477. return nil
  25478. case sopnode.FieldParentID:
  25479. v, ok := value.(uint64)
  25480. if !ok {
  25481. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25482. }
  25483. m.SetParentID(v)
  25484. return nil
  25485. case sopnode.FieldName:
  25486. v, ok := value.(string)
  25487. if !ok {
  25488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25489. }
  25490. m.SetName(v)
  25491. return nil
  25492. case sopnode.FieldConditionType:
  25493. v, ok := value.(int)
  25494. if !ok {
  25495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25496. }
  25497. m.SetConditionType(v)
  25498. return nil
  25499. case sopnode.FieldConditionList:
  25500. v, ok := value.([]string)
  25501. if !ok {
  25502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25503. }
  25504. m.SetConditionList(v)
  25505. return nil
  25506. case sopnode.FieldNoReplyCondition:
  25507. v, ok := value.(uint64)
  25508. if !ok {
  25509. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25510. }
  25511. m.SetNoReplyCondition(v)
  25512. return nil
  25513. case sopnode.FieldNoReplyUnit:
  25514. v, ok := value.(string)
  25515. if !ok {
  25516. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25517. }
  25518. m.SetNoReplyUnit(v)
  25519. return nil
  25520. case sopnode.FieldActionMessage:
  25521. v, ok := value.([]custom_types.Action)
  25522. if !ok {
  25523. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25524. }
  25525. m.SetActionMessage(v)
  25526. return nil
  25527. case sopnode.FieldActionLabelAdd:
  25528. v, ok := value.([]uint64)
  25529. if !ok {
  25530. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25531. }
  25532. m.SetActionLabelAdd(v)
  25533. return nil
  25534. case sopnode.FieldActionLabelDel:
  25535. v, ok := value.([]uint64)
  25536. if !ok {
  25537. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25538. }
  25539. m.SetActionLabelDel(v)
  25540. return nil
  25541. case sopnode.FieldActionForward:
  25542. v, ok := value.(*custom_types.ActionForward)
  25543. if !ok {
  25544. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25545. }
  25546. m.SetActionForward(v)
  25547. return nil
  25548. }
  25549. return fmt.Errorf("unknown SopNode field %s", name)
  25550. }
  25551. // AddedFields returns all numeric fields that were incremented/decremented during
  25552. // this mutation.
  25553. func (m *SopNodeMutation) AddedFields() []string {
  25554. var fields []string
  25555. if m.addstatus != nil {
  25556. fields = append(fields, sopnode.FieldStatus)
  25557. }
  25558. if m.addparent_id != nil {
  25559. fields = append(fields, sopnode.FieldParentID)
  25560. }
  25561. if m.addcondition_type != nil {
  25562. fields = append(fields, sopnode.FieldConditionType)
  25563. }
  25564. if m.addno_reply_condition != nil {
  25565. fields = append(fields, sopnode.FieldNoReplyCondition)
  25566. }
  25567. return fields
  25568. }
  25569. // AddedField returns the numeric value that was incremented/decremented on a field
  25570. // with the given name. The second boolean return value indicates that this field
  25571. // was not set, or was not defined in the schema.
  25572. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  25573. switch name {
  25574. case sopnode.FieldStatus:
  25575. return m.AddedStatus()
  25576. case sopnode.FieldParentID:
  25577. return m.AddedParentID()
  25578. case sopnode.FieldConditionType:
  25579. return m.AddedConditionType()
  25580. case sopnode.FieldNoReplyCondition:
  25581. return m.AddedNoReplyCondition()
  25582. }
  25583. return nil, false
  25584. }
  25585. // AddField adds the value to the field with the given name. It returns an error if
  25586. // the field is not defined in the schema, or if the type mismatched the field
  25587. // type.
  25588. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  25589. switch name {
  25590. case sopnode.FieldStatus:
  25591. v, ok := value.(int8)
  25592. if !ok {
  25593. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25594. }
  25595. m.AddStatus(v)
  25596. return nil
  25597. case sopnode.FieldParentID:
  25598. v, ok := value.(int64)
  25599. if !ok {
  25600. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25601. }
  25602. m.AddParentID(v)
  25603. return nil
  25604. case sopnode.FieldConditionType:
  25605. v, ok := value.(int)
  25606. if !ok {
  25607. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25608. }
  25609. m.AddConditionType(v)
  25610. return nil
  25611. case sopnode.FieldNoReplyCondition:
  25612. v, ok := value.(int64)
  25613. if !ok {
  25614. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25615. }
  25616. m.AddNoReplyCondition(v)
  25617. return nil
  25618. }
  25619. return fmt.Errorf("unknown SopNode numeric field %s", name)
  25620. }
  25621. // ClearedFields returns all nullable fields that were cleared during this
  25622. // mutation.
  25623. func (m *SopNodeMutation) ClearedFields() []string {
  25624. var fields []string
  25625. if m.FieldCleared(sopnode.FieldStatus) {
  25626. fields = append(fields, sopnode.FieldStatus)
  25627. }
  25628. if m.FieldCleared(sopnode.FieldDeletedAt) {
  25629. fields = append(fields, sopnode.FieldDeletedAt)
  25630. }
  25631. if m.FieldCleared(sopnode.FieldConditionList) {
  25632. fields = append(fields, sopnode.FieldConditionList)
  25633. }
  25634. if m.FieldCleared(sopnode.FieldActionMessage) {
  25635. fields = append(fields, sopnode.FieldActionMessage)
  25636. }
  25637. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  25638. fields = append(fields, sopnode.FieldActionLabelAdd)
  25639. }
  25640. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  25641. fields = append(fields, sopnode.FieldActionLabelDel)
  25642. }
  25643. if m.FieldCleared(sopnode.FieldActionForward) {
  25644. fields = append(fields, sopnode.FieldActionForward)
  25645. }
  25646. return fields
  25647. }
  25648. // FieldCleared returns a boolean indicating if a field with the given name was
  25649. // cleared in this mutation.
  25650. func (m *SopNodeMutation) FieldCleared(name string) bool {
  25651. _, ok := m.clearedFields[name]
  25652. return ok
  25653. }
  25654. // ClearField clears the value of the field with the given name. It returns an
  25655. // error if the field is not defined in the schema.
  25656. func (m *SopNodeMutation) ClearField(name string) error {
  25657. switch name {
  25658. case sopnode.FieldStatus:
  25659. m.ClearStatus()
  25660. return nil
  25661. case sopnode.FieldDeletedAt:
  25662. m.ClearDeletedAt()
  25663. return nil
  25664. case sopnode.FieldConditionList:
  25665. m.ClearConditionList()
  25666. return nil
  25667. case sopnode.FieldActionMessage:
  25668. m.ClearActionMessage()
  25669. return nil
  25670. case sopnode.FieldActionLabelAdd:
  25671. m.ClearActionLabelAdd()
  25672. return nil
  25673. case sopnode.FieldActionLabelDel:
  25674. m.ClearActionLabelDel()
  25675. return nil
  25676. case sopnode.FieldActionForward:
  25677. m.ClearActionForward()
  25678. return nil
  25679. }
  25680. return fmt.Errorf("unknown SopNode nullable field %s", name)
  25681. }
  25682. // ResetField resets all changes in the mutation for the field with the given name.
  25683. // It returns an error if the field is not defined in the schema.
  25684. func (m *SopNodeMutation) ResetField(name string) error {
  25685. switch name {
  25686. case sopnode.FieldCreatedAt:
  25687. m.ResetCreatedAt()
  25688. return nil
  25689. case sopnode.FieldUpdatedAt:
  25690. m.ResetUpdatedAt()
  25691. return nil
  25692. case sopnode.FieldStatus:
  25693. m.ResetStatus()
  25694. return nil
  25695. case sopnode.FieldDeletedAt:
  25696. m.ResetDeletedAt()
  25697. return nil
  25698. case sopnode.FieldStageID:
  25699. m.ResetStageID()
  25700. return nil
  25701. case sopnode.FieldParentID:
  25702. m.ResetParentID()
  25703. return nil
  25704. case sopnode.FieldName:
  25705. m.ResetName()
  25706. return nil
  25707. case sopnode.FieldConditionType:
  25708. m.ResetConditionType()
  25709. return nil
  25710. case sopnode.FieldConditionList:
  25711. m.ResetConditionList()
  25712. return nil
  25713. case sopnode.FieldNoReplyCondition:
  25714. m.ResetNoReplyCondition()
  25715. return nil
  25716. case sopnode.FieldNoReplyUnit:
  25717. m.ResetNoReplyUnit()
  25718. return nil
  25719. case sopnode.FieldActionMessage:
  25720. m.ResetActionMessage()
  25721. return nil
  25722. case sopnode.FieldActionLabelAdd:
  25723. m.ResetActionLabelAdd()
  25724. return nil
  25725. case sopnode.FieldActionLabelDel:
  25726. m.ResetActionLabelDel()
  25727. return nil
  25728. case sopnode.FieldActionForward:
  25729. m.ResetActionForward()
  25730. return nil
  25731. }
  25732. return fmt.Errorf("unknown SopNode field %s", name)
  25733. }
  25734. // AddedEdges returns all edge names that were set/added in this mutation.
  25735. func (m *SopNodeMutation) AddedEdges() []string {
  25736. edges := make([]string, 0, 2)
  25737. if m.sop_stage != nil {
  25738. edges = append(edges, sopnode.EdgeSopStage)
  25739. }
  25740. if m.node_messages != nil {
  25741. edges = append(edges, sopnode.EdgeNodeMessages)
  25742. }
  25743. return edges
  25744. }
  25745. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25746. // name in this mutation.
  25747. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  25748. switch name {
  25749. case sopnode.EdgeSopStage:
  25750. if id := m.sop_stage; id != nil {
  25751. return []ent.Value{*id}
  25752. }
  25753. case sopnode.EdgeNodeMessages:
  25754. ids := make([]ent.Value, 0, len(m.node_messages))
  25755. for id := range m.node_messages {
  25756. ids = append(ids, id)
  25757. }
  25758. return ids
  25759. }
  25760. return nil
  25761. }
  25762. // RemovedEdges returns all edge names that were removed in this mutation.
  25763. func (m *SopNodeMutation) RemovedEdges() []string {
  25764. edges := make([]string, 0, 2)
  25765. if m.removednode_messages != nil {
  25766. edges = append(edges, sopnode.EdgeNodeMessages)
  25767. }
  25768. return edges
  25769. }
  25770. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25771. // the given name in this mutation.
  25772. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  25773. switch name {
  25774. case sopnode.EdgeNodeMessages:
  25775. ids := make([]ent.Value, 0, len(m.removednode_messages))
  25776. for id := range m.removednode_messages {
  25777. ids = append(ids, id)
  25778. }
  25779. return ids
  25780. }
  25781. return nil
  25782. }
  25783. // ClearedEdges returns all edge names that were cleared in this mutation.
  25784. func (m *SopNodeMutation) ClearedEdges() []string {
  25785. edges := make([]string, 0, 2)
  25786. if m.clearedsop_stage {
  25787. edges = append(edges, sopnode.EdgeSopStage)
  25788. }
  25789. if m.clearednode_messages {
  25790. edges = append(edges, sopnode.EdgeNodeMessages)
  25791. }
  25792. return edges
  25793. }
  25794. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25795. // was cleared in this mutation.
  25796. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  25797. switch name {
  25798. case sopnode.EdgeSopStage:
  25799. return m.clearedsop_stage
  25800. case sopnode.EdgeNodeMessages:
  25801. return m.clearednode_messages
  25802. }
  25803. return false
  25804. }
  25805. // ClearEdge clears the value of the edge with the given name. It returns an error
  25806. // if that edge is not defined in the schema.
  25807. func (m *SopNodeMutation) ClearEdge(name string) error {
  25808. switch name {
  25809. case sopnode.EdgeSopStage:
  25810. m.ClearSopStage()
  25811. return nil
  25812. }
  25813. return fmt.Errorf("unknown SopNode unique edge %s", name)
  25814. }
  25815. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25816. // It returns an error if the edge is not defined in the schema.
  25817. func (m *SopNodeMutation) ResetEdge(name string) error {
  25818. switch name {
  25819. case sopnode.EdgeSopStage:
  25820. m.ResetSopStage()
  25821. return nil
  25822. case sopnode.EdgeNodeMessages:
  25823. m.ResetNodeMessages()
  25824. return nil
  25825. }
  25826. return fmt.Errorf("unknown SopNode edge %s", name)
  25827. }
  25828. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  25829. type SopStageMutation struct {
  25830. config
  25831. op Op
  25832. typ string
  25833. id *uint64
  25834. created_at *time.Time
  25835. updated_at *time.Time
  25836. status *uint8
  25837. addstatus *int8
  25838. deleted_at *time.Time
  25839. name *string
  25840. condition_type *int
  25841. addcondition_type *int
  25842. condition_operator *int
  25843. addcondition_operator *int
  25844. condition_list *[]custom_types.Condition
  25845. appendcondition_list []custom_types.Condition
  25846. action_message *[]custom_types.Action
  25847. appendaction_message []custom_types.Action
  25848. action_label_add *[]uint64
  25849. appendaction_label_add []uint64
  25850. action_label_del *[]uint64
  25851. appendaction_label_del []uint64
  25852. action_forward **custom_types.ActionForward
  25853. index_sort *int
  25854. addindex_sort *int
  25855. clearedFields map[string]struct{}
  25856. sop_task *uint64
  25857. clearedsop_task bool
  25858. stage_nodes map[uint64]struct{}
  25859. removedstage_nodes map[uint64]struct{}
  25860. clearedstage_nodes bool
  25861. stage_messages map[uint64]struct{}
  25862. removedstage_messages map[uint64]struct{}
  25863. clearedstage_messages bool
  25864. done bool
  25865. oldValue func(context.Context) (*SopStage, error)
  25866. predicates []predicate.SopStage
  25867. }
  25868. var _ ent.Mutation = (*SopStageMutation)(nil)
  25869. // sopstageOption allows management of the mutation configuration using functional options.
  25870. type sopstageOption func(*SopStageMutation)
  25871. // newSopStageMutation creates new mutation for the SopStage entity.
  25872. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  25873. m := &SopStageMutation{
  25874. config: c,
  25875. op: op,
  25876. typ: TypeSopStage,
  25877. clearedFields: make(map[string]struct{}),
  25878. }
  25879. for _, opt := range opts {
  25880. opt(m)
  25881. }
  25882. return m
  25883. }
  25884. // withSopStageID sets the ID field of the mutation.
  25885. func withSopStageID(id uint64) sopstageOption {
  25886. return func(m *SopStageMutation) {
  25887. var (
  25888. err error
  25889. once sync.Once
  25890. value *SopStage
  25891. )
  25892. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  25893. once.Do(func() {
  25894. if m.done {
  25895. err = errors.New("querying old values post mutation is not allowed")
  25896. } else {
  25897. value, err = m.Client().SopStage.Get(ctx, id)
  25898. }
  25899. })
  25900. return value, err
  25901. }
  25902. m.id = &id
  25903. }
  25904. }
  25905. // withSopStage sets the old SopStage of the mutation.
  25906. func withSopStage(node *SopStage) sopstageOption {
  25907. return func(m *SopStageMutation) {
  25908. m.oldValue = func(context.Context) (*SopStage, error) {
  25909. return node, nil
  25910. }
  25911. m.id = &node.ID
  25912. }
  25913. }
  25914. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25915. // executed in a transaction (ent.Tx), a transactional client is returned.
  25916. func (m SopStageMutation) Client() *Client {
  25917. client := &Client{config: m.config}
  25918. client.init()
  25919. return client
  25920. }
  25921. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25922. // it returns an error otherwise.
  25923. func (m SopStageMutation) Tx() (*Tx, error) {
  25924. if _, ok := m.driver.(*txDriver); !ok {
  25925. return nil, errors.New("ent: mutation is not running in a transaction")
  25926. }
  25927. tx := &Tx{config: m.config}
  25928. tx.init()
  25929. return tx, nil
  25930. }
  25931. // SetID sets the value of the id field. Note that this
  25932. // operation is only accepted on creation of SopStage entities.
  25933. func (m *SopStageMutation) SetID(id uint64) {
  25934. m.id = &id
  25935. }
  25936. // ID returns the ID value in the mutation. Note that the ID is only available
  25937. // if it was provided to the builder or after it was returned from the database.
  25938. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  25939. if m.id == nil {
  25940. return
  25941. }
  25942. return *m.id, true
  25943. }
  25944. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  25945. // That means, if the mutation is applied within a transaction with an isolation level such
  25946. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  25947. // or updated by the mutation.
  25948. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  25949. switch {
  25950. case m.op.Is(OpUpdateOne | OpDeleteOne):
  25951. id, exists := m.ID()
  25952. if exists {
  25953. return []uint64{id}, nil
  25954. }
  25955. fallthrough
  25956. case m.op.Is(OpUpdate | OpDelete):
  25957. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  25958. default:
  25959. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  25960. }
  25961. }
  25962. // SetCreatedAt sets the "created_at" field.
  25963. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  25964. m.created_at = &t
  25965. }
  25966. // CreatedAt returns the value of the "created_at" field in the mutation.
  25967. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  25968. v := m.created_at
  25969. if v == nil {
  25970. return
  25971. }
  25972. return *v, true
  25973. }
  25974. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  25975. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25976. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25977. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  25978. if !m.op.Is(OpUpdateOne) {
  25979. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  25980. }
  25981. if m.id == nil || m.oldValue == nil {
  25982. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  25983. }
  25984. oldValue, err := m.oldValue(ctx)
  25985. if err != nil {
  25986. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  25987. }
  25988. return oldValue.CreatedAt, nil
  25989. }
  25990. // ResetCreatedAt resets all changes to the "created_at" field.
  25991. func (m *SopStageMutation) ResetCreatedAt() {
  25992. m.created_at = nil
  25993. }
  25994. // SetUpdatedAt sets the "updated_at" field.
  25995. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  25996. m.updated_at = &t
  25997. }
  25998. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  25999. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  26000. v := m.updated_at
  26001. if v == nil {
  26002. return
  26003. }
  26004. return *v, true
  26005. }
  26006. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  26007. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26008. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26009. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26010. if !m.op.Is(OpUpdateOne) {
  26011. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26012. }
  26013. if m.id == nil || m.oldValue == nil {
  26014. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26015. }
  26016. oldValue, err := m.oldValue(ctx)
  26017. if err != nil {
  26018. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26019. }
  26020. return oldValue.UpdatedAt, nil
  26021. }
  26022. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26023. func (m *SopStageMutation) ResetUpdatedAt() {
  26024. m.updated_at = nil
  26025. }
  26026. // SetStatus sets the "status" field.
  26027. func (m *SopStageMutation) SetStatus(u uint8) {
  26028. m.status = &u
  26029. m.addstatus = nil
  26030. }
  26031. // Status returns the value of the "status" field in the mutation.
  26032. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  26033. v := m.status
  26034. if v == nil {
  26035. return
  26036. }
  26037. return *v, true
  26038. }
  26039. // OldStatus returns the old "status" field's value of the SopStage entity.
  26040. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26041. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26042. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  26043. if !m.op.Is(OpUpdateOne) {
  26044. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26045. }
  26046. if m.id == nil || m.oldValue == nil {
  26047. return v, errors.New("OldStatus requires an ID field in the mutation")
  26048. }
  26049. oldValue, err := m.oldValue(ctx)
  26050. if err != nil {
  26051. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26052. }
  26053. return oldValue.Status, nil
  26054. }
  26055. // AddStatus adds u to the "status" field.
  26056. func (m *SopStageMutation) AddStatus(u int8) {
  26057. if m.addstatus != nil {
  26058. *m.addstatus += u
  26059. } else {
  26060. m.addstatus = &u
  26061. }
  26062. }
  26063. // AddedStatus returns the value that was added to the "status" field in this mutation.
  26064. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  26065. v := m.addstatus
  26066. if v == nil {
  26067. return
  26068. }
  26069. return *v, true
  26070. }
  26071. // ClearStatus clears the value of the "status" field.
  26072. func (m *SopStageMutation) ClearStatus() {
  26073. m.status = nil
  26074. m.addstatus = nil
  26075. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  26076. }
  26077. // StatusCleared returns if the "status" field was cleared in this mutation.
  26078. func (m *SopStageMutation) StatusCleared() bool {
  26079. _, ok := m.clearedFields[sopstage.FieldStatus]
  26080. return ok
  26081. }
  26082. // ResetStatus resets all changes to the "status" field.
  26083. func (m *SopStageMutation) ResetStatus() {
  26084. m.status = nil
  26085. m.addstatus = nil
  26086. delete(m.clearedFields, sopstage.FieldStatus)
  26087. }
  26088. // SetDeletedAt sets the "deleted_at" field.
  26089. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  26090. m.deleted_at = &t
  26091. }
  26092. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26093. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  26094. v := m.deleted_at
  26095. if v == nil {
  26096. return
  26097. }
  26098. return *v, true
  26099. }
  26100. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  26101. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26102. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26103. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26104. if !m.op.Is(OpUpdateOne) {
  26105. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26106. }
  26107. if m.id == nil || m.oldValue == nil {
  26108. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26109. }
  26110. oldValue, err := m.oldValue(ctx)
  26111. if err != nil {
  26112. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26113. }
  26114. return oldValue.DeletedAt, nil
  26115. }
  26116. // ClearDeletedAt clears the value of the "deleted_at" field.
  26117. func (m *SopStageMutation) ClearDeletedAt() {
  26118. m.deleted_at = nil
  26119. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  26120. }
  26121. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26122. func (m *SopStageMutation) DeletedAtCleared() bool {
  26123. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  26124. return ok
  26125. }
  26126. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26127. func (m *SopStageMutation) ResetDeletedAt() {
  26128. m.deleted_at = nil
  26129. delete(m.clearedFields, sopstage.FieldDeletedAt)
  26130. }
  26131. // SetTaskID sets the "task_id" field.
  26132. func (m *SopStageMutation) SetTaskID(u uint64) {
  26133. m.sop_task = &u
  26134. }
  26135. // TaskID returns the value of the "task_id" field in the mutation.
  26136. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  26137. v := m.sop_task
  26138. if v == nil {
  26139. return
  26140. }
  26141. return *v, true
  26142. }
  26143. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  26144. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26145. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26146. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  26147. if !m.op.Is(OpUpdateOne) {
  26148. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  26149. }
  26150. if m.id == nil || m.oldValue == nil {
  26151. return v, errors.New("OldTaskID requires an ID field in the mutation")
  26152. }
  26153. oldValue, err := m.oldValue(ctx)
  26154. if err != nil {
  26155. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  26156. }
  26157. return oldValue.TaskID, nil
  26158. }
  26159. // ResetTaskID resets all changes to the "task_id" field.
  26160. func (m *SopStageMutation) ResetTaskID() {
  26161. m.sop_task = nil
  26162. }
  26163. // SetName sets the "name" field.
  26164. func (m *SopStageMutation) SetName(s string) {
  26165. m.name = &s
  26166. }
  26167. // Name returns the value of the "name" field in the mutation.
  26168. func (m *SopStageMutation) Name() (r string, exists bool) {
  26169. v := m.name
  26170. if v == nil {
  26171. return
  26172. }
  26173. return *v, true
  26174. }
  26175. // OldName returns the old "name" field's value of the SopStage entity.
  26176. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26177. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26178. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  26179. if !m.op.Is(OpUpdateOne) {
  26180. return v, errors.New("OldName is only allowed on UpdateOne operations")
  26181. }
  26182. if m.id == nil || m.oldValue == nil {
  26183. return v, errors.New("OldName requires an ID field in the mutation")
  26184. }
  26185. oldValue, err := m.oldValue(ctx)
  26186. if err != nil {
  26187. return v, fmt.Errorf("querying old value for OldName: %w", err)
  26188. }
  26189. return oldValue.Name, nil
  26190. }
  26191. // ResetName resets all changes to the "name" field.
  26192. func (m *SopStageMutation) ResetName() {
  26193. m.name = nil
  26194. }
  26195. // SetConditionType sets the "condition_type" field.
  26196. func (m *SopStageMutation) SetConditionType(i int) {
  26197. m.condition_type = &i
  26198. m.addcondition_type = nil
  26199. }
  26200. // ConditionType returns the value of the "condition_type" field in the mutation.
  26201. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  26202. v := m.condition_type
  26203. if v == nil {
  26204. return
  26205. }
  26206. return *v, true
  26207. }
  26208. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  26209. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26210. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26211. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  26212. if !m.op.Is(OpUpdateOne) {
  26213. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  26214. }
  26215. if m.id == nil || m.oldValue == nil {
  26216. return v, errors.New("OldConditionType requires an ID field in the mutation")
  26217. }
  26218. oldValue, err := m.oldValue(ctx)
  26219. if err != nil {
  26220. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  26221. }
  26222. return oldValue.ConditionType, nil
  26223. }
  26224. // AddConditionType adds i to the "condition_type" field.
  26225. func (m *SopStageMutation) AddConditionType(i int) {
  26226. if m.addcondition_type != nil {
  26227. *m.addcondition_type += i
  26228. } else {
  26229. m.addcondition_type = &i
  26230. }
  26231. }
  26232. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  26233. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  26234. v := m.addcondition_type
  26235. if v == nil {
  26236. return
  26237. }
  26238. return *v, true
  26239. }
  26240. // ResetConditionType resets all changes to the "condition_type" field.
  26241. func (m *SopStageMutation) ResetConditionType() {
  26242. m.condition_type = nil
  26243. m.addcondition_type = nil
  26244. }
  26245. // SetConditionOperator sets the "condition_operator" field.
  26246. func (m *SopStageMutation) SetConditionOperator(i int) {
  26247. m.condition_operator = &i
  26248. m.addcondition_operator = nil
  26249. }
  26250. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  26251. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  26252. v := m.condition_operator
  26253. if v == nil {
  26254. return
  26255. }
  26256. return *v, true
  26257. }
  26258. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  26259. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26260. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26261. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  26262. if !m.op.Is(OpUpdateOne) {
  26263. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  26264. }
  26265. if m.id == nil || m.oldValue == nil {
  26266. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  26267. }
  26268. oldValue, err := m.oldValue(ctx)
  26269. if err != nil {
  26270. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  26271. }
  26272. return oldValue.ConditionOperator, nil
  26273. }
  26274. // AddConditionOperator adds i to the "condition_operator" field.
  26275. func (m *SopStageMutation) AddConditionOperator(i int) {
  26276. if m.addcondition_operator != nil {
  26277. *m.addcondition_operator += i
  26278. } else {
  26279. m.addcondition_operator = &i
  26280. }
  26281. }
  26282. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  26283. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  26284. v := m.addcondition_operator
  26285. if v == nil {
  26286. return
  26287. }
  26288. return *v, true
  26289. }
  26290. // ResetConditionOperator resets all changes to the "condition_operator" field.
  26291. func (m *SopStageMutation) ResetConditionOperator() {
  26292. m.condition_operator = nil
  26293. m.addcondition_operator = nil
  26294. }
  26295. // SetConditionList sets the "condition_list" field.
  26296. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  26297. m.condition_list = &ct
  26298. m.appendcondition_list = nil
  26299. }
  26300. // ConditionList returns the value of the "condition_list" field in the mutation.
  26301. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  26302. v := m.condition_list
  26303. if v == nil {
  26304. return
  26305. }
  26306. return *v, true
  26307. }
  26308. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  26309. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26310. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26311. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  26312. if !m.op.Is(OpUpdateOne) {
  26313. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  26314. }
  26315. if m.id == nil || m.oldValue == nil {
  26316. return v, errors.New("OldConditionList requires an ID field in the mutation")
  26317. }
  26318. oldValue, err := m.oldValue(ctx)
  26319. if err != nil {
  26320. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  26321. }
  26322. return oldValue.ConditionList, nil
  26323. }
  26324. // AppendConditionList adds ct to the "condition_list" field.
  26325. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  26326. m.appendcondition_list = append(m.appendcondition_list, ct...)
  26327. }
  26328. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  26329. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  26330. if len(m.appendcondition_list) == 0 {
  26331. return nil, false
  26332. }
  26333. return m.appendcondition_list, true
  26334. }
  26335. // ResetConditionList resets all changes to the "condition_list" field.
  26336. func (m *SopStageMutation) ResetConditionList() {
  26337. m.condition_list = nil
  26338. m.appendcondition_list = nil
  26339. }
  26340. // SetActionMessage sets the "action_message" field.
  26341. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  26342. m.action_message = &ct
  26343. m.appendaction_message = nil
  26344. }
  26345. // ActionMessage returns the value of the "action_message" field in the mutation.
  26346. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  26347. v := m.action_message
  26348. if v == nil {
  26349. return
  26350. }
  26351. return *v, true
  26352. }
  26353. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  26354. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26355. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26356. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  26357. if !m.op.Is(OpUpdateOne) {
  26358. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  26359. }
  26360. if m.id == nil || m.oldValue == nil {
  26361. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  26362. }
  26363. oldValue, err := m.oldValue(ctx)
  26364. if err != nil {
  26365. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  26366. }
  26367. return oldValue.ActionMessage, nil
  26368. }
  26369. // AppendActionMessage adds ct to the "action_message" field.
  26370. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  26371. m.appendaction_message = append(m.appendaction_message, ct...)
  26372. }
  26373. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  26374. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  26375. if len(m.appendaction_message) == 0 {
  26376. return nil, false
  26377. }
  26378. return m.appendaction_message, true
  26379. }
  26380. // ClearActionMessage clears the value of the "action_message" field.
  26381. func (m *SopStageMutation) ClearActionMessage() {
  26382. m.action_message = nil
  26383. m.appendaction_message = nil
  26384. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  26385. }
  26386. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  26387. func (m *SopStageMutation) ActionMessageCleared() bool {
  26388. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  26389. return ok
  26390. }
  26391. // ResetActionMessage resets all changes to the "action_message" field.
  26392. func (m *SopStageMutation) ResetActionMessage() {
  26393. m.action_message = nil
  26394. m.appendaction_message = nil
  26395. delete(m.clearedFields, sopstage.FieldActionMessage)
  26396. }
  26397. // SetActionLabelAdd sets the "action_label_add" field.
  26398. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  26399. m.action_label_add = &u
  26400. m.appendaction_label_add = nil
  26401. }
  26402. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  26403. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  26404. v := m.action_label_add
  26405. if v == nil {
  26406. return
  26407. }
  26408. return *v, true
  26409. }
  26410. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  26411. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26412. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26413. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  26414. if !m.op.Is(OpUpdateOne) {
  26415. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  26416. }
  26417. if m.id == nil || m.oldValue == nil {
  26418. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  26419. }
  26420. oldValue, err := m.oldValue(ctx)
  26421. if err != nil {
  26422. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  26423. }
  26424. return oldValue.ActionLabelAdd, nil
  26425. }
  26426. // AppendActionLabelAdd adds u to the "action_label_add" field.
  26427. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  26428. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  26429. }
  26430. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  26431. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  26432. if len(m.appendaction_label_add) == 0 {
  26433. return nil, false
  26434. }
  26435. return m.appendaction_label_add, true
  26436. }
  26437. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  26438. func (m *SopStageMutation) ClearActionLabelAdd() {
  26439. m.action_label_add = nil
  26440. m.appendaction_label_add = nil
  26441. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  26442. }
  26443. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  26444. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  26445. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  26446. return ok
  26447. }
  26448. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  26449. func (m *SopStageMutation) ResetActionLabelAdd() {
  26450. m.action_label_add = nil
  26451. m.appendaction_label_add = nil
  26452. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  26453. }
  26454. // SetActionLabelDel sets the "action_label_del" field.
  26455. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  26456. m.action_label_del = &u
  26457. m.appendaction_label_del = nil
  26458. }
  26459. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  26460. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  26461. v := m.action_label_del
  26462. if v == nil {
  26463. return
  26464. }
  26465. return *v, true
  26466. }
  26467. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  26468. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26469. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26470. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  26471. if !m.op.Is(OpUpdateOne) {
  26472. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  26473. }
  26474. if m.id == nil || m.oldValue == nil {
  26475. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  26476. }
  26477. oldValue, err := m.oldValue(ctx)
  26478. if err != nil {
  26479. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  26480. }
  26481. return oldValue.ActionLabelDel, nil
  26482. }
  26483. // AppendActionLabelDel adds u to the "action_label_del" field.
  26484. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  26485. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  26486. }
  26487. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  26488. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  26489. if len(m.appendaction_label_del) == 0 {
  26490. return nil, false
  26491. }
  26492. return m.appendaction_label_del, true
  26493. }
  26494. // ClearActionLabelDel clears the value of the "action_label_del" field.
  26495. func (m *SopStageMutation) ClearActionLabelDel() {
  26496. m.action_label_del = nil
  26497. m.appendaction_label_del = nil
  26498. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  26499. }
  26500. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  26501. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  26502. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  26503. return ok
  26504. }
  26505. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  26506. func (m *SopStageMutation) ResetActionLabelDel() {
  26507. m.action_label_del = nil
  26508. m.appendaction_label_del = nil
  26509. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  26510. }
  26511. // SetActionForward sets the "action_forward" field.
  26512. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  26513. m.action_forward = &ctf
  26514. }
  26515. // ActionForward returns the value of the "action_forward" field in the mutation.
  26516. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  26517. v := m.action_forward
  26518. if v == nil {
  26519. return
  26520. }
  26521. return *v, true
  26522. }
  26523. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  26524. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26525. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26526. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  26527. if !m.op.Is(OpUpdateOne) {
  26528. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  26529. }
  26530. if m.id == nil || m.oldValue == nil {
  26531. return v, errors.New("OldActionForward requires an ID field in the mutation")
  26532. }
  26533. oldValue, err := m.oldValue(ctx)
  26534. if err != nil {
  26535. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  26536. }
  26537. return oldValue.ActionForward, nil
  26538. }
  26539. // ClearActionForward clears the value of the "action_forward" field.
  26540. func (m *SopStageMutation) ClearActionForward() {
  26541. m.action_forward = nil
  26542. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  26543. }
  26544. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  26545. func (m *SopStageMutation) ActionForwardCleared() bool {
  26546. _, ok := m.clearedFields[sopstage.FieldActionForward]
  26547. return ok
  26548. }
  26549. // ResetActionForward resets all changes to the "action_forward" field.
  26550. func (m *SopStageMutation) ResetActionForward() {
  26551. m.action_forward = nil
  26552. delete(m.clearedFields, sopstage.FieldActionForward)
  26553. }
  26554. // SetIndexSort sets the "index_sort" field.
  26555. func (m *SopStageMutation) SetIndexSort(i int) {
  26556. m.index_sort = &i
  26557. m.addindex_sort = nil
  26558. }
  26559. // IndexSort returns the value of the "index_sort" field in the mutation.
  26560. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  26561. v := m.index_sort
  26562. if v == nil {
  26563. return
  26564. }
  26565. return *v, true
  26566. }
  26567. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  26568. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26569. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26570. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  26571. if !m.op.Is(OpUpdateOne) {
  26572. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  26573. }
  26574. if m.id == nil || m.oldValue == nil {
  26575. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  26576. }
  26577. oldValue, err := m.oldValue(ctx)
  26578. if err != nil {
  26579. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  26580. }
  26581. return oldValue.IndexSort, nil
  26582. }
  26583. // AddIndexSort adds i to the "index_sort" field.
  26584. func (m *SopStageMutation) AddIndexSort(i int) {
  26585. if m.addindex_sort != nil {
  26586. *m.addindex_sort += i
  26587. } else {
  26588. m.addindex_sort = &i
  26589. }
  26590. }
  26591. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  26592. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  26593. v := m.addindex_sort
  26594. if v == nil {
  26595. return
  26596. }
  26597. return *v, true
  26598. }
  26599. // ClearIndexSort clears the value of the "index_sort" field.
  26600. func (m *SopStageMutation) ClearIndexSort() {
  26601. m.index_sort = nil
  26602. m.addindex_sort = nil
  26603. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  26604. }
  26605. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  26606. func (m *SopStageMutation) IndexSortCleared() bool {
  26607. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  26608. return ok
  26609. }
  26610. // ResetIndexSort resets all changes to the "index_sort" field.
  26611. func (m *SopStageMutation) ResetIndexSort() {
  26612. m.index_sort = nil
  26613. m.addindex_sort = nil
  26614. delete(m.clearedFields, sopstage.FieldIndexSort)
  26615. }
  26616. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  26617. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  26618. m.sop_task = &id
  26619. }
  26620. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  26621. func (m *SopStageMutation) ClearSopTask() {
  26622. m.clearedsop_task = true
  26623. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  26624. }
  26625. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  26626. func (m *SopStageMutation) SopTaskCleared() bool {
  26627. return m.clearedsop_task
  26628. }
  26629. // SopTaskID returns the "sop_task" edge ID in the mutation.
  26630. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  26631. if m.sop_task != nil {
  26632. return *m.sop_task, true
  26633. }
  26634. return
  26635. }
  26636. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  26637. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  26638. // SopTaskID instead. It exists only for internal usage by the builders.
  26639. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  26640. if id := m.sop_task; id != nil {
  26641. ids = append(ids, *id)
  26642. }
  26643. return
  26644. }
  26645. // ResetSopTask resets all changes to the "sop_task" edge.
  26646. func (m *SopStageMutation) ResetSopTask() {
  26647. m.sop_task = nil
  26648. m.clearedsop_task = false
  26649. }
  26650. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  26651. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  26652. if m.stage_nodes == nil {
  26653. m.stage_nodes = make(map[uint64]struct{})
  26654. }
  26655. for i := range ids {
  26656. m.stage_nodes[ids[i]] = struct{}{}
  26657. }
  26658. }
  26659. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  26660. func (m *SopStageMutation) ClearStageNodes() {
  26661. m.clearedstage_nodes = true
  26662. }
  26663. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  26664. func (m *SopStageMutation) StageNodesCleared() bool {
  26665. return m.clearedstage_nodes
  26666. }
  26667. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  26668. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  26669. if m.removedstage_nodes == nil {
  26670. m.removedstage_nodes = make(map[uint64]struct{})
  26671. }
  26672. for i := range ids {
  26673. delete(m.stage_nodes, ids[i])
  26674. m.removedstage_nodes[ids[i]] = struct{}{}
  26675. }
  26676. }
  26677. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  26678. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  26679. for id := range m.removedstage_nodes {
  26680. ids = append(ids, id)
  26681. }
  26682. return
  26683. }
  26684. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  26685. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  26686. for id := range m.stage_nodes {
  26687. ids = append(ids, id)
  26688. }
  26689. return
  26690. }
  26691. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  26692. func (m *SopStageMutation) ResetStageNodes() {
  26693. m.stage_nodes = nil
  26694. m.clearedstage_nodes = false
  26695. m.removedstage_nodes = nil
  26696. }
  26697. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  26698. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  26699. if m.stage_messages == nil {
  26700. m.stage_messages = make(map[uint64]struct{})
  26701. }
  26702. for i := range ids {
  26703. m.stage_messages[ids[i]] = struct{}{}
  26704. }
  26705. }
  26706. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  26707. func (m *SopStageMutation) ClearStageMessages() {
  26708. m.clearedstage_messages = true
  26709. }
  26710. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  26711. func (m *SopStageMutation) StageMessagesCleared() bool {
  26712. return m.clearedstage_messages
  26713. }
  26714. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  26715. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  26716. if m.removedstage_messages == nil {
  26717. m.removedstage_messages = make(map[uint64]struct{})
  26718. }
  26719. for i := range ids {
  26720. delete(m.stage_messages, ids[i])
  26721. m.removedstage_messages[ids[i]] = struct{}{}
  26722. }
  26723. }
  26724. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  26725. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  26726. for id := range m.removedstage_messages {
  26727. ids = append(ids, id)
  26728. }
  26729. return
  26730. }
  26731. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  26732. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  26733. for id := range m.stage_messages {
  26734. ids = append(ids, id)
  26735. }
  26736. return
  26737. }
  26738. // ResetStageMessages resets all changes to the "stage_messages" edge.
  26739. func (m *SopStageMutation) ResetStageMessages() {
  26740. m.stage_messages = nil
  26741. m.clearedstage_messages = false
  26742. m.removedstage_messages = nil
  26743. }
  26744. // Where appends a list predicates to the SopStageMutation builder.
  26745. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  26746. m.predicates = append(m.predicates, ps...)
  26747. }
  26748. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  26749. // users can use type-assertion to append predicates that do not depend on any generated package.
  26750. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  26751. p := make([]predicate.SopStage, len(ps))
  26752. for i := range ps {
  26753. p[i] = ps[i]
  26754. }
  26755. m.Where(p...)
  26756. }
  26757. // Op returns the operation name.
  26758. func (m *SopStageMutation) Op() Op {
  26759. return m.op
  26760. }
  26761. // SetOp allows setting the mutation operation.
  26762. func (m *SopStageMutation) SetOp(op Op) {
  26763. m.op = op
  26764. }
  26765. // Type returns the node type of this mutation (SopStage).
  26766. func (m *SopStageMutation) Type() string {
  26767. return m.typ
  26768. }
  26769. // Fields returns all fields that were changed during this mutation. Note that in
  26770. // order to get all numeric fields that were incremented/decremented, call
  26771. // AddedFields().
  26772. func (m *SopStageMutation) Fields() []string {
  26773. fields := make([]string, 0, 14)
  26774. if m.created_at != nil {
  26775. fields = append(fields, sopstage.FieldCreatedAt)
  26776. }
  26777. if m.updated_at != nil {
  26778. fields = append(fields, sopstage.FieldUpdatedAt)
  26779. }
  26780. if m.status != nil {
  26781. fields = append(fields, sopstage.FieldStatus)
  26782. }
  26783. if m.deleted_at != nil {
  26784. fields = append(fields, sopstage.FieldDeletedAt)
  26785. }
  26786. if m.sop_task != nil {
  26787. fields = append(fields, sopstage.FieldTaskID)
  26788. }
  26789. if m.name != nil {
  26790. fields = append(fields, sopstage.FieldName)
  26791. }
  26792. if m.condition_type != nil {
  26793. fields = append(fields, sopstage.FieldConditionType)
  26794. }
  26795. if m.condition_operator != nil {
  26796. fields = append(fields, sopstage.FieldConditionOperator)
  26797. }
  26798. if m.condition_list != nil {
  26799. fields = append(fields, sopstage.FieldConditionList)
  26800. }
  26801. if m.action_message != nil {
  26802. fields = append(fields, sopstage.FieldActionMessage)
  26803. }
  26804. if m.action_label_add != nil {
  26805. fields = append(fields, sopstage.FieldActionLabelAdd)
  26806. }
  26807. if m.action_label_del != nil {
  26808. fields = append(fields, sopstage.FieldActionLabelDel)
  26809. }
  26810. if m.action_forward != nil {
  26811. fields = append(fields, sopstage.FieldActionForward)
  26812. }
  26813. if m.index_sort != nil {
  26814. fields = append(fields, sopstage.FieldIndexSort)
  26815. }
  26816. return fields
  26817. }
  26818. // Field returns the value of a field with the given name. The second boolean
  26819. // return value indicates that this field was not set, or was not defined in the
  26820. // schema.
  26821. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  26822. switch name {
  26823. case sopstage.FieldCreatedAt:
  26824. return m.CreatedAt()
  26825. case sopstage.FieldUpdatedAt:
  26826. return m.UpdatedAt()
  26827. case sopstage.FieldStatus:
  26828. return m.Status()
  26829. case sopstage.FieldDeletedAt:
  26830. return m.DeletedAt()
  26831. case sopstage.FieldTaskID:
  26832. return m.TaskID()
  26833. case sopstage.FieldName:
  26834. return m.Name()
  26835. case sopstage.FieldConditionType:
  26836. return m.ConditionType()
  26837. case sopstage.FieldConditionOperator:
  26838. return m.ConditionOperator()
  26839. case sopstage.FieldConditionList:
  26840. return m.ConditionList()
  26841. case sopstage.FieldActionMessage:
  26842. return m.ActionMessage()
  26843. case sopstage.FieldActionLabelAdd:
  26844. return m.ActionLabelAdd()
  26845. case sopstage.FieldActionLabelDel:
  26846. return m.ActionLabelDel()
  26847. case sopstage.FieldActionForward:
  26848. return m.ActionForward()
  26849. case sopstage.FieldIndexSort:
  26850. return m.IndexSort()
  26851. }
  26852. return nil, false
  26853. }
  26854. // OldField returns the old value of the field from the database. An error is
  26855. // returned if the mutation operation is not UpdateOne, or the query to the
  26856. // database failed.
  26857. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26858. switch name {
  26859. case sopstage.FieldCreatedAt:
  26860. return m.OldCreatedAt(ctx)
  26861. case sopstage.FieldUpdatedAt:
  26862. return m.OldUpdatedAt(ctx)
  26863. case sopstage.FieldStatus:
  26864. return m.OldStatus(ctx)
  26865. case sopstage.FieldDeletedAt:
  26866. return m.OldDeletedAt(ctx)
  26867. case sopstage.FieldTaskID:
  26868. return m.OldTaskID(ctx)
  26869. case sopstage.FieldName:
  26870. return m.OldName(ctx)
  26871. case sopstage.FieldConditionType:
  26872. return m.OldConditionType(ctx)
  26873. case sopstage.FieldConditionOperator:
  26874. return m.OldConditionOperator(ctx)
  26875. case sopstage.FieldConditionList:
  26876. return m.OldConditionList(ctx)
  26877. case sopstage.FieldActionMessage:
  26878. return m.OldActionMessage(ctx)
  26879. case sopstage.FieldActionLabelAdd:
  26880. return m.OldActionLabelAdd(ctx)
  26881. case sopstage.FieldActionLabelDel:
  26882. return m.OldActionLabelDel(ctx)
  26883. case sopstage.FieldActionForward:
  26884. return m.OldActionForward(ctx)
  26885. case sopstage.FieldIndexSort:
  26886. return m.OldIndexSort(ctx)
  26887. }
  26888. return nil, fmt.Errorf("unknown SopStage field %s", name)
  26889. }
  26890. // SetField sets the value of a field with the given name. It returns an error if
  26891. // the field is not defined in the schema, or if the type mismatched the field
  26892. // type.
  26893. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  26894. switch name {
  26895. case sopstage.FieldCreatedAt:
  26896. v, ok := value.(time.Time)
  26897. if !ok {
  26898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26899. }
  26900. m.SetCreatedAt(v)
  26901. return nil
  26902. case sopstage.FieldUpdatedAt:
  26903. v, ok := value.(time.Time)
  26904. if !ok {
  26905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26906. }
  26907. m.SetUpdatedAt(v)
  26908. return nil
  26909. case sopstage.FieldStatus:
  26910. v, ok := value.(uint8)
  26911. if !ok {
  26912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26913. }
  26914. m.SetStatus(v)
  26915. return nil
  26916. case sopstage.FieldDeletedAt:
  26917. v, ok := value.(time.Time)
  26918. if !ok {
  26919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26920. }
  26921. m.SetDeletedAt(v)
  26922. return nil
  26923. case sopstage.FieldTaskID:
  26924. v, ok := value.(uint64)
  26925. if !ok {
  26926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26927. }
  26928. m.SetTaskID(v)
  26929. return nil
  26930. case sopstage.FieldName:
  26931. v, ok := value.(string)
  26932. if !ok {
  26933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26934. }
  26935. m.SetName(v)
  26936. return nil
  26937. case sopstage.FieldConditionType:
  26938. v, ok := value.(int)
  26939. if !ok {
  26940. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26941. }
  26942. m.SetConditionType(v)
  26943. return nil
  26944. case sopstage.FieldConditionOperator:
  26945. v, ok := value.(int)
  26946. if !ok {
  26947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26948. }
  26949. m.SetConditionOperator(v)
  26950. return nil
  26951. case sopstage.FieldConditionList:
  26952. v, ok := value.([]custom_types.Condition)
  26953. if !ok {
  26954. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26955. }
  26956. m.SetConditionList(v)
  26957. return nil
  26958. case sopstage.FieldActionMessage:
  26959. v, ok := value.([]custom_types.Action)
  26960. if !ok {
  26961. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26962. }
  26963. m.SetActionMessage(v)
  26964. return nil
  26965. case sopstage.FieldActionLabelAdd:
  26966. v, ok := value.([]uint64)
  26967. if !ok {
  26968. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26969. }
  26970. m.SetActionLabelAdd(v)
  26971. return nil
  26972. case sopstage.FieldActionLabelDel:
  26973. v, ok := value.([]uint64)
  26974. if !ok {
  26975. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26976. }
  26977. m.SetActionLabelDel(v)
  26978. return nil
  26979. case sopstage.FieldActionForward:
  26980. v, ok := value.(*custom_types.ActionForward)
  26981. if !ok {
  26982. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26983. }
  26984. m.SetActionForward(v)
  26985. return nil
  26986. case sopstage.FieldIndexSort:
  26987. v, ok := value.(int)
  26988. if !ok {
  26989. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26990. }
  26991. m.SetIndexSort(v)
  26992. return nil
  26993. }
  26994. return fmt.Errorf("unknown SopStage field %s", name)
  26995. }
  26996. // AddedFields returns all numeric fields that were incremented/decremented during
  26997. // this mutation.
  26998. func (m *SopStageMutation) AddedFields() []string {
  26999. var fields []string
  27000. if m.addstatus != nil {
  27001. fields = append(fields, sopstage.FieldStatus)
  27002. }
  27003. if m.addcondition_type != nil {
  27004. fields = append(fields, sopstage.FieldConditionType)
  27005. }
  27006. if m.addcondition_operator != nil {
  27007. fields = append(fields, sopstage.FieldConditionOperator)
  27008. }
  27009. if m.addindex_sort != nil {
  27010. fields = append(fields, sopstage.FieldIndexSort)
  27011. }
  27012. return fields
  27013. }
  27014. // AddedField returns the numeric value that was incremented/decremented on a field
  27015. // with the given name. The second boolean return value indicates that this field
  27016. // was not set, or was not defined in the schema.
  27017. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  27018. switch name {
  27019. case sopstage.FieldStatus:
  27020. return m.AddedStatus()
  27021. case sopstage.FieldConditionType:
  27022. return m.AddedConditionType()
  27023. case sopstage.FieldConditionOperator:
  27024. return m.AddedConditionOperator()
  27025. case sopstage.FieldIndexSort:
  27026. return m.AddedIndexSort()
  27027. }
  27028. return nil, false
  27029. }
  27030. // AddField adds the value to the field with the given name. It returns an error if
  27031. // the field is not defined in the schema, or if the type mismatched the field
  27032. // type.
  27033. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  27034. switch name {
  27035. case sopstage.FieldStatus:
  27036. v, ok := value.(int8)
  27037. if !ok {
  27038. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27039. }
  27040. m.AddStatus(v)
  27041. return nil
  27042. case sopstage.FieldConditionType:
  27043. v, ok := value.(int)
  27044. if !ok {
  27045. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27046. }
  27047. m.AddConditionType(v)
  27048. return nil
  27049. case sopstage.FieldConditionOperator:
  27050. v, ok := value.(int)
  27051. if !ok {
  27052. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27053. }
  27054. m.AddConditionOperator(v)
  27055. return nil
  27056. case sopstage.FieldIndexSort:
  27057. v, ok := value.(int)
  27058. if !ok {
  27059. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27060. }
  27061. m.AddIndexSort(v)
  27062. return nil
  27063. }
  27064. return fmt.Errorf("unknown SopStage numeric field %s", name)
  27065. }
  27066. // ClearedFields returns all nullable fields that were cleared during this
  27067. // mutation.
  27068. func (m *SopStageMutation) ClearedFields() []string {
  27069. var fields []string
  27070. if m.FieldCleared(sopstage.FieldStatus) {
  27071. fields = append(fields, sopstage.FieldStatus)
  27072. }
  27073. if m.FieldCleared(sopstage.FieldDeletedAt) {
  27074. fields = append(fields, sopstage.FieldDeletedAt)
  27075. }
  27076. if m.FieldCleared(sopstage.FieldActionMessage) {
  27077. fields = append(fields, sopstage.FieldActionMessage)
  27078. }
  27079. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  27080. fields = append(fields, sopstage.FieldActionLabelAdd)
  27081. }
  27082. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  27083. fields = append(fields, sopstage.FieldActionLabelDel)
  27084. }
  27085. if m.FieldCleared(sopstage.FieldActionForward) {
  27086. fields = append(fields, sopstage.FieldActionForward)
  27087. }
  27088. if m.FieldCleared(sopstage.FieldIndexSort) {
  27089. fields = append(fields, sopstage.FieldIndexSort)
  27090. }
  27091. return fields
  27092. }
  27093. // FieldCleared returns a boolean indicating if a field with the given name was
  27094. // cleared in this mutation.
  27095. func (m *SopStageMutation) FieldCleared(name string) bool {
  27096. _, ok := m.clearedFields[name]
  27097. return ok
  27098. }
  27099. // ClearField clears the value of the field with the given name. It returns an
  27100. // error if the field is not defined in the schema.
  27101. func (m *SopStageMutation) ClearField(name string) error {
  27102. switch name {
  27103. case sopstage.FieldStatus:
  27104. m.ClearStatus()
  27105. return nil
  27106. case sopstage.FieldDeletedAt:
  27107. m.ClearDeletedAt()
  27108. return nil
  27109. case sopstage.FieldActionMessage:
  27110. m.ClearActionMessage()
  27111. return nil
  27112. case sopstage.FieldActionLabelAdd:
  27113. m.ClearActionLabelAdd()
  27114. return nil
  27115. case sopstage.FieldActionLabelDel:
  27116. m.ClearActionLabelDel()
  27117. return nil
  27118. case sopstage.FieldActionForward:
  27119. m.ClearActionForward()
  27120. return nil
  27121. case sopstage.FieldIndexSort:
  27122. m.ClearIndexSort()
  27123. return nil
  27124. }
  27125. return fmt.Errorf("unknown SopStage nullable field %s", name)
  27126. }
  27127. // ResetField resets all changes in the mutation for the field with the given name.
  27128. // It returns an error if the field is not defined in the schema.
  27129. func (m *SopStageMutation) ResetField(name string) error {
  27130. switch name {
  27131. case sopstage.FieldCreatedAt:
  27132. m.ResetCreatedAt()
  27133. return nil
  27134. case sopstage.FieldUpdatedAt:
  27135. m.ResetUpdatedAt()
  27136. return nil
  27137. case sopstage.FieldStatus:
  27138. m.ResetStatus()
  27139. return nil
  27140. case sopstage.FieldDeletedAt:
  27141. m.ResetDeletedAt()
  27142. return nil
  27143. case sopstage.FieldTaskID:
  27144. m.ResetTaskID()
  27145. return nil
  27146. case sopstage.FieldName:
  27147. m.ResetName()
  27148. return nil
  27149. case sopstage.FieldConditionType:
  27150. m.ResetConditionType()
  27151. return nil
  27152. case sopstage.FieldConditionOperator:
  27153. m.ResetConditionOperator()
  27154. return nil
  27155. case sopstage.FieldConditionList:
  27156. m.ResetConditionList()
  27157. return nil
  27158. case sopstage.FieldActionMessage:
  27159. m.ResetActionMessage()
  27160. return nil
  27161. case sopstage.FieldActionLabelAdd:
  27162. m.ResetActionLabelAdd()
  27163. return nil
  27164. case sopstage.FieldActionLabelDel:
  27165. m.ResetActionLabelDel()
  27166. return nil
  27167. case sopstage.FieldActionForward:
  27168. m.ResetActionForward()
  27169. return nil
  27170. case sopstage.FieldIndexSort:
  27171. m.ResetIndexSort()
  27172. return nil
  27173. }
  27174. return fmt.Errorf("unknown SopStage field %s", name)
  27175. }
  27176. // AddedEdges returns all edge names that were set/added in this mutation.
  27177. func (m *SopStageMutation) AddedEdges() []string {
  27178. edges := make([]string, 0, 3)
  27179. if m.sop_task != nil {
  27180. edges = append(edges, sopstage.EdgeSopTask)
  27181. }
  27182. if m.stage_nodes != nil {
  27183. edges = append(edges, sopstage.EdgeStageNodes)
  27184. }
  27185. if m.stage_messages != nil {
  27186. edges = append(edges, sopstage.EdgeStageMessages)
  27187. }
  27188. return edges
  27189. }
  27190. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27191. // name in this mutation.
  27192. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  27193. switch name {
  27194. case sopstage.EdgeSopTask:
  27195. if id := m.sop_task; id != nil {
  27196. return []ent.Value{*id}
  27197. }
  27198. case sopstage.EdgeStageNodes:
  27199. ids := make([]ent.Value, 0, len(m.stage_nodes))
  27200. for id := range m.stage_nodes {
  27201. ids = append(ids, id)
  27202. }
  27203. return ids
  27204. case sopstage.EdgeStageMessages:
  27205. ids := make([]ent.Value, 0, len(m.stage_messages))
  27206. for id := range m.stage_messages {
  27207. ids = append(ids, id)
  27208. }
  27209. return ids
  27210. }
  27211. return nil
  27212. }
  27213. // RemovedEdges returns all edge names that were removed in this mutation.
  27214. func (m *SopStageMutation) RemovedEdges() []string {
  27215. edges := make([]string, 0, 3)
  27216. if m.removedstage_nodes != nil {
  27217. edges = append(edges, sopstage.EdgeStageNodes)
  27218. }
  27219. if m.removedstage_messages != nil {
  27220. edges = append(edges, sopstage.EdgeStageMessages)
  27221. }
  27222. return edges
  27223. }
  27224. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27225. // the given name in this mutation.
  27226. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  27227. switch name {
  27228. case sopstage.EdgeStageNodes:
  27229. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  27230. for id := range m.removedstage_nodes {
  27231. ids = append(ids, id)
  27232. }
  27233. return ids
  27234. case sopstage.EdgeStageMessages:
  27235. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  27236. for id := range m.removedstage_messages {
  27237. ids = append(ids, id)
  27238. }
  27239. return ids
  27240. }
  27241. return nil
  27242. }
  27243. // ClearedEdges returns all edge names that were cleared in this mutation.
  27244. func (m *SopStageMutation) ClearedEdges() []string {
  27245. edges := make([]string, 0, 3)
  27246. if m.clearedsop_task {
  27247. edges = append(edges, sopstage.EdgeSopTask)
  27248. }
  27249. if m.clearedstage_nodes {
  27250. edges = append(edges, sopstage.EdgeStageNodes)
  27251. }
  27252. if m.clearedstage_messages {
  27253. edges = append(edges, sopstage.EdgeStageMessages)
  27254. }
  27255. return edges
  27256. }
  27257. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27258. // was cleared in this mutation.
  27259. func (m *SopStageMutation) EdgeCleared(name string) bool {
  27260. switch name {
  27261. case sopstage.EdgeSopTask:
  27262. return m.clearedsop_task
  27263. case sopstage.EdgeStageNodes:
  27264. return m.clearedstage_nodes
  27265. case sopstage.EdgeStageMessages:
  27266. return m.clearedstage_messages
  27267. }
  27268. return false
  27269. }
  27270. // ClearEdge clears the value of the edge with the given name. It returns an error
  27271. // if that edge is not defined in the schema.
  27272. func (m *SopStageMutation) ClearEdge(name string) error {
  27273. switch name {
  27274. case sopstage.EdgeSopTask:
  27275. m.ClearSopTask()
  27276. return nil
  27277. }
  27278. return fmt.Errorf("unknown SopStage unique edge %s", name)
  27279. }
  27280. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27281. // It returns an error if the edge is not defined in the schema.
  27282. func (m *SopStageMutation) ResetEdge(name string) error {
  27283. switch name {
  27284. case sopstage.EdgeSopTask:
  27285. m.ResetSopTask()
  27286. return nil
  27287. case sopstage.EdgeStageNodes:
  27288. m.ResetStageNodes()
  27289. return nil
  27290. case sopstage.EdgeStageMessages:
  27291. m.ResetStageMessages()
  27292. return nil
  27293. }
  27294. return fmt.Errorf("unknown SopStage edge %s", name)
  27295. }
  27296. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  27297. type SopTaskMutation struct {
  27298. config
  27299. op Op
  27300. typ string
  27301. id *uint64
  27302. created_at *time.Time
  27303. updated_at *time.Time
  27304. status *uint8
  27305. addstatus *int8
  27306. deleted_at *time.Time
  27307. name *string
  27308. bot_wxid_list *[]string
  27309. appendbot_wxid_list []string
  27310. _type *int
  27311. add_type *int
  27312. plan_start_time *time.Time
  27313. plan_end_time *time.Time
  27314. creator_id *string
  27315. organization_id *uint64
  27316. addorganization_id *int64
  27317. token *[]string
  27318. appendtoken []string
  27319. clearedFields map[string]struct{}
  27320. task_stages map[uint64]struct{}
  27321. removedtask_stages map[uint64]struct{}
  27322. clearedtask_stages bool
  27323. done bool
  27324. oldValue func(context.Context) (*SopTask, error)
  27325. predicates []predicate.SopTask
  27326. }
  27327. var _ ent.Mutation = (*SopTaskMutation)(nil)
  27328. // soptaskOption allows management of the mutation configuration using functional options.
  27329. type soptaskOption func(*SopTaskMutation)
  27330. // newSopTaskMutation creates new mutation for the SopTask entity.
  27331. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  27332. m := &SopTaskMutation{
  27333. config: c,
  27334. op: op,
  27335. typ: TypeSopTask,
  27336. clearedFields: make(map[string]struct{}),
  27337. }
  27338. for _, opt := range opts {
  27339. opt(m)
  27340. }
  27341. return m
  27342. }
  27343. // withSopTaskID sets the ID field of the mutation.
  27344. func withSopTaskID(id uint64) soptaskOption {
  27345. return func(m *SopTaskMutation) {
  27346. var (
  27347. err error
  27348. once sync.Once
  27349. value *SopTask
  27350. )
  27351. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  27352. once.Do(func() {
  27353. if m.done {
  27354. err = errors.New("querying old values post mutation is not allowed")
  27355. } else {
  27356. value, err = m.Client().SopTask.Get(ctx, id)
  27357. }
  27358. })
  27359. return value, err
  27360. }
  27361. m.id = &id
  27362. }
  27363. }
  27364. // withSopTask sets the old SopTask of the mutation.
  27365. func withSopTask(node *SopTask) soptaskOption {
  27366. return func(m *SopTaskMutation) {
  27367. m.oldValue = func(context.Context) (*SopTask, error) {
  27368. return node, nil
  27369. }
  27370. m.id = &node.ID
  27371. }
  27372. }
  27373. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27374. // executed in a transaction (ent.Tx), a transactional client is returned.
  27375. func (m SopTaskMutation) Client() *Client {
  27376. client := &Client{config: m.config}
  27377. client.init()
  27378. return client
  27379. }
  27380. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27381. // it returns an error otherwise.
  27382. func (m SopTaskMutation) Tx() (*Tx, error) {
  27383. if _, ok := m.driver.(*txDriver); !ok {
  27384. return nil, errors.New("ent: mutation is not running in a transaction")
  27385. }
  27386. tx := &Tx{config: m.config}
  27387. tx.init()
  27388. return tx, nil
  27389. }
  27390. // SetID sets the value of the id field. Note that this
  27391. // operation is only accepted on creation of SopTask entities.
  27392. func (m *SopTaskMutation) SetID(id uint64) {
  27393. m.id = &id
  27394. }
  27395. // ID returns the ID value in the mutation. Note that the ID is only available
  27396. // if it was provided to the builder or after it was returned from the database.
  27397. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  27398. if m.id == nil {
  27399. return
  27400. }
  27401. return *m.id, true
  27402. }
  27403. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27404. // That means, if the mutation is applied within a transaction with an isolation level such
  27405. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27406. // or updated by the mutation.
  27407. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  27408. switch {
  27409. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27410. id, exists := m.ID()
  27411. if exists {
  27412. return []uint64{id}, nil
  27413. }
  27414. fallthrough
  27415. case m.op.Is(OpUpdate | OpDelete):
  27416. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  27417. default:
  27418. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27419. }
  27420. }
  27421. // SetCreatedAt sets the "created_at" field.
  27422. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  27423. m.created_at = &t
  27424. }
  27425. // CreatedAt returns the value of the "created_at" field in the mutation.
  27426. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  27427. v := m.created_at
  27428. if v == nil {
  27429. return
  27430. }
  27431. return *v, true
  27432. }
  27433. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  27434. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27435. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27436. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27437. if !m.op.Is(OpUpdateOne) {
  27438. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27439. }
  27440. if m.id == nil || m.oldValue == nil {
  27441. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27442. }
  27443. oldValue, err := m.oldValue(ctx)
  27444. if err != nil {
  27445. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27446. }
  27447. return oldValue.CreatedAt, nil
  27448. }
  27449. // ResetCreatedAt resets all changes to the "created_at" field.
  27450. func (m *SopTaskMutation) ResetCreatedAt() {
  27451. m.created_at = nil
  27452. }
  27453. // SetUpdatedAt sets the "updated_at" field.
  27454. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  27455. m.updated_at = &t
  27456. }
  27457. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27458. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  27459. v := m.updated_at
  27460. if v == nil {
  27461. return
  27462. }
  27463. return *v, true
  27464. }
  27465. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  27466. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27467. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27468. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27469. if !m.op.Is(OpUpdateOne) {
  27470. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27471. }
  27472. if m.id == nil || m.oldValue == nil {
  27473. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27474. }
  27475. oldValue, err := m.oldValue(ctx)
  27476. if err != nil {
  27477. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27478. }
  27479. return oldValue.UpdatedAt, nil
  27480. }
  27481. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27482. func (m *SopTaskMutation) ResetUpdatedAt() {
  27483. m.updated_at = nil
  27484. }
  27485. // SetStatus sets the "status" field.
  27486. func (m *SopTaskMutation) SetStatus(u uint8) {
  27487. m.status = &u
  27488. m.addstatus = nil
  27489. }
  27490. // Status returns the value of the "status" field in the mutation.
  27491. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  27492. v := m.status
  27493. if v == nil {
  27494. return
  27495. }
  27496. return *v, true
  27497. }
  27498. // OldStatus returns the old "status" field's value of the SopTask entity.
  27499. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27500. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27501. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  27502. if !m.op.Is(OpUpdateOne) {
  27503. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  27504. }
  27505. if m.id == nil || m.oldValue == nil {
  27506. return v, errors.New("OldStatus requires an ID field in the mutation")
  27507. }
  27508. oldValue, err := m.oldValue(ctx)
  27509. if err != nil {
  27510. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  27511. }
  27512. return oldValue.Status, nil
  27513. }
  27514. // AddStatus adds u to the "status" field.
  27515. func (m *SopTaskMutation) AddStatus(u int8) {
  27516. if m.addstatus != nil {
  27517. *m.addstatus += u
  27518. } else {
  27519. m.addstatus = &u
  27520. }
  27521. }
  27522. // AddedStatus returns the value that was added to the "status" field in this mutation.
  27523. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  27524. v := m.addstatus
  27525. if v == nil {
  27526. return
  27527. }
  27528. return *v, true
  27529. }
  27530. // ClearStatus clears the value of the "status" field.
  27531. func (m *SopTaskMutation) ClearStatus() {
  27532. m.status = nil
  27533. m.addstatus = nil
  27534. m.clearedFields[soptask.FieldStatus] = struct{}{}
  27535. }
  27536. // StatusCleared returns if the "status" field was cleared in this mutation.
  27537. func (m *SopTaskMutation) StatusCleared() bool {
  27538. _, ok := m.clearedFields[soptask.FieldStatus]
  27539. return ok
  27540. }
  27541. // ResetStatus resets all changes to the "status" field.
  27542. func (m *SopTaskMutation) ResetStatus() {
  27543. m.status = nil
  27544. m.addstatus = nil
  27545. delete(m.clearedFields, soptask.FieldStatus)
  27546. }
  27547. // SetDeletedAt sets the "deleted_at" field.
  27548. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  27549. m.deleted_at = &t
  27550. }
  27551. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  27552. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  27553. v := m.deleted_at
  27554. if v == nil {
  27555. return
  27556. }
  27557. return *v, true
  27558. }
  27559. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  27560. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27561. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27562. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  27563. if !m.op.Is(OpUpdateOne) {
  27564. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  27565. }
  27566. if m.id == nil || m.oldValue == nil {
  27567. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  27568. }
  27569. oldValue, err := m.oldValue(ctx)
  27570. if err != nil {
  27571. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  27572. }
  27573. return oldValue.DeletedAt, nil
  27574. }
  27575. // ClearDeletedAt clears the value of the "deleted_at" field.
  27576. func (m *SopTaskMutation) ClearDeletedAt() {
  27577. m.deleted_at = nil
  27578. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  27579. }
  27580. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  27581. func (m *SopTaskMutation) DeletedAtCleared() bool {
  27582. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  27583. return ok
  27584. }
  27585. // ResetDeletedAt resets all changes to the "deleted_at" field.
  27586. func (m *SopTaskMutation) ResetDeletedAt() {
  27587. m.deleted_at = nil
  27588. delete(m.clearedFields, soptask.FieldDeletedAt)
  27589. }
  27590. // SetName sets the "name" field.
  27591. func (m *SopTaskMutation) SetName(s string) {
  27592. m.name = &s
  27593. }
  27594. // Name returns the value of the "name" field in the mutation.
  27595. func (m *SopTaskMutation) Name() (r string, exists bool) {
  27596. v := m.name
  27597. if v == nil {
  27598. return
  27599. }
  27600. return *v, true
  27601. }
  27602. // OldName returns the old "name" field's value of the SopTask entity.
  27603. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27604. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27605. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  27606. if !m.op.Is(OpUpdateOne) {
  27607. return v, errors.New("OldName is only allowed on UpdateOne operations")
  27608. }
  27609. if m.id == nil || m.oldValue == nil {
  27610. return v, errors.New("OldName requires an ID field in the mutation")
  27611. }
  27612. oldValue, err := m.oldValue(ctx)
  27613. if err != nil {
  27614. return v, fmt.Errorf("querying old value for OldName: %w", err)
  27615. }
  27616. return oldValue.Name, nil
  27617. }
  27618. // ResetName resets all changes to the "name" field.
  27619. func (m *SopTaskMutation) ResetName() {
  27620. m.name = nil
  27621. }
  27622. // SetBotWxidList sets the "bot_wxid_list" field.
  27623. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  27624. m.bot_wxid_list = &s
  27625. m.appendbot_wxid_list = nil
  27626. }
  27627. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  27628. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  27629. v := m.bot_wxid_list
  27630. if v == nil {
  27631. return
  27632. }
  27633. return *v, true
  27634. }
  27635. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  27636. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27637. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27638. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  27639. if !m.op.Is(OpUpdateOne) {
  27640. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  27641. }
  27642. if m.id == nil || m.oldValue == nil {
  27643. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  27644. }
  27645. oldValue, err := m.oldValue(ctx)
  27646. if err != nil {
  27647. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  27648. }
  27649. return oldValue.BotWxidList, nil
  27650. }
  27651. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  27652. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  27653. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  27654. }
  27655. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  27656. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  27657. if len(m.appendbot_wxid_list) == 0 {
  27658. return nil, false
  27659. }
  27660. return m.appendbot_wxid_list, true
  27661. }
  27662. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  27663. func (m *SopTaskMutation) ClearBotWxidList() {
  27664. m.bot_wxid_list = nil
  27665. m.appendbot_wxid_list = nil
  27666. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  27667. }
  27668. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  27669. func (m *SopTaskMutation) BotWxidListCleared() bool {
  27670. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  27671. return ok
  27672. }
  27673. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  27674. func (m *SopTaskMutation) ResetBotWxidList() {
  27675. m.bot_wxid_list = nil
  27676. m.appendbot_wxid_list = nil
  27677. delete(m.clearedFields, soptask.FieldBotWxidList)
  27678. }
  27679. // SetType sets the "type" field.
  27680. func (m *SopTaskMutation) SetType(i int) {
  27681. m._type = &i
  27682. m.add_type = nil
  27683. }
  27684. // GetType returns the value of the "type" field in the mutation.
  27685. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  27686. v := m._type
  27687. if v == nil {
  27688. return
  27689. }
  27690. return *v, true
  27691. }
  27692. // OldType returns the old "type" field's value of the SopTask entity.
  27693. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27694. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27695. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  27696. if !m.op.Is(OpUpdateOne) {
  27697. return v, errors.New("OldType is only allowed on UpdateOne operations")
  27698. }
  27699. if m.id == nil || m.oldValue == nil {
  27700. return v, errors.New("OldType requires an ID field in the mutation")
  27701. }
  27702. oldValue, err := m.oldValue(ctx)
  27703. if err != nil {
  27704. return v, fmt.Errorf("querying old value for OldType: %w", err)
  27705. }
  27706. return oldValue.Type, nil
  27707. }
  27708. // AddType adds i to the "type" field.
  27709. func (m *SopTaskMutation) AddType(i int) {
  27710. if m.add_type != nil {
  27711. *m.add_type += i
  27712. } else {
  27713. m.add_type = &i
  27714. }
  27715. }
  27716. // AddedType returns the value that was added to the "type" field in this mutation.
  27717. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  27718. v := m.add_type
  27719. if v == nil {
  27720. return
  27721. }
  27722. return *v, true
  27723. }
  27724. // ResetType resets all changes to the "type" field.
  27725. func (m *SopTaskMutation) ResetType() {
  27726. m._type = nil
  27727. m.add_type = nil
  27728. }
  27729. // SetPlanStartTime sets the "plan_start_time" field.
  27730. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  27731. m.plan_start_time = &t
  27732. }
  27733. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  27734. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  27735. v := m.plan_start_time
  27736. if v == nil {
  27737. return
  27738. }
  27739. return *v, true
  27740. }
  27741. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  27742. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27743. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27744. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  27745. if !m.op.Is(OpUpdateOne) {
  27746. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  27747. }
  27748. if m.id == nil || m.oldValue == nil {
  27749. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  27750. }
  27751. oldValue, err := m.oldValue(ctx)
  27752. if err != nil {
  27753. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  27754. }
  27755. return oldValue.PlanStartTime, nil
  27756. }
  27757. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  27758. func (m *SopTaskMutation) ClearPlanStartTime() {
  27759. m.plan_start_time = nil
  27760. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  27761. }
  27762. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  27763. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  27764. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  27765. return ok
  27766. }
  27767. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  27768. func (m *SopTaskMutation) ResetPlanStartTime() {
  27769. m.plan_start_time = nil
  27770. delete(m.clearedFields, soptask.FieldPlanStartTime)
  27771. }
  27772. // SetPlanEndTime sets the "plan_end_time" field.
  27773. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  27774. m.plan_end_time = &t
  27775. }
  27776. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  27777. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  27778. v := m.plan_end_time
  27779. if v == nil {
  27780. return
  27781. }
  27782. return *v, true
  27783. }
  27784. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  27785. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27786. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27787. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  27788. if !m.op.Is(OpUpdateOne) {
  27789. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  27790. }
  27791. if m.id == nil || m.oldValue == nil {
  27792. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  27793. }
  27794. oldValue, err := m.oldValue(ctx)
  27795. if err != nil {
  27796. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  27797. }
  27798. return oldValue.PlanEndTime, nil
  27799. }
  27800. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  27801. func (m *SopTaskMutation) ClearPlanEndTime() {
  27802. m.plan_end_time = nil
  27803. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  27804. }
  27805. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  27806. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  27807. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  27808. return ok
  27809. }
  27810. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  27811. func (m *SopTaskMutation) ResetPlanEndTime() {
  27812. m.plan_end_time = nil
  27813. delete(m.clearedFields, soptask.FieldPlanEndTime)
  27814. }
  27815. // SetCreatorID sets the "creator_id" field.
  27816. func (m *SopTaskMutation) SetCreatorID(s string) {
  27817. m.creator_id = &s
  27818. }
  27819. // CreatorID returns the value of the "creator_id" field in the mutation.
  27820. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  27821. v := m.creator_id
  27822. if v == nil {
  27823. return
  27824. }
  27825. return *v, true
  27826. }
  27827. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  27828. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27829. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27830. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  27831. if !m.op.Is(OpUpdateOne) {
  27832. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  27833. }
  27834. if m.id == nil || m.oldValue == nil {
  27835. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  27836. }
  27837. oldValue, err := m.oldValue(ctx)
  27838. if err != nil {
  27839. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  27840. }
  27841. return oldValue.CreatorID, nil
  27842. }
  27843. // ClearCreatorID clears the value of the "creator_id" field.
  27844. func (m *SopTaskMutation) ClearCreatorID() {
  27845. m.creator_id = nil
  27846. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  27847. }
  27848. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  27849. func (m *SopTaskMutation) CreatorIDCleared() bool {
  27850. _, ok := m.clearedFields[soptask.FieldCreatorID]
  27851. return ok
  27852. }
  27853. // ResetCreatorID resets all changes to the "creator_id" field.
  27854. func (m *SopTaskMutation) ResetCreatorID() {
  27855. m.creator_id = nil
  27856. delete(m.clearedFields, soptask.FieldCreatorID)
  27857. }
  27858. // SetOrganizationID sets the "organization_id" field.
  27859. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  27860. m.organization_id = &u
  27861. m.addorganization_id = nil
  27862. }
  27863. // OrganizationID returns the value of the "organization_id" field in the mutation.
  27864. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  27865. v := m.organization_id
  27866. if v == nil {
  27867. return
  27868. }
  27869. return *v, true
  27870. }
  27871. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  27872. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27873. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27874. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  27875. if !m.op.Is(OpUpdateOne) {
  27876. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  27877. }
  27878. if m.id == nil || m.oldValue == nil {
  27879. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  27880. }
  27881. oldValue, err := m.oldValue(ctx)
  27882. if err != nil {
  27883. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  27884. }
  27885. return oldValue.OrganizationID, nil
  27886. }
  27887. // AddOrganizationID adds u to the "organization_id" field.
  27888. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  27889. if m.addorganization_id != nil {
  27890. *m.addorganization_id += u
  27891. } else {
  27892. m.addorganization_id = &u
  27893. }
  27894. }
  27895. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  27896. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  27897. v := m.addorganization_id
  27898. if v == nil {
  27899. return
  27900. }
  27901. return *v, true
  27902. }
  27903. // ClearOrganizationID clears the value of the "organization_id" field.
  27904. func (m *SopTaskMutation) ClearOrganizationID() {
  27905. m.organization_id = nil
  27906. m.addorganization_id = nil
  27907. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  27908. }
  27909. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  27910. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  27911. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  27912. return ok
  27913. }
  27914. // ResetOrganizationID resets all changes to the "organization_id" field.
  27915. func (m *SopTaskMutation) ResetOrganizationID() {
  27916. m.organization_id = nil
  27917. m.addorganization_id = nil
  27918. delete(m.clearedFields, soptask.FieldOrganizationID)
  27919. }
  27920. // SetToken sets the "token" field.
  27921. func (m *SopTaskMutation) SetToken(s []string) {
  27922. m.token = &s
  27923. m.appendtoken = nil
  27924. }
  27925. // Token returns the value of the "token" field in the mutation.
  27926. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  27927. v := m.token
  27928. if v == nil {
  27929. return
  27930. }
  27931. return *v, true
  27932. }
  27933. // OldToken returns the old "token" field's value of the SopTask entity.
  27934. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27935. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27936. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  27937. if !m.op.Is(OpUpdateOne) {
  27938. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  27939. }
  27940. if m.id == nil || m.oldValue == nil {
  27941. return v, errors.New("OldToken requires an ID field in the mutation")
  27942. }
  27943. oldValue, err := m.oldValue(ctx)
  27944. if err != nil {
  27945. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  27946. }
  27947. return oldValue.Token, nil
  27948. }
  27949. // AppendToken adds s to the "token" field.
  27950. func (m *SopTaskMutation) AppendToken(s []string) {
  27951. m.appendtoken = append(m.appendtoken, s...)
  27952. }
  27953. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  27954. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  27955. if len(m.appendtoken) == 0 {
  27956. return nil, false
  27957. }
  27958. return m.appendtoken, true
  27959. }
  27960. // ClearToken clears the value of the "token" field.
  27961. func (m *SopTaskMutation) ClearToken() {
  27962. m.token = nil
  27963. m.appendtoken = nil
  27964. m.clearedFields[soptask.FieldToken] = struct{}{}
  27965. }
  27966. // TokenCleared returns if the "token" field was cleared in this mutation.
  27967. func (m *SopTaskMutation) TokenCleared() bool {
  27968. _, ok := m.clearedFields[soptask.FieldToken]
  27969. return ok
  27970. }
  27971. // ResetToken resets all changes to the "token" field.
  27972. func (m *SopTaskMutation) ResetToken() {
  27973. m.token = nil
  27974. m.appendtoken = nil
  27975. delete(m.clearedFields, soptask.FieldToken)
  27976. }
  27977. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  27978. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  27979. if m.task_stages == nil {
  27980. m.task_stages = make(map[uint64]struct{})
  27981. }
  27982. for i := range ids {
  27983. m.task_stages[ids[i]] = struct{}{}
  27984. }
  27985. }
  27986. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  27987. func (m *SopTaskMutation) ClearTaskStages() {
  27988. m.clearedtask_stages = true
  27989. }
  27990. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  27991. func (m *SopTaskMutation) TaskStagesCleared() bool {
  27992. return m.clearedtask_stages
  27993. }
  27994. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  27995. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  27996. if m.removedtask_stages == nil {
  27997. m.removedtask_stages = make(map[uint64]struct{})
  27998. }
  27999. for i := range ids {
  28000. delete(m.task_stages, ids[i])
  28001. m.removedtask_stages[ids[i]] = struct{}{}
  28002. }
  28003. }
  28004. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  28005. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  28006. for id := range m.removedtask_stages {
  28007. ids = append(ids, id)
  28008. }
  28009. return
  28010. }
  28011. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  28012. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  28013. for id := range m.task_stages {
  28014. ids = append(ids, id)
  28015. }
  28016. return
  28017. }
  28018. // ResetTaskStages resets all changes to the "task_stages" edge.
  28019. func (m *SopTaskMutation) ResetTaskStages() {
  28020. m.task_stages = nil
  28021. m.clearedtask_stages = false
  28022. m.removedtask_stages = nil
  28023. }
  28024. // Where appends a list predicates to the SopTaskMutation builder.
  28025. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  28026. m.predicates = append(m.predicates, ps...)
  28027. }
  28028. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  28029. // users can use type-assertion to append predicates that do not depend on any generated package.
  28030. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  28031. p := make([]predicate.SopTask, len(ps))
  28032. for i := range ps {
  28033. p[i] = ps[i]
  28034. }
  28035. m.Where(p...)
  28036. }
  28037. // Op returns the operation name.
  28038. func (m *SopTaskMutation) Op() Op {
  28039. return m.op
  28040. }
  28041. // SetOp allows setting the mutation operation.
  28042. func (m *SopTaskMutation) SetOp(op Op) {
  28043. m.op = op
  28044. }
  28045. // Type returns the node type of this mutation (SopTask).
  28046. func (m *SopTaskMutation) Type() string {
  28047. return m.typ
  28048. }
  28049. // Fields returns all fields that were changed during this mutation. Note that in
  28050. // order to get all numeric fields that were incremented/decremented, call
  28051. // AddedFields().
  28052. func (m *SopTaskMutation) Fields() []string {
  28053. fields := make([]string, 0, 12)
  28054. if m.created_at != nil {
  28055. fields = append(fields, soptask.FieldCreatedAt)
  28056. }
  28057. if m.updated_at != nil {
  28058. fields = append(fields, soptask.FieldUpdatedAt)
  28059. }
  28060. if m.status != nil {
  28061. fields = append(fields, soptask.FieldStatus)
  28062. }
  28063. if m.deleted_at != nil {
  28064. fields = append(fields, soptask.FieldDeletedAt)
  28065. }
  28066. if m.name != nil {
  28067. fields = append(fields, soptask.FieldName)
  28068. }
  28069. if m.bot_wxid_list != nil {
  28070. fields = append(fields, soptask.FieldBotWxidList)
  28071. }
  28072. if m._type != nil {
  28073. fields = append(fields, soptask.FieldType)
  28074. }
  28075. if m.plan_start_time != nil {
  28076. fields = append(fields, soptask.FieldPlanStartTime)
  28077. }
  28078. if m.plan_end_time != nil {
  28079. fields = append(fields, soptask.FieldPlanEndTime)
  28080. }
  28081. if m.creator_id != nil {
  28082. fields = append(fields, soptask.FieldCreatorID)
  28083. }
  28084. if m.organization_id != nil {
  28085. fields = append(fields, soptask.FieldOrganizationID)
  28086. }
  28087. if m.token != nil {
  28088. fields = append(fields, soptask.FieldToken)
  28089. }
  28090. return fields
  28091. }
  28092. // Field returns the value of a field with the given name. The second boolean
  28093. // return value indicates that this field was not set, or was not defined in the
  28094. // schema.
  28095. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  28096. switch name {
  28097. case soptask.FieldCreatedAt:
  28098. return m.CreatedAt()
  28099. case soptask.FieldUpdatedAt:
  28100. return m.UpdatedAt()
  28101. case soptask.FieldStatus:
  28102. return m.Status()
  28103. case soptask.FieldDeletedAt:
  28104. return m.DeletedAt()
  28105. case soptask.FieldName:
  28106. return m.Name()
  28107. case soptask.FieldBotWxidList:
  28108. return m.BotWxidList()
  28109. case soptask.FieldType:
  28110. return m.GetType()
  28111. case soptask.FieldPlanStartTime:
  28112. return m.PlanStartTime()
  28113. case soptask.FieldPlanEndTime:
  28114. return m.PlanEndTime()
  28115. case soptask.FieldCreatorID:
  28116. return m.CreatorID()
  28117. case soptask.FieldOrganizationID:
  28118. return m.OrganizationID()
  28119. case soptask.FieldToken:
  28120. return m.Token()
  28121. }
  28122. return nil, false
  28123. }
  28124. // OldField returns the old value of the field from the database. An error is
  28125. // returned if the mutation operation is not UpdateOne, or the query to the
  28126. // database failed.
  28127. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  28128. switch name {
  28129. case soptask.FieldCreatedAt:
  28130. return m.OldCreatedAt(ctx)
  28131. case soptask.FieldUpdatedAt:
  28132. return m.OldUpdatedAt(ctx)
  28133. case soptask.FieldStatus:
  28134. return m.OldStatus(ctx)
  28135. case soptask.FieldDeletedAt:
  28136. return m.OldDeletedAt(ctx)
  28137. case soptask.FieldName:
  28138. return m.OldName(ctx)
  28139. case soptask.FieldBotWxidList:
  28140. return m.OldBotWxidList(ctx)
  28141. case soptask.FieldType:
  28142. return m.OldType(ctx)
  28143. case soptask.FieldPlanStartTime:
  28144. return m.OldPlanStartTime(ctx)
  28145. case soptask.FieldPlanEndTime:
  28146. return m.OldPlanEndTime(ctx)
  28147. case soptask.FieldCreatorID:
  28148. return m.OldCreatorID(ctx)
  28149. case soptask.FieldOrganizationID:
  28150. return m.OldOrganizationID(ctx)
  28151. case soptask.FieldToken:
  28152. return m.OldToken(ctx)
  28153. }
  28154. return nil, fmt.Errorf("unknown SopTask field %s", name)
  28155. }
  28156. // SetField sets the value of a field with the given name. It returns an error if
  28157. // the field is not defined in the schema, or if the type mismatched the field
  28158. // type.
  28159. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  28160. switch name {
  28161. case soptask.FieldCreatedAt:
  28162. v, ok := value.(time.Time)
  28163. if !ok {
  28164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28165. }
  28166. m.SetCreatedAt(v)
  28167. return nil
  28168. case soptask.FieldUpdatedAt:
  28169. v, ok := value.(time.Time)
  28170. if !ok {
  28171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28172. }
  28173. m.SetUpdatedAt(v)
  28174. return nil
  28175. case soptask.FieldStatus:
  28176. v, ok := value.(uint8)
  28177. if !ok {
  28178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28179. }
  28180. m.SetStatus(v)
  28181. return nil
  28182. case soptask.FieldDeletedAt:
  28183. v, ok := value.(time.Time)
  28184. if !ok {
  28185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28186. }
  28187. m.SetDeletedAt(v)
  28188. return nil
  28189. case soptask.FieldName:
  28190. v, ok := value.(string)
  28191. if !ok {
  28192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28193. }
  28194. m.SetName(v)
  28195. return nil
  28196. case soptask.FieldBotWxidList:
  28197. v, ok := value.([]string)
  28198. if !ok {
  28199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28200. }
  28201. m.SetBotWxidList(v)
  28202. return nil
  28203. case soptask.FieldType:
  28204. v, ok := value.(int)
  28205. if !ok {
  28206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28207. }
  28208. m.SetType(v)
  28209. return nil
  28210. case soptask.FieldPlanStartTime:
  28211. v, ok := value.(time.Time)
  28212. if !ok {
  28213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28214. }
  28215. m.SetPlanStartTime(v)
  28216. return nil
  28217. case soptask.FieldPlanEndTime:
  28218. v, ok := value.(time.Time)
  28219. if !ok {
  28220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28221. }
  28222. m.SetPlanEndTime(v)
  28223. return nil
  28224. case soptask.FieldCreatorID:
  28225. v, ok := value.(string)
  28226. if !ok {
  28227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28228. }
  28229. m.SetCreatorID(v)
  28230. return nil
  28231. case soptask.FieldOrganizationID:
  28232. v, ok := value.(uint64)
  28233. if !ok {
  28234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28235. }
  28236. m.SetOrganizationID(v)
  28237. return nil
  28238. case soptask.FieldToken:
  28239. v, ok := value.([]string)
  28240. if !ok {
  28241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28242. }
  28243. m.SetToken(v)
  28244. return nil
  28245. }
  28246. return fmt.Errorf("unknown SopTask field %s", name)
  28247. }
  28248. // AddedFields returns all numeric fields that were incremented/decremented during
  28249. // this mutation.
  28250. func (m *SopTaskMutation) AddedFields() []string {
  28251. var fields []string
  28252. if m.addstatus != nil {
  28253. fields = append(fields, soptask.FieldStatus)
  28254. }
  28255. if m.add_type != nil {
  28256. fields = append(fields, soptask.FieldType)
  28257. }
  28258. if m.addorganization_id != nil {
  28259. fields = append(fields, soptask.FieldOrganizationID)
  28260. }
  28261. return fields
  28262. }
  28263. // AddedField returns the numeric value that was incremented/decremented on a field
  28264. // with the given name. The second boolean return value indicates that this field
  28265. // was not set, or was not defined in the schema.
  28266. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  28267. switch name {
  28268. case soptask.FieldStatus:
  28269. return m.AddedStatus()
  28270. case soptask.FieldType:
  28271. return m.AddedType()
  28272. case soptask.FieldOrganizationID:
  28273. return m.AddedOrganizationID()
  28274. }
  28275. return nil, false
  28276. }
  28277. // AddField adds the value to the field with the given name. It returns an error if
  28278. // the field is not defined in the schema, or if the type mismatched the field
  28279. // type.
  28280. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  28281. switch name {
  28282. case soptask.FieldStatus:
  28283. v, ok := value.(int8)
  28284. if !ok {
  28285. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28286. }
  28287. m.AddStatus(v)
  28288. return nil
  28289. case soptask.FieldType:
  28290. v, ok := value.(int)
  28291. if !ok {
  28292. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28293. }
  28294. m.AddType(v)
  28295. return nil
  28296. case soptask.FieldOrganizationID:
  28297. v, ok := value.(int64)
  28298. if !ok {
  28299. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28300. }
  28301. m.AddOrganizationID(v)
  28302. return nil
  28303. }
  28304. return fmt.Errorf("unknown SopTask numeric field %s", name)
  28305. }
  28306. // ClearedFields returns all nullable fields that were cleared during this
  28307. // mutation.
  28308. func (m *SopTaskMutation) ClearedFields() []string {
  28309. var fields []string
  28310. if m.FieldCleared(soptask.FieldStatus) {
  28311. fields = append(fields, soptask.FieldStatus)
  28312. }
  28313. if m.FieldCleared(soptask.FieldDeletedAt) {
  28314. fields = append(fields, soptask.FieldDeletedAt)
  28315. }
  28316. if m.FieldCleared(soptask.FieldBotWxidList) {
  28317. fields = append(fields, soptask.FieldBotWxidList)
  28318. }
  28319. if m.FieldCleared(soptask.FieldPlanStartTime) {
  28320. fields = append(fields, soptask.FieldPlanStartTime)
  28321. }
  28322. if m.FieldCleared(soptask.FieldPlanEndTime) {
  28323. fields = append(fields, soptask.FieldPlanEndTime)
  28324. }
  28325. if m.FieldCleared(soptask.FieldCreatorID) {
  28326. fields = append(fields, soptask.FieldCreatorID)
  28327. }
  28328. if m.FieldCleared(soptask.FieldOrganizationID) {
  28329. fields = append(fields, soptask.FieldOrganizationID)
  28330. }
  28331. if m.FieldCleared(soptask.FieldToken) {
  28332. fields = append(fields, soptask.FieldToken)
  28333. }
  28334. return fields
  28335. }
  28336. // FieldCleared returns a boolean indicating if a field with the given name was
  28337. // cleared in this mutation.
  28338. func (m *SopTaskMutation) FieldCleared(name string) bool {
  28339. _, ok := m.clearedFields[name]
  28340. return ok
  28341. }
  28342. // ClearField clears the value of the field with the given name. It returns an
  28343. // error if the field is not defined in the schema.
  28344. func (m *SopTaskMutation) ClearField(name string) error {
  28345. switch name {
  28346. case soptask.FieldStatus:
  28347. m.ClearStatus()
  28348. return nil
  28349. case soptask.FieldDeletedAt:
  28350. m.ClearDeletedAt()
  28351. return nil
  28352. case soptask.FieldBotWxidList:
  28353. m.ClearBotWxidList()
  28354. return nil
  28355. case soptask.FieldPlanStartTime:
  28356. m.ClearPlanStartTime()
  28357. return nil
  28358. case soptask.FieldPlanEndTime:
  28359. m.ClearPlanEndTime()
  28360. return nil
  28361. case soptask.FieldCreatorID:
  28362. m.ClearCreatorID()
  28363. return nil
  28364. case soptask.FieldOrganizationID:
  28365. m.ClearOrganizationID()
  28366. return nil
  28367. case soptask.FieldToken:
  28368. m.ClearToken()
  28369. return nil
  28370. }
  28371. return fmt.Errorf("unknown SopTask nullable field %s", name)
  28372. }
  28373. // ResetField resets all changes in the mutation for the field with the given name.
  28374. // It returns an error if the field is not defined in the schema.
  28375. func (m *SopTaskMutation) ResetField(name string) error {
  28376. switch name {
  28377. case soptask.FieldCreatedAt:
  28378. m.ResetCreatedAt()
  28379. return nil
  28380. case soptask.FieldUpdatedAt:
  28381. m.ResetUpdatedAt()
  28382. return nil
  28383. case soptask.FieldStatus:
  28384. m.ResetStatus()
  28385. return nil
  28386. case soptask.FieldDeletedAt:
  28387. m.ResetDeletedAt()
  28388. return nil
  28389. case soptask.FieldName:
  28390. m.ResetName()
  28391. return nil
  28392. case soptask.FieldBotWxidList:
  28393. m.ResetBotWxidList()
  28394. return nil
  28395. case soptask.FieldType:
  28396. m.ResetType()
  28397. return nil
  28398. case soptask.FieldPlanStartTime:
  28399. m.ResetPlanStartTime()
  28400. return nil
  28401. case soptask.FieldPlanEndTime:
  28402. m.ResetPlanEndTime()
  28403. return nil
  28404. case soptask.FieldCreatorID:
  28405. m.ResetCreatorID()
  28406. return nil
  28407. case soptask.FieldOrganizationID:
  28408. m.ResetOrganizationID()
  28409. return nil
  28410. case soptask.FieldToken:
  28411. m.ResetToken()
  28412. return nil
  28413. }
  28414. return fmt.Errorf("unknown SopTask field %s", name)
  28415. }
  28416. // AddedEdges returns all edge names that were set/added in this mutation.
  28417. func (m *SopTaskMutation) AddedEdges() []string {
  28418. edges := make([]string, 0, 1)
  28419. if m.task_stages != nil {
  28420. edges = append(edges, soptask.EdgeTaskStages)
  28421. }
  28422. return edges
  28423. }
  28424. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  28425. // name in this mutation.
  28426. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  28427. switch name {
  28428. case soptask.EdgeTaskStages:
  28429. ids := make([]ent.Value, 0, len(m.task_stages))
  28430. for id := range m.task_stages {
  28431. ids = append(ids, id)
  28432. }
  28433. return ids
  28434. }
  28435. return nil
  28436. }
  28437. // RemovedEdges returns all edge names that were removed in this mutation.
  28438. func (m *SopTaskMutation) RemovedEdges() []string {
  28439. edges := make([]string, 0, 1)
  28440. if m.removedtask_stages != nil {
  28441. edges = append(edges, soptask.EdgeTaskStages)
  28442. }
  28443. return edges
  28444. }
  28445. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  28446. // the given name in this mutation.
  28447. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  28448. switch name {
  28449. case soptask.EdgeTaskStages:
  28450. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  28451. for id := range m.removedtask_stages {
  28452. ids = append(ids, id)
  28453. }
  28454. return ids
  28455. }
  28456. return nil
  28457. }
  28458. // ClearedEdges returns all edge names that were cleared in this mutation.
  28459. func (m *SopTaskMutation) ClearedEdges() []string {
  28460. edges := make([]string, 0, 1)
  28461. if m.clearedtask_stages {
  28462. edges = append(edges, soptask.EdgeTaskStages)
  28463. }
  28464. return edges
  28465. }
  28466. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28467. // was cleared in this mutation.
  28468. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  28469. switch name {
  28470. case soptask.EdgeTaskStages:
  28471. return m.clearedtask_stages
  28472. }
  28473. return false
  28474. }
  28475. // ClearEdge clears the value of the edge with the given name. It returns an error
  28476. // if that edge is not defined in the schema.
  28477. func (m *SopTaskMutation) ClearEdge(name string) error {
  28478. switch name {
  28479. }
  28480. return fmt.Errorf("unknown SopTask unique edge %s", name)
  28481. }
  28482. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28483. // It returns an error if the edge is not defined in the schema.
  28484. func (m *SopTaskMutation) ResetEdge(name string) error {
  28485. switch name {
  28486. case soptask.EdgeTaskStages:
  28487. m.ResetTaskStages()
  28488. return nil
  28489. }
  28490. return fmt.Errorf("unknown SopTask edge %s", name)
  28491. }
  28492. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  28493. type TokenMutation struct {
  28494. config
  28495. op Op
  28496. typ string
  28497. id *uint64
  28498. created_at *time.Time
  28499. updated_at *time.Time
  28500. deleted_at *time.Time
  28501. expire_at *time.Time
  28502. token *string
  28503. mac *string
  28504. organization_id *uint64
  28505. addorganization_id *int64
  28506. custom_agent_base *string
  28507. custom_agent_key *string
  28508. openai_base *string
  28509. openai_key *string
  28510. clearedFields map[string]struct{}
  28511. agent *uint64
  28512. clearedagent bool
  28513. done bool
  28514. oldValue func(context.Context) (*Token, error)
  28515. predicates []predicate.Token
  28516. }
  28517. var _ ent.Mutation = (*TokenMutation)(nil)
  28518. // tokenOption allows management of the mutation configuration using functional options.
  28519. type tokenOption func(*TokenMutation)
  28520. // newTokenMutation creates new mutation for the Token entity.
  28521. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  28522. m := &TokenMutation{
  28523. config: c,
  28524. op: op,
  28525. typ: TypeToken,
  28526. clearedFields: make(map[string]struct{}),
  28527. }
  28528. for _, opt := range opts {
  28529. opt(m)
  28530. }
  28531. return m
  28532. }
  28533. // withTokenID sets the ID field of the mutation.
  28534. func withTokenID(id uint64) tokenOption {
  28535. return func(m *TokenMutation) {
  28536. var (
  28537. err error
  28538. once sync.Once
  28539. value *Token
  28540. )
  28541. m.oldValue = func(ctx context.Context) (*Token, error) {
  28542. once.Do(func() {
  28543. if m.done {
  28544. err = errors.New("querying old values post mutation is not allowed")
  28545. } else {
  28546. value, err = m.Client().Token.Get(ctx, id)
  28547. }
  28548. })
  28549. return value, err
  28550. }
  28551. m.id = &id
  28552. }
  28553. }
  28554. // withToken sets the old Token of the mutation.
  28555. func withToken(node *Token) tokenOption {
  28556. return func(m *TokenMutation) {
  28557. m.oldValue = func(context.Context) (*Token, error) {
  28558. return node, nil
  28559. }
  28560. m.id = &node.ID
  28561. }
  28562. }
  28563. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28564. // executed in a transaction (ent.Tx), a transactional client is returned.
  28565. func (m TokenMutation) Client() *Client {
  28566. client := &Client{config: m.config}
  28567. client.init()
  28568. return client
  28569. }
  28570. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28571. // it returns an error otherwise.
  28572. func (m TokenMutation) Tx() (*Tx, error) {
  28573. if _, ok := m.driver.(*txDriver); !ok {
  28574. return nil, errors.New("ent: mutation is not running in a transaction")
  28575. }
  28576. tx := &Tx{config: m.config}
  28577. tx.init()
  28578. return tx, nil
  28579. }
  28580. // SetID sets the value of the id field. Note that this
  28581. // operation is only accepted on creation of Token entities.
  28582. func (m *TokenMutation) SetID(id uint64) {
  28583. m.id = &id
  28584. }
  28585. // ID returns the ID value in the mutation. Note that the ID is only available
  28586. // if it was provided to the builder or after it was returned from the database.
  28587. func (m *TokenMutation) ID() (id uint64, exists bool) {
  28588. if m.id == nil {
  28589. return
  28590. }
  28591. return *m.id, true
  28592. }
  28593. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28594. // That means, if the mutation is applied within a transaction with an isolation level such
  28595. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28596. // or updated by the mutation.
  28597. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  28598. switch {
  28599. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28600. id, exists := m.ID()
  28601. if exists {
  28602. return []uint64{id}, nil
  28603. }
  28604. fallthrough
  28605. case m.op.Is(OpUpdate | OpDelete):
  28606. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  28607. default:
  28608. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28609. }
  28610. }
  28611. // SetCreatedAt sets the "created_at" field.
  28612. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  28613. m.created_at = &t
  28614. }
  28615. // CreatedAt returns the value of the "created_at" field in the mutation.
  28616. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  28617. v := m.created_at
  28618. if v == nil {
  28619. return
  28620. }
  28621. return *v, true
  28622. }
  28623. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  28624. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  28625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28626. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  28627. if !m.op.Is(OpUpdateOne) {
  28628. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  28629. }
  28630. if m.id == nil || m.oldValue == nil {
  28631. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  28632. }
  28633. oldValue, err := m.oldValue(ctx)
  28634. if err != nil {
  28635. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  28636. }
  28637. return oldValue.CreatedAt, nil
  28638. }
  28639. // ResetCreatedAt resets all changes to the "created_at" field.
  28640. func (m *TokenMutation) ResetCreatedAt() {
  28641. m.created_at = nil
  28642. }
  28643. // SetUpdatedAt sets the "updated_at" field.
  28644. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  28645. m.updated_at = &t
  28646. }
  28647. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  28648. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  28649. v := m.updated_at
  28650. if v == nil {
  28651. return
  28652. }
  28653. return *v, true
  28654. }
  28655. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  28656. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  28657. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28658. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  28659. if !m.op.Is(OpUpdateOne) {
  28660. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  28661. }
  28662. if m.id == nil || m.oldValue == nil {
  28663. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  28664. }
  28665. oldValue, err := m.oldValue(ctx)
  28666. if err != nil {
  28667. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  28668. }
  28669. return oldValue.UpdatedAt, nil
  28670. }
  28671. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28672. func (m *TokenMutation) ResetUpdatedAt() {
  28673. m.updated_at = nil
  28674. }
  28675. // SetDeletedAt sets the "deleted_at" field.
  28676. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  28677. m.deleted_at = &t
  28678. }
  28679. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  28680. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  28681. v := m.deleted_at
  28682. if v == nil {
  28683. return
  28684. }
  28685. return *v, true
  28686. }
  28687. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  28688. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  28689. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28690. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  28691. if !m.op.Is(OpUpdateOne) {
  28692. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  28693. }
  28694. if m.id == nil || m.oldValue == nil {
  28695. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  28696. }
  28697. oldValue, err := m.oldValue(ctx)
  28698. if err != nil {
  28699. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  28700. }
  28701. return oldValue.DeletedAt, nil
  28702. }
  28703. // ClearDeletedAt clears the value of the "deleted_at" field.
  28704. func (m *TokenMutation) ClearDeletedAt() {
  28705. m.deleted_at = nil
  28706. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  28707. }
  28708. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  28709. func (m *TokenMutation) DeletedAtCleared() bool {
  28710. _, ok := m.clearedFields[token.FieldDeletedAt]
  28711. return ok
  28712. }
  28713. // ResetDeletedAt resets all changes to the "deleted_at" field.
  28714. func (m *TokenMutation) ResetDeletedAt() {
  28715. m.deleted_at = nil
  28716. delete(m.clearedFields, token.FieldDeletedAt)
  28717. }
  28718. // SetExpireAt sets the "expire_at" field.
  28719. func (m *TokenMutation) SetExpireAt(t time.Time) {
  28720. m.expire_at = &t
  28721. }
  28722. // ExpireAt returns the value of the "expire_at" field in the mutation.
  28723. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  28724. v := m.expire_at
  28725. if v == nil {
  28726. return
  28727. }
  28728. return *v, true
  28729. }
  28730. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  28731. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  28732. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28733. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  28734. if !m.op.Is(OpUpdateOne) {
  28735. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  28736. }
  28737. if m.id == nil || m.oldValue == nil {
  28738. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  28739. }
  28740. oldValue, err := m.oldValue(ctx)
  28741. if err != nil {
  28742. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  28743. }
  28744. return oldValue.ExpireAt, nil
  28745. }
  28746. // ClearExpireAt clears the value of the "expire_at" field.
  28747. func (m *TokenMutation) ClearExpireAt() {
  28748. m.expire_at = nil
  28749. m.clearedFields[token.FieldExpireAt] = struct{}{}
  28750. }
  28751. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  28752. func (m *TokenMutation) ExpireAtCleared() bool {
  28753. _, ok := m.clearedFields[token.FieldExpireAt]
  28754. return ok
  28755. }
  28756. // ResetExpireAt resets all changes to the "expire_at" field.
  28757. func (m *TokenMutation) ResetExpireAt() {
  28758. m.expire_at = nil
  28759. delete(m.clearedFields, token.FieldExpireAt)
  28760. }
  28761. // SetToken sets the "token" field.
  28762. func (m *TokenMutation) SetToken(s string) {
  28763. m.token = &s
  28764. }
  28765. // Token returns the value of the "token" field in the mutation.
  28766. func (m *TokenMutation) Token() (r string, exists bool) {
  28767. v := m.token
  28768. if v == nil {
  28769. return
  28770. }
  28771. return *v, true
  28772. }
  28773. // OldToken returns the old "token" field's value of the Token entity.
  28774. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  28775. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28776. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  28777. if !m.op.Is(OpUpdateOne) {
  28778. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  28779. }
  28780. if m.id == nil || m.oldValue == nil {
  28781. return v, errors.New("OldToken requires an ID field in the mutation")
  28782. }
  28783. oldValue, err := m.oldValue(ctx)
  28784. if err != nil {
  28785. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  28786. }
  28787. return oldValue.Token, nil
  28788. }
  28789. // ClearToken clears the value of the "token" field.
  28790. func (m *TokenMutation) ClearToken() {
  28791. m.token = nil
  28792. m.clearedFields[token.FieldToken] = struct{}{}
  28793. }
  28794. // TokenCleared returns if the "token" field was cleared in this mutation.
  28795. func (m *TokenMutation) TokenCleared() bool {
  28796. _, ok := m.clearedFields[token.FieldToken]
  28797. return ok
  28798. }
  28799. // ResetToken resets all changes to the "token" field.
  28800. func (m *TokenMutation) ResetToken() {
  28801. m.token = nil
  28802. delete(m.clearedFields, token.FieldToken)
  28803. }
  28804. // SetMAC sets the "mac" field.
  28805. func (m *TokenMutation) SetMAC(s string) {
  28806. m.mac = &s
  28807. }
  28808. // MAC returns the value of the "mac" field in the mutation.
  28809. func (m *TokenMutation) MAC() (r string, exists bool) {
  28810. v := m.mac
  28811. if v == nil {
  28812. return
  28813. }
  28814. return *v, true
  28815. }
  28816. // OldMAC returns the old "mac" field's value of the Token entity.
  28817. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  28818. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28819. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  28820. if !m.op.Is(OpUpdateOne) {
  28821. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  28822. }
  28823. if m.id == nil || m.oldValue == nil {
  28824. return v, errors.New("OldMAC requires an ID field in the mutation")
  28825. }
  28826. oldValue, err := m.oldValue(ctx)
  28827. if err != nil {
  28828. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  28829. }
  28830. return oldValue.MAC, nil
  28831. }
  28832. // ClearMAC clears the value of the "mac" field.
  28833. func (m *TokenMutation) ClearMAC() {
  28834. m.mac = nil
  28835. m.clearedFields[token.FieldMAC] = struct{}{}
  28836. }
  28837. // MACCleared returns if the "mac" field was cleared in this mutation.
  28838. func (m *TokenMutation) MACCleared() bool {
  28839. _, ok := m.clearedFields[token.FieldMAC]
  28840. return ok
  28841. }
  28842. // ResetMAC resets all changes to the "mac" field.
  28843. func (m *TokenMutation) ResetMAC() {
  28844. m.mac = nil
  28845. delete(m.clearedFields, token.FieldMAC)
  28846. }
  28847. // SetOrganizationID sets the "organization_id" field.
  28848. func (m *TokenMutation) SetOrganizationID(u uint64) {
  28849. m.organization_id = &u
  28850. m.addorganization_id = nil
  28851. }
  28852. // OrganizationID returns the value of the "organization_id" field in the mutation.
  28853. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  28854. v := m.organization_id
  28855. if v == nil {
  28856. return
  28857. }
  28858. return *v, true
  28859. }
  28860. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  28861. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  28862. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28863. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  28864. if !m.op.Is(OpUpdateOne) {
  28865. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  28866. }
  28867. if m.id == nil || m.oldValue == nil {
  28868. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  28869. }
  28870. oldValue, err := m.oldValue(ctx)
  28871. if err != nil {
  28872. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  28873. }
  28874. return oldValue.OrganizationID, nil
  28875. }
  28876. // AddOrganizationID adds u to the "organization_id" field.
  28877. func (m *TokenMutation) AddOrganizationID(u int64) {
  28878. if m.addorganization_id != nil {
  28879. *m.addorganization_id += u
  28880. } else {
  28881. m.addorganization_id = &u
  28882. }
  28883. }
  28884. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  28885. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  28886. v := m.addorganization_id
  28887. if v == nil {
  28888. return
  28889. }
  28890. return *v, true
  28891. }
  28892. // ResetOrganizationID resets all changes to the "organization_id" field.
  28893. func (m *TokenMutation) ResetOrganizationID() {
  28894. m.organization_id = nil
  28895. m.addorganization_id = nil
  28896. }
  28897. // SetAgentID sets the "agent_id" field.
  28898. func (m *TokenMutation) SetAgentID(u uint64) {
  28899. m.agent = &u
  28900. }
  28901. // AgentID returns the value of the "agent_id" field in the mutation.
  28902. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  28903. v := m.agent
  28904. if v == nil {
  28905. return
  28906. }
  28907. return *v, true
  28908. }
  28909. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  28910. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  28911. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28912. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  28913. if !m.op.Is(OpUpdateOne) {
  28914. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  28915. }
  28916. if m.id == nil || m.oldValue == nil {
  28917. return v, errors.New("OldAgentID requires an ID field in the mutation")
  28918. }
  28919. oldValue, err := m.oldValue(ctx)
  28920. if err != nil {
  28921. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  28922. }
  28923. return oldValue.AgentID, nil
  28924. }
  28925. // ResetAgentID resets all changes to the "agent_id" field.
  28926. func (m *TokenMutation) ResetAgentID() {
  28927. m.agent = nil
  28928. }
  28929. // SetCustomAgentBase sets the "custom_agent_base" field.
  28930. func (m *TokenMutation) SetCustomAgentBase(s string) {
  28931. m.custom_agent_base = &s
  28932. }
  28933. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  28934. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  28935. v := m.custom_agent_base
  28936. if v == nil {
  28937. return
  28938. }
  28939. return *v, true
  28940. }
  28941. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  28942. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  28943. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28944. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  28945. if !m.op.Is(OpUpdateOne) {
  28946. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  28947. }
  28948. if m.id == nil || m.oldValue == nil {
  28949. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  28950. }
  28951. oldValue, err := m.oldValue(ctx)
  28952. if err != nil {
  28953. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  28954. }
  28955. return oldValue.CustomAgentBase, nil
  28956. }
  28957. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  28958. func (m *TokenMutation) ClearCustomAgentBase() {
  28959. m.custom_agent_base = nil
  28960. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  28961. }
  28962. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  28963. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  28964. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  28965. return ok
  28966. }
  28967. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  28968. func (m *TokenMutation) ResetCustomAgentBase() {
  28969. m.custom_agent_base = nil
  28970. delete(m.clearedFields, token.FieldCustomAgentBase)
  28971. }
  28972. // SetCustomAgentKey sets the "custom_agent_key" field.
  28973. func (m *TokenMutation) SetCustomAgentKey(s string) {
  28974. m.custom_agent_key = &s
  28975. }
  28976. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  28977. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  28978. v := m.custom_agent_key
  28979. if v == nil {
  28980. return
  28981. }
  28982. return *v, true
  28983. }
  28984. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  28985. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  28986. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28987. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  28988. if !m.op.Is(OpUpdateOne) {
  28989. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  28990. }
  28991. if m.id == nil || m.oldValue == nil {
  28992. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  28993. }
  28994. oldValue, err := m.oldValue(ctx)
  28995. if err != nil {
  28996. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  28997. }
  28998. return oldValue.CustomAgentKey, nil
  28999. }
  29000. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  29001. func (m *TokenMutation) ClearCustomAgentKey() {
  29002. m.custom_agent_key = nil
  29003. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  29004. }
  29005. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  29006. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  29007. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  29008. return ok
  29009. }
  29010. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  29011. func (m *TokenMutation) ResetCustomAgentKey() {
  29012. m.custom_agent_key = nil
  29013. delete(m.clearedFields, token.FieldCustomAgentKey)
  29014. }
  29015. // SetOpenaiBase sets the "openai_base" field.
  29016. func (m *TokenMutation) SetOpenaiBase(s string) {
  29017. m.openai_base = &s
  29018. }
  29019. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  29020. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  29021. v := m.openai_base
  29022. if v == nil {
  29023. return
  29024. }
  29025. return *v, true
  29026. }
  29027. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  29028. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29029. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29030. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  29031. if !m.op.Is(OpUpdateOne) {
  29032. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  29033. }
  29034. if m.id == nil || m.oldValue == nil {
  29035. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  29036. }
  29037. oldValue, err := m.oldValue(ctx)
  29038. if err != nil {
  29039. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  29040. }
  29041. return oldValue.OpenaiBase, nil
  29042. }
  29043. // ClearOpenaiBase clears the value of the "openai_base" field.
  29044. func (m *TokenMutation) ClearOpenaiBase() {
  29045. m.openai_base = nil
  29046. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  29047. }
  29048. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  29049. func (m *TokenMutation) OpenaiBaseCleared() bool {
  29050. _, ok := m.clearedFields[token.FieldOpenaiBase]
  29051. return ok
  29052. }
  29053. // ResetOpenaiBase resets all changes to the "openai_base" field.
  29054. func (m *TokenMutation) ResetOpenaiBase() {
  29055. m.openai_base = nil
  29056. delete(m.clearedFields, token.FieldOpenaiBase)
  29057. }
  29058. // SetOpenaiKey sets the "openai_key" field.
  29059. func (m *TokenMutation) SetOpenaiKey(s string) {
  29060. m.openai_key = &s
  29061. }
  29062. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  29063. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  29064. v := m.openai_key
  29065. if v == nil {
  29066. return
  29067. }
  29068. return *v, true
  29069. }
  29070. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  29071. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29072. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29073. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  29074. if !m.op.Is(OpUpdateOne) {
  29075. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  29076. }
  29077. if m.id == nil || m.oldValue == nil {
  29078. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  29079. }
  29080. oldValue, err := m.oldValue(ctx)
  29081. if err != nil {
  29082. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  29083. }
  29084. return oldValue.OpenaiKey, nil
  29085. }
  29086. // ClearOpenaiKey clears the value of the "openai_key" field.
  29087. func (m *TokenMutation) ClearOpenaiKey() {
  29088. m.openai_key = nil
  29089. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  29090. }
  29091. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  29092. func (m *TokenMutation) OpenaiKeyCleared() bool {
  29093. _, ok := m.clearedFields[token.FieldOpenaiKey]
  29094. return ok
  29095. }
  29096. // ResetOpenaiKey resets all changes to the "openai_key" field.
  29097. func (m *TokenMutation) ResetOpenaiKey() {
  29098. m.openai_key = nil
  29099. delete(m.clearedFields, token.FieldOpenaiKey)
  29100. }
  29101. // ClearAgent clears the "agent" edge to the Agent entity.
  29102. func (m *TokenMutation) ClearAgent() {
  29103. m.clearedagent = true
  29104. m.clearedFields[token.FieldAgentID] = struct{}{}
  29105. }
  29106. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  29107. func (m *TokenMutation) AgentCleared() bool {
  29108. return m.clearedagent
  29109. }
  29110. // AgentIDs returns the "agent" edge IDs in the mutation.
  29111. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  29112. // AgentID instead. It exists only for internal usage by the builders.
  29113. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  29114. if id := m.agent; id != nil {
  29115. ids = append(ids, *id)
  29116. }
  29117. return
  29118. }
  29119. // ResetAgent resets all changes to the "agent" edge.
  29120. func (m *TokenMutation) ResetAgent() {
  29121. m.agent = nil
  29122. m.clearedagent = false
  29123. }
  29124. // Where appends a list predicates to the TokenMutation builder.
  29125. func (m *TokenMutation) Where(ps ...predicate.Token) {
  29126. m.predicates = append(m.predicates, ps...)
  29127. }
  29128. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  29129. // users can use type-assertion to append predicates that do not depend on any generated package.
  29130. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  29131. p := make([]predicate.Token, len(ps))
  29132. for i := range ps {
  29133. p[i] = ps[i]
  29134. }
  29135. m.Where(p...)
  29136. }
  29137. // Op returns the operation name.
  29138. func (m *TokenMutation) Op() Op {
  29139. return m.op
  29140. }
  29141. // SetOp allows setting the mutation operation.
  29142. func (m *TokenMutation) SetOp(op Op) {
  29143. m.op = op
  29144. }
  29145. // Type returns the node type of this mutation (Token).
  29146. func (m *TokenMutation) Type() string {
  29147. return m.typ
  29148. }
  29149. // Fields returns all fields that were changed during this mutation. Note that in
  29150. // order to get all numeric fields that were incremented/decremented, call
  29151. // AddedFields().
  29152. func (m *TokenMutation) Fields() []string {
  29153. fields := make([]string, 0, 12)
  29154. if m.created_at != nil {
  29155. fields = append(fields, token.FieldCreatedAt)
  29156. }
  29157. if m.updated_at != nil {
  29158. fields = append(fields, token.FieldUpdatedAt)
  29159. }
  29160. if m.deleted_at != nil {
  29161. fields = append(fields, token.FieldDeletedAt)
  29162. }
  29163. if m.expire_at != nil {
  29164. fields = append(fields, token.FieldExpireAt)
  29165. }
  29166. if m.token != nil {
  29167. fields = append(fields, token.FieldToken)
  29168. }
  29169. if m.mac != nil {
  29170. fields = append(fields, token.FieldMAC)
  29171. }
  29172. if m.organization_id != nil {
  29173. fields = append(fields, token.FieldOrganizationID)
  29174. }
  29175. if m.agent != nil {
  29176. fields = append(fields, token.FieldAgentID)
  29177. }
  29178. if m.custom_agent_base != nil {
  29179. fields = append(fields, token.FieldCustomAgentBase)
  29180. }
  29181. if m.custom_agent_key != nil {
  29182. fields = append(fields, token.FieldCustomAgentKey)
  29183. }
  29184. if m.openai_base != nil {
  29185. fields = append(fields, token.FieldOpenaiBase)
  29186. }
  29187. if m.openai_key != nil {
  29188. fields = append(fields, token.FieldOpenaiKey)
  29189. }
  29190. return fields
  29191. }
  29192. // Field returns the value of a field with the given name. The second boolean
  29193. // return value indicates that this field was not set, or was not defined in the
  29194. // schema.
  29195. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  29196. switch name {
  29197. case token.FieldCreatedAt:
  29198. return m.CreatedAt()
  29199. case token.FieldUpdatedAt:
  29200. return m.UpdatedAt()
  29201. case token.FieldDeletedAt:
  29202. return m.DeletedAt()
  29203. case token.FieldExpireAt:
  29204. return m.ExpireAt()
  29205. case token.FieldToken:
  29206. return m.Token()
  29207. case token.FieldMAC:
  29208. return m.MAC()
  29209. case token.FieldOrganizationID:
  29210. return m.OrganizationID()
  29211. case token.FieldAgentID:
  29212. return m.AgentID()
  29213. case token.FieldCustomAgentBase:
  29214. return m.CustomAgentBase()
  29215. case token.FieldCustomAgentKey:
  29216. return m.CustomAgentKey()
  29217. case token.FieldOpenaiBase:
  29218. return m.OpenaiBase()
  29219. case token.FieldOpenaiKey:
  29220. return m.OpenaiKey()
  29221. }
  29222. return nil, false
  29223. }
  29224. // OldField returns the old value of the field from the database. An error is
  29225. // returned if the mutation operation is not UpdateOne, or the query to the
  29226. // database failed.
  29227. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29228. switch name {
  29229. case token.FieldCreatedAt:
  29230. return m.OldCreatedAt(ctx)
  29231. case token.FieldUpdatedAt:
  29232. return m.OldUpdatedAt(ctx)
  29233. case token.FieldDeletedAt:
  29234. return m.OldDeletedAt(ctx)
  29235. case token.FieldExpireAt:
  29236. return m.OldExpireAt(ctx)
  29237. case token.FieldToken:
  29238. return m.OldToken(ctx)
  29239. case token.FieldMAC:
  29240. return m.OldMAC(ctx)
  29241. case token.FieldOrganizationID:
  29242. return m.OldOrganizationID(ctx)
  29243. case token.FieldAgentID:
  29244. return m.OldAgentID(ctx)
  29245. case token.FieldCustomAgentBase:
  29246. return m.OldCustomAgentBase(ctx)
  29247. case token.FieldCustomAgentKey:
  29248. return m.OldCustomAgentKey(ctx)
  29249. case token.FieldOpenaiBase:
  29250. return m.OldOpenaiBase(ctx)
  29251. case token.FieldOpenaiKey:
  29252. return m.OldOpenaiKey(ctx)
  29253. }
  29254. return nil, fmt.Errorf("unknown Token field %s", name)
  29255. }
  29256. // SetField sets the value of a field with the given name. It returns an error if
  29257. // the field is not defined in the schema, or if the type mismatched the field
  29258. // type.
  29259. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  29260. switch name {
  29261. case token.FieldCreatedAt:
  29262. v, ok := value.(time.Time)
  29263. if !ok {
  29264. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29265. }
  29266. m.SetCreatedAt(v)
  29267. return nil
  29268. case token.FieldUpdatedAt:
  29269. v, ok := value.(time.Time)
  29270. if !ok {
  29271. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29272. }
  29273. m.SetUpdatedAt(v)
  29274. return nil
  29275. case token.FieldDeletedAt:
  29276. v, ok := value.(time.Time)
  29277. if !ok {
  29278. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29279. }
  29280. m.SetDeletedAt(v)
  29281. return nil
  29282. case token.FieldExpireAt:
  29283. v, ok := value.(time.Time)
  29284. if !ok {
  29285. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29286. }
  29287. m.SetExpireAt(v)
  29288. return nil
  29289. case token.FieldToken:
  29290. v, ok := value.(string)
  29291. if !ok {
  29292. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29293. }
  29294. m.SetToken(v)
  29295. return nil
  29296. case token.FieldMAC:
  29297. v, ok := value.(string)
  29298. if !ok {
  29299. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29300. }
  29301. m.SetMAC(v)
  29302. return nil
  29303. case token.FieldOrganizationID:
  29304. v, ok := value.(uint64)
  29305. if !ok {
  29306. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29307. }
  29308. m.SetOrganizationID(v)
  29309. return nil
  29310. case token.FieldAgentID:
  29311. v, ok := value.(uint64)
  29312. if !ok {
  29313. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29314. }
  29315. m.SetAgentID(v)
  29316. return nil
  29317. case token.FieldCustomAgentBase:
  29318. v, ok := value.(string)
  29319. if !ok {
  29320. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29321. }
  29322. m.SetCustomAgentBase(v)
  29323. return nil
  29324. case token.FieldCustomAgentKey:
  29325. v, ok := value.(string)
  29326. if !ok {
  29327. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29328. }
  29329. m.SetCustomAgentKey(v)
  29330. return nil
  29331. case token.FieldOpenaiBase:
  29332. v, ok := value.(string)
  29333. if !ok {
  29334. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29335. }
  29336. m.SetOpenaiBase(v)
  29337. return nil
  29338. case token.FieldOpenaiKey:
  29339. v, ok := value.(string)
  29340. if !ok {
  29341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29342. }
  29343. m.SetOpenaiKey(v)
  29344. return nil
  29345. }
  29346. return fmt.Errorf("unknown Token field %s", name)
  29347. }
  29348. // AddedFields returns all numeric fields that were incremented/decremented during
  29349. // this mutation.
  29350. func (m *TokenMutation) AddedFields() []string {
  29351. var fields []string
  29352. if m.addorganization_id != nil {
  29353. fields = append(fields, token.FieldOrganizationID)
  29354. }
  29355. return fields
  29356. }
  29357. // AddedField returns the numeric value that was incremented/decremented on a field
  29358. // with the given name. The second boolean return value indicates that this field
  29359. // was not set, or was not defined in the schema.
  29360. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  29361. switch name {
  29362. case token.FieldOrganizationID:
  29363. return m.AddedOrganizationID()
  29364. }
  29365. return nil, false
  29366. }
  29367. // AddField adds the value to the field with the given name. It returns an error if
  29368. // the field is not defined in the schema, or if the type mismatched the field
  29369. // type.
  29370. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  29371. switch name {
  29372. case token.FieldOrganizationID:
  29373. v, ok := value.(int64)
  29374. if !ok {
  29375. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29376. }
  29377. m.AddOrganizationID(v)
  29378. return nil
  29379. }
  29380. return fmt.Errorf("unknown Token numeric field %s", name)
  29381. }
  29382. // ClearedFields returns all nullable fields that were cleared during this
  29383. // mutation.
  29384. func (m *TokenMutation) ClearedFields() []string {
  29385. var fields []string
  29386. if m.FieldCleared(token.FieldDeletedAt) {
  29387. fields = append(fields, token.FieldDeletedAt)
  29388. }
  29389. if m.FieldCleared(token.FieldExpireAt) {
  29390. fields = append(fields, token.FieldExpireAt)
  29391. }
  29392. if m.FieldCleared(token.FieldToken) {
  29393. fields = append(fields, token.FieldToken)
  29394. }
  29395. if m.FieldCleared(token.FieldMAC) {
  29396. fields = append(fields, token.FieldMAC)
  29397. }
  29398. if m.FieldCleared(token.FieldCustomAgentBase) {
  29399. fields = append(fields, token.FieldCustomAgentBase)
  29400. }
  29401. if m.FieldCleared(token.FieldCustomAgentKey) {
  29402. fields = append(fields, token.FieldCustomAgentKey)
  29403. }
  29404. if m.FieldCleared(token.FieldOpenaiBase) {
  29405. fields = append(fields, token.FieldOpenaiBase)
  29406. }
  29407. if m.FieldCleared(token.FieldOpenaiKey) {
  29408. fields = append(fields, token.FieldOpenaiKey)
  29409. }
  29410. return fields
  29411. }
  29412. // FieldCleared returns a boolean indicating if a field with the given name was
  29413. // cleared in this mutation.
  29414. func (m *TokenMutation) FieldCleared(name string) bool {
  29415. _, ok := m.clearedFields[name]
  29416. return ok
  29417. }
  29418. // ClearField clears the value of the field with the given name. It returns an
  29419. // error if the field is not defined in the schema.
  29420. func (m *TokenMutation) ClearField(name string) error {
  29421. switch name {
  29422. case token.FieldDeletedAt:
  29423. m.ClearDeletedAt()
  29424. return nil
  29425. case token.FieldExpireAt:
  29426. m.ClearExpireAt()
  29427. return nil
  29428. case token.FieldToken:
  29429. m.ClearToken()
  29430. return nil
  29431. case token.FieldMAC:
  29432. m.ClearMAC()
  29433. return nil
  29434. case token.FieldCustomAgentBase:
  29435. m.ClearCustomAgentBase()
  29436. return nil
  29437. case token.FieldCustomAgentKey:
  29438. m.ClearCustomAgentKey()
  29439. return nil
  29440. case token.FieldOpenaiBase:
  29441. m.ClearOpenaiBase()
  29442. return nil
  29443. case token.FieldOpenaiKey:
  29444. m.ClearOpenaiKey()
  29445. return nil
  29446. }
  29447. return fmt.Errorf("unknown Token nullable field %s", name)
  29448. }
  29449. // ResetField resets all changes in the mutation for the field with the given name.
  29450. // It returns an error if the field is not defined in the schema.
  29451. func (m *TokenMutation) ResetField(name string) error {
  29452. switch name {
  29453. case token.FieldCreatedAt:
  29454. m.ResetCreatedAt()
  29455. return nil
  29456. case token.FieldUpdatedAt:
  29457. m.ResetUpdatedAt()
  29458. return nil
  29459. case token.FieldDeletedAt:
  29460. m.ResetDeletedAt()
  29461. return nil
  29462. case token.FieldExpireAt:
  29463. m.ResetExpireAt()
  29464. return nil
  29465. case token.FieldToken:
  29466. m.ResetToken()
  29467. return nil
  29468. case token.FieldMAC:
  29469. m.ResetMAC()
  29470. return nil
  29471. case token.FieldOrganizationID:
  29472. m.ResetOrganizationID()
  29473. return nil
  29474. case token.FieldAgentID:
  29475. m.ResetAgentID()
  29476. return nil
  29477. case token.FieldCustomAgentBase:
  29478. m.ResetCustomAgentBase()
  29479. return nil
  29480. case token.FieldCustomAgentKey:
  29481. m.ResetCustomAgentKey()
  29482. return nil
  29483. case token.FieldOpenaiBase:
  29484. m.ResetOpenaiBase()
  29485. return nil
  29486. case token.FieldOpenaiKey:
  29487. m.ResetOpenaiKey()
  29488. return nil
  29489. }
  29490. return fmt.Errorf("unknown Token field %s", name)
  29491. }
  29492. // AddedEdges returns all edge names that were set/added in this mutation.
  29493. func (m *TokenMutation) AddedEdges() []string {
  29494. edges := make([]string, 0, 1)
  29495. if m.agent != nil {
  29496. edges = append(edges, token.EdgeAgent)
  29497. }
  29498. return edges
  29499. }
  29500. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29501. // name in this mutation.
  29502. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  29503. switch name {
  29504. case token.EdgeAgent:
  29505. if id := m.agent; id != nil {
  29506. return []ent.Value{*id}
  29507. }
  29508. }
  29509. return nil
  29510. }
  29511. // RemovedEdges returns all edge names that were removed in this mutation.
  29512. func (m *TokenMutation) RemovedEdges() []string {
  29513. edges := make([]string, 0, 1)
  29514. return edges
  29515. }
  29516. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29517. // the given name in this mutation.
  29518. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  29519. return nil
  29520. }
  29521. // ClearedEdges returns all edge names that were cleared in this mutation.
  29522. func (m *TokenMutation) ClearedEdges() []string {
  29523. edges := make([]string, 0, 1)
  29524. if m.clearedagent {
  29525. edges = append(edges, token.EdgeAgent)
  29526. }
  29527. return edges
  29528. }
  29529. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29530. // was cleared in this mutation.
  29531. func (m *TokenMutation) EdgeCleared(name string) bool {
  29532. switch name {
  29533. case token.EdgeAgent:
  29534. return m.clearedagent
  29535. }
  29536. return false
  29537. }
  29538. // ClearEdge clears the value of the edge with the given name. It returns an error
  29539. // if that edge is not defined in the schema.
  29540. func (m *TokenMutation) ClearEdge(name string) error {
  29541. switch name {
  29542. case token.EdgeAgent:
  29543. m.ClearAgent()
  29544. return nil
  29545. }
  29546. return fmt.Errorf("unknown Token unique edge %s", name)
  29547. }
  29548. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29549. // It returns an error if the edge is not defined in the schema.
  29550. func (m *TokenMutation) ResetEdge(name string) error {
  29551. switch name {
  29552. case token.EdgeAgent:
  29553. m.ResetAgent()
  29554. return nil
  29555. }
  29556. return fmt.Errorf("unknown Token edge %s", name)
  29557. }
  29558. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  29559. type TutorialMutation struct {
  29560. config
  29561. op Op
  29562. typ string
  29563. id *uint64
  29564. created_at *time.Time
  29565. updated_at *time.Time
  29566. deleted_at *time.Time
  29567. index *int
  29568. addindex *int
  29569. title *string
  29570. content *string
  29571. organization_id *uint64
  29572. addorganization_id *int64
  29573. clearedFields map[string]struct{}
  29574. employee *uint64
  29575. clearedemployee bool
  29576. done bool
  29577. oldValue func(context.Context) (*Tutorial, error)
  29578. predicates []predicate.Tutorial
  29579. }
  29580. var _ ent.Mutation = (*TutorialMutation)(nil)
  29581. // tutorialOption allows management of the mutation configuration using functional options.
  29582. type tutorialOption func(*TutorialMutation)
  29583. // newTutorialMutation creates new mutation for the Tutorial entity.
  29584. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  29585. m := &TutorialMutation{
  29586. config: c,
  29587. op: op,
  29588. typ: TypeTutorial,
  29589. clearedFields: make(map[string]struct{}),
  29590. }
  29591. for _, opt := range opts {
  29592. opt(m)
  29593. }
  29594. return m
  29595. }
  29596. // withTutorialID sets the ID field of the mutation.
  29597. func withTutorialID(id uint64) tutorialOption {
  29598. return func(m *TutorialMutation) {
  29599. var (
  29600. err error
  29601. once sync.Once
  29602. value *Tutorial
  29603. )
  29604. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  29605. once.Do(func() {
  29606. if m.done {
  29607. err = errors.New("querying old values post mutation is not allowed")
  29608. } else {
  29609. value, err = m.Client().Tutorial.Get(ctx, id)
  29610. }
  29611. })
  29612. return value, err
  29613. }
  29614. m.id = &id
  29615. }
  29616. }
  29617. // withTutorial sets the old Tutorial of the mutation.
  29618. func withTutorial(node *Tutorial) tutorialOption {
  29619. return func(m *TutorialMutation) {
  29620. m.oldValue = func(context.Context) (*Tutorial, error) {
  29621. return node, nil
  29622. }
  29623. m.id = &node.ID
  29624. }
  29625. }
  29626. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29627. // executed in a transaction (ent.Tx), a transactional client is returned.
  29628. func (m TutorialMutation) Client() *Client {
  29629. client := &Client{config: m.config}
  29630. client.init()
  29631. return client
  29632. }
  29633. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29634. // it returns an error otherwise.
  29635. func (m TutorialMutation) Tx() (*Tx, error) {
  29636. if _, ok := m.driver.(*txDriver); !ok {
  29637. return nil, errors.New("ent: mutation is not running in a transaction")
  29638. }
  29639. tx := &Tx{config: m.config}
  29640. tx.init()
  29641. return tx, nil
  29642. }
  29643. // SetID sets the value of the id field. Note that this
  29644. // operation is only accepted on creation of Tutorial entities.
  29645. func (m *TutorialMutation) SetID(id uint64) {
  29646. m.id = &id
  29647. }
  29648. // ID returns the ID value in the mutation. Note that the ID is only available
  29649. // if it was provided to the builder or after it was returned from the database.
  29650. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  29651. if m.id == nil {
  29652. return
  29653. }
  29654. return *m.id, true
  29655. }
  29656. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29657. // That means, if the mutation is applied within a transaction with an isolation level such
  29658. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29659. // or updated by the mutation.
  29660. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  29661. switch {
  29662. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29663. id, exists := m.ID()
  29664. if exists {
  29665. return []uint64{id}, nil
  29666. }
  29667. fallthrough
  29668. case m.op.Is(OpUpdate | OpDelete):
  29669. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  29670. default:
  29671. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29672. }
  29673. }
  29674. // SetCreatedAt sets the "created_at" field.
  29675. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  29676. m.created_at = &t
  29677. }
  29678. // CreatedAt returns the value of the "created_at" field in the mutation.
  29679. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  29680. v := m.created_at
  29681. if v == nil {
  29682. return
  29683. }
  29684. return *v, true
  29685. }
  29686. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  29687. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  29688. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29689. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29690. if !m.op.Is(OpUpdateOne) {
  29691. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29692. }
  29693. if m.id == nil || m.oldValue == nil {
  29694. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29695. }
  29696. oldValue, err := m.oldValue(ctx)
  29697. if err != nil {
  29698. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29699. }
  29700. return oldValue.CreatedAt, nil
  29701. }
  29702. // ResetCreatedAt resets all changes to the "created_at" field.
  29703. func (m *TutorialMutation) ResetCreatedAt() {
  29704. m.created_at = nil
  29705. }
  29706. // SetUpdatedAt sets the "updated_at" field.
  29707. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  29708. m.updated_at = &t
  29709. }
  29710. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29711. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  29712. v := m.updated_at
  29713. if v == nil {
  29714. return
  29715. }
  29716. return *v, true
  29717. }
  29718. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  29719. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  29720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29721. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29722. if !m.op.Is(OpUpdateOne) {
  29723. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29724. }
  29725. if m.id == nil || m.oldValue == nil {
  29726. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29727. }
  29728. oldValue, err := m.oldValue(ctx)
  29729. if err != nil {
  29730. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29731. }
  29732. return oldValue.UpdatedAt, nil
  29733. }
  29734. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29735. func (m *TutorialMutation) ResetUpdatedAt() {
  29736. m.updated_at = nil
  29737. }
  29738. // SetDeletedAt sets the "deleted_at" field.
  29739. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  29740. m.deleted_at = &t
  29741. }
  29742. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  29743. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  29744. v := m.deleted_at
  29745. if v == nil {
  29746. return
  29747. }
  29748. return *v, true
  29749. }
  29750. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  29751. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  29752. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29753. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  29754. if !m.op.Is(OpUpdateOne) {
  29755. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  29756. }
  29757. if m.id == nil || m.oldValue == nil {
  29758. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  29759. }
  29760. oldValue, err := m.oldValue(ctx)
  29761. if err != nil {
  29762. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  29763. }
  29764. return oldValue.DeletedAt, nil
  29765. }
  29766. // ClearDeletedAt clears the value of the "deleted_at" field.
  29767. func (m *TutorialMutation) ClearDeletedAt() {
  29768. m.deleted_at = nil
  29769. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  29770. }
  29771. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  29772. func (m *TutorialMutation) DeletedAtCleared() bool {
  29773. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  29774. return ok
  29775. }
  29776. // ResetDeletedAt resets all changes to the "deleted_at" field.
  29777. func (m *TutorialMutation) ResetDeletedAt() {
  29778. m.deleted_at = nil
  29779. delete(m.clearedFields, tutorial.FieldDeletedAt)
  29780. }
  29781. // SetEmployeeID sets the "employee_id" field.
  29782. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  29783. m.employee = &u
  29784. }
  29785. // EmployeeID returns the value of the "employee_id" field in the mutation.
  29786. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  29787. v := m.employee
  29788. if v == nil {
  29789. return
  29790. }
  29791. return *v, true
  29792. }
  29793. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  29794. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  29795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29796. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  29797. if !m.op.Is(OpUpdateOne) {
  29798. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  29799. }
  29800. if m.id == nil || m.oldValue == nil {
  29801. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  29802. }
  29803. oldValue, err := m.oldValue(ctx)
  29804. if err != nil {
  29805. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  29806. }
  29807. return oldValue.EmployeeID, nil
  29808. }
  29809. // ResetEmployeeID resets all changes to the "employee_id" field.
  29810. func (m *TutorialMutation) ResetEmployeeID() {
  29811. m.employee = nil
  29812. }
  29813. // SetIndex sets the "index" field.
  29814. func (m *TutorialMutation) SetIndex(i int) {
  29815. m.index = &i
  29816. m.addindex = nil
  29817. }
  29818. // Index returns the value of the "index" field in the mutation.
  29819. func (m *TutorialMutation) Index() (r int, exists bool) {
  29820. v := m.index
  29821. if v == nil {
  29822. return
  29823. }
  29824. return *v, true
  29825. }
  29826. // OldIndex returns the old "index" field's value of the Tutorial entity.
  29827. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  29828. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29829. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  29830. if !m.op.Is(OpUpdateOne) {
  29831. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  29832. }
  29833. if m.id == nil || m.oldValue == nil {
  29834. return v, errors.New("OldIndex requires an ID field in the mutation")
  29835. }
  29836. oldValue, err := m.oldValue(ctx)
  29837. if err != nil {
  29838. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  29839. }
  29840. return oldValue.Index, nil
  29841. }
  29842. // AddIndex adds i to the "index" field.
  29843. func (m *TutorialMutation) AddIndex(i int) {
  29844. if m.addindex != nil {
  29845. *m.addindex += i
  29846. } else {
  29847. m.addindex = &i
  29848. }
  29849. }
  29850. // AddedIndex returns the value that was added to the "index" field in this mutation.
  29851. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  29852. v := m.addindex
  29853. if v == nil {
  29854. return
  29855. }
  29856. return *v, true
  29857. }
  29858. // ResetIndex resets all changes to the "index" field.
  29859. func (m *TutorialMutation) ResetIndex() {
  29860. m.index = nil
  29861. m.addindex = nil
  29862. }
  29863. // SetTitle sets the "title" field.
  29864. func (m *TutorialMutation) SetTitle(s string) {
  29865. m.title = &s
  29866. }
  29867. // Title returns the value of the "title" field in the mutation.
  29868. func (m *TutorialMutation) Title() (r string, exists bool) {
  29869. v := m.title
  29870. if v == nil {
  29871. return
  29872. }
  29873. return *v, true
  29874. }
  29875. // OldTitle returns the old "title" field's value of the Tutorial entity.
  29876. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  29877. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29878. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  29879. if !m.op.Is(OpUpdateOne) {
  29880. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  29881. }
  29882. if m.id == nil || m.oldValue == nil {
  29883. return v, errors.New("OldTitle requires an ID field in the mutation")
  29884. }
  29885. oldValue, err := m.oldValue(ctx)
  29886. if err != nil {
  29887. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  29888. }
  29889. return oldValue.Title, nil
  29890. }
  29891. // ResetTitle resets all changes to the "title" field.
  29892. func (m *TutorialMutation) ResetTitle() {
  29893. m.title = nil
  29894. }
  29895. // SetContent sets the "content" field.
  29896. func (m *TutorialMutation) SetContent(s string) {
  29897. m.content = &s
  29898. }
  29899. // Content returns the value of the "content" field in the mutation.
  29900. func (m *TutorialMutation) Content() (r string, exists bool) {
  29901. v := m.content
  29902. if v == nil {
  29903. return
  29904. }
  29905. return *v, true
  29906. }
  29907. // OldContent returns the old "content" field's value of the Tutorial entity.
  29908. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  29909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29910. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  29911. if !m.op.Is(OpUpdateOne) {
  29912. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  29913. }
  29914. if m.id == nil || m.oldValue == nil {
  29915. return v, errors.New("OldContent requires an ID field in the mutation")
  29916. }
  29917. oldValue, err := m.oldValue(ctx)
  29918. if err != nil {
  29919. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  29920. }
  29921. return oldValue.Content, nil
  29922. }
  29923. // ResetContent resets all changes to the "content" field.
  29924. func (m *TutorialMutation) ResetContent() {
  29925. m.content = nil
  29926. }
  29927. // SetOrganizationID sets the "organization_id" field.
  29928. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  29929. m.organization_id = &u
  29930. m.addorganization_id = nil
  29931. }
  29932. // OrganizationID returns the value of the "organization_id" field in the mutation.
  29933. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  29934. v := m.organization_id
  29935. if v == nil {
  29936. return
  29937. }
  29938. return *v, true
  29939. }
  29940. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  29941. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  29942. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29943. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  29944. if !m.op.Is(OpUpdateOne) {
  29945. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  29946. }
  29947. if m.id == nil || m.oldValue == nil {
  29948. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  29949. }
  29950. oldValue, err := m.oldValue(ctx)
  29951. if err != nil {
  29952. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  29953. }
  29954. return oldValue.OrganizationID, nil
  29955. }
  29956. // AddOrganizationID adds u to the "organization_id" field.
  29957. func (m *TutorialMutation) AddOrganizationID(u int64) {
  29958. if m.addorganization_id != nil {
  29959. *m.addorganization_id += u
  29960. } else {
  29961. m.addorganization_id = &u
  29962. }
  29963. }
  29964. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  29965. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  29966. v := m.addorganization_id
  29967. if v == nil {
  29968. return
  29969. }
  29970. return *v, true
  29971. }
  29972. // ResetOrganizationID resets all changes to the "organization_id" field.
  29973. func (m *TutorialMutation) ResetOrganizationID() {
  29974. m.organization_id = nil
  29975. m.addorganization_id = nil
  29976. }
  29977. // ClearEmployee clears the "employee" edge to the Employee entity.
  29978. func (m *TutorialMutation) ClearEmployee() {
  29979. m.clearedemployee = true
  29980. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  29981. }
  29982. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  29983. func (m *TutorialMutation) EmployeeCleared() bool {
  29984. return m.clearedemployee
  29985. }
  29986. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  29987. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  29988. // EmployeeID instead. It exists only for internal usage by the builders.
  29989. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  29990. if id := m.employee; id != nil {
  29991. ids = append(ids, *id)
  29992. }
  29993. return
  29994. }
  29995. // ResetEmployee resets all changes to the "employee" edge.
  29996. func (m *TutorialMutation) ResetEmployee() {
  29997. m.employee = nil
  29998. m.clearedemployee = false
  29999. }
  30000. // Where appends a list predicates to the TutorialMutation builder.
  30001. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  30002. m.predicates = append(m.predicates, ps...)
  30003. }
  30004. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  30005. // users can use type-assertion to append predicates that do not depend on any generated package.
  30006. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  30007. p := make([]predicate.Tutorial, len(ps))
  30008. for i := range ps {
  30009. p[i] = ps[i]
  30010. }
  30011. m.Where(p...)
  30012. }
  30013. // Op returns the operation name.
  30014. func (m *TutorialMutation) Op() Op {
  30015. return m.op
  30016. }
  30017. // SetOp allows setting the mutation operation.
  30018. func (m *TutorialMutation) SetOp(op Op) {
  30019. m.op = op
  30020. }
  30021. // Type returns the node type of this mutation (Tutorial).
  30022. func (m *TutorialMutation) Type() string {
  30023. return m.typ
  30024. }
  30025. // Fields returns all fields that were changed during this mutation. Note that in
  30026. // order to get all numeric fields that were incremented/decremented, call
  30027. // AddedFields().
  30028. func (m *TutorialMutation) Fields() []string {
  30029. fields := make([]string, 0, 8)
  30030. if m.created_at != nil {
  30031. fields = append(fields, tutorial.FieldCreatedAt)
  30032. }
  30033. if m.updated_at != nil {
  30034. fields = append(fields, tutorial.FieldUpdatedAt)
  30035. }
  30036. if m.deleted_at != nil {
  30037. fields = append(fields, tutorial.FieldDeletedAt)
  30038. }
  30039. if m.employee != nil {
  30040. fields = append(fields, tutorial.FieldEmployeeID)
  30041. }
  30042. if m.index != nil {
  30043. fields = append(fields, tutorial.FieldIndex)
  30044. }
  30045. if m.title != nil {
  30046. fields = append(fields, tutorial.FieldTitle)
  30047. }
  30048. if m.content != nil {
  30049. fields = append(fields, tutorial.FieldContent)
  30050. }
  30051. if m.organization_id != nil {
  30052. fields = append(fields, tutorial.FieldOrganizationID)
  30053. }
  30054. return fields
  30055. }
  30056. // Field returns the value of a field with the given name. The second boolean
  30057. // return value indicates that this field was not set, or was not defined in the
  30058. // schema.
  30059. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  30060. switch name {
  30061. case tutorial.FieldCreatedAt:
  30062. return m.CreatedAt()
  30063. case tutorial.FieldUpdatedAt:
  30064. return m.UpdatedAt()
  30065. case tutorial.FieldDeletedAt:
  30066. return m.DeletedAt()
  30067. case tutorial.FieldEmployeeID:
  30068. return m.EmployeeID()
  30069. case tutorial.FieldIndex:
  30070. return m.Index()
  30071. case tutorial.FieldTitle:
  30072. return m.Title()
  30073. case tutorial.FieldContent:
  30074. return m.Content()
  30075. case tutorial.FieldOrganizationID:
  30076. return m.OrganizationID()
  30077. }
  30078. return nil, false
  30079. }
  30080. // OldField returns the old value of the field from the database. An error is
  30081. // returned if the mutation operation is not UpdateOne, or the query to the
  30082. // database failed.
  30083. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30084. switch name {
  30085. case tutorial.FieldCreatedAt:
  30086. return m.OldCreatedAt(ctx)
  30087. case tutorial.FieldUpdatedAt:
  30088. return m.OldUpdatedAt(ctx)
  30089. case tutorial.FieldDeletedAt:
  30090. return m.OldDeletedAt(ctx)
  30091. case tutorial.FieldEmployeeID:
  30092. return m.OldEmployeeID(ctx)
  30093. case tutorial.FieldIndex:
  30094. return m.OldIndex(ctx)
  30095. case tutorial.FieldTitle:
  30096. return m.OldTitle(ctx)
  30097. case tutorial.FieldContent:
  30098. return m.OldContent(ctx)
  30099. case tutorial.FieldOrganizationID:
  30100. return m.OldOrganizationID(ctx)
  30101. }
  30102. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  30103. }
  30104. // SetField sets the value of a field with the given name. It returns an error if
  30105. // the field is not defined in the schema, or if the type mismatched the field
  30106. // type.
  30107. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  30108. switch name {
  30109. case tutorial.FieldCreatedAt:
  30110. v, ok := value.(time.Time)
  30111. if !ok {
  30112. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30113. }
  30114. m.SetCreatedAt(v)
  30115. return nil
  30116. case tutorial.FieldUpdatedAt:
  30117. v, ok := value.(time.Time)
  30118. if !ok {
  30119. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30120. }
  30121. m.SetUpdatedAt(v)
  30122. return nil
  30123. case tutorial.FieldDeletedAt:
  30124. v, ok := value.(time.Time)
  30125. if !ok {
  30126. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30127. }
  30128. m.SetDeletedAt(v)
  30129. return nil
  30130. case tutorial.FieldEmployeeID:
  30131. v, ok := value.(uint64)
  30132. if !ok {
  30133. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30134. }
  30135. m.SetEmployeeID(v)
  30136. return nil
  30137. case tutorial.FieldIndex:
  30138. v, ok := value.(int)
  30139. if !ok {
  30140. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30141. }
  30142. m.SetIndex(v)
  30143. return nil
  30144. case tutorial.FieldTitle:
  30145. v, ok := value.(string)
  30146. if !ok {
  30147. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30148. }
  30149. m.SetTitle(v)
  30150. return nil
  30151. case tutorial.FieldContent:
  30152. v, ok := value.(string)
  30153. if !ok {
  30154. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30155. }
  30156. m.SetContent(v)
  30157. return nil
  30158. case tutorial.FieldOrganizationID:
  30159. v, ok := value.(uint64)
  30160. if !ok {
  30161. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30162. }
  30163. m.SetOrganizationID(v)
  30164. return nil
  30165. }
  30166. return fmt.Errorf("unknown Tutorial field %s", name)
  30167. }
  30168. // AddedFields returns all numeric fields that were incremented/decremented during
  30169. // this mutation.
  30170. func (m *TutorialMutation) AddedFields() []string {
  30171. var fields []string
  30172. if m.addindex != nil {
  30173. fields = append(fields, tutorial.FieldIndex)
  30174. }
  30175. if m.addorganization_id != nil {
  30176. fields = append(fields, tutorial.FieldOrganizationID)
  30177. }
  30178. return fields
  30179. }
  30180. // AddedField returns the numeric value that was incremented/decremented on a field
  30181. // with the given name. The second boolean return value indicates that this field
  30182. // was not set, or was not defined in the schema.
  30183. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  30184. switch name {
  30185. case tutorial.FieldIndex:
  30186. return m.AddedIndex()
  30187. case tutorial.FieldOrganizationID:
  30188. return m.AddedOrganizationID()
  30189. }
  30190. return nil, false
  30191. }
  30192. // AddField adds the value to the field with the given name. It returns an error if
  30193. // the field is not defined in the schema, or if the type mismatched the field
  30194. // type.
  30195. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  30196. switch name {
  30197. case tutorial.FieldIndex:
  30198. v, ok := value.(int)
  30199. if !ok {
  30200. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30201. }
  30202. m.AddIndex(v)
  30203. return nil
  30204. case tutorial.FieldOrganizationID:
  30205. v, ok := value.(int64)
  30206. if !ok {
  30207. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30208. }
  30209. m.AddOrganizationID(v)
  30210. return nil
  30211. }
  30212. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  30213. }
  30214. // ClearedFields returns all nullable fields that were cleared during this
  30215. // mutation.
  30216. func (m *TutorialMutation) ClearedFields() []string {
  30217. var fields []string
  30218. if m.FieldCleared(tutorial.FieldDeletedAt) {
  30219. fields = append(fields, tutorial.FieldDeletedAt)
  30220. }
  30221. return fields
  30222. }
  30223. // FieldCleared returns a boolean indicating if a field with the given name was
  30224. // cleared in this mutation.
  30225. func (m *TutorialMutation) FieldCleared(name string) bool {
  30226. _, ok := m.clearedFields[name]
  30227. return ok
  30228. }
  30229. // ClearField clears the value of the field with the given name. It returns an
  30230. // error if the field is not defined in the schema.
  30231. func (m *TutorialMutation) ClearField(name string) error {
  30232. switch name {
  30233. case tutorial.FieldDeletedAt:
  30234. m.ClearDeletedAt()
  30235. return nil
  30236. }
  30237. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  30238. }
  30239. // ResetField resets all changes in the mutation for the field with the given name.
  30240. // It returns an error if the field is not defined in the schema.
  30241. func (m *TutorialMutation) ResetField(name string) error {
  30242. switch name {
  30243. case tutorial.FieldCreatedAt:
  30244. m.ResetCreatedAt()
  30245. return nil
  30246. case tutorial.FieldUpdatedAt:
  30247. m.ResetUpdatedAt()
  30248. return nil
  30249. case tutorial.FieldDeletedAt:
  30250. m.ResetDeletedAt()
  30251. return nil
  30252. case tutorial.FieldEmployeeID:
  30253. m.ResetEmployeeID()
  30254. return nil
  30255. case tutorial.FieldIndex:
  30256. m.ResetIndex()
  30257. return nil
  30258. case tutorial.FieldTitle:
  30259. m.ResetTitle()
  30260. return nil
  30261. case tutorial.FieldContent:
  30262. m.ResetContent()
  30263. return nil
  30264. case tutorial.FieldOrganizationID:
  30265. m.ResetOrganizationID()
  30266. return nil
  30267. }
  30268. return fmt.Errorf("unknown Tutorial field %s", name)
  30269. }
  30270. // AddedEdges returns all edge names that were set/added in this mutation.
  30271. func (m *TutorialMutation) AddedEdges() []string {
  30272. edges := make([]string, 0, 1)
  30273. if m.employee != nil {
  30274. edges = append(edges, tutorial.EdgeEmployee)
  30275. }
  30276. return edges
  30277. }
  30278. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  30279. // name in this mutation.
  30280. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  30281. switch name {
  30282. case tutorial.EdgeEmployee:
  30283. if id := m.employee; id != nil {
  30284. return []ent.Value{*id}
  30285. }
  30286. }
  30287. return nil
  30288. }
  30289. // RemovedEdges returns all edge names that were removed in this mutation.
  30290. func (m *TutorialMutation) RemovedEdges() []string {
  30291. edges := make([]string, 0, 1)
  30292. return edges
  30293. }
  30294. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  30295. // the given name in this mutation.
  30296. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  30297. return nil
  30298. }
  30299. // ClearedEdges returns all edge names that were cleared in this mutation.
  30300. func (m *TutorialMutation) ClearedEdges() []string {
  30301. edges := make([]string, 0, 1)
  30302. if m.clearedemployee {
  30303. edges = append(edges, tutorial.EdgeEmployee)
  30304. }
  30305. return edges
  30306. }
  30307. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30308. // was cleared in this mutation.
  30309. func (m *TutorialMutation) EdgeCleared(name string) bool {
  30310. switch name {
  30311. case tutorial.EdgeEmployee:
  30312. return m.clearedemployee
  30313. }
  30314. return false
  30315. }
  30316. // ClearEdge clears the value of the edge with the given name. It returns an error
  30317. // if that edge is not defined in the schema.
  30318. func (m *TutorialMutation) ClearEdge(name string) error {
  30319. switch name {
  30320. case tutorial.EdgeEmployee:
  30321. m.ClearEmployee()
  30322. return nil
  30323. }
  30324. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  30325. }
  30326. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30327. // It returns an error if the edge is not defined in the schema.
  30328. func (m *TutorialMutation) ResetEdge(name string) error {
  30329. switch name {
  30330. case tutorial.EdgeEmployee:
  30331. m.ResetEmployee()
  30332. return nil
  30333. }
  30334. return fmt.Errorf("unknown Tutorial edge %s", name)
  30335. }
  30336. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  30337. type UsageDetailMutation struct {
  30338. config
  30339. op Op
  30340. typ string
  30341. id *uint64
  30342. created_at *time.Time
  30343. updated_at *time.Time
  30344. status *uint8
  30345. addstatus *int8
  30346. _type *int
  30347. add_type *int
  30348. bot_id *string
  30349. receiver_id *string
  30350. app *int
  30351. addapp *int
  30352. session_id *uint64
  30353. addsession_id *int64
  30354. request *string
  30355. response *string
  30356. original_data *custom_types.OriginalData
  30357. total_tokens *uint64
  30358. addtotal_tokens *int64
  30359. prompt_tokens *uint64
  30360. addprompt_tokens *int64
  30361. completion_tokens *uint64
  30362. addcompletion_tokens *int64
  30363. organization_id *uint64
  30364. addorganization_id *int64
  30365. clearedFields map[string]struct{}
  30366. done bool
  30367. oldValue func(context.Context) (*UsageDetail, error)
  30368. predicates []predicate.UsageDetail
  30369. }
  30370. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  30371. // usagedetailOption allows management of the mutation configuration using functional options.
  30372. type usagedetailOption func(*UsageDetailMutation)
  30373. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  30374. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  30375. m := &UsageDetailMutation{
  30376. config: c,
  30377. op: op,
  30378. typ: TypeUsageDetail,
  30379. clearedFields: make(map[string]struct{}),
  30380. }
  30381. for _, opt := range opts {
  30382. opt(m)
  30383. }
  30384. return m
  30385. }
  30386. // withUsageDetailID sets the ID field of the mutation.
  30387. func withUsageDetailID(id uint64) usagedetailOption {
  30388. return func(m *UsageDetailMutation) {
  30389. var (
  30390. err error
  30391. once sync.Once
  30392. value *UsageDetail
  30393. )
  30394. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  30395. once.Do(func() {
  30396. if m.done {
  30397. err = errors.New("querying old values post mutation is not allowed")
  30398. } else {
  30399. value, err = m.Client().UsageDetail.Get(ctx, id)
  30400. }
  30401. })
  30402. return value, err
  30403. }
  30404. m.id = &id
  30405. }
  30406. }
  30407. // withUsageDetail sets the old UsageDetail of the mutation.
  30408. func withUsageDetail(node *UsageDetail) usagedetailOption {
  30409. return func(m *UsageDetailMutation) {
  30410. m.oldValue = func(context.Context) (*UsageDetail, error) {
  30411. return node, nil
  30412. }
  30413. m.id = &node.ID
  30414. }
  30415. }
  30416. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30417. // executed in a transaction (ent.Tx), a transactional client is returned.
  30418. func (m UsageDetailMutation) Client() *Client {
  30419. client := &Client{config: m.config}
  30420. client.init()
  30421. return client
  30422. }
  30423. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30424. // it returns an error otherwise.
  30425. func (m UsageDetailMutation) Tx() (*Tx, error) {
  30426. if _, ok := m.driver.(*txDriver); !ok {
  30427. return nil, errors.New("ent: mutation is not running in a transaction")
  30428. }
  30429. tx := &Tx{config: m.config}
  30430. tx.init()
  30431. return tx, nil
  30432. }
  30433. // SetID sets the value of the id field. Note that this
  30434. // operation is only accepted on creation of UsageDetail entities.
  30435. func (m *UsageDetailMutation) SetID(id uint64) {
  30436. m.id = &id
  30437. }
  30438. // ID returns the ID value in the mutation. Note that the ID is only available
  30439. // if it was provided to the builder or after it was returned from the database.
  30440. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  30441. if m.id == nil {
  30442. return
  30443. }
  30444. return *m.id, true
  30445. }
  30446. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30447. // That means, if the mutation is applied within a transaction with an isolation level such
  30448. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30449. // or updated by the mutation.
  30450. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  30451. switch {
  30452. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30453. id, exists := m.ID()
  30454. if exists {
  30455. return []uint64{id}, nil
  30456. }
  30457. fallthrough
  30458. case m.op.Is(OpUpdate | OpDelete):
  30459. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  30460. default:
  30461. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30462. }
  30463. }
  30464. // SetCreatedAt sets the "created_at" field.
  30465. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  30466. m.created_at = &t
  30467. }
  30468. // CreatedAt returns the value of the "created_at" field in the mutation.
  30469. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  30470. v := m.created_at
  30471. if v == nil {
  30472. return
  30473. }
  30474. return *v, true
  30475. }
  30476. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  30477. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30478. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30479. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  30480. if !m.op.Is(OpUpdateOne) {
  30481. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  30482. }
  30483. if m.id == nil || m.oldValue == nil {
  30484. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  30485. }
  30486. oldValue, err := m.oldValue(ctx)
  30487. if err != nil {
  30488. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  30489. }
  30490. return oldValue.CreatedAt, nil
  30491. }
  30492. // ResetCreatedAt resets all changes to the "created_at" field.
  30493. func (m *UsageDetailMutation) ResetCreatedAt() {
  30494. m.created_at = nil
  30495. }
  30496. // SetUpdatedAt sets the "updated_at" field.
  30497. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  30498. m.updated_at = &t
  30499. }
  30500. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  30501. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  30502. v := m.updated_at
  30503. if v == nil {
  30504. return
  30505. }
  30506. return *v, true
  30507. }
  30508. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  30509. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30510. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30511. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  30512. if !m.op.Is(OpUpdateOne) {
  30513. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  30514. }
  30515. if m.id == nil || m.oldValue == nil {
  30516. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  30517. }
  30518. oldValue, err := m.oldValue(ctx)
  30519. if err != nil {
  30520. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  30521. }
  30522. return oldValue.UpdatedAt, nil
  30523. }
  30524. // ResetUpdatedAt resets all changes to the "updated_at" field.
  30525. func (m *UsageDetailMutation) ResetUpdatedAt() {
  30526. m.updated_at = nil
  30527. }
  30528. // SetStatus sets the "status" field.
  30529. func (m *UsageDetailMutation) SetStatus(u uint8) {
  30530. m.status = &u
  30531. m.addstatus = nil
  30532. }
  30533. // Status returns the value of the "status" field in the mutation.
  30534. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  30535. v := m.status
  30536. if v == nil {
  30537. return
  30538. }
  30539. return *v, true
  30540. }
  30541. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  30542. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30543. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30544. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  30545. if !m.op.Is(OpUpdateOne) {
  30546. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  30547. }
  30548. if m.id == nil || m.oldValue == nil {
  30549. return v, errors.New("OldStatus requires an ID field in the mutation")
  30550. }
  30551. oldValue, err := m.oldValue(ctx)
  30552. if err != nil {
  30553. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  30554. }
  30555. return oldValue.Status, nil
  30556. }
  30557. // AddStatus adds u to the "status" field.
  30558. func (m *UsageDetailMutation) AddStatus(u int8) {
  30559. if m.addstatus != nil {
  30560. *m.addstatus += u
  30561. } else {
  30562. m.addstatus = &u
  30563. }
  30564. }
  30565. // AddedStatus returns the value that was added to the "status" field in this mutation.
  30566. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  30567. v := m.addstatus
  30568. if v == nil {
  30569. return
  30570. }
  30571. return *v, true
  30572. }
  30573. // ClearStatus clears the value of the "status" field.
  30574. func (m *UsageDetailMutation) ClearStatus() {
  30575. m.status = nil
  30576. m.addstatus = nil
  30577. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  30578. }
  30579. // StatusCleared returns if the "status" field was cleared in this mutation.
  30580. func (m *UsageDetailMutation) StatusCleared() bool {
  30581. _, ok := m.clearedFields[usagedetail.FieldStatus]
  30582. return ok
  30583. }
  30584. // ResetStatus resets all changes to the "status" field.
  30585. func (m *UsageDetailMutation) ResetStatus() {
  30586. m.status = nil
  30587. m.addstatus = nil
  30588. delete(m.clearedFields, usagedetail.FieldStatus)
  30589. }
  30590. // SetType sets the "type" field.
  30591. func (m *UsageDetailMutation) SetType(i int) {
  30592. m._type = &i
  30593. m.add_type = nil
  30594. }
  30595. // GetType returns the value of the "type" field in the mutation.
  30596. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  30597. v := m._type
  30598. if v == nil {
  30599. return
  30600. }
  30601. return *v, true
  30602. }
  30603. // OldType returns the old "type" field's value of the UsageDetail entity.
  30604. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30605. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30606. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  30607. if !m.op.Is(OpUpdateOne) {
  30608. return v, errors.New("OldType is only allowed on UpdateOne operations")
  30609. }
  30610. if m.id == nil || m.oldValue == nil {
  30611. return v, errors.New("OldType requires an ID field in the mutation")
  30612. }
  30613. oldValue, err := m.oldValue(ctx)
  30614. if err != nil {
  30615. return v, fmt.Errorf("querying old value for OldType: %w", err)
  30616. }
  30617. return oldValue.Type, nil
  30618. }
  30619. // AddType adds i to the "type" field.
  30620. func (m *UsageDetailMutation) AddType(i int) {
  30621. if m.add_type != nil {
  30622. *m.add_type += i
  30623. } else {
  30624. m.add_type = &i
  30625. }
  30626. }
  30627. // AddedType returns the value that was added to the "type" field in this mutation.
  30628. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  30629. v := m.add_type
  30630. if v == nil {
  30631. return
  30632. }
  30633. return *v, true
  30634. }
  30635. // ClearType clears the value of the "type" field.
  30636. func (m *UsageDetailMutation) ClearType() {
  30637. m._type = nil
  30638. m.add_type = nil
  30639. m.clearedFields[usagedetail.FieldType] = struct{}{}
  30640. }
  30641. // TypeCleared returns if the "type" field was cleared in this mutation.
  30642. func (m *UsageDetailMutation) TypeCleared() bool {
  30643. _, ok := m.clearedFields[usagedetail.FieldType]
  30644. return ok
  30645. }
  30646. // ResetType resets all changes to the "type" field.
  30647. func (m *UsageDetailMutation) ResetType() {
  30648. m._type = nil
  30649. m.add_type = nil
  30650. delete(m.clearedFields, usagedetail.FieldType)
  30651. }
  30652. // SetBotID sets the "bot_id" field.
  30653. func (m *UsageDetailMutation) SetBotID(s string) {
  30654. m.bot_id = &s
  30655. }
  30656. // BotID returns the value of the "bot_id" field in the mutation.
  30657. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  30658. v := m.bot_id
  30659. if v == nil {
  30660. return
  30661. }
  30662. return *v, true
  30663. }
  30664. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  30665. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30666. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30667. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  30668. if !m.op.Is(OpUpdateOne) {
  30669. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  30670. }
  30671. if m.id == nil || m.oldValue == nil {
  30672. return v, errors.New("OldBotID requires an ID field in the mutation")
  30673. }
  30674. oldValue, err := m.oldValue(ctx)
  30675. if err != nil {
  30676. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  30677. }
  30678. return oldValue.BotID, nil
  30679. }
  30680. // ResetBotID resets all changes to the "bot_id" field.
  30681. func (m *UsageDetailMutation) ResetBotID() {
  30682. m.bot_id = nil
  30683. }
  30684. // SetReceiverID sets the "receiver_id" field.
  30685. func (m *UsageDetailMutation) SetReceiverID(s string) {
  30686. m.receiver_id = &s
  30687. }
  30688. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  30689. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  30690. v := m.receiver_id
  30691. if v == nil {
  30692. return
  30693. }
  30694. return *v, true
  30695. }
  30696. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  30697. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30699. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  30700. if !m.op.Is(OpUpdateOne) {
  30701. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  30702. }
  30703. if m.id == nil || m.oldValue == nil {
  30704. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  30705. }
  30706. oldValue, err := m.oldValue(ctx)
  30707. if err != nil {
  30708. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  30709. }
  30710. return oldValue.ReceiverID, nil
  30711. }
  30712. // ResetReceiverID resets all changes to the "receiver_id" field.
  30713. func (m *UsageDetailMutation) ResetReceiverID() {
  30714. m.receiver_id = nil
  30715. }
  30716. // SetApp sets the "app" field.
  30717. func (m *UsageDetailMutation) SetApp(i int) {
  30718. m.app = &i
  30719. m.addapp = nil
  30720. }
  30721. // App returns the value of the "app" field in the mutation.
  30722. func (m *UsageDetailMutation) App() (r int, exists bool) {
  30723. v := m.app
  30724. if v == nil {
  30725. return
  30726. }
  30727. return *v, true
  30728. }
  30729. // OldApp returns the old "app" field's value of the UsageDetail entity.
  30730. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30731. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30732. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  30733. if !m.op.Is(OpUpdateOne) {
  30734. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  30735. }
  30736. if m.id == nil || m.oldValue == nil {
  30737. return v, errors.New("OldApp requires an ID field in the mutation")
  30738. }
  30739. oldValue, err := m.oldValue(ctx)
  30740. if err != nil {
  30741. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  30742. }
  30743. return oldValue.App, nil
  30744. }
  30745. // AddApp adds i to the "app" field.
  30746. func (m *UsageDetailMutation) AddApp(i int) {
  30747. if m.addapp != nil {
  30748. *m.addapp += i
  30749. } else {
  30750. m.addapp = &i
  30751. }
  30752. }
  30753. // AddedApp returns the value that was added to the "app" field in this mutation.
  30754. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  30755. v := m.addapp
  30756. if v == nil {
  30757. return
  30758. }
  30759. return *v, true
  30760. }
  30761. // ClearApp clears the value of the "app" field.
  30762. func (m *UsageDetailMutation) ClearApp() {
  30763. m.app = nil
  30764. m.addapp = nil
  30765. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  30766. }
  30767. // AppCleared returns if the "app" field was cleared in this mutation.
  30768. func (m *UsageDetailMutation) AppCleared() bool {
  30769. _, ok := m.clearedFields[usagedetail.FieldApp]
  30770. return ok
  30771. }
  30772. // ResetApp resets all changes to the "app" field.
  30773. func (m *UsageDetailMutation) ResetApp() {
  30774. m.app = nil
  30775. m.addapp = nil
  30776. delete(m.clearedFields, usagedetail.FieldApp)
  30777. }
  30778. // SetSessionID sets the "session_id" field.
  30779. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  30780. m.session_id = &u
  30781. m.addsession_id = nil
  30782. }
  30783. // SessionID returns the value of the "session_id" field in the mutation.
  30784. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  30785. v := m.session_id
  30786. if v == nil {
  30787. return
  30788. }
  30789. return *v, true
  30790. }
  30791. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  30792. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30793. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30794. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  30795. if !m.op.Is(OpUpdateOne) {
  30796. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  30797. }
  30798. if m.id == nil || m.oldValue == nil {
  30799. return v, errors.New("OldSessionID requires an ID field in the mutation")
  30800. }
  30801. oldValue, err := m.oldValue(ctx)
  30802. if err != nil {
  30803. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  30804. }
  30805. return oldValue.SessionID, nil
  30806. }
  30807. // AddSessionID adds u to the "session_id" field.
  30808. func (m *UsageDetailMutation) AddSessionID(u int64) {
  30809. if m.addsession_id != nil {
  30810. *m.addsession_id += u
  30811. } else {
  30812. m.addsession_id = &u
  30813. }
  30814. }
  30815. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  30816. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  30817. v := m.addsession_id
  30818. if v == nil {
  30819. return
  30820. }
  30821. return *v, true
  30822. }
  30823. // ClearSessionID clears the value of the "session_id" field.
  30824. func (m *UsageDetailMutation) ClearSessionID() {
  30825. m.session_id = nil
  30826. m.addsession_id = nil
  30827. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  30828. }
  30829. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  30830. func (m *UsageDetailMutation) SessionIDCleared() bool {
  30831. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  30832. return ok
  30833. }
  30834. // ResetSessionID resets all changes to the "session_id" field.
  30835. func (m *UsageDetailMutation) ResetSessionID() {
  30836. m.session_id = nil
  30837. m.addsession_id = nil
  30838. delete(m.clearedFields, usagedetail.FieldSessionID)
  30839. }
  30840. // SetRequest sets the "request" field.
  30841. func (m *UsageDetailMutation) SetRequest(s string) {
  30842. m.request = &s
  30843. }
  30844. // Request returns the value of the "request" field in the mutation.
  30845. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  30846. v := m.request
  30847. if v == nil {
  30848. return
  30849. }
  30850. return *v, true
  30851. }
  30852. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  30853. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30854. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30855. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  30856. if !m.op.Is(OpUpdateOne) {
  30857. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  30858. }
  30859. if m.id == nil || m.oldValue == nil {
  30860. return v, errors.New("OldRequest requires an ID field in the mutation")
  30861. }
  30862. oldValue, err := m.oldValue(ctx)
  30863. if err != nil {
  30864. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  30865. }
  30866. return oldValue.Request, nil
  30867. }
  30868. // ResetRequest resets all changes to the "request" field.
  30869. func (m *UsageDetailMutation) ResetRequest() {
  30870. m.request = nil
  30871. }
  30872. // SetResponse sets the "response" field.
  30873. func (m *UsageDetailMutation) SetResponse(s string) {
  30874. m.response = &s
  30875. }
  30876. // Response returns the value of the "response" field in the mutation.
  30877. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  30878. v := m.response
  30879. if v == nil {
  30880. return
  30881. }
  30882. return *v, true
  30883. }
  30884. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  30885. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30886. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30887. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  30888. if !m.op.Is(OpUpdateOne) {
  30889. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  30890. }
  30891. if m.id == nil || m.oldValue == nil {
  30892. return v, errors.New("OldResponse requires an ID field in the mutation")
  30893. }
  30894. oldValue, err := m.oldValue(ctx)
  30895. if err != nil {
  30896. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  30897. }
  30898. return oldValue.Response, nil
  30899. }
  30900. // ResetResponse resets all changes to the "response" field.
  30901. func (m *UsageDetailMutation) ResetResponse() {
  30902. m.response = nil
  30903. }
  30904. // SetOriginalData sets the "original_data" field.
  30905. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  30906. m.original_data = &ctd
  30907. }
  30908. // OriginalData returns the value of the "original_data" field in the mutation.
  30909. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  30910. v := m.original_data
  30911. if v == nil {
  30912. return
  30913. }
  30914. return *v, true
  30915. }
  30916. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  30917. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30918. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30919. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  30920. if !m.op.Is(OpUpdateOne) {
  30921. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  30922. }
  30923. if m.id == nil || m.oldValue == nil {
  30924. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  30925. }
  30926. oldValue, err := m.oldValue(ctx)
  30927. if err != nil {
  30928. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  30929. }
  30930. return oldValue.OriginalData, nil
  30931. }
  30932. // ResetOriginalData resets all changes to the "original_data" field.
  30933. func (m *UsageDetailMutation) ResetOriginalData() {
  30934. m.original_data = nil
  30935. }
  30936. // SetTotalTokens sets the "total_tokens" field.
  30937. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  30938. m.total_tokens = &u
  30939. m.addtotal_tokens = nil
  30940. }
  30941. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  30942. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  30943. v := m.total_tokens
  30944. if v == nil {
  30945. return
  30946. }
  30947. return *v, true
  30948. }
  30949. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  30950. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30951. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30952. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  30953. if !m.op.Is(OpUpdateOne) {
  30954. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  30955. }
  30956. if m.id == nil || m.oldValue == nil {
  30957. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  30958. }
  30959. oldValue, err := m.oldValue(ctx)
  30960. if err != nil {
  30961. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  30962. }
  30963. return oldValue.TotalTokens, nil
  30964. }
  30965. // AddTotalTokens adds u to the "total_tokens" field.
  30966. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  30967. if m.addtotal_tokens != nil {
  30968. *m.addtotal_tokens += u
  30969. } else {
  30970. m.addtotal_tokens = &u
  30971. }
  30972. }
  30973. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  30974. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  30975. v := m.addtotal_tokens
  30976. if v == nil {
  30977. return
  30978. }
  30979. return *v, true
  30980. }
  30981. // ClearTotalTokens clears the value of the "total_tokens" field.
  30982. func (m *UsageDetailMutation) ClearTotalTokens() {
  30983. m.total_tokens = nil
  30984. m.addtotal_tokens = nil
  30985. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  30986. }
  30987. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  30988. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  30989. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  30990. return ok
  30991. }
  30992. // ResetTotalTokens resets all changes to the "total_tokens" field.
  30993. func (m *UsageDetailMutation) ResetTotalTokens() {
  30994. m.total_tokens = nil
  30995. m.addtotal_tokens = nil
  30996. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  30997. }
  30998. // SetPromptTokens sets the "prompt_tokens" field.
  30999. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  31000. m.prompt_tokens = &u
  31001. m.addprompt_tokens = nil
  31002. }
  31003. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  31004. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  31005. v := m.prompt_tokens
  31006. if v == nil {
  31007. return
  31008. }
  31009. return *v, true
  31010. }
  31011. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  31012. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31013. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31014. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  31015. if !m.op.Is(OpUpdateOne) {
  31016. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  31017. }
  31018. if m.id == nil || m.oldValue == nil {
  31019. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  31020. }
  31021. oldValue, err := m.oldValue(ctx)
  31022. if err != nil {
  31023. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  31024. }
  31025. return oldValue.PromptTokens, nil
  31026. }
  31027. // AddPromptTokens adds u to the "prompt_tokens" field.
  31028. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  31029. if m.addprompt_tokens != nil {
  31030. *m.addprompt_tokens += u
  31031. } else {
  31032. m.addprompt_tokens = &u
  31033. }
  31034. }
  31035. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  31036. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  31037. v := m.addprompt_tokens
  31038. if v == nil {
  31039. return
  31040. }
  31041. return *v, true
  31042. }
  31043. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  31044. func (m *UsageDetailMutation) ClearPromptTokens() {
  31045. m.prompt_tokens = nil
  31046. m.addprompt_tokens = nil
  31047. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  31048. }
  31049. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  31050. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  31051. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  31052. return ok
  31053. }
  31054. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  31055. func (m *UsageDetailMutation) ResetPromptTokens() {
  31056. m.prompt_tokens = nil
  31057. m.addprompt_tokens = nil
  31058. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  31059. }
  31060. // SetCompletionTokens sets the "completion_tokens" field.
  31061. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  31062. m.completion_tokens = &u
  31063. m.addcompletion_tokens = nil
  31064. }
  31065. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  31066. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  31067. v := m.completion_tokens
  31068. if v == nil {
  31069. return
  31070. }
  31071. return *v, true
  31072. }
  31073. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  31074. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31075. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31076. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  31077. if !m.op.Is(OpUpdateOne) {
  31078. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  31079. }
  31080. if m.id == nil || m.oldValue == nil {
  31081. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  31082. }
  31083. oldValue, err := m.oldValue(ctx)
  31084. if err != nil {
  31085. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  31086. }
  31087. return oldValue.CompletionTokens, nil
  31088. }
  31089. // AddCompletionTokens adds u to the "completion_tokens" field.
  31090. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  31091. if m.addcompletion_tokens != nil {
  31092. *m.addcompletion_tokens += u
  31093. } else {
  31094. m.addcompletion_tokens = &u
  31095. }
  31096. }
  31097. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  31098. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  31099. v := m.addcompletion_tokens
  31100. if v == nil {
  31101. return
  31102. }
  31103. return *v, true
  31104. }
  31105. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  31106. func (m *UsageDetailMutation) ClearCompletionTokens() {
  31107. m.completion_tokens = nil
  31108. m.addcompletion_tokens = nil
  31109. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  31110. }
  31111. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  31112. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  31113. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  31114. return ok
  31115. }
  31116. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  31117. func (m *UsageDetailMutation) ResetCompletionTokens() {
  31118. m.completion_tokens = nil
  31119. m.addcompletion_tokens = nil
  31120. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  31121. }
  31122. // SetOrganizationID sets the "organization_id" field.
  31123. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  31124. m.organization_id = &u
  31125. m.addorganization_id = nil
  31126. }
  31127. // OrganizationID returns the value of the "organization_id" field in the mutation.
  31128. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  31129. v := m.organization_id
  31130. if v == nil {
  31131. return
  31132. }
  31133. return *v, true
  31134. }
  31135. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  31136. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31137. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31138. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  31139. if !m.op.Is(OpUpdateOne) {
  31140. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  31141. }
  31142. if m.id == nil || m.oldValue == nil {
  31143. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  31144. }
  31145. oldValue, err := m.oldValue(ctx)
  31146. if err != nil {
  31147. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  31148. }
  31149. return oldValue.OrganizationID, nil
  31150. }
  31151. // AddOrganizationID adds u to the "organization_id" field.
  31152. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  31153. if m.addorganization_id != nil {
  31154. *m.addorganization_id += u
  31155. } else {
  31156. m.addorganization_id = &u
  31157. }
  31158. }
  31159. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  31160. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  31161. v := m.addorganization_id
  31162. if v == nil {
  31163. return
  31164. }
  31165. return *v, true
  31166. }
  31167. // ClearOrganizationID clears the value of the "organization_id" field.
  31168. func (m *UsageDetailMutation) ClearOrganizationID() {
  31169. m.organization_id = nil
  31170. m.addorganization_id = nil
  31171. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  31172. }
  31173. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  31174. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  31175. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  31176. return ok
  31177. }
  31178. // ResetOrganizationID resets all changes to the "organization_id" field.
  31179. func (m *UsageDetailMutation) ResetOrganizationID() {
  31180. m.organization_id = nil
  31181. m.addorganization_id = nil
  31182. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  31183. }
  31184. // Where appends a list predicates to the UsageDetailMutation builder.
  31185. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  31186. m.predicates = append(m.predicates, ps...)
  31187. }
  31188. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  31189. // users can use type-assertion to append predicates that do not depend on any generated package.
  31190. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  31191. p := make([]predicate.UsageDetail, len(ps))
  31192. for i := range ps {
  31193. p[i] = ps[i]
  31194. }
  31195. m.Where(p...)
  31196. }
  31197. // Op returns the operation name.
  31198. func (m *UsageDetailMutation) Op() Op {
  31199. return m.op
  31200. }
  31201. // SetOp allows setting the mutation operation.
  31202. func (m *UsageDetailMutation) SetOp(op Op) {
  31203. m.op = op
  31204. }
  31205. // Type returns the node type of this mutation (UsageDetail).
  31206. func (m *UsageDetailMutation) Type() string {
  31207. return m.typ
  31208. }
  31209. // Fields returns all fields that were changed during this mutation. Note that in
  31210. // order to get all numeric fields that were incremented/decremented, call
  31211. // AddedFields().
  31212. func (m *UsageDetailMutation) Fields() []string {
  31213. fields := make([]string, 0, 15)
  31214. if m.created_at != nil {
  31215. fields = append(fields, usagedetail.FieldCreatedAt)
  31216. }
  31217. if m.updated_at != nil {
  31218. fields = append(fields, usagedetail.FieldUpdatedAt)
  31219. }
  31220. if m.status != nil {
  31221. fields = append(fields, usagedetail.FieldStatus)
  31222. }
  31223. if m._type != nil {
  31224. fields = append(fields, usagedetail.FieldType)
  31225. }
  31226. if m.bot_id != nil {
  31227. fields = append(fields, usagedetail.FieldBotID)
  31228. }
  31229. if m.receiver_id != nil {
  31230. fields = append(fields, usagedetail.FieldReceiverID)
  31231. }
  31232. if m.app != nil {
  31233. fields = append(fields, usagedetail.FieldApp)
  31234. }
  31235. if m.session_id != nil {
  31236. fields = append(fields, usagedetail.FieldSessionID)
  31237. }
  31238. if m.request != nil {
  31239. fields = append(fields, usagedetail.FieldRequest)
  31240. }
  31241. if m.response != nil {
  31242. fields = append(fields, usagedetail.FieldResponse)
  31243. }
  31244. if m.original_data != nil {
  31245. fields = append(fields, usagedetail.FieldOriginalData)
  31246. }
  31247. if m.total_tokens != nil {
  31248. fields = append(fields, usagedetail.FieldTotalTokens)
  31249. }
  31250. if m.prompt_tokens != nil {
  31251. fields = append(fields, usagedetail.FieldPromptTokens)
  31252. }
  31253. if m.completion_tokens != nil {
  31254. fields = append(fields, usagedetail.FieldCompletionTokens)
  31255. }
  31256. if m.organization_id != nil {
  31257. fields = append(fields, usagedetail.FieldOrganizationID)
  31258. }
  31259. return fields
  31260. }
  31261. // Field returns the value of a field with the given name. The second boolean
  31262. // return value indicates that this field was not set, or was not defined in the
  31263. // schema.
  31264. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  31265. switch name {
  31266. case usagedetail.FieldCreatedAt:
  31267. return m.CreatedAt()
  31268. case usagedetail.FieldUpdatedAt:
  31269. return m.UpdatedAt()
  31270. case usagedetail.FieldStatus:
  31271. return m.Status()
  31272. case usagedetail.FieldType:
  31273. return m.GetType()
  31274. case usagedetail.FieldBotID:
  31275. return m.BotID()
  31276. case usagedetail.FieldReceiverID:
  31277. return m.ReceiverID()
  31278. case usagedetail.FieldApp:
  31279. return m.App()
  31280. case usagedetail.FieldSessionID:
  31281. return m.SessionID()
  31282. case usagedetail.FieldRequest:
  31283. return m.Request()
  31284. case usagedetail.FieldResponse:
  31285. return m.Response()
  31286. case usagedetail.FieldOriginalData:
  31287. return m.OriginalData()
  31288. case usagedetail.FieldTotalTokens:
  31289. return m.TotalTokens()
  31290. case usagedetail.FieldPromptTokens:
  31291. return m.PromptTokens()
  31292. case usagedetail.FieldCompletionTokens:
  31293. return m.CompletionTokens()
  31294. case usagedetail.FieldOrganizationID:
  31295. return m.OrganizationID()
  31296. }
  31297. return nil, false
  31298. }
  31299. // OldField returns the old value of the field from the database. An error is
  31300. // returned if the mutation operation is not UpdateOne, or the query to the
  31301. // database failed.
  31302. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  31303. switch name {
  31304. case usagedetail.FieldCreatedAt:
  31305. return m.OldCreatedAt(ctx)
  31306. case usagedetail.FieldUpdatedAt:
  31307. return m.OldUpdatedAt(ctx)
  31308. case usagedetail.FieldStatus:
  31309. return m.OldStatus(ctx)
  31310. case usagedetail.FieldType:
  31311. return m.OldType(ctx)
  31312. case usagedetail.FieldBotID:
  31313. return m.OldBotID(ctx)
  31314. case usagedetail.FieldReceiverID:
  31315. return m.OldReceiverID(ctx)
  31316. case usagedetail.FieldApp:
  31317. return m.OldApp(ctx)
  31318. case usagedetail.FieldSessionID:
  31319. return m.OldSessionID(ctx)
  31320. case usagedetail.FieldRequest:
  31321. return m.OldRequest(ctx)
  31322. case usagedetail.FieldResponse:
  31323. return m.OldResponse(ctx)
  31324. case usagedetail.FieldOriginalData:
  31325. return m.OldOriginalData(ctx)
  31326. case usagedetail.FieldTotalTokens:
  31327. return m.OldTotalTokens(ctx)
  31328. case usagedetail.FieldPromptTokens:
  31329. return m.OldPromptTokens(ctx)
  31330. case usagedetail.FieldCompletionTokens:
  31331. return m.OldCompletionTokens(ctx)
  31332. case usagedetail.FieldOrganizationID:
  31333. return m.OldOrganizationID(ctx)
  31334. }
  31335. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  31336. }
  31337. // SetField sets the value of a field with the given name. It returns an error if
  31338. // the field is not defined in the schema, or if the type mismatched the field
  31339. // type.
  31340. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  31341. switch name {
  31342. case usagedetail.FieldCreatedAt:
  31343. v, ok := value.(time.Time)
  31344. if !ok {
  31345. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31346. }
  31347. m.SetCreatedAt(v)
  31348. return nil
  31349. case usagedetail.FieldUpdatedAt:
  31350. v, ok := value.(time.Time)
  31351. if !ok {
  31352. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31353. }
  31354. m.SetUpdatedAt(v)
  31355. return nil
  31356. case usagedetail.FieldStatus:
  31357. v, ok := value.(uint8)
  31358. if !ok {
  31359. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31360. }
  31361. m.SetStatus(v)
  31362. return nil
  31363. case usagedetail.FieldType:
  31364. v, ok := value.(int)
  31365. if !ok {
  31366. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31367. }
  31368. m.SetType(v)
  31369. return nil
  31370. case usagedetail.FieldBotID:
  31371. v, ok := value.(string)
  31372. if !ok {
  31373. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31374. }
  31375. m.SetBotID(v)
  31376. return nil
  31377. case usagedetail.FieldReceiverID:
  31378. v, ok := value.(string)
  31379. if !ok {
  31380. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31381. }
  31382. m.SetReceiverID(v)
  31383. return nil
  31384. case usagedetail.FieldApp:
  31385. v, ok := value.(int)
  31386. if !ok {
  31387. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31388. }
  31389. m.SetApp(v)
  31390. return nil
  31391. case usagedetail.FieldSessionID:
  31392. v, ok := value.(uint64)
  31393. if !ok {
  31394. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31395. }
  31396. m.SetSessionID(v)
  31397. return nil
  31398. case usagedetail.FieldRequest:
  31399. v, ok := value.(string)
  31400. if !ok {
  31401. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31402. }
  31403. m.SetRequest(v)
  31404. return nil
  31405. case usagedetail.FieldResponse:
  31406. v, ok := value.(string)
  31407. if !ok {
  31408. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31409. }
  31410. m.SetResponse(v)
  31411. return nil
  31412. case usagedetail.FieldOriginalData:
  31413. v, ok := value.(custom_types.OriginalData)
  31414. if !ok {
  31415. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31416. }
  31417. m.SetOriginalData(v)
  31418. return nil
  31419. case usagedetail.FieldTotalTokens:
  31420. v, ok := value.(uint64)
  31421. if !ok {
  31422. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31423. }
  31424. m.SetTotalTokens(v)
  31425. return nil
  31426. case usagedetail.FieldPromptTokens:
  31427. v, ok := value.(uint64)
  31428. if !ok {
  31429. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31430. }
  31431. m.SetPromptTokens(v)
  31432. return nil
  31433. case usagedetail.FieldCompletionTokens:
  31434. v, ok := value.(uint64)
  31435. if !ok {
  31436. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31437. }
  31438. m.SetCompletionTokens(v)
  31439. return nil
  31440. case usagedetail.FieldOrganizationID:
  31441. v, ok := value.(uint64)
  31442. if !ok {
  31443. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31444. }
  31445. m.SetOrganizationID(v)
  31446. return nil
  31447. }
  31448. return fmt.Errorf("unknown UsageDetail field %s", name)
  31449. }
  31450. // AddedFields returns all numeric fields that were incremented/decremented during
  31451. // this mutation.
  31452. func (m *UsageDetailMutation) AddedFields() []string {
  31453. var fields []string
  31454. if m.addstatus != nil {
  31455. fields = append(fields, usagedetail.FieldStatus)
  31456. }
  31457. if m.add_type != nil {
  31458. fields = append(fields, usagedetail.FieldType)
  31459. }
  31460. if m.addapp != nil {
  31461. fields = append(fields, usagedetail.FieldApp)
  31462. }
  31463. if m.addsession_id != nil {
  31464. fields = append(fields, usagedetail.FieldSessionID)
  31465. }
  31466. if m.addtotal_tokens != nil {
  31467. fields = append(fields, usagedetail.FieldTotalTokens)
  31468. }
  31469. if m.addprompt_tokens != nil {
  31470. fields = append(fields, usagedetail.FieldPromptTokens)
  31471. }
  31472. if m.addcompletion_tokens != nil {
  31473. fields = append(fields, usagedetail.FieldCompletionTokens)
  31474. }
  31475. if m.addorganization_id != nil {
  31476. fields = append(fields, usagedetail.FieldOrganizationID)
  31477. }
  31478. return fields
  31479. }
  31480. // AddedField returns the numeric value that was incremented/decremented on a field
  31481. // with the given name. The second boolean return value indicates that this field
  31482. // was not set, or was not defined in the schema.
  31483. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  31484. switch name {
  31485. case usagedetail.FieldStatus:
  31486. return m.AddedStatus()
  31487. case usagedetail.FieldType:
  31488. return m.AddedType()
  31489. case usagedetail.FieldApp:
  31490. return m.AddedApp()
  31491. case usagedetail.FieldSessionID:
  31492. return m.AddedSessionID()
  31493. case usagedetail.FieldTotalTokens:
  31494. return m.AddedTotalTokens()
  31495. case usagedetail.FieldPromptTokens:
  31496. return m.AddedPromptTokens()
  31497. case usagedetail.FieldCompletionTokens:
  31498. return m.AddedCompletionTokens()
  31499. case usagedetail.FieldOrganizationID:
  31500. return m.AddedOrganizationID()
  31501. }
  31502. return nil, false
  31503. }
  31504. // AddField adds the value to the field with the given name. It returns an error if
  31505. // the field is not defined in the schema, or if the type mismatched the field
  31506. // type.
  31507. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  31508. switch name {
  31509. case usagedetail.FieldStatus:
  31510. v, ok := value.(int8)
  31511. if !ok {
  31512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31513. }
  31514. m.AddStatus(v)
  31515. return nil
  31516. case usagedetail.FieldType:
  31517. v, ok := value.(int)
  31518. if !ok {
  31519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31520. }
  31521. m.AddType(v)
  31522. return nil
  31523. case usagedetail.FieldApp:
  31524. v, ok := value.(int)
  31525. if !ok {
  31526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31527. }
  31528. m.AddApp(v)
  31529. return nil
  31530. case usagedetail.FieldSessionID:
  31531. v, ok := value.(int64)
  31532. if !ok {
  31533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31534. }
  31535. m.AddSessionID(v)
  31536. return nil
  31537. case usagedetail.FieldTotalTokens:
  31538. v, ok := value.(int64)
  31539. if !ok {
  31540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31541. }
  31542. m.AddTotalTokens(v)
  31543. return nil
  31544. case usagedetail.FieldPromptTokens:
  31545. v, ok := value.(int64)
  31546. if !ok {
  31547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31548. }
  31549. m.AddPromptTokens(v)
  31550. return nil
  31551. case usagedetail.FieldCompletionTokens:
  31552. v, ok := value.(int64)
  31553. if !ok {
  31554. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31555. }
  31556. m.AddCompletionTokens(v)
  31557. return nil
  31558. case usagedetail.FieldOrganizationID:
  31559. v, ok := value.(int64)
  31560. if !ok {
  31561. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31562. }
  31563. m.AddOrganizationID(v)
  31564. return nil
  31565. }
  31566. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  31567. }
  31568. // ClearedFields returns all nullable fields that were cleared during this
  31569. // mutation.
  31570. func (m *UsageDetailMutation) ClearedFields() []string {
  31571. var fields []string
  31572. if m.FieldCleared(usagedetail.FieldStatus) {
  31573. fields = append(fields, usagedetail.FieldStatus)
  31574. }
  31575. if m.FieldCleared(usagedetail.FieldType) {
  31576. fields = append(fields, usagedetail.FieldType)
  31577. }
  31578. if m.FieldCleared(usagedetail.FieldApp) {
  31579. fields = append(fields, usagedetail.FieldApp)
  31580. }
  31581. if m.FieldCleared(usagedetail.FieldSessionID) {
  31582. fields = append(fields, usagedetail.FieldSessionID)
  31583. }
  31584. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  31585. fields = append(fields, usagedetail.FieldTotalTokens)
  31586. }
  31587. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  31588. fields = append(fields, usagedetail.FieldPromptTokens)
  31589. }
  31590. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  31591. fields = append(fields, usagedetail.FieldCompletionTokens)
  31592. }
  31593. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  31594. fields = append(fields, usagedetail.FieldOrganizationID)
  31595. }
  31596. return fields
  31597. }
  31598. // FieldCleared returns a boolean indicating if a field with the given name was
  31599. // cleared in this mutation.
  31600. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  31601. _, ok := m.clearedFields[name]
  31602. return ok
  31603. }
  31604. // ClearField clears the value of the field with the given name. It returns an
  31605. // error if the field is not defined in the schema.
  31606. func (m *UsageDetailMutation) ClearField(name string) error {
  31607. switch name {
  31608. case usagedetail.FieldStatus:
  31609. m.ClearStatus()
  31610. return nil
  31611. case usagedetail.FieldType:
  31612. m.ClearType()
  31613. return nil
  31614. case usagedetail.FieldApp:
  31615. m.ClearApp()
  31616. return nil
  31617. case usagedetail.FieldSessionID:
  31618. m.ClearSessionID()
  31619. return nil
  31620. case usagedetail.FieldTotalTokens:
  31621. m.ClearTotalTokens()
  31622. return nil
  31623. case usagedetail.FieldPromptTokens:
  31624. m.ClearPromptTokens()
  31625. return nil
  31626. case usagedetail.FieldCompletionTokens:
  31627. m.ClearCompletionTokens()
  31628. return nil
  31629. case usagedetail.FieldOrganizationID:
  31630. m.ClearOrganizationID()
  31631. return nil
  31632. }
  31633. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  31634. }
  31635. // ResetField resets all changes in the mutation for the field with the given name.
  31636. // It returns an error if the field is not defined in the schema.
  31637. func (m *UsageDetailMutation) ResetField(name string) error {
  31638. switch name {
  31639. case usagedetail.FieldCreatedAt:
  31640. m.ResetCreatedAt()
  31641. return nil
  31642. case usagedetail.FieldUpdatedAt:
  31643. m.ResetUpdatedAt()
  31644. return nil
  31645. case usagedetail.FieldStatus:
  31646. m.ResetStatus()
  31647. return nil
  31648. case usagedetail.FieldType:
  31649. m.ResetType()
  31650. return nil
  31651. case usagedetail.FieldBotID:
  31652. m.ResetBotID()
  31653. return nil
  31654. case usagedetail.FieldReceiverID:
  31655. m.ResetReceiverID()
  31656. return nil
  31657. case usagedetail.FieldApp:
  31658. m.ResetApp()
  31659. return nil
  31660. case usagedetail.FieldSessionID:
  31661. m.ResetSessionID()
  31662. return nil
  31663. case usagedetail.FieldRequest:
  31664. m.ResetRequest()
  31665. return nil
  31666. case usagedetail.FieldResponse:
  31667. m.ResetResponse()
  31668. return nil
  31669. case usagedetail.FieldOriginalData:
  31670. m.ResetOriginalData()
  31671. return nil
  31672. case usagedetail.FieldTotalTokens:
  31673. m.ResetTotalTokens()
  31674. return nil
  31675. case usagedetail.FieldPromptTokens:
  31676. m.ResetPromptTokens()
  31677. return nil
  31678. case usagedetail.FieldCompletionTokens:
  31679. m.ResetCompletionTokens()
  31680. return nil
  31681. case usagedetail.FieldOrganizationID:
  31682. m.ResetOrganizationID()
  31683. return nil
  31684. }
  31685. return fmt.Errorf("unknown UsageDetail field %s", name)
  31686. }
  31687. // AddedEdges returns all edge names that were set/added in this mutation.
  31688. func (m *UsageDetailMutation) AddedEdges() []string {
  31689. edges := make([]string, 0, 0)
  31690. return edges
  31691. }
  31692. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31693. // name in this mutation.
  31694. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  31695. return nil
  31696. }
  31697. // RemovedEdges returns all edge names that were removed in this mutation.
  31698. func (m *UsageDetailMutation) RemovedEdges() []string {
  31699. edges := make([]string, 0, 0)
  31700. return edges
  31701. }
  31702. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31703. // the given name in this mutation.
  31704. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  31705. return nil
  31706. }
  31707. // ClearedEdges returns all edge names that were cleared in this mutation.
  31708. func (m *UsageDetailMutation) ClearedEdges() []string {
  31709. edges := make([]string, 0, 0)
  31710. return edges
  31711. }
  31712. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31713. // was cleared in this mutation.
  31714. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  31715. return false
  31716. }
  31717. // ClearEdge clears the value of the edge with the given name. It returns an error
  31718. // if that edge is not defined in the schema.
  31719. func (m *UsageDetailMutation) ClearEdge(name string) error {
  31720. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  31721. }
  31722. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31723. // It returns an error if the edge is not defined in the schema.
  31724. func (m *UsageDetailMutation) ResetEdge(name string) error {
  31725. return fmt.Errorf("unknown UsageDetail edge %s", name)
  31726. }
  31727. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  31728. type UsageStatisticDayMutation struct {
  31729. config
  31730. op Op
  31731. typ string
  31732. id *uint64
  31733. created_at *time.Time
  31734. updated_at *time.Time
  31735. status *uint8
  31736. addstatus *int8
  31737. deleted_at *time.Time
  31738. addtime *uint64
  31739. addaddtime *int64
  31740. _type *int
  31741. add_type *int
  31742. bot_id *string
  31743. organization_id *uint64
  31744. addorganization_id *int64
  31745. ai_response *uint64
  31746. addai_response *int64
  31747. sop_run *uint64
  31748. addsop_run *int64
  31749. total_friend *uint64
  31750. addtotal_friend *int64
  31751. total_group *uint64
  31752. addtotal_group *int64
  31753. account_balance *uint64
  31754. addaccount_balance *int64
  31755. consume_token *uint64
  31756. addconsume_token *int64
  31757. active_user *uint64
  31758. addactive_user *int64
  31759. new_user *int64
  31760. addnew_user *int64
  31761. label_dist *[]custom_types.LabelDist
  31762. appendlabel_dist []custom_types.LabelDist
  31763. clearedFields map[string]struct{}
  31764. done bool
  31765. oldValue func(context.Context) (*UsageStatisticDay, error)
  31766. predicates []predicate.UsageStatisticDay
  31767. }
  31768. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  31769. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  31770. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  31771. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  31772. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  31773. m := &UsageStatisticDayMutation{
  31774. config: c,
  31775. op: op,
  31776. typ: TypeUsageStatisticDay,
  31777. clearedFields: make(map[string]struct{}),
  31778. }
  31779. for _, opt := range opts {
  31780. opt(m)
  31781. }
  31782. return m
  31783. }
  31784. // withUsageStatisticDayID sets the ID field of the mutation.
  31785. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  31786. return func(m *UsageStatisticDayMutation) {
  31787. var (
  31788. err error
  31789. once sync.Once
  31790. value *UsageStatisticDay
  31791. )
  31792. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  31793. once.Do(func() {
  31794. if m.done {
  31795. err = errors.New("querying old values post mutation is not allowed")
  31796. } else {
  31797. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  31798. }
  31799. })
  31800. return value, err
  31801. }
  31802. m.id = &id
  31803. }
  31804. }
  31805. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  31806. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  31807. return func(m *UsageStatisticDayMutation) {
  31808. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  31809. return node, nil
  31810. }
  31811. m.id = &node.ID
  31812. }
  31813. }
  31814. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31815. // executed in a transaction (ent.Tx), a transactional client is returned.
  31816. func (m UsageStatisticDayMutation) Client() *Client {
  31817. client := &Client{config: m.config}
  31818. client.init()
  31819. return client
  31820. }
  31821. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31822. // it returns an error otherwise.
  31823. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  31824. if _, ok := m.driver.(*txDriver); !ok {
  31825. return nil, errors.New("ent: mutation is not running in a transaction")
  31826. }
  31827. tx := &Tx{config: m.config}
  31828. tx.init()
  31829. return tx, nil
  31830. }
  31831. // SetID sets the value of the id field. Note that this
  31832. // operation is only accepted on creation of UsageStatisticDay entities.
  31833. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  31834. m.id = &id
  31835. }
  31836. // ID returns the ID value in the mutation. Note that the ID is only available
  31837. // if it was provided to the builder or after it was returned from the database.
  31838. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  31839. if m.id == nil {
  31840. return
  31841. }
  31842. return *m.id, true
  31843. }
  31844. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31845. // That means, if the mutation is applied within a transaction with an isolation level such
  31846. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  31847. // or updated by the mutation.
  31848. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  31849. switch {
  31850. case m.op.Is(OpUpdateOne | OpDeleteOne):
  31851. id, exists := m.ID()
  31852. if exists {
  31853. return []uint64{id}, nil
  31854. }
  31855. fallthrough
  31856. case m.op.Is(OpUpdate | OpDelete):
  31857. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  31858. default:
  31859. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  31860. }
  31861. }
  31862. // SetCreatedAt sets the "created_at" field.
  31863. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  31864. m.created_at = &t
  31865. }
  31866. // CreatedAt returns the value of the "created_at" field in the mutation.
  31867. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  31868. v := m.created_at
  31869. if v == nil {
  31870. return
  31871. }
  31872. return *v, true
  31873. }
  31874. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  31875. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31876. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31877. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31878. if !m.op.Is(OpUpdateOne) {
  31879. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31880. }
  31881. if m.id == nil || m.oldValue == nil {
  31882. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31883. }
  31884. oldValue, err := m.oldValue(ctx)
  31885. if err != nil {
  31886. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31887. }
  31888. return oldValue.CreatedAt, nil
  31889. }
  31890. // ResetCreatedAt resets all changes to the "created_at" field.
  31891. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  31892. m.created_at = nil
  31893. }
  31894. // SetUpdatedAt sets the "updated_at" field.
  31895. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  31896. m.updated_at = &t
  31897. }
  31898. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31899. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  31900. v := m.updated_at
  31901. if v == nil {
  31902. return
  31903. }
  31904. return *v, true
  31905. }
  31906. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  31907. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31908. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31909. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31910. if !m.op.Is(OpUpdateOne) {
  31911. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31912. }
  31913. if m.id == nil || m.oldValue == nil {
  31914. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31915. }
  31916. oldValue, err := m.oldValue(ctx)
  31917. if err != nil {
  31918. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31919. }
  31920. return oldValue.UpdatedAt, nil
  31921. }
  31922. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31923. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  31924. m.updated_at = nil
  31925. }
  31926. // SetStatus sets the "status" field.
  31927. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  31928. m.status = &u
  31929. m.addstatus = nil
  31930. }
  31931. // Status returns the value of the "status" field in the mutation.
  31932. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  31933. v := m.status
  31934. if v == nil {
  31935. return
  31936. }
  31937. return *v, true
  31938. }
  31939. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  31940. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31941. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31942. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  31943. if !m.op.Is(OpUpdateOne) {
  31944. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  31945. }
  31946. if m.id == nil || m.oldValue == nil {
  31947. return v, errors.New("OldStatus requires an ID field in the mutation")
  31948. }
  31949. oldValue, err := m.oldValue(ctx)
  31950. if err != nil {
  31951. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  31952. }
  31953. return oldValue.Status, nil
  31954. }
  31955. // AddStatus adds u to the "status" field.
  31956. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  31957. if m.addstatus != nil {
  31958. *m.addstatus += u
  31959. } else {
  31960. m.addstatus = &u
  31961. }
  31962. }
  31963. // AddedStatus returns the value that was added to the "status" field in this mutation.
  31964. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  31965. v := m.addstatus
  31966. if v == nil {
  31967. return
  31968. }
  31969. return *v, true
  31970. }
  31971. // ClearStatus clears the value of the "status" field.
  31972. func (m *UsageStatisticDayMutation) ClearStatus() {
  31973. m.status = nil
  31974. m.addstatus = nil
  31975. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  31976. }
  31977. // StatusCleared returns if the "status" field was cleared in this mutation.
  31978. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  31979. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  31980. return ok
  31981. }
  31982. // ResetStatus resets all changes to the "status" field.
  31983. func (m *UsageStatisticDayMutation) ResetStatus() {
  31984. m.status = nil
  31985. m.addstatus = nil
  31986. delete(m.clearedFields, usagestatisticday.FieldStatus)
  31987. }
  31988. // SetDeletedAt sets the "deleted_at" field.
  31989. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  31990. m.deleted_at = &t
  31991. }
  31992. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  31993. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  31994. v := m.deleted_at
  31995. if v == nil {
  31996. return
  31997. }
  31998. return *v, true
  31999. }
  32000. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  32001. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32002. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32003. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  32004. if !m.op.Is(OpUpdateOne) {
  32005. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  32006. }
  32007. if m.id == nil || m.oldValue == nil {
  32008. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  32009. }
  32010. oldValue, err := m.oldValue(ctx)
  32011. if err != nil {
  32012. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  32013. }
  32014. return oldValue.DeletedAt, nil
  32015. }
  32016. // ClearDeletedAt clears the value of the "deleted_at" field.
  32017. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  32018. m.deleted_at = nil
  32019. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  32020. }
  32021. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  32022. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  32023. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  32024. return ok
  32025. }
  32026. // ResetDeletedAt resets all changes to the "deleted_at" field.
  32027. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  32028. m.deleted_at = nil
  32029. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  32030. }
  32031. // SetAddtime sets the "addtime" field.
  32032. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  32033. m.addtime = &u
  32034. m.addaddtime = nil
  32035. }
  32036. // Addtime returns the value of the "addtime" field in the mutation.
  32037. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  32038. v := m.addtime
  32039. if v == nil {
  32040. return
  32041. }
  32042. return *v, true
  32043. }
  32044. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  32045. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32046. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32047. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  32048. if !m.op.Is(OpUpdateOne) {
  32049. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  32050. }
  32051. if m.id == nil || m.oldValue == nil {
  32052. return v, errors.New("OldAddtime requires an ID field in the mutation")
  32053. }
  32054. oldValue, err := m.oldValue(ctx)
  32055. if err != nil {
  32056. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  32057. }
  32058. return oldValue.Addtime, nil
  32059. }
  32060. // AddAddtime adds u to the "addtime" field.
  32061. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  32062. if m.addaddtime != nil {
  32063. *m.addaddtime += u
  32064. } else {
  32065. m.addaddtime = &u
  32066. }
  32067. }
  32068. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  32069. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  32070. v := m.addaddtime
  32071. if v == nil {
  32072. return
  32073. }
  32074. return *v, true
  32075. }
  32076. // ResetAddtime resets all changes to the "addtime" field.
  32077. func (m *UsageStatisticDayMutation) ResetAddtime() {
  32078. m.addtime = nil
  32079. m.addaddtime = nil
  32080. }
  32081. // SetType sets the "type" field.
  32082. func (m *UsageStatisticDayMutation) SetType(i int) {
  32083. m._type = &i
  32084. m.add_type = nil
  32085. }
  32086. // GetType returns the value of the "type" field in the mutation.
  32087. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  32088. v := m._type
  32089. if v == nil {
  32090. return
  32091. }
  32092. return *v, true
  32093. }
  32094. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  32095. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32096. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32097. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  32098. if !m.op.Is(OpUpdateOne) {
  32099. return v, errors.New("OldType is only allowed on UpdateOne operations")
  32100. }
  32101. if m.id == nil || m.oldValue == nil {
  32102. return v, errors.New("OldType requires an ID field in the mutation")
  32103. }
  32104. oldValue, err := m.oldValue(ctx)
  32105. if err != nil {
  32106. return v, fmt.Errorf("querying old value for OldType: %w", err)
  32107. }
  32108. return oldValue.Type, nil
  32109. }
  32110. // AddType adds i to the "type" field.
  32111. func (m *UsageStatisticDayMutation) AddType(i int) {
  32112. if m.add_type != nil {
  32113. *m.add_type += i
  32114. } else {
  32115. m.add_type = &i
  32116. }
  32117. }
  32118. // AddedType returns the value that was added to the "type" field in this mutation.
  32119. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  32120. v := m.add_type
  32121. if v == nil {
  32122. return
  32123. }
  32124. return *v, true
  32125. }
  32126. // ResetType resets all changes to the "type" field.
  32127. func (m *UsageStatisticDayMutation) ResetType() {
  32128. m._type = nil
  32129. m.add_type = nil
  32130. }
  32131. // SetBotID sets the "bot_id" field.
  32132. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  32133. m.bot_id = &s
  32134. }
  32135. // BotID returns the value of the "bot_id" field in the mutation.
  32136. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  32137. v := m.bot_id
  32138. if v == nil {
  32139. return
  32140. }
  32141. return *v, true
  32142. }
  32143. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  32144. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32145. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32146. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  32147. if !m.op.Is(OpUpdateOne) {
  32148. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  32149. }
  32150. if m.id == nil || m.oldValue == nil {
  32151. return v, errors.New("OldBotID requires an ID field in the mutation")
  32152. }
  32153. oldValue, err := m.oldValue(ctx)
  32154. if err != nil {
  32155. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  32156. }
  32157. return oldValue.BotID, nil
  32158. }
  32159. // ClearBotID clears the value of the "bot_id" field.
  32160. func (m *UsageStatisticDayMutation) ClearBotID() {
  32161. m.bot_id = nil
  32162. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  32163. }
  32164. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  32165. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  32166. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  32167. return ok
  32168. }
  32169. // ResetBotID resets all changes to the "bot_id" field.
  32170. func (m *UsageStatisticDayMutation) ResetBotID() {
  32171. m.bot_id = nil
  32172. delete(m.clearedFields, usagestatisticday.FieldBotID)
  32173. }
  32174. // SetOrganizationID sets the "organization_id" field.
  32175. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  32176. m.organization_id = &u
  32177. m.addorganization_id = nil
  32178. }
  32179. // OrganizationID returns the value of the "organization_id" field in the mutation.
  32180. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  32181. v := m.organization_id
  32182. if v == nil {
  32183. return
  32184. }
  32185. return *v, true
  32186. }
  32187. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  32188. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32189. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32190. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  32191. if !m.op.Is(OpUpdateOne) {
  32192. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  32193. }
  32194. if m.id == nil || m.oldValue == nil {
  32195. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  32196. }
  32197. oldValue, err := m.oldValue(ctx)
  32198. if err != nil {
  32199. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  32200. }
  32201. return oldValue.OrganizationID, nil
  32202. }
  32203. // AddOrganizationID adds u to the "organization_id" field.
  32204. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  32205. if m.addorganization_id != nil {
  32206. *m.addorganization_id += u
  32207. } else {
  32208. m.addorganization_id = &u
  32209. }
  32210. }
  32211. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  32212. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  32213. v := m.addorganization_id
  32214. if v == nil {
  32215. return
  32216. }
  32217. return *v, true
  32218. }
  32219. // ClearOrganizationID clears the value of the "organization_id" field.
  32220. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  32221. m.organization_id = nil
  32222. m.addorganization_id = nil
  32223. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  32224. }
  32225. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  32226. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  32227. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  32228. return ok
  32229. }
  32230. // ResetOrganizationID resets all changes to the "organization_id" field.
  32231. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  32232. m.organization_id = nil
  32233. m.addorganization_id = nil
  32234. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  32235. }
  32236. // SetAiResponse sets the "ai_response" field.
  32237. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  32238. m.ai_response = &u
  32239. m.addai_response = nil
  32240. }
  32241. // AiResponse returns the value of the "ai_response" field in the mutation.
  32242. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  32243. v := m.ai_response
  32244. if v == nil {
  32245. return
  32246. }
  32247. return *v, true
  32248. }
  32249. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  32250. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32251. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32252. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  32253. if !m.op.Is(OpUpdateOne) {
  32254. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  32255. }
  32256. if m.id == nil || m.oldValue == nil {
  32257. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  32258. }
  32259. oldValue, err := m.oldValue(ctx)
  32260. if err != nil {
  32261. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  32262. }
  32263. return oldValue.AiResponse, nil
  32264. }
  32265. // AddAiResponse adds u to the "ai_response" field.
  32266. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  32267. if m.addai_response != nil {
  32268. *m.addai_response += u
  32269. } else {
  32270. m.addai_response = &u
  32271. }
  32272. }
  32273. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  32274. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  32275. v := m.addai_response
  32276. if v == nil {
  32277. return
  32278. }
  32279. return *v, true
  32280. }
  32281. // ResetAiResponse resets all changes to the "ai_response" field.
  32282. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  32283. m.ai_response = nil
  32284. m.addai_response = nil
  32285. }
  32286. // SetSopRun sets the "sop_run" field.
  32287. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  32288. m.sop_run = &u
  32289. m.addsop_run = nil
  32290. }
  32291. // SopRun returns the value of the "sop_run" field in the mutation.
  32292. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  32293. v := m.sop_run
  32294. if v == nil {
  32295. return
  32296. }
  32297. return *v, true
  32298. }
  32299. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  32300. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32301. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32302. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  32303. if !m.op.Is(OpUpdateOne) {
  32304. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  32305. }
  32306. if m.id == nil || m.oldValue == nil {
  32307. return v, errors.New("OldSopRun requires an ID field in the mutation")
  32308. }
  32309. oldValue, err := m.oldValue(ctx)
  32310. if err != nil {
  32311. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  32312. }
  32313. return oldValue.SopRun, nil
  32314. }
  32315. // AddSopRun adds u to the "sop_run" field.
  32316. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  32317. if m.addsop_run != nil {
  32318. *m.addsop_run += u
  32319. } else {
  32320. m.addsop_run = &u
  32321. }
  32322. }
  32323. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  32324. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  32325. v := m.addsop_run
  32326. if v == nil {
  32327. return
  32328. }
  32329. return *v, true
  32330. }
  32331. // ResetSopRun resets all changes to the "sop_run" field.
  32332. func (m *UsageStatisticDayMutation) ResetSopRun() {
  32333. m.sop_run = nil
  32334. m.addsop_run = nil
  32335. }
  32336. // SetTotalFriend sets the "total_friend" field.
  32337. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  32338. m.total_friend = &u
  32339. m.addtotal_friend = nil
  32340. }
  32341. // TotalFriend returns the value of the "total_friend" field in the mutation.
  32342. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  32343. v := m.total_friend
  32344. if v == nil {
  32345. return
  32346. }
  32347. return *v, true
  32348. }
  32349. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  32350. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32351. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32352. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  32353. if !m.op.Is(OpUpdateOne) {
  32354. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  32355. }
  32356. if m.id == nil || m.oldValue == nil {
  32357. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  32358. }
  32359. oldValue, err := m.oldValue(ctx)
  32360. if err != nil {
  32361. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  32362. }
  32363. return oldValue.TotalFriend, nil
  32364. }
  32365. // AddTotalFriend adds u to the "total_friend" field.
  32366. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  32367. if m.addtotal_friend != nil {
  32368. *m.addtotal_friend += u
  32369. } else {
  32370. m.addtotal_friend = &u
  32371. }
  32372. }
  32373. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  32374. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  32375. v := m.addtotal_friend
  32376. if v == nil {
  32377. return
  32378. }
  32379. return *v, true
  32380. }
  32381. // ResetTotalFriend resets all changes to the "total_friend" field.
  32382. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  32383. m.total_friend = nil
  32384. m.addtotal_friend = nil
  32385. }
  32386. // SetTotalGroup sets the "total_group" field.
  32387. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  32388. m.total_group = &u
  32389. m.addtotal_group = nil
  32390. }
  32391. // TotalGroup returns the value of the "total_group" field in the mutation.
  32392. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  32393. v := m.total_group
  32394. if v == nil {
  32395. return
  32396. }
  32397. return *v, true
  32398. }
  32399. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  32400. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32402. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  32403. if !m.op.Is(OpUpdateOne) {
  32404. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  32405. }
  32406. if m.id == nil || m.oldValue == nil {
  32407. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  32408. }
  32409. oldValue, err := m.oldValue(ctx)
  32410. if err != nil {
  32411. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  32412. }
  32413. return oldValue.TotalGroup, nil
  32414. }
  32415. // AddTotalGroup adds u to the "total_group" field.
  32416. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  32417. if m.addtotal_group != nil {
  32418. *m.addtotal_group += u
  32419. } else {
  32420. m.addtotal_group = &u
  32421. }
  32422. }
  32423. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  32424. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  32425. v := m.addtotal_group
  32426. if v == nil {
  32427. return
  32428. }
  32429. return *v, true
  32430. }
  32431. // ResetTotalGroup resets all changes to the "total_group" field.
  32432. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  32433. m.total_group = nil
  32434. m.addtotal_group = nil
  32435. }
  32436. // SetAccountBalance sets the "account_balance" field.
  32437. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  32438. m.account_balance = &u
  32439. m.addaccount_balance = nil
  32440. }
  32441. // AccountBalance returns the value of the "account_balance" field in the mutation.
  32442. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  32443. v := m.account_balance
  32444. if v == nil {
  32445. return
  32446. }
  32447. return *v, true
  32448. }
  32449. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  32450. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32451. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32452. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  32453. if !m.op.Is(OpUpdateOne) {
  32454. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  32455. }
  32456. if m.id == nil || m.oldValue == nil {
  32457. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  32458. }
  32459. oldValue, err := m.oldValue(ctx)
  32460. if err != nil {
  32461. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  32462. }
  32463. return oldValue.AccountBalance, nil
  32464. }
  32465. // AddAccountBalance adds u to the "account_balance" field.
  32466. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  32467. if m.addaccount_balance != nil {
  32468. *m.addaccount_balance += u
  32469. } else {
  32470. m.addaccount_balance = &u
  32471. }
  32472. }
  32473. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  32474. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  32475. v := m.addaccount_balance
  32476. if v == nil {
  32477. return
  32478. }
  32479. return *v, true
  32480. }
  32481. // ResetAccountBalance resets all changes to the "account_balance" field.
  32482. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  32483. m.account_balance = nil
  32484. m.addaccount_balance = nil
  32485. }
  32486. // SetConsumeToken sets the "consume_token" field.
  32487. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  32488. m.consume_token = &u
  32489. m.addconsume_token = nil
  32490. }
  32491. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  32492. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  32493. v := m.consume_token
  32494. if v == nil {
  32495. return
  32496. }
  32497. return *v, true
  32498. }
  32499. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  32500. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32501. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32502. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  32503. if !m.op.Is(OpUpdateOne) {
  32504. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  32505. }
  32506. if m.id == nil || m.oldValue == nil {
  32507. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  32508. }
  32509. oldValue, err := m.oldValue(ctx)
  32510. if err != nil {
  32511. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  32512. }
  32513. return oldValue.ConsumeToken, nil
  32514. }
  32515. // AddConsumeToken adds u to the "consume_token" field.
  32516. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  32517. if m.addconsume_token != nil {
  32518. *m.addconsume_token += u
  32519. } else {
  32520. m.addconsume_token = &u
  32521. }
  32522. }
  32523. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  32524. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  32525. v := m.addconsume_token
  32526. if v == nil {
  32527. return
  32528. }
  32529. return *v, true
  32530. }
  32531. // ResetConsumeToken resets all changes to the "consume_token" field.
  32532. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  32533. m.consume_token = nil
  32534. m.addconsume_token = nil
  32535. }
  32536. // SetActiveUser sets the "active_user" field.
  32537. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  32538. m.active_user = &u
  32539. m.addactive_user = nil
  32540. }
  32541. // ActiveUser returns the value of the "active_user" field in the mutation.
  32542. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  32543. v := m.active_user
  32544. if v == nil {
  32545. return
  32546. }
  32547. return *v, true
  32548. }
  32549. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  32550. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32551. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32552. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  32553. if !m.op.Is(OpUpdateOne) {
  32554. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  32555. }
  32556. if m.id == nil || m.oldValue == nil {
  32557. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  32558. }
  32559. oldValue, err := m.oldValue(ctx)
  32560. if err != nil {
  32561. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  32562. }
  32563. return oldValue.ActiveUser, nil
  32564. }
  32565. // AddActiveUser adds u to the "active_user" field.
  32566. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  32567. if m.addactive_user != nil {
  32568. *m.addactive_user += u
  32569. } else {
  32570. m.addactive_user = &u
  32571. }
  32572. }
  32573. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  32574. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  32575. v := m.addactive_user
  32576. if v == nil {
  32577. return
  32578. }
  32579. return *v, true
  32580. }
  32581. // ResetActiveUser resets all changes to the "active_user" field.
  32582. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  32583. m.active_user = nil
  32584. m.addactive_user = nil
  32585. }
  32586. // SetNewUser sets the "new_user" field.
  32587. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  32588. m.new_user = &i
  32589. m.addnew_user = nil
  32590. }
  32591. // NewUser returns the value of the "new_user" field in the mutation.
  32592. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  32593. v := m.new_user
  32594. if v == nil {
  32595. return
  32596. }
  32597. return *v, true
  32598. }
  32599. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  32600. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32601. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32602. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  32603. if !m.op.Is(OpUpdateOne) {
  32604. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  32605. }
  32606. if m.id == nil || m.oldValue == nil {
  32607. return v, errors.New("OldNewUser requires an ID field in the mutation")
  32608. }
  32609. oldValue, err := m.oldValue(ctx)
  32610. if err != nil {
  32611. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  32612. }
  32613. return oldValue.NewUser, nil
  32614. }
  32615. // AddNewUser adds i to the "new_user" field.
  32616. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  32617. if m.addnew_user != nil {
  32618. *m.addnew_user += i
  32619. } else {
  32620. m.addnew_user = &i
  32621. }
  32622. }
  32623. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  32624. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  32625. v := m.addnew_user
  32626. if v == nil {
  32627. return
  32628. }
  32629. return *v, true
  32630. }
  32631. // ResetNewUser resets all changes to the "new_user" field.
  32632. func (m *UsageStatisticDayMutation) ResetNewUser() {
  32633. m.new_user = nil
  32634. m.addnew_user = nil
  32635. }
  32636. // SetLabelDist sets the "label_dist" field.
  32637. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  32638. m.label_dist = &ctd
  32639. m.appendlabel_dist = nil
  32640. }
  32641. // LabelDist returns the value of the "label_dist" field in the mutation.
  32642. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  32643. v := m.label_dist
  32644. if v == nil {
  32645. return
  32646. }
  32647. return *v, true
  32648. }
  32649. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  32650. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32652. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  32653. if !m.op.Is(OpUpdateOne) {
  32654. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  32655. }
  32656. if m.id == nil || m.oldValue == nil {
  32657. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  32658. }
  32659. oldValue, err := m.oldValue(ctx)
  32660. if err != nil {
  32661. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  32662. }
  32663. return oldValue.LabelDist, nil
  32664. }
  32665. // AppendLabelDist adds ctd to the "label_dist" field.
  32666. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  32667. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  32668. }
  32669. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  32670. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  32671. if len(m.appendlabel_dist) == 0 {
  32672. return nil, false
  32673. }
  32674. return m.appendlabel_dist, true
  32675. }
  32676. // ResetLabelDist resets all changes to the "label_dist" field.
  32677. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  32678. m.label_dist = nil
  32679. m.appendlabel_dist = nil
  32680. }
  32681. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  32682. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  32683. m.predicates = append(m.predicates, ps...)
  32684. }
  32685. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  32686. // users can use type-assertion to append predicates that do not depend on any generated package.
  32687. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  32688. p := make([]predicate.UsageStatisticDay, len(ps))
  32689. for i := range ps {
  32690. p[i] = ps[i]
  32691. }
  32692. m.Where(p...)
  32693. }
  32694. // Op returns the operation name.
  32695. func (m *UsageStatisticDayMutation) Op() Op {
  32696. return m.op
  32697. }
  32698. // SetOp allows setting the mutation operation.
  32699. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  32700. m.op = op
  32701. }
  32702. // Type returns the node type of this mutation (UsageStatisticDay).
  32703. func (m *UsageStatisticDayMutation) Type() string {
  32704. return m.typ
  32705. }
  32706. // Fields returns all fields that were changed during this mutation. Note that in
  32707. // order to get all numeric fields that were incremented/decremented, call
  32708. // AddedFields().
  32709. func (m *UsageStatisticDayMutation) Fields() []string {
  32710. fields := make([]string, 0, 17)
  32711. if m.created_at != nil {
  32712. fields = append(fields, usagestatisticday.FieldCreatedAt)
  32713. }
  32714. if m.updated_at != nil {
  32715. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  32716. }
  32717. if m.status != nil {
  32718. fields = append(fields, usagestatisticday.FieldStatus)
  32719. }
  32720. if m.deleted_at != nil {
  32721. fields = append(fields, usagestatisticday.FieldDeletedAt)
  32722. }
  32723. if m.addtime != nil {
  32724. fields = append(fields, usagestatisticday.FieldAddtime)
  32725. }
  32726. if m._type != nil {
  32727. fields = append(fields, usagestatisticday.FieldType)
  32728. }
  32729. if m.bot_id != nil {
  32730. fields = append(fields, usagestatisticday.FieldBotID)
  32731. }
  32732. if m.organization_id != nil {
  32733. fields = append(fields, usagestatisticday.FieldOrganizationID)
  32734. }
  32735. if m.ai_response != nil {
  32736. fields = append(fields, usagestatisticday.FieldAiResponse)
  32737. }
  32738. if m.sop_run != nil {
  32739. fields = append(fields, usagestatisticday.FieldSopRun)
  32740. }
  32741. if m.total_friend != nil {
  32742. fields = append(fields, usagestatisticday.FieldTotalFriend)
  32743. }
  32744. if m.total_group != nil {
  32745. fields = append(fields, usagestatisticday.FieldTotalGroup)
  32746. }
  32747. if m.account_balance != nil {
  32748. fields = append(fields, usagestatisticday.FieldAccountBalance)
  32749. }
  32750. if m.consume_token != nil {
  32751. fields = append(fields, usagestatisticday.FieldConsumeToken)
  32752. }
  32753. if m.active_user != nil {
  32754. fields = append(fields, usagestatisticday.FieldActiveUser)
  32755. }
  32756. if m.new_user != nil {
  32757. fields = append(fields, usagestatisticday.FieldNewUser)
  32758. }
  32759. if m.label_dist != nil {
  32760. fields = append(fields, usagestatisticday.FieldLabelDist)
  32761. }
  32762. return fields
  32763. }
  32764. // Field returns the value of a field with the given name. The second boolean
  32765. // return value indicates that this field was not set, or was not defined in the
  32766. // schema.
  32767. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  32768. switch name {
  32769. case usagestatisticday.FieldCreatedAt:
  32770. return m.CreatedAt()
  32771. case usagestatisticday.FieldUpdatedAt:
  32772. return m.UpdatedAt()
  32773. case usagestatisticday.FieldStatus:
  32774. return m.Status()
  32775. case usagestatisticday.FieldDeletedAt:
  32776. return m.DeletedAt()
  32777. case usagestatisticday.FieldAddtime:
  32778. return m.Addtime()
  32779. case usagestatisticday.FieldType:
  32780. return m.GetType()
  32781. case usagestatisticday.FieldBotID:
  32782. return m.BotID()
  32783. case usagestatisticday.FieldOrganizationID:
  32784. return m.OrganizationID()
  32785. case usagestatisticday.FieldAiResponse:
  32786. return m.AiResponse()
  32787. case usagestatisticday.FieldSopRun:
  32788. return m.SopRun()
  32789. case usagestatisticday.FieldTotalFriend:
  32790. return m.TotalFriend()
  32791. case usagestatisticday.FieldTotalGroup:
  32792. return m.TotalGroup()
  32793. case usagestatisticday.FieldAccountBalance:
  32794. return m.AccountBalance()
  32795. case usagestatisticday.FieldConsumeToken:
  32796. return m.ConsumeToken()
  32797. case usagestatisticday.FieldActiveUser:
  32798. return m.ActiveUser()
  32799. case usagestatisticday.FieldNewUser:
  32800. return m.NewUser()
  32801. case usagestatisticday.FieldLabelDist:
  32802. return m.LabelDist()
  32803. }
  32804. return nil, false
  32805. }
  32806. // OldField returns the old value of the field from the database. An error is
  32807. // returned if the mutation operation is not UpdateOne, or the query to the
  32808. // database failed.
  32809. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  32810. switch name {
  32811. case usagestatisticday.FieldCreatedAt:
  32812. return m.OldCreatedAt(ctx)
  32813. case usagestatisticday.FieldUpdatedAt:
  32814. return m.OldUpdatedAt(ctx)
  32815. case usagestatisticday.FieldStatus:
  32816. return m.OldStatus(ctx)
  32817. case usagestatisticday.FieldDeletedAt:
  32818. return m.OldDeletedAt(ctx)
  32819. case usagestatisticday.FieldAddtime:
  32820. return m.OldAddtime(ctx)
  32821. case usagestatisticday.FieldType:
  32822. return m.OldType(ctx)
  32823. case usagestatisticday.FieldBotID:
  32824. return m.OldBotID(ctx)
  32825. case usagestatisticday.FieldOrganizationID:
  32826. return m.OldOrganizationID(ctx)
  32827. case usagestatisticday.FieldAiResponse:
  32828. return m.OldAiResponse(ctx)
  32829. case usagestatisticday.FieldSopRun:
  32830. return m.OldSopRun(ctx)
  32831. case usagestatisticday.FieldTotalFriend:
  32832. return m.OldTotalFriend(ctx)
  32833. case usagestatisticday.FieldTotalGroup:
  32834. return m.OldTotalGroup(ctx)
  32835. case usagestatisticday.FieldAccountBalance:
  32836. return m.OldAccountBalance(ctx)
  32837. case usagestatisticday.FieldConsumeToken:
  32838. return m.OldConsumeToken(ctx)
  32839. case usagestatisticday.FieldActiveUser:
  32840. return m.OldActiveUser(ctx)
  32841. case usagestatisticday.FieldNewUser:
  32842. return m.OldNewUser(ctx)
  32843. case usagestatisticday.FieldLabelDist:
  32844. return m.OldLabelDist(ctx)
  32845. }
  32846. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  32847. }
  32848. // SetField sets the value of a field with the given name. It returns an error if
  32849. // the field is not defined in the schema, or if the type mismatched the field
  32850. // type.
  32851. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  32852. switch name {
  32853. case usagestatisticday.FieldCreatedAt:
  32854. v, ok := value.(time.Time)
  32855. if !ok {
  32856. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32857. }
  32858. m.SetCreatedAt(v)
  32859. return nil
  32860. case usagestatisticday.FieldUpdatedAt:
  32861. v, ok := value.(time.Time)
  32862. if !ok {
  32863. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32864. }
  32865. m.SetUpdatedAt(v)
  32866. return nil
  32867. case usagestatisticday.FieldStatus:
  32868. v, ok := value.(uint8)
  32869. if !ok {
  32870. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32871. }
  32872. m.SetStatus(v)
  32873. return nil
  32874. case usagestatisticday.FieldDeletedAt:
  32875. v, ok := value.(time.Time)
  32876. if !ok {
  32877. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32878. }
  32879. m.SetDeletedAt(v)
  32880. return nil
  32881. case usagestatisticday.FieldAddtime:
  32882. v, ok := value.(uint64)
  32883. if !ok {
  32884. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32885. }
  32886. m.SetAddtime(v)
  32887. return nil
  32888. case usagestatisticday.FieldType:
  32889. v, ok := value.(int)
  32890. if !ok {
  32891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32892. }
  32893. m.SetType(v)
  32894. return nil
  32895. case usagestatisticday.FieldBotID:
  32896. v, ok := value.(string)
  32897. if !ok {
  32898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32899. }
  32900. m.SetBotID(v)
  32901. return nil
  32902. case usagestatisticday.FieldOrganizationID:
  32903. v, ok := value.(uint64)
  32904. if !ok {
  32905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32906. }
  32907. m.SetOrganizationID(v)
  32908. return nil
  32909. case usagestatisticday.FieldAiResponse:
  32910. v, ok := value.(uint64)
  32911. if !ok {
  32912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32913. }
  32914. m.SetAiResponse(v)
  32915. return nil
  32916. case usagestatisticday.FieldSopRun:
  32917. v, ok := value.(uint64)
  32918. if !ok {
  32919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32920. }
  32921. m.SetSopRun(v)
  32922. return nil
  32923. case usagestatisticday.FieldTotalFriend:
  32924. v, ok := value.(uint64)
  32925. if !ok {
  32926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32927. }
  32928. m.SetTotalFriend(v)
  32929. return nil
  32930. case usagestatisticday.FieldTotalGroup:
  32931. v, ok := value.(uint64)
  32932. if !ok {
  32933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32934. }
  32935. m.SetTotalGroup(v)
  32936. return nil
  32937. case usagestatisticday.FieldAccountBalance:
  32938. v, ok := value.(uint64)
  32939. if !ok {
  32940. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32941. }
  32942. m.SetAccountBalance(v)
  32943. return nil
  32944. case usagestatisticday.FieldConsumeToken:
  32945. v, ok := value.(uint64)
  32946. if !ok {
  32947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32948. }
  32949. m.SetConsumeToken(v)
  32950. return nil
  32951. case usagestatisticday.FieldActiveUser:
  32952. v, ok := value.(uint64)
  32953. if !ok {
  32954. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32955. }
  32956. m.SetActiveUser(v)
  32957. return nil
  32958. case usagestatisticday.FieldNewUser:
  32959. v, ok := value.(int64)
  32960. if !ok {
  32961. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32962. }
  32963. m.SetNewUser(v)
  32964. return nil
  32965. case usagestatisticday.FieldLabelDist:
  32966. v, ok := value.([]custom_types.LabelDist)
  32967. if !ok {
  32968. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32969. }
  32970. m.SetLabelDist(v)
  32971. return nil
  32972. }
  32973. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  32974. }
  32975. // AddedFields returns all numeric fields that were incremented/decremented during
  32976. // this mutation.
  32977. func (m *UsageStatisticDayMutation) AddedFields() []string {
  32978. var fields []string
  32979. if m.addstatus != nil {
  32980. fields = append(fields, usagestatisticday.FieldStatus)
  32981. }
  32982. if m.addaddtime != nil {
  32983. fields = append(fields, usagestatisticday.FieldAddtime)
  32984. }
  32985. if m.add_type != nil {
  32986. fields = append(fields, usagestatisticday.FieldType)
  32987. }
  32988. if m.addorganization_id != nil {
  32989. fields = append(fields, usagestatisticday.FieldOrganizationID)
  32990. }
  32991. if m.addai_response != nil {
  32992. fields = append(fields, usagestatisticday.FieldAiResponse)
  32993. }
  32994. if m.addsop_run != nil {
  32995. fields = append(fields, usagestatisticday.FieldSopRun)
  32996. }
  32997. if m.addtotal_friend != nil {
  32998. fields = append(fields, usagestatisticday.FieldTotalFriend)
  32999. }
  33000. if m.addtotal_group != nil {
  33001. fields = append(fields, usagestatisticday.FieldTotalGroup)
  33002. }
  33003. if m.addaccount_balance != nil {
  33004. fields = append(fields, usagestatisticday.FieldAccountBalance)
  33005. }
  33006. if m.addconsume_token != nil {
  33007. fields = append(fields, usagestatisticday.FieldConsumeToken)
  33008. }
  33009. if m.addactive_user != nil {
  33010. fields = append(fields, usagestatisticday.FieldActiveUser)
  33011. }
  33012. if m.addnew_user != nil {
  33013. fields = append(fields, usagestatisticday.FieldNewUser)
  33014. }
  33015. return fields
  33016. }
  33017. // AddedField returns the numeric value that was incremented/decremented on a field
  33018. // with the given name. The second boolean return value indicates that this field
  33019. // was not set, or was not defined in the schema.
  33020. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  33021. switch name {
  33022. case usagestatisticday.FieldStatus:
  33023. return m.AddedStatus()
  33024. case usagestatisticday.FieldAddtime:
  33025. return m.AddedAddtime()
  33026. case usagestatisticday.FieldType:
  33027. return m.AddedType()
  33028. case usagestatisticday.FieldOrganizationID:
  33029. return m.AddedOrganizationID()
  33030. case usagestatisticday.FieldAiResponse:
  33031. return m.AddedAiResponse()
  33032. case usagestatisticday.FieldSopRun:
  33033. return m.AddedSopRun()
  33034. case usagestatisticday.FieldTotalFriend:
  33035. return m.AddedTotalFriend()
  33036. case usagestatisticday.FieldTotalGroup:
  33037. return m.AddedTotalGroup()
  33038. case usagestatisticday.FieldAccountBalance:
  33039. return m.AddedAccountBalance()
  33040. case usagestatisticday.FieldConsumeToken:
  33041. return m.AddedConsumeToken()
  33042. case usagestatisticday.FieldActiveUser:
  33043. return m.AddedActiveUser()
  33044. case usagestatisticday.FieldNewUser:
  33045. return m.AddedNewUser()
  33046. }
  33047. return nil, false
  33048. }
  33049. // AddField adds the value to the field with the given name. It returns an error if
  33050. // the field is not defined in the schema, or if the type mismatched the field
  33051. // type.
  33052. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  33053. switch name {
  33054. case usagestatisticday.FieldStatus:
  33055. v, ok := value.(int8)
  33056. if !ok {
  33057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33058. }
  33059. m.AddStatus(v)
  33060. return nil
  33061. case usagestatisticday.FieldAddtime:
  33062. v, ok := value.(int64)
  33063. if !ok {
  33064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33065. }
  33066. m.AddAddtime(v)
  33067. return nil
  33068. case usagestatisticday.FieldType:
  33069. v, ok := value.(int)
  33070. if !ok {
  33071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33072. }
  33073. m.AddType(v)
  33074. return nil
  33075. case usagestatisticday.FieldOrganizationID:
  33076. v, ok := value.(int64)
  33077. if !ok {
  33078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33079. }
  33080. m.AddOrganizationID(v)
  33081. return nil
  33082. case usagestatisticday.FieldAiResponse:
  33083. v, ok := value.(int64)
  33084. if !ok {
  33085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33086. }
  33087. m.AddAiResponse(v)
  33088. return nil
  33089. case usagestatisticday.FieldSopRun:
  33090. v, ok := value.(int64)
  33091. if !ok {
  33092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33093. }
  33094. m.AddSopRun(v)
  33095. return nil
  33096. case usagestatisticday.FieldTotalFriend:
  33097. v, ok := value.(int64)
  33098. if !ok {
  33099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33100. }
  33101. m.AddTotalFriend(v)
  33102. return nil
  33103. case usagestatisticday.FieldTotalGroup:
  33104. v, ok := value.(int64)
  33105. if !ok {
  33106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33107. }
  33108. m.AddTotalGroup(v)
  33109. return nil
  33110. case usagestatisticday.FieldAccountBalance:
  33111. v, ok := value.(int64)
  33112. if !ok {
  33113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33114. }
  33115. m.AddAccountBalance(v)
  33116. return nil
  33117. case usagestatisticday.FieldConsumeToken:
  33118. v, ok := value.(int64)
  33119. if !ok {
  33120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33121. }
  33122. m.AddConsumeToken(v)
  33123. return nil
  33124. case usagestatisticday.FieldActiveUser:
  33125. v, ok := value.(int64)
  33126. if !ok {
  33127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33128. }
  33129. m.AddActiveUser(v)
  33130. return nil
  33131. case usagestatisticday.FieldNewUser:
  33132. v, ok := value.(int64)
  33133. if !ok {
  33134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33135. }
  33136. m.AddNewUser(v)
  33137. return nil
  33138. }
  33139. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  33140. }
  33141. // ClearedFields returns all nullable fields that were cleared during this
  33142. // mutation.
  33143. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  33144. var fields []string
  33145. if m.FieldCleared(usagestatisticday.FieldStatus) {
  33146. fields = append(fields, usagestatisticday.FieldStatus)
  33147. }
  33148. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  33149. fields = append(fields, usagestatisticday.FieldDeletedAt)
  33150. }
  33151. if m.FieldCleared(usagestatisticday.FieldBotID) {
  33152. fields = append(fields, usagestatisticday.FieldBotID)
  33153. }
  33154. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  33155. fields = append(fields, usagestatisticday.FieldOrganizationID)
  33156. }
  33157. return fields
  33158. }
  33159. // FieldCleared returns a boolean indicating if a field with the given name was
  33160. // cleared in this mutation.
  33161. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  33162. _, ok := m.clearedFields[name]
  33163. return ok
  33164. }
  33165. // ClearField clears the value of the field with the given name. It returns an
  33166. // error if the field is not defined in the schema.
  33167. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  33168. switch name {
  33169. case usagestatisticday.FieldStatus:
  33170. m.ClearStatus()
  33171. return nil
  33172. case usagestatisticday.FieldDeletedAt:
  33173. m.ClearDeletedAt()
  33174. return nil
  33175. case usagestatisticday.FieldBotID:
  33176. m.ClearBotID()
  33177. return nil
  33178. case usagestatisticday.FieldOrganizationID:
  33179. m.ClearOrganizationID()
  33180. return nil
  33181. }
  33182. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  33183. }
  33184. // ResetField resets all changes in the mutation for the field with the given name.
  33185. // It returns an error if the field is not defined in the schema.
  33186. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  33187. switch name {
  33188. case usagestatisticday.FieldCreatedAt:
  33189. m.ResetCreatedAt()
  33190. return nil
  33191. case usagestatisticday.FieldUpdatedAt:
  33192. m.ResetUpdatedAt()
  33193. return nil
  33194. case usagestatisticday.FieldStatus:
  33195. m.ResetStatus()
  33196. return nil
  33197. case usagestatisticday.FieldDeletedAt:
  33198. m.ResetDeletedAt()
  33199. return nil
  33200. case usagestatisticday.FieldAddtime:
  33201. m.ResetAddtime()
  33202. return nil
  33203. case usagestatisticday.FieldType:
  33204. m.ResetType()
  33205. return nil
  33206. case usagestatisticday.FieldBotID:
  33207. m.ResetBotID()
  33208. return nil
  33209. case usagestatisticday.FieldOrganizationID:
  33210. m.ResetOrganizationID()
  33211. return nil
  33212. case usagestatisticday.FieldAiResponse:
  33213. m.ResetAiResponse()
  33214. return nil
  33215. case usagestatisticday.FieldSopRun:
  33216. m.ResetSopRun()
  33217. return nil
  33218. case usagestatisticday.FieldTotalFriend:
  33219. m.ResetTotalFriend()
  33220. return nil
  33221. case usagestatisticday.FieldTotalGroup:
  33222. m.ResetTotalGroup()
  33223. return nil
  33224. case usagestatisticday.FieldAccountBalance:
  33225. m.ResetAccountBalance()
  33226. return nil
  33227. case usagestatisticday.FieldConsumeToken:
  33228. m.ResetConsumeToken()
  33229. return nil
  33230. case usagestatisticday.FieldActiveUser:
  33231. m.ResetActiveUser()
  33232. return nil
  33233. case usagestatisticday.FieldNewUser:
  33234. m.ResetNewUser()
  33235. return nil
  33236. case usagestatisticday.FieldLabelDist:
  33237. m.ResetLabelDist()
  33238. return nil
  33239. }
  33240. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  33241. }
  33242. // AddedEdges returns all edge names that were set/added in this mutation.
  33243. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  33244. edges := make([]string, 0, 0)
  33245. return edges
  33246. }
  33247. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33248. // name in this mutation.
  33249. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  33250. return nil
  33251. }
  33252. // RemovedEdges returns all edge names that were removed in this mutation.
  33253. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  33254. edges := make([]string, 0, 0)
  33255. return edges
  33256. }
  33257. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33258. // the given name in this mutation.
  33259. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  33260. return nil
  33261. }
  33262. // ClearedEdges returns all edge names that were cleared in this mutation.
  33263. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  33264. edges := make([]string, 0, 0)
  33265. return edges
  33266. }
  33267. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33268. // was cleared in this mutation.
  33269. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  33270. return false
  33271. }
  33272. // ClearEdge clears the value of the edge with the given name. It returns an error
  33273. // if that edge is not defined in the schema.
  33274. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  33275. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  33276. }
  33277. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33278. // It returns an error if the edge is not defined in the schema.
  33279. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  33280. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  33281. }
  33282. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  33283. type UsageStatisticHourMutation struct {
  33284. config
  33285. op Op
  33286. typ string
  33287. id *uint64
  33288. created_at *time.Time
  33289. updated_at *time.Time
  33290. status *uint8
  33291. addstatus *int8
  33292. deleted_at *time.Time
  33293. addtime *uint64
  33294. addaddtime *int64
  33295. _type *int
  33296. add_type *int
  33297. bot_id *string
  33298. organization_id *uint64
  33299. addorganization_id *int64
  33300. ai_response *uint64
  33301. addai_response *int64
  33302. sop_run *uint64
  33303. addsop_run *int64
  33304. total_friend *uint64
  33305. addtotal_friend *int64
  33306. total_group *uint64
  33307. addtotal_group *int64
  33308. account_balance *uint64
  33309. addaccount_balance *int64
  33310. consume_token *uint64
  33311. addconsume_token *int64
  33312. active_user *uint64
  33313. addactive_user *int64
  33314. new_user *int64
  33315. addnew_user *int64
  33316. label_dist *[]custom_types.LabelDist
  33317. appendlabel_dist []custom_types.LabelDist
  33318. clearedFields map[string]struct{}
  33319. done bool
  33320. oldValue func(context.Context) (*UsageStatisticHour, error)
  33321. predicates []predicate.UsageStatisticHour
  33322. }
  33323. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  33324. // usagestatistichourOption allows management of the mutation configuration using functional options.
  33325. type usagestatistichourOption func(*UsageStatisticHourMutation)
  33326. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  33327. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  33328. m := &UsageStatisticHourMutation{
  33329. config: c,
  33330. op: op,
  33331. typ: TypeUsageStatisticHour,
  33332. clearedFields: make(map[string]struct{}),
  33333. }
  33334. for _, opt := range opts {
  33335. opt(m)
  33336. }
  33337. return m
  33338. }
  33339. // withUsageStatisticHourID sets the ID field of the mutation.
  33340. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  33341. return func(m *UsageStatisticHourMutation) {
  33342. var (
  33343. err error
  33344. once sync.Once
  33345. value *UsageStatisticHour
  33346. )
  33347. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  33348. once.Do(func() {
  33349. if m.done {
  33350. err = errors.New("querying old values post mutation is not allowed")
  33351. } else {
  33352. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  33353. }
  33354. })
  33355. return value, err
  33356. }
  33357. m.id = &id
  33358. }
  33359. }
  33360. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  33361. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  33362. return func(m *UsageStatisticHourMutation) {
  33363. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  33364. return node, nil
  33365. }
  33366. m.id = &node.ID
  33367. }
  33368. }
  33369. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33370. // executed in a transaction (ent.Tx), a transactional client is returned.
  33371. func (m UsageStatisticHourMutation) Client() *Client {
  33372. client := &Client{config: m.config}
  33373. client.init()
  33374. return client
  33375. }
  33376. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33377. // it returns an error otherwise.
  33378. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  33379. if _, ok := m.driver.(*txDriver); !ok {
  33380. return nil, errors.New("ent: mutation is not running in a transaction")
  33381. }
  33382. tx := &Tx{config: m.config}
  33383. tx.init()
  33384. return tx, nil
  33385. }
  33386. // SetID sets the value of the id field. Note that this
  33387. // operation is only accepted on creation of UsageStatisticHour entities.
  33388. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  33389. m.id = &id
  33390. }
  33391. // ID returns the ID value in the mutation. Note that the ID is only available
  33392. // if it was provided to the builder or after it was returned from the database.
  33393. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  33394. if m.id == nil {
  33395. return
  33396. }
  33397. return *m.id, true
  33398. }
  33399. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33400. // That means, if the mutation is applied within a transaction with an isolation level such
  33401. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33402. // or updated by the mutation.
  33403. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  33404. switch {
  33405. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33406. id, exists := m.ID()
  33407. if exists {
  33408. return []uint64{id}, nil
  33409. }
  33410. fallthrough
  33411. case m.op.Is(OpUpdate | OpDelete):
  33412. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  33413. default:
  33414. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  33415. }
  33416. }
  33417. // SetCreatedAt sets the "created_at" field.
  33418. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  33419. m.created_at = &t
  33420. }
  33421. // CreatedAt returns the value of the "created_at" field in the mutation.
  33422. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  33423. v := m.created_at
  33424. if v == nil {
  33425. return
  33426. }
  33427. return *v, true
  33428. }
  33429. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  33430. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33432. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  33433. if !m.op.Is(OpUpdateOne) {
  33434. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  33435. }
  33436. if m.id == nil || m.oldValue == nil {
  33437. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  33438. }
  33439. oldValue, err := m.oldValue(ctx)
  33440. if err != nil {
  33441. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  33442. }
  33443. return oldValue.CreatedAt, nil
  33444. }
  33445. // ResetCreatedAt resets all changes to the "created_at" field.
  33446. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  33447. m.created_at = nil
  33448. }
  33449. // SetUpdatedAt sets the "updated_at" field.
  33450. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  33451. m.updated_at = &t
  33452. }
  33453. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  33454. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  33455. v := m.updated_at
  33456. if v == nil {
  33457. return
  33458. }
  33459. return *v, true
  33460. }
  33461. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  33462. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33463. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33464. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  33465. if !m.op.Is(OpUpdateOne) {
  33466. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  33467. }
  33468. if m.id == nil || m.oldValue == nil {
  33469. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  33470. }
  33471. oldValue, err := m.oldValue(ctx)
  33472. if err != nil {
  33473. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  33474. }
  33475. return oldValue.UpdatedAt, nil
  33476. }
  33477. // ResetUpdatedAt resets all changes to the "updated_at" field.
  33478. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  33479. m.updated_at = nil
  33480. }
  33481. // SetStatus sets the "status" field.
  33482. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  33483. m.status = &u
  33484. m.addstatus = nil
  33485. }
  33486. // Status returns the value of the "status" field in the mutation.
  33487. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  33488. v := m.status
  33489. if v == nil {
  33490. return
  33491. }
  33492. return *v, true
  33493. }
  33494. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  33495. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33496. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33497. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  33498. if !m.op.Is(OpUpdateOne) {
  33499. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  33500. }
  33501. if m.id == nil || m.oldValue == nil {
  33502. return v, errors.New("OldStatus requires an ID field in the mutation")
  33503. }
  33504. oldValue, err := m.oldValue(ctx)
  33505. if err != nil {
  33506. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  33507. }
  33508. return oldValue.Status, nil
  33509. }
  33510. // AddStatus adds u to the "status" field.
  33511. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  33512. if m.addstatus != nil {
  33513. *m.addstatus += u
  33514. } else {
  33515. m.addstatus = &u
  33516. }
  33517. }
  33518. // AddedStatus returns the value that was added to the "status" field in this mutation.
  33519. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  33520. v := m.addstatus
  33521. if v == nil {
  33522. return
  33523. }
  33524. return *v, true
  33525. }
  33526. // ClearStatus clears the value of the "status" field.
  33527. func (m *UsageStatisticHourMutation) ClearStatus() {
  33528. m.status = nil
  33529. m.addstatus = nil
  33530. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  33531. }
  33532. // StatusCleared returns if the "status" field was cleared in this mutation.
  33533. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  33534. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  33535. return ok
  33536. }
  33537. // ResetStatus resets all changes to the "status" field.
  33538. func (m *UsageStatisticHourMutation) ResetStatus() {
  33539. m.status = nil
  33540. m.addstatus = nil
  33541. delete(m.clearedFields, usagestatistichour.FieldStatus)
  33542. }
  33543. // SetDeletedAt sets the "deleted_at" field.
  33544. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  33545. m.deleted_at = &t
  33546. }
  33547. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  33548. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  33549. v := m.deleted_at
  33550. if v == nil {
  33551. return
  33552. }
  33553. return *v, true
  33554. }
  33555. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  33556. // If the UsageStatisticHour 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 *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  33559. if !m.op.Is(OpUpdateOne) {
  33560. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  33561. }
  33562. if m.id == nil || m.oldValue == nil {
  33563. return v, errors.New("OldDeletedAt 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 OldDeletedAt: %w", err)
  33568. }
  33569. return oldValue.DeletedAt, nil
  33570. }
  33571. // ClearDeletedAt clears the value of the "deleted_at" field.
  33572. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  33573. m.deleted_at = nil
  33574. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  33575. }
  33576. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  33577. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  33578. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  33579. return ok
  33580. }
  33581. // ResetDeletedAt resets all changes to the "deleted_at" field.
  33582. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  33583. m.deleted_at = nil
  33584. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  33585. }
  33586. // SetAddtime sets the "addtime" field.
  33587. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  33588. m.addtime = &u
  33589. m.addaddtime = nil
  33590. }
  33591. // Addtime returns the value of the "addtime" field in the mutation.
  33592. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  33593. v := m.addtime
  33594. if v == nil {
  33595. return
  33596. }
  33597. return *v, true
  33598. }
  33599. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  33600. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33601. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33602. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  33603. if !m.op.Is(OpUpdateOne) {
  33604. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  33605. }
  33606. if m.id == nil || m.oldValue == nil {
  33607. return v, errors.New("OldAddtime requires an ID field in the mutation")
  33608. }
  33609. oldValue, err := m.oldValue(ctx)
  33610. if err != nil {
  33611. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  33612. }
  33613. return oldValue.Addtime, nil
  33614. }
  33615. // AddAddtime adds u to the "addtime" field.
  33616. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  33617. if m.addaddtime != nil {
  33618. *m.addaddtime += u
  33619. } else {
  33620. m.addaddtime = &u
  33621. }
  33622. }
  33623. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  33624. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  33625. v := m.addaddtime
  33626. if v == nil {
  33627. return
  33628. }
  33629. return *v, true
  33630. }
  33631. // ResetAddtime resets all changes to the "addtime" field.
  33632. func (m *UsageStatisticHourMutation) ResetAddtime() {
  33633. m.addtime = nil
  33634. m.addaddtime = nil
  33635. }
  33636. // SetType sets the "type" field.
  33637. func (m *UsageStatisticHourMutation) SetType(i int) {
  33638. m._type = &i
  33639. m.add_type = nil
  33640. }
  33641. // GetType returns the value of the "type" field in the mutation.
  33642. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  33643. v := m._type
  33644. if v == nil {
  33645. return
  33646. }
  33647. return *v, true
  33648. }
  33649. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  33650. // If the UsageStatisticHour 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 *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  33653. if !m.op.Is(OpUpdateOne) {
  33654. return v, errors.New("OldType is only allowed on UpdateOne operations")
  33655. }
  33656. if m.id == nil || m.oldValue == nil {
  33657. return v, errors.New("OldType 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 OldType: %w", err)
  33662. }
  33663. return oldValue.Type, nil
  33664. }
  33665. // AddType adds i to the "type" field.
  33666. func (m *UsageStatisticHourMutation) AddType(i int) {
  33667. if m.add_type != nil {
  33668. *m.add_type += i
  33669. } else {
  33670. m.add_type = &i
  33671. }
  33672. }
  33673. // AddedType returns the value that was added to the "type" field in this mutation.
  33674. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  33675. v := m.add_type
  33676. if v == nil {
  33677. return
  33678. }
  33679. return *v, true
  33680. }
  33681. // ResetType resets all changes to the "type" field.
  33682. func (m *UsageStatisticHourMutation) ResetType() {
  33683. m._type = nil
  33684. m.add_type = nil
  33685. }
  33686. // SetBotID sets the "bot_id" field.
  33687. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  33688. m.bot_id = &s
  33689. }
  33690. // BotID returns the value of the "bot_id" field in the mutation.
  33691. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  33692. v := m.bot_id
  33693. if v == nil {
  33694. return
  33695. }
  33696. return *v, true
  33697. }
  33698. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  33699. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33700. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33701. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  33702. if !m.op.Is(OpUpdateOne) {
  33703. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  33704. }
  33705. if m.id == nil || m.oldValue == nil {
  33706. return v, errors.New("OldBotID requires an ID field in the mutation")
  33707. }
  33708. oldValue, err := m.oldValue(ctx)
  33709. if err != nil {
  33710. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  33711. }
  33712. return oldValue.BotID, nil
  33713. }
  33714. // ClearBotID clears the value of the "bot_id" field.
  33715. func (m *UsageStatisticHourMutation) ClearBotID() {
  33716. m.bot_id = nil
  33717. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  33718. }
  33719. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  33720. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  33721. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  33722. return ok
  33723. }
  33724. // ResetBotID resets all changes to the "bot_id" field.
  33725. func (m *UsageStatisticHourMutation) ResetBotID() {
  33726. m.bot_id = nil
  33727. delete(m.clearedFields, usagestatistichour.FieldBotID)
  33728. }
  33729. // SetOrganizationID sets the "organization_id" field.
  33730. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  33731. m.organization_id = &u
  33732. m.addorganization_id = nil
  33733. }
  33734. // OrganizationID returns the value of the "organization_id" field in the mutation.
  33735. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  33736. v := m.organization_id
  33737. if v == nil {
  33738. return
  33739. }
  33740. return *v, true
  33741. }
  33742. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  33743. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33744. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33745. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  33746. if !m.op.Is(OpUpdateOne) {
  33747. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  33748. }
  33749. if m.id == nil || m.oldValue == nil {
  33750. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  33751. }
  33752. oldValue, err := m.oldValue(ctx)
  33753. if err != nil {
  33754. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  33755. }
  33756. return oldValue.OrganizationID, nil
  33757. }
  33758. // AddOrganizationID adds u to the "organization_id" field.
  33759. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  33760. if m.addorganization_id != nil {
  33761. *m.addorganization_id += u
  33762. } else {
  33763. m.addorganization_id = &u
  33764. }
  33765. }
  33766. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  33767. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  33768. v := m.addorganization_id
  33769. if v == nil {
  33770. return
  33771. }
  33772. return *v, true
  33773. }
  33774. // ClearOrganizationID clears the value of the "organization_id" field.
  33775. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  33776. m.organization_id = nil
  33777. m.addorganization_id = nil
  33778. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  33779. }
  33780. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  33781. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  33782. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  33783. return ok
  33784. }
  33785. // ResetOrganizationID resets all changes to the "organization_id" field.
  33786. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  33787. m.organization_id = nil
  33788. m.addorganization_id = nil
  33789. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  33790. }
  33791. // SetAiResponse sets the "ai_response" field.
  33792. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  33793. m.ai_response = &u
  33794. m.addai_response = nil
  33795. }
  33796. // AiResponse returns the value of the "ai_response" field in the mutation.
  33797. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  33798. v := m.ai_response
  33799. if v == nil {
  33800. return
  33801. }
  33802. return *v, true
  33803. }
  33804. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  33805. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33807. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  33808. if !m.op.Is(OpUpdateOne) {
  33809. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  33810. }
  33811. if m.id == nil || m.oldValue == nil {
  33812. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  33813. }
  33814. oldValue, err := m.oldValue(ctx)
  33815. if err != nil {
  33816. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  33817. }
  33818. return oldValue.AiResponse, nil
  33819. }
  33820. // AddAiResponse adds u to the "ai_response" field.
  33821. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  33822. if m.addai_response != nil {
  33823. *m.addai_response += u
  33824. } else {
  33825. m.addai_response = &u
  33826. }
  33827. }
  33828. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  33829. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  33830. v := m.addai_response
  33831. if v == nil {
  33832. return
  33833. }
  33834. return *v, true
  33835. }
  33836. // ResetAiResponse resets all changes to the "ai_response" field.
  33837. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  33838. m.ai_response = nil
  33839. m.addai_response = nil
  33840. }
  33841. // SetSopRun sets the "sop_run" field.
  33842. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  33843. m.sop_run = &u
  33844. m.addsop_run = nil
  33845. }
  33846. // SopRun returns the value of the "sop_run" field in the mutation.
  33847. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  33848. v := m.sop_run
  33849. if v == nil {
  33850. return
  33851. }
  33852. return *v, true
  33853. }
  33854. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  33855. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33856. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33857. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  33858. if !m.op.Is(OpUpdateOne) {
  33859. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  33860. }
  33861. if m.id == nil || m.oldValue == nil {
  33862. return v, errors.New("OldSopRun requires an ID field in the mutation")
  33863. }
  33864. oldValue, err := m.oldValue(ctx)
  33865. if err != nil {
  33866. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  33867. }
  33868. return oldValue.SopRun, nil
  33869. }
  33870. // AddSopRun adds u to the "sop_run" field.
  33871. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  33872. if m.addsop_run != nil {
  33873. *m.addsop_run += u
  33874. } else {
  33875. m.addsop_run = &u
  33876. }
  33877. }
  33878. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  33879. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  33880. v := m.addsop_run
  33881. if v == nil {
  33882. return
  33883. }
  33884. return *v, true
  33885. }
  33886. // ResetSopRun resets all changes to the "sop_run" field.
  33887. func (m *UsageStatisticHourMutation) ResetSopRun() {
  33888. m.sop_run = nil
  33889. m.addsop_run = nil
  33890. }
  33891. // SetTotalFriend sets the "total_friend" field.
  33892. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  33893. m.total_friend = &u
  33894. m.addtotal_friend = nil
  33895. }
  33896. // TotalFriend returns the value of the "total_friend" field in the mutation.
  33897. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  33898. v := m.total_friend
  33899. if v == nil {
  33900. return
  33901. }
  33902. return *v, true
  33903. }
  33904. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  33905. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33907. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  33908. if !m.op.Is(OpUpdateOne) {
  33909. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  33910. }
  33911. if m.id == nil || m.oldValue == nil {
  33912. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  33913. }
  33914. oldValue, err := m.oldValue(ctx)
  33915. if err != nil {
  33916. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  33917. }
  33918. return oldValue.TotalFriend, nil
  33919. }
  33920. // AddTotalFriend adds u to the "total_friend" field.
  33921. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  33922. if m.addtotal_friend != nil {
  33923. *m.addtotal_friend += u
  33924. } else {
  33925. m.addtotal_friend = &u
  33926. }
  33927. }
  33928. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  33929. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  33930. v := m.addtotal_friend
  33931. if v == nil {
  33932. return
  33933. }
  33934. return *v, true
  33935. }
  33936. // ResetTotalFriend resets all changes to the "total_friend" field.
  33937. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  33938. m.total_friend = nil
  33939. m.addtotal_friend = nil
  33940. }
  33941. // SetTotalGroup sets the "total_group" field.
  33942. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  33943. m.total_group = &u
  33944. m.addtotal_group = nil
  33945. }
  33946. // TotalGroup returns the value of the "total_group" field in the mutation.
  33947. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  33948. v := m.total_group
  33949. if v == nil {
  33950. return
  33951. }
  33952. return *v, true
  33953. }
  33954. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  33955. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33956. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33957. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  33958. if !m.op.Is(OpUpdateOne) {
  33959. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  33960. }
  33961. if m.id == nil || m.oldValue == nil {
  33962. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  33963. }
  33964. oldValue, err := m.oldValue(ctx)
  33965. if err != nil {
  33966. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  33967. }
  33968. return oldValue.TotalGroup, nil
  33969. }
  33970. // AddTotalGroup adds u to the "total_group" field.
  33971. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  33972. if m.addtotal_group != nil {
  33973. *m.addtotal_group += u
  33974. } else {
  33975. m.addtotal_group = &u
  33976. }
  33977. }
  33978. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  33979. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  33980. v := m.addtotal_group
  33981. if v == nil {
  33982. return
  33983. }
  33984. return *v, true
  33985. }
  33986. // ResetTotalGroup resets all changes to the "total_group" field.
  33987. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  33988. m.total_group = nil
  33989. m.addtotal_group = nil
  33990. }
  33991. // SetAccountBalance sets the "account_balance" field.
  33992. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  33993. m.account_balance = &u
  33994. m.addaccount_balance = nil
  33995. }
  33996. // AccountBalance returns the value of the "account_balance" field in the mutation.
  33997. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  33998. v := m.account_balance
  33999. if v == nil {
  34000. return
  34001. }
  34002. return *v, true
  34003. }
  34004. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  34005. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34006. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34007. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  34008. if !m.op.Is(OpUpdateOne) {
  34009. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  34010. }
  34011. if m.id == nil || m.oldValue == nil {
  34012. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  34013. }
  34014. oldValue, err := m.oldValue(ctx)
  34015. if err != nil {
  34016. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  34017. }
  34018. return oldValue.AccountBalance, nil
  34019. }
  34020. // AddAccountBalance adds u to the "account_balance" field.
  34021. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  34022. if m.addaccount_balance != nil {
  34023. *m.addaccount_balance += u
  34024. } else {
  34025. m.addaccount_balance = &u
  34026. }
  34027. }
  34028. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  34029. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  34030. v := m.addaccount_balance
  34031. if v == nil {
  34032. return
  34033. }
  34034. return *v, true
  34035. }
  34036. // ResetAccountBalance resets all changes to the "account_balance" field.
  34037. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  34038. m.account_balance = nil
  34039. m.addaccount_balance = nil
  34040. }
  34041. // SetConsumeToken sets the "consume_token" field.
  34042. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  34043. m.consume_token = &u
  34044. m.addconsume_token = nil
  34045. }
  34046. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  34047. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  34048. v := m.consume_token
  34049. if v == nil {
  34050. return
  34051. }
  34052. return *v, true
  34053. }
  34054. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  34055. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34056. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34057. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  34058. if !m.op.Is(OpUpdateOne) {
  34059. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  34060. }
  34061. if m.id == nil || m.oldValue == nil {
  34062. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  34063. }
  34064. oldValue, err := m.oldValue(ctx)
  34065. if err != nil {
  34066. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  34067. }
  34068. return oldValue.ConsumeToken, nil
  34069. }
  34070. // AddConsumeToken adds u to the "consume_token" field.
  34071. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  34072. if m.addconsume_token != nil {
  34073. *m.addconsume_token += u
  34074. } else {
  34075. m.addconsume_token = &u
  34076. }
  34077. }
  34078. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  34079. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  34080. v := m.addconsume_token
  34081. if v == nil {
  34082. return
  34083. }
  34084. return *v, true
  34085. }
  34086. // ResetConsumeToken resets all changes to the "consume_token" field.
  34087. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  34088. m.consume_token = nil
  34089. m.addconsume_token = nil
  34090. }
  34091. // SetActiveUser sets the "active_user" field.
  34092. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  34093. m.active_user = &u
  34094. m.addactive_user = nil
  34095. }
  34096. // ActiveUser returns the value of the "active_user" field in the mutation.
  34097. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  34098. v := m.active_user
  34099. if v == nil {
  34100. return
  34101. }
  34102. return *v, true
  34103. }
  34104. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  34105. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34106. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34107. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  34108. if !m.op.Is(OpUpdateOne) {
  34109. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  34110. }
  34111. if m.id == nil || m.oldValue == nil {
  34112. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  34113. }
  34114. oldValue, err := m.oldValue(ctx)
  34115. if err != nil {
  34116. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  34117. }
  34118. return oldValue.ActiveUser, nil
  34119. }
  34120. // AddActiveUser adds u to the "active_user" field.
  34121. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  34122. if m.addactive_user != nil {
  34123. *m.addactive_user += u
  34124. } else {
  34125. m.addactive_user = &u
  34126. }
  34127. }
  34128. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  34129. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  34130. v := m.addactive_user
  34131. if v == nil {
  34132. return
  34133. }
  34134. return *v, true
  34135. }
  34136. // ResetActiveUser resets all changes to the "active_user" field.
  34137. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  34138. m.active_user = nil
  34139. m.addactive_user = nil
  34140. }
  34141. // SetNewUser sets the "new_user" field.
  34142. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  34143. m.new_user = &i
  34144. m.addnew_user = nil
  34145. }
  34146. // NewUser returns the value of the "new_user" field in the mutation.
  34147. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  34148. v := m.new_user
  34149. if v == nil {
  34150. return
  34151. }
  34152. return *v, true
  34153. }
  34154. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  34155. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34156. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34157. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  34158. if !m.op.Is(OpUpdateOne) {
  34159. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  34160. }
  34161. if m.id == nil || m.oldValue == nil {
  34162. return v, errors.New("OldNewUser requires an ID field in the mutation")
  34163. }
  34164. oldValue, err := m.oldValue(ctx)
  34165. if err != nil {
  34166. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  34167. }
  34168. return oldValue.NewUser, nil
  34169. }
  34170. // AddNewUser adds i to the "new_user" field.
  34171. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  34172. if m.addnew_user != nil {
  34173. *m.addnew_user += i
  34174. } else {
  34175. m.addnew_user = &i
  34176. }
  34177. }
  34178. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  34179. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  34180. v := m.addnew_user
  34181. if v == nil {
  34182. return
  34183. }
  34184. return *v, true
  34185. }
  34186. // ResetNewUser resets all changes to the "new_user" field.
  34187. func (m *UsageStatisticHourMutation) ResetNewUser() {
  34188. m.new_user = nil
  34189. m.addnew_user = nil
  34190. }
  34191. // SetLabelDist sets the "label_dist" field.
  34192. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  34193. m.label_dist = &ctd
  34194. m.appendlabel_dist = nil
  34195. }
  34196. // LabelDist returns the value of the "label_dist" field in the mutation.
  34197. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  34198. v := m.label_dist
  34199. if v == nil {
  34200. return
  34201. }
  34202. return *v, true
  34203. }
  34204. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  34205. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34206. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34207. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  34208. if !m.op.Is(OpUpdateOne) {
  34209. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  34210. }
  34211. if m.id == nil || m.oldValue == nil {
  34212. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  34213. }
  34214. oldValue, err := m.oldValue(ctx)
  34215. if err != nil {
  34216. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  34217. }
  34218. return oldValue.LabelDist, nil
  34219. }
  34220. // AppendLabelDist adds ctd to the "label_dist" field.
  34221. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  34222. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  34223. }
  34224. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  34225. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  34226. if len(m.appendlabel_dist) == 0 {
  34227. return nil, false
  34228. }
  34229. return m.appendlabel_dist, true
  34230. }
  34231. // ResetLabelDist resets all changes to the "label_dist" field.
  34232. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  34233. m.label_dist = nil
  34234. m.appendlabel_dist = nil
  34235. }
  34236. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  34237. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  34238. m.predicates = append(m.predicates, ps...)
  34239. }
  34240. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  34241. // users can use type-assertion to append predicates that do not depend on any generated package.
  34242. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  34243. p := make([]predicate.UsageStatisticHour, len(ps))
  34244. for i := range ps {
  34245. p[i] = ps[i]
  34246. }
  34247. m.Where(p...)
  34248. }
  34249. // Op returns the operation name.
  34250. func (m *UsageStatisticHourMutation) Op() Op {
  34251. return m.op
  34252. }
  34253. // SetOp allows setting the mutation operation.
  34254. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  34255. m.op = op
  34256. }
  34257. // Type returns the node type of this mutation (UsageStatisticHour).
  34258. func (m *UsageStatisticHourMutation) Type() string {
  34259. return m.typ
  34260. }
  34261. // Fields returns all fields that were changed during this mutation. Note that in
  34262. // order to get all numeric fields that were incremented/decremented, call
  34263. // AddedFields().
  34264. func (m *UsageStatisticHourMutation) Fields() []string {
  34265. fields := make([]string, 0, 17)
  34266. if m.created_at != nil {
  34267. fields = append(fields, usagestatistichour.FieldCreatedAt)
  34268. }
  34269. if m.updated_at != nil {
  34270. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  34271. }
  34272. if m.status != nil {
  34273. fields = append(fields, usagestatistichour.FieldStatus)
  34274. }
  34275. if m.deleted_at != nil {
  34276. fields = append(fields, usagestatistichour.FieldDeletedAt)
  34277. }
  34278. if m.addtime != nil {
  34279. fields = append(fields, usagestatistichour.FieldAddtime)
  34280. }
  34281. if m._type != nil {
  34282. fields = append(fields, usagestatistichour.FieldType)
  34283. }
  34284. if m.bot_id != nil {
  34285. fields = append(fields, usagestatistichour.FieldBotID)
  34286. }
  34287. if m.organization_id != nil {
  34288. fields = append(fields, usagestatistichour.FieldOrganizationID)
  34289. }
  34290. if m.ai_response != nil {
  34291. fields = append(fields, usagestatistichour.FieldAiResponse)
  34292. }
  34293. if m.sop_run != nil {
  34294. fields = append(fields, usagestatistichour.FieldSopRun)
  34295. }
  34296. if m.total_friend != nil {
  34297. fields = append(fields, usagestatistichour.FieldTotalFriend)
  34298. }
  34299. if m.total_group != nil {
  34300. fields = append(fields, usagestatistichour.FieldTotalGroup)
  34301. }
  34302. if m.account_balance != nil {
  34303. fields = append(fields, usagestatistichour.FieldAccountBalance)
  34304. }
  34305. if m.consume_token != nil {
  34306. fields = append(fields, usagestatistichour.FieldConsumeToken)
  34307. }
  34308. if m.active_user != nil {
  34309. fields = append(fields, usagestatistichour.FieldActiveUser)
  34310. }
  34311. if m.new_user != nil {
  34312. fields = append(fields, usagestatistichour.FieldNewUser)
  34313. }
  34314. if m.label_dist != nil {
  34315. fields = append(fields, usagestatistichour.FieldLabelDist)
  34316. }
  34317. return fields
  34318. }
  34319. // Field returns the value of a field with the given name. The second boolean
  34320. // return value indicates that this field was not set, or was not defined in the
  34321. // schema.
  34322. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  34323. switch name {
  34324. case usagestatistichour.FieldCreatedAt:
  34325. return m.CreatedAt()
  34326. case usagestatistichour.FieldUpdatedAt:
  34327. return m.UpdatedAt()
  34328. case usagestatistichour.FieldStatus:
  34329. return m.Status()
  34330. case usagestatistichour.FieldDeletedAt:
  34331. return m.DeletedAt()
  34332. case usagestatistichour.FieldAddtime:
  34333. return m.Addtime()
  34334. case usagestatistichour.FieldType:
  34335. return m.GetType()
  34336. case usagestatistichour.FieldBotID:
  34337. return m.BotID()
  34338. case usagestatistichour.FieldOrganizationID:
  34339. return m.OrganizationID()
  34340. case usagestatistichour.FieldAiResponse:
  34341. return m.AiResponse()
  34342. case usagestatistichour.FieldSopRun:
  34343. return m.SopRun()
  34344. case usagestatistichour.FieldTotalFriend:
  34345. return m.TotalFriend()
  34346. case usagestatistichour.FieldTotalGroup:
  34347. return m.TotalGroup()
  34348. case usagestatistichour.FieldAccountBalance:
  34349. return m.AccountBalance()
  34350. case usagestatistichour.FieldConsumeToken:
  34351. return m.ConsumeToken()
  34352. case usagestatistichour.FieldActiveUser:
  34353. return m.ActiveUser()
  34354. case usagestatistichour.FieldNewUser:
  34355. return m.NewUser()
  34356. case usagestatistichour.FieldLabelDist:
  34357. return m.LabelDist()
  34358. }
  34359. return nil, false
  34360. }
  34361. // OldField returns the old value of the field from the database. An error is
  34362. // returned if the mutation operation is not UpdateOne, or the query to the
  34363. // database failed.
  34364. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34365. switch name {
  34366. case usagestatistichour.FieldCreatedAt:
  34367. return m.OldCreatedAt(ctx)
  34368. case usagestatistichour.FieldUpdatedAt:
  34369. return m.OldUpdatedAt(ctx)
  34370. case usagestatistichour.FieldStatus:
  34371. return m.OldStatus(ctx)
  34372. case usagestatistichour.FieldDeletedAt:
  34373. return m.OldDeletedAt(ctx)
  34374. case usagestatistichour.FieldAddtime:
  34375. return m.OldAddtime(ctx)
  34376. case usagestatistichour.FieldType:
  34377. return m.OldType(ctx)
  34378. case usagestatistichour.FieldBotID:
  34379. return m.OldBotID(ctx)
  34380. case usagestatistichour.FieldOrganizationID:
  34381. return m.OldOrganizationID(ctx)
  34382. case usagestatistichour.FieldAiResponse:
  34383. return m.OldAiResponse(ctx)
  34384. case usagestatistichour.FieldSopRun:
  34385. return m.OldSopRun(ctx)
  34386. case usagestatistichour.FieldTotalFriend:
  34387. return m.OldTotalFriend(ctx)
  34388. case usagestatistichour.FieldTotalGroup:
  34389. return m.OldTotalGroup(ctx)
  34390. case usagestatistichour.FieldAccountBalance:
  34391. return m.OldAccountBalance(ctx)
  34392. case usagestatistichour.FieldConsumeToken:
  34393. return m.OldConsumeToken(ctx)
  34394. case usagestatistichour.FieldActiveUser:
  34395. return m.OldActiveUser(ctx)
  34396. case usagestatistichour.FieldNewUser:
  34397. return m.OldNewUser(ctx)
  34398. case usagestatistichour.FieldLabelDist:
  34399. return m.OldLabelDist(ctx)
  34400. }
  34401. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  34402. }
  34403. // SetField sets the value of a field with the given name. It returns an error if
  34404. // the field is not defined in the schema, or if the type mismatched the field
  34405. // type.
  34406. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  34407. switch name {
  34408. case usagestatistichour.FieldCreatedAt:
  34409. v, ok := value.(time.Time)
  34410. if !ok {
  34411. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34412. }
  34413. m.SetCreatedAt(v)
  34414. return nil
  34415. case usagestatistichour.FieldUpdatedAt:
  34416. v, ok := value.(time.Time)
  34417. if !ok {
  34418. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34419. }
  34420. m.SetUpdatedAt(v)
  34421. return nil
  34422. case usagestatistichour.FieldStatus:
  34423. v, ok := value.(uint8)
  34424. if !ok {
  34425. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34426. }
  34427. m.SetStatus(v)
  34428. return nil
  34429. case usagestatistichour.FieldDeletedAt:
  34430. v, ok := value.(time.Time)
  34431. if !ok {
  34432. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34433. }
  34434. m.SetDeletedAt(v)
  34435. return nil
  34436. case usagestatistichour.FieldAddtime:
  34437. v, ok := value.(uint64)
  34438. if !ok {
  34439. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34440. }
  34441. m.SetAddtime(v)
  34442. return nil
  34443. case usagestatistichour.FieldType:
  34444. v, ok := value.(int)
  34445. if !ok {
  34446. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34447. }
  34448. m.SetType(v)
  34449. return nil
  34450. case usagestatistichour.FieldBotID:
  34451. v, ok := value.(string)
  34452. if !ok {
  34453. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34454. }
  34455. m.SetBotID(v)
  34456. return nil
  34457. case usagestatistichour.FieldOrganizationID:
  34458. v, ok := value.(uint64)
  34459. if !ok {
  34460. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34461. }
  34462. m.SetOrganizationID(v)
  34463. return nil
  34464. case usagestatistichour.FieldAiResponse:
  34465. v, ok := value.(uint64)
  34466. if !ok {
  34467. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34468. }
  34469. m.SetAiResponse(v)
  34470. return nil
  34471. case usagestatistichour.FieldSopRun:
  34472. v, ok := value.(uint64)
  34473. if !ok {
  34474. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34475. }
  34476. m.SetSopRun(v)
  34477. return nil
  34478. case usagestatistichour.FieldTotalFriend:
  34479. v, ok := value.(uint64)
  34480. if !ok {
  34481. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34482. }
  34483. m.SetTotalFriend(v)
  34484. return nil
  34485. case usagestatistichour.FieldTotalGroup:
  34486. v, ok := value.(uint64)
  34487. if !ok {
  34488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34489. }
  34490. m.SetTotalGroup(v)
  34491. return nil
  34492. case usagestatistichour.FieldAccountBalance:
  34493. v, ok := value.(uint64)
  34494. if !ok {
  34495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34496. }
  34497. m.SetAccountBalance(v)
  34498. return nil
  34499. case usagestatistichour.FieldConsumeToken:
  34500. v, ok := value.(uint64)
  34501. if !ok {
  34502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34503. }
  34504. m.SetConsumeToken(v)
  34505. return nil
  34506. case usagestatistichour.FieldActiveUser:
  34507. v, ok := value.(uint64)
  34508. if !ok {
  34509. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34510. }
  34511. m.SetActiveUser(v)
  34512. return nil
  34513. case usagestatistichour.FieldNewUser:
  34514. v, ok := value.(int64)
  34515. if !ok {
  34516. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34517. }
  34518. m.SetNewUser(v)
  34519. return nil
  34520. case usagestatistichour.FieldLabelDist:
  34521. v, ok := value.([]custom_types.LabelDist)
  34522. if !ok {
  34523. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34524. }
  34525. m.SetLabelDist(v)
  34526. return nil
  34527. }
  34528. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  34529. }
  34530. // AddedFields returns all numeric fields that were incremented/decremented during
  34531. // this mutation.
  34532. func (m *UsageStatisticHourMutation) AddedFields() []string {
  34533. var fields []string
  34534. if m.addstatus != nil {
  34535. fields = append(fields, usagestatistichour.FieldStatus)
  34536. }
  34537. if m.addaddtime != nil {
  34538. fields = append(fields, usagestatistichour.FieldAddtime)
  34539. }
  34540. if m.add_type != nil {
  34541. fields = append(fields, usagestatistichour.FieldType)
  34542. }
  34543. if m.addorganization_id != nil {
  34544. fields = append(fields, usagestatistichour.FieldOrganizationID)
  34545. }
  34546. if m.addai_response != nil {
  34547. fields = append(fields, usagestatistichour.FieldAiResponse)
  34548. }
  34549. if m.addsop_run != nil {
  34550. fields = append(fields, usagestatistichour.FieldSopRun)
  34551. }
  34552. if m.addtotal_friend != nil {
  34553. fields = append(fields, usagestatistichour.FieldTotalFriend)
  34554. }
  34555. if m.addtotal_group != nil {
  34556. fields = append(fields, usagestatistichour.FieldTotalGroup)
  34557. }
  34558. if m.addaccount_balance != nil {
  34559. fields = append(fields, usagestatistichour.FieldAccountBalance)
  34560. }
  34561. if m.addconsume_token != nil {
  34562. fields = append(fields, usagestatistichour.FieldConsumeToken)
  34563. }
  34564. if m.addactive_user != nil {
  34565. fields = append(fields, usagestatistichour.FieldActiveUser)
  34566. }
  34567. if m.addnew_user != nil {
  34568. fields = append(fields, usagestatistichour.FieldNewUser)
  34569. }
  34570. return fields
  34571. }
  34572. // AddedField returns the numeric value that was incremented/decremented on a field
  34573. // with the given name. The second boolean return value indicates that this field
  34574. // was not set, or was not defined in the schema.
  34575. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  34576. switch name {
  34577. case usagestatistichour.FieldStatus:
  34578. return m.AddedStatus()
  34579. case usagestatistichour.FieldAddtime:
  34580. return m.AddedAddtime()
  34581. case usagestatistichour.FieldType:
  34582. return m.AddedType()
  34583. case usagestatistichour.FieldOrganizationID:
  34584. return m.AddedOrganizationID()
  34585. case usagestatistichour.FieldAiResponse:
  34586. return m.AddedAiResponse()
  34587. case usagestatistichour.FieldSopRun:
  34588. return m.AddedSopRun()
  34589. case usagestatistichour.FieldTotalFriend:
  34590. return m.AddedTotalFriend()
  34591. case usagestatistichour.FieldTotalGroup:
  34592. return m.AddedTotalGroup()
  34593. case usagestatistichour.FieldAccountBalance:
  34594. return m.AddedAccountBalance()
  34595. case usagestatistichour.FieldConsumeToken:
  34596. return m.AddedConsumeToken()
  34597. case usagestatistichour.FieldActiveUser:
  34598. return m.AddedActiveUser()
  34599. case usagestatistichour.FieldNewUser:
  34600. return m.AddedNewUser()
  34601. }
  34602. return nil, false
  34603. }
  34604. // AddField adds the value to the field with the given name. It returns an error if
  34605. // the field is not defined in the schema, or if the type mismatched the field
  34606. // type.
  34607. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  34608. switch name {
  34609. case usagestatistichour.FieldStatus:
  34610. v, ok := value.(int8)
  34611. if !ok {
  34612. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34613. }
  34614. m.AddStatus(v)
  34615. return nil
  34616. case usagestatistichour.FieldAddtime:
  34617. v, ok := value.(int64)
  34618. if !ok {
  34619. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34620. }
  34621. m.AddAddtime(v)
  34622. return nil
  34623. case usagestatistichour.FieldType:
  34624. v, ok := value.(int)
  34625. if !ok {
  34626. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34627. }
  34628. m.AddType(v)
  34629. return nil
  34630. case usagestatistichour.FieldOrganizationID:
  34631. v, ok := value.(int64)
  34632. if !ok {
  34633. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34634. }
  34635. m.AddOrganizationID(v)
  34636. return nil
  34637. case usagestatistichour.FieldAiResponse:
  34638. v, ok := value.(int64)
  34639. if !ok {
  34640. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34641. }
  34642. m.AddAiResponse(v)
  34643. return nil
  34644. case usagestatistichour.FieldSopRun:
  34645. v, ok := value.(int64)
  34646. if !ok {
  34647. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34648. }
  34649. m.AddSopRun(v)
  34650. return nil
  34651. case usagestatistichour.FieldTotalFriend:
  34652. v, ok := value.(int64)
  34653. if !ok {
  34654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34655. }
  34656. m.AddTotalFriend(v)
  34657. return nil
  34658. case usagestatistichour.FieldTotalGroup:
  34659. v, ok := value.(int64)
  34660. if !ok {
  34661. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34662. }
  34663. m.AddTotalGroup(v)
  34664. return nil
  34665. case usagestatistichour.FieldAccountBalance:
  34666. v, ok := value.(int64)
  34667. if !ok {
  34668. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34669. }
  34670. m.AddAccountBalance(v)
  34671. return nil
  34672. case usagestatistichour.FieldConsumeToken:
  34673. v, ok := value.(int64)
  34674. if !ok {
  34675. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34676. }
  34677. m.AddConsumeToken(v)
  34678. return nil
  34679. case usagestatistichour.FieldActiveUser:
  34680. v, ok := value.(int64)
  34681. if !ok {
  34682. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34683. }
  34684. m.AddActiveUser(v)
  34685. return nil
  34686. case usagestatistichour.FieldNewUser:
  34687. v, ok := value.(int64)
  34688. if !ok {
  34689. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34690. }
  34691. m.AddNewUser(v)
  34692. return nil
  34693. }
  34694. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  34695. }
  34696. // ClearedFields returns all nullable fields that were cleared during this
  34697. // mutation.
  34698. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  34699. var fields []string
  34700. if m.FieldCleared(usagestatistichour.FieldStatus) {
  34701. fields = append(fields, usagestatistichour.FieldStatus)
  34702. }
  34703. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  34704. fields = append(fields, usagestatistichour.FieldDeletedAt)
  34705. }
  34706. if m.FieldCleared(usagestatistichour.FieldBotID) {
  34707. fields = append(fields, usagestatistichour.FieldBotID)
  34708. }
  34709. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  34710. fields = append(fields, usagestatistichour.FieldOrganizationID)
  34711. }
  34712. return fields
  34713. }
  34714. // FieldCleared returns a boolean indicating if a field with the given name was
  34715. // cleared in this mutation.
  34716. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  34717. _, ok := m.clearedFields[name]
  34718. return ok
  34719. }
  34720. // ClearField clears the value of the field with the given name. It returns an
  34721. // error if the field is not defined in the schema.
  34722. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  34723. switch name {
  34724. case usagestatistichour.FieldStatus:
  34725. m.ClearStatus()
  34726. return nil
  34727. case usagestatistichour.FieldDeletedAt:
  34728. m.ClearDeletedAt()
  34729. return nil
  34730. case usagestatistichour.FieldBotID:
  34731. m.ClearBotID()
  34732. return nil
  34733. case usagestatistichour.FieldOrganizationID:
  34734. m.ClearOrganizationID()
  34735. return nil
  34736. }
  34737. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  34738. }
  34739. // ResetField resets all changes in the mutation for the field with the given name.
  34740. // It returns an error if the field is not defined in the schema.
  34741. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  34742. switch name {
  34743. case usagestatistichour.FieldCreatedAt:
  34744. m.ResetCreatedAt()
  34745. return nil
  34746. case usagestatistichour.FieldUpdatedAt:
  34747. m.ResetUpdatedAt()
  34748. return nil
  34749. case usagestatistichour.FieldStatus:
  34750. m.ResetStatus()
  34751. return nil
  34752. case usagestatistichour.FieldDeletedAt:
  34753. m.ResetDeletedAt()
  34754. return nil
  34755. case usagestatistichour.FieldAddtime:
  34756. m.ResetAddtime()
  34757. return nil
  34758. case usagestatistichour.FieldType:
  34759. m.ResetType()
  34760. return nil
  34761. case usagestatistichour.FieldBotID:
  34762. m.ResetBotID()
  34763. return nil
  34764. case usagestatistichour.FieldOrganizationID:
  34765. m.ResetOrganizationID()
  34766. return nil
  34767. case usagestatistichour.FieldAiResponse:
  34768. m.ResetAiResponse()
  34769. return nil
  34770. case usagestatistichour.FieldSopRun:
  34771. m.ResetSopRun()
  34772. return nil
  34773. case usagestatistichour.FieldTotalFriend:
  34774. m.ResetTotalFriend()
  34775. return nil
  34776. case usagestatistichour.FieldTotalGroup:
  34777. m.ResetTotalGroup()
  34778. return nil
  34779. case usagestatistichour.FieldAccountBalance:
  34780. m.ResetAccountBalance()
  34781. return nil
  34782. case usagestatistichour.FieldConsumeToken:
  34783. m.ResetConsumeToken()
  34784. return nil
  34785. case usagestatistichour.FieldActiveUser:
  34786. m.ResetActiveUser()
  34787. return nil
  34788. case usagestatistichour.FieldNewUser:
  34789. m.ResetNewUser()
  34790. return nil
  34791. case usagestatistichour.FieldLabelDist:
  34792. m.ResetLabelDist()
  34793. return nil
  34794. }
  34795. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  34796. }
  34797. // AddedEdges returns all edge names that were set/added in this mutation.
  34798. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  34799. edges := make([]string, 0, 0)
  34800. return edges
  34801. }
  34802. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  34803. // name in this mutation.
  34804. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  34805. return nil
  34806. }
  34807. // RemovedEdges returns all edge names that were removed in this mutation.
  34808. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  34809. edges := make([]string, 0, 0)
  34810. return edges
  34811. }
  34812. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  34813. // the given name in this mutation.
  34814. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  34815. return nil
  34816. }
  34817. // ClearedEdges returns all edge names that were cleared in this mutation.
  34818. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  34819. edges := make([]string, 0, 0)
  34820. return edges
  34821. }
  34822. // EdgeCleared returns a boolean which indicates if the edge with the given name
  34823. // was cleared in this mutation.
  34824. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  34825. return false
  34826. }
  34827. // ClearEdge clears the value of the edge with the given name. It returns an error
  34828. // if that edge is not defined in the schema.
  34829. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  34830. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  34831. }
  34832. // ResetEdge resets all changes to the edge with the given name in this mutation.
  34833. // It returns an error if the edge is not defined in the schema.
  34834. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  34835. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  34836. }
  34837. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  34838. type UsageStatisticMonthMutation struct {
  34839. config
  34840. op Op
  34841. typ string
  34842. id *uint64
  34843. created_at *time.Time
  34844. updated_at *time.Time
  34845. status *uint8
  34846. addstatus *int8
  34847. deleted_at *time.Time
  34848. addtime *uint64
  34849. addaddtime *int64
  34850. _type *int
  34851. add_type *int
  34852. bot_id *string
  34853. organization_id *uint64
  34854. addorganization_id *int64
  34855. ai_response *uint64
  34856. addai_response *int64
  34857. sop_run *uint64
  34858. addsop_run *int64
  34859. total_friend *uint64
  34860. addtotal_friend *int64
  34861. total_group *uint64
  34862. addtotal_group *int64
  34863. account_balance *uint64
  34864. addaccount_balance *int64
  34865. consume_token *uint64
  34866. addconsume_token *int64
  34867. active_user *uint64
  34868. addactive_user *int64
  34869. new_user *int64
  34870. addnew_user *int64
  34871. label_dist *[]custom_types.LabelDist
  34872. appendlabel_dist []custom_types.LabelDist
  34873. clearedFields map[string]struct{}
  34874. done bool
  34875. oldValue func(context.Context) (*UsageStatisticMonth, error)
  34876. predicates []predicate.UsageStatisticMonth
  34877. }
  34878. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  34879. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  34880. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  34881. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  34882. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  34883. m := &UsageStatisticMonthMutation{
  34884. config: c,
  34885. op: op,
  34886. typ: TypeUsageStatisticMonth,
  34887. clearedFields: make(map[string]struct{}),
  34888. }
  34889. for _, opt := range opts {
  34890. opt(m)
  34891. }
  34892. return m
  34893. }
  34894. // withUsageStatisticMonthID sets the ID field of the mutation.
  34895. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  34896. return func(m *UsageStatisticMonthMutation) {
  34897. var (
  34898. err error
  34899. once sync.Once
  34900. value *UsageStatisticMonth
  34901. )
  34902. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  34903. once.Do(func() {
  34904. if m.done {
  34905. err = errors.New("querying old values post mutation is not allowed")
  34906. } else {
  34907. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  34908. }
  34909. })
  34910. return value, err
  34911. }
  34912. m.id = &id
  34913. }
  34914. }
  34915. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  34916. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  34917. return func(m *UsageStatisticMonthMutation) {
  34918. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  34919. return node, nil
  34920. }
  34921. m.id = &node.ID
  34922. }
  34923. }
  34924. // Client returns a new `ent.Client` from the mutation. If the mutation was
  34925. // executed in a transaction (ent.Tx), a transactional client is returned.
  34926. func (m UsageStatisticMonthMutation) Client() *Client {
  34927. client := &Client{config: m.config}
  34928. client.init()
  34929. return client
  34930. }
  34931. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  34932. // it returns an error otherwise.
  34933. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  34934. if _, ok := m.driver.(*txDriver); !ok {
  34935. return nil, errors.New("ent: mutation is not running in a transaction")
  34936. }
  34937. tx := &Tx{config: m.config}
  34938. tx.init()
  34939. return tx, nil
  34940. }
  34941. // SetID sets the value of the id field. Note that this
  34942. // operation is only accepted on creation of UsageStatisticMonth entities.
  34943. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  34944. m.id = &id
  34945. }
  34946. // ID returns the ID value in the mutation. Note that the ID is only available
  34947. // if it was provided to the builder or after it was returned from the database.
  34948. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  34949. if m.id == nil {
  34950. return
  34951. }
  34952. return *m.id, true
  34953. }
  34954. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  34955. // That means, if the mutation is applied within a transaction with an isolation level such
  34956. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  34957. // or updated by the mutation.
  34958. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  34959. switch {
  34960. case m.op.Is(OpUpdateOne | OpDeleteOne):
  34961. id, exists := m.ID()
  34962. if exists {
  34963. return []uint64{id}, nil
  34964. }
  34965. fallthrough
  34966. case m.op.Is(OpUpdate | OpDelete):
  34967. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  34968. default:
  34969. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  34970. }
  34971. }
  34972. // SetCreatedAt sets the "created_at" field.
  34973. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  34974. m.created_at = &t
  34975. }
  34976. // CreatedAt returns the value of the "created_at" field in the mutation.
  34977. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  34978. v := m.created_at
  34979. if v == nil {
  34980. return
  34981. }
  34982. return *v, true
  34983. }
  34984. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  34985. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34986. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34987. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  34988. if !m.op.Is(OpUpdateOne) {
  34989. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  34990. }
  34991. if m.id == nil || m.oldValue == nil {
  34992. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  34993. }
  34994. oldValue, err := m.oldValue(ctx)
  34995. if err != nil {
  34996. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  34997. }
  34998. return oldValue.CreatedAt, nil
  34999. }
  35000. // ResetCreatedAt resets all changes to the "created_at" field.
  35001. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  35002. m.created_at = nil
  35003. }
  35004. // SetUpdatedAt sets the "updated_at" field.
  35005. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  35006. m.updated_at = &t
  35007. }
  35008. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  35009. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  35010. v := m.updated_at
  35011. if v == nil {
  35012. return
  35013. }
  35014. return *v, true
  35015. }
  35016. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  35017. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35018. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35019. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35020. if !m.op.Is(OpUpdateOne) {
  35021. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35022. }
  35023. if m.id == nil || m.oldValue == nil {
  35024. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35025. }
  35026. oldValue, err := m.oldValue(ctx)
  35027. if err != nil {
  35028. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35029. }
  35030. return oldValue.UpdatedAt, nil
  35031. }
  35032. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35033. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  35034. m.updated_at = nil
  35035. }
  35036. // SetStatus sets the "status" field.
  35037. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  35038. m.status = &u
  35039. m.addstatus = nil
  35040. }
  35041. // Status returns the value of the "status" field in the mutation.
  35042. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  35043. v := m.status
  35044. if v == nil {
  35045. return
  35046. }
  35047. return *v, true
  35048. }
  35049. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  35050. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35051. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35052. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  35053. if !m.op.Is(OpUpdateOne) {
  35054. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  35055. }
  35056. if m.id == nil || m.oldValue == nil {
  35057. return v, errors.New("OldStatus requires an ID field in the mutation")
  35058. }
  35059. oldValue, err := m.oldValue(ctx)
  35060. if err != nil {
  35061. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  35062. }
  35063. return oldValue.Status, nil
  35064. }
  35065. // AddStatus adds u to the "status" field.
  35066. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  35067. if m.addstatus != nil {
  35068. *m.addstatus += u
  35069. } else {
  35070. m.addstatus = &u
  35071. }
  35072. }
  35073. // AddedStatus returns the value that was added to the "status" field in this mutation.
  35074. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  35075. v := m.addstatus
  35076. if v == nil {
  35077. return
  35078. }
  35079. return *v, true
  35080. }
  35081. // ClearStatus clears the value of the "status" field.
  35082. func (m *UsageStatisticMonthMutation) ClearStatus() {
  35083. m.status = nil
  35084. m.addstatus = nil
  35085. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  35086. }
  35087. // StatusCleared returns if the "status" field was cleared in this mutation.
  35088. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  35089. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  35090. return ok
  35091. }
  35092. // ResetStatus resets all changes to the "status" field.
  35093. func (m *UsageStatisticMonthMutation) ResetStatus() {
  35094. m.status = nil
  35095. m.addstatus = nil
  35096. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  35097. }
  35098. // SetDeletedAt sets the "deleted_at" field.
  35099. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  35100. m.deleted_at = &t
  35101. }
  35102. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  35103. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  35104. v := m.deleted_at
  35105. if v == nil {
  35106. return
  35107. }
  35108. return *v, true
  35109. }
  35110. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  35111. // If the UsageStatisticMonth 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 *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  35114. if !m.op.Is(OpUpdateOne) {
  35115. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  35116. }
  35117. if m.id == nil || m.oldValue == nil {
  35118. return v, errors.New("OldDeletedAt 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 OldDeletedAt: %w", err)
  35123. }
  35124. return oldValue.DeletedAt, nil
  35125. }
  35126. // ClearDeletedAt clears the value of the "deleted_at" field.
  35127. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  35128. m.deleted_at = nil
  35129. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  35130. }
  35131. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  35132. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  35133. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  35134. return ok
  35135. }
  35136. // ResetDeletedAt resets all changes to the "deleted_at" field.
  35137. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  35138. m.deleted_at = nil
  35139. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  35140. }
  35141. // SetAddtime sets the "addtime" field.
  35142. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  35143. m.addtime = &u
  35144. m.addaddtime = nil
  35145. }
  35146. // Addtime returns the value of the "addtime" field in the mutation.
  35147. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  35148. v := m.addtime
  35149. if v == nil {
  35150. return
  35151. }
  35152. return *v, true
  35153. }
  35154. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  35155. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35156. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35157. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  35158. if !m.op.Is(OpUpdateOne) {
  35159. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  35160. }
  35161. if m.id == nil || m.oldValue == nil {
  35162. return v, errors.New("OldAddtime requires an ID field in the mutation")
  35163. }
  35164. oldValue, err := m.oldValue(ctx)
  35165. if err != nil {
  35166. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  35167. }
  35168. return oldValue.Addtime, nil
  35169. }
  35170. // AddAddtime adds u to the "addtime" field.
  35171. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  35172. if m.addaddtime != nil {
  35173. *m.addaddtime += u
  35174. } else {
  35175. m.addaddtime = &u
  35176. }
  35177. }
  35178. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  35179. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  35180. v := m.addaddtime
  35181. if v == nil {
  35182. return
  35183. }
  35184. return *v, true
  35185. }
  35186. // ResetAddtime resets all changes to the "addtime" field.
  35187. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  35188. m.addtime = nil
  35189. m.addaddtime = nil
  35190. }
  35191. // SetType sets the "type" field.
  35192. func (m *UsageStatisticMonthMutation) SetType(i int) {
  35193. m._type = &i
  35194. m.add_type = nil
  35195. }
  35196. // GetType returns the value of the "type" field in the mutation.
  35197. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  35198. v := m._type
  35199. if v == nil {
  35200. return
  35201. }
  35202. return *v, true
  35203. }
  35204. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  35205. // If the UsageStatisticMonth 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 *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  35208. if !m.op.Is(OpUpdateOne) {
  35209. return v, errors.New("OldType is only allowed on UpdateOne operations")
  35210. }
  35211. if m.id == nil || m.oldValue == nil {
  35212. return v, errors.New("OldType 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 OldType: %w", err)
  35217. }
  35218. return oldValue.Type, nil
  35219. }
  35220. // AddType adds i to the "type" field.
  35221. func (m *UsageStatisticMonthMutation) AddType(i int) {
  35222. if m.add_type != nil {
  35223. *m.add_type += i
  35224. } else {
  35225. m.add_type = &i
  35226. }
  35227. }
  35228. // AddedType returns the value that was added to the "type" field in this mutation.
  35229. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  35230. v := m.add_type
  35231. if v == nil {
  35232. return
  35233. }
  35234. return *v, true
  35235. }
  35236. // ResetType resets all changes to the "type" field.
  35237. func (m *UsageStatisticMonthMutation) ResetType() {
  35238. m._type = nil
  35239. m.add_type = nil
  35240. }
  35241. // SetBotID sets the "bot_id" field.
  35242. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  35243. m.bot_id = &s
  35244. }
  35245. // BotID returns the value of the "bot_id" field in the mutation.
  35246. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  35247. v := m.bot_id
  35248. if v == nil {
  35249. return
  35250. }
  35251. return *v, true
  35252. }
  35253. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  35254. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35255. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35256. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  35257. if !m.op.Is(OpUpdateOne) {
  35258. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  35259. }
  35260. if m.id == nil || m.oldValue == nil {
  35261. return v, errors.New("OldBotID requires an ID field in the mutation")
  35262. }
  35263. oldValue, err := m.oldValue(ctx)
  35264. if err != nil {
  35265. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  35266. }
  35267. return oldValue.BotID, nil
  35268. }
  35269. // ClearBotID clears the value of the "bot_id" field.
  35270. func (m *UsageStatisticMonthMutation) ClearBotID() {
  35271. m.bot_id = nil
  35272. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  35273. }
  35274. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  35275. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  35276. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  35277. return ok
  35278. }
  35279. // ResetBotID resets all changes to the "bot_id" field.
  35280. func (m *UsageStatisticMonthMutation) ResetBotID() {
  35281. m.bot_id = nil
  35282. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  35283. }
  35284. // SetOrganizationID sets the "organization_id" field.
  35285. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  35286. m.organization_id = &u
  35287. m.addorganization_id = nil
  35288. }
  35289. // OrganizationID returns the value of the "organization_id" field in the mutation.
  35290. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  35291. v := m.organization_id
  35292. if v == nil {
  35293. return
  35294. }
  35295. return *v, true
  35296. }
  35297. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  35298. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35299. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35300. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  35301. if !m.op.Is(OpUpdateOne) {
  35302. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  35303. }
  35304. if m.id == nil || m.oldValue == nil {
  35305. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  35306. }
  35307. oldValue, err := m.oldValue(ctx)
  35308. if err != nil {
  35309. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  35310. }
  35311. return oldValue.OrganizationID, nil
  35312. }
  35313. // AddOrganizationID adds u to the "organization_id" field.
  35314. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  35315. if m.addorganization_id != nil {
  35316. *m.addorganization_id += u
  35317. } else {
  35318. m.addorganization_id = &u
  35319. }
  35320. }
  35321. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  35322. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  35323. v := m.addorganization_id
  35324. if v == nil {
  35325. return
  35326. }
  35327. return *v, true
  35328. }
  35329. // ClearOrganizationID clears the value of the "organization_id" field.
  35330. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  35331. m.organization_id = nil
  35332. m.addorganization_id = nil
  35333. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  35334. }
  35335. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  35336. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  35337. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  35338. return ok
  35339. }
  35340. // ResetOrganizationID resets all changes to the "organization_id" field.
  35341. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  35342. m.organization_id = nil
  35343. m.addorganization_id = nil
  35344. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  35345. }
  35346. // SetAiResponse sets the "ai_response" field.
  35347. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  35348. m.ai_response = &u
  35349. m.addai_response = nil
  35350. }
  35351. // AiResponse returns the value of the "ai_response" field in the mutation.
  35352. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  35353. v := m.ai_response
  35354. if v == nil {
  35355. return
  35356. }
  35357. return *v, true
  35358. }
  35359. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  35360. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35362. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  35363. if !m.op.Is(OpUpdateOne) {
  35364. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  35365. }
  35366. if m.id == nil || m.oldValue == nil {
  35367. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  35368. }
  35369. oldValue, err := m.oldValue(ctx)
  35370. if err != nil {
  35371. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  35372. }
  35373. return oldValue.AiResponse, nil
  35374. }
  35375. // AddAiResponse adds u to the "ai_response" field.
  35376. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  35377. if m.addai_response != nil {
  35378. *m.addai_response += u
  35379. } else {
  35380. m.addai_response = &u
  35381. }
  35382. }
  35383. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  35384. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  35385. v := m.addai_response
  35386. if v == nil {
  35387. return
  35388. }
  35389. return *v, true
  35390. }
  35391. // ResetAiResponse resets all changes to the "ai_response" field.
  35392. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  35393. m.ai_response = nil
  35394. m.addai_response = nil
  35395. }
  35396. // SetSopRun sets the "sop_run" field.
  35397. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  35398. m.sop_run = &u
  35399. m.addsop_run = nil
  35400. }
  35401. // SopRun returns the value of the "sop_run" field in the mutation.
  35402. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  35403. v := m.sop_run
  35404. if v == nil {
  35405. return
  35406. }
  35407. return *v, true
  35408. }
  35409. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  35410. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35411. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35412. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  35413. if !m.op.Is(OpUpdateOne) {
  35414. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  35415. }
  35416. if m.id == nil || m.oldValue == nil {
  35417. return v, errors.New("OldSopRun requires an ID field in the mutation")
  35418. }
  35419. oldValue, err := m.oldValue(ctx)
  35420. if err != nil {
  35421. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  35422. }
  35423. return oldValue.SopRun, nil
  35424. }
  35425. // AddSopRun adds u to the "sop_run" field.
  35426. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  35427. if m.addsop_run != nil {
  35428. *m.addsop_run += u
  35429. } else {
  35430. m.addsop_run = &u
  35431. }
  35432. }
  35433. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  35434. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  35435. v := m.addsop_run
  35436. if v == nil {
  35437. return
  35438. }
  35439. return *v, true
  35440. }
  35441. // ResetSopRun resets all changes to the "sop_run" field.
  35442. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  35443. m.sop_run = nil
  35444. m.addsop_run = nil
  35445. }
  35446. // SetTotalFriend sets the "total_friend" field.
  35447. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  35448. m.total_friend = &u
  35449. m.addtotal_friend = nil
  35450. }
  35451. // TotalFriend returns the value of the "total_friend" field in the mutation.
  35452. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  35453. v := m.total_friend
  35454. if v == nil {
  35455. return
  35456. }
  35457. return *v, true
  35458. }
  35459. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  35460. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35461. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35462. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  35463. if !m.op.Is(OpUpdateOne) {
  35464. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  35465. }
  35466. if m.id == nil || m.oldValue == nil {
  35467. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  35468. }
  35469. oldValue, err := m.oldValue(ctx)
  35470. if err != nil {
  35471. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  35472. }
  35473. return oldValue.TotalFriend, nil
  35474. }
  35475. // AddTotalFriend adds u to the "total_friend" field.
  35476. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  35477. if m.addtotal_friend != nil {
  35478. *m.addtotal_friend += u
  35479. } else {
  35480. m.addtotal_friend = &u
  35481. }
  35482. }
  35483. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  35484. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  35485. v := m.addtotal_friend
  35486. if v == nil {
  35487. return
  35488. }
  35489. return *v, true
  35490. }
  35491. // ResetTotalFriend resets all changes to the "total_friend" field.
  35492. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  35493. m.total_friend = nil
  35494. m.addtotal_friend = nil
  35495. }
  35496. // SetTotalGroup sets the "total_group" field.
  35497. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  35498. m.total_group = &u
  35499. m.addtotal_group = nil
  35500. }
  35501. // TotalGroup returns the value of the "total_group" field in the mutation.
  35502. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  35503. v := m.total_group
  35504. if v == nil {
  35505. return
  35506. }
  35507. return *v, true
  35508. }
  35509. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  35510. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35511. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35512. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  35513. if !m.op.Is(OpUpdateOne) {
  35514. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  35515. }
  35516. if m.id == nil || m.oldValue == nil {
  35517. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  35518. }
  35519. oldValue, err := m.oldValue(ctx)
  35520. if err != nil {
  35521. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  35522. }
  35523. return oldValue.TotalGroup, nil
  35524. }
  35525. // AddTotalGroup adds u to the "total_group" field.
  35526. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  35527. if m.addtotal_group != nil {
  35528. *m.addtotal_group += u
  35529. } else {
  35530. m.addtotal_group = &u
  35531. }
  35532. }
  35533. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  35534. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  35535. v := m.addtotal_group
  35536. if v == nil {
  35537. return
  35538. }
  35539. return *v, true
  35540. }
  35541. // ResetTotalGroup resets all changes to the "total_group" field.
  35542. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  35543. m.total_group = nil
  35544. m.addtotal_group = nil
  35545. }
  35546. // SetAccountBalance sets the "account_balance" field.
  35547. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  35548. m.account_balance = &u
  35549. m.addaccount_balance = nil
  35550. }
  35551. // AccountBalance returns the value of the "account_balance" field in the mutation.
  35552. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  35553. v := m.account_balance
  35554. if v == nil {
  35555. return
  35556. }
  35557. return *v, true
  35558. }
  35559. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  35560. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35561. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35562. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  35563. if !m.op.Is(OpUpdateOne) {
  35564. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  35565. }
  35566. if m.id == nil || m.oldValue == nil {
  35567. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  35568. }
  35569. oldValue, err := m.oldValue(ctx)
  35570. if err != nil {
  35571. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  35572. }
  35573. return oldValue.AccountBalance, nil
  35574. }
  35575. // AddAccountBalance adds u to the "account_balance" field.
  35576. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  35577. if m.addaccount_balance != nil {
  35578. *m.addaccount_balance += u
  35579. } else {
  35580. m.addaccount_balance = &u
  35581. }
  35582. }
  35583. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  35584. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  35585. v := m.addaccount_balance
  35586. if v == nil {
  35587. return
  35588. }
  35589. return *v, true
  35590. }
  35591. // ResetAccountBalance resets all changes to the "account_balance" field.
  35592. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  35593. m.account_balance = nil
  35594. m.addaccount_balance = nil
  35595. }
  35596. // SetConsumeToken sets the "consume_token" field.
  35597. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  35598. m.consume_token = &u
  35599. m.addconsume_token = nil
  35600. }
  35601. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  35602. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  35603. v := m.consume_token
  35604. if v == nil {
  35605. return
  35606. }
  35607. return *v, true
  35608. }
  35609. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  35610. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35611. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35612. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  35613. if !m.op.Is(OpUpdateOne) {
  35614. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  35615. }
  35616. if m.id == nil || m.oldValue == nil {
  35617. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  35618. }
  35619. oldValue, err := m.oldValue(ctx)
  35620. if err != nil {
  35621. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  35622. }
  35623. return oldValue.ConsumeToken, nil
  35624. }
  35625. // AddConsumeToken adds u to the "consume_token" field.
  35626. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  35627. if m.addconsume_token != nil {
  35628. *m.addconsume_token += u
  35629. } else {
  35630. m.addconsume_token = &u
  35631. }
  35632. }
  35633. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  35634. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  35635. v := m.addconsume_token
  35636. if v == nil {
  35637. return
  35638. }
  35639. return *v, true
  35640. }
  35641. // ResetConsumeToken resets all changes to the "consume_token" field.
  35642. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  35643. m.consume_token = nil
  35644. m.addconsume_token = nil
  35645. }
  35646. // SetActiveUser sets the "active_user" field.
  35647. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  35648. m.active_user = &u
  35649. m.addactive_user = nil
  35650. }
  35651. // ActiveUser returns the value of the "active_user" field in the mutation.
  35652. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  35653. v := m.active_user
  35654. if v == nil {
  35655. return
  35656. }
  35657. return *v, true
  35658. }
  35659. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  35660. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35661. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35662. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  35663. if !m.op.Is(OpUpdateOne) {
  35664. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  35665. }
  35666. if m.id == nil || m.oldValue == nil {
  35667. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  35668. }
  35669. oldValue, err := m.oldValue(ctx)
  35670. if err != nil {
  35671. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  35672. }
  35673. return oldValue.ActiveUser, nil
  35674. }
  35675. // AddActiveUser adds u to the "active_user" field.
  35676. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  35677. if m.addactive_user != nil {
  35678. *m.addactive_user += u
  35679. } else {
  35680. m.addactive_user = &u
  35681. }
  35682. }
  35683. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  35684. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  35685. v := m.addactive_user
  35686. if v == nil {
  35687. return
  35688. }
  35689. return *v, true
  35690. }
  35691. // ResetActiveUser resets all changes to the "active_user" field.
  35692. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  35693. m.active_user = nil
  35694. m.addactive_user = nil
  35695. }
  35696. // SetNewUser sets the "new_user" field.
  35697. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  35698. m.new_user = &i
  35699. m.addnew_user = nil
  35700. }
  35701. // NewUser returns the value of the "new_user" field in the mutation.
  35702. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  35703. v := m.new_user
  35704. if v == nil {
  35705. return
  35706. }
  35707. return *v, true
  35708. }
  35709. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  35710. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35711. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35712. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  35713. if !m.op.Is(OpUpdateOne) {
  35714. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  35715. }
  35716. if m.id == nil || m.oldValue == nil {
  35717. return v, errors.New("OldNewUser requires an ID field in the mutation")
  35718. }
  35719. oldValue, err := m.oldValue(ctx)
  35720. if err != nil {
  35721. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  35722. }
  35723. return oldValue.NewUser, nil
  35724. }
  35725. // AddNewUser adds i to the "new_user" field.
  35726. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  35727. if m.addnew_user != nil {
  35728. *m.addnew_user += i
  35729. } else {
  35730. m.addnew_user = &i
  35731. }
  35732. }
  35733. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  35734. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  35735. v := m.addnew_user
  35736. if v == nil {
  35737. return
  35738. }
  35739. return *v, true
  35740. }
  35741. // ResetNewUser resets all changes to the "new_user" field.
  35742. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  35743. m.new_user = nil
  35744. m.addnew_user = nil
  35745. }
  35746. // SetLabelDist sets the "label_dist" field.
  35747. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  35748. m.label_dist = &ctd
  35749. m.appendlabel_dist = nil
  35750. }
  35751. // LabelDist returns the value of the "label_dist" field in the mutation.
  35752. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  35753. v := m.label_dist
  35754. if v == nil {
  35755. return
  35756. }
  35757. return *v, true
  35758. }
  35759. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  35760. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35761. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35762. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  35763. if !m.op.Is(OpUpdateOne) {
  35764. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  35765. }
  35766. if m.id == nil || m.oldValue == nil {
  35767. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  35768. }
  35769. oldValue, err := m.oldValue(ctx)
  35770. if err != nil {
  35771. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  35772. }
  35773. return oldValue.LabelDist, nil
  35774. }
  35775. // AppendLabelDist adds ctd to the "label_dist" field.
  35776. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  35777. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  35778. }
  35779. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  35780. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  35781. if len(m.appendlabel_dist) == 0 {
  35782. return nil, false
  35783. }
  35784. return m.appendlabel_dist, true
  35785. }
  35786. // ResetLabelDist resets all changes to the "label_dist" field.
  35787. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  35788. m.label_dist = nil
  35789. m.appendlabel_dist = nil
  35790. }
  35791. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  35792. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  35793. m.predicates = append(m.predicates, ps...)
  35794. }
  35795. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  35796. // users can use type-assertion to append predicates that do not depend on any generated package.
  35797. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  35798. p := make([]predicate.UsageStatisticMonth, len(ps))
  35799. for i := range ps {
  35800. p[i] = ps[i]
  35801. }
  35802. m.Where(p...)
  35803. }
  35804. // Op returns the operation name.
  35805. func (m *UsageStatisticMonthMutation) Op() Op {
  35806. return m.op
  35807. }
  35808. // SetOp allows setting the mutation operation.
  35809. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  35810. m.op = op
  35811. }
  35812. // Type returns the node type of this mutation (UsageStatisticMonth).
  35813. func (m *UsageStatisticMonthMutation) Type() string {
  35814. return m.typ
  35815. }
  35816. // Fields returns all fields that were changed during this mutation. Note that in
  35817. // order to get all numeric fields that were incremented/decremented, call
  35818. // AddedFields().
  35819. func (m *UsageStatisticMonthMutation) Fields() []string {
  35820. fields := make([]string, 0, 17)
  35821. if m.created_at != nil {
  35822. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  35823. }
  35824. if m.updated_at != nil {
  35825. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  35826. }
  35827. if m.status != nil {
  35828. fields = append(fields, usagestatisticmonth.FieldStatus)
  35829. }
  35830. if m.deleted_at != nil {
  35831. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  35832. }
  35833. if m.addtime != nil {
  35834. fields = append(fields, usagestatisticmonth.FieldAddtime)
  35835. }
  35836. if m._type != nil {
  35837. fields = append(fields, usagestatisticmonth.FieldType)
  35838. }
  35839. if m.bot_id != nil {
  35840. fields = append(fields, usagestatisticmonth.FieldBotID)
  35841. }
  35842. if m.organization_id != nil {
  35843. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  35844. }
  35845. if m.ai_response != nil {
  35846. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  35847. }
  35848. if m.sop_run != nil {
  35849. fields = append(fields, usagestatisticmonth.FieldSopRun)
  35850. }
  35851. if m.total_friend != nil {
  35852. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  35853. }
  35854. if m.total_group != nil {
  35855. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  35856. }
  35857. if m.account_balance != nil {
  35858. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  35859. }
  35860. if m.consume_token != nil {
  35861. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  35862. }
  35863. if m.active_user != nil {
  35864. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  35865. }
  35866. if m.new_user != nil {
  35867. fields = append(fields, usagestatisticmonth.FieldNewUser)
  35868. }
  35869. if m.label_dist != nil {
  35870. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  35871. }
  35872. return fields
  35873. }
  35874. // Field returns the value of a field with the given name. The second boolean
  35875. // return value indicates that this field was not set, or was not defined in the
  35876. // schema.
  35877. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  35878. switch name {
  35879. case usagestatisticmonth.FieldCreatedAt:
  35880. return m.CreatedAt()
  35881. case usagestatisticmonth.FieldUpdatedAt:
  35882. return m.UpdatedAt()
  35883. case usagestatisticmonth.FieldStatus:
  35884. return m.Status()
  35885. case usagestatisticmonth.FieldDeletedAt:
  35886. return m.DeletedAt()
  35887. case usagestatisticmonth.FieldAddtime:
  35888. return m.Addtime()
  35889. case usagestatisticmonth.FieldType:
  35890. return m.GetType()
  35891. case usagestatisticmonth.FieldBotID:
  35892. return m.BotID()
  35893. case usagestatisticmonth.FieldOrganizationID:
  35894. return m.OrganizationID()
  35895. case usagestatisticmonth.FieldAiResponse:
  35896. return m.AiResponse()
  35897. case usagestatisticmonth.FieldSopRun:
  35898. return m.SopRun()
  35899. case usagestatisticmonth.FieldTotalFriend:
  35900. return m.TotalFriend()
  35901. case usagestatisticmonth.FieldTotalGroup:
  35902. return m.TotalGroup()
  35903. case usagestatisticmonth.FieldAccountBalance:
  35904. return m.AccountBalance()
  35905. case usagestatisticmonth.FieldConsumeToken:
  35906. return m.ConsumeToken()
  35907. case usagestatisticmonth.FieldActiveUser:
  35908. return m.ActiveUser()
  35909. case usagestatisticmonth.FieldNewUser:
  35910. return m.NewUser()
  35911. case usagestatisticmonth.FieldLabelDist:
  35912. return m.LabelDist()
  35913. }
  35914. return nil, false
  35915. }
  35916. // OldField returns the old value of the field from the database. An error is
  35917. // returned if the mutation operation is not UpdateOne, or the query to the
  35918. // database failed.
  35919. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  35920. switch name {
  35921. case usagestatisticmonth.FieldCreatedAt:
  35922. return m.OldCreatedAt(ctx)
  35923. case usagestatisticmonth.FieldUpdatedAt:
  35924. return m.OldUpdatedAt(ctx)
  35925. case usagestatisticmonth.FieldStatus:
  35926. return m.OldStatus(ctx)
  35927. case usagestatisticmonth.FieldDeletedAt:
  35928. return m.OldDeletedAt(ctx)
  35929. case usagestatisticmonth.FieldAddtime:
  35930. return m.OldAddtime(ctx)
  35931. case usagestatisticmonth.FieldType:
  35932. return m.OldType(ctx)
  35933. case usagestatisticmonth.FieldBotID:
  35934. return m.OldBotID(ctx)
  35935. case usagestatisticmonth.FieldOrganizationID:
  35936. return m.OldOrganizationID(ctx)
  35937. case usagestatisticmonth.FieldAiResponse:
  35938. return m.OldAiResponse(ctx)
  35939. case usagestatisticmonth.FieldSopRun:
  35940. return m.OldSopRun(ctx)
  35941. case usagestatisticmonth.FieldTotalFriend:
  35942. return m.OldTotalFriend(ctx)
  35943. case usagestatisticmonth.FieldTotalGroup:
  35944. return m.OldTotalGroup(ctx)
  35945. case usagestatisticmonth.FieldAccountBalance:
  35946. return m.OldAccountBalance(ctx)
  35947. case usagestatisticmonth.FieldConsumeToken:
  35948. return m.OldConsumeToken(ctx)
  35949. case usagestatisticmonth.FieldActiveUser:
  35950. return m.OldActiveUser(ctx)
  35951. case usagestatisticmonth.FieldNewUser:
  35952. return m.OldNewUser(ctx)
  35953. case usagestatisticmonth.FieldLabelDist:
  35954. return m.OldLabelDist(ctx)
  35955. }
  35956. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  35957. }
  35958. // SetField sets the value of a field with the given name. It returns an error if
  35959. // the field is not defined in the schema, or if the type mismatched the field
  35960. // type.
  35961. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  35962. switch name {
  35963. case usagestatisticmonth.FieldCreatedAt:
  35964. v, ok := value.(time.Time)
  35965. if !ok {
  35966. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35967. }
  35968. m.SetCreatedAt(v)
  35969. return nil
  35970. case usagestatisticmonth.FieldUpdatedAt:
  35971. v, ok := value.(time.Time)
  35972. if !ok {
  35973. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35974. }
  35975. m.SetUpdatedAt(v)
  35976. return nil
  35977. case usagestatisticmonth.FieldStatus:
  35978. v, ok := value.(uint8)
  35979. if !ok {
  35980. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35981. }
  35982. m.SetStatus(v)
  35983. return nil
  35984. case usagestatisticmonth.FieldDeletedAt:
  35985. v, ok := value.(time.Time)
  35986. if !ok {
  35987. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35988. }
  35989. m.SetDeletedAt(v)
  35990. return nil
  35991. case usagestatisticmonth.FieldAddtime:
  35992. v, ok := value.(uint64)
  35993. if !ok {
  35994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35995. }
  35996. m.SetAddtime(v)
  35997. return nil
  35998. case usagestatisticmonth.FieldType:
  35999. v, ok := value.(int)
  36000. if !ok {
  36001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36002. }
  36003. m.SetType(v)
  36004. return nil
  36005. case usagestatisticmonth.FieldBotID:
  36006. v, ok := value.(string)
  36007. if !ok {
  36008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36009. }
  36010. m.SetBotID(v)
  36011. return nil
  36012. case usagestatisticmonth.FieldOrganizationID:
  36013. v, ok := value.(uint64)
  36014. if !ok {
  36015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36016. }
  36017. m.SetOrganizationID(v)
  36018. return nil
  36019. case usagestatisticmonth.FieldAiResponse:
  36020. v, ok := value.(uint64)
  36021. if !ok {
  36022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36023. }
  36024. m.SetAiResponse(v)
  36025. return nil
  36026. case usagestatisticmonth.FieldSopRun:
  36027. v, ok := value.(uint64)
  36028. if !ok {
  36029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36030. }
  36031. m.SetSopRun(v)
  36032. return nil
  36033. case usagestatisticmonth.FieldTotalFriend:
  36034. v, ok := value.(uint64)
  36035. if !ok {
  36036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36037. }
  36038. m.SetTotalFriend(v)
  36039. return nil
  36040. case usagestatisticmonth.FieldTotalGroup:
  36041. v, ok := value.(uint64)
  36042. if !ok {
  36043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36044. }
  36045. m.SetTotalGroup(v)
  36046. return nil
  36047. case usagestatisticmonth.FieldAccountBalance:
  36048. v, ok := value.(uint64)
  36049. if !ok {
  36050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36051. }
  36052. m.SetAccountBalance(v)
  36053. return nil
  36054. case usagestatisticmonth.FieldConsumeToken:
  36055. v, ok := value.(uint64)
  36056. if !ok {
  36057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36058. }
  36059. m.SetConsumeToken(v)
  36060. return nil
  36061. case usagestatisticmonth.FieldActiveUser:
  36062. v, ok := value.(uint64)
  36063. if !ok {
  36064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36065. }
  36066. m.SetActiveUser(v)
  36067. return nil
  36068. case usagestatisticmonth.FieldNewUser:
  36069. v, ok := value.(int64)
  36070. if !ok {
  36071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36072. }
  36073. m.SetNewUser(v)
  36074. return nil
  36075. case usagestatisticmonth.FieldLabelDist:
  36076. v, ok := value.([]custom_types.LabelDist)
  36077. if !ok {
  36078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36079. }
  36080. m.SetLabelDist(v)
  36081. return nil
  36082. }
  36083. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  36084. }
  36085. // AddedFields returns all numeric fields that were incremented/decremented during
  36086. // this mutation.
  36087. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  36088. var fields []string
  36089. if m.addstatus != nil {
  36090. fields = append(fields, usagestatisticmonth.FieldStatus)
  36091. }
  36092. if m.addaddtime != nil {
  36093. fields = append(fields, usagestatisticmonth.FieldAddtime)
  36094. }
  36095. if m.add_type != nil {
  36096. fields = append(fields, usagestatisticmonth.FieldType)
  36097. }
  36098. if m.addorganization_id != nil {
  36099. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  36100. }
  36101. if m.addai_response != nil {
  36102. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  36103. }
  36104. if m.addsop_run != nil {
  36105. fields = append(fields, usagestatisticmonth.FieldSopRun)
  36106. }
  36107. if m.addtotal_friend != nil {
  36108. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  36109. }
  36110. if m.addtotal_group != nil {
  36111. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  36112. }
  36113. if m.addaccount_balance != nil {
  36114. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  36115. }
  36116. if m.addconsume_token != nil {
  36117. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  36118. }
  36119. if m.addactive_user != nil {
  36120. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  36121. }
  36122. if m.addnew_user != nil {
  36123. fields = append(fields, usagestatisticmonth.FieldNewUser)
  36124. }
  36125. return fields
  36126. }
  36127. // AddedField returns the numeric value that was incremented/decremented on a field
  36128. // with the given name. The second boolean return value indicates that this field
  36129. // was not set, or was not defined in the schema.
  36130. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  36131. switch name {
  36132. case usagestatisticmonth.FieldStatus:
  36133. return m.AddedStatus()
  36134. case usagestatisticmonth.FieldAddtime:
  36135. return m.AddedAddtime()
  36136. case usagestatisticmonth.FieldType:
  36137. return m.AddedType()
  36138. case usagestatisticmonth.FieldOrganizationID:
  36139. return m.AddedOrganizationID()
  36140. case usagestatisticmonth.FieldAiResponse:
  36141. return m.AddedAiResponse()
  36142. case usagestatisticmonth.FieldSopRun:
  36143. return m.AddedSopRun()
  36144. case usagestatisticmonth.FieldTotalFriend:
  36145. return m.AddedTotalFriend()
  36146. case usagestatisticmonth.FieldTotalGroup:
  36147. return m.AddedTotalGroup()
  36148. case usagestatisticmonth.FieldAccountBalance:
  36149. return m.AddedAccountBalance()
  36150. case usagestatisticmonth.FieldConsumeToken:
  36151. return m.AddedConsumeToken()
  36152. case usagestatisticmonth.FieldActiveUser:
  36153. return m.AddedActiveUser()
  36154. case usagestatisticmonth.FieldNewUser:
  36155. return m.AddedNewUser()
  36156. }
  36157. return nil, false
  36158. }
  36159. // AddField adds the value to the field with the given name. It returns an error if
  36160. // the field is not defined in the schema, or if the type mismatched the field
  36161. // type.
  36162. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  36163. switch name {
  36164. case usagestatisticmonth.FieldStatus:
  36165. v, ok := value.(int8)
  36166. if !ok {
  36167. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36168. }
  36169. m.AddStatus(v)
  36170. return nil
  36171. case usagestatisticmonth.FieldAddtime:
  36172. v, ok := value.(int64)
  36173. if !ok {
  36174. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36175. }
  36176. m.AddAddtime(v)
  36177. return nil
  36178. case usagestatisticmonth.FieldType:
  36179. v, ok := value.(int)
  36180. if !ok {
  36181. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36182. }
  36183. m.AddType(v)
  36184. return nil
  36185. case usagestatisticmonth.FieldOrganizationID:
  36186. v, ok := value.(int64)
  36187. if !ok {
  36188. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36189. }
  36190. m.AddOrganizationID(v)
  36191. return nil
  36192. case usagestatisticmonth.FieldAiResponse:
  36193. v, ok := value.(int64)
  36194. if !ok {
  36195. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36196. }
  36197. m.AddAiResponse(v)
  36198. return nil
  36199. case usagestatisticmonth.FieldSopRun:
  36200. v, ok := value.(int64)
  36201. if !ok {
  36202. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36203. }
  36204. m.AddSopRun(v)
  36205. return nil
  36206. case usagestatisticmonth.FieldTotalFriend:
  36207. v, ok := value.(int64)
  36208. if !ok {
  36209. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36210. }
  36211. m.AddTotalFriend(v)
  36212. return nil
  36213. case usagestatisticmonth.FieldTotalGroup:
  36214. v, ok := value.(int64)
  36215. if !ok {
  36216. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36217. }
  36218. m.AddTotalGroup(v)
  36219. return nil
  36220. case usagestatisticmonth.FieldAccountBalance:
  36221. v, ok := value.(int64)
  36222. if !ok {
  36223. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36224. }
  36225. m.AddAccountBalance(v)
  36226. return nil
  36227. case usagestatisticmonth.FieldConsumeToken:
  36228. v, ok := value.(int64)
  36229. if !ok {
  36230. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36231. }
  36232. m.AddConsumeToken(v)
  36233. return nil
  36234. case usagestatisticmonth.FieldActiveUser:
  36235. v, ok := value.(int64)
  36236. if !ok {
  36237. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36238. }
  36239. m.AddActiveUser(v)
  36240. return nil
  36241. case usagestatisticmonth.FieldNewUser:
  36242. v, ok := value.(int64)
  36243. if !ok {
  36244. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36245. }
  36246. m.AddNewUser(v)
  36247. return nil
  36248. }
  36249. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  36250. }
  36251. // ClearedFields returns all nullable fields that were cleared during this
  36252. // mutation.
  36253. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  36254. var fields []string
  36255. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  36256. fields = append(fields, usagestatisticmonth.FieldStatus)
  36257. }
  36258. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  36259. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  36260. }
  36261. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  36262. fields = append(fields, usagestatisticmonth.FieldBotID)
  36263. }
  36264. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  36265. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  36266. }
  36267. return fields
  36268. }
  36269. // FieldCleared returns a boolean indicating if a field with the given name was
  36270. // cleared in this mutation.
  36271. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  36272. _, ok := m.clearedFields[name]
  36273. return ok
  36274. }
  36275. // ClearField clears the value of the field with the given name. It returns an
  36276. // error if the field is not defined in the schema.
  36277. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  36278. switch name {
  36279. case usagestatisticmonth.FieldStatus:
  36280. m.ClearStatus()
  36281. return nil
  36282. case usagestatisticmonth.FieldDeletedAt:
  36283. m.ClearDeletedAt()
  36284. return nil
  36285. case usagestatisticmonth.FieldBotID:
  36286. m.ClearBotID()
  36287. return nil
  36288. case usagestatisticmonth.FieldOrganizationID:
  36289. m.ClearOrganizationID()
  36290. return nil
  36291. }
  36292. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  36293. }
  36294. // ResetField resets all changes in the mutation for the field with the given name.
  36295. // It returns an error if the field is not defined in the schema.
  36296. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  36297. switch name {
  36298. case usagestatisticmonth.FieldCreatedAt:
  36299. m.ResetCreatedAt()
  36300. return nil
  36301. case usagestatisticmonth.FieldUpdatedAt:
  36302. m.ResetUpdatedAt()
  36303. return nil
  36304. case usagestatisticmonth.FieldStatus:
  36305. m.ResetStatus()
  36306. return nil
  36307. case usagestatisticmonth.FieldDeletedAt:
  36308. m.ResetDeletedAt()
  36309. return nil
  36310. case usagestatisticmonth.FieldAddtime:
  36311. m.ResetAddtime()
  36312. return nil
  36313. case usagestatisticmonth.FieldType:
  36314. m.ResetType()
  36315. return nil
  36316. case usagestatisticmonth.FieldBotID:
  36317. m.ResetBotID()
  36318. return nil
  36319. case usagestatisticmonth.FieldOrganizationID:
  36320. m.ResetOrganizationID()
  36321. return nil
  36322. case usagestatisticmonth.FieldAiResponse:
  36323. m.ResetAiResponse()
  36324. return nil
  36325. case usagestatisticmonth.FieldSopRun:
  36326. m.ResetSopRun()
  36327. return nil
  36328. case usagestatisticmonth.FieldTotalFriend:
  36329. m.ResetTotalFriend()
  36330. return nil
  36331. case usagestatisticmonth.FieldTotalGroup:
  36332. m.ResetTotalGroup()
  36333. return nil
  36334. case usagestatisticmonth.FieldAccountBalance:
  36335. m.ResetAccountBalance()
  36336. return nil
  36337. case usagestatisticmonth.FieldConsumeToken:
  36338. m.ResetConsumeToken()
  36339. return nil
  36340. case usagestatisticmonth.FieldActiveUser:
  36341. m.ResetActiveUser()
  36342. return nil
  36343. case usagestatisticmonth.FieldNewUser:
  36344. m.ResetNewUser()
  36345. return nil
  36346. case usagestatisticmonth.FieldLabelDist:
  36347. m.ResetLabelDist()
  36348. return nil
  36349. }
  36350. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  36351. }
  36352. // AddedEdges returns all edge names that were set/added in this mutation.
  36353. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  36354. edges := make([]string, 0, 0)
  36355. return edges
  36356. }
  36357. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  36358. // name in this mutation.
  36359. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  36360. return nil
  36361. }
  36362. // RemovedEdges returns all edge names that were removed in this mutation.
  36363. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  36364. edges := make([]string, 0, 0)
  36365. return edges
  36366. }
  36367. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  36368. // the given name in this mutation.
  36369. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  36370. return nil
  36371. }
  36372. // ClearedEdges returns all edge names that were cleared in this mutation.
  36373. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  36374. edges := make([]string, 0, 0)
  36375. return edges
  36376. }
  36377. // EdgeCleared returns a boolean which indicates if the edge with the given name
  36378. // was cleared in this mutation.
  36379. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  36380. return false
  36381. }
  36382. // ClearEdge clears the value of the edge with the given name. It returns an error
  36383. // if that edge is not defined in the schema.
  36384. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  36385. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  36386. }
  36387. // ResetEdge resets all changes to the edge with the given name in this mutation.
  36388. // It returns an error if the edge is not defined in the schema.
  36389. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  36390. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  36391. }
  36392. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  36393. type UsageTotalMutation struct {
  36394. config
  36395. op Op
  36396. typ string
  36397. id *uint64
  36398. created_at *time.Time
  36399. updated_at *time.Time
  36400. status *uint8
  36401. addstatus *int8
  36402. _type *int
  36403. add_type *int
  36404. bot_id *string
  36405. total_tokens *uint64
  36406. addtotal_tokens *int64
  36407. start_index *uint64
  36408. addstart_index *int64
  36409. end_index *uint64
  36410. addend_index *int64
  36411. organization_id *uint64
  36412. addorganization_id *int64
  36413. clearedFields map[string]struct{}
  36414. done bool
  36415. oldValue func(context.Context) (*UsageTotal, error)
  36416. predicates []predicate.UsageTotal
  36417. }
  36418. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  36419. // usagetotalOption allows management of the mutation configuration using functional options.
  36420. type usagetotalOption func(*UsageTotalMutation)
  36421. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  36422. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  36423. m := &UsageTotalMutation{
  36424. config: c,
  36425. op: op,
  36426. typ: TypeUsageTotal,
  36427. clearedFields: make(map[string]struct{}),
  36428. }
  36429. for _, opt := range opts {
  36430. opt(m)
  36431. }
  36432. return m
  36433. }
  36434. // withUsageTotalID sets the ID field of the mutation.
  36435. func withUsageTotalID(id uint64) usagetotalOption {
  36436. return func(m *UsageTotalMutation) {
  36437. var (
  36438. err error
  36439. once sync.Once
  36440. value *UsageTotal
  36441. )
  36442. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  36443. once.Do(func() {
  36444. if m.done {
  36445. err = errors.New("querying old values post mutation is not allowed")
  36446. } else {
  36447. value, err = m.Client().UsageTotal.Get(ctx, id)
  36448. }
  36449. })
  36450. return value, err
  36451. }
  36452. m.id = &id
  36453. }
  36454. }
  36455. // withUsageTotal sets the old UsageTotal of the mutation.
  36456. func withUsageTotal(node *UsageTotal) usagetotalOption {
  36457. return func(m *UsageTotalMutation) {
  36458. m.oldValue = func(context.Context) (*UsageTotal, error) {
  36459. return node, nil
  36460. }
  36461. m.id = &node.ID
  36462. }
  36463. }
  36464. // Client returns a new `ent.Client` from the mutation. If the mutation was
  36465. // executed in a transaction (ent.Tx), a transactional client is returned.
  36466. func (m UsageTotalMutation) Client() *Client {
  36467. client := &Client{config: m.config}
  36468. client.init()
  36469. return client
  36470. }
  36471. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  36472. // it returns an error otherwise.
  36473. func (m UsageTotalMutation) Tx() (*Tx, error) {
  36474. if _, ok := m.driver.(*txDriver); !ok {
  36475. return nil, errors.New("ent: mutation is not running in a transaction")
  36476. }
  36477. tx := &Tx{config: m.config}
  36478. tx.init()
  36479. return tx, nil
  36480. }
  36481. // SetID sets the value of the id field. Note that this
  36482. // operation is only accepted on creation of UsageTotal entities.
  36483. func (m *UsageTotalMutation) SetID(id uint64) {
  36484. m.id = &id
  36485. }
  36486. // ID returns the ID value in the mutation. Note that the ID is only available
  36487. // if it was provided to the builder or after it was returned from the database.
  36488. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  36489. if m.id == nil {
  36490. return
  36491. }
  36492. return *m.id, true
  36493. }
  36494. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36495. // That means, if the mutation is applied within a transaction with an isolation level such
  36496. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36497. // or updated by the mutation.
  36498. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  36499. switch {
  36500. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36501. id, exists := m.ID()
  36502. if exists {
  36503. return []uint64{id}, nil
  36504. }
  36505. fallthrough
  36506. case m.op.Is(OpUpdate | OpDelete):
  36507. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  36508. default:
  36509. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36510. }
  36511. }
  36512. // SetCreatedAt sets the "created_at" field.
  36513. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  36514. m.created_at = &t
  36515. }
  36516. // CreatedAt returns the value of the "created_at" field in the mutation.
  36517. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  36518. v := m.created_at
  36519. if v == nil {
  36520. return
  36521. }
  36522. return *v, true
  36523. }
  36524. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  36525. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  36526. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36527. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36528. if !m.op.Is(OpUpdateOne) {
  36529. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36530. }
  36531. if m.id == nil || m.oldValue == nil {
  36532. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36533. }
  36534. oldValue, err := m.oldValue(ctx)
  36535. if err != nil {
  36536. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36537. }
  36538. return oldValue.CreatedAt, nil
  36539. }
  36540. // ResetCreatedAt resets all changes to the "created_at" field.
  36541. func (m *UsageTotalMutation) ResetCreatedAt() {
  36542. m.created_at = nil
  36543. }
  36544. // SetUpdatedAt sets the "updated_at" field.
  36545. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  36546. m.updated_at = &t
  36547. }
  36548. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36549. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  36550. v := m.updated_at
  36551. if v == nil {
  36552. return
  36553. }
  36554. return *v, true
  36555. }
  36556. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  36557. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  36558. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36559. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36560. if !m.op.Is(OpUpdateOne) {
  36561. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36562. }
  36563. if m.id == nil || m.oldValue == nil {
  36564. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36565. }
  36566. oldValue, err := m.oldValue(ctx)
  36567. if err != nil {
  36568. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36569. }
  36570. return oldValue.UpdatedAt, nil
  36571. }
  36572. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36573. func (m *UsageTotalMutation) ResetUpdatedAt() {
  36574. m.updated_at = nil
  36575. }
  36576. // SetStatus sets the "status" field.
  36577. func (m *UsageTotalMutation) SetStatus(u uint8) {
  36578. m.status = &u
  36579. m.addstatus = nil
  36580. }
  36581. // Status returns the value of the "status" field in the mutation.
  36582. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  36583. v := m.status
  36584. if v == nil {
  36585. return
  36586. }
  36587. return *v, true
  36588. }
  36589. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  36590. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  36591. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36592. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  36593. if !m.op.Is(OpUpdateOne) {
  36594. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  36595. }
  36596. if m.id == nil || m.oldValue == nil {
  36597. return v, errors.New("OldStatus requires an ID field in the mutation")
  36598. }
  36599. oldValue, err := m.oldValue(ctx)
  36600. if err != nil {
  36601. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  36602. }
  36603. return oldValue.Status, nil
  36604. }
  36605. // AddStatus adds u to the "status" field.
  36606. func (m *UsageTotalMutation) AddStatus(u int8) {
  36607. if m.addstatus != nil {
  36608. *m.addstatus += u
  36609. } else {
  36610. m.addstatus = &u
  36611. }
  36612. }
  36613. // AddedStatus returns the value that was added to the "status" field in this mutation.
  36614. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  36615. v := m.addstatus
  36616. if v == nil {
  36617. return
  36618. }
  36619. return *v, true
  36620. }
  36621. // ClearStatus clears the value of the "status" field.
  36622. func (m *UsageTotalMutation) ClearStatus() {
  36623. m.status = nil
  36624. m.addstatus = nil
  36625. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  36626. }
  36627. // StatusCleared returns if the "status" field was cleared in this mutation.
  36628. func (m *UsageTotalMutation) StatusCleared() bool {
  36629. _, ok := m.clearedFields[usagetotal.FieldStatus]
  36630. return ok
  36631. }
  36632. // ResetStatus resets all changes to the "status" field.
  36633. func (m *UsageTotalMutation) ResetStatus() {
  36634. m.status = nil
  36635. m.addstatus = nil
  36636. delete(m.clearedFields, usagetotal.FieldStatus)
  36637. }
  36638. // SetType sets the "type" field.
  36639. func (m *UsageTotalMutation) SetType(i int) {
  36640. m._type = &i
  36641. m.add_type = nil
  36642. }
  36643. // GetType returns the value of the "type" field in the mutation.
  36644. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  36645. v := m._type
  36646. if v == nil {
  36647. return
  36648. }
  36649. return *v, true
  36650. }
  36651. // OldType returns the old "type" field's value of the UsageTotal entity.
  36652. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  36653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36654. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  36655. if !m.op.Is(OpUpdateOne) {
  36656. return v, errors.New("OldType is only allowed on UpdateOne operations")
  36657. }
  36658. if m.id == nil || m.oldValue == nil {
  36659. return v, errors.New("OldType requires an ID field in the mutation")
  36660. }
  36661. oldValue, err := m.oldValue(ctx)
  36662. if err != nil {
  36663. return v, fmt.Errorf("querying old value for OldType: %w", err)
  36664. }
  36665. return oldValue.Type, nil
  36666. }
  36667. // AddType adds i to the "type" field.
  36668. func (m *UsageTotalMutation) AddType(i int) {
  36669. if m.add_type != nil {
  36670. *m.add_type += i
  36671. } else {
  36672. m.add_type = &i
  36673. }
  36674. }
  36675. // AddedType returns the value that was added to the "type" field in this mutation.
  36676. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  36677. v := m.add_type
  36678. if v == nil {
  36679. return
  36680. }
  36681. return *v, true
  36682. }
  36683. // ClearType clears the value of the "type" field.
  36684. func (m *UsageTotalMutation) ClearType() {
  36685. m._type = nil
  36686. m.add_type = nil
  36687. m.clearedFields[usagetotal.FieldType] = struct{}{}
  36688. }
  36689. // TypeCleared returns if the "type" field was cleared in this mutation.
  36690. func (m *UsageTotalMutation) TypeCleared() bool {
  36691. _, ok := m.clearedFields[usagetotal.FieldType]
  36692. return ok
  36693. }
  36694. // ResetType resets all changes to the "type" field.
  36695. func (m *UsageTotalMutation) ResetType() {
  36696. m._type = nil
  36697. m.add_type = nil
  36698. delete(m.clearedFields, usagetotal.FieldType)
  36699. }
  36700. // SetBotID sets the "bot_id" field.
  36701. func (m *UsageTotalMutation) SetBotID(s string) {
  36702. m.bot_id = &s
  36703. }
  36704. // BotID returns the value of the "bot_id" field in the mutation.
  36705. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  36706. v := m.bot_id
  36707. if v == nil {
  36708. return
  36709. }
  36710. return *v, true
  36711. }
  36712. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  36713. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  36714. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36715. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  36716. if !m.op.Is(OpUpdateOne) {
  36717. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  36718. }
  36719. if m.id == nil || m.oldValue == nil {
  36720. return v, errors.New("OldBotID requires an ID field in the mutation")
  36721. }
  36722. oldValue, err := m.oldValue(ctx)
  36723. if err != nil {
  36724. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  36725. }
  36726. return oldValue.BotID, nil
  36727. }
  36728. // ResetBotID resets all changes to the "bot_id" field.
  36729. func (m *UsageTotalMutation) ResetBotID() {
  36730. m.bot_id = nil
  36731. }
  36732. // SetTotalTokens sets the "total_tokens" field.
  36733. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  36734. m.total_tokens = &u
  36735. m.addtotal_tokens = nil
  36736. }
  36737. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  36738. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  36739. v := m.total_tokens
  36740. if v == nil {
  36741. return
  36742. }
  36743. return *v, true
  36744. }
  36745. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  36746. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  36747. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36748. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  36749. if !m.op.Is(OpUpdateOne) {
  36750. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  36751. }
  36752. if m.id == nil || m.oldValue == nil {
  36753. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  36754. }
  36755. oldValue, err := m.oldValue(ctx)
  36756. if err != nil {
  36757. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  36758. }
  36759. return oldValue.TotalTokens, nil
  36760. }
  36761. // AddTotalTokens adds u to the "total_tokens" field.
  36762. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  36763. if m.addtotal_tokens != nil {
  36764. *m.addtotal_tokens += u
  36765. } else {
  36766. m.addtotal_tokens = &u
  36767. }
  36768. }
  36769. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  36770. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  36771. v := m.addtotal_tokens
  36772. if v == nil {
  36773. return
  36774. }
  36775. return *v, true
  36776. }
  36777. // ClearTotalTokens clears the value of the "total_tokens" field.
  36778. func (m *UsageTotalMutation) ClearTotalTokens() {
  36779. m.total_tokens = nil
  36780. m.addtotal_tokens = nil
  36781. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  36782. }
  36783. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  36784. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  36785. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  36786. return ok
  36787. }
  36788. // ResetTotalTokens resets all changes to the "total_tokens" field.
  36789. func (m *UsageTotalMutation) ResetTotalTokens() {
  36790. m.total_tokens = nil
  36791. m.addtotal_tokens = nil
  36792. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  36793. }
  36794. // SetStartIndex sets the "start_index" field.
  36795. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  36796. m.start_index = &u
  36797. m.addstart_index = nil
  36798. }
  36799. // StartIndex returns the value of the "start_index" field in the mutation.
  36800. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  36801. v := m.start_index
  36802. if v == nil {
  36803. return
  36804. }
  36805. return *v, true
  36806. }
  36807. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  36808. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  36809. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36810. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  36811. if !m.op.Is(OpUpdateOne) {
  36812. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  36813. }
  36814. if m.id == nil || m.oldValue == nil {
  36815. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  36816. }
  36817. oldValue, err := m.oldValue(ctx)
  36818. if err != nil {
  36819. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  36820. }
  36821. return oldValue.StartIndex, nil
  36822. }
  36823. // AddStartIndex adds u to the "start_index" field.
  36824. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  36825. if m.addstart_index != nil {
  36826. *m.addstart_index += u
  36827. } else {
  36828. m.addstart_index = &u
  36829. }
  36830. }
  36831. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  36832. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  36833. v := m.addstart_index
  36834. if v == nil {
  36835. return
  36836. }
  36837. return *v, true
  36838. }
  36839. // ClearStartIndex clears the value of the "start_index" field.
  36840. func (m *UsageTotalMutation) ClearStartIndex() {
  36841. m.start_index = nil
  36842. m.addstart_index = nil
  36843. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  36844. }
  36845. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  36846. func (m *UsageTotalMutation) StartIndexCleared() bool {
  36847. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  36848. return ok
  36849. }
  36850. // ResetStartIndex resets all changes to the "start_index" field.
  36851. func (m *UsageTotalMutation) ResetStartIndex() {
  36852. m.start_index = nil
  36853. m.addstart_index = nil
  36854. delete(m.clearedFields, usagetotal.FieldStartIndex)
  36855. }
  36856. // SetEndIndex sets the "end_index" field.
  36857. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  36858. m.end_index = &u
  36859. m.addend_index = nil
  36860. }
  36861. // EndIndex returns the value of the "end_index" field in the mutation.
  36862. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  36863. v := m.end_index
  36864. if v == nil {
  36865. return
  36866. }
  36867. return *v, true
  36868. }
  36869. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  36870. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  36871. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36872. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  36873. if !m.op.Is(OpUpdateOne) {
  36874. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  36875. }
  36876. if m.id == nil || m.oldValue == nil {
  36877. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  36878. }
  36879. oldValue, err := m.oldValue(ctx)
  36880. if err != nil {
  36881. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  36882. }
  36883. return oldValue.EndIndex, nil
  36884. }
  36885. // AddEndIndex adds u to the "end_index" field.
  36886. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  36887. if m.addend_index != nil {
  36888. *m.addend_index += u
  36889. } else {
  36890. m.addend_index = &u
  36891. }
  36892. }
  36893. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  36894. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  36895. v := m.addend_index
  36896. if v == nil {
  36897. return
  36898. }
  36899. return *v, true
  36900. }
  36901. // ClearEndIndex clears the value of the "end_index" field.
  36902. func (m *UsageTotalMutation) ClearEndIndex() {
  36903. m.end_index = nil
  36904. m.addend_index = nil
  36905. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  36906. }
  36907. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  36908. func (m *UsageTotalMutation) EndIndexCleared() bool {
  36909. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  36910. return ok
  36911. }
  36912. // ResetEndIndex resets all changes to the "end_index" field.
  36913. func (m *UsageTotalMutation) ResetEndIndex() {
  36914. m.end_index = nil
  36915. m.addend_index = nil
  36916. delete(m.clearedFields, usagetotal.FieldEndIndex)
  36917. }
  36918. // SetOrganizationID sets the "organization_id" field.
  36919. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  36920. m.organization_id = &u
  36921. m.addorganization_id = nil
  36922. }
  36923. // OrganizationID returns the value of the "organization_id" field in the mutation.
  36924. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  36925. v := m.organization_id
  36926. if v == nil {
  36927. return
  36928. }
  36929. return *v, true
  36930. }
  36931. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  36932. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  36933. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36934. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  36935. if !m.op.Is(OpUpdateOne) {
  36936. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  36937. }
  36938. if m.id == nil || m.oldValue == nil {
  36939. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  36940. }
  36941. oldValue, err := m.oldValue(ctx)
  36942. if err != nil {
  36943. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  36944. }
  36945. return oldValue.OrganizationID, nil
  36946. }
  36947. // AddOrganizationID adds u to the "organization_id" field.
  36948. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  36949. if m.addorganization_id != nil {
  36950. *m.addorganization_id += u
  36951. } else {
  36952. m.addorganization_id = &u
  36953. }
  36954. }
  36955. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  36956. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  36957. v := m.addorganization_id
  36958. if v == nil {
  36959. return
  36960. }
  36961. return *v, true
  36962. }
  36963. // ClearOrganizationID clears the value of the "organization_id" field.
  36964. func (m *UsageTotalMutation) ClearOrganizationID() {
  36965. m.organization_id = nil
  36966. m.addorganization_id = nil
  36967. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  36968. }
  36969. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  36970. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  36971. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  36972. return ok
  36973. }
  36974. // ResetOrganizationID resets all changes to the "organization_id" field.
  36975. func (m *UsageTotalMutation) ResetOrganizationID() {
  36976. m.organization_id = nil
  36977. m.addorganization_id = nil
  36978. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  36979. }
  36980. // Where appends a list predicates to the UsageTotalMutation builder.
  36981. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  36982. m.predicates = append(m.predicates, ps...)
  36983. }
  36984. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  36985. // users can use type-assertion to append predicates that do not depend on any generated package.
  36986. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  36987. p := make([]predicate.UsageTotal, len(ps))
  36988. for i := range ps {
  36989. p[i] = ps[i]
  36990. }
  36991. m.Where(p...)
  36992. }
  36993. // Op returns the operation name.
  36994. func (m *UsageTotalMutation) Op() Op {
  36995. return m.op
  36996. }
  36997. // SetOp allows setting the mutation operation.
  36998. func (m *UsageTotalMutation) SetOp(op Op) {
  36999. m.op = op
  37000. }
  37001. // Type returns the node type of this mutation (UsageTotal).
  37002. func (m *UsageTotalMutation) Type() string {
  37003. return m.typ
  37004. }
  37005. // Fields returns all fields that were changed during this mutation. Note that in
  37006. // order to get all numeric fields that were incremented/decremented, call
  37007. // AddedFields().
  37008. func (m *UsageTotalMutation) Fields() []string {
  37009. fields := make([]string, 0, 9)
  37010. if m.created_at != nil {
  37011. fields = append(fields, usagetotal.FieldCreatedAt)
  37012. }
  37013. if m.updated_at != nil {
  37014. fields = append(fields, usagetotal.FieldUpdatedAt)
  37015. }
  37016. if m.status != nil {
  37017. fields = append(fields, usagetotal.FieldStatus)
  37018. }
  37019. if m._type != nil {
  37020. fields = append(fields, usagetotal.FieldType)
  37021. }
  37022. if m.bot_id != nil {
  37023. fields = append(fields, usagetotal.FieldBotID)
  37024. }
  37025. if m.total_tokens != nil {
  37026. fields = append(fields, usagetotal.FieldTotalTokens)
  37027. }
  37028. if m.start_index != nil {
  37029. fields = append(fields, usagetotal.FieldStartIndex)
  37030. }
  37031. if m.end_index != nil {
  37032. fields = append(fields, usagetotal.FieldEndIndex)
  37033. }
  37034. if m.organization_id != nil {
  37035. fields = append(fields, usagetotal.FieldOrganizationID)
  37036. }
  37037. return fields
  37038. }
  37039. // Field returns the value of a field with the given name. The second boolean
  37040. // return value indicates that this field was not set, or was not defined in the
  37041. // schema.
  37042. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  37043. switch name {
  37044. case usagetotal.FieldCreatedAt:
  37045. return m.CreatedAt()
  37046. case usagetotal.FieldUpdatedAt:
  37047. return m.UpdatedAt()
  37048. case usagetotal.FieldStatus:
  37049. return m.Status()
  37050. case usagetotal.FieldType:
  37051. return m.GetType()
  37052. case usagetotal.FieldBotID:
  37053. return m.BotID()
  37054. case usagetotal.FieldTotalTokens:
  37055. return m.TotalTokens()
  37056. case usagetotal.FieldStartIndex:
  37057. return m.StartIndex()
  37058. case usagetotal.FieldEndIndex:
  37059. return m.EndIndex()
  37060. case usagetotal.FieldOrganizationID:
  37061. return m.OrganizationID()
  37062. }
  37063. return nil, false
  37064. }
  37065. // OldField returns the old value of the field from the database. An error is
  37066. // returned if the mutation operation is not UpdateOne, or the query to the
  37067. // database failed.
  37068. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37069. switch name {
  37070. case usagetotal.FieldCreatedAt:
  37071. return m.OldCreatedAt(ctx)
  37072. case usagetotal.FieldUpdatedAt:
  37073. return m.OldUpdatedAt(ctx)
  37074. case usagetotal.FieldStatus:
  37075. return m.OldStatus(ctx)
  37076. case usagetotal.FieldType:
  37077. return m.OldType(ctx)
  37078. case usagetotal.FieldBotID:
  37079. return m.OldBotID(ctx)
  37080. case usagetotal.FieldTotalTokens:
  37081. return m.OldTotalTokens(ctx)
  37082. case usagetotal.FieldStartIndex:
  37083. return m.OldStartIndex(ctx)
  37084. case usagetotal.FieldEndIndex:
  37085. return m.OldEndIndex(ctx)
  37086. case usagetotal.FieldOrganizationID:
  37087. return m.OldOrganizationID(ctx)
  37088. }
  37089. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  37090. }
  37091. // SetField sets the value of a field with the given name. It returns an error if
  37092. // the field is not defined in the schema, or if the type mismatched the field
  37093. // type.
  37094. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  37095. switch name {
  37096. case usagetotal.FieldCreatedAt:
  37097. v, ok := value.(time.Time)
  37098. if !ok {
  37099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37100. }
  37101. m.SetCreatedAt(v)
  37102. return nil
  37103. case usagetotal.FieldUpdatedAt:
  37104. v, ok := value.(time.Time)
  37105. if !ok {
  37106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37107. }
  37108. m.SetUpdatedAt(v)
  37109. return nil
  37110. case usagetotal.FieldStatus:
  37111. v, ok := value.(uint8)
  37112. if !ok {
  37113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37114. }
  37115. m.SetStatus(v)
  37116. return nil
  37117. case usagetotal.FieldType:
  37118. v, ok := value.(int)
  37119. if !ok {
  37120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37121. }
  37122. m.SetType(v)
  37123. return nil
  37124. case usagetotal.FieldBotID:
  37125. v, ok := value.(string)
  37126. if !ok {
  37127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37128. }
  37129. m.SetBotID(v)
  37130. return nil
  37131. case usagetotal.FieldTotalTokens:
  37132. v, ok := value.(uint64)
  37133. if !ok {
  37134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37135. }
  37136. m.SetTotalTokens(v)
  37137. return nil
  37138. case usagetotal.FieldStartIndex:
  37139. v, ok := value.(uint64)
  37140. if !ok {
  37141. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37142. }
  37143. m.SetStartIndex(v)
  37144. return nil
  37145. case usagetotal.FieldEndIndex:
  37146. v, ok := value.(uint64)
  37147. if !ok {
  37148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37149. }
  37150. m.SetEndIndex(v)
  37151. return nil
  37152. case usagetotal.FieldOrganizationID:
  37153. v, ok := value.(uint64)
  37154. if !ok {
  37155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37156. }
  37157. m.SetOrganizationID(v)
  37158. return nil
  37159. }
  37160. return fmt.Errorf("unknown UsageTotal field %s", name)
  37161. }
  37162. // AddedFields returns all numeric fields that were incremented/decremented during
  37163. // this mutation.
  37164. func (m *UsageTotalMutation) AddedFields() []string {
  37165. var fields []string
  37166. if m.addstatus != nil {
  37167. fields = append(fields, usagetotal.FieldStatus)
  37168. }
  37169. if m.add_type != nil {
  37170. fields = append(fields, usagetotal.FieldType)
  37171. }
  37172. if m.addtotal_tokens != nil {
  37173. fields = append(fields, usagetotal.FieldTotalTokens)
  37174. }
  37175. if m.addstart_index != nil {
  37176. fields = append(fields, usagetotal.FieldStartIndex)
  37177. }
  37178. if m.addend_index != nil {
  37179. fields = append(fields, usagetotal.FieldEndIndex)
  37180. }
  37181. if m.addorganization_id != nil {
  37182. fields = append(fields, usagetotal.FieldOrganizationID)
  37183. }
  37184. return fields
  37185. }
  37186. // AddedField returns the numeric value that was incremented/decremented on a field
  37187. // with the given name. The second boolean return value indicates that this field
  37188. // was not set, or was not defined in the schema.
  37189. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  37190. switch name {
  37191. case usagetotal.FieldStatus:
  37192. return m.AddedStatus()
  37193. case usagetotal.FieldType:
  37194. return m.AddedType()
  37195. case usagetotal.FieldTotalTokens:
  37196. return m.AddedTotalTokens()
  37197. case usagetotal.FieldStartIndex:
  37198. return m.AddedStartIndex()
  37199. case usagetotal.FieldEndIndex:
  37200. return m.AddedEndIndex()
  37201. case usagetotal.FieldOrganizationID:
  37202. return m.AddedOrganizationID()
  37203. }
  37204. return nil, false
  37205. }
  37206. // AddField adds the value to the field with the given name. It returns an error if
  37207. // the field is not defined in the schema, or if the type mismatched the field
  37208. // type.
  37209. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  37210. switch name {
  37211. case usagetotal.FieldStatus:
  37212. v, ok := value.(int8)
  37213. if !ok {
  37214. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37215. }
  37216. m.AddStatus(v)
  37217. return nil
  37218. case usagetotal.FieldType:
  37219. v, ok := value.(int)
  37220. if !ok {
  37221. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37222. }
  37223. m.AddType(v)
  37224. return nil
  37225. case usagetotal.FieldTotalTokens:
  37226. v, ok := value.(int64)
  37227. if !ok {
  37228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37229. }
  37230. m.AddTotalTokens(v)
  37231. return nil
  37232. case usagetotal.FieldStartIndex:
  37233. v, ok := value.(int64)
  37234. if !ok {
  37235. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37236. }
  37237. m.AddStartIndex(v)
  37238. return nil
  37239. case usagetotal.FieldEndIndex:
  37240. v, ok := value.(int64)
  37241. if !ok {
  37242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37243. }
  37244. m.AddEndIndex(v)
  37245. return nil
  37246. case usagetotal.FieldOrganizationID:
  37247. v, ok := value.(int64)
  37248. if !ok {
  37249. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37250. }
  37251. m.AddOrganizationID(v)
  37252. return nil
  37253. }
  37254. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  37255. }
  37256. // ClearedFields returns all nullable fields that were cleared during this
  37257. // mutation.
  37258. func (m *UsageTotalMutation) ClearedFields() []string {
  37259. var fields []string
  37260. if m.FieldCleared(usagetotal.FieldStatus) {
  37261. fields = append(fields, usagetotal.FieldStatus)
  37262. }
  37263. if m.FieldCleared(usagetotal.FieldType) {
  37264. fields = append(fields, usagetotal.FieldType)
  37265. }
  37266. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  37267. fields = append(fields, usagetotal.FieldTotalTokens)
  37268. }
  37269. if m.FieldCleared(usagetotal.FieldStartIndex) {
  37270. fields = append(fields, usagetotal.FieldStartIndex)
  37271. }
  37272. if m.FieldCleared(usagetotal.FieldEndIndex) {
  37273. fields = append(fields, usagetotal.FieldEndIndex)
  37274. }
  37275. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  37276. fields = append(fields, usagetotal.FieldOrganizationID)
  37277. }
  37278. return fields
  37279. }
  37280. // FieldCleared returns a boolean indicating if a field with the given name was
  37281. // cleared in this mutation.
  37282. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  37283. _, ok := m.clearedFields[name]
  37284. return ok
  37285. }
  37286. // ClearField clears the value of the field with the given name. It returns an
  37287. // error if the field is not defined in the schema.
  37288. func (m *UsageTotalMutation) ClearField(name string) error {
  37289. switch name {
  37290. case usagetotal.FieldStatus:
  37291. m.ClearStatus()
  37292. return nil
  37293. case usagetotal.FieldType:
  37294. m.ClearType()
  37295. return nil
  37296. case usagetotal.FieldTotalTokens:
  37297. m.ClearTotalTokens()
  37298. return nil
  37299. case usagetotal.FieldStartIndex:
  37300. m.ClearStartIndex()
  37301. return nil
  37302. case usagetotal.FieldEndIndex:
  37303. m.ClearEndIndex()
  37304. return nil
  37305. case usagetotal.FieldOrganizationID:
  37306. m.ClearOrganizationID()
  37307. return nil
  37308. }
  37309. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  37310. }
  37311. // ResetField resets all changes in the mutation for the field with the given name.
  37312. // It returns an error if the field is not defined in the schema.
  37313. func (m *UsageTotalMutation) ResetField(name string) error {
  37314. switch name {
  37315. case usagetotal.FieldCreatedAt:
  37316. m.ResetCreatedAt()
  37317. return nil
  37318. case usagetotal.FieldUpdatedAt:
  37319. m.ResetUpdatedAt()
  37320. return nil
  37321. case usagetotal.FieldStatus:
  37322. m.ResetStatus()
  37323. return nil
  37324. case usagetotal.FieldType:
  37325. m.ResetType()
  37326. return nil
  37327. case usagetotal.FieldBotID:
  37328. m.ResetBotID()
  37329. return nil
  37330. case usagetotal.FieldTotalTokens:
  37331. m.ResetTotalTokens()
  37332. return nil
  37333. case usagetotal.FieldStartIndex:
  37334. m.ResetStartIndex()
  37335. return nil
  37336. case usagetotal.FieldEndIndex:
  37337. m.ResetEndIndex()
  37338. return nil
  37339. case usagetotal.FieldOrganizationID:
  37340. m.ResetOrganizationID()
  37341. return nil
  37342. }
  37343. return fmt.Errorf("unknown UsageTotal field %s", name)
  37344. }
  37345. // AddedEdges returns all edge names that were set/added in this mutation.
  37346. func (m *UsageTotalMutation) AddedEdges() []string {
  37347. edges := make([]string, 0, 0)
  37348. return edges
  37349. }
  37350. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37351. // name in this mutation.
  37352. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  37353. return nil
  37354. }
  37355. // RemovedEdges returns all edge names that were removed in this mutation.
  37356. func (m *UsageTotalMutation) RemovedEdges() []string {
  37357. edges := make([]string, 0, 0)
  37358. return edges
  37359. }
  37360. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37361. // the given name in this mutation.
  37362. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  37363. return nil
  37364. }
  37365. // ClearedEdges returns all edge names that were cleared in this mutation.
  37366. func (m *UsageTotalMutation) ClearedEdges() []string {
  37367. edges := make([]string, 0, 0)
  37368. return edges
  37369. }
  37370. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37371. // was cleared in this mutation.
  37372. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  37373. return false
  37374. }
  37375. // ClearEdge clears the value of the edge with the given name. It returns an error
  37376. // if that edge is not defined in the schema.
  37377. func (m *UsageTotalMutation) ClearEdge(name string) error {
  37378. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  37379. }
  37380. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37381. // It returns an error if the edge is not defined in the schema.
  37382. func (m *UsageTotalMutation) ResetEdge(name string) error {
  37383. return fmt.Errorf("unknown UsageTotal edge %s", name)
  37384. }
  37385. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  37386. type WhatsappMutation struct {
  37387. config
  37388. op Op
  37389. typ string
  37390. id *uint64
  37391. created_at *time.Time
  37392. updated_at *time.Time
  37393. status *uint8
  37394. addstatus *int8
  37395. deleted_at *time.Time
  37396. wa_id *string
  37397. wa_name *string
  37398. callback *string
  37399. account *string
  37400. cc *string
  37401. phone *string
  37402. cc_phone *string
  37403. phone_name *string
  37404. phone_status *int8
  37405. addphone_status *int8
  37406. organization_id *uint64
  37407. addorganization_id *int64
  37408. api_base *string
  37409. api_key *string
  37410. allow_list *[]string
  37411. appendallow_list []string
  37412. group_allow_list *[]string
  37413. appendgroup_allow_list []string
  37414. block_list *[]string
  37415. appendblock_list []string
  37416. group_block_list *[]string
  37417. appendgroup_block_list []string
  37418. clearedFields map[string]struct{}
  37419. agent *uint64
  37420. clearedagent bool
  37421. done bool
  37422. oldValue func(context.Context) (*Whatsapp, error)
  37423. predicates []predicate.Whatsapp
  37424. }
  37425. var _ ent.Mutation = (*WhatsappMutation)(nil)
  37426. // whatsappOption allows management of the mutation configuration using functional options.
  37427. type whatsappOption func(*WhatsappMutation)
  37428. // newWhatsappMutation creates new mutation for the Whatsapp entity.
  37429. func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
  37430. m := &WhatsappMutation{
  37431. config: c,
  37432. op: op,
  37433. typ: TypeWhatsapp,
  37434. clearedFields: make(map[string]struct{}),
  37435. }
  37436. for _, opt := range opts {
  37437. opt(m)
  37438. }
  37439. return m
  37440. }
  37441. // withWhatsappID sets the ID field of the mutation.
  37442. func withWhatsappID(id uint64) whatsappOption {
  37443. return func(m *WhatsappMutation) {
  37444. var (
  37445. err error
  37446. once sync.Once
  37447. value *Whatsapp
  37448. )
  37449. m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
  37450. once.Do(func() {
  37451. if m.done {
  37452. err = errors.New("querying old values post mutation is not allowed")
  37453. } else {
  37454. value, err = m.Client().Whatsapp.Get(ctx, id)
  37455. }
  37456. })
  37457. return value, err
  37458. }
  37459. m.id = &id
  37460. }
  37461. }
  37462. // withWhatsapp sets the old Whatsapp of the mutation.
  37463. func withWhatsapp(node *Whatsapp) whatsappOption {
  37464. return func(m *WhatsappMutation) {
  37465. m.oldValue = func(context.Context) (*Whatsapp, error) {
  37466. return node, nil
  37467. }
  37468. m.id = &node.ID
  37469. }
  37470. }
  37471. // Client returns a new `ent.Client` from the mutation. If the mutation was
  37472. // executed in a transaction (ent.Tx), a transactional client is returned.
  37473. func (m WhatsappMutation) Client() *Client {
  37474. client := &Client{config: m.config}
  37475. client.init()
  37476. return client
  37477. }
  37478. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  37479. // it returns an error otherwise.
  37480. func (m WhatsappMutation) Tx() (*Tx, error) {
  37481. if _, ok := m.driver.(*txDriver); !ok {
  37482. return nil, errors.New("ent: mutation is not running in a transaction")
  37483. }
  37484. tx := &Tx{config: m.config}
  37485. tx.init()
  37486. return tx, nil
  37487. }
  37488. // SetID sets the value of the id field. Note that this
  37489. // operation is only accepted on creation of Whatsapp entities.
  37490. func (m *WhatsappMutation) SetID(id uint64) {
  37491. m.id = &id
  37492. }
  37493. // ID returns the ID value in the mutation. Note that the ID is only available
  37494. // if it was provided to the builder or after it was returned from the database.
  37495. func (m *WhatsappMutation) ID() (id uint64, exists bool) {
  37496. if m.id == nil {
  37497. return
  37498. }
  37499. return *m.id, true
  37500. }
  37501. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  37502. // That means, if the mutation is applied within a transaction with an isolation level such
  37503. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  37504. // or updated by the mutation.
  37505. func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
  37506. switch {
  37507. case m.op.Is(OpUpdateOne | OpDeleteOne):
  37508. id, exists := m.ID()
  37509. if exists {
  37510. return []uint64{id}, nil
  37511. }
  37512. fallthrough
  37513. case m.op.Is(OpUpdate | OpDelete):
  37514. return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
  37515. default:
  37516. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  37517. }
  37518. }
  37519. // SetCreatedAt sets the "created_at" field.
  37520. func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
  37521. m.created_at = &t
  37522. }
  37523. // CreatedAt returns the value of the "created_at" field in the mutation.
  37524. func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
  37525. v := m.created_at
  37526. if v == nil {
  37527. return
  37528. }
  37529. return *v, true
  37530. }
  37531. // OldCreatedAt returns the old "created_at" field's value of the Whatsapp entity.
  37532. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37533. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37534. func (m *WhatsappMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  37535. if !m.op.Is(OpUpdateOne) {
  37536. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  37537. }
  37538. if m.id == nil || m.oldValue == nil {
  37539. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  37540. }
  37541. oldValue, err := m.oldValue(ctx)
  37542. if err != nil {
  37543. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  37544. }
  37545. return oldValue.CreatedAt, nil
  37546. }
  37547. // ResetCreatedAt resets all changes to the "created_at" field.
  37548. func (m *WhatsappMutation) ResetCreatedAt() {
  37549. m.created_at = nil
  37550. }
  37551. // SetUpdatedAt sets the "updated_at" field.
  37552. func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
  37553. m.updated_at = &t
  37554. }
  37555. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  37556. func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
  37557. v := m.updated_at
  37558. if v == nil {
  37559. return
  37560. }
  37561. return *v, true
  37562. }
  37563. // OldUpdatedAt returns the old "updated_at" field's value of the Whatsapp entity.
  37564. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37565. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37566. func (m *WhatsappMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  37567. if !m.op.Is(OpUpdateOne) {
  37568. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  37569. }
  37570. if m.id == nil || m.oldValue == nil {
  37571. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  37572. }
  37573. oldValue, err := m.oldValue(ctx)
  37574. if err != nil {
  37575. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  37576. }
  37577. return oldValue.UpdatedAt, nil
  37578. }
  37579. // ResetUpdatedAt resets all changes to the "updated_at" field.
  37580. func (m *WhatsappMutation) ResetUpdatedAt() {
  37581. m.updated_at = nil
  37582. }
  37583. // SetStatus sets the "status" field.
  37584. func (m *WhatsappMutation) SetStatus(u uint8) {
  37585. m.status = &u
  37586. m.addstatus = nil
  37587. }
  37588. // Status returns the value of the "status" field in the mutation.
  37589. func (m *WhatsappMutation) Status() (r uint8, exists bool) {
  37590. v := m.status
  37591. if v == nil {
  37592. return
  37593. }
  37594. return *v, true
  37595. }
  37596. // OldStatus returns the old "status" field's value of the Whatsapp entity.
  37597. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37598. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37599. func (m *WhatsappMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  37600. if !m.op.Is(OpUpdateOne) {
  37601. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  37602. }
  37603. if m.id == nil || m.oldValue == nil {
  37604. return v, errors.New("OldStatus requires an ID field in the mutation")
  37605. }
  37606. oldValue, err := m.oldValue(ctx)
  37607. if err != nil {
  37608. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  37609. }
  37610. return oldValue.Status, nil
  37611. }
  37612. // AddStatus adds u to the "status" field.
  37613. func (m *WhatsappMutation) AddStatus(u int8) {
  37614. if m.addstatus != nil {
  37615. *m.addstatus += u
  37616. } else {
  37617. m.addstatus = &u
  37618. }
  37619. }
  37620. // AddedStatus returns the value that was added to the "status" field in this mutation.
  37621. func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
  37622. v := m.addstatus
  37623. if v == nil {
  37624. return
  37625. }
  37626. return *v, true
  37627. }
  37628. // ClearStatus clears the value of the "status" field.
  37629. func (m *WhatsappMutation) ClearStatus() {
  37630. m.status = nil
  37631. m.addstatus = nil
  37632. m.clearedFields[whatsapp.FieldStatus] = struct{}{}
  37633. }
  37634. // StatusCleared returns if the "status" field was cleared in this mutation.
  37635. func (m *WhatsappMutation) StatusCleared() bool {
  37636. _, ok := m.clearedFields[whatsapp.FieldStatus]
  37637. return ok
  37638. }
  37639. // ResetStatus resets all changes to the "status" field.
  37640. func (m *WhatsappMutation) ResetStatus() {
  37641. m.status = nil
  37642. m.addstatus = nil
  37643. delete(m.clearedFields, whatsapp.FieldStatus)
  37644. }
  37645. // SetDeletedAt sets the "deleted_at" field.
  37646. func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
  37647. m.deleted_at = &t
  37648. }
  37649. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  37650. func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
  37651. v := m.deleted_at
  37652. if v == nil {
  37653. return
  37654. }
  37655. return *v, true
  37656. }
  37657. // OldDeletedAt returns the old "deleted_at" field's value of the Whatsapp entity.
  37658. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37659. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37660. func (m *WhatsappMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  37661. if !m.op.Is(OpUpdateOne) {
  37662. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  37663. }
  37664. if m.id == nil || m.oldValue == nil {
  37665. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  37666. }
  37667. oldValue, err := m.oldValue(ctx)
  37668. if err != nil {
  37669. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  37670. }
  37671. return oldValue.DeletedAt, nil
  37672. }
  37673. // ClearDeletedAt clears the value of the "deleted_at" field.
  37674. func (m *WhatsappMutation) ClearDeletedAt() {
  37675. m.deleted_at = nil
  37676. m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
  37677. }
  37678. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  37679. func (m *WhatsappMutation) DeletedAtCleared() bool {
  37680. _, ok := m.clearedFields[whatsapp.FieldDeletedAt]
  37681. return ok
  37682. }
  37683. // ResetDeletedAt resets all changes to the "deleted_at" field.
  37684. func (m *WhatsappMutation) ResetDeletedAt() {
  37685. m.deleted_at = nil
  37686. delete(m.clearedFields, whatsapp.FieldDeletedAt)
  37687. }
  37688. // SetWaID sets the "wa_id" field.
  37689. func (m *WhatsappMutation) SetWaID(s string) {
  37690. m.wa_id = &s
  37691. }
  37692. // WaID returns the value of the "wa_id" field in the mutation.
  37693. func (m *WhatsappMutation) WaID() (r string, exists bool) {
  37694. v := m.wa_id
  37695. if v == nil {
  37696. return
  37697. }
  37698. return *v, true
  37699. }
  37700. // OldWaID returns the old "wa_id" field's value of the Whatsapp entity.
  37701. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37702. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37703. func (m *WhatsappMutation) OldWaID(ctx context.Context) (v string, err error) {
  37704. if !m.op.Is(OpUpdateOne) {
  37705. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  37706. }
  37707. if m.id == nil || m.oldValue == nil {
  37708. return v, errors.New("OldWaID requires an ID field in the mutation")
  37709. }
  37710. oldValue, err := m.oldValue(ctx)
  37711. if err != nil {
  37712. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  37713. }
  37714. return oldValue.WaID, nil
  37715. }
  37716. // ClearWaID clears the value of the "wa_id" field.
  37717. func (m *WhatsappMutation) ClearWaID() {
  37718. m.wa_id = nil
  37719. m.clearedFields[whatsapp.FieldWaID] = struct{}{}
  37720. }
  37721. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  37722. func (m *WhatsappMutation) WaIDCleared() bool {
  37723. _, ok := m.clearedFields[whatsapp.FieldWaID]
  37724. return ok
  37725. }
  37726. // ResetWaID resets all changes to the "wa_id" field.
  37727. func (m *WhatsappMutation) ResetWaID() {
  37728. m.wa_id = nil
  37729. delete(m.clearedFields, whatsapp.FieldWaID)
  37730. }
  37731. // SetWaName sets the "wa_name" field.
  37732. func (m *WhatsappMutation) SetWaName(s string) {
  37733. m.wa_name = &s
  37734. }
  37735. // WaName returns the value of the "wa_name" field in the mutation.
  37736. func (m *WhatsappMutation) WaName() (r string, exists bool) {
  37737. v := m.wa_name
  37738. if v == nil {
  37739. return
  37740. }
  37741. return *v, true
  37742. }
  37743. // OldWaName returns the old "wa_name" field's value of the Whatsapp entity.
  37744. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37745. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37746. func (m *WhatsappMutation) OldWaName(ctx context.Context) (v string, err error) {
  37747. if !m.op.Is(OpUpdateOne) {
  37748. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  37749. }
  37750. if m.id == nil || m.oldValue == nil {
  37751. return v, errors.New("OldWaName requires an ID field in the mutation")
  37752. }
  37753. oldValue, err := m.oldValue(ctx)
  37754. if err != nil {
  37755. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  37756. }
  37757. return oldValue.WaName, nil
  37758. }
  37759. // ClearWaName clears the value of the "wa_name" field.
  37760. func (m *WhatsappMutation) ClearWaName() {
  37761. m.wa_name = nil
  37762. m.clearedFields[whatsapp.FieldWaName] = struct{}{}
  37763. }
  37764. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  37765. func (m *WhatsappMutation) WaNameCleared() bool {
  37766. _, ok := m.clearedFields[whatsapp.FieldWaName]
  37767. return ok
  37768. }
  37769. // ResetWaName resets all changes to the "wa_name" field.
  37770. func (m *WhatsappMutation) ResetWaName() {
  37771. m.wa_name = nil
  37772. delete(m.clearedFields, whatsapp.FieldWaName)
  37773. }
  37774. // SetCallback sets the "callback" field.
  37775. func (m *WhatsappMutation) SetCallback(s string) {
  37776. m.callback = &s
  37777. }
  37778. // Callback returns the value of the "callback" field in the mutation.
  37779. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  37780. v := m.callback
  37781. if v == nil {
  37782. return
  37783. }
  37784. return *v, true
  37785. }
  37786. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  37787. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37788. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37789. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  37790. if !m.op.Is(OpUpdateOne) {
  37791. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  37792. }
  37793. if m.id == nil || m.oldValue == nil {
  37794. return v, errors.New("OldCallback requires an ID field in the mutation")
  37795. }
  37796. oldValue, err := m.oldValue(ctx)
  37797. if err != nil {
  37798. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  37799. }
  37800. return oldValue.Callback, nil
  37801. }
  37802. // ClearCallback clears the value of the "callback" field.
  37803. func (m *WhatsappMutation) ClearCallback() {
  37804. m.callback = nil
  37805. m.clearedFields[whatsapp.FieldCallback] = struct{}{}
  37806. }
  37807. // CallbackCleared returns if the "callback" field was cleared in this mutation.
  37808. func (m *WhatsappMutation) CallbackCleared() bool {
  37809. _, ok := m.clearedFields[whatsapp.FieldCallback]
  37810. return ok
  37811. }
  37812. // ResetCallback resets all changes to the "callback" field.
  37813. func (m *WhatsappMutation) ResetCallback() {
  37814. m.callback = nil
  37815. delete(m.clearedFields, whatsapp.FieldCallback)
  37816. }
  37817. // SetAgentID sets the "agent_id" field.
  37818. func (m *WhatsappMutation) SetAgentID(u uint64) {
  37819. m.agent = &u
  37820. }
  37821. // AgentID returns the value of the "agent_id" field in the mutation.
  37822. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  37823. v := m.agent
  37824. if v == nil {
  37825. return
  37826. }
  37827. return *v, true
  37828. }
  37829. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  37830. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37831. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37832. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  37833. if !m.op.Is(OpUpdateOne) {
  37834. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  37835. }
  37836. if m.id == nil || m.oldValue == nil {
  37837. return v, errors.New("OldAgentID requires an ID field in the mutation")
  37838. }
  37839. oldValue, err := m.oldValue(ctx)
  37840. if err != nil {
  37841. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  37842. }
  37843. return oldValue.AgentID, nil
  37844. }
  37845. // ResetAgentID resets all changes to the "agent_id" field.
  37846. func (m *WhatsappMutation) ResetAgentID() {
  37847. m.agent = nil
  37848. }
  37849. // SetAccount sets the "account" field.
  37850. func (m *WhatsappMutation) SetAccount(s string) {
  37851. m.account = &s
  37852. }
  37853. // Account returns the value of the "account" field in the mutation.
  37854. func (m *WhatsappMutation) Account() (r string, exists bool) {
  37855. v := m.account
  37856. if v == nil {
  37857. return
  37858. }
  37859. return *v, true
  37860. }
  37861. // OldAccount returns the old "account" field's value of the Whatsapp entity.
  37862. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37863. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37864. func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error) {
  37865. if !m.op.Is(OpUpdateOne) {
  37866. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  37867. }
  37868. if m.id == nil || m.oldValue == nil {
  37869. return v, errors.New("OldAccount requires an ID field in the mutation")
  37870. }
  37871. oldValue, err := m.oldValue(ctx)
  37872. if err != nil {
  37873. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  37874. }
  37875. return oldValue.Account, nil
  37876. }
  37877. // ClearAccount clears the value of the "account" field.
  37878. func (m *WhatsappMutation) ClearAccount() {
  37879. m.account = nil
  37880. m.clearedFields[whatsapp.FieldAccount] = struct{}{}
  37881. }
  37882. // AccountCleared returns if the "account" field was cleared in this mutation.
  37883. func (m *WhatsappMutation) AccountCleared() bool {
  37884. _, ok := m.clearedFields[whatsapp.FieldAccount]
  37885. return ok
  37886. }
  37887. // ResetAccount resets all changes to the "account" field.
  37888. func (m *WhatsappMutation) ResetAccount() {
  37889. m.account = nil
  37890. delete(m.clearedFields, whatsapp.FieldAccount)
  37891. }
  37892. // SetCc sets the "cc" field.
  37893. func (m *WhatsappMutation) SetCc(s string) {
  37894. m.cc = &s
  37895. }
  37896. // Cc returns the value of the "cc" field in the mutation.
  37897. func (m *WhatsappMutation) Cc() (r string, exists bool) {
  37898. v := m.cc
  37899. if v == nil {
  37900. return
  37901. }
  37902. return *v, true
  37903. }
  37904. // OldCc returns the old "cc" field's value of the Whatsapp entity.
  37905. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37907. func (m *WhatsappMutation) OldCc(ctx context.Context) (v string, err error) {
  37908. if !m.op.Is(OpUpdateOne) {
  37909. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  37910. }
  37911. if m.id == nil || m.oldValue == nil {
  37912. return v, errors.New("OldCc requires an ID field in the mutation")
  37913. }
  37914. oldValue, err := m.oldValue(ctx)
  37915. if err != nil {
  37916. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  37917. }
  37918. return oldValue.Cc, nil
  37919. }
  37920. // ResetCc resets all changes to the "cc" field.
  37921. func (m *WhatsappMutation) ResetCc() {
  37922. m.cc = nil
  37923. }
  37924. // SetPhone sets the "phone" field.
  37925. func (m *WhatsappMutation) SetPhone(s string) {
  37926. m.phone = &s
  37927. }
  37928. // Phone returns the value of the "phone" field in the mutation.
  37929. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  37930. v := m.phone
  37931. if v == nil {
  37932. return
  37933. }
  37934. return *v, true
  37935. }
  37936. // OldPhone returns the old "phone" field's value of the Whatsapp entity.
  37937. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37938. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37939. func (m *WhatsappMutation) OldPhone(ctx context.Context) (v string, err error) {
  37940. if !m.op.Is(OpUpdateOne) {
  37941. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  37942. }
  37943. if m.id == nil || m.oldValue == nil {
  37944. return v, errors.New("OldPhone requires an ID field in the mutation")
  37945. }
  37946. oldValue, err := m.oldValue(ctx)
  37947. if err != nil {
  37948. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  37949. }
  37950. return oldValue.Phone, nil
  37951. }
  37952. // ResetPhone resets all changes to the "phone" field.
  37953. func (m *WhatsappMutation) ResetPhone() {
  37954. m.phone = nil
  37955. }
  37956. // SetCcPhone sets the "cc_phone" field.
  37957. func (m *WhatsappMutation) SetCcPhone(s string) {
  37958. m.cc_phone = &s
  37959. }
  37960. // CcPhone returns the value of the "cc_phone" field in the mutation.
  37961. func (m *WhatsappMutation) CcPhone() (r string, exists bool) {
  37962. v := m.cc_phone
  37963. if v == nil {
  37964. return
  37965. }
  37966. return *v, true
  37967. }
  37968. // OldCcPhone returns the old "cc_phone" field's value of the Whatsapp entity.
  37969. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37970. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37971. func (m *WhatsappMutation) OldCcPhone(ctx context.Context) (v string, err error) {
  37972. if !m.op.Is(OpUpdateOne) {
  37973. return v, errors.New("OldCcPhone is only allowed on UpdateOne operations")
  37974. }
  37975. if m.id == nil || m.oldValue == nil {
  37976. return v, errors.New("OldCcPhone requires an ID field in the mutation")
  37977. }
  37978. oldValue, err := m.oldValue(ctx)
  37979. if err != nil {
  37980. return v, fmt.Errorf("querying old value for OldCcPhone: %w", err)
  37981. }
  37982. return oldValue.CcPhone, nil
  37983. }
  37984. // ResetCcPhone resets all changes to the "cc_phone" field.
  37985. func (m *WhatsappMutation) ResetCcPhone() {
  37986. m.cc_phone = nil
  37987. }
  37988. // SetPhoneName sets the "phone_name" field.
  37989. func (m *WhatsappMutation) SetPhoneName(s string) {
  37990. m.phone_name = &s
  37991. }
  37992. // PhoneName returns the value of the "phone_name" field in the mutation.
  37993. func (m *WhatsappMutation) PhoneName() (r string, exists bool) {
  37994. v := m.phone_name
  37995. if v == nil {
  37996. return
  37997. }
  37998. return *v, true
  37999. }
  38000. // OldPhoneName returns the old "phone_name" field's value of the Whatsapp entity.
  38001. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38002. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38003. func (m *WhatsappMutation) OldPhoneName(ctx context.Context) (v string, err error) {
  38004. if !m.op.Is(OpUpdateOne) {
  38005. return v, errors.New("OldPhoneName is only allowed on UpdateOne operations")
  38006. }
  38007. if m.id == nil || m.oldValue == nil {
  38008. return v, errors.New("OldPhoneName requires an ID field in the mutation")
  38009. }
  38010. oldValue, err := m.oldValue(ctx)
  38011. if err != nil {
  38012. return v, fmt.Errorf("querying old value for OldPhoneName: %w", err)
  38013. }
  38014. return oldValue.PhoneName, nil
  38015. }
  38016. // ResetPhoneName resets all changes to the "phone_name" field.
  38017. func (m *WhatsappMutation) ResetPhoneName() {
  38018. m.phone_name = nil
  38019. }
  38020. // SetPhoneStatus sets the "phone_status" field.
  38021. func (m *WhatsappMutation) SetPhoneStatus(i int8) {
  38022. m.phone_status = &i
  38023. m.addphone_status = nil
  38024. }
  38025. // PhoneStatus returns the value of the "phone_status" field in the mutation.
  38026. func (m *WhatsappMutation) PhoneStatus() (r int8, exists bool) {
  38027. v := m.phone_status
  38028. if v == nil {
  38029. return
  38030. }
  38031. return *v, true
  38032. }
  38033. // OldPhoneStatus returns the old "phone_status" field's value of the Whatsapp entity.
  38034. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38035. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38036. func (m *WhatsappMutation) OldPhoneStatus(ctx context.Context) (v int8, err error) {
  38037. if !m.op.Is(OpUpdateOne) {
  38038. return v, errors.New("OldPhoneStatus is only allowed on UpdateOne operations")
  38039. }
  38040. if m.id == nil || m.oldValue == nil {
  38041. return v, errors.New("OldPhoneStatus requires an ID field in the mutation")
  38042. }
  38043. oldValue, err := m.oldValue(ctx)
  38044. if err != nil {
  38045. return v, fmt.Errorf("querying old value for OldPhoneStatus: %w", err)
  38046. }
  38047. return oldValue.PhoneStatus, nil
  38048. }
  38049. // AddPhoneStatus adds i to the "phone_status" field.
  38050. func (m *WhatsappMutation) AddPhoneStatus(i int8) {
  38051. if m.addphone_status != nil {
  38052. *m.addphone_status += i
  38053. } else {
  38054. m.addphone_status = &i
  38055. }
  38056. }
  38057. // AddedPhoneStatus returns the value that was added to the "phone_status" field in this mutation.
  38058. func (m *WhatsappMutation) AddedPhoneStatus() (r int8, exists bool) {
  38059. v := m.addphone_status
  38060. if v == nil {
  38061. return
  38062. }
  38063. return *v, true
  38064. }
  38065. // ResetPhoneStatus resets all changes to the "phone_status" field.
  38066. func (m *WhatsappMutation) ResetPhoneStatus() {
  38067. m.phone_status = nil
  38068. m.addphone_status = nil
  38069. }
  38070. // SetOrganizationID sets the "organization_id" field.
  38071. func (m *WhatsappMutation) SetOrganizationID(u uint64) {
  38072. m.organization_id = &u
  38073. m.addorganization_id = nil
  38074. }
  38075. // OrganizationID returns the value of the "organization_id" field in the mutation.
  38076. func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
  38077. v := m.organization_id
  38078. if v == nil {
  38079. return
  38080. }
  38081. return *v, true
  38082. }
  38083. // OldOrganizationID returns the old "organization_id" field's value of the Whatsapp entity.
  38084. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38085. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38086. func (m *WhatsappMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  38087. if !m.op.Is(OpUpdateOne) {
  38088. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  38089. }
  38090. if m.id == nil || m.oldValue == nil {
  38091. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  38092. }
  38093. oldValue, err := m.oldValue(ctx)
  38094. if err != nil {
  38095. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  38096. }
  38097. return oldValue.OrganizationID, nil
  38098. }
  38099. // AddOrganizationID adds u to the "organization_id" field.
  38100. func (m *WhatsappMutation) AddOrganizationID(u int64) {
  38101. if m.addorganization_id != nil {
  38102. *m.addorganization_id += u
  38103. } else {
  38104. m.addorganization_id = &u
  38105. }
  38106. }
  38107. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  38108. func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
  38109. v := m.addorganization_id
  38110. if v == nil {
  38111. return
  38112. }
  38113. return *v, true
  38114. }
  38115. // ClearOrganizationID clears the value of the "organization_id" field.
  38116. func (m *WhatsappMutation) ClearOrganizationID() {
  38117. m.organization_id = nil
  38118. m.addorganization_id = nil
  38119. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  38120. }
  38121. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  38122. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  38123. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  38124. return ok
  38125. }
  38126. // ResetOrganizationID resets all changes to the "organization_id" field.
  38127. func (m *WhatsappMutation) ResetOrganizationID() {
  38128. m.organization_id = nil
  38129. m.addorganization_id = nil
  38130. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  38131. }
  38132. // SetAPIBase sets the "api_base" field.
  38133. func (m *WhatsappMutation) SetAPIBase(s string) {
  38134. m.api_base = &s
  38135. }
  38136. // APIBase returns the value of the "api_base" field in the mutation.
  38137. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  38138. v := m.api_base
  38139. if v == nil {
  38140. return
  38141. }
  38142. return *v, true
  38143. }
  38144. // OldAPIBase returns the old "api_base" field's value of the Whatsapp entity.
  38145. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38146. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38147. func (m *WhatsappMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  38148. if !m.op.Is(OpUpdateOne) {
  38149. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  38150. }
  38151. if m.id == nil || m.oldValue == nil {
  38152. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  38153. }
  38154. oldValue, err := m.oldValue(ctx)
  38155. if err != nil {
  38156. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  38157. }
  38158. return oldValue.APIBase, nil
  38159. }
  38160. // ClearAPIBase clears the value of the "api_base" field.
  38161. func (m *WhatsappMutation) ClearAPIBase() {
  38162. m.api_base = nil
  38163. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  38164. }
  38165. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  38166. func (m *WhatsappMutation) APIBaseCleared() bool {
  38167. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  38168. return ok
  38169. }
  38170. // ResetAPIBase resets all changes to the "api_base" field.
  38171. func (m *WhatsappMutation) ResetAPIBase() {
  38172. m.api_base = nil
  38173. delete(m.clearedFields, whatsapp.FieldAPIBase)
  38174. }
  38175. // SetAPIKey sets the "api_key" field.
  38176. func (m *WhatsappMutation) SetAPIKey(s string) {
  38177. m.api_key = &s
  38178. }
  38179. // APIKey returns the value of the "api_key" field in the mutation.
  38180. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  38181. v := m.api_key
  38182. if v == nil {
  38183. return
  38184. }
  38185. return *v, true
  38186. }
  38187. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  38188. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38189. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38190. func (m *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  38191. if !m.op.Is(OpUpdateOne) {
  38192. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  38193. }
  38194. if m.id == nil || m.oldValue == nil {
  38195. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  38196. }
  38197. oldValue, err := m.oldValue(ctx)
  38198. if err != nil {
  38199. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  38200. }
  38201. return oldValue.APIKey, nil
  38202. }
  38203. // ClearAPIKey clears the value of the "api_key" field.
  38204. func (m *WhatsappMutation) ClearAPIKey() {
  38205. m.api_key = nil
  38206. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  38207. }
  38208. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  38209. func (m *WhatsappMutation) APIKeyCleared() bool {
  38210. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  38211. return ok
  38212. }
  38213. // ResetAPIKey resets all changes to the "api_key" field.
  38214. func (m *WhatsappMutation) ResetAPIKey() {
  38215. m.api_key = nil
  38216. delete(m.clearedFields, whatsapp.FieldAPIKey)
  38217. }
  38218. // SetAllowList sets the "allow_list" field.
  38219. func (m *WhatsappMutation) SetAllowList(s []string) {
  38220. m.allow_list = &s
  38221. m.appendallow_list = nil
  38222. }
  38223. // AllowList returns the value of the "allow_list" field in the mutation.
  38224. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  38225. v := m.allow_list
  38226. if v == nil {
  38227. return
  38228. }
  38229. return *v, true
  38230. }
  38231. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  38232. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38233. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38234. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  38235. if !m.op.Is(OpUpdateOne) {
  38236. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  38237. }
  38238. if m.id == nil || m.oldValue == nil {
  38239. return v, errors.New("OldAllowList requires an ID field in the mutation")
  38240. }
  38241. oldValue, err := m.oldValue(ctx)
  38242. if err != nil {
  38243. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  38244. }
  38245. return oldValue.AllowList, nil
  38246. }
  38247. // AppendAllowList adds s to the "allow_list" field.
  38248. func (m *WhatsappMutation) AppendAllowList(s []string) {
  38249. m.appendallow_list = append(m.appendallow_list, s...)
  38250. }
  38251. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  38252. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  38253. if len(m.appendallow_list) == 0 {
  38254. return nil, false
  38255. }
  38256. return m.appendallow_list, true
  38257. }
  38258. // ClearAllowList clears the value of the "allow_list" field.
  38259. func (m *WhatsappMutation) ClearAllowList() {
  38260. m.allow_list = nil
  38261. m.appendallow_list = nil
  38262. m.clearedFields[whatsapp.FieldAllowList] = struct{}{}
  38263. }
  38264. // AllowListCleared returns if the "allow_list" field was cleared in this mutation.
  38265. func (m *WhatsappMutation) AllowListCleared() bool {
  38266. _, ok := m.clearedFields[whatsapp.FieldAllowList]
  38267. return ok
  38268. }
  38269. // ResetAllowList resets all changes to the "allow_list" field.
  38270. func (m *WhatsappMutation) ResetAllowList() {
  38271. m.allow_list = nil
  38272. m.appendallow_list = nil
  38273. delete(m.clearedFields, whatsapp.FieldAllowList)
  38274. }
  38275. // SetGroupAllowList sets the "group_allow_list" field.
  38276. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  38277. m.group_allow_list = &s
  38278. m.appendgroup_allow_list = nil
  38279. }
  38280. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  38281. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  38282. v := m.group_allow_list
  38283. if v == nil {
  38284. return
  38285. }
  38286. return *v, true
  38287. }
  38288. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  38289. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38290. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38291. func (m *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  38292. if !m.op.Is(OpUpdateOne) {
  38293. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  38294. }
  38295. if m.id == nil || m.oldValue == nil {
  38296. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  38297. }
  38298. oldValue, err := m.oldValue(ctx)
  38299. if err != nil {
  38300. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  38301. }
  38302. return oldValue.GroupAllowList, nil
  38303. }
  38304. // AppendGroupAllowList adds s to the "group_allow_list" field.
  38305. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  38306. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  38307. }
  38308. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  38309. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  38310. if len(m.appendgroup_allow_list) == 0 {
  38311. return nil, false
  38312. }
  38313. return m.appendgroup_allow_list, true
  38314. }
  38315. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  38316. func (m *WhatsappMutation) ClearGroupAllowList() {
  38317. m.group_allow_list = nil
  38318. m.appendgroup_allow_list = nil
  38319. m.clearedFields[whatsapp.FieldGroupAllowList] = struct{}{}
  38320. }
  38321. // GroupAllowListCleared returns if the "group_allow_list" field was cleared in this mutation.
  38322. func (m *WhatsappMutation) GroupAllowListCleared() bool {
  38323. _, ok := m.clearedFields[whatsapp.FieldGroupAllowList]
  38324. return ok
  38325. }
  38326. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  38327. func (m *WhatsappMutation) ResetGroupAllowList() {
  38328. m.group_allow_list = nil
  38329. m.appendgroup_allow_list = nil
  38330. delete(m.clearedFields, whatsapp.FieldGroupAllowList)
  38331. }
  38332. // SetBlockList sets the "block_list" field.
  38333. func (m *WhatsappMutation) SetBlockList(s []string) {
  38334. m.block_list = &s
  38335. m.appendblock_list = nil
  38336. }
  38337. // BlockList returns the value of the "block_list" field in the mutation.
  38338. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  38339. v := m.block_list
  38340. if v == nil {
  38341. return
  38342. }
  38343. return *v, true
  38344. }
  38345. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  38346. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38347. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38348. func (m *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  38349. if !m.op.Is(OpUpdateOne) {
  38350. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  38351. }
  38352. if m.id == nil || m.oldValue == nil {
  38353. return v, errors.New("OldBlockList requires an ID field in the mutation")
  38354. }
  38355. oldValue, err := m.oldValue(ctx)
  38356. if err != nil {
  38357. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  38358. }
  38359. return oldValue.BlockList, nil
  38360. }
  38361. // AppendBlockList adds s to the "block_list" field.
  38362. func (m *WhatsappMutation) AppendBlockList(s []string) {
  38363. m.appendblock_list = append(m.appendblock_list, s...)
  38364. }
  38365. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  38366. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  38367. if len(m.appendblock_list) == 0 {
  38368. return nil, false
  38369. }
  38370. return m.appendblock_list, true
  38371. }
  38372. // ClearBlockList clears the value of the "block_list" field.
  38373. func (m *WhatsappMutation) ClearBlockList() {
  38374. m.block_list = nil
  38375. m.appendblock_list = nil
  38376. m.clearedFields[whatsapp.FieldBlockList] = struct{}{}
  38377. }
  38378. // BlockListCleared returns if the "block_list" field was cleared in this mutation.
  38379. func (m *WhatsappMutation) BlockListCleared() bool {
  38380. _, ok := m.clearedFields[whatsapp.FieldBlockList]
  38381. return ok
  38382. }
  38383. // ResetBlockList resets all changes to the "block_list" field.
  38384. func (m *WhatsappMutation) ResetBlockList() {
  38385. m.block_list = nil
  38386. m.appendblock_list = nil
  38387. delete(m.clearedFields, whatsapp.FieldBlockList)
  38388. }
  38389. // SetGroupBlockList sets the "group_block_list" field.
  38390. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  38391. m.group_block_list = &s
  38392. m.appendgroup_block_list = nil
  38393. }
  38394. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  38395. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  38396. v := m.group_block_list
  38397. if v == nil {
  38398. return
  38399. }
  38400. return *v, true
  38401. }
  38402. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  38403. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38404. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38405. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  38406. if !m.op.Is(OpUpdateOne) {
  38407. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  38408. }
  38409. if m.id == nil || m.oldValue == nil {
  38410. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  38411. }
  38412. oldValue, err := m.oldValue(ctx)
  38413. if err != nil {
  38414. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  38415. }
  38416. return oldValue.GroupBlockList, nil
  38417. }
  38418. // AppendGroupBlockList adds s to the "group_block_list" field.
  38419. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  38420. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  38421. }
  38422. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  38423. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  38424. if len(m.appendgroup_block_list) == 0 {
  38425. return nil, false
  38426. }
  38427. return m.appendgroup_block_list, true
  38428. }
  38429. // ClearGroupBlockList clears the value of the "group_block_list" field.
  38430. func (m *WhatsappMutation) ClearGroupBlockList() {
  38431. m.group_block_list = nil
  38432. m.appendgroup_block_list = nil
  38433. m.clearedFields[whatsapp.FieldGroupBlockList] = struct{}{}
  38434. }
  38435. // GroupBlockListCleared returns if the "group_block_list" field was cleared in this mutation.
  38436. func (m *WhatsappMutation) GroupBlockListCleared() bool {
  38437. _, ok := m.clearedFields[whatsapp.FieldGroupBlockList]
  38438. return ok
  38439. }
  38440. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  38441. func (m *WhatsappMutation) ResetGroupBlockList() {
  38442. m.group_block_list = nil
  38443. m.appendgroup_block_list = nil
  38444. delete(m.clearedFields, whatsapp.FieldGroupBlockList)
  38445. }
  38446. // ClearAgent clears the "agent" edge to the Agent entity.
  38447. func (m *WhatsappMutation) ClearAgent() {
  38448. m.clearedagent = true
  38449. m.clearedFields[whatsapp.FieldAgentID] = struct{}{}
  38450. }
  38451. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  38452. func (m *WhatsappMutation) AgentCleared() bool {
  38453. return m.clearedagent
  38454. }
  38455. // AgentIDs returns the "agent" edge IDs in the mutation.
  38456. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  38457. // AgentID instead. It exists only for internal usage by the builders.
  38458. func (m *WhatsappMutation) AgentIDs() (ids []uint64) {
  38459. if id := m.agent; id != nil {
  38460. ids = append(ids, *id)
  38461. }
  38462. return
  38463. }
  38464. // ResetAgent resets all changes to the "agent" edge.
  38465. func (m *WhatsappMutation) ResetAgent() {
  38466. m.agent = nil
  38467. m.clearedagent = false
  38468. }
  38469. // Where appends a list predicates to the WhatsappMutation builder.
  38470. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  38471. m.predicates = append(m.predicates, ps...)
  38472. }
  38473. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  38474. // users can use type-assertion to append predicates that do not depend on any generated package.
  38475. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  38476. p := make([]predicate.Whatsapp, len(ps))
  38477. for i := range ps {
  38478. p[i] = ps[i]
  38479. }
  38480. m.Where(p...)
  38481. }
  38482. // Op returns the operation name.
  38483. func (m *WhatsappMutation) Op() Op {
  38484. return m.op
  38485. }
  38486. // SetOp allows setting the mutation operation.
  38487. func (m *WhatsappMutation) SetOp(op Op) {
  38488. m.op = op
  38489. }
  38490. // Type returns the node type of this mutation (Whatsapp).
  38491. func (m *WhatsappMutation) Type() string {
  38492. return m.typ
  38493. }
  38494. // Fields returns all fields that were changed during this mutation. Note that in
  38495. // order to get all numeric fields that were incremented/decremented, call
  38496. // AddedFields().
  38497. func (m *WhatsappMutation) Fields() []string {
  38498. fields := make([]string, 0, 21)
  38499. if m.created_at != nil {
  38500. fields = append(fields, whatsapp.FieldCreatedAt)
  38501. }
  38502. if m.updated_at != nil {
  38503. fields = append(fields, whatsapp.FieldUpdatedAt)
  38504. }
  38505. if m.status != nil {
  38506. fields = append(fields, whatsapp.FieldStatus)
  38507. }
  38508. if m.deleted_at != nil {
  38509. fields = append(fields, whatsapp.FieldDeletedAt)
  38510. }
  38511. if m.wa_id != nil {
  38512. fields = append(fields, whatsapp.FieldWaID)
  38513. }
  38514. if m.wa_name != nil {
  38515. fields = append(fields, whatsapp.FieldWaName)
  38516. }
  38517. if m.callback != nil {
  38518. fields = append(fields, whatsapp.FieldCallback)
  38519. }
  38520. if m.agent != nil {
  38521. fields = append(fields, whatsapp.FieldAgentID)
  38522. }
  38523. if m.account != nil {
  38524. fields = append(fields, whatsapp.FieldAccount)
  38525. }
  38526. if m.cc != nil {
  38527. fields = append(fields, whatsapp.FieldCc)
  38528. }
  38529. if m.phone != nil {
  38530. fields = append(fields, whatsapp.FieldPhone)
  38531. }
  38532. if m.cc_phone != nil {
  38533. fields = append(fields, whatsapp.FieldCcPhone)
  38534. }
  38535. if m.phone_name != nil {
  38536. fields = append(fields, whatsapp.FieldPhoneName)
  38537. }
  38538. if m.phone_status != nil {
  38539. fields = append(fields, whatsapp.FieldPhoneStatus)
  38540. }
  38541. if m.organization_id != nil {
  38542. fields = append(fields, whatsapp.FieldOrganizationID)
  38543. }
  38544. if m.api_base != nil {
  38545. fields = append(fields, whatsapp.FieldAPIBase)
  38546. }
  38547. if m.api_key != nil {
  38548. fields = append(fields, whatsapp.FieldAPIKey)
  38549. }
  38550. if m.allow_list != nil {
  38551. fields = append(fields, whatsapp.FieldAllowList)
  38552. }
  38553. if m.group_allow_list != nil {
  38554. fields = append(fields, whatsapp.FieldGroupAllowList)
  38555. }
  38556. if m.block_list != nil {
  38557. fields = append(fields, whatsapp.FieldBlockList)
  38558. }
  38559. if m.group_block_list != nil {
  38560. fields = append(fields, whatsapp.FieldGroupBlockList)
  38561. }
  38562. return fields
  38563. }
  38564. // Field returns the value of a field with the given name. The second boolean
  38565. // return value indicates that this field was not set, or was not defined in the
  38566. // schema.
  38567. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  38568. switch name {
  38569. case whatsapp.FieldCreatedAt:
  38570. return m.CreatedAt()
  38571. case whatsapp.FieldUpdatedAt:
  38572. return m.UpdatedAt()
  38573. case whatsapp.FieldStatus:
  38574. return m.Status()
  38575. case whatsapp.FieldDeletedAt:
  38576. return m.DeletedAt()
  38577. case whatsapp.FieldWaID:
  38578. return m.WaID()
  38579. case whatsapp.FieldWaName:
  38580. return m.WaName()
  38581. case whatsapp.FieldCallback:
  38582. return m.Callback()
  38583. case whatsapp.FieldAgentID:
  38584. return m.AgentID()
  38585. case whatsapp.FieldAccount:
  38586. return m.Account()
  38587. case whatsapp.FieldCc:
  38588. return m.Cc()
  38589. case whatsapp.FieldPhone:
  38590. return m.Phone()
  38591. case whatsapp.FieldCcPhone:
  38592. return m.CcPhone()
  38593. case whatsapp.FieldPhoneName:
  38594. return m.PhoneName()
  38595. case whatsapp.FieldPhoneStatus:
  38596. return m.PhoneStatus()
  38597. case whatsapp.FieldOrganizationID:
  38598. return m.OrganizationID()
  38599. case whatsapp.FieldAPIBase:
  38600. return m.APIBase()
  38601. case whatsapp.FieldAPIKey:
  38602. return m.APIKey()
  38603. case whatsapp.FieldAllowList:
  38604. return m.AllowList()
  38605. case whatsapp.FieldGroupAllowList:
  38606. return m.GroupAllowList()
  38607. case whatsapp.FieldBlockList:
  38608. return m.BlockList()
  38609. case whatsapp.FieldGroupBlockList:
  38610. return m.GroupBlockList()
  38611. }
  38612. return nil, false
  38613. }
  38614. // OldField returns the old value of the field from the database. An error is
  38615. // returned if the mutation operation is not UpdateOne, or the query to the
  38616. // database failed.
  38617. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  38618. switch name {
  38619. case whatsapp.FieldCreatedAt:
  38620. return m.OldCreatedAt(ctx)
  38621. case whatsapp.FieldUpdatedAt:
  38622. return m.OldUpdatedAt(ctx)
  38623. case whatsapp.FieldStatus:
  38624. return m.OldStatus(ctx)
  38625. case whatsapp.FieldDeletedAt:
  38626. return m.OldDeletedAt(ctx)
  38627. case whatsapp.FieldWaID:
  38628. return m.OldWaID(ctx)
  38629. case whatsapp.FieldWaName:
  38630. return m.OldWaName(ctx)
  38631. case whatsapp.FieldCallback:
  38632. return m.OldCallback(ctx)
  38633. case whatsapp.FieldAgentID:
  38634. return m.OldAgentID(ctx)
  38635. case whatsapp.FieldAccount:
  38636. return m.OldAccount(ctx)
  38637. case whatsapp.FieldCc:
  38638. return m.OldCc(ctx)
  38639. case whatsapp.FieldPhone:
  38640. return m.OldPhone(ctx)
  38641. case whatsapp.FieldCcPhone:
  38642. return m.OldCcPhone(ctx)
  38643. case whatsapp.FieldPhoneName:
  38644. return m.OldPhoneName(ctx)
  38645. case whatsapp.FieldPhoneStatus:
  38646. return m.OldPhoneStatus(ctx)
  38647. case whatsapp.FieldOrganizationID:
  38648. return m.OldOrganizationID(ctx)
  38649. case whatsapp.FieldAPIBase:
  38650. return m.OldAPIBase(ctx)
  38651. case whatsapp.FieldAPIKey:
  38652. return m.OldAPIKey(ctx)
  38653. case whatsapp.FieldAllowList:
  38654. return m.OldAllowList(ctx)
  38655. case whatsapp.FieldGroupAllowList:
  38656. return m.OldGroupAllowList(ctx)
  38657. case whatsapp.FieldBlockList:
  38658. return m.OldBlockList(ctx)
  38659. case whatsapp.FieldGroupBlockList:
  38660. return m.OldGroupBlockList(ctx)
  38661. }
  38662. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  38663. }
  38664. // SetField sets the value of a field with the given name. It returns an error if
  38665. // the field is not defined in the schema, or if the type mismatched the field
  38666. // type.
  38667. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  38668. switch name {
  38669. case whatsapp.FieldCreatedAt:
  38670. v, ok := value.(time.Time)
  38671. if !ok {
  38672. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38673. }
  38674. m.SetCreatedAt(v)
  38675. return nil
  38676. case whatsapp.FieldUpdatedAt:
  38677. v, ok := value.(time.Time)
  38678. if !ok {
  38679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38680. }
  38681. m.SetUpdatedAt(v)
  38682. return nil
  38683. case whatsapp.FieldStatus:
  38684. v, ok := value.(uint8)
  38685. if !ok {
  38686. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38687. }
  38688. m.SetStatus(v)
  38689. return nil
  38690. case whatsapp.FieldDeletedAt:
  38691. v, ok := value.(time.Time)
  38692. if !ok {
  38693. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38694. }
  38695. m.SetDeletedAt(v)
  38696. return nil
  38697. case whatsapp.FieldWaID:
  38698. v, ok := value.(string)
  38699. if !ok {
  38700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38701. }
  38702. m.SetWaID(v)
  38703. return nil
  38704. case whatsapp.FieldWaName:
  38705. v, ok := value.(string)
  38706. if !ok {
  38707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38708. }
  38709. m.SetWaName(v)
  38710. return nil
  38711. case whatsapp.FieldCallback:
  38712. v, ok := value.(string)
  38713. if !ok {
  38714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38715. }
  38716. m.SetCallback(v)
  38717. return nil
  38718. case whatsapp.FieldAgentID:
  38719. v, ok := value.(uint64)
  38720. if !ok {
  38721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38722. }
  38723. m.SetAgentID(v)
  38724. return nil
  38725. case whatsapp.FieldAccount:
  38726. v, ok := value.(string)
  38727. if !ok {
  38728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38729. }
  38730. m.SetAccount(v)
  38731. return nil
  38732. case whatsapp.FieldCc:
  38733. v, ok := value.(string)
  38734. if !ok {
  38735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38736. }
  38737. m.SetCc(v)
  38738. return nil
  38739. case whatsapp.FieldPhone:
  38740. v, ok := value.(string)
  38741. if !ok {
  38742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38743. }
  38744. m.SetPhone(v)
  38745. return nil
  38746. case whatsapp.FieldCcPhone:
  38747. v, ok := value.(string)
  38748. if !ok {
  38749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38750. }
  38751. m.SetCcPhone(v)
  38752. return nil
  38753. case whatsapp.FieldPhoneName:
  38754. v, ok := value.(string)
  38755. if !ok {
  38756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38757. }
  38758. m.SetPhoneName(v)
  38759. return nil
  38760. case whatsapp.FieldPhoneStatus:
  38761. v, ok := value.(int8)
  38762. if !ok {
  38763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38764. }
  38765. m.SetPhoneStatus(v)
  38766. return nil
  38767. case whatsapp.FieldOrganizationID:
  38768. v, ok := value.(uint64)
  38769. if !ok {
  38770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38771. }
  38772. m.SetOrganizationID(v)
  38773. return nil
  38774. case whatsapp.FieldAPIBase:
  38775. v, ok := value.(string)
  38776. if !ok {
  38777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38778. }
  38779. m.SetAPIBase(v)
  38780. return nil
  38781. case whatsapp.FieldAPIKey:
  38782. v, ok := value.(string)
  38783. if !ok {
  38784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38785. }
  38786. m.SetAPIKey(v)
  38787. return nil
  38788. case whatsapp.FieldAllowList:
  38789. v, ok := value.([]string)
  38790. if !ok {
  38791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38792. }
  38793. m.SetAllowList(v)
  38794. return nil
  38795. case whatsapp.FieldGroupAllowList:
  38796. v, ok := value.([]string)
  38797. if !ok {
  38798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38799. }
  38800. m.SetGroupAllowList(v)
  38801. return nil
  38802. case whatsapp.FieldBlockList:
  38803. v, ok := value.([]string)
  38804. if !ok {
  38805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38806. }
  38807. m.SetBlockList(v)
  38808. return nil
  38809. case whatsapp.FieldGroupBlockList:
  38810. v, ok := value.([]string)
  38811. if !ok {
  38812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38813. }
  38814. m.SetGroupBlockList(v)
  38815. return nil
  38816. }
  38817. return fmt.Errorf("unknown Whatsapp field %s", name)
  38818. }
  38819. // AddedFields returns all numeric fields that were incremented/decremented during
  38820. // this mutation.
  38821. func (m *WhatsappMutation) AddedFields() []string {
  38822. var fields []string
  38823. if m.addstatus != nil {
  38824. fields = append(fields, whatsapp.FieldStatus)
  38825. }
  38826. if m.addphone_status != nil {
  38827. fields = append(fields, whatsapp.FieldPhoneStatus)
  38828. }
  38829. if m.addorganization_id != nil {
  38830. fields = append(fields, whatsapp.FieldOrganizationID)
  38831. }
  38832. return fields
  38833. }
  38834. // AddedField returns the numeric value that was incremented/decremented on a field
  38835. // with the given name. The second boolean return value indicates that this field
  38836. // was not set, or was not defined in the schema.
  38837. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  38838. switch name {
  38839. case whatsapp.FieldStatus:
  38840. return m.AddedStatus()
  38841. case whatsapp.FieldPhoneStatus:
  38842. return m.AddedPhoneStatus()
  38843. case whatsapp.FieldOrganizationID:
  38844. return m.AddedOrganizationID()
  38845. }
  38846. return nil, false
  38847. }
  38848. // AddField adds the value to the field with the given name. It returns an error if
  38849. // the field is not defined in the schema, or if the type mismatched the field
  38850. // type.
  38851. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  38852. switch name {
  38853. case whatsapp.FieldStatus:
  38854. v, ok := value.(int8)
  38855. if !ok {
  38856. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38857. }
  38858. m.AddStatus(v)
  38859. return nil
  38860. case whatsapp.FieldPhoneStatus:
  38861. v, ok := value.(int8)
  38862. if !ok {
  38863. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38864. }
  38865. m.AddPhoneStatus(v)
  38866. return nil
  38867. case whatsapp.FieldOrganizationID:
  38868. v, ok := value.(int64)
  38869. if !ok {
  38870. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38871. }
  38872. m.AddOrganizationID(v)
  38873. return nil
  38874. }
  38875. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  38876. }
  38877. // ClearedFields returns all nullable fields that were cleared during this
  38878. // mutation.
  38879. func (m *WhatsappMutation) ClearedFields() []string {
  38880. var fields []string
  38881. if m.FieldCleared(whatsapp.FieldStatus) {
  38882. fields = append(fields, whatsapp.FieldStatus)
  38883. }
  38884. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  38885. fields = append(fields, whatsapp.FieldDeletedAt)
  38886. }
  38887. if m.FieldCleared(whatsapp.FieldWaID) {
  38888. fields = append(fields, whatsapp.FieldWaID)
  38889. }
  38890. if m.FieldCleared(whatsapp.FieldWaName) {
  38891. fields = append(fields, whatsapp.FieldWaName)
  38892. }
  38893. if m.FieldCleared(whatsapp.FieldCallback) {
  38894. fields = append(fields, whatsapp.FieldCallback)
  38895. }
  38896. if m.FieldCleared(whatsapp.FieldAccount) {
  38897. fields = append(fields, whatsapp.FieldAccount)
  38898. }
  38899. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  38900. fields = append(fields, whatsapp.FieldOrganizationID)
  38901. }
  38902. if m.FieldCleared(whatsapp.FieldAPIBase) {
  38903. fields = append(fields, whatsapp.FieldAPIBase)
  38904. }
  38905. if m.FieldCleared(whatsapp.FieldAPIKey) {
  38906. fields = append(fields, whatsapp.FieldAPIKey)
  38907. }
  38908. if m.FieldCleared(whatsapp.FieldAllowList) {
  38909. fields = append(fields, whatsapp.FieldAllowList)
  38910. }
  38911. if m.FieldCleared(whatsapp.FieldGroupAllowList) {
  38912. fields = append(fields, whatsapp.FieldGroupAllowList)
  38913. }
  38914. if m.FieldCleared(whatsapp.FieldBlockList) {
  38915. fields = append(fields, whatsapp.FieldBlockList)
  38916. }
  38917. if m.FieldCleared(whatsapp.FieldGroupBlockList) {
  38918. fields = append(fields, whatsapp.FieldGroupBlockList)
  38919. }
  38920. return fields
  38921. }
  38922. // FieldCleared returns a boolean indicating if a field with the given name was
  38923. // cleared in this mutation.
  38924. func (m *WhatsappMutation) FieldCleared(name string) bool {
  38925. _, ok := m.clearedFields[name]
  38926. return ok
  38927. }
  38928. // ClearField clears the value of the field with the given name. It returns an
  38929. // error if the field is not defined in the schema.
  38930. func (m *WhatsappMutation) ClearField(name string) error {
  38931. switch name {
  38932. case whatsapp.FieldStatus:
  38933. m.ClearStatus()
  38934. return nil
  38935. case whatsapp.FieldDeletedAt:
  38936. m.ClearDeletedAt()
  38937. return nil
  38938. case whatsapp.FieldWaID:
  38939. m.ClearWaID()
  38940. return nil
  38941. case whatsapp.FieldWaName:
  38942. m.ClearWaName()
  38943. return nil
  38944. case whatsapp.FieldCallback:
  38945. m.ClearCallback()
  38946. return nil
  38947. case whatsapp.FieldAccount:
  38948. m.ClearAccount()
  38949. return nil
  38950. case whatsapp.FieldOrganizationID:
  38951. m.ClearOrganizationID()
  38952. return nil
  38953. case whatsapp.FieldAPIBase:
  38954. m.ClearAPIBase()
  38955. return nil
  38956. case whatsapp.FieldAPIKey:
  38957. m.ClearAPIKey()
  38958. return nil
  38959. case whatsapp.FieldAllowList:
  38960. m.ClearAllowList()
  38961. return nil
  38962. case whatsapp.FieldGroupAllowList:
  38963. m.ClearGroupAllowList()
  38964. return nil
  38965. case whatsapp.FieldBlockList:
  38966. m.ClearBlockList()
  38967. return nil
  38968. case whatsapp.FieldGroupBlockList:
  38969. m.ClearGroupBlockList()
  38970. return nil
  38971. }
  38972. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  38973. }
  38974. // ResetField resets all changes in the mutation for the field with the given name.
  38975. // It returns an error if the field is not defined in the schema.
  38976. func (m *WhatsappMutation) ResetField(name string) error {
  38977. switch name {
  38978. case whatsapp.FieldCreatedAt:
  38979. m.ResetCreatedAt()
  38980. return nil
  38981. case whatsapp.FieldUpdatedAt:
  38982. m.ResetUpdatedAt()
  38983. return nil
  38984. case whatsapp.FieldStatus:
  38985. m.ResetStatus()
  38986. return nil
  38987. case whatsapp.FieldDeletedAt:
  38988. m.ResetDeletedAt()
  38989. return nil
  38990. case whatsapp.FieldWaID:
  38991. m.ResetWaID()
  38992. return nil
  38993. case whatsapp.FieldWaName:
  38994. m.ResetWaName()
  38995. return nil
  38996. case whatsapp.FieldCallback:
  38997. m.ResetCallback()
  38998. return nil
  38999. case whatsapp.FieldAgentID:
  39000. m.ResetAgentID()
  39001. return nil
  39002. case whatsapp.FieldAccount:
  39003. m.ResetAccount()
  39004. return nil
  39005. case whatsapp.FieldCc:
  39006. m.ResetCc()
  39007. return nil
  39008. case whatsapp.FieldPhone:
  39009. m.ResetPhone()
  39010. return nil
  39011. case whatsapp.FieldCcPhone:
  39012. m.ResetCcPhone()
  39013. return nil
  39014. case whatsapp.FieldPhoneName:
  39015. m.ResetPhoneName()
  39016. return nil
  39017. case whatsapp.FieldPhoneStatus:
  39018. m.ResetPhoneStatus()
  39019. return nil
  39020. case whatsapp.FieldOrganizationID:
  39021. m.ResetOrganizationID()
  39022. return nil
  39023. case whatsapp.FieldAPIBase:
  39024. m.ResetAPIBase()
  39025. return nil
  39026. case whatsapp.FieldAPIKey:
  39027. m.ResetAPIKey()
  39028. return nil
  39029. case whatsapp.FieldAllowList:
  39030. m.ResetAllowList()
  39031. return nil
  39032. case whatsapp.FieldGroupAllowList:
  39033. m.ResetGroupAllowList()
  39034. return nil
  39035. case whatsapp.FieldBlockList:
  39036. m.ResetBlockList()
  39037. return nil
  39038. case whatsapp.FieldGroupBlockList:
  39039. m.ResetGroupBlockList()
  39040. return nil
  39041. }
  39042. return fmt.Errorf("unknown Whatsapp field %s", name)
  39043. }
  39044. // AddedEdges returns all edge names that were set/added in this mutation.
  39045. func (m *WhatsappMutation) AddedEdges() []string {
  39046. edges := make([]string, 0, 1)
  39047. if m.agent != nil {
  39048. edges = append(edges, whatsapp.EdgeAgent)
  39049. }
  39050. return edges
  39051. }
  39052. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  39053. // name in this mutation.
  39054. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  39055. switch name {
  39056. case whatsapp.EdgeAgent:
  39057. if id := m.agent; id != nil {
  39058. return []ent.Value{*id}
  39059. }
  39060. }
  39061. return nil
  39062. }
  39063. // RemovedEdges returns all edge names that were removed in this mutation.
  39064. func (m *WhatsappMutation) RemovedEdges() []string {
  39065. edges := make([]string, 0, 1)
  39066. return edges
  39067. }
  39068. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39069. // the given name in this mutation.
  39070. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  39071. return nil
  39072. }
  39073. // ClearedEdges returns all edge names that were cleared in this mutation.
  39074. func (m *WhatsappMutation) ClearedEdges() []string {
  39075. edges := make([]string, 0, 1)
  39076. if m.clearedagent {
  39077. edges = append(edges, whatsapp.EdgeAgent)
  39078. }
  39079. return edges
  39080. }
  39081. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39082. // was cleared in this mutation.
  39083. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  39084. switch name {
  39085. case whatsapp.EdgeAgent:
  39086. return m.clearedagent
  39087. }
  39088. return false
  39089. }
  39090. // ClearEdge clears the value of the edge with the given name. It returns an error
  39091. // if that edge is not defined in the schema.
  39092. func (m *WhatsappMutation) ClearEdge(name string) error {
  39093. switch name {
  39094. case whatsapp.EdgeAgent:
  39095. m.ClearAgent()
  39096. return nil
  39097. }
  39098. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  39099. }
  39100. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39101. // It returns an error if the edge is not defined in the schema.
  39102. func (m *WhatsappMutation) ResetEdge(name string) error {
  39103. switch name {
  39104. case whatsapp.EdgeAgent:
  39105. m.ResetAgent()
  39106. return nil
  39107. }
  39108. return fmt.Errorf("unknown Whatsapp edge %s", name)
  39109. }
  39110. // WhatsappChannelMutation represents an operation that mutates the WhatsappChannel nodes in the graph.
  39111. type WhatsappChannelMutation struct {
  39112. config
  39113. op Op
  39114. typ string
  39115. id *uint64
  39116. created_at *time.Time
  39117. updated_at *time.Time
  39118. status *uint8
  39119. addstatus *int8
  39120. deleted_at *time.Time
  39121. ak *string
  39122. sk *string
  39123. wa_id *string
  39124. wa_name *string
  39125. waba_id *uint64
  39126. addwaba_id *int64
  39127. business_id *uint64
  39128. addbusiness_id *int64
  39129. organization_id *uint64
  39130. addorganization_id *int64
  39131. verify_account *string
  39132. clearedFields map[string]struct{}
  39133. done bool
  39134. oldValue func(context.Context) (*WhatsappChannel, error)
  39135. predicates []predicate.WhatsappChannel
  39136. }
  39137. var _ ent.Mutation = (*WhatsappChannelMutation)(nil)
  39138. // whatsappchannelOption allows management of the mutation configuration using functional options.
  39139. type whatsappchannelOption func(*WhatsappChannelMutation)
  39140. // newWhatsappChannelMutation creates new mutation for the WhatsappChannel entity.
  39141. func newWhatsappChannelMutation(c config, op Op, opts ...whatsappchannelOption) *WhatsappChannelMutation {
  39142. m := &WhatsappChannelMutation{
  39143. config: c,
  39144. op: op,
  39145. typ: TypeWhatsappChannel,
  39146. clearedFields: make(map[string]struct{}),
  39147. }
  39148. for _, opt := range opts {
  39149. opt(m)
  39150. }
  39151. return m
  39152. }
  39153. // withWhatsappChannelID sets the ID field of the mutation.
  39154. func withWhatsappChannelID(id uint64) whatsappchannelOption {
  39155. return func(m *WhatsappChannelMutation) {
  39156. var (
  39157. err error
  39158. once sync.Once
  39159. value *WhatsappChannel
  39160. )
  39161. m.oldValue = func(ctx context.Context) (*WhatsappChannel, error) {
  39162. once.Do(func() {
  39163. if m.done {
  39164. err = errors.New("querying old values post mutation is not allowed")
  39165. } else {
  39166. value, err = m.Client().WhatsappChannel.Get(ctx, id)
  39167. }
  39168. })
  39169. return value, err
  39170. }
  39171. m.id = &id
  39172. }
  39173. }
  39174. // withWhatsappChannel sets the old WhatsappChannel of the mutation.
  39175. func withWhatsappChannel(node *WhatsappChannel) whatsappchannelOption {
  39176. return func(m *WhatsappChannelMutation) {
  39177. m.oldValue = func(context.Context) (*WhatsappChannel, error) {
  39178. return node, nil
  39179. }
  39180. m.id = &node.ID
  39181. }
  39182. }
  39183. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39184. // executed in a transaction (ent.Tx), a transactional client is returned.
  39185. func (m WhatsappChannelMutation) Client() *Client {
  39186. client := &Client{config: m.config}
  39187. client.init()
  39188. return client
  39189. }
  39190. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39191. // it returns an error otherwise.
  39192. func (m WhatsappChannelMutation) Tx() (*Tx, error) {
  39193. if _, ok := m.driver.(*txDriver); !ok {
  39194. return nil, errors.New("ent: mutation is not running in a transaction")
  39195. }
  39196. tx := &Tx{config: m.config}
  39197. tx.init()
  39198. return tx, nil
  39199. }
  39200. // SetID sets the value of the id field. Note that this
  39201. // operation is only accepted on creation of WhatsappChannel entities.
  39202. func (m *WhatsappChannelMutation) SetID(id uint64) {
  39203. m.id = &id
  39204. }
  39205. // ID returns the ID value in the mutation. Note that the ID is only available
  39206. // if it was provided to the builder or after it was returned from the database.
  39207. func (m *WhatsappChannelMutation) ID() (id uint64, exists bool) {
  39208. if m.id == nil {
  39209. return
  39210. }
  39211. return *m.id, true
  39212. }
  39213. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39214. // That means, if the mutation is applied within a transaction with an isolation level such
  39215. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39216. // or updated by the mutation.
  39217. func (m *WhatsappChannelMutation) IDs(ctx context.Context) ([]uint64, error) {
  39218. switch {
  39219. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39220. id, exists := m.ID()
  39221. if exists {
  39222. return []uint64{id}, nil
  39223. }
  39224. fallthrough
  39225. case m.op.Is(OpUpdate | OpDelete):
  39226. return m.Client().WhatsappChannel.Query().Where(m.predicates...).IDs(ctx)
  39227. default:
  39228. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39229. }
  39230. }
  39231. // SetCreatedAt sets the "created_at" field.
  39232. func (m *WhatsappChannelMutation) SetCreatedAt(t time.Time) {
  39233. m.created_at = &t
  39234. }
  39235. // CreatedAt returns the value of the "created_at" field in the mutation.
  39236. func (m *WhatsappChannelMutation) CreatedAt() (r time.Time, exists bool) {
  39237. v := m.created_at
  39238. if v == nil {
  39239. return
  39240. }
  39241. return *v, true
  39242. }
  39243. // OldCreatedAt returns the old "created_at" field's value of the WhatsappChannel entity.
  39244. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39245. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39246. func (m *WhatsappChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39247. if !m.op.Is(OpUpdateOne) {
  39248. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39249. }
  39250. if m.id == nil || m.oldValue == nil {
  39251. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39252. }
  39253. oldValue, err := m.oldValue(ctx)
  39254. if err != nil {
  39255. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39256. }
  39257. return oldValue.CreatedAt, nil
  39258. }
  39259. // ResetCreatedAt resets all changes to the "created_at" field.
  39260. func (m *WhatsappChannelMutation) ResetCreatedAt() {
  39261. m.created_at = nil
  39262. }
  39263. // SetUpdatedAt sets the "updated_at" field.
  39264. func (m *WhatsappChannelMutation) SetUpdatedAt(t time.Time) {
  39265. m.updated_at = &t
  39266. }
  39267. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  39268. func (m *WhatsappChannelMutation) UpdatedAt() (r time.Time, exists bool) {
  39269. v := m.updated_at
  39270. if v == nil {
  39271. return
  39272. }
  39273. return *v, true
  39274. }
  39275. // OldUpdatedAt returns the old "updated_at" field's value of the WhatsappChannel entity.
  39276. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39277. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39278. func (m *WhatsappChannelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  39279. if !m.op.Is(OpUpdateOne) {
  39280. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  39281. }
  39282. if m.id == nil || m.oldValue == nil {
  39283. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  39284. }
  39285. oldValue, err := m.oldValue(ctx)
  39286. if err != nil {
  39287. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  39288. }
  39289. return oldValue.UpdatedAt, nil
  39290. }
  39291. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39292. func (m *WhatsappChannelMutation) ResetUpdatedAt() {
  39293. m.updated_at = nil
  39294. }
  39295. // SetStatus sets the "status" field.
  39296. func (m *WhatsappChannelMutation) SetStatus(u uint8) {
  39297. m.status = &u
  39298. m.addstatus = nil
  39299. }
  39300. // Status returns the value of the "status" field in the mutation.
  39301. func (m *WhatsappChannelMutation) Status() (r uint8, exists bool) {
  39302. v := m.status
  39303. if v == nil {
  39304. return
  39305. }
  39306. return *v, true
  39307. }
  39308. // OldStatus returns the old "status" field's value of the WhatsappChannel entity.
  39309. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39310. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39311. func (m *WhatsappChannelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  39312. if !m.op.Is(OpUpdateOne) {
  39313. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  39314. }
  39315. if m.id == nil || m.oldValue == nil {
  39316. return v, errors.New("OldStatus requires an ID field in the mutation")
  39317. }
  39318. oldValue, err := m.oldValue(ctx)
  39319. if err != nil {
  39320. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  39321. }
  39322. return oldValue.Status, nil
  39323. }
  39324. // AddStatus adds u to the "status" field.
  39325. func (m *WhatsappChannelMutation) AddStatus(u int8) {
  39326. if m.addstatus != nil {
  39327. *m.addstatus += u
  39328. } else {
  39329. m.addstatus = &u
  39330. }
  39331. }
  39332. // AddedStatus returns the value that was added to the "status" field in this mutation.
  39333. func (m *WhatsappChannelMutation) AddedStatus() (r int8, exists bool) {
  39334. v := m.addstatus
  39335. if v == nil {
  39336. return
  39337. }
  39338. return *v, true
  39339. }
  39340. // ClearStatus clears the value of the "status" field.
  39341. func (m *WhatsappChannelMutation) ClearStatus() {
  39342. m.status = nil
  39343. m.addstatus = nil
  39344. m.clearedFields[whatsappchannel.FieldStatus] = struct{}{}
  39345. }
  39346. // StatusCleared returns if the "status" field was cleared in this mutation.
  39347. func (m *WhatsappChannelMutation) StatusCleared() bool {
  39348. _, ok := m.clearedFields[whatsappchannel.FieldStatus]
  39349. return ok
  39350. }
  39351. // ResetStatus resets all changes to the "status" field.
  39352. func (m *WhatsappChannelMutation) ResetStatus() {
  39353. m.status = nil
  39354. m.addstatus = nil
  39355. delete(m.clearedFields, whatsappchannel.FieldStatus)
  39356. }
  39357. // SetDeletedAt sets the "deleted_at" field.
  39358. func (m *WhatsappChannelMutation) SetDeletedAt(t time.Time) {
  39359. m.deleted_at = &t
  39360. }
  39361. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  39362. func (m *WhatsappChannelMutation) DeletedAt() (r time.Time, exists bool) {
  39363. v := m.deleted_at
  39364. if v == nil {
  39365. return
  39366. }
  39367. return *v, true
  39368. }
  39369. // OldDeletedAt returns the old "deleted_at" field's value of the WhatsappChannel entity.
  39370. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39371. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39372. func (m *WhatsappChannelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  39373. if !m.op.Is(OpUpdateOne) {
  39374. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  39375. }
  39376. if m.id == nil || m.oldValue == nil {
  39377. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  39378. }
  39379. oldValue, err := m.oldValue(ctx)
  39380. if err != nil {
  39381. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  39382. }
  39383. return oldValue.DeletedAt, nil
  39384. }
  39385. // ClearDeletedAt clears the value of the "deleted_at" field.
  39386. func (m *WhatsappChannelMutation) ClearDeletedAt() {
  39387. m.deleted_at = nil
  39388. m.clearedFields[whatsappchannel.FieldDeletedAt] = struct{}{}
  39389. }
  39390. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  39391. func (m *WhatsappChannelMutation) DeletedAtCleared() bool {
  39392. _, ok := m.clearedFields[whatsappchannel.FieldDeletedAt]
  39393. return ok
  39394. }
  39395. // ResetDeletedAt resets all changes to the "deleted_at" field.
  39396. func (m *WhatsappChannelMutation) ResetDeletedAt() {
  39397. m.deleted_at = nil
  39398. delete(m.clearedFields, whatsappchannel.FieldDeletedAt)
  39399. }
  39400. // SetAk sets the "ak" field.
  39401. func (m *WhatsappChannelMutation) SetAk(s string) {
  39402. m.ak = &s
  39403. }
  39404. // Ak returns the value of the "ak" field in the mutation.
  39405. func (m *WhatsappChannelMutation) Ak() (r string, exists bool) {
  39406. v := m.ak
  39407. if v == nil {
  39408. return
  39409. }
  39410. return *v, true
  39411. }
  39412. // OldAk returns the old "ak" field's value of the WhatsappChannel entity.
  39413. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39414. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39415. func (m *WhatsappChannelMutation) OldAk(ctx context.Context) (v string, err error) {
  39416. if !m.op.Is(OpUpdateOne) {
  39417. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  39418. }
  39419. if m.id == nil || m.oldValue == nil {
  39420. return v, errors.New("OldAk requires an ID field in the mutation")
  39421. }
  39422. oldValue, err := m.oldValue(ctx)
  39423. if err != nil {
  39424. return v, fmt.Errorf("querying old value for OldAk: %w", err)
  39425. }
  39426. return oldValue.Ak, nil
  39427. }
  39428. // ClearAk clears the value of the "ak" field.
  39429. func (m *WhatsappChannelMutation) ClearAk() {
  39430. m.ak = nil
  39431. m.clearedFields[whatsappchannel.FieldAk] = struct{}{}
  39432. }
  39433. // AkCleared returns if the "ak" field was cleared in this mutation.
  39434. func (m *WhatsappChannelMutation) AkCleared() bool {
  39435. _, ok := m.clearedFields[whatsappchannel.FieldAk]
  39436. return ok
  39437. }
  39438. // ResetAk resets all changes to the "ak" field.
  39439. func (m *WhatsappChannelMutation) ResetAk() {
  39440. m.ak = nil
  39441. delete(m.clearedFields, whatsappchannel.FieldAk)
  39442. }
  39443. // SetSk sets the "sk" field.
  39444. func (m *WhatsappChannelMutation) SetSk(s string) {
  39445. m.sk = &s
  39446. }
  39447. // Sk returns the value of the "sk" field in the mutation.
  39448. func (m *WhatsappChannelMutation) Sk() (r string, exists bool) {
  39449. v := m.sk
  39450. if v == nil {
  39451. return
  39452. }
  39453. return *v, true
  39454. }
  39455. // OldSk returns the old "sk" field's value of the WhatsappChannel entity.
  39456. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39458. func (m *WhatsappChannelMutation) OldSk(ctx context.Context) (v string, err error) {
  39459. if !m.op.Is(OpUpdateOne) {
  39460. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  39461. }
  39462. if m.id == nil || m.oldValue == nil {
  39463. return v, errors.New("OldSk requires an ID field in the mutation")
  39464. }
  39465. oldValue, err := m.oldValue(ctx)
  39466. if err != nil {
  39467. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  39468. }
  39469. return oldValue.Sk, nil
  39470. }
  39471. // ResetSk resets all changes to the "sk" field.
  39472. func (m *WhatsappChannelMutation) ResetSk() {
  39473. m.sk = nil
  39474. }
  39475. // SetWaID sets the "wa_id" field.
  39476. func (m *WhatsappChannelMutation) SetWaID(s string) {
  39477. m.wa_id = &s
  39478. }
  39479. // WaID returns the value of the "wa_id" field in the mutation.
  39480. func (m *WhatsappChannelMutation) WaID() (r string, exists bool) {
  39481. v := m.wa_id
  39482. if v == nil {
  39483. return
  39484. }
  39485. return *v, true
  39486. }
  39487. // OldWaID returns the old "wa_id" field's value of the WhatsappChannel entity.
  39488. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39489. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39490. func (m *WhatsappChannelMutation) OldWaID(ctx context.Context) (v string, err error) {
  39491. if !m.op.Is(OpUpdateOne) {
  39492. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  39493. }
  39494. if m.id == nil || m.oldValue == nil {
  39495. return v, errors.New("OldWaID requires an ID field in the mutation")
  39496. }
  39497. oldValue, err := m.oldValue(ctx)
  39498. if err != nil {
  39499. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  39500. }
  39501. return oldValue.WaID, nil
  39502. }
  39503. // ClearWaID clears the value of the "wa_id" field.
  39504. func (m *WhatsappChannelMutation) ClearWaID() {
  39505. m.wa_id = nil
  39506. m.clearedFields[whatsappchannel.FieldWaID] = struct{}{}
  39507. }
  39508. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  39509. func (m *WhatsappChannelMutation) WaIDCleared() bool {
  39510. _, ok := m.clearedFields[whatsappchannel.FieldWaID]
  39511. return ok
  39512. }
  39513. // ResetWaID resets all changes to the "wa_id" field.
  39514. func (m *WhatsappChannelMutation) ResetWaID() {
  39515. m.wa_id = nil
  39516. delete(m.clearedFields, whatsappchannel.FieldWaID)
  39517. }
  39518. // SetWaName sets the "wa_name" field.
  39519. func (m *WhatsappChannelMutation) SetWaName(s string) {
  39520. m.wa_name = &s
  39521. }
  39522. // WaName returns the value of the "wa_name" field in the mutation.
  39523. func (m *WhatsappChannelMutation) WaName() (r string, exists bool) {
  39524. v := m.wa_name
  39525. if v == nil {
  39526. return
  39527. }
  39528. return *v, true
  39529. }
  39530. // OldWaName returns the old "wa_name" field's value of the WhatsappChannel entity.
  39531. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39532. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39533. func (m *WhatsappChannelMutation) OldWaName(ctx context.Context) (v string, err error) {
  39534. if !m.op.Is(OpUpdateOne) {
  39535. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  39536. }
  39537. if m.id == nil || m.oldValue == nil {
  39538. return v, errors.New("OldWaName requires an ID field in the mutation")
  39539. }
  39540. oldValue, err := m.oldValue(ctx)
  39541. if err != nil {
  39542. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  39543. }
  39544. return oldValue.WaName, nil
  39545. }
  39546. // ClearWaName clears the value of the "wa_name" field.
  39547. func (m *WhatsappChannelMutation) ClearWaName() {
  39548. m.wa_name = nil
  39549. m.clearedFields[whatsappchannel.FieldWaName] = struct{}{}
  39550. }
  39551. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  39552. func (m *WhatsappChannelMutation) WaNameCleared() bool {
  39553. _, ok := m.clearedFields[whatsappchannel.FieldWaName]
  39554. return ok
  39555. }
  39556. // ResetWaName resets all changes to the "wa_name" field.
  39557. func (m *WhatsappChannelMutation) ResetWaName() {
  39558. m.wa_name = nil
  39559. delete(m.clearedFields, whatsappchannel.FieldWaName)
  39560. }
  39561. // SetWabaID sets the "waba_id" field.
  39562. func (m *WhatsappChannelMutation) SetWabaID(u uint64) {
  39563. m.waba_id = &u
  39564. m.addwaba_id = nil
  39565. }
  39566. // WabaID returns the value of the "waba_id" field in the mutation.
  39567. func (m *WhatsappChannelMutation) WabaID() (r uint64, exists bool) {
  39568. v := m.waba_id
  39569. if v == nil {
  39570. return
  39571. }
  39572. return *v, true
  39573. }
  39574. // OldWabaID returns the old "waba_id" field's value of the WhatsappChannel entity.
  39575. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39576. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39577. func (m *WhatsappChannelMutation) OldWabaID(ctx context.Context) (v uint64, err error) {
  39578. if !m.op.Is(OpUpdateOne) {
  39579. return v, errors.New("OldWabaID is only allowed on UpdateOne operations")
  39580. }
  39581. if m.id == nil || m.oldValue == nil {
  39582. return v, errors.New("OldWabaID requires an ID field in the mutation")
  39583. }
  39584. oldValue, err := m.oldValue(ctx)
  39585. if err != nil {
  39586. return v, fmt.Errorf("querying old value for OldWabaID: %w", err)
  39587. }
  39588. return oldValue.WabaID, nil
  39589. }
  39590. // AddWabaID adds u to the "waba_id" field.
  39591. func (m *WhatsappChannelMutation) AddWabaID(u int64) {
  39592. if m.addwaba_id != nil {
  39593. *m.addwaba_id += u
  39594. } else {
  39595. m.addwaba_id = &u
  39596. }
  39597. }
  39598. // AddedWabaID returns the value that was added to the "waba_id" field in this mutation.
  39599. func (m *WhatsappChannelMutation) AddedWabaID() (r int64, exists bool) {
  39600. v := m.addwaba_id
  39601. if v == nil {
  39602. return
  39603. }
  39604. return *v, true
  39605. }
  39606. // ResetWabaID resets all changes to the "waba_id" field.
  39607. func (m *WhatsappChannelMutation) ResetWabaID() {
  39608. m.waba_id = nil
  39609. m.addwaba_id = nil
  39610. }
  39611. // SetBusinessID sets the "business_id" field.
  39612. func (m *WhatsappChannelMutation) SetBusinessID(u uint64) {
  39613. m.business_id = &u
  39614. m.addbusiness_id = nil
  39615. }
  39616. // BusinessID returns the value of the "business_id" field in the mutation.
  39617. func (m *WhatsappChannelMutation) BusinessID() (r uint64, exists bool) {
  39618. v := m.business_id
  39619. if v == nil {
  39620. return
  39621. }
  39622. return *v, true
  39623. }
  39624. // OldBusinessID returns the old "business_id" field's value of the WhatsappChannel entity.
  39625. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39626. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39627. func (m *WhatsappChannelMutation) OldBusinessID(ctx context.Context) (v uint64, err error) {
  39628. if !m.op.Is(OpUpdateOne) {
  39629. return v, errors.New("OldBusinessID is only allowed on UpdateOne operations")
  39630. }
  39631. if m.id == nil || m.oldValue == nil {
  39632. return v, errors.New("OldBusinessID requires an ID field in the mutation")
  39633. }
  39634. oldValue, err := m.oldValue(ctx)
  39635. if err != nil {
  39636. return v, fmt.Errorf("querying old value for OldBusinessID: %w", err)
  39637. }
  39638. return oldValue.BusinessID, nil
  39639. }
  39640. // AddBusinessID adds u to the "business_id" field.
  39641. func (m *WhatsappChannelMutation) AddBusinessID(u int64) {
  39642. if m.addbusiness_id != nil {
  39643. *m.addbusiness_id += u
  39644. } else {
  39645. m.addbusiness_id = &u
  39646. }
  39647. }
  39648. // AddedBusinessID returns the value that was added to the "business_id" field in this mutation.
  39649. func (m *WhatsappChannelMutation) AddedBusinessID() (r int64, exists bool) {
  39650. v := m.addbusiness_id
  39651. if v == nil {
  39652. return
  39653. }
  39654. return *v, true
  39655. }
  39656. // ResetBusinessID resets all changes to the "business_id" field.
  39657. func (m *WhatsappChannelMutation) ResetBusinessID() {
  39658. m.business_id = nil
  39659. m.addbusiness_id = nil
  39660. }
  39661. // SetOrganizationID sets the "organization_id" field.
  39662. func (m *WhatsappChannelMutation) SetOrganizationID(u uint64) {
  39663. m.organization_id = &u
  39664. m.addorganization_id = nil
  39665. }
  39666. // OrganizationID returns the value of the "organization_id" field in the mutation.
  39667. func (m *WhatsappChannelMutation) OrganizationID() (r uint64, exists bool) {
  39668. v := m.organization_id
  39669. if v == nil {
  39670. return
  39671. }
  39672. return *v, true
  39673. }
  39674. // OldOrganizationID returns the old "organization_id" field's value of the WhatsappChannel entity.
  39675. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39676. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39677. func (m *WhatsappChannelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  39678. if !m.op.Is(OpUpdateOne) {
  39679. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  39680. }
  39681. if m.id == nil || m.oldValue == nil {
  39682. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  39683. }
  39684. oldValue, err := m.oldValue(ctx)
  39685. if err != nil {
  39686. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  39687. }
  39688. return oldValue.OrganizationID, nil
  39689. }
  39690. // AddOrganizationID adds u to the "organization_id" field.
  39691. func (m *WhatsappChannelMutation) AddOrganizationID(u int64) {
  39692. if m.addorganization_id != nil {
  39693. *m.addorganization_id += u
  39694. } else {
  39695. m.addorganization_id = &u
  39696. }
  39697. }
  39698. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  39699. func (m *WhatsappChannelMutation) AddedOrganizationID() (r int64, exists bool) {
  39700. v := m.addorganization_id
  39701. if v == nil {
  39702. return
  39703. }
  39704. return *v, true
  39705. }
  39706. // ClearOrganizationID clears the value of the "organization_id" field.
  39707. func (m *WhatsappChannelMutation) ClearOrganizationID() {
  39708. m.organization_id = nil
  39709. m.addorganization_id = nil
  39710. m.clearedFields[whatsappchannel.FieldOrganizationID] = struct{}{}
  39711. }
  39712. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  39713. func (m *WhatsappChannelMutation) OrganizationIDCleared() bool {
  39714. _, ok := m.clearedFields[whatsappchannel.FieldOrganizationID]
  39715. return ok
  39716. }
  39717. // ResetOrganizationID resets all changes to the "organization_id" field.
  39718. func (m *WhatsappChannelMutation) ResetOrganizationID() {
  39719. m.organization_id = nil
  39720. m.addorganization_id = nil
  39721. delete(m.clearedFields, whatsappchannel.FieldOrganizationID)
  39722. }
  39723. // SetVerifyAccount sets the "verify_account" field.
  39724. func (m *WhatsappChannelMutation) SetVerifyAccount(s string) {
  39725. m.verify_account = &s
  39726. }
  39727. // VerifyAccount returns the value of the "verify_account" field in the mutation.
  39728. func (m *WhatsappChannelMutation) VerifyAccount() (r string, exists bool) {
  39729. v := m.verify_account
  39730. if v == nil {
  39731. return
  39732. }
  39733. return *v, true
  39734. }
  39735. // OldVerifyAccount returns the old "verify_account" field's value of the WhatsappChannel entity.
  39736. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39737. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39738. func (m *WhatsappChannelMutation) OldVerifyAccount(ctx context.Context) (v string, err error) {
  39739. if !m.op.Is(OpUpdateOne) {
  39740. return v, errors.New("OldVerifyAccount is only allowed on UpdateOne operations")
  39741. }
  39742. if m.id == nil || m.oldValue == nil {
  39743. return v, errors.New("OldVerifyAccount requires an ID field in the mutation")
  39744. }
  39745. oldValue, err := m.oldValue(ctx)
  39746. if err != nil {
  39747. return v, fmt.Errorf("querying old value for OldVerifyAccount: %w", err)
  39748. }
  39749. return oldValue.VerifyAccount, nil
  39750. }
  39751. // ResetVerifyAccount resets all changes to the "verify_account" field.
  39752. func (m *WhatsappChannelMutation) ResetVerifyAccount() {
  39753. m.verify_account = nil
  39754. }
  39755. // Where appends a list predicates to the WhatsappChannelMutation builder.
  39756. func (m *WhatsappChannelMutation) Where(ps ...predicate.WhatsappChannel) {
  39757. m.predicates = append(m.predicates, ps...)
  39758. }
  39759. // WhereP appends storage-level predicates to the WhatsappChannelMutation builder. Using this method,
  39760. // users can use type-assertion to append predicates that do not depend on any generated package.
  39761. func (m *WhatsappChannelMutation) WhereP(ps ...func(*sql.Selector)) {
  39762. p := make([]predicate.WhatsappChannel, len(ps))
  39763. for i := range ps {
  39764. p[i] = ps[i]
  39765. }
  39766. m.Where(p...)
  39767. }
  39768. // Op returns the operation name.
  39769. func (m *WhatsappChannelMutation) Op() Op {
  39770. return m.op
  39771. }
  39772. // SetOp allows setting the mutation operation.
  39773. func (m *WhatsappChannelMutation) SetOp(op Op) {
  39774. m.op = op
  39775. }
  39776. // Type returns the node type of this mutation (WhatsappChannel).
  39777. func (m *WhatsappChannelMutation) Type() string {
  39778. return m.typ
  39779. }
  39780. // Fields returns all fields that were changed during this mutation. Note that in
  39781. // order to get all numeric fields that were incremented/decremented, call
  39782. // AddedFields().
  39783. func (m *WhatsappChannelMutation) Fields() []string {
  39784. fields := make([]string, 0, 12)
  39785. if m.created_at != nil {
  39786. fields = append(fields, whatsappchannel.FieldCreatedAt)
  39787. }
  39788. if m.updated_at != nil {
  39789. fields = append(fields, whatsappchannel.FieldUpdatedAt)
  39790. }
  39791. if m.status != nil {
  39792. fields = append(fields, whatsappchannel.FieldStatus)
  39793. }
  39794. if m.deleted_at != nil {
  39795. fields = append(fields, whatsappchannel.FieldDeletedAt)
  39796. }
  39797. if m.ak != nil {
  39798. fields = append(fields, whatsappchannel.FieldAk)
  39799. }
  39800. if m.sk != nil {
  39801. fields = append(fields, whatsappchannel.FieldSk)
  39802. }
  39803. if m.wa_id != nil {
  39804. fields = append(fields, whatsappchannel.FieldWaID)
  39805. }
  39806. if m.wa_name != nil {
  39807. fields = append(fields, whatsappchannel.FieldWaName)
  39808. }
  39809. if m.waba_id != nil {
  39810. fields = append(fields, whatsappchannel.FieldWabaID)
  39811. }
  39812. if m.business_id != nil {
  39813. fields = append(fields, whatsappchannel.FieldBusinessID)
  39814. }
  39815. if m.organization_id != nil {
  39816. fields = append(fields, whatsappchannel.FieldOrganizationID)
  39817. }
  39818. if m.verify_account != nil {
  39819. fields = append(fields, whatsappchannel.FieldVerifyAccount)
  39820. }
  39821. return fields
  39822. }
  39823. // Field returns the value of a field with the given name. The second boolean
  39824. // return value indicates that this field was not set, or was not defined in the
  39825. // schema.
  39826. func (m *WhatsappChannelMutation) Field(name string) (ent.Value, bool) {
  39827. switch name {
  39828. case whatsappchannel.FieldCreatedAt:
  39829. return m.CreatedAt()
  39830. case whatsappchannel.FieldUpdatedAt:
  39831. return m.UpdatedAt()
  39832. case whatsappchannel.FieldStatus:
  39833. return m.Status()
  39834. case whatsappchannel.FieldDeletedAt:
  39835. return m.DeletedAt()
  39836. case whatsappchannel.FieldAk:
  39837. return m.Ak()
  39838. case whatsappchannel.FieldSk:
  39839. return m.Sk()
  39840. case whatsappchannel.FieldWaID:
  39841. return m.WaID()
  39842. case whatsappchannel.FieldWaName:
  39843. return m.WaName()
  39844. case whatsappchannel.FieldWabaID:
  39845. return m.WabaID()
  39846. case whatsappchannel.FieldBusinessID:
  39847. return m.BusinessID()
  39848. case whatsappchannel.FieldOrganizationID:
  39849. return m.OrganizationID()
  39850. case whatsappchannel.FieldVerifyAccount:
  39851. return m.VerifyAccount()
  39852. }
  39853. return nil, false
  39854. }
  39855. // OldField returns the old value of the field from the database. An error is
  39856. // returned if the mutation operation is not UpdateOne, or the query to the
  39857. // database failed.
  39858. func (m *WhatsappChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  39859. switch name {
  39860. case whatsappchannel.FieldCreatedAt:
  39861. return m.OldCreatedAt(ctx)
  39862. case whatsappchannel.FieldUpdatedAt:
  39863. return m.OldUpdatedAt(ctx)
  39864. case whatsappchannel.FieldStatus:
  39865. return m.OldStatus(ctx)
  39866. case whatsappchannel.FieldDeletedAt:
  39867. return m.OldDeletedAt(ctx)
  39868. case whatsappchannel.FieldAk:
  39869. return m.OldAk(ctx)
  39870. case whatsappchannel.FieldSk:
  39871. return m.OldSk(ctx)
  39872. case whatsappchannel.FieldWaID:
  39873. return m.OldWaID(ctx)
  39874. case whatsappchannel.FieldWaName:
  39875. return m.OldWaName(ctx)
  39876. case whatsappchannel.FieldWabaID:
  39877. return m.OldWabaID(ctx)
  39878. case whatsappchannel.FieldBusinessID:
  39879. return m.OldBusinessID(ctx)
  39880. case whatsappchannel.FieldOrganizationID:
  39881. return m.OldOrganizationID(ctx)
  39882. case whatsappchannel.FieldVerifyAccount:
  39883. return m.OldVerifyAccount(ctx)
  39884. }
  39885. return nil, fmt.Errorf("unknown WhatsappChannel field %s", name)
  39886. }
  39887. // SetField sets the value of a field with the given name. It returns an error if
  39888. // the field is not defined in the schema, or if the type mismatched the field
  39889. // type.
  39890. func (m *WhatsappChannelMutation) SetField(name string, value ent.Value) error {
  39891. switch name {
  39892. case whatsappchannel.FieldCreatedAt:
  39893. v, ok := value.(time.Time)
  39894. if !ok {
  39895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39896. }
  39897. m.SetCreatedAt(v)
  39898. return nil
  39899. case whatsappchannel.FieldUpdatedAt:
  39900. v, ok := value.(time.Time)
  39901. if !ok {
  39902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39903. }
  39904. m.SetUpdatedAt(v)
  39905. return nil
  39906. case whatsappchannel.FieldStatus:
  39907. v, ok := value.(uint8)
  39908. if !ok {
  39909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39910. }
  39911. m.SetStatus(v)
  39912. return nil
  39913. case whatsappchannel.FieldDeletedAt:
  39914. v, ok := value.(time.Time)
  39915. if !ok {
  39916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39917. }
  39918. m.SetDeletedAt(v)
  39919. return nil
  39920. case whatsappchannel.FieldAk:
  39921. v, ok := value.(string)
  39922. if !ok {
  39923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39924. }
  39925. m.SetAk(v)
  39926. return nil
  39927. case whatsappchannel.FieldSk:
  39928. v, ok := value.(string)
  39929. if !ok {
  39930. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39931. }
  39932. m.SetSk(v)
  39933. return nil
  39934. case whatsappchannel.FieldWaID:
  39935. v, ok := value.(string)
  39936. if !ok {
  39937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39938. }
  39939. m.SetWaID(v)
  39940. return nil
  39941. case whatsappchannel.FieldWaName:
  39942. v, ok := value.(string)
  39943. if !ok {
  39944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39945. }
  39946. m.SetWaName(v)
  39947. return nil
  39948. case whatsappchannel.FieldWabaID:
  39949. v, ok := value.(uint64)
  39950. if !ok {
  39951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39952. }
  39953. m.SetWabaID(v)
  39954. return nil
  39955. case whatsappchannel.FieldBusinessID:
  39956. v, ok := value.(uint64)
  39957. if !ok {
  39958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39959. }
  39960. m.SetBusinessID(v)
  39961. return nil
  39962. case whatsappchannel.FieldOrganizationID:
  39963. v, ok := value.(uint64)
  39964. if !ok {
  39965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39966. }
  39967. m.SetOrganizationID(v)
  39968. return nil
  39969. case whatsappchannel.FieldVerifyAccount:
  39970. v, ok := value.(string)
  39971. if !ok {
  39972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39973. }
  39974. m.SetVerifyAccount(v)
  39975. return nil
  39976. }
  39977. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  39978. }
  39979. // AddedFields returns all numeric fields that were incremented/decremented during
  39980. // this mutation.
  39981. func (m *WhatsappChannelMutation) AddedFields() []string {
  39982. var fields []string
  39983. if m.addstatus != nil {
  39984. fields = append(fields, whatsappchannel.FieldStatus)
  39985. }
  39986. if m.addwaba_id != nil {
  39987. fields = append(fields, whatsappchannel.FieldWabaID)
  39988. }
  39989. if m.addbusiness_id != nil {
  39990. fields = append(fields, whatsappchannel.FieldBusinessID)
  39991. }
  39992. if m.addorganization_id != nil {
  39993. fields = append(fields, whatsappchannel.FieldOrganizationID)
  39994. }
  39995. return fields
  39996. }
  39997. // AddedField returns the numeric value that was incremented/decremented on a field
  39998. // with the given name. The second boolean return value indicates that this field
  39999. // was not set, or was not defined in the schema.
  40000. func (m *WhatsappChannelMutation) AddedField(name string) (ent.Value, bool) {
  40001. switch name {
  40002. case whatsappchannel.FieldStatus:
  40003. return m.AddedStatus()
  40004. case whatsappchannel.FieldWabaID:
  40005. return m.AddedWabaID()
  40006. case whatsappchannel.FieldBusinessID:
  40007. return m.AddedBusinessID()
  40008. case whatsappchannel.FieldOrganizationID:
  40009. return m.AddedOrganizationID()
  40010. }
  40011. return nil, false
  40012. }
  40013. // AddField adds the value to the field with the given name. It returns an error if
  40014. // the field is not defined in the schema, or if the type mismatched the field
  40015. // type.
  40016. func (m *WhatsappChannelMutation) AddField(name string, value ent.Value) error {
  40017. switch name {
  40018. case whatsappchannel.FieldStatus:
  40019. v, ok := value.(int8)
  40020. if !ok {
  40021. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40022. }
  40023. m.AddStatus(v)
  40024. return nil
  40025. case whatsappchannel.FieldWabaID:
  40026. v, ok := value.(int64)
  40027. if !ok {
  40028. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40029. }
  40030. m.AddWabaID(v)
  40031. return nil
  40032. case whatsappchannel.FieldBusinessID:
  40033. v, ok := value.(int64)
  40034. if !ok {
  40035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40036. }
  40037. m.AddBusinessID(v)
  40038. return nil
  40039. case whatsappchannel.FieldOrganizationID:
  40040. v, ok := value.(int64)
  40041. if !ok {
  40042. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40043. }
  40044. m.AddOrganizationID(v)
  40045. return nil
  40046. }
  40047. return fmt.Errorf("unknown WhatsappChannel numeric field %s", name)
  40048. }
  40049. // ClearedFields returns all nullable fields that were cleared during this
  40050. // mutation.
  40051. func (m *WhatsappChannelMutation) ClearedFields() []string {
  40052. var fields []string
  40053. if m.FieldCleared(whatsappchannel.FieldStatus) {
  40054. fields = append(fields, whatsappchannel.FieldStatus)
  40055. }
  40056. if m.FieldCleared(whatsappchannel.FieldDeletedAt) {
  40057. fields = append(fields, whatsappchannel.FieldDeletedAt)
  40058. }
  40059. if m.FieldCleared(whatsappchannel.FieldAk) {
  40060. fields = append(fields, whatsappchannel.FieldAk)
  40061. }
  40062. if m.FieldCleared(whatsappchannel.FieldWaID) {
  40063. fields = append(fields, whatsappchannel.FieldWaID)
  40064. }
  40065. if m.FieldCleared(whatsappchannel.FieldWaName) {
  40066. fields = append(fields, whatsappchannel.FieldWaName)
  40067. }
  40068. if m.FieldCleared(whatsappchannel.FieldOrganizationID) {
  40069. fields = append(fields, whatsappchannel.FieldOrganizationID)
  40070. }
  40071. return fields
  40072. }
  40073. // FieldCleared returns a boolean indicating if a field with the given name was
  40074. // cleared in this mutation.
  40075. func (m *WhatsappChannelMutation) FieldCleared(name string) bool {
  40076. _, ok := m.clearedFields[name]
  40077. return ok
  40078. }
  40079. // ClearField clears the value of the field with the given name. It returns an
  40080. // error if the field is not defined in the schema.
  40081. func (m *WhatsappChannelMutation) ClearField(name string) error {
  40082. switch name {
  40083. case whatsappchannel.FieldStatus:
  40084. m.ClearStatus()
  40085. return nil
  40086. case whatsappchannel.FieldDeletedAt:
  40087. m.ClearDeletedAt()
  40088. return nil
  40089. case whatsappchannel.FieldAk:
  40090. m.ClearAk()
  40091. return nil
  40092. case whatsappchannel.FieldWaID:
  40093. m.ClearWaID()
  40094. return nil
  40095. case whatsappchannel.FieldWaName:
  40096. m.ClearWaName()
  40097. return nil
  40098. case whatsappchannel.FieldOrganizationID:
  40099. m.ClearOrganizationID()
  40100. return nil
  40101. }
  40102. return fmt.Errorf("unknown WhatsappChannel nullable field %s", name)
  40103. }
  40104. // ResetField resets all changes in the mutation for the field with the given name.
  40105. // It returns an error if the field is not defined in the schema.
  40106. func (m *WhatsappChannelMutation) ResetField(name string) error {
  40107. switch name {
  40108. case whatsappchannel.FieldCreatedAt:
  40109. m.ResetCreatedAt()
  40110. return nil
  40111. case whatsappchannel.FieldUpdatedAt:
  40112. m.ResetUpdatedAt()
  40113. return nil
  40114. case whatsappchannel.FieldStatus:
  40115. m.ResetStatus()
  40116. return nil
  40117. case whatsappchannel.FieldDeletedAt:
  40118. m.ResetDeletedAt()
  40119. return nil
  40120. case whatsappchannel.FieldAk:
  40121. m.ResetAk()
  40122. return nil
  40123. case whatsappchannel.FieldSk:
  40124. m.ResetSk()
  40125. return nil
  40126. case whatsappchannel.FieldWaID:
  40127. m.ResetWaID()
  40128. return nil
  40129. case whatsappchannel.FieldWaName:
  40130. m.ResetWaName()
  40131. return nil
  40132. case whatsappchannel.FieldWabaID:
  40133. m.ResetWabaID()
  40134. return nil
  40135. case whatsappchannel.FieldBusinessID:
  40136. m.ResetBusinessID()
  40137. return nil
  40138. case whatsappchannel.FieldOrganizationID:
  40139. m.ResetOrganizationID()
  40140. return nil
  40141. case whatsappchannel.FieldVerifyAccount:
  40142. m.ResetVerifyAccount()
  40143. return nil
  40144. }
  40145. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  40146. }
  40147. // AddedEdges returns all edge names that were set/added in this mutation.
  40148. func (m *WhatsappChannelMutation) AddedEdges() []string {
  40149. edges := make([]string, 0, 0)
  40150. return edges
  40151. }
  40152. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  40153. // name in this mutation.
  40154. func (m *WhatsappChannelMutation) AddedIDs(name string) []ent.Value {
  40155. return nil
  40156. }
  40157. // RemovedEdges returns all edge names that were removed in this mutation.
  40158. func (m *WhatsappChannelMutation) RemovedEdges() []string {
  40159. edges := make([]string, 0, 0)
  40160. return edges
  40161. }
  40162. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  40163. // the given name in this mutation.
  40164. func (m *WhatsappChannelMutation) RemovedIDs(name string) []ent.Value {
  40165. return nil
  40166. }
  40167. // ClearedEdges returns all edge names that were cleared in this mutation.
  40168. func (m *WhatsappChannelMutation) ClearedEdges() []string {
  40169. edges := make([]string, 0, 0)
  40170. return edges
  40171. }
  40172. // EdgeCleared returns a boolean which indicates if the edge with the given name
  40173. // was cleared in this mutation.
  40174. func (m *WhatsappChannelMutation) EdgeCleared(name string) bool {
  40175. return false
  40176. }
  40177. // ClearEdge clears the value of the edge with the given name. It returns an error
  40178. // if that edge is not defined in the schema.
  40179. func (m *WhatsappChannelMutation) ClearEdge(name string) error {
  40180. return fmt.Errorf("unknown WhatsappChannel unique edge %s", name)
  40181. }
  40182. // ResetEdge resets all changes to the edge with the given name in this mutation.
  40183. // It returns an error if the edge is not defined in the schema.
  40184. func (m *WhatsappChannelMutation) ResetEdge(name string) error {
  40185. return fmt.Errorf("unknown WhatsappChannel edge %s", name)
  40186. }
  40187. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  40188. type WorkExperienceMutation struct {
  40189. config
  40190. op Op
  40191. typ string
  40192. id *uint64
  40193. created_at *time.Time
  40194. updated_at *time.Time
  40195. deleted_at *time.Time
  40196. start_date *time.Time
  40197. end_date *time.Time
  40198. company *string
  40199. experience *string
  40200. organization_id *uint64
  40201. addorganization_id *int64
  40202. clearedFields map[string]struct{}
  40203. employee *uint64
  40204. clearedemployee bool
  40205. done bool
  40206. oldValue func(context.Context) (*WorkExperience, error)
  40207. predicates []predicate.WorkExperience
  40208. }
  40209. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  40210. // workexperienceOption allows management of the mutation configuration using functional options.
  40211. type workexperienceOption func(*WorkExperienceMutation)
  40212. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  40213. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  40214. m := &WorkExperienceMutation{
  40215. config: c,
  40216. op: op,
  40217. typ: TypeWorkExperience,
  40218. clearedFields: make(map[string]struct{}),
  40219. }
  40220. for _, opt := range opts {
  40221. opt(m)
  40222. }
  40223. return m
  40224. }
  40225. // withWorkExperienceID sets the ID field of the mutation.
  40226. func withWorkExperienceID(id uint64) workexperienceOption {
  40227. return func(m *WorkExperienceMutation) {
  40228. var (
  40229. err error
  40230. once sync.Once
  40231. value *WorkExperience
  40232. )
  40233. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  40234. once.Do(func() {
  40235. if m.done {
  40236. err = errors.New("querying old values post mutation is not allowed")
  40237. } else {
  40238. value, err = m.Client().WorkExperience.Get(ctx, id)
  40239. }
  40240. })
  40241. return value, err
  40242. }
  40243. m.id = &id
  40244. }
  40245. }
  40246. // withWorkExperience sets the old WorkExperience of the mutation.
  40247. func withWorkExperience(node *WorkExperience) workexperienceOption {
  40248. return func(m *WorkExperienceMutation) {
  40249. m.oldValue = func(context.Context) (*WorkExperience, error) {
  40250. return node, nil
  40251. }
  40252. m.id = &node.ID
  40253. }
  40254. }
  40255. // Client returns a new `ent.Client` from the mutation. If the mutation was
  40256. // executed in a transaction (ent.Tx), a transactional client is returned.
  40257. func (m WorkExperienceMutation) Client() *Client {
  40258. client := &Client{config: m.config}
  40259. client.init()
  40260. return client
  40261. }
  40262. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  40263. // it returns an error otherwise.
  40264. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  40265. if _, ok := m.driver.(*txDriver); !ok {
  40266. return nil, errors.New("ent: mutation is not running in a transaction")
  40267. }
  40268. tx := &Tx{config: m.config}
  40269. tx.init()
  40270. return tx, nil
  40271. }
  40272. // SetID sets the value of the id field. Note that this
  40273. // operation is only accepted on creation of WorkExperience entities.
  40274. func (m *WorkExperienceMutation) SetID(id uint64) {
  40275. m.id = &id
  40276. }
  40277. // ID returns the ID value in the mutation. Note that the ID is only available
  40278. // if it was provided to the builder or after it was returned from the database.
  40279. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  40280. if m.id == nil {
  40281. return
  40282. }
  40283. return *m.id, true
  40284. }
  40285. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  40286. // That means, if the mutation is applied within a transaction with an isolation level such
  40287. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  40288. // or updated by the mutation.
  40289. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  40290. switch {
  40291. case m.op.Is(OpUpdateOne | OpDeleteOne):
  40292. id, exists := m.ID()
  40293. if exists {
  40294. return []uint64{id}, nil
  40295. }
  40296. fallthrough
  40297. case m.op.Is(OpUpdate | OpDelete):
  40298. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  40299. default:
  40300. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  40301. }
  40302. }
  40303. // SetCreatedAt sets the "created_at" field.
  40304. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  40305. m.created_at = &t
  40306. }
  40307. // CreatedAt returns the value of the "created_at" field in the mutation.
  40308. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  40309. v := m.created_at
  40310. if v == nil {
  40311. return
  40312. }
  40313. return *v, true
  40314. }
  40315. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  40316. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  40317. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40318. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  40319. if !m.op.Is(OpUpdateOne) {
  40320. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  40321. }
  40322. if m.id == nil || m.oldValue == nil {
  40323. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  40324. }
  40325. oldValue, err := m.oldValue(ctx)
  40326. if err != nil {
  40327. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  40328. }
  40329. return oldValue.CreatedAt, nil
  40330. }
  40331. // ResetCreatedAt resets all changes to the "created_at" field.
  40332. func (m *WorkExperienceMutation) ResetCreatedAt() {
  40333. m.created_at = nil
  40334. }
  40335. // SetUpdatedAt sets the "updated_at" field.
  40336. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  40337. m.updated_at = &t
  40338. }
  40339. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  40340. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  40341. v := m.updated_at
  40342. if v == nil {
  40343. return
  40344. }
  40345. return *v, true
  40346. }
  40347. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  40348. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  40349. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40350. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  40351. if !m.op.Is(OpUpdateOne) {
  40352. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  40353. }
  40354. if m.id == nil || m.oldValue == nil {
  40355. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  40356. }
  40357. oldValue, err := m.oldValue(ctx)
  40358. if err != nil {
  40359. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  40360. }
  40361. return oldValue.UpdatedAt, nil
  40362. }
  40363. // ResetUpdatedAt resets all changes to the "updated_at" field.
  40364. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  40365. m.updated_at = nil
  40366. }
  40367. // SetDeletedAt sets the "deleted_at" field.
  40368. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  40369. m.deleted_at = &t
  40370. }
  40371. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  40372. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  40373. v := m.deleted_at
  40374. if v == nil {
  40375. return
  40376. }
  40377. return *v, true
  40378. }
  40379. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  40380. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  40381. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40382. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  40383. if !m.op.Is(OpUpdateOne) {
  40384. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  40385. }
  40386. if m.id == nil || m.oldValue == nil {
  40387. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  40388. }
  40389. oldValue, err := m.oldValue(ctx)
  40390. if err != nil {
  40391. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  40392. }
  40393. return oldValue.DeletedAt, nil
  40394. }
  40395. // ClearDeletedAt clears the value of the "deleted_at" field.
  40396. func (m *WorkExperienceMutation) ClearDeletedAt() {
  40397. m.deleted_at = nil
  40398. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  40399. }
  40400. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  40401. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  40402. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  40403. return ok
  40404. }
  40405. // ResetDeletedAt resets all changes to the "deleted_at" field.
  40406. func (m *WorkExperienceMutation) ResetDeletedAt() {
  40407. m.deleted_at = nil
  40408. delete(m.clearedFields, workexperience.FieldDeletedAt)
  40409. }
  40410. // SetEmployeeID sets the "employee_id" field.
  40411. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  40412. m.employee = &u
  40413. }
  40414. // EmployeeID returns the value of the "employee_id" field in the mutation.
  40415. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  40416. v := m.employee
  40417. if v == nil {
  40418. return
  40419. }
  40420. return *v, true
  40421. }
  40422. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  40423. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  40424. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40425. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  40426. if !m.op.Is(OpUpdateOne) {
  40427. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  40428. }
  40429. if m.id == nil || m.oldValue == nil {
  40430. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  40431. }
  40432. oldValue, err := m.oldValue(ctx)
  40433. if err != nil {
  40434. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  40435. }
  40436. return oldValue.EmployeeID, nil
  40437. }
  40438. // ResetEmployeeID resets all changes to the "employee_id" field.
  40439. func (m *WorkExperienceMutation) ResetEmployeeID() {
  40440. m.employee = nil
  40441. }
  40442. // SetStartDate sets the "start_date" field.
  40443. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  40444. m.start_date = &t
  40445. }
  40446. // StartDate returns the value of the "start_date" field in the mutation.
  40447. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  40448. v := m.start_date
  40449. if v == nil {
  40450. return
  40451. }
  40452. return *v, true
  40453. }
  40454. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  40455. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  40456. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40457. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  40458. if !m.op.Is(OpUpdateOne) {
  40459. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  40460. }
  40461. if m.id == nil || m.oldValue == nil {
  40462. return v, errors.New("OldStartDate requires an ID field in the mutation")
  40463. }
  40464. oldValue, err := m.oldValue(ctx)
  40465. if err != nil {
  40466. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  40467. }
  40468. return oldValue.StartDate, nil
  40469. }
  40470. // ResetStartDate resets all changes to the "start_date" field.
  40471. func (m *WorkExperienceMutation) ResetStartDate() {
  40472. m.start_date = nil
  40473. }
  40474. // SetEndDate sets the "end_date" field.
  40475. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  40476. m.end_date = &t
  40477. }
  40478. // EndDate returns the value of the "end_date" field in the mutation.
  40479. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  40480. v := m.end_date
  40481. if v == nil {
  40482. return
  40483. }
  40484. return *v, true
  40485. }
  40486. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  40487. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  40488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40489. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  40490. if !m.op.Is(OpUpdateOne) {
  40491. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  40492. }
  40493. if m.id == nil || m.oldValue == nil {
  40494. return v, errors.New("OldEndDate requires an ID field in the mutation")
  40495. }
  40496. oldValue, err := m.oldValue(ctx)
  40497. if err != nil {
  40498. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  40499. }
  40500. return oldValue.EndDate, nil
  40501. }
  40502. // ResetEndDate resets all changes to the "end_date" field.
  40503. func (m *WorkExperienceMutation) ResetEndDate() {
  40504. m.end_date = nil
  40505. }
  40506. // SetCompany sets the "company" field.
  40507. func (m *WorkExperienceMutation) SetCompany(s string) {
  40508. m.company = &s
  40509. }
  40510. // Company returns the value of the "company" field in the mutation.
  40511. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  40512. v := m.company
  40513. if v == nil {
  40514. return
  40515. }
  40516. return *v, true
  40517. }
  40518. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  40519. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  40520. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40521. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  40522. if !m.op.Is(OpUpdateOne) {
  40523. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  40524. }
  40525. if m.id == nil || m.oldValue == nil {
  40526. return v, errors.New("OldCompany requires an ID field in the mutation")
  40527. }
  40528. oldValue, err := m.oldValue(ctx)
  40529. if err != nil {
  40530. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  40531. }
  40532. return oldValue.Company, nil
  40533. }
  40534. // ResetCompany resets all changes to the "company" field.
  40535. func (m *WorkExperienceMutation) ResetCompany() {
  40536. m.company = nil
  40537. }
  40538. // SetExperience sets the "experience" field.
  40539. func (m *WorkExperienceMutation) SetExperience(s string) {
  40540. m.experience = &s
  40541. }
  40542. // Experience returns the value of the "experience" field in the mutation.
  40543. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  40544. v := m.experience
  40545. if v == nil {
  40546. return
  40547. }
  40548. return *v, true
  40549. }
  40550. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  40551. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  40552. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40553. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  40554. if !m.op.Is(OpUpdateOne) {
  40555. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  40556. }
  40557. if m.id == nil || m.oldValue == nil {
  40558. return v, errors.New("OldExperience requires an ID field in the mutation")
  40559. }
  40560. oldValue, err := m.oldValue(ctx)
  40561. if err != nil {
  40562. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  40563. }
  40564. return oldValue.Experience, nil
  40565. }
  40566. // ResetExperience resets all changes to the "experience" field.
  40567. func (m *WorkExperienceMutation) ResetExperience() {
  40568. m.experience = nil
  40569. }
  40570. // SetOrganizationID sets the "organization_id" field.
  40571. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  40572. m.organization_id = &u
  40573. m.addorganization_id = nil
  40574. }
  40575. // OrganizationID returns the value of the "organization_id" field in the mutation.
  40576. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  40577. v := m.organization_id
  40578. if v == nil {
  40579. return
  40580. }
  40581. return *v, true
  40582. }
  40583. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  40584. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  40585. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40586. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  40587. if !m.op.Is(OpUpdateOne) {
  40588. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  40589. }
  40590. if m.id == nil || m.oldValue == nil {
  40591. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  40592. }
  40593. oldValue, err := m.oldValue(ctx)
  40594. if err != nil {
  40595. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  40596. }
  40597. return oldValue.OrganizationID, nil
  40598. }
  40599. // AddOrganizationID adds u to the "organization_id" field.
  40600. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  40601. if m.addorganization_id != nil {
  40602. *m.addorganization_id += u
  40603. } else {
  40604. m.addorganization_id = &u
  40605. }
  40606. }
  40607. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  40608. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  40609. v := m.addorganization_id
  40610. if v == nil {
  40611. return
  40612. }
  40613. return *v, true
  40614. }
  40615. // ResetOrganizationID resets all changes to the "organization_id" field.
  40616. func (m *WorkExperienceMutation) ResetOrganizationID() {
  40617. m.organization_id = nil
  40618. m.addorganization_id = nil
  40619. }
  40620. // ClearEmployee clears the "employee" edge to the Employee entity.
  40621. func (m *WorkExperienceMutation) ClearEmployee() {
  40622. m.clearedemployee = true
  40623. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  40624. }
  40625. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  40626. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  40627. return m.clearedemployee
  40628. }
  40629. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  40630. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  40631. // EmployeeID instead. It exists only for internal usage by the builders.
  40632. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  40633. if id := m.employee; id != nil {
  40634. ids = append(ids, *id)
  40635. }
  40636. return
  40637. }
  40638. // ResetEmployee resets all changes to the "employee" edge.
  40639. func (m *WorkExperienceMutation) ResetEmployee() {
  40640. m.employee = nil
  40641. m.clearedemployee = false
  40642. }
  40643. // Where appends a list predicates to the WorkExperienceMutation builder.
  40644. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  40645. m.predicates = append(m.predicates, ps...)
  40646. }
  40647. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  40648. // users can use type-assertion to append predicates that do not depend on any generated package.
  40649. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  40650. p := make([]predicate.WorkExperience, len(ps))
  40651. for i := range ps {
  40652. p[i] = ps[i]
  40653. }
  40654. m.Where(p...)
  40655. }
  40656. // Op returns the operation name.
  40657. func (m *WorkExperienceMutation) Op() Op {
  40658. return m.op
  40659. }
  40660. // SetOp allows setting the mutation operation.
  40661. func (m *WorkExperienceMutation) SetOp(op Op) {
  40662. m.op = op
  40663. }
  40664. // Type returns the node type of this mutation (WorkExperience).
  40665. func (m *WorkExperienceMutation) Type() string {
  40666. return m.typ
  40667. }
  40668. // Fields returns all fields that were changed during this mutation. Note that in
  40669. // order to get all numeric fields that were incremented/decremented, call
  40670. // AddedFields().
  40671. func (m *WorkExperienceMutation) Fields() []string {
  40672. fields := make([]string, 0, 9)
  40673. if m.created_at != nil {
  40674. fields = append(fields, workexperience.FieldCreatedAt)
  40675. }
  40676. if m.updated_at != nil {
  40677. fields = append(fields, workexperience.FieldUpdatedAt)
  40678. }
  40679. if m.deleted_at != nil {
  40680. fields = append(fields, workexperience.FieldDeletedAt)
  40681. }
  40682. if m.employee != nil {
  40683. fields = append(fields, workexperience.FieldEmployeeID)
  40684. }
  40685. if m.start_date != nil {
  40686. fields = append(fields, workexperience.FieldStartDate)
  40687. }
  40688. if m.end_date != nil {
  40689. fields = append(fields, workexperience.FieldEndDate)
  40690. }
  40691. if m.company != nil {
  40692. fields = append(fields, workexperience.FieldCompany)
  40693. }
  40694. if m.experience != nil {
  40695. fields = append(fields, workexperience.FieldExperience)
  40696. }
  40697. if m.organization_id != nil {
  40698. fields = append(fields, workexperience.FieldOrganizationID)
  40699. }
  40700. return fields
  40701. }
  40702. // Field returns the value of a field with the given name. The second boolean
  40703. // return value indicates that this field was not set, or was not defined in the
  40704. // schema.
  40705. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  40706. switch name {
  40707. case workexperience.FieldCreatedAt:
  40708. return m.CreatedAt()
  40709. case workexperience.FieldUpdatedAt:
  40710. return m.UpdatedAt()
  40711. case workexperience.FieldDeletedAt:
  40712. return m.DeletedAt()
  40713. case workexperience.FieldEmployeeID:
  40714. return m.EmployeeID()
  40715. case workexperience.FieldStartDate:
  40716. return m.StartDate()
  40717. case workexperience.FieldEndDate:
  40718. return m.EndDate()
  40719. case workexperience.FieldCompany:
  40720. return m.Company()
  40721. case workexperience.FieldExperience:
  40722. return m.Experience()
  40723. case workexperience.FieldOrganizationID:
  40724. return m.OrganizationID()
  40725. }
  40726. return nil, false
  40727. }
  40728. // OldField returns the old value of the field from the database. An error is
  40729. // returned if the mutation operation is not UpdateOne, or the query to the
  40730. // database failed.
  40731. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  40732. switch name {
  40733. case workexperience.FieldCreatedAt:
  40734. return m.OldCreatedAt(ctx)
  40735. case workexperience.FieldUpdatedAt:
  40736. return m.OldUpdatedAt(ctx)
  40737. case workexperience.FieldDeletedAt:
  40738. return m.OldDeletedAt(ctx)
  40739. case workexperience.FieldEmployeeID:
  40740. return m.OldEmployeeID(ctx)
  40741. case workexperience.FieldStartDate:
  40742. return m.OldStartDate(ctx)
  40743. case workexperience.FieldEndDate:
  40744. return m.OldEndDate(ctx)
  40745. case workexperience.FieldCompany:
  40746. return m.OldCompany(ctx)
  40747. case workexperience.FieldExperience:
  40748. return m.OldExperience(ctx)
  40749. case workexperience.FieldOrganizationID:
  40750. return m.OldOrganizationID(ctx)
  40751. }
  40752. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  40753. }
  40754. // SetField sets the value of a field with the given name. It returns an error if
  40755. // the field is not defined in the schema, or if the type mismatched the field
  40756. // type.
  40757. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  40758. switch name {
  40759. case workexperience.FieldCreatedAt:
  40760. v, ok := value.(time.Time)
  40761. if !ok {
  40762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40763. }
  40764. m.SetCreatedAt(v)
  40765. return nil
  40766. case workexperience.FieldUpdatedAt:
  40767. v, ok := value.(time.Time)
  40768. if !ok {
  40769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40770. }
  40771. m.SetUpdatedAt(v)
  40772. return nil
  40773. case workexperience.FieldDeletedAt:
  40774. v, ok := value.(time.Time)
  40775. if !ok {
  40776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40777. }
  40778. m.SetDeletedAt(v)
  40779. return nil
  40780. case workexperience.FieldEmployeeID:
  40781. v, ok := value.(uint64)
  40782. if !ok {
  40783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40784. }
  40785. m.SetEmployeeID(v)
  40786. return nil
  40787. case workexperience.FieldStartDate:
  40788. v, ok := value.(time.Time)
  40789. if !ok {
  40790. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40791. }
  40792. m.SetStartDate(v)
  40793. return nil
  40794. case workexperience.FieldEndDate:
  40795. v, ok := value.(time.Time)
  40796. if !ok {
  40797. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40798. }
  40799. m.SetEndDate(v)
  40800. return nil
  40801. case workexperience.FieldCompany:
  40802. v, ok := value.(string)
  40803. if !ok {
  40804. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40805. }
  40806. m.SetCompany(v)
  40807. return nil
  40808. case workexperience.FieldExperience:
  40809. v, ok := value.(string)
  40810. if !ok {
  40811. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40812. }
  40813. m.SetExperience(v)
  40814. return nil
  40815. case workexperience.FieldOrganizationID:
  40816. v, ok := value.(uint64)
  40817. if !ok {
  40818. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40819. }
  40820. m.SetOrganizationID(v)
  40821. return nil
  40822. }
  40823. return fmt.Errorf("unknown WorkExperience field %s", name)
  40824. }
  40825. // AddedFields returns all numeric fields that were incremented/decremented during
  40826. // this mutation.
  40827. func (m *WorkExperienceMutation) AddedFields() []string {
  40828. var fields []string
  40829. if m.addorganization_id != nil {
  40830. fields = append(fields, workexperience.FieldOrganizationID)
  40831. }
  40832. return fields
  40833. }
  40834. // AddedField returns the numeric value that was incremented/decremented on a field
  40835. // with the given name. The second boolean return value indicates that this field
  40836. // was not set, or was not defined in the schema.
  40837. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  40838. switch name {
  40839. case workexperience.FieldOrganizationID:
  40840. return m.AddedOrganizationID()
  40841. }
  40842. return nil, false
  40843. }
  40844. // AddField adds the value to the field with the given name. It returns an error if
  40845. // the field is not defined in the schema, or if the type mismatched the field
  40846. // type.
  40847. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  40848. switch name {
  40849. case workexperience.FieldOrganizationID:
  40850. v, ok := value.(int64)
  40851. if !ok {
  40852. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40853. }
  40854. m.AddOrganizationID(v)
  40855. return nil
  40856. }
  40857. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  40858. }
  40859. // ClearedFields returns all nullable fields that were cleared during this
  40860. // mutation.
  40861. func (m *WorkExperienceMutation) ClearedFields() []string {
  40862. var fields []string
  40863. if m.FieldCleared(workexperience.FieldDeletedAt) {
  40864. fields = append(fields, workexperience.FieldDeletedAt)
  40865. }
  40866. return fields
  40867. }
  40868. // FieldCleared returns a boolean indicating if a field with the given name was
  40869. // cleared in this mutation.
  40870. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  40871. _, ok := m.clearedFields[name]
  40872. return ok
  40873. }
  40874. // ClearField clears the value of the field with the given name. It returns an
  40875. // error if the field is not defined in the schema.
  40876. func (m *WorkExperienceMutation) ClearField(name string) error {
  40877. switch name {
  40878. case workexperience.FieldDeletedAt:
  40879. m.ClearDeletedAt()
  40880. return nil
  40881. }
  40882. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  40883. }
  40884. // ResetField resets all changes in the mutation for the field with the given name.
  40885. // It returns an error if the field is not defined in the schema.
  40886. func (m *WorkExperienceMutation) ResetField(name string) error {
  40887. switch name {
  40888. case workexperience.FieldCreatedAt:
  40889. m.ResetCreatedAt()
  40890. return nil
  40891. case workexperience.FieldUpdatedAt:
  40892. m.ResetUpdatedAt()
  40893. return nil
  40894. case workexperience.FieldDeletedAt:
  40895. m.ResetDeletedAt()
  40896. return nil
  40897. case workexperience.FieldEmployeeID:
  40898. m.ResetEmployeeID()
  40899. return nil
  40900. case workexperience.FieldStartDate:
  40901. m.ResetStartDate()
  40902. return nil
  40903. case workexperience.FieldEndDate:
  40904. m.ResetEndDate()
  40905. return nil
  40906. case workexperience.FieldCompany:
  40907. m.ResetCompany()
  40908. return nil
  40909. case workexperience.FieldExperience:
  40910. m.ResetExperience()
  40911. return nil
  40912. case workexperience.FieldOrganizationID:
  40913. m.ResetOrganizationID()
  40914. return nil
  40915. }
  40916. return fmt.Errorf("unknown WorkExperience field %s", name)
  40917. }
  40918. // AddedEdges returns all edge names that were set/added in this mutation.
  40919. func (m *WorkExperienceMutation) AddedEdges() []string {
  40920. edges := make([]string, 0, 1)
  40921. if m.employee != nil {
  40922. edges = append(edges, workexperience.EdgeEmployee)
  40923. }
  40924. return edges
  40925. }
  40926. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  40927. // name in this mutation.
  40928. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  40929. switch name {
  40930. case workexperience.EdgeEmployee:
  40931. if id := m.employee; id != nil {
  40932. return []ent.Value{*id}
  40933. }
  40934. }
  40935. return nil
  40936. }
  40937. // RemovedEdges returns all edge names that were removed in this mutation.
  40938. func (m *WorkExperienceMutation) RemovedEdges() []string {
  40939. edges := make([]string, 0, 1)
  40940. return edges
  40941. }
  40942. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  40943. // the given name in this mutation.
  40944. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  40945. return nil
  40946. }
  40947. // ClearedEdges returns all edge names that were cleared in this mutation.
  40948. func (m *WorkExperienceMutation) ClearedEdges() []string {
  40949. edges := make([]string, 0, 1)
  40950. if m.clearedemployee {
  40951. edges = append(edges, workexperience.EdgeEmployee)
  40952. }
  40953. return edges
  40954. }
  40955. // EdgeCleared returns a boolean which indicates if the edge with the given name
  40956. // was cleared in this mutation.
  40957. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  40958. switch name {
  40959. case workexperience.EdgeEmployee:
  40960. return m.clearedemployee
  40961. }
  40962. return false
  40963. }
  40964. // ClearEdge clears the value of the edge with the given name. It returns an error
  40965. // if that edge is not defined in the schema.
  40966. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  40967. switch name {
  40968. case workexperience.EdgeEmployee:
  40969. m.ClearEmployee()
  40970. return nil
  40971. }
  40972. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  40973. }
  40974. // ResetEdge resets all changes to the edge with the given name in this mutation.
  40975. // It returns an error if the edge is not defined in the schema.
  40976. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  40977. switch name {
  40978. case workexperience.EdgeEmployee:
  40979. m.ResetEmployee()
  40980. return nil
  40981. }
  40982. return fmt.Errorf("unknown WorkExperience edge %s", name)
  40983. }
  40984. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  40985. type WpChatroomMutation struct {
  40986. config
  40987. op Op
  40988. typ string
  40989. id *uint64
  40990. created_at *time.Time
  40991. updated_at *time.Time
  40992. status *uint8
  40993. addstatus *int8
  40994. wx_wxid *string
  40995. chatroom_id *string
  40996. nickname *string
  40997. owner *string
  40998. avatar *string
  40999. member_list *[]string
  41000. appendmember_list []string
  41001. clearedFields map[string]struct{}
  41002. done bool
  41003. oldValue func(context.Context) (*WpChatroom, error)
  41004. predicates []predicate.WpChatroom
  41005. }
  41006. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  41007. // wpchatroomOption allows management of the mutation configuration using functional options.
  41008. type wpchatroomOption func(*WpChatroomMutation)
  41009. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  41010. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  41011. m := &WpChatroomMutation{
  41012. config: c,
  41013. op: op,
  41014. typ: TypeWpChatroom,
  41015. clearedFields: make(map[string]struct{}),
  41016. }
  41017. for _, opt := range opts {
  41018. opt(m)
  41019. }
  41020. return m
  41021. }
  41022. // withWpChatroomID sets the ID field of the mutation.
  41023. func withWpChatroomID(id uint64) wpchatroomOption {
  41024. return func(m *WpChatroomMutation) {
  41025. var (
  41026. err error
  41027. once sync.Once
  41028. value *WpChatroom
  41029. )
  41030. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  41031. once.Do(func() {
  41032. if m.done {
  41033. err = errors.New("querying old values post mutation is not allowed")
  41034. } else {
  41035. value, err = m.Client().WpChatroom.Get(ctx, id)
  41036. }
  41037. })
  41038. return value, err
  41039. }
  41040. m.id = &id
  41041. }
  41042. }
  41043. // withWpChatroom sets the old WpChatroom of the mutation.
  41044. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  41045. return func(m *WpChatroomMutation) {
  41046. m.oldValue = func(context.Context) (*WpChatroom, error) {
  41047. return node, nil
  41048. }
  41049. m.id = &node.ID
  41050. }
  41051. }
  41052. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41053. // executed in a transaction (ent.Tx), a transactional client is returned.
  41054. func (m WpChatroomMutation) Client() *Client {
  41055. client := &Client{config: m.config}
  41056. client.init()
  41057. return client
  41058. }
  41059. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41060. // it returns an error otherwise.
  41061. func (m WpChatroomMutation) Tx() (*Tx, error) {
  41062. if _, ok := m.driver.(*txDriver); !ok {
  41063. return nil, errors.New("ent: mutation is not running in a transaction")
  41064. }
  41065. tx := &Tx{config: m.config}
  41066. tx.init()
  41067. return tx, nil
  41068. }
  41069. // SetID sets the value of the id field. Note that this
  41070. // operation is only accepted on creation of WpChatroom entities.
  41071. func (m *WpChatroomMutation) SetID(id uint64) {
  41072. m.id = &id
  41073. }
  41074. // ID returns the ID value in the mutation. Note that the ID is only available
  41075. // if it was provided to the builder or after it was returned from the database.
  41076. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  41077. if m.id == nil {
  41078. return
  41079. }
  41080. return *m.id, true
  41081. }
  41082. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41083. // That means, if the mutation is applied within a transaction with an isolation level such
  41084. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41085. // or updated by the mutation.
  41086. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  41087. switch {
  41088. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41089. id, exists := m.ID()
  41090. if exists {
  41091. return []uint64{id}, nil
  41092. }
  41093. fallthrough
  41094. case m.op.Is(OpUpdate | OpDelete):
  41095. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  41096. default:
  41097. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41098. }
  41099. }
  41100. // SetCreatedAt sets the "created_at" field.
  41101. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  41102. m.created_at = &t
  41103. }
  41104. // CreatedAt returns the value of the "created_at" field in the mutation.
  41105. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  41106. v := m.created_at
  41107. if v == nil {
  41108. return
  41109. }
  41110. return *v, true
  41111. }
  41112. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  41113. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  41114. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41115. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  41116. if !m.op.Is(OpUpdateOne) {
  41117. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  41118. }
  41119. if m.id == nil || m.oldValue == nil {
  41120. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  41121. }
  41122. oldValue, err := m.oldValue(ctx)
  41123. if err != nil {
  41124. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  41125. }
  41126. return oldValue.CreatedAt, nil
  41127. }
  41128. // ResetCreatedAt resets all changes to the "created_at" field.
  41129. func (m *WpChatroomMutation) ResetCreatedAt() {
  41130. m.created_at = nil
  41131. }
  41132. // SetUpdatedAt sets the "updated_at" field.
  41133. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  41134. m.updated_at = &t
  41135. }
  41136. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  41137. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  41138. v := m.updated_at
  41139. if v == nil {
  41140. return
  41141. }
  41142. return *v, true
  41143. }
  41144. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  41145. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  41146. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41147. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  41148. if !m.op.Is(OpUpdateOne) {
  41149. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  41150. }
  41151. if m.id == nil || m.oldValue == nil {
  41152. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  41153. }
  41154. oldValue, err := m.oldValue(ctx)
  41155. if err != nil {
  41156. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  41157. }
  41158. return oldValue.UpdatedAt, nil
  41159. }
  41160. // ResetUpdatedAt resets all changes to the "updated_at" field.
  41161. func (m *WpChatroomMutation) ResetUpdatedAt() {
  41162. m.updated_at = nil
  41163. }
  41164. // SetStatus sets the "status" field.
  41165. func (m *WpChatroomMutation) SetStatus(u uint8) {
  41166. m.status = &u
  41167. m.addstatus = nil
  41168. }
  41169. // Status returns the value of the "status" field in the mutation.
  41170. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  41171. v := m.status
  41172. if v == nil {
  41173. return
  41174. }
  41175. return *v, true
  41176. }
  41177. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  41178. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  41179. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41180. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  41181. if !m.op.Is(OpUpdateOne) {
  41182. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  41183. }
  41184. if m.id == nil || m.oldValue == nil {
  41185. return v, errors.New("OldStatus requires an ID field in the mutation")
  41186. }
  41187. oldValue, err := m.oldValue(ctx)
  41188. if err != nil {
  41189. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  41190. }
  41191. return oldValue.Status, nil
  41192. }
  41193. // AddStatus adds u to the "status" field.
  41194. func (m *WpChatroomMutation) AddStatus(u int8) {
  41195. if m.addstatus != nil {
  41196. *m.addstatus += u
  41197. } else {
  41198. m.addstatus = &u
  41199. }
  41200. }
  41201. // AddedStatus returns the value that was added to the "status" field in this mutation.
  41202. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  41203. v := m.addstatus
  41204. if v == nil {
  41205. return
  41206. }
  41207. return *v, true
  41208. }
  41209. // ClearStatus clears the value of the "status" field.
  41210. func (m *WpChatroomMutation) ClearStatus() {
  41211. m.status = nil
  41212. m.addstatus = nil
  41213. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  41214. }
  41215. // StatusCleared returns if the "status" field was cleared in this mutation.
  41216. func (m *WpChatroomMutation) StatusCleared() bool {
  41217. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  41218. return ok
  41219. }
  41220. // ResetStatus resets all changes to the "status" field.
  41221. func (m *WpChatroomMutation) ResetStatus() {
  41222. m.status = nil
  41223. m.addstatus = nil
  41224. delete(m.clearedFields, wpchatroom.FieldStatus)
  41225. }
  41226. // SetWxWxid sets the "wx_wxid" field.
  41227. func (m *WpChatroomMutation) SetWxWxid(s string) {
  41228. m.wx_wxid = &s
  41229. }
  41230. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  41231. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  41232. v := m.wx_wxid
  41233. if v == nil {
  41234. return
  41235. }
  41236. return *v, true
  41237. }
  41238. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  41239. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  41240. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41241. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  41242. if !m.op.Is(OpUpdateOne) {
  41243. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  41244. }
  41245. if m.id == nil || m.oldValue == nil {
  41246. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  41247. }
  41248. oldValue, err := m.oldValue(ctx)
  41249. if err != nil {
  41250. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  41251. }
  41252. return oldValue.WxWxid, nil
  41253. }
  41254. // ResetWxWxid resets all changes to the "wx_wxid" field.
  41255. func (m *WpChatroomMutation) ResetWxWxid() {
  41256. m.wx_wxid = nil
  41257. }
  41258. // SetChatroomID sets the "chatroom_id" field.
  41259. func (m *WpChatroomMutation) SetChatroomID(s string) {
  41260. m.chatroom_id = &s
  41261. }
  41262. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  41263. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  41264. v := m.chatroom_id
  41265. if v == nil {
  41266. return
  41267. }
  41268. return *v, true
  41269. }
  41270. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  41271. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  41272. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41273. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  41274. if !m.op.Is(OpUpdateOne) {
  41275. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  41276. }
  41277. if m.id == nil || m.oldValue == nil {
  41278. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  41279. }
  41280. oldValue, err := m.oldValue(ctx)
  41281. if err != nil {
  41282. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  41283. }
  41284. return oldValue.ChatroomID, nil
  41285. }
  41286. // ResetChatroomID resets all changes to the "chatroom_id" field.
  41287. func (m *WpChatroomMutation) ResetChatroomID() {
  41288. m.chatroom_id = nil
  41289. }
  41290. // SetNickname sets the "nickname" field.
  41291. func (m *WpChatroomMutation) SetNickname(s string) {
  41292. m.nickname = &s
  41293. }
  41294. // Nickname returns the value of the "nickname" field in the mutation.
  41295. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  41296. v := m.nickname
  41297. if v == nil {
  41298. return
  41299. }
  41300. return *v, true
  41301. }
  41302. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  41303. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  41304. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41305. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  41306. if !m.op.Is(OpUpdateOne) {
  41307. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  41308. }
  41309. if m.id == nil || m.oldValue == nil {
  41310. return v, errors.New("OldNickname requires an ID field in the mutation")
  41311. }
  41312. oldValue, err := m.oldValue(ctx)
  41313. if err != nil {
  41314. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  41315. }
  41316. return oldValue.Nickname, nil
  41317. }
  41318. // ResetNickname resets all changes to the "nickname" field.
  41319. func (m *WpChatroomMutation) ResetNickname() {
  41320. m.nickname = nil
  41321. }
  41322. // SetOwner sets the "owner" field.
  41323. func (m *WpChatroomMutation) SetOwner(s string) {
  41324. m.owner = &s
  41325. }
  41326. // Owner returns the value of the "owner" field in the mutation.
  41327. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  41328. v := m.owner
  41329. if v == nil {
  41330. return
  41331. }
  41332. return *v, true
  41333. }
  41334. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  41335. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  41336. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41337. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  41338. if !m.op.Is(OpUpdateOne) {
  41339. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  41340. }
  41341. if m.id == nil || m.oldValue == nil {
  41342. return v, errors.New("OldOwner requires an ID field in the mutation")
  41343. }
  41344. oldValue, err := m.oldValue(ctx)
  41345. if err != nil {
  41346. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  41347. }
  41348. return oldValue.Owner, nil
  41349. }
  41350. // ResetOwner resets all changes to the "owner" field.
  41351. func (m *WpChatroomMutation) ResetOwner() {
  41352. m.owner = nil
  41353. }
  41354. // SetAvatar sets the "avatar" field.
  41355. func (m *WpChatroomMutation) SetAvatar(s string) {
  41356. m.avatar = &s
  41357. }
  41358. // Avatar returns the value of the "avatar" field in the mutation.
  41359. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  41360. v := m.avatar
  41361. if v == nil {
  41362. return
  41363. }
  41364. return *v, true
  41365. }
  41366. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  41367. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  41368. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41369. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  41370. if !m.op.Is(OpUpdateOne) {
  41371. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  41372. }
  41373. if m.id == nil || m.oldValue == nil {
  41374. return v, errors.New("OldAvatar requires an ID field in the mutation")
  41375. }
  41376. oldValue, err := m.oldValue(ctx)
  41377. if err != nil {
  41378. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  41379. }
  41380. return oldValue.Avatar, nil
  41381. }
  41382. // ResetAvatar resets all changes to the "avatar" field.
  41383. func (m *WpChatroomMutation) ResetAvatar() {
  41384. m.avatar = nil
  41385. }
  41386. // SetMemberList sets the "member_list" field.
  41387. func (m *WpChatroomMutation) SetMemberList(s []string) {
  41388. m.member_list = &s
  41389. m.appendmember_list = nil
  41390. }
  41391. // MemberList returns the value of the "member_list" field in the mutation.
  41392. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  41393. v := m.member_list
  41394. if v == nil {
  41395. return
  41396. }
  41397. return *v, true
  41398. }
  41399. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  41400. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  41401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41402. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  41403. if !m.op.Is(OpUpdateOne) {
  41404. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  41405. }
  41406. if m.id == nil || m.oldValue == nil {
  41407. return v, errors.New("OldMemberList requires an ID field in the mutation")
  41408. }
  41409. oldValue, err := m.oldValue(ctx)
  41410. if err != nil {
  41411. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  41412. }
  41413. return oldValue.MemberList, nil
  41414. }
  41415. // AppendMemberList adds s to the "member_list" field.
  41416. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  41417. m.appendmember_list = append(m.appendmember_list, s...)
  41418. }
  41419. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  41420. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  41421. if len(m.appendmember_list) == 0 {
  41422. return nil, false
  41423. }
  41424. return m.appendmember_list, true
  41425. }
  41426. // ResetMemberList resets all changes to the "member_list" field.
  41427. func (m *WpChatroomMutation) ResetMemberList() {
  41428. m.member_list = nil
  41429. m.appendmember_list = nil
  41430. }
  41431. // Where appends a list predicates to the WpChatroomMutation builder.
  41432. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  41433. m.predicates = append(m.predicates, ps...)
  41434. }
  41435. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  41436. // users can use type-assertion to append predicates that do not depend on any generated package.
  41437. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  41438. p := make([]predicate.WpChatroom, len(ps))
  41439. for i := range ps {
  41440. p[i] = ps[i]
  41441. }
  41442. m.Where(p...)
  41443. }
  41444. // Op returns the operation name.
  41445. func (m *WpChatroomMutation) Op() Op {
  41446. return m.op
  41447. }
  41448. // SetOp allows setting the mutation operation.
  41449. func (m *WpChatroomMutation) SetOp(op Op) {
  41450. m.op = op
  41451. }
  41452. // Type returns the node type of this mutation (WpChatroom).
  41453. func (m *WpChatroomMutation) Type() string {
  41454. return m.typ
  41455. }
  41456. // Fields returns all fields that were changed during this mutation. Note that in
  41457. // order to get all numeric fields that were incremented/decremented, call
  41458. // AddedFields().
  41459. func (m *WpChatroomMutation) Fields() []string {
  41460. fields := make([]string, 0, 9)
  41461. if m.created_at != nil {
  41462. fields = append(fields, wpchatroom.FieldCreatedAt)
  41463. }
  41464. if m.updated_at != nil {
  41465. fields = append(fields, wpchatroom.FieldUpdatedAt)
  41466. }
  41467. if m.status != nil {
  41468. fields = append(fields, wpchatroom.FieldStatus)
  41469. }
  41470. if m.wx_wxid != nil {
  41471. fields = append(fields, wpchatroom.FieldWxWxid)
  41472. }
  41473. if m.chatroom_id != nil {
  41474. fields = append(fields, wpchatroom.FieldChatroomID)
  41475. }
  41476. if m.nickname != nil {
  41477. fields = append(fields, wpchatroom.FieldNickname)
  41478. }
  41479. if m.owner != nil {
  41480. fields = append(fields, wpchatroom.FieldOwner)
  41481. }
  41482. if m.avatar != nil {
  41483. fields = append(fields, wpchatroom.FieldAvatar)
  41484. }
  41485. if m.member_list != nil {
  41486. fields = append(fields, wpchatroom.FieldMemberList)
  41487. }
  41488. return fields
  41489. }
  41490. // Field returns the value of a field with the given name. The second boolean
  41491. // return value indicates that this field was not set, or was not defined in the
  41492. // schema.
  41493. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  41494. switch name {
  41495. case wpchatroom.FieldCreatedAt:
  41496. return m.CreatedAt()
  41497. case wpchatroom.FieldUpdatedAt:
  41498. return m.UpdatedAt()
  41499. case wpchatroom.FieldStatus:
  41500. return m.Status()
  41501. case wpchatroom.FieldWxWxid:
  41502. return m.WxWxid()
  41503. case wpchatroom.FieldChatroomID:
  41504. return m.ChatroomID()
  41505. case wpchatroom.FieldNickname:
  41506. return m.Nickname()
  41507. case wpchatroom.FieldOwner:
  41508. return m.Owner()
  41509. case wpchatroom.FieldAvatar:
  41510. return m.Avatar()
  41511. case wpchatroom.FieldMemberList:
  41512. return m.MemberList()
  41513. }
  41514. return nil, false
  41515. }
  41516. // OldField returns the old value of the field from the database. An error is
  41517. // returned if the mutation operation is not UpdateOne, or the query to the
  41518. // database failed.
  41519. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  41520. switch name {
  41521. case wpchatroom.FieldCreatedAt:
  41522. return m.OldCreatedAt(ctx)
  41523. case wpchatroom.FieldUpdatedAt:
  41524. return m.OldUpdatedAt(ctx)
  41525. case wpchatroom.FieldStatus:
  41526. return m.OldStatus(ctx)
  41527. case wpchatroom.FieldWxWxid:
  41528. return m.OldWxWxid(ctx)
  41529. case wpchatroom.FieldChatroomID:
  41530. return m.OldChatroomID(ctx)
  41531. case wpchatroom.FieldNickname:
  41532. return m.OldNickname(ctx)
  41533. case wpchatroom.FieldOwner:
  41534. return m.OldOwner(ctx)
  41535. case wpchatroom.FieldAvatar:
  41536. return m.OldAvatar(ctx)
  41537. case wpchatroom.FieldMemberList:
  41538. return m.OldMemberList(ctx)
  41539. }
  41540. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  41541. }
  41542. // SetField sets the value of a field with the given name. It returns an error if
  41543. // the field is not defined in the schema, or if the type mismatched the field
  41544. // type.
  41545. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  41546. switch name {
  41547. case wpchatroom.FieldCreatedAt:
  41548. v, ok := value.(time.Time)
  41549. if !ok {
  41550. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41551. }
  41552. m.SetCreatedAt(v)
  41553. return nil
  41554. case wpchatroom.FieldUpdatedAt:
  41555. v, ok := value.(time.Time)
  41556. if !ok {
  41557. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41558. }
  41559. m.SetUpdatedAt(v)
  41560. return nil
  41561. case wpchatroom.FieldStatus:
  41562. v, ok := value.(uint8)
  41563. if !ok {
  41564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41565. }
  41566. m.SetStatus(v)
  41567. return nil
  41568. case wpchatroom.FieldWxWxid:
  41569. v, ok := value.(string)
  41570. if !ok {
  41571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41572. }
  41573. m.SetWxWxid(v)
  41574. return nil
  41575. case wpchatroom.FieldChatroomID:
  41576. v, ok := value.(string)
  41577. if !ok {
  41578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41579. }
  41580. m.SetChatroomID(v)
  41581. return nil
  41582. case wpchatroom.FieldNickname:
  41583. v, ok := value.(string)
  41584. if !ok {
  41585. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41586. }
  41587. m.SetNickname(v)
  41588. return nil
  41589. case wpchatroom.FieldOwner:
  41590. v, ok := value.(string)
  41591. if !ok {
  41592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41593. }
  41594. m.SetOwner(v)
  41595. return nil
  41596. case wpchatroom.FieldAvatar:
  41597. v, ok := value.(string)
  41598. if !ok {
  41599. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41600. }
  41601. m.SetAvatar(v)
  41602. return nil
  41603. case wpchatroom.FieldMemberList:
  41604. v, ok := value.([]string)
  41605. if !ok {
  41606. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41607. }
  41608. m.SetMemberList(v)
  41609. return nil
  41610. }
  41611. return fmt.Errorf("unknown WpChatroom field %s", name)
  41612. }
  41613. // AddedFields returns all numeric fields that were incremented/decremented during
  41614. // this mutation.
  41615. func (m *WpChatroomMutation) AddedFields() []string {
  41616. var fields []string
  41617. if m.addstatus != nil {
  41618. fields = append(fields, wpchatroom.FieldStatus)
  41619. }
  41620. return fields
  41621. }
  41622. // AddedField returns the numeric value that was incremented/decremented on a field
  41623. // with the given name. The second boolean return value indicates that this field
  41624. // was not set, or was not defined in the schema.
  41625. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  41626. switch name {
  41627. case wpchatroom.FieldStatus:
  41628. return m.AddedStatus()
  41629. }
  41630. return nil, false
  41631. }
  41632. // AddField adds the value to the field with the given name. It returns an error if
  41633. // the field is not defined in the schema, or if the type mismatched the field
  41634. // type.
  41635. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  41636. switch name {
  41637. case wpchatroom.FieldStatus:
  41638. v, ok := value.(int8)
  41639. if !ok {
  41640. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41641. }
  41642. m.AddStatus(v)
  41643. return nil
  41644. }
  41645. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  41646. }
  41647. // ClearedFields returns all nullable fields that were cleared during this
  41648. // mutation.
  41649. func (m *WpChatroomMutation) ClearedFields() []string {
  41650. var fields []string
  41651. if m.FieldCleared(wpchatroom.FieldStatus) {
  41652. fields = append(fields, wpchatroom.FieldStatus)
  41653. }
  41654. return fields
  41655. }
  41656. // FieldCleared returns a boolean indicating if a field with the given name was
  41657. // cleared in this mutation.
  41658. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  41659. _, ok := m.clearedFields[name]
  41660. return ok
  41661. }
  41662. // ClearField clears the value of the field with the given name. It returns an
  41663. // error if the field is not defined in the schema.
  41664. func (m *WpChatroomMutation) ClearField(name string) error {
  41665. switch name {
  41666. case wpchatroom.FieldStatus:
  41667. m.ClearStatus()
  41668. return nil
  41669. }
  41670. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  41671. }
  41672. // ResetField resets all changes in the mutation for the field with the given name.
  41673. // It returns an error if the field is not defined in the schema.
  41674. func (m *WpChatroomMutation) ResetField(name string) error {
  41675. switch name {
  41676. case wpchatroom.FieldCreatedAt:
  41677. m.ResetCreatedAt()
  41678. return nil
  41679. case wpchatroom.FieldUpdatedAt:
  41680. m.ResetUpdatedAt()
  41681. return nil
  41682. case wpchatroom.FieldStatus:
  41683. m.ResetStatus()
  41684. return nil
  41685. case wpchatroom.FieldWxWxid:
  41686. m.ResetWxWxid()
  41687. return nil
  41688. case wpchatroom.FieldChatroomID:
  41689. m.ResetChatroomID()
  41690. return nil
  41691. case wpchatroom.FieldNickname:
  41692. m.ResetNickname()
  41693. return nil
  41694. case wpchatroom.FieldOwner:
  41695. m.ResetOwner()
  41696. return nil
  41697. case wpchatroom.FieldAvatar:
  41698. m.ResetAvatar()
  41699. return nil
  41700. case wpchatroom.FieldMemberList:
  41701. m.ResetMemberList()
  41702. return nil
  41703. }
  41704. return fmt.Errorf("unknown WpChatroom field %s", name)
  41705. }
  41706. // AddedEdges returns all edge names that were set/added in this mutation.
  41707. func (m *WpChatroomMutation) AddedEdges() []string {
  41708. edges := make([]string, 0, 0)
  41709. return edges
  41710. }
  41711. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  41712. // name in this mutation.
  41713. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  41714. return nil
  41715. }
  41716. // RemovedEdges returns all edge names that were removed in this mutation.
  41717. func (m *WpChatroomMutation) RemovedEdges() []string {
  41718. edges := make([]string, 0, 0)
  41719. return edges
  41720. }
  41721. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  41722. // the given name in this mutation.
  41723. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  41724. return nil
  41725. }
  41726. // ClearedEdges returns all edge names that were cleared in this mutation.
  41727. func (m *WpChatroomMutation) ClearedEdges() []string {
  41728. edges := make([]string, 0, 0)
  41729. return edges
  41730. }
  41731. // EdgeCleared returns a boolean which indicates if the edge with the given name
  41732. // was cleared in this mutation.
  41733. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  41734. return false
  41735. }
  41736. // ClearEdge clears the value of the edge with the given name. It returns an error
  41737. // if that edge is not defined in the schema.
  41738. func (m *WpChatroomMutation) ClearEdge(name string) error {
  41739. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  41740. }
  41741. // ResetEdge resets all changes to the edge with the given name in this mutation.
  41742. // It returns an error if the edge is not defined in the schema.
  41743. func (m *WpChatroomMutation) ResetEdge(name string) error {
  41744. return fmt.Errorf("unknown WpChatroom edge %s", name)
  41745. }
  41746. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  41747. type WpChatroomMemberMutation struct {
  41748. config
  41749. op Op
  41750. typ string
  41751. id *uint64
  41752. created_at *time.Time
  41753. updated_at *time.Time
  41754. status *uint8
  41755. addstatus *int8
  41756. wx_wxid *string
  41757. wxid *string
  41758. nickname *string
  41759. avatar *string
  41760. clearedFields map[string]struct{}
  41761. done bool
  41762. oldValue func(context.Context) (*WpChatroomMember, error)
  41763. predicates []predicate.WpChatroomMember
  41764. }
  41765. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  41766. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  41767. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  41768. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  41769. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  41770. m := &WpChatroomMemberMutation{
  41771. config: c,
  41772. op: op,
  41773. typ: TypeWpChatroomMember,
  41774. clearedFields: make(map[string]struct{}),
  41775. }
  41776. for _, opt := range opts {
  41777. opt(m)
  41778. }
  41779. return m
  41780. }
  41781. // withWpChatroomMemberID sets the ID field of the mutation.
  41782. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  41783. return func(m *WpChatroomMemberMutation) {
  41784. var (
  41785. err error
  41786. once sync.Once
  41787. value *WpChatroomMember
  41788. )
  41789. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  41790. once.Do(func() {
  41791. if m.done {
  41792. err = errors.New("querying old values post mutation is not allowed")
  41793. } else {
  41794. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  41795. }
  41796. })
  41797. return value, err
  41798. }
  41799. m.id = &id
  41800. }
  41801. }
  41802. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  41803. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  41804. return func(m *WpChatroomMemberMutation) {
  41805. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  41806. return node, nil
  41807. }
  41808. m.id = &node.ID
  41809. }
  41810. }
  41811. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41812. // executed in a transaction (ent.Tx), a transactional client is returned.
  41813. func (m WpChatroomMemberMutation) Client() *Client {
  41814. client := &Client{config: m.config}
  41815. client.init()
  41816. return client
  41817. }
  41818. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41819. // it returns an error otherwise.
  41820. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  41821. if _, ok := m.driver.(*txDriver); !ok {
  41822. return nil, errors.New("ent: mutation is not running in a transaction")
  41823. }
  41824. tx := &Tx{config: m.config}
  41825. tx.init()
  41826. return tx, nil
  41827. }
  41828. // SetID sets the value of the id field. Note that this
  41829. // operation is only accepted on creation of WpChatroomMember entities.
  41830. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  41831. m.id = &id
  41832. }
  41833. // ID returns the ID value in the mutation. Note that the ID is only available
  41834. // if it was provided to the builder or after it was returned from the database.
  41835. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  41836. if m.id == nil {
  41837. return
  41838. }
  41839. return *m.id, true
  41840. }
  41841. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41842. // That means, if the mutation is applied within a transaction with an isolation level such
  41843. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41844. // or updated by the mutation.
  41845. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  41846. switch {
  41847. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41848. id, exists := m.ID()
  41849. if exists {
  41850. return []uint64{id}, nil
  41851. }
  41852. fallthrough
  41853. case m.op.Is(OpUpdate | OpDelete):
  41854. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  41855. default:
  41856. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41857. }
  41858. }
  41859. // SetCreatedAt sets the "created_at" field.
  41860. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  41861. m.created_at = &t
  41862. }
  41863. // CreatedAt returns the value of the "created_at" field in the mutation.
  41864. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  41865. v := m.created_at
  41866. if v == nil {
  41867. return
  41868. }
  41869. return *v, true
  41870. }
  41871. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  41872. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  41873. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41874. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  41875. if !m.op.Is(OpUpdateOne) {
  41876. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  41877. }
  41878. if m.id == nil || m.oldValue == nil {
  41879. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  41880. }
  41881. oldValue, err := m.oldValue(ctx)
  41882. if err != nil {
  41883. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  41884. }
  41885. return oldValue.CreatedAt, nil
  41886. }
  41887. // ResetCreatedAt resets all changes to the "created_at" field.
  41888. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  41889. m.created_at = nil
  41890. }
  41891. // SetUpdatedAt sets the "updated_at" field.
  41892. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  41893. m.updated_at = &t
  41894. }
  41895. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  41896. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  41897. v := m.updated_at
  41898. if v == nil {
  41899. return
  41900. }
  41901. return *v, true
  41902. }
  41903. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  41904. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  41905. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41906. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  41907. if !m.op.Is(OpUpdateOne) {
  41908. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  41909. }
  41910. if m.id == nil || m.oldValue == nil {
  41911. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  41912. }
  41913. oldValue, err := m.oldValue(ctx)
  41914. if err != nil {
  41915. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  41916. }
  41917. return oldValue.UpdatedAt, nil
  41918. }
  41919. // ResetUpdatedAt resets all changes to the "updated_at" field.
  41920. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  41921. m.updated_at = nil
  41922. }
  41923. // SetStatus sets the "status" field.
  41924. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  41925. m.status = &u
  41926. m.addstatus = nil
  41927. }
  41928. // Status returns the value of the "status" field in the mutation.
  41929. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  41930. v := m.status
  41931. if v == nil {
  41932. return
  41933. }
  41934. return *v, true
  41935. }
  41936. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  41937. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  41938. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41939. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  41940. if !m.op.Is(OpUpdateOne) {
  41941. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  41942. }
  41943. if m.id == nil || m.oldValue == nil {
  41944. return v, errors.New("OldStatus requires an ID field in the mutation")
  41945. }
  41946. oldValue, err := m.oldValue(ctx)
  41947. if err != nil {
  41948. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  41949. }
  41950. return oldValue.Status, nil
  41951. }
  41952. // AddStatus adds u to the "status" field.
  41953. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  41954. if m.addstatus != nil {
  41955. *m.addstatus += u
  41956. } else {
  41957. m.addstatus = &u
  41958. }
  41959. }
  41960. // AddedStatus returns the value that was added to the "status" field in this mutation.
  41961. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  41962. v := m.addstatus
  41963. if v == nil {
  41964. return
  41965. }
  41966. return *v, true
  41967. }
  41968. // ClearStatus clears the value of the "status" field.
  41969. func (m *WpChatroomMemberMutation) ClearStatus() {
  41970. m.status = nil
  41971. m.addstatus = nil
  41972. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  41973. }
  41974. // StatusCleared returns if the "status" field was cleared in this mutation.
  41975. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  41976. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  41977. return ok
  41978. }
  41979. // ResetStatus resets all changes to the "status" field.
  41980. func (m *WpChatroomMemberMutation) ResetStatus() {
  41981. m.status = nil
  41982. m.addstatus = nil
  41983. delete(m.clearedFields, wpchatroommember.FieldStatus)
  41984. }
  41985. // SetWxWxid sets the "wx_wxid" field.
  41986. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  41987. m.wx_wxid = &s
  41988. }
  41989. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  41990. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  41991. v := m.wx_wxid
  41992. if v == nil {
  41993. return
  41994. }
  41995. return *v, true
  41996. }
  41997. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  41998. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  41999. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42000. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  42001. if !m.op.Is(OpUpdateOne) {
  42002. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  42003. }
  42004. if m.id == nil || m.oldValue == nil {
  42005. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  42006. }
  42007. oldValue, err := m.oldValue(ctx)
  42008. if err != nil {
  42009. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  42010. }
  42011. return oldValue.WxWxid, nil
  42012. }
  42013. // ResetWxWxid resets all changes to the "wx_wxid" field.
  42014. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  42015. m.wx_wxid = nil
  42016. }
  42017. // SetWxid sets the "wxid" field.
  42018. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  42019. m.wxid = &s
  42020. }
  42021. // Wxid returns the value of the "wxid" field in the mutation.
  42022. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  42023. v := m.wxid
  42024. if v == nil {
  42025. return
  42026. }
  42027. return *v, true
  42028. }
  42029. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  42030. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  42031. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42032. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  42033. if !m.op.Is(OpUpdateOne) {
  42034. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  42035. }
  42036. if m.id == nil || m.oldValue == nil {
  42037. return v, errors.New("OldWxid requires an ID field in the mutation")
  42038. }
  42039. oldValue, err := m.oldValue(ctx)
  42040. if err != nil {
  42041. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  42042. }
  42043. return oldValue.Wxid, nil
  42044. }
  42045. // ResetWxid resets all changes to the "wxid" field.
  42046. func (m *WpChatroomMemberMutation) ResetWxid() {
  42047. m.wxid = nil
  42048. }
  42049. // SetNickname sets the "nickname" field.
  42050. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  42051. m.nickname = &s
  42052. }
  42053. // Nickname returns the value of the "nickname" field in the mutation.
  42054. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  42055. v := m.nickname
  42056. if v == nil {
  42057. return
  42058. }
  42059. return *v, true
  42060. }
  42061. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  42062. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  42063. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42064. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  42065. if !m.op.Is(OpUpdateOne) {
  42066. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  42067. }
  42068. if m.id == nil || m.oldValue == nil {
  42069. return v, errors.New("OldNickname requires an ID field in the mutation")
  42070. }
  42071. oldValue, err := m.oldValue(ctx)
  42072. if err != nil {
  42073. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  42074. }
  42075. return oldValue.Nickname, nil
  42076. }
  42077. // ResetNickname resets all changes to the "nickname" field.
  42078. func (m *WpChatroomMemberMutation) ResetNickname() {
  42079. m.nickname = nil
  42080. }
  42081. // SetAvatar sets the "avatar" field.
  42082. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  42083. m.avatar = &s
  42084. }
  42085. // Avatar returns the value of the "avatar" field in the mutation.
  42086. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  42087. v := m.avatar
  42088. if v == nil {
  42089. return
  42090. }
  42091. return *v, true
  42092. }
  42093. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  42094. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  42095. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42096. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  42097. if !m.op.Is(OpUpdateOne) {
  42098. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  42099. }
  42100. if m.id == nil || m.oldValue == nil {
  42101. return v, errors.New("OldAvatar requires an ID field in the mutation")
  42102. }
  42103. oldValue, err := m.oldValue(ctx)
  42104. if err != nil {
  42105. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  42106. }
  42107. return oldValue.Avatar, nil
  42108. }
  42109. // ResetAvatar resets all changes to the "avatar" field.
  42110. func (m *WpChatroomMemberMutation) ResetAvatar() {
  42111. m.avatar = nil
  42112. }
  42113. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  42114. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  42115. m.predicates = append(m.predicates, ps...)
  42116. }
  42117. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  42118. // users can use type-assertion to append predicates that do not depend on any generated package.
  42119. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  42120. p := make([]predicate.WpChatroomMember, len(ps))
  42121. for i := range ps {
  42122. p[i] = ps[i]
  42123. }
  42124. m.Where(p...)
  42125. }
  42126. // Op returns the operation name.
  42127. func (m *WpChatroomMemberMutation) Op() Op {
  42128. return m.op
  42129. }
  42130. // SetOp allows setting the mutation operation.
  42131. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  42132. m.op = op
  42133. }
  42134. // Type returns the node type of this mutation (WpChatroomMember).
  42135. func (m *WpChatroomMemberMutation) Type() string {
  42136. return m.typ
  42137. }
  42138. // Fields returns all fields that were changed during this mutation. Note that in
  42139. // order to get all numeric fields that were incremented/decremented, call
  42140. // AddedFields().
  42141. func (m *WpChatroomMemberMutation) Fields() []string {
  42142. fields := make([]string, 0, 7)
  42143. if m.created_at != nil {
  42144. fields = append(fields, wpchatroommember.FieldCreatedAt)
  42145. }
  42146. if m.updated_at != nil {
  42147. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  42148. }
  42149. if m.status != nil {
  42150. fields = append(fields, wpchatroommember.FieldStatus)
  42151. }
  42152. if m.wx_wxid != nil {
  42153. fields = append(fields, wpchatroommember.FieldWxWxid)
  42154. }
  42155. if m.wxid != nil {
  42156. fields = append(fields, wpchatroommember.FieldWxid)
  42157. }
  42158. if m.nickname != nil {
  42159. fields = append(fields, wpchatroommember.FieldNickname)
  42160. }
  42161. if m.avatar != nil {
  42162. fields = append(fields, wpchatroommember.FieldAvatar)
  42163. }
  42164. return fields
  42165. }
  42166. // Field returns the value of a field with the given name. The second boolean
  42167. // return value indicates that this field was not set, or was not defined in the
  42168. // schema.
  42169. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  42170. switch name {
  42171. case wpchatroommember.FieldCreatedAt:
  42172. return m.CreatedAt()
  42173. case wpchatroommember.FieldUpdatedAt:
  42174. return m.UpdatedAt()
  42175. case wpchatroommember.FieldStatus:
  42176. return m.Status()
  42177. case wpchatroommember.FieldWxWxid:
  42178. return m.WxWxid()
  42179. case wpchatroommember.FieldWxid:
  42180. return m.Wxid()
  42181. case wpchatroommember.FieldNickname:
  42182. return m.Nickname()
  42183. case wpchatroommember.FieldAvatar:
  42184. return m.Avatar()
  42185. }
  42186. return nil, false
  42187. }
  42188. // OldField returns the old value of the field from the database. An error is
  42189. // returned if the mutation operation is not UpdateOne, or the query to the
  42190. // database failed.
  42191. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  42192. switch name {
  42193. case wpchatroommember.FieldCreatedAt:
  42194. return m.OldCreatedAt(ctx)
  42195. case wpchatroommember.FieldUpdatedAt:
  42196. return m.OldUpdatedAt(ctx)
  42197. case wpchatroommember.FieldStatus:
  42198. return m.OldStatus(ctx)
  42199. case wpchatroommember.FieldWxWxid:
  42200. return m.OldWxWxid(ctx)
  42201. case wpchatroommember.FieldWxid:
  42202. return m.OldWxid(ctx)
  42203. case wpchatroommember.FieldNickname:
  42204. return m.OldNickname(ctx)
  42205. case wpchatroommember.FieldAvatar:
  42206. return m.OldAvatar(ctx)
  42207. }
  42208. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  42209. }
  42210. // SetField sets the value of a field with the given name. It returns an error if
  42211. // the field is not defined in the schema, or if the type mismatched the field
  42212. // type.
  42213. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  42214. switch name {
  42215. case wpchatroommember.FieldCreatedAt:
  42216. v, ok := value.(time.Time)
  42217. if !ok {
  42218. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42219. }
  42220. m.SetCreatedAt(v)
  42221. return nil
  42222. case wpchatroommember.FieldUpdatedAt:
  42223. v, ok := value.(time.Time)
  42224. if !ok {
  42225. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42226. }
  42227. m.SetUpdatedAt(v)
  42228. return nil
  42229. case wpchatroommember.FieldStatus:
  42230. v, ok := value.(uint8)
  42231. if !ok {
  42232. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42233. }
  42234. m.SetStatus(v)
  42235. return nil
  42236. case wpchatroommember.FieldWxWxid:
  42237. v, ok := value.(string)
  42238. if !ok {
  42239. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42240. }
  42241. m.SetWxWxid(v)
  42242. return nil
  42243. case wpchatroommember.FieldWxid:
  42244. v, ok := value.(string)
  42245. if !ok {
  42246. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42247. }
  42248. m.SetWxid(v)
  42249. return nil
  42250. case wpchatroommember.FieldNickname:
  42251. v, ok := value.(string)
  42252. if !ok {
  42253. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42254. }
  42255. m.SetNickname(v)
  42256. return nil
  42257. case wpchatroommember.FieldAvatar:
  42258. v, ok := value.(string)
  42259. if !ok {
  42260. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42261. }
  42262. m.SetAvatar(v)
  42263. return nil
  42264. }
  42265. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  42266. }
  42267. // AddedFields returns all numeric fields that were incremented/decremented during
  42268. // this mutation.
  42269. func (m *WpChatroomMemberMutation) AddedFields() []string {
  42270. var fields []string
  42271. if m.addstatus != nil {
  42272. fields = append(fields, wpchatroommember.FieldStatus)
  42273. }
  42274. return fields
  42275. }
  42276. // AddedField returns the numeric value that was incremented/decremented on a field
  42277. // with the given name. The second boolean return value indicates that this field
  42278. // was not set, or was not defined in the schema.
  42279. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  42280. switch name {
  42281. case wpchatroommember.FieldStatus:
  42282. return m.AddedStatus()
  42283. }
  42284. return nil, false
  42285. }
  42286. // AddField adds the value to the field with the given name. It returns an error if
  42287. // the field is not defined in the schema, or if the type mismatched the field
  42288. // type.
  42289. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  42290. switch name {
  42291. case wpchatroommember.FieldStatus:
  42292. v, ok := value.(int8)
  42293. if !ok {
  42294. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42295. }
  42296. m.AddStatus(v)
  42297. return nil
  42298. }
  42299. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  42300. }
  42301. // ClearedFields returns all nullable fields that were cleared during this
  42302. // mutation.
  42303. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  42304. var fields []string
  42305. if m.FieldCleared(wpchatroommember.FieldStatus) {
  42306. fields = append(fields, wpchatroommember.FieldStatus)
  42307. }
  42308. return fields
  42309. }
  42310. // FieldCleared returns a boolean indicating if a field with the given name was
  42311. // cleared in this mutation.
  42312. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  42313. _, ok := m.clearedFields[name]
  42314. return ok
  42315. }
  42316. // ClearField clears the value of the field with the given name. It returns an
  42317. // error if the field is not defined in the schema.
  42318. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  42319. switch name {
  42320. case wpchatroommember.FieldStatus:
  42321. m.ClearStatus()
  42322. return nil
  42323. }
  42324. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  42325. }
  42326. // ResetField resets all changes in the mutation for the field with the given name.
  42327. // It returns an error if the field is not defined in the schema.
  42328. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  42329. switch name {
  42330. case wpchatroommember.FieldCreatedAt:
  42331. m.ResetCreatedAt()
  42332. return nil
  42333. case wpchatroommember.FieldUpdatedAt:
  42334. m.ResetUpdatedAt()
  42335. return nil
  42336. case wpchatroommember.FieldStatus:
  42337. m.ResetStatus()
  42338. return nil
  42339. case wpchatroommember.FieldWxWxid:
  42340. m.ResetWxWxid()
  42341. return nil
  42342. case wpchatroommember.FieldWxid:
  42343. m.ResetWxid()
  42344. return nil
  42345. case wpchatroommember.FieldNickname:
  42346. m.ResetNickname()
  42347. return nil
  42348. case wpchatroommember.FieldAvatar:
  42349. m.ResetAvatar()
  42350. return nil
  42351. }
  42352. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  42353. }
  42354. // AddedEdges returns all edge names that were set/added in this mutation.
  42355. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  42356. edges := make([]string, 0, 0)
  42357. return edges
  42358. }
  42359. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  42360. // name in this mutation.
  42361. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  42362. return nil
  42363. }
  42364. // RemovedEdges returns all edge names that were removed in this mutation.
  42365. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  42366. edges := make([]string, 0, 0)
  42367. return edges
  42368. }
  42369. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  42370. // the given name in this mutation.
  42371. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  42372. return nil
  42373. }
  42374. // ClearedEdges returns all edge names that were cleared in this mutation.
  42375. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  42376. edges := make([]string, 0, 0)
  42377. return edges
  42378. }
  42379. // EdgeCleared returns a boolean which indicates if the edge with the given name
  42380. // was cleared in this mutation.
  42381. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  42382. return false
  42383. }
  42384. // ClearEdge clears the value of the edge with the given name. It returns an error
  42385. // if that edge is not defined in the schema.
  42386. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  42387. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  42388. }
  42389. // ResetEdge resets all changes to the edge with the given name in this mutation.
  42390. // It returns an error if the edge is not defined in the schema.
  42391. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  42392. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  42393. }
  42394. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  42395. type WxMutation struct {
  42396. config
  42397. op Op
  42398. typ string
  42399. id *uint64
  42400. created_at *time.Time
  42401. updated_at *time.Time
  42402. status *uint8
  42403. addstatus *int8
  42404. deleted_at *time.Time
  42405. port *string
  42406. process_id *string
  42407. callback *string
  42408. wxid *string
  42409. account *string
  42410. nickname *string
  42411. tel *string
  42412. head_big *string
  42413. organization_id *uint64
  42414. addorganization_id *int64
  42415. api_base *string
  42416. api_key *string
  42417. allow_list *[]string
  42418. appendallow_list []string
  42419. group_allow_list *[]string
  42420. appendgroup_allow_list []string
  42421. block_list *[]string
  42422. appendblock_list []string
  42423. group_block_list *[]string
  42424. appendgroup_block_list []string
  42425. ctype *uint64
  42426. addctype *int64
  42427. clearedFields map[string]struct{}
  42428. server *uint64
  42429. clearedserver bool
  42430. agent *uint64
  42431. clearedagent bool
  42432. done bool
  42433. oldValue func(context.Context) (*Wx, error)
  42434. predicates []predicate.Wx
  42435. }
  42436. var _ ent.Mutation = (*WxMutation)(nil)
  42437. // wxOption allows management of the mutation configuration using functional options.
  42438. type wxOption func(*WxMutation)
  42439. // newWxMutation creates new mutation for the Wx entity.
  42440. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  42441. m := &WxMutation{
  42442. config: c,
  42443. op: op,
  42444. typ: TypeWx,
  42445. clearedFields: make(map[string]struct{}),
  42446. }
  42447. for _, opt := range opts {
  42448. opt(m)
  42449. }
  42450. return m
  42451. }
  42452. // withWxID sets the ID field of the mutation.
  42453. func withWxID(id uint64) wxOption {
  42454. return func(m *WxMutation) {
  42455. var (
  42456. err error
  42457. once sync.Once
  42458. value *Wx
  42459. )
  42460. m.oldValue = func(ctx context.Context) (*Wx, error) {
  42461. once.Do(func() {
  42462. if m.done {
  42463. err = errors.New("querying old values post mutation is not allowed")
  42464. } else {
  42465. value, err = m.Client().Wx.Get(ctx, id)
  42466. }
  42467. })
  42468. return value, err
  42469. }
  42470. m.id = &id
  42471. }
  42472. }
  42473. // withWx sets the old Wx of the mutation.
  42474. func withWx(node *Wx) wxOption {
  42475. return func(m *WxMutation) {
  42476. m.oldValue = func(context.Context) (*Wx, error) {
  42477. return node, nil
  42478. }
  42479. m.id = &node.ID
  42480. }
  42481. }
  42482. // Client returns a new `ent.Client` from the mutation. If the mutation was
  42483. // executed in a transaction (ent.Tx), a transactional client is returned.
  42484. func (m WxMutation) Client() *Client {
  42485. client := &Client{config: m.config}
  42486. client.init()
  42487. return client
  42488. }
  42489. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  42490. // it returns an error otherwise.
  42491. func (m WxMutation) Tx() (*Tx, error) {
  42492. if _, ok := m.driver.(*txDriver); !ok {
  42493. return nil, errors.New("ent: mutation is not running in a transaction")
  42494. }
  42495. tx := &Tx{config: m.config}
  42496. tx.init()
  42497. return tx, nil
  42498. }
  42499. // SetID sets the value of the id field. Note that this
  42500. // operation is only accepted on creation of Wx entities.
  42501. func (m *WxMutation) SetID(id uint64) {
  42502. m.id = &id
  42503. }
  42504. // ID returns the ID value in the mutation. Note that the ID is only available
  42505. // if it was provided to the builder or after it was returned from the database.
  42506. func (m *WxMutation) ID() (id uint64, exists bool) {
  42507. if m.id == nil {
  42508. return
  42509. }
  42510. return *m.id, true
  42511. }
  42512. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  42513. // That means, if the mutation is applied within a transaction with an isolation level such
  42514. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  42515. // or updated by the mutation.
  42516. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  42517. switch {
  42518. case m.op.Is(OpUpdateOne | OpDeleteOne):
  42519. id, exists := m.ID()
  42520. if exists {
  42521. return []uint64{id}, nil
  42522. }
  42523. fallthrough
  42524. case m.op.Is(OpUpdate | OpDelete):
  42525. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  42526. default:
  42527. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  42528. }
  42529. }
  42530. // SetCreatedAt sets the "created_at" field.
  42531. func (m *WxMutation) SetCreatedAt(t time.Time) {
  42532. m.created_at = &t
  42533. }
  42534. // CreatedAt returns the value of the "created_at" field in the mutation.
  42535. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  42536. v := m.created_at
  42537. if v == nil {
  42538. return
  42539. }
  42540. return *v, true
  42541. }
  42542. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  42543. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42544. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42545. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  42546. if !m.op.Is(OpUpdateOne) {
  42547. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  42548. }
  42549. if m.id == nil || m.oldValue == nil {
  42550. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  42551. }
  42552. oldValue, err := m.oldValue(ctx)
  42553. if err != nil {
  42554. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  42555. }
  42556. return oldValue.CreatedAt, nil
  42557. }
  42558. // ResetCreatedAt resets all changes to the "created_at" field.
  42559. func (m *WxMutation) ResetCreatedAt() {
  42560. m.created_at = nil
  42561. }
  42562. // SetUpdatedAt sets the "updated_at" field.
  42563. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  42564. m.updated_at = &t
  42565. }
  42566. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  42567. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  42568. v := m.updated_at
  42569. if v == nil {
  42570. return
  42571. }
  42572. return *v, true
  42573. }
  42574. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  42575. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42576. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42577. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  42578. if !m.op.Is(OpUpdateOne) {
  42579. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  42580. }
  42581. if m.id == nil || m.oldValue == nil {
  42582. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  42583. }
  42584. oldValue, err := m.oldValue(ctx)
  42585. if err != nil {
  42586. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  42587. }
  42588. return oldValue.UpdatedAt, nil
  42589. }
  42590. // ResetUpdatedAt resets all changes to the "updated_at" field.
  42591. func (m *WxMutation) ResetUpdatedAt() {
  42592. m.updated_at = nil
  42593. }
  42594. // SetStatus sets the "status" field.
  42595. func (m *WxMutation) SetStatus(u uint8) {
  42596. m.status = &u
  42597. m.addstatus = nil
  42598. }
  42599. // Status returns the value of the "status" field in the mutation.
  42600. func (m *WxMutation) Status() (r uint8, exists bool) {
  42601. v := m.status
  42602. if v == nil {
  42603. return
  42604. }
  42605. return *v, true
  42606. }
  42607. // OldStatus returns the old "status" field's value of the Wx entity.
  42608. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42609. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42610. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  42611. if !m.op.Is(OpUpdateOne) {
  42612. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  42613. }
  42614. if m.id == nil || m.oldValue == nil {
  42615. return v, errors.New("OldStatus requires an ID field in the mutation")
  42616. }
  42617. oldValue, err := m.oldValue(ctx)
  42618. if err != nil {
  42619. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  42620. }
  42621. return oldValue.Status, nil
  42622. }
  42623. // AddStatus adds u to the "status" field.
  42624. func (m *WxMutation) AddStatus(u int8) {
  42625. if m.addstatus != nil {
  42626. *m.addstatus += u
  42627. } else {
  42628. m.addstatus = &u
  42629. }
  42630. }
  42631. // AddedStatus returns the value that was added to the "status" field in this mutation.
  42632. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  42633. v := m.addstatus
  42634. if v == nil {
  42635. return
  42636. }
  42637. return *v, true
  42638. }
  42639. // ClearStatus clears the value of the "status" field.
  42640. func (m *WxMutation) ClearStatus() {
  42641. m.status = nil
  42642. m.addstatus = nil
  42643. m.clearedFields[wx.FieldStatus] = struct{}{}
  42644. }
  42645. // StatusCleared returns if the "status" field was cleared in this mutation.
  42646. func (m *WxMutation) StatusCleared() bool {
  42647. _, ok := m.clearedFields[wx.FieldStatus]
  42648. return ok
  42649. }
  42650. // ResetStatus resets all changes to the "status" field.
  42651. func (m *WxMutation) ResetStatus() {
  42652. m.status = nil
  42653. m.addstatus = nil
  42654. delete(m.clearedFields, wx.FieldStatus)
  42655. }
  42656. // SetDeletedAt sets the "deleted_at" field.
  42657. func (m *WxMutation) SetDeletedAt(t time.Time) {
  42658. m.deleted_at = &t
  42659. }
  42660. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  42661. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  42662. v := m.deleted_at
  42663. if v == nil {
  42664. return
  42665. }
  42666. return *v, true
  42667. }
  42668. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  42669. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42670. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42671. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  42672. if !m.op.Is(OpUpdateOne) {
  42673. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  42674. }
  42675. if m.id == nil || m.oldValue == nil {
  42676. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  42677. }
  42678. oldValue, err := m.oldValue(ctx)
  42679. if err != nil {
  42680. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  42681. }
  42682. return oldValue.DeletedAt, nil
  42683. }
  42684. // ClearDeletedAt clears the value of the "deleted_at" field.
  42685. func (m *WxMutation) ClearDeletedAt() {
  42686. m.deleted_at = nil
  42687. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  42688. }
  42689. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  42690. func (m *WxMutation) DeletedAtCleared() bool {
  42691. _, ok := m.clearedFields[wx.FieldDeletedAt]
  42692. return ok
  42693. }
  42694. // ResetDeletedAt resets all changes to the "deleted_at" field.
  42695. func (m *WxMutation) ResetDeletedAt() {
  42696. m.deleted_at = nil
  42697. delete(m.clearedFields, wx.FieldDeletedAt)
  42698. }
  42699. // SetServerID sets the "server_id" field.
  42700. func (m *WxMutation) SetServerID(u uint64) {
  42701. m.server = &u
  42702. }
  42703. // ServerID returns the value of the "server_id" field in the mutation.
  42704. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  42705. v := m.server
  42706. if v == nil {
  42707. return
  42708. }
  42709. return *v, true
  42710. }
  42711. // OldServerID returns the old "server_id" field's value of the Wx entity.
  42712. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42713. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42714. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  42715. if !m.op.Is(OpUpdateOne) {
  42716. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  42717. }
  42718. if m.id == nil || m.oldValue == nil {
  42719. return v, errors.New("OldServerID requires an ID field in the mutation")
  42720. }
  42721. oldValue, err := m.oldValue(ctx)
  42722. if err != nil {
  42723. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  42724. }
  42725. return oldValue.ServerID, nil
  42726. }
  42727. // ClearServerID clears the value of the "server_id" field.
  42728. func (m *WxMutation) ClearServerID() {
  42729. m.server = nil
  42730. m.clearedFields[wx.FieldServerID] = struct{}{}
  42731. }
  42732. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  42733. func (m *WxMutation) ServerIDCleared() bool {
  42734. _, ok := m.clearedFields[wx.FieldServerID]
  42735. return ok
  42736. }
  42737. // ResetServerID resets all changes to the "server_id" field.
  42738. func (m *WxMutation) ResetServerID() {
  42739. m.server = nil
  42740. delete(m.clearedFields, wx.FieldServerID)
  42741. }
  42742. // SetPort sets the "port" field.
  42743. func (m *WxMutation) SetPort(s string) {
  42744. m.port = &s
  42745. }
  42746. // Port returns the value of the "port" field in the mutation.
  42747. func (m *WxMutation) Port() (r string, exists bool) {
  42748. v := m.port
  42749. if v == nil {
  42750. return
  42751. }
  42752. return *v, true
  42753. }
  42754. // OldPort returns the old "port" field's value of the Wx entity.
  42755. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42756. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42757. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  42758. if !m.op.Is(OpUpdateOne) {
  42759. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  42760. }
  42761. if m.id == nil || m.oldValue == nil {
  42762. return v, errors.New("OldPort requires an ID field in the mutation")
  42763. }
  42764. oldValue, err := m.oldValue(ctx)
  42765. if err != nil {
  42766. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  42767. }
  42768. return oldValue.Port, nil
  42769. }
  42770. // ResetPort resets all changes to the "port" field.
  42771. func (m *WxMutation) ResetPort() {
  42772. m.port = nil
  42773. }
  42774. // SetProcessID sets the "process_id" field.
  42775. func (m *WxMutation) SetProcessID(s string) {
  42776. m.process_id = &s
  42777. }
  42778. // ProcessID returns the value of the "process_id" field in the mutation.
  42779. func (m *WxMutation) ProcessID() (r string, exists bool) {
  42780. v := m.process_id
  42781. if v == nil {
  42782. return
  42783. }
  42784. return *v, true
  42785. }
  42786. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  42787. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42788. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42789. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  42790. if !m.op.Is(OpUpdateOne) {
  42791. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  42792. }
  42793. if m.id == nil || m.oldValue == nil {
  42794. return v, errors.New("OldProcessID requires an ID field in the mutation")
  42795. }
  42796. oldValue, err := m.oldValue(ctx)
  42797. if err != nil {
  42798. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  42799. }
  42800. return oldValue.ProcessID, nil
  42801. }
  42802. // ResetProcessID resets all changes to the "process_id" field.
  42803. func (m *WxMutation) ResetProcessID() {
  42804. m.process_id = nil
  42805. }
  42806. // SetCallback sets the "callback" field.
  42807. func (m *WxMutation) SetCallback(s string) {
  42808. m.callback = &s
  42809. }
  42810. // Callback returns the value of the "callback" field in the mutation.
  42811. func (m *WxMutation) Callback() (r string, exists bool) {
  42812. v := m.callback
  42813. if v == nil {
  42814. return
  42815. }
  42816. return *v, true
  42817. }
  42818. // OldCallback returns the old "callback" field's value of the Wx entity.
  42819. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42820. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42821. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  42822. if !m.op.Is(OpUpdateOne) {
  42823. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  42824. }
  42825. if m.id == nil || m.oldValue == nil {
  42826. return v, errors.New("OldCallback requires an ID field in the mutation")
  42827. }
  42828. oldValue, err := m.oldValue(ctx)
  42829. if err != nil {
  42830. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  42831. }
  42832. return oldValue.Callback, nil
  42833. }
  42834. // ResetCallback resets all changes to the "callback" field.
  42835. func (m *WxMutation) ResetCallback() {
  42836. m.callback = nil
  42837. }
  42838. // SetWxid sets the "wxid" field.
  42839. func (m *WxMutation) SetWxid(s string) {
  42840. m.wxid = &s
  42841. }
  42842. // Wxid returns the value of the "wxid" field in the mutation.
  42843. func (m *WxMutation) Wxid() (r string, exists bool) {
  42844. v := m.wxid
  42845. if v == nil {
  42846. return
  42847. }
  42848. return *v, true
  42849. }
  42850. // OldWxid returns the old "wxid" field's value of the Wx entity.
  42851. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42852. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42853. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  42854. if !m.op.Is(OpUpdateOne) {
  42855. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  42856. }
  42857. if m.id == nil || m.oldValue == nil {
  42858. return v, errors.New("OldWxid requires an ID field in the mutation")
  42859. }
  42860. oldValue, err := m.oldValue(ctx)
  42861. if err != nil {
  42862. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  42863. }
  42864. return oldValue.Wxid, nil
  42865. }
  42866. // ResetWxid resets all changes to the "wxid" field.
  42867. func (m *WxMutation) ResetWxid() {
  42868. m.wxid = nil
  42869. }
  42870. // SetAccount sets the "account" field.
  42871. func (m *WxMutation) SetAccount(s string) {
  42872. m.account = &s
  42873. }
  42874. // Account returns the value of the "account" field in the mutation.
  42875. func (m *WxMutation) Account() (r string, exists bool) {
  42876. v := m.account
  42877. if v == nil {
  42878. return
  42879. }
  42880. return *v, true
  42881. }
  42882. // OldAccount returns the old "account" field's value of the Wx entity.
  42883. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42884. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42885. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  42886. if !m.op.Is(OpUpdateOne) {
  42887. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  42888. }
  42889. if m.id == nil || m.oldValue == nil {
  42890. return v, errors.New("OldAccount requires an ID field in the mutation")
  42891. }
  42892. oldValue, err := m.oldValue(ctx)
  42893. if err != nil {
  42894. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  42895. }
  42896. return oldValue.Account, nil
  42897. }
  42898. // ResetAccount resets all changes to the "account" field.
  42899. func (m *WxMutation) ResetAccount() {
  42900. m.account = nil
  42901. }
  42902. // SetNickname sets the "nickname" field.
  42903. func (m *WxMutation) SetNickname(s string) {
  42904. m.nickname = &s
  42905. }
  42906. // Nickname returns the value of the "nickname" field in the mutation.
  42907. func (m *WxMutation) Nickname() (r string, exists bool) {
  42908. v := m.nickname
  42909. if v == nil {
  42910. return
  42911. }
  42912. return *v, true
  42913. }
  42914. // OldNickname returns the old "nickname" field's value of the Wx entity.
  42915. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42916. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42917. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  42918. if !m.op.Is(OpUpdateOne) {
  42919. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  42920. }
  42921. if m.id == nil || m.oldValue == nil {
  42922. return v, errors.New("OldNickname requires an ID field in the mutation")
  42923. }
  42924. oldValue, err := m.oldValue(ctx)
  42925. if err != nil {
  42926. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  42927. }
  42928. return oldValue.Nickname, nil
  42929. }
  42930. // ResetNickname resets all changes to the "nickname" field.
  42931. func (m *WxMutation) ResetNickname() {
  42932. m.nickname = nil
  42933. }
  42934. // SetTel sets the "tel" field.
  42935. func (m *WxMutation) SetTel(s string) {
  42936. m.tel = &s
  42937. }
  42938. // Tel returns the value of the "tel" field in the mutation.
  42939. func (m *WxMutation) Tel() (r string, exists bool) {
  42940. v := m.tel
  42941. if v == nil {
  42942. return
  42943. }
  42944. return *v, true
  42945. }
  42946. // OldTel returns the old "tel" field's value of the Wx entity.
  42947. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42948. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42949. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  42950. if !m.op.Is(OpUpdateOne) {
  42951. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  42952. }
  42953. if m.id == nil || m.oldValue == nil {
  42954. return v, errors.New("OldTel requires an ID field in the mutation")
  42955. }
  42956. oldValue, err := m.oldValue(ctx)
  42957. if err != nil {
  42958. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  42959. }
  42960. return oldValue.Tel, nil
  42961. }
  42962. // ResetTel resets all changes to the "tel" field.
  42963. func (m *WxMutation) ResetTel() {
  42964. m.tel = nil
  42965. }
  42966. // SetHeadBig sets the "head_big" field.
  42967. func (m *WxMutation) SetHeadBig(s string) {
  42968. m.head_big = &s
  42969. }
  42970. // HeadBig returns the value of the "head_big" field in the mutation.
  42971. func (m *WxMutation) HeadBig() (r string, exists bool) {
  42972. v := m.head_big
  42973. if v == nil {
  42974. return
  42975. }
  42976. return *v, true
  42977. }
  42978. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  42979. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42980. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42981. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  42982. if !m.op.Is(OpUpdateOne) {
  42983. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  42984. }
  42985. if m.id == nil || m.oldValue == nil {
  42986. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  42987. }
  42988. oldValue, err := m.oldValue(ctx)
  42989. if err != nil {
  42990. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  42991. }
  42992. return oldValue.HeadBig, nil
  42993. }
  42994. // ResetHeadBig resets all changes to the "head_big" field.
  42995. func (m *WxMutation) ResetHeadBig() {
  42996. m.head_big = nil
  42997. }
  42998. // SetOrganizationID sets the "organization_id" field.
  42999. func (m *WxMutation) SetOrganizationID(u uint64) {
  43000. m.organization_id = &u
  43001. m.addorganization_id = nil
  43002. }
  43003. // OrganizationID returns the value of the "organization_id" field in the mutation.
  43004. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  43005. v := m.organization_id
  43006. if v == nil {
  43007. return
  43008. }
  43009. return *v, true
  43010. }
  43011. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  43012. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43013. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43014. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  43015. if !m.op.Is(OpUpdateOne) {
  43016. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  43017. }
  43018. if m.id == nil || m.oldValue == nil {
  43019. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  43020. }
  43021. oldValue, err := m.oldValue(ctx)
  43022. if err != nil {
  43023. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  43024. }
  43025. return oldValue.OrganizationID, nil
  43026. }
  43027. // AddOrganizationID adds u to the "organization_id" field.
  43028. func (m *WxMutation) AddOrganizationID(u int64) {
  43029. if m.addorganization_id != nil {
  43030. *m.addorganization_id += u
  43031. } else {
  43032. m.addorganization_id = &u
  43033. }
  43034. }
  43035. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  43036. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  43037. v := m.addorganization_id
  43038. if v == nil {
  43039. return
  43040. }
  43041. return *v, true
  43042. }
  43043. // ClearOrganizationID clears the value of the "organization_id" field.
  43044. func (m *WxMutation) ClearOrganizationID() {
  43045. m.organization_id = nil
  43046. m.addorganization_id = nil
  43047. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  43048. }
  43049. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  43050. func (m *WxMutation) OrganizationIDCleared() bool {
  43051. _, ok := m.clearedFields[wx.FieldOrganizationID]
  43052. return ok
  43053. }
  43054. // ResetOrganizationID resets all changes to the "organization_id" field.
  43055. func (m *WxMutation) ResetOrganizationID() {
  43056. m.organization_id = nil
  43057. m.addorganization_id = nil
  43058. delete(m.clearedFields, wx.FieldOrganizationID)
  43059. }
  43060. // SetAgentID sets the "agent_id" field.
  43061. func (m *WxMutation) SetAgentID(u uint64) {
  43062. m.agent = &u
  43063. }
  43064. // AgentID returns the value of the "agent_id" field in the mutation.
  43065. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  43066. v := m.agent
  43067. if v == nil {
  43068. return
  43069. }
  43070. return *v, true
  43071. }
  43072. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  43073. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43074. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43075. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  43076. if !m.op.Is(OpUpdateOne) {
  43077. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  43078. }
  43079. if m.id == nil || m.oldValue == nil {
  43080. return v, errors.New("OldAgentID requires an ID field in the mutation")
  43081. }
  43082. oldValue, err := m.oldValue(ctx)
  43083. if err != nil {
  43084. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  43085. }
  43086. return oldValue.AgentID, nil
  43087. }
  43088. // ResetAgentID resets all changes to the "agent_id" field.
  43089. func (m *WxMutation) ResetAgentID() {
  43090. m.agent = nil
  43091. }
  43092. // SetAPIBase sets the "api_base" field.
  43093. func (m *WxMutation) SetAPIBase(s string) {
  43094. m.api_base = &s
  43095. }
  43096. // APIBase returns the value of the "api_base" field in the mutation.
  43097. func (m *WxMutation) APIBase() (r string, exists bool) {
  43098. v := m.api_base
  43099. if v == nil {
  43100. return
  43101. }
  43102. return *v, true
  43103. }
  43104. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  43105. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43106. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43107. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  43108. if !m.op.Is(OpUpdateOne) {
  43109. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  43110. }
  43111. if m.id == nil || m.oldValue == nil {
  43112. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  43113. }
  43114. oldValue, err := m.oldValue(ctx)
  43115. if err != nil {
  43116. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  43117. }
  43118. return oldValue.APIBase, nil
  43119. }
  43120. // ClearAPIBase clears the value of the "api_base" field.
  43121. func (m *WxMutation) ClearAPIBase() {
  43122. m.api_base = nil
  43123. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  43124. }
  43125. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  43126. func (m *WxMutation) APIBaseCleared() bool {
  43127. _, ok := m.clearedFields[wx.FieldAPIBase]
  43128. return ok
  43129. }
  43130. // ResetAPIBase resets all changes to the "api_base" field.
  43131. func (m *WxMutation) ResetAPIBase() {
  43132. m.api_base = nil
  43133. delete(m.clearedFields, wx.FieldAPIBase)
  43134. }
  43135. // SetAPIKey sets the "api_key" field.
  43136. func (m *WxMutation) SetAPIKey(s string) {
  43137. m.api_key = &s
  43138. }
  43139. // APIKey returns the value of the "api_key" field in the mutation.
  43140. func (m *WxMutation) APIKey() (r string, exists bool) {
  43141. v := m.api_key
  43142. if v == nil {
  43143. return
  43144. }
  43145. return *v, true
  43146. }
  43147. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  43148. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43149. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43150. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  43151. if !m.op.Is(OpUpdateOne) {
  43152. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  43153. }
  43154. if m.id == nil || m.oldValue == nil {
  43155. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  43156. }
  43157. oldValue, err := m.oldValue(ctx)
  43158. if err != nil {
  43159. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  43160. }
  43161. return oldValue.APIKey, nil
  43162. }
  43163. // ClearAPIKey clears the value of the "api_key" field.
  43164. func (m *WxMutation) ClearAPIKey() {
  43165. m.api_key = nil
  43166. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  43167. }
  43168. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  43169. func (m *WxMutation) APIKeyCleared() bool {
  43170. _, ok := m.clearedFields[wx.FieldAPIKey]
  43171. return ok
  43172. }
  43173. // ResetAPIKey resets all changes to the "api_key" field.
  43174. func (m *WxMutation) ResetAPIKey() {
  43175. m.api_key = nil
  43176. delete(m.clearedFields, wx.FieldAPIKey)
  43177. }
  43178. // SetAllowList sets the "allow_list" field.
  43179. func (m *WxMutation) SetAllowList(s []string) {
  43180. m.allow_list = &s
  43181. m.appendallow_list = nil
  43182. }
  43183. // AllowList returns the value of the "allow_list" field in the mutation.
  43184. func (m *WxMutation) AllowList() (r []string, exists bool) {
  43185. v := m.allow_list
  43186. if v == nil {
  43187. return
  43188. }
  43189. return *v, true
  43190. }
  43191. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  43192. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43193. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43194. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  43195. if !m.op.Is(OpUpdateOne) {
  43196. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  43197. }
  43198. if m.id == nil || m.oldValue == nil {
  43199. return v, errors.New("OldAllowList requires an ID field in the mutation")
  43200. }
  43201. oldValue, err := m.oldValue(ctx)
  43202. if err != nil {
  43203. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  43204. }
  43205. return oldValue.AllowList, nil
  43206. }
  43207. // AppendAllowList adds s to the "allow_list" field.
  43208. func (m *WxMutation) AppendAllowList(s []string) {
  43209. m.appendallow_list = append(m.appendallow_list, s...)
  43210. }
  43211. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  43212. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  43213. if len(m.appendallow_list) == 0 {
  43214. return nil, false
  43215. }
  43216. return m.appendallow_list, true
  43217. }
  43218. // ResetAllowList resets all changes to the "allow_list" field.
  43219. func (m *WxMutation) ResetAllowList() {
  43220. m.allow_list = nil
  43221. m.appendallow_list = nil
  43222. }
  43223. // SetGroupAllowList sets the "group_allow_list" field.
  43224. func (m *WxMutation) SetGroupAllowList(s []string) {
  43225. m.group_allow_list = &s
  43226. m.appendgroup_allow_list = nil
  43227. }
  43228. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  43229. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  43230. v := m.group_allow_list
  43231. if v == nil {
  43232. return
  43233. }
  43234. return *v, true
  43235. }
  43236. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  43237. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43238. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43239. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  43240. if !m.op.Is(OpUpdateOne) {
  43241. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  43242. }
  43243. if m.id == nil || m.oldValue == nil {
  43244. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  43245. }
  43246. oldValue, err := m.oldValue(ctx)
  43247. if err != nil {
  43248. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  43249. }
  43250. return oldValue.GroupAllowList, nil
  43251. }
  43252. // AppendGroupAllowList adds s to the "group_allow_list" field.
  43253. func (m *WxMutation) AppendGroupAllowList(s []string) {
  43254. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  43255. }
  43256. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  43257. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  43258. if len(m.appendgroup_allow_list) == 0 {
  43259. return nil, false
  43260. }
  43261. return m.appendgroup_allow_list, true
  43262. }
  43263. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  43264. func (m *WxMutation) ResetGroupAllowList() {
  43265. m.group_allow_list = nil
  43266. m.appendgroup_allow_list = nil
  43267. }
  43268. // SetBlockList sets the "block_list" field.
  43269. func (m *WxMutation) SetBlockList(s []string) {
  43270. m.block_list = &s
  43271. m.appendblock_list = nil
  43272. }
  43273. // BlockList returns the value of the "block_list" field in the mutation.
  43274. func (m *WxMutation) BlockList() (r []string, exists bool) {
  43275. v := m.block_list
  43276. if v == nil {
  43277. return
  43278. }
  43279. return *v, true
  43280. }
  43281. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  43282. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43283. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43284. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  43285. if !m.op.Is(OpUpdateOne) {
  43286. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  43287. }
  43288. if m.id == nil || m.oldValue == nil {
  43289. return v, errors.New("OldBlockList requires an ID field in the mutation")
  43290. }
  43291. oldValue, err := m.oldValue(ctx)
  43292. if err != nil {
  43293. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  43294. }
  43295. return oldValue.BlockList, nil
  43296. }
  43297. // AppendBlockList adds s to the "block_list" field.
  43298. func (m *WxMutation) AppendBlockList(s []string) {
  43299. m.appendblock_list = append(m.appendblock_list, s...)
  43300. }
  43301. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  43302. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  43303. if len(m.appendblock_list) == 0 {
  43304. return nil, false
  43305. }
  43306. return m.appendblock_list, true
  43307. }
  43308. // ResetBlockList resets all changes to the "block_list" field.
  43309. func (m *WxMutation) ResetBlockList() {
  43310. m.block_list = nil
  43311. m.appendblock_list = nil
  43312. }
  43313. // SetGroupBlockList sets the "group_block_list" field.
  43314. func (m *WxMutation) SetGroupBlockList(s []string) {
  43315. m.group_block_list = &s
  43316. m.appendgroup_block_list = nil
  43317. }
  43318. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  43319. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  43320. v := m.group_block_list
  43321. if v == nil {
  43322. return
  43323. }
  43324. return *v, true
  43325. }
  43326. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  43327. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43328. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43329. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  43330. if !m.op.Is(OpUpdateOne) {
  43331. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  43332. }
  43333. if m.id == nil || m.oldValue == nil {
  43334. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  43335. }
  43336. oldValue, err := m.oldValue(ctx)
  43337. if err != nil {
  43338. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  43339. }
  43340. return oldValue.GroupBlockList, nil
  43341. }
  43342. // AppendGroupBlockList adds s to the "group_block_list" field.
  43343. func (m *WxMutation) AppendGroupBlockList(s []string) {
  43344. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  43345. }
  43346. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  43347. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  43348. if len(m.appendgroup_block_list) == 0 {
  43349. return nil, false
  43350. }
  43351. return m.appendgroup_block_list, true
  43352. }
  43353. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  43354. func (m *WxMutation) ResetGroupBlockList() {
  43355. m.group_block_list = nil
  43356. m.appendgroup_block_list = nil
  43357. }
  43358. // SetCtype sets the "ctype" field.
  43359. func (m *WxMutation) SetCtype(u uint64) {
  43360. m.ctype = &u
  43361. m.addctype = nil
  43362. }
  43363. // Ctype returns the value of the "ctype" field in the mutation.
  43364. func (m *WxMutation) Ctype() (r uint64, exists bool) {
  43365. v := m.ctype
  43366. if v == nil {
  43367. return
  43368. }
  43369. return *v, true
  43370. }
  43371. // OldCtype returns the old "ctype" field's value of the Wx entity.
  43372. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43373. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43374. func (m *WxMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  43375. if !m.op.Is(OpUpdateOne) {
  43376. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  43377. }
  43378. if m.id == nil || m.oldValue == nil {
  43379. return v, errors.New("OldCtype requires an ID field in the mutation")
  43380. }
  43381. oldValue, err := m.oldValue(ctx)
  43382. if err != nil {
  43383. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  43384. }
  43385. return oldValue.Ctype, nil
  43386. }
  43387. // AddCtype adds u to the "ctype" field.
  43388. func (m *WxMutation) AddCtype(u int64) {
  43389. if m.addctype != nil {
  43390. *m.addctype += u
  43391. } else {
  43392. m.addctype = &u
  43393. }
  43394. }
  43395. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  43396. func (m *WxMutation) AddedCtype() (r int64, exists bool) {
  43397. v := m.addctype
  43398. if v == nil {
  43399. return
  43400. }
  43401. return *v, true
  43402. }
  43403. // ClearCtype clears the value of the "ctype" field.
  43404. func (m *WxMutation) ClearCtype() {
  43405. m.ctype = nil
  43406. m.addctype = nil
  43407. m.clearedFields[wx.FieldCtype] = struct{}{}
  43408. }
  43409. // CtypeCleared returns if the "ctype" field was cleared in this mutation.
  43410. func (m *WxMutation) CtypeCleared() bool {
  43411. _, ok := m.clearedFields[wx.FieldCtype]
  43412. return ok
  43413. }
  43414. // ResetCtype resets all changes to the "ctype" field.
  43415. func (m *WxMutation) ResetCtype() {
  43416. m.ctype = nil
  43417. m.addctype = nil
  43418. delete(m.clearedFields, wx.FieldCtype)
  43419. }
  43420. // ClearServer clears the "server" edge to the Server entity.
  43421. func (m *WxMutation) ClearServer() {
  43422. m.clearedserver = true
  43423. m.clearedFields[wx.FieldServerID] = struct{}{}
  43424. }
  43425. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  43426. func (m *WxMutation) ServerCleared() bool {
  43427. return m.ServerIDCleared() || m.clearedserver
  43428. }
  43429. // ServerIDs returns the "server" edge IDs in the mutation.
  43430. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  43431. // ServerID instead. It exists only for internal usage by the builders.
  43432. func (m *WxMutation) ServerIDs() (ids []uint64) {
  43433. if id := m.server; id != nil {
  43434. ids = append(ids, *id)
  43435. }
  43436. return
  43437. }
  43438. // ResetServer resets all changes to the "server" edge.
  43439. func (m *WxMutation) ResetServer() {
  43440. m.server = nil
  43441. m.clearedserver = false
  43442. }
  43443. // ClearAgent clears the "agent" edge to the Agent entity.
  43444. func (m *WxMutation) ClearAgent() {
  43445. m.clearedagent = true
  43446. m.clearedFields[wx.FieldAgentID] = struct{}{}
  43447. }
  43448. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  43449. func (m *WxMutation) AgentCleared() bool {
  43450. return m.clearedagent
  43451. }
  43452. // AgentIDs returns the "agent" edge IDs in the mutation.
  43453. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  43454. // AgentID instead. It exists only for internal usage by the builders.
  43455. func (m *WxMutation) AgentIDs() (ids []uint64) {
  43456. if id := m.agent; id != nil {
  43457. ids = append(ids, *id)
  43458. }
  43459. return
  43460. }
  43461. // ResetAgent resets all changes to the "agent" edge.
  43462. func (m *WxMutation) ResetAgent() {
  43463. m.agent = nil
  43464. m.clearedagent = false
  43465. }
  43466. // Where appends a list predicates to the WxMutation builder.
  43467. func (m *WxMutation) Where(ps ...predicate.Wx) {
  43468. m.predicates = append(m.predicates, ps...)
  43469. }
  43470. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  43471. // users can use type-assertion to append predicates that do not depend on any generated package.
  43472. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  43473. p := make([]predicate.Wx, len(ps))
  43474. for i := range ps {
  43475. p[i] = ps[i]
  43476. }
  43477. m.Where(p...)
  43478. }
  43479. // Op returns the operation name.
  43480. func (m *WxMutation) Op() Op {
  43481. return m.op
  43482. }
  43483. // SetOp allows setting the mutation operation.
  43484. func (m *WxMutation) SetOp(op Op) {
  43485. m.op = op
  43486. }
  43487. // Type returns the node type of this mutation (Wx).
  43488. func (m *WxMutation) Type() string {
  43489. return m.typ
  43490. }
  43491. // Fields returns all fields that were changed during this mutation. Note that in
  43492. // order to get all numeric fields that were incremented/decremented, call
  43493. // AddedFields().
  43494. func (m *WxMutation) Fields() []string {
  43495. fields := make([]string, 0, 22)
  43496. if m.created_at != nil {
  43497. fields = append(fields, wx.FieldCreatedAt)
  43498. }
  43499. if m.updated_at != nil {
  43500. fields = append(fields, wx.FieldUpdatedAt)
  43501. }
  43502. if m.status != nil {
  43503. fields = append(fields, wx.FieldStatus)
  43504. }
  43505. if m.deleted_at != nil {
  43506. fields = append(fields, wx.FieldDeletedAt)
  43507. }
  43508. if m.server != nil {
  43509. fields = append(fields, wx.FieldServerID)
  43510. }
  43511. if m.port != nil {
  43512. fields = append(fields, wx.FieldPort)
  43513. }
  43514. if m.process_id != nil {
  43515. fields = append(fields, wx.FieldProcessID)
  43516. }
  43517. if m.callback != nil {
  43518. fields = append(fields, wx.FieldCallback)
  43519. }
  43520. if m.wxid != nil {
  43521. fields = append(fields, wx.FieldWxid)
  43522. }
  43523. if m.account != nil {
  43524. fields = append(fields, wx.FieldAccount)
  43525. }
  43526. if m.nickname != nil {
  43527. fields = append(fields, wx.FieldNickname)
  43528. }
  43529. if m.tel != nil {
  43530. fields = append(fields, wx.FieldTel)
  43531. }
  43532. if m.head_big != nil {
  43533. fields = append(fields, wx.FieldHeadBig)
  43534. }
  43535. if m.organization_id != nil {
  43536. fields = append(fields, wx.FieldOrganizationID)
  43537. }
  43538. if m.agent != nil {
  43539. fields = append(fields, wx.FieldAgentID)
  43540. }
  43541. if m.api_base != nil {
  43542. fields = append(fields, wx.FieldAPIBase)
  43543. }
  43544. if m.api_key != nil {
  43545. fields = append(fields, wx.FieldAPIKey)
  43546. }
  43547. if m.allow_list != nil {
  43548. fields = append(fields, wx.FieldAllowList)
  43549. }
  43550. if m.group_allow_list != nil {
  43551. fields = append(fields, wx.FieldGroupAllowList)
  43552. }
  43553. if m.block_list != nil {
  43554. fields = append(fields, wx.FieldBlockList)
  43555. }
  43556. if m.group_block_list != nil {
  43557. fields = append(fields, wx.FieldGroupBlockList)
  43558. }
  43559. if m.ctype != nil {
  43560. fields = append(fields, wx.FieldCtype)
  43561. }
  43562. return fields
  43563. }
  43564. // Field returns the value of a field with the given name. The second boolean
  43565. // return value indicates that this field was not set, or was not defined in the
  43566. // schema.
  43567. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  43568. switch name {
  43569. case wx.FieldCreatedAt:
  43570. return m.CreatedAt()
  43571. case wx.FieldUpdatedAt:
  43572. return m.UpdatedAt()
  43573. case wx.FieldStatus:
  43574. return m.Status()
  43575. case wx.FieldDeletedAt:
  43576. return m.DeletedAt()
  43577. case wx.FieldServerID:
  43578. return m.ServerID()
  43579. case wx.FieldPort:
  43580. return m.Port()
  43581. case wx.FieldProcessID:
  43582. return m.ProcessID()
  43583. case wx.FieldCallback:
  43584. return m.Callback()
  43585. case wx.FieldWxid:
  43586. return m.Wxid()
  43587. case wx.FieldAccount:
  43588. return m.Account()
  43589. case wx.FieldNickname:
  43590. return m.Nickname()
  43591. case wx.FieldTel:
  43592. return m.Tel()
  43593. case wx.FieldHeadBig:
  43594. return m.HeadBig()
  43595. case wx.FieldOrganizationID:
  43596. return m.OrganizationID()
  43597. case wx.FieldAgentID:
  43598. return m.AgentID()
  43599. case wx.FieldAPIBase:
  43600. return m.APIBase()
  43601. case wx.FieldAPIKey:
  43602. return m.APIKey()
  43603. case wx.FieldAllowList:
  43604. return m.AllowList()
  43605. case wx.FieldGroupAllowList:
  43606. return m.GroupAllowList()
  43607. case wx.FieldBlockList:
  43608. return m.BlockList()
  43609. case wx.FieldGroupBlockList:
  43610. return m.GroupBlockList()
  43611. case wx.FieldCtype:
  43612. return m.Ctype()
  43613. }
  43614. return nil, false
  43615. }
  43616. // OldField returns the old value of the field from the database. An error is
  43617. // returned if the mutation operation is not UpdateOne, or the query to the
  43618. // database failed.
  43619. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  43620. switch name {
  43621. case wx.FieldCreatedAt:
  43622. return m.OldCreatedAt(ctx)
  43623. case wx.FieldUpdatedAt:
  43624. return m.OldUpdatedAt(ctx)
  43625. case wx.FieldStatus:
  43626. return m.OldStatus(ctx)
  43627. case wx.FieldDeletedAt:
  43628. return m.OldDeletedAt(ctx)
  43629. case wx.FieldServerID:
  43630. return m.OldServerID(ctx)
  43631. case wx.FieldPort:
  43632. return m.OldPort(ctx)
  43633. case wx.FieldProcessID:
  43634. return m.OldProcessID(ctx)
  43635. case wx.FieldCallback:
  43636. return m.OldCallback(ctx)
  43637. case wx.FieldWxid:
  43638. return m.OldWxid(ctx)
  43639. case wx.FieldAccount:
  43640. return m.OldAccount(ctx)
  43641. case wx.FieldNickname:
  43642. return m.OldNickname(ctx)
  43643. case wx.FieldTel:
  43644. return m.OldTel(ctx)
  43645. case wx.FieldHeadBig:
  43646. return m.OldHeadBig(ctx)
  43647. case wx.FieldOrganizationID:
  43648. return m.OldOrganizationID(ctx)
  43649. case wx.FieldAgentID:
  43650. return m.OldAgentID(ctx)
  43651. case wx.FieldAPIBase:
  43652. return m.OldAPIBase(ctx)
  43653. case wx.FieldAPIKey:
  43654. return m.OldAPIKey(ctx)
  43655. case wx.FieldAllowList:
  43656. return m.OldAllowList(ctx)
  43657. case wx.FieldGroupAllowList:
  43658. return m.OldGroupAllowList(ctx)
  43659. case wx.FieldBlockList:
  43660. return m.OldBlockList(ctx)
  43661. case wx.FieldGroupBlockList:
  43662. return m.OldGroupBlockList(ctx)
  43663. case wx.FieldCtype:
  43664. return m.OldCtype(ctx)
  43665. }
  43666. return nil, fmt.Errorf("unknown Wx field %s", name)
  43667. }
  43668. // SetField sets the value of a field with the given name. It returns an error if
  43669. // the field is not defined in the schema, or if the type mismatched the field
  43670. // type.
  43671. func (m *WxMutation) SetField(name string, value ent.Value) error {
  43672. switch name {
  43673. case wx.FieldCreatedAt:
  43674. v, ok := value.(time.Time)
  43675. if !ok {
  43676. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43677. }
  43678. m.SetCreatedAt(v)
  43679. return nil
  43680. case wx.FieldUpdatedAt:
  43681. v, ok := value.(time.Time)
  43682. if !ok {
  43683. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43684. }
  43685. m.SetUpdatedAt(v)
  43686. return nil
  43687. case wx.FieldStatus:
  43688. v, ok := value.(uint8)
  43689. if !ok {
  43690. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43691. }
  43692. m.SetStatus(v)
  43693. return nil
  43694. case wx.FieldDeletedAt:
  43695. v, ok := value.(time.Time)
  43696. if !ok {
  43697. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43698. }
  43699. m.SetDeletedAt(v)
  43700. return nil
  43701. case wx.FieldServerID:
  43702. v, ok := value.(uint64)
  43703. if !ok {
  43704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43705. }
  43706. m.SetServerID(v)
  43707. return nil
  43708. case wx.FieldPort:
  43709. v, ok := value.(string)
  43710. if !ok {
  43711. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43712. }
  43713. m.SetPort(v)
  43714. return nil
  43715. case wx.FieldProcessID:
  43716. v, ok := value.(string)
  43717. if !ok {
  43718. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43719. }
  43720. m.SetProcessID(v)
  43721. return nil
  43722. case wx.FieldCallback:
  43723. v, ok := value.(string)
  43724. if !ok {
  43725. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43726. }
  43727. m.SetCallback(v)
  43728. return nil
  43729. case wx.FieldWxid:
  43730. v, ok := value.(string)
  43731. if !ok {
  43732. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43733. }
  43734. m.SetWxid(v)
  43735. return nil
  43736. case wx.FieldAccount:
  43737. v, ok := value.(string)
  43738. if !ok {
  43739. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43740. }
  43741. m.SetAccount(v)
  43742. return nil
  43743. case wx.FieldNickname:
  43744. v, ok := value.(string)
  43745. if !ok {
  43746. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43747. }
  43748. m.SetNickname(v)
  43749. return nil
  43750. case wx.FieldTel:
  43751. v, ok := value.(string)
  43752. if !ok {
  43753. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43754. }
  43755. m.SetTel(v)
  43756. return nil
  43757. case wx.FieldHeadBig:
  43758. v, ok := value.(string)
  43759. if !ok {
  43760. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43761. }
  43762. m.SetHeadBig(v)
  43763. return nil
  43764. case wx.FieldOrganizationID:
  43765. v, ok := value.(uint64)
  43766. if !ok {
  43767. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43768. }
  43769. m.SetOrganizationID(v)
  43770. return nil
  43771. case wx.FieldAgentID:
  43772. v, ok := value.(uint64)
  43773. if !ok {
  43774. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43775. }
  43776. m.SetAgentID(v)
  43777. return nil
  43778. case wx.FieldAPIBase:
  43779. v, ok := value.(string)
  43780. if !ok {
  43781. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43782. }
  43783. m.SetAPIBase(v)
  43784. return nil
  43785. case wx.FieldAPIKey:
  43786. v, ok := value.(string)
  43787. if !ok {
  43788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43789. }
  43790. m.SetAPIKey(v)
  43791. return nil
  43792. case wx.FieldAllowList:
  43793. v, ok := value.([]string)
  43794. if !ok {
  43795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43796. }
  43797. m.SetAllowList(v)
  43798. return nil
  43799. case wx.FieldGroupAllowList:
  43800. v, ok := value.([]string)
  43801. if !ok {
  43802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43803. }
  43804. m.SetGroupAllowList(v)
  43805. return nil
  43806. case wx.FieldBlockList:
  43807. v, ok := value.([]string)
  43808. if !ok {
  43809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43810. }
  43811. m.SetBlockList(v)
  43812. return nil
  43813. case wx.FieldGroupBlockList:
  43814. v, ok := value.([]string)
  43815. if !ok {
  43816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43817. }
  43818. m.SetGroupBlockList(v)
  43819. return nil
  43820. case wx.FieldCtype:
  43821. v, ok := value.(uint64)
  43822. if !ok {
  43823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43824. }
  43825. m.SetCtype(v)
  43826. return nil
  43827. }
  43828. return fmt.Errorf("unknown Wx field %s", name)
  43829. }
  43830. // AddedFields returns all numeric fields that were incremented/decremented during
  43831. // this mutation.
  43832. func (m *WxMutation) AddedFields() []string {
  43833. var fields []string
  43834. if m.addstatus != nil {
  43835. fields = append(fields, wx.FieldStatus)
  43836. }
  43837. if m.addorganization_id != nil {
  43838. fields = append(fields, wx.FieldOrganizationID)
  43839. }
  43840. if m.addctype != nil {
  43841. fields = append(fields, wx.FieldCtype)
  43842. }
  43843. return fields
  43844. }
  43845. // AddedField returns the numeric value that was incremented/decremented on a field
  43846. // with the given name. The second boolean return value indicates that this field
  43847. // was not set, or was not defined in the schema.
  43848. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  43849. switch name {
  43850. case wx.FieldStatus:
  43851. return m.AddedStatus()
  43852. case wx.FieldOrganizationID:
  43853. return m.AddedOrganizationID()
  43854. case wx.FieldCtype:
  43855. return m.AddedCtype()
  43856. }
  43857. return nil, false
  43858. }
  43859. // AddField adds the value to the 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 *WxMutation) AddField(name string, value ent.Value) error {
  43863. switch name {
  43864. case wx.FieldStatus:
  43865. v, ok := value.(int8)
  43866. if !ok {
  43867. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43868. }
  43869. m.AddStatus(v)
  43870. return nil
  43871. case wx.FieldOrganizationID:
  43872. v, ok := value.(int64)
  43873. if !ok {
  43874. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43875. }
  43876. m.AddOrganizationID(v)
  43877. return nil
  43878. case wx.FieldCtype:
  43879. v, ok := value.(int64)
  43880. if !ok {
  43881. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43882. }
  43883. m.AddCtype(v)
  43884. return nil
  43885. }
  43886. return fmt.Errorf("unknown Wx numeric field %s", name)
  43887. }
  43888. // ClearedFields returns all nullable fields that were cleared during this
  43889. // mutation.
  43890. func (m *WxMutation) ClearedFields() []string {
  43891. var fields []string
  43892. if m.FieldCleared(wx.FieldStatus) {
  43893. fields = append(fields, wx.FieldStatus)
  43894. }
  43895. if m.FieldCleared(wx.FieldDeletedAt) {
  43896. fields = append(fields, wx.FieldDeletedAt)
  43897. }
  43898. if m.FieldCleared(wx.FieldServerID) {
  43899. fields = append(fields, wx.FieldServerID)
  43900. }
  43901. if m.FieldCleared(wx.FieldOrganizationID) {
  43902. fields = append(fields, wx.FieldOrganizationID)
  43903. }
  43904. if m.FieldCleared(wx.FieldAPIBase) {
  43905. fields = append(fields, wx.FieldAPIBase)
  43906. }
  43907. if m.FieldCleared(wx.FieldAPIKey) {
  43908. fields = append(fields, wx.FieldAPIKey)
  43909. }
  43910. if m.FieldCleared(wx.FieldCtype) {
  43911. fields = append(fields, wx.FieldCtype)
  43912. }
  43913. return fields
  43914. }
  43915. // FieldCleared returns a boolean indicating if a field with the given name was
  43916. // cleared in this mutation.
  43917. func (m *WxMutation) FieldCleared(name string) bool {
  43918. _, ok := m.clearedFields[name]
  43919. return ok
  43920. }
  43921. // ClearField clears the value of the field with the given name. It returns an
  43922. // error if the field is not defined in the schema.
  43923. func (m *WxMutation) ClearField(name string) error {
  43924. switch name {
  43925. case wx.FieldStatus:
  43926. m.ClearStatus()
  43927. return nil
  43928. case wx.FieldDeletedAt:
  43929. m.ClearDeletedAt()
  43930. return nil
  43931. case wx.FieldServerID:
  43932. m.ClearServerID()
  43933. return nil
  43934. case wx.FieldOrganizationID:
  43935. m.ClearOrganizationID()
  43936. return nil
  43937. case wx.FieldAPIBase:
  43938. m.ClearAPIBase()
  43939. return nil
  43940. case wx.FieldAPIKey:
  43941. m.ClearAPIKey()
  43942. return nil
  43943. case wx.FieldCtype:
  43944. m.ClearCtype()
  43945. return nil
  43946. }
  43947. return fmt.Errorf("unknown Wx nullable field %s", name)
  43948. }
  43949. // ResetField resets all changes in the mutation for the field with the given name.
  43950. // It returns an error if the field is not defined in the schema.
  43951. func (m *WxMutation) ResetField(name string) error {
  43952. switch name {
  43953. case wx.FieldCreatedAt:
  43954. m.ResetCreatedAt()
  43955. return nil
  43956. case wx.FieldUpdatedAt:
  43957. m.ResetUpdatedAt()
  43958. return nil
  43959. case wx.FieldStatus:
  43960. m.ResetStatus()
  43961. return nil
  43962. case wx.FieldDeletedAt:
  43963. m.ResetDeletedAt()
  43964. return nil
  43965. case wx.FieldServerID:
  43966. m.ResetServerID()
  43967. return nil
  43968. case wx.FieldPort:
  43969. m.ResetPort()
  43970. return nil
  43971. case wx.FieldProcessID:
  43972. m.ResetProcessID()
  43973. return nil
  43974. case wx.FieldCallback:
  43975. m.ResetCallback()
  43976. return nil
  43977. case wx.FieldWxid:
  43978. m.ResetWxid()
  43979. return nil
  43980. case wx.FieldAccount:
  43981. m.ResetAccount()
  43982. return nil
  43983. case wx.FieldNickname:
  43984. m.ResetNickname()
  43985. return nil
  43986. case wx.FieldTel:
  43987. m.ResetTel()
  43988. return nil
  43989. case wx.FieldHeadBig:
  43990. m.ResetHeadBig()
  43991. return nil
  43992. case wx.FieldOrganizationID:
  43993. m.ResetOrganizationID()
  43994. return nil
  43995. case wx.FieldAgentID:
  43996. m.ResetAgentID()
  43997. return nil
  43998. case wx.FieldAPIBase:
  43999. m.ResetAPIBase()
  44000. return nil
  44001. case wx.FieldAPIKey:
  44002. m.ResetAPIKey()
  44003. return nil
  44004. case wx.FieldAllowList:
  44005. m.ResetAllowList()
  44006. return nil
  44007. case wx.FieldGroupAllowList:
  44008. m.ResetGroupAllowList()
  44009. return nil
  44010. case wx.FieldBlockList:
  44011. m.ResetBlockList()
  44012. return nil
  44013. case wx.FieldGroupBlockList:
  44014. m.ResetGroupBlockList()
  44015. return nil
  44016. case wx.FieldCtype:
  44017. m.ResetCtype()
  44018. return nil
  44019. }
  44020. return fmt.Errorf("unknown Wx field %s", name)
  44021. }
  44022. // AddedEdges returns all edge names that were set/added in this mutation.
  44023. func (m *WxMutation) AddedEdges() []string {
  44024. edges := make([]string, 0, 2)
  44025. if m.server != nil {
  44026. edges = append(edges, wx.EdgeServer)
  44027. }
  44028. if m.agent != nil {
  44029. edges = append(edges, wx.EdgeAgent)
  44030. }
  44031. return edges
  44032. }
  44033. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  44034. // name in this mutation.
  44035. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  44036. switch name {
  44037. case wx.EdgeServer:
  44038. if id := m.server; id != nil {
  44039. return []ent.Value{*id}
  44040. }
  44041. case wx.EdgeAgent:
  44042. if id := m.agent; id != nil {
  44043. return []ent.Value{*id}
  44044. }
  44045. }
  44046. return nil
  44047. }
  44048. // RemovedEdges returns all edge names that were removed in this mutation.
  44049. func (m *WxMutation) RemovedEdges() []string {
  44050. edges := make([]string, 0, 2)
  44051. return edges
  44052. }
  44053. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  44054. // the given name in this mutation.
  44055. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  44056. return nil
  44057. }
  44058. // ClearedEdges returns all edge names that were cleared in this mutation.
  44059. func (m *WxMutation) ClearedEdges() []string {
  44060. edges := make([]string, 0, 2)
  44061. if m.clearedserver {
  44062. edges = append(edges, wx.EdgeServer)
  44063. }
  44064. if m.clearedagent {
  44065. edges = append(edges, wx.EdgeAgent)
  44066. }
  44067. return edges
  44068. }
  44069. // EdgeCleared returns a boolean which indicates if the edge with the given name
  44070. // was cleared in this mutation.
  44071. func (m *WxMutation) EdgeCleared(name string) bool {
  44072. switch name {
  44073. case wx.EdgeServer:
  44074. return m.clearedserver
  44075. case wx.EdgeAgent:
  44076. return m.clearedagent
  44077. }
  44078. return false
  44079. }
  44080. // ClearEdge clears the value of the edge with the given name. It returns an error
  44081. // if that edge is not defined in the schema.
  44082. func (m *WxMutation) ClearEdge(name string) error {
  44083. switch name {
  44084. case wx.EdgeServer:
  44085. m.ClearServer()
  44086. return nil
  44087. case wx.EdgeAgent:
  44088. m.ClearAgent()
  44089. return nil
  44090. }
  44091. return fmt.Errorf("unknown Wx unique edge %s", name)
  44092. }
  44093. // ResetEdge resets all changes to the edge with the given name in this mutation.
  44094. // It returns an error if the edge is not defined in the schema.
  44095. func (m *WxMutation) ResetEdge(name string) error {
  44096. switch name {
  44097. case wx.EdgeServer:
  44098. m.ResetServer()
  44099. return nil
  44100. case wx.EdgeAgent:
  44101. m.ResetAgent()
  44102. return nil
  44103. }
  44104. return fmt.Errorf("unknown Wx edge %s", name)
  44105. }
  44106. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  44107. type WxCardMutation struct {
  44108. config
  44109. op Op
  44110. typ string
  44111. id *uint64
  44112. created_at *time.Time
  44113. updated_at *time.Time
  44114. deleted_at *time.Time
  44115. user_id *uint64
  44116. adduser_id *int64
  44117. wx_user_id *uint64
  44118. addwx_user_id *int64
  44119. avatar *string
  44120. logo *string
  44121. name *string
  44122. company *string
  44123. address *string
  44124. phone *string
  44125. official_account *string
  44126. wechat_account *string
  44127. email *string
  44128. api_base *string
  44129. api_key *string
  44130. ai_info *string
  44131. intro *string
  44132. clearedFields map[string]struct{}
  44133. done bool
  44134. oldValue func(context.Context) (*WxCard, error)
  44135. predicates []predicate.WxCard
  44136. }
  44137. var _ ent.Mutation = (*WxCardMutation)(nil)
  44138. // wxcardOption allows management of the mutation configuration using functional options.
  44139. type wxcardOption func(*WxCardMutation)
  44140. // newWxCardMutation creates new mutation for the WxCard entity.
  44141. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  44142. m := &WxCardMutation{
  44143. config: c,
  44144. op: op,
  44145. typ: TypeWxCard,
  44146. clearedFields: make(map[string]struct{}),
  44147. }
  44148. for _, opt := range opts {
  44149. opt(m)
  44150. }
  44151. return m
  44152. }
  44153. // withWxCardID sets the ID field of the mutation.
  44154. func withWxCardID(id uint64) wxcardOption {
  44155. return func(m *WxCardMutation) {
  44156. var (
  44157. err error
  44158. once sync.Once
  44159. value *WxCard
  44160. )
  44161. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  44162. once.Do(func() {
  44163. if m.done {
  44164. err = errors.New("querying old values post mutation is not allowed")
  44165. } else {
  44166. value, err = m.Client().WxCard.Get(ctx, id)
  44167. }
  44168. })
  44169. return value, err
  44170. }
  44171. m.id = &id
  44172. }
  44173. }
  44174. // withWxCard sets the old WxCard of the mutation.
  44175. func withWxCard(node *WxCard) wxcardOption {
  44176. return func(m *WxCardMutation) {
  44177. m.oldValue = func(context.Context) (*WxCard, error) {
  44178. return node, nil
  44179. }
  44180. m.id = &node.ID
  44181. }
  44182. }
  44183. // Client returns a new `ent.Client` from the mutation. If the mutation was
  44184. // executed in a transaction (ent.Tx), a transactional client is returned.
  44185. func (m WxCardMutation) Client() *Client {
  44186. client := &Client{config: m.config}
  44187. client.init()
  44188. return client
  44189. }
  44190. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  44191. // it returns an error otherwise.
  44192. func (m WxCardMutation) Tx() (*Tx, error) {
  44193. if _, ok := m.driver.(*txDriver); !ok {
  44194. return nil, errors.New("ent: mutation is not running in a transaction")
  44195. }
  44196. tx := &Tx{config: m.config}
  44197. tx.init()
  44198. return tx, nil
  44199. }
  44200. // SetID sets the value of the id field. Note that this
  44201. // operation is only accepted on creation of WxCard entities.
  44202. func (m *WxCardMutation) SetID(id uint64) {
  44203. m.id = &id
  44204. }
  44205. // ID returns the ID value in the mutation. Note that the ID is only available
  44206. // if it was provided to the builder or after it was returned from the database.
  44207. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  44208. if m.id == nil {
  44209. return
  44210. }
  44211. return *m.id, true
  44212. }
  44213. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  44214. // That means, if the mutation is applied within a transaction with an isolation level such
  44215. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  44216. // or updated by the mutation.
  44217. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  44218. switch {
  44219. case m.op.Is(OpUpdateOne | OpDeleteOne):
  44220. id, exists := m.ID()
  44221. if exists {
  44222. return []uint64{id}, nil
  44223. }
  44224. fallthrough
  44225. case m.op.Is(OpUpdate | OpDelete):
  44226. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  44227. default:
  44228. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  44229. }
  44230. }
  44231. // SetCreatedAt sets the "created_at" field.
  44232. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  44233. m.created_at = &t
  44234. }
  44235. // CreatedAt returns the value of the "created_at" field in the mutation.
  44236. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  44237. v := m.created_at
  44238. if v == nil {
  44239. return
  44240. }
  44241. return *v, true
  44242. }
  44243. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  44244. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44245. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44246. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  44247. if !m.op.Is(OpUpdateOne) {
  44248. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  44249. }
  44250. if m.id == nil || m.oldValue == nil {
  44251. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  44252. }
  44253. oldValue, err := m.oldValue(ctx)
  44254. if err != nil {
  44255. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  44256. }
  44257. return oldValue.CreatedAt, nil
  44258. }
  44259. // ResetCreatedAt resets all changes to the "created_at" field.
  44260. func (m *WxCardMutation) ResetCreatedAt() {
  44261. m.created_at = nil
  44262. }
  44263. // SetUpdatedAt sets the "updated_at" field.
  44264. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  44265. m.updated_at = &t
  44266. }
  44267. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  44268. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  44269. v := m.updated_at
  44270. if v == nil {
  44271. return
  44272. }
  44273. return *v, true
  44274. }
  44275. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  44276. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44277. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44278. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  44279. if !m.op.Is(OpUpdateOne) {
  44280. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  44281. }
  44282. if m.id == nil || m.oldValue == nil {
  44283. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  44284. }
  44285. oldValue, err := m.oldValue(ctx)
  44286. if err != nil {
  44287. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  44288. }
  44289. return oldValue.UpdatedAt, nil
  44290. }
  44291. // ResetUpdatedAt resets all changes to the "updated_at" field.
  44292. func (m *WxCardMutation) ResetUpdatedAt() {
  44293. m.updated_at = nil
  44294. }
  44295. // SetDeletedAt sets the "deleted_at" field.
  44296. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  44297. m.deleted_at = &t
  44298. }
  44299. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  44300. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  44301. v := m.deleted_at
  44302. if v == nil {
  44303. return
  44304. }
  44305. return *v, true
  44306. }
  44307. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  44308. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44309. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44310. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  44311. if !m.op.Is(OpUpdateOne) {
  44312. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  44313. }
  44314. if m.id == nil || m.oldValue == nil {
  44315. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  44316. }
  44317. oldValue, err := m.oldValue(ctx)
  44318. if err != nil {
  44319. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  44320. }
  44321. return oldValue.DeletedAt, nil
  44322. }
  44323. // ClearDeletedAt clears the value of the "deleted_at" field.
  44324. func (m *WxCardMutation) ClearDeletedAt() {
  44325. m.deleted_at = nil
  44326. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  44327. }
  44328. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  44329. func (m *WxCardMutation) DeletedAtCleared() bool {
  44330. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  44331. return ok
  44332. }
  44333. // ResetDeletedAt resets all changes to the "deleted_at" field.
  44334. func (m *WxCardMutation) ResetDeletedAt() {
  44335. m.deleted_at = nil
  44336. delete(m.clearedFields, wxcard.FieldDeletedAt)
  44337. }
  44338. // SetUserID sets the "user_id" field.
  44339. func (m *WxCardMutation) SetUserID(u uint64) {
  44340. m.user_id = &u
  44341. m.adduser_id = nil
  44342. }
  44343. // UserID returns the value of the "user_id" field in the mutation.
  44344. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  44345. v := m.user_id
  44346. if v == nil {
  44347. return
  44348. }
  44349. return *v, true
  44350. }
  44351. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  44352. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44353. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44354. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  44355. if !m.op.Is(OpUpdateOne) {
  44356. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  44357. }
  44358. if m.id == nil || m.oldValue == nil {
  44359. return v, errors.New("OldUserID requires an ID field in the mutation")
  44360. }
  44361. oldValue, err := m.oldValue(ctx)
  44362. if err != nil {
  44363. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  44364. }
  44365. return oldValue.UserID, nil
  44366. }
  44367. // AddUserID adds u to the "user_id" field.
  44368. func (m *WxCardMutation) AddUserID(u int64) {
  44369. if m.adduser_id != nil {
  44370. *m.adduser_id += u
  44371. } else {
  44372. m.adduser_id = &u
  44373. }
  44374. }
  44375. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  44376. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  44377. v := m.adduser_id
  44378. if v == nil {
  44379. return
  44380. }
  44381. return *v, true
  44382. }
  44383. // ClearUserID clears the value of the "user_id" field.
  44384. func (m *WxCardMutation) ClearUserID() {
  44385. m.user_id = nil
  44386. m.adduser_id = nil
  44387. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  44388. }
  44389. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  44390. func (m *WxCardMutation) UserIDCleared() bool {
  44391. _, ok := m.clearedFields[wxcard.FieldUserID]
  44392. return ok
  44393. }
  44394. // ResetUserID resets all changes to the "user_id" field.
  44395. func (m *WxCardMutation) ResetUserID() {
  44396. m.user_id = nil
  44397. m.adduser_id = nil
  44398. delete(m.clearedFields, wxcard.FieldUserID)
  44399. }
  44400. // SetWxUserID sets the "wx_user_id" field.
  44401. func (m *WxCardMutation) SetWxUserID(u uint64) {
  44402. m.wx_user_id = &u
  44403. m.addwx_user_id = nil
  44404. }
  44405. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  44406. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  44407. v := m.wx_user_id
  44408. if v == nil {
  44409. return
  44410. }
  44411. return *v, true
  44412. }
  44413. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  44414. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44415. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44416. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  44417. if !m.op.Is(OpUpdateOne) {
  44418. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  44419. }
  44420. if m.id == nil || m.oldValue == nil {
  44421. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  44422. }
  44423. oldValue, err := m.oldValue(ctx)
  44424. if err != nil {
  44425. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  44426. }
  44427. return oldValue.WxUserID, nil
  44428. }
  44429. // AddWxUserID adds u to the "wx_user_id" field.
  44430. func (m *WxCardMutation) AddWxUserID(u int64) {
  44431. if m.addwx_user_id != nil {
  44432. *m.addwx_user_id += u
  44433. } else {
  44434. m.addwx_user_id = &u
  44435. }
  44436. }
  44437. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  44438. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  44439. v := m.addwx_user_id
  44440. if v == nil {
  44441. return
  44442. }
  44443. return *v, true
  44444. }
  44445. // ClearWxUserID clears the value of the "wx_user_id" field.
  44446. func (m *WxCardMutation) ClearWxUserID() {
  44447. m.wx_user_id = nil
  44448. m.addwx_user_id = nil
  44449. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  44450. }
  44451. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  44452. func (m *WxCardMutation) WxUserIDCleared() bool {
  44453. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  44454. return ok
  44455. }
  44456. // ResetWxUserID resets all changes to the "wx_user_id" field.
  44457. func (m *WxCardMutation) ResetWxUserID() {
  44458. m.wx_user_id = nil
  44459. m.addwx_user_id = nil
  44460. delete(m.clearedFields, wxcard.FieldWxUserID)
  44461. }
  44462. // SetAvatar sets the "avatar" field.
  44463. func (m *WxCardMutation) SetAvatar(s string) {
  44464. m.avatar = &s
  44465. }
  44466. // Avatar returns the value of the "avatar" field in the mutation.
  44467. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  44468. v := m.avatar
  44469. if v == nil {
  44470. return
  44471. }
  44472. return *v, true
  44473. }
  44474. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  44475. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44476. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44477. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  44478. if !m.op.Is(OpUpdateOne) {
  44479. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  44480. }
  44481. if m.id == nil || m.oldValue == nil {
  44482. return v, errors.New("OldAvatar requires an ID field in the mutation")
  44483. }
  44484. oldValue, err := m.oldValue(ctx)
  44485. if err != nil {
  44486. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  44487. }
  44488. return oldValue.Avatar, nil
  44489. }
  44490. // ResetAvatar resets all changes to the "avatar" field.
  44491. func (m *WxCardMutation) ResetAvatar() {
  44492. m.avatar = nil
  44493. }
  44494. // SetLogo sets the "logo" field.
  44495. func (m *WxCardMutation) SetLogo(s string) {
  44496. m.logo = &s
  44497. }
  44498. // Logo returns the value of the "logo" field in the mutation.
  44499. func (m *WxCardMutation) Logo() (r string, exists bool) {
  44500. v := m.logo
  44501. if v == nil {
  44502. return
  44503. }
  44504. return *v, true
  44505. }
  44506. // OldLogo returns the old "logo" field's value of the WxCard entity.
  44507. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44508. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44509. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  44510. if !m.op.Is(OpUpdateOne) {
  44511. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  44512. }
  44513. if m.id == nil || m.oldValue == nil {
  44514. return v, errors.New("OldLogo requires an ID field in the mutation")
  44515. }
  44516. oldValue, err := m.oldValue(ctx)
  44517. if err != nil {
  44518. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  44519. }
  44520. return oldValue.Logo, nil
  44521. }
  44522. // ResetLogo resets all changes to the "logo" field.
  44523. func (m *WxCardMutation) ResetLogo() {
  44524. m.logo = nil
  44525. }
  44526. // SetName sets the "name" field.
  44527. func (m *WxCardMutation) SetName(s string) {
  44528. m.name = &s
  44529. }
  44530. // Name returns the value of the "name" field in the mutation.
  44531. func (m *WxCardMutation) Name() (r string, exists bool) {
  44532. v := m.name
  44533. if v == nil {
  44534. return
  44535. }
  44536. return *v, true
  44537. }
  44538. // OldName returns the old "name" field's value of the WxCard entity.
  44539. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44540. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44541. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  44542. if !m.op.Is(OpUpdateOne) {
  44543. return v, errors.New("OldName is only allowed on UpdateOne operations")
  44544. }
  44545. if m.id == nil || m.oldValue == nil {
  44546. return v, errors.New("OldName requires an ID field in the mutation")
  44547. }
  44548. oldValue, err := m.oldValue(ctx)
  44549. if err != nil {
  44550. return v, fmt.Errorf("querying old value for OldName: %w", err)
  44551. }
  44552. return oldValue.Name, nil
  44553. }
  44554. // ResetName resets all changes to the "name" field.
  44555. func (m *WxCardMutation) ResetName() {
  44556. m.name = nil
  44557. }
  44558. // SetCompany sets the "company" field.
  44559. func (m *WxCardMutation) SetCompany(s string) {
  44560. m.company = &s
  44561. }
  44562. // Company returns the value of the "company" field in the mutation.
  44563. func (m *WxCardMutation) Company() (r string, exists bool) {
  44564. v := m.company
  44565. if v == nil {
  44566. return
  44567. }
  44568. return *v, true
  44569. }
  44570. // OldCompany returns the old "company" field's value of the WxCard entity.
  44571. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44572. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44573. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  44574. if !m.op.Is(OpUpdateOne) {
  44575. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  44576. }
  44577. if m.id == nil || m.oldValue == nil {
  44578. return v, errors.New("OldCompany requires an ID field in the mutation")
  44579. }
  44580. oldValue, err := m.oldValue(ctx)
  44581. if err != nil {
  44582. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  44583. }
  44584. return oldValue.Company, nil
  44585. }
  44586. // ResetCompany resets all changes to the "company" field.
  44587. func (m *WxCardMutation) ResetCompany() {
  44588. m.company = nil
  44589. }
  44590. // SetAddress sets the "address" field.
  44591. func (m *WxCardMutation) SetAddress(s string) {
  44592. m.address = &s
  44593. }
  44594. // Address returns the value of the "address" field in the mutation.
  44595. func (m *WxCardMutation) Address() (r string, exists bool) {
  44596. v := m.address
  44597. if v == nil {
  44598. return
  44599. }
  44600. return *v, true
  44601. }
  44602. // OldAddress returns the old "address" field's value of the WxCard entity.
  44603. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44604. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44605. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  44606. if !m.op.Is(OpUpdateOne) {
  44607. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  44608. }
  44609. if m.id == nil || m.oldValue == nil {
  44610. return v, errors.New("OldAddress requires an ID field in the mutation")
  44611. }
  44612. oldValue, err := m.oldValue(ctx)
  44613. if err != nil {
  44614. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  44615. }
  44616. return oldValue.Address, nil
  44617. }
  44618. // ResetAddress resets all changes to the "address" field.
  44619. func (m *WxCardMutation) ResetAddress() {
  44620. m.address = nil
  44621. }
  44622. // SetPhone sets the "phone" field.
  44623. func (m *WxCardMutation) SetPhone(s string) {
  44624. m.phone = &s
  44625. }
  44626. // Phone returns the value of the "phone" field in the mutation.
  44627. func (m *WxCardMutation) Phone() (r string, exists bool) {
  44628. v := m.phone
  44629. if v == nil {
  44630. return
  44631. }
  44632. return *v, true
  44633. }
  44634. // OldPhone returns the old "phone" field's value of the WxCard entity.
  44635. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44636. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44637. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  44638. if !m.op.Is(OpUpdateOne) {
  44639. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  44640. }
  44641. if m.id == nil || m.oldValue == nil {
  44642. return v, errors.New("OldPhone requires an ID field in the mutation")
  44643. }
  44644. oldValue, err := m.oldValue(ctx)
  44645. if err != nil {
  44646. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  44647. }
  44648. return oldValue.Phone, nil
  44649. }
  44650. // ResetPhone resets all changes to the "phone" field.
  44651. func (m *WxCardMutation) ResetPhone() {
  44652. m.phone = nil
  44653. }
  44654. // SetOfficialAccount sets the "official_account" field.
  44655. func (m *WxCardMutation) SetOfficialAccount(s string) {
  44656. m.official_account = &s
  44657. }
  44658. // OfficialAccount returns the value of the "official_account" field in the mutation.
  44659. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  44660. v := m.official_account
  44661. if v == nil {
  44662. return
  44663. }
  44664. return *v, true
  44665. }
  44666. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  44667. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44668. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44669. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  44670. if !m.op.Is(OpUpdateOne) {
  44671. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  44672. }
  44673. if m.id == nil || m.oldValue == nil {
  44674. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  44675. }
  44676. oldValue, err := m.oldValue(ctx)
  44677. if err != nil {
  44678. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  44679. }
  44680. return oldValue.OfficialAccount, nil
  44681. }
  44682. // ResetOfficialAccount resets all changes to the "official_account" field.
  44683. func (m *WxCardMutation) ResetOfficialAccount() {
  44684. m.official_account = nil
  44685. }
  44686. // SetWechatAccount sets the "wechat_account" field.
  44687. func (m *WxCardMutation) SetWechatAccount(s string) {
  44688. m.wechat_account = &s
  44689. }
  44690. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  44691. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  44692. v := m.wechat_account
  44693. if v == nil {
  44694. return
  44695. }
  44696. return *v, true
  44697. }
  44698. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  44699. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44700. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44701. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  44702. if !m.op.Is(OpUpdateOne) {
  44703. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  44704. }
  44705. if m.id == nil || m.oldValue == nil {
  44706. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  44707. }
  44708. oldValue, err := m.oldValue(ctx)
  44709. if err != nil {
  44710. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  44711. }
  44712. return oldValue.WechatAccount, nil
  44713. }
  44714. // ResetWechatAccount resets all changes to the "wechat_account" field.
  44715. func (m *WxCardMutation) ResetWechatAccount() {
  44716. m.wechat_account = nil
  44717. }
  44718. // SetEmail sets the "email" field.
  44719. func (m *WxCardMutation) SetEmail(s string) {
  44720. m.email = &s
  44721. }
  44722. // Email returns the value of the "email" field in the mutation.
  44723. func (m *WxCardMutation) Email() (r string, exists bool) {
  44724. v := m.email
  44725. if v == nil {
  44726. return
  44727. }
  44728. return *v, true
  44729. }
  44730. // OldEmail returns the old "email" field's value of the WxCard entity.
  44731. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44732. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44733. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  44734. if !m.op.Is(OpUpdateOne) {
  44735. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  44736. }
  44737. if m.id == nil || m.oldValue == nil {
  44738. return v, errors.New("OldEmail requires an ID field in the mutation")
  44739. }
  44740. oldValue, err := m.oldValue(ctx)
  44741. if err != nil {
  44742. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  44743. }
  44744. return oldValue.Email, nil
  44745. }
  44746. // ClearEmail clears the value of the "email" field.
  44747. func (m *WxCardMutation) ClearEmail() {
  44748. m.email = nil
  44749. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  44750. }
  44751. // EmailCleared returns if the "email" field was cleared in this mutation.
  44752. func (m *WxCardMutation) EmailCleared() bool {
  44753. _, ok := m.clearedFields[wxcard.FieldEmail]
  44754. return ok
  44755. }
  44756. // ResetEmail resets all changes to the "email" field.
  44757. func (m *WxCardMutation) ResetEmail() {
  44758. m.email = nil
  44759. delete(m.clearedFields, wxcard.FieldEmail)
  44760. }
  44761. // SetAPIBase sets the "api_base" field.
  44762. func (m *WxCardMutation) SetAPIBase(s string) {
  44763. m.api_base = &s
  44764. }
  44765. // APIBase returns the value of the "api_base" field in the mutation.
  44766. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  44767. v := m.api_base
  44768. if v == nil {
  44769. return
  44770. }
  44771. return *v, true
  44772. }
  44773. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  44774. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44775. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44776. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  44777. if !m.op.Is(OpUpdateOne) {
  44778. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  44779. }
  44780. if m.id == nil || m.oldValue == nil {
  44781. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  44782. }
  44783. oldValue, err := m.oldValue(ctx)
  44784. if err != nil {
  44785. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  44786. }
  44787. return oldValue.APIBase, nil
  44788. }
  44789. // ClearAPIBase clears the value of the "api_base" field.
  44790. func (m *WxCardMutation) ClearAPIBase() {
  44791. m.api_base = nil
  44792. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  44793. }
  44794. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  44795. func (m *WxCardMutation) APIBaseCleared() bool {
  44796. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  44797. return ok
  44798. }
  44799. // ResetAPIBase resets all changes to the "api_base" field.
  44800. func (m *WxCardMutation) ResetAPIBase() {
  44801. m.api_base = nil
  44802. delete(m.clearedFields, wxcard.FieldAPIBase)
  44803. }
  44804. // SetAPIKey sets the "api_key" field.
  44805. func (m *WxCardMutation) SetAPIKey(s string) {
  44806. m.api_key = &s
  44807. }
  44808. // APIKey returns the value of the "api_key" field in the mutation.
  44809. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  44810. v := m.api_key
  44811. if v == nil {
  44812. return
  44813. }
  44814. return *v, true
  44815. }
  44816. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  44817. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44818. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44819. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  44820. if !m.op.Is(OpUpdateOne) {
  44821. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  44822. }
  44823. if m.id == nil || m.oldValue == nil {
  44824. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  44825. }
  44826. oldValue, err := m.oldValue(ctx)
  44827. if err != nil {
  44828. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  44829. }
  44830. return oldValue.APIKey, nil
  44831. }
  44832. // ClearAPIKey clears the value of the "api_key" field.
  44833. func (m *WxCardMutation) ClearAPIKey() {
  44834. m.api_key = nil
  44835. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  44836. }
  44837. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  44838. func (m *WxCardMutation) APIKeyCleared() bool {
  44839. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  44840. return ok
  44841. }
  44842. // ResetAPIKey resets all changes to the "api_key" field.
  44843. func (m *WxCardMutation) ResetAPIKey() {
  44844. m.api_key = nil
  44845. delete(m.clearedFields, wxcard.FieldAPIKey)
  44846. }
  44847. // SetAiInfo sets the "ai_info" field.
  44848. func (m *WxCardMutation) SetAiInfo(s string) {
  44849. m.ai_info = &s
  44850. }
  44851. // AiInfo returns the value of the "ai_info" field in the mutation.
  44852. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  44853. v := m.ai_info
  44854. if v == nil {
  44855. return
  44856. }
  44857. return *v, true
  44858. }
  44859. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  44860. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44861. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44862. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  44863. if !m.op.Is(OpUpdateOne) {
  44864. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  44865. }
  44866. if m.id == nil || m.oldValue == nil {
  44867. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  44868. }
  44869. oldValue, err := m.oldValue(ctx)
  44870. if err != nil {
  44871. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  44872. }
  44873. return oldValue.AiInfo, nil
  44874. }
  44875. // ClearAiInfo clears the value of the "ai_info" field.
  44876. func (m *WxCardMutation) ClearAiInfo() {
  44877. m.ai_info = nil
  44878. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  44879. }
  44880. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  44881. func (m *WxCardMutation) AiInfoCleared() bool {
  44882. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  44883. return ok
  44884. }
  44885. // ResetAiInfo resets all changes to the "ai_info" field.
  44886. func (m *WxCardMutation) ResetAiInfo() {
  44887. m.ai_info = nil
  44888. delete(m.clearedFields, wxcard.FieldAiInfo)
  44889. }
  44890. // SetIntro sets the "intro" field.
  44891. func (m *WxCardMutation) SetIntro(s string) {
  44892. m.intro = &s
  44893. }
  44894. // Intro returns the value of the "intro" field in the mutation.
  44895. func (m *WxCardMutation) Intro() (r string, exists bool) {
  44896. v := m.intro
  44897. if v == nil {
  44898. return
  44899. }
  44900. return *v, true
  44901. }
  44902. // OldIntro returns the old "intro" field's value of the WxCard entity.
  44903. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44904. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44905. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  44906. if !m.op.Is(OpUpdateOne) {
  44907. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  44908. }
  44909. if m.id == nil || m.oldValue == nil {
  44910. return v, errors.New("OldIntro requires an ID field in the mutation")
  44911. }
  44912. oldValue, err := m.oldValue(ctx)
  44913. if err != nil {
  44914. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  44915. }
  44916. return oldValue.Intro, nil
  44917. }
  44918. // ClearIntro clears the value of the "intro" field.
  44919. func (m *WxCardMutation) ClearIntro() {
  44920. m.intro = nil
  44921. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  44922. }
  44923. // IntroCleared returns if the "intro" field was cleared in this mutation.
  44924. func (m *WxCardMutation) IntroCleared() bool {
  44925. _, ok := m.clearedFields[wxcard.FieldIntro]
  44926. return ok
  44927. }
  44928. // ResetIntro resets all changes to the "intro" field.
  44929. func (m *WxCardMutation) ResetIntro() {
  44930. m.intro = nil
  44931. delete(m.clearedFields, wxcard.FieldIntro)
  44932. }
  44933. // Where appends a list predicates to the WxCardMutation builder.
  44934. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  44935. m.predicates = append(m.predicates, ps...)
  44936. }
  44937. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  44938. // users can use type-assertion to append predicates that do not depend on any generated package.
  44939. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  44940. p := make([]predicate.WxCard, len(ps))
  44941. for i := range ps {
  44942. p[i] = ps[i]
  44943. }
  44944. m.Where(p...)
  44945. }
  44946. // Op returns the operation name.
  44947. func (m *WxCardMutation) Op() Op {
  44948. return m.op
  44949. }
  44950. // SetOp allows setting the mutation operation.
  44951. func (m *WxCardMutation) SetOp(op Op) {
  44952. m.op = op
  44953. }
  44954. // Type returns the node type of this mutation (WxCard).
  44955. func (m *WxCardMutation) Type() string {
  44956. return m.typ
  44957. }
  44958. // Fields returns all fields that were changed during this mutation. Note that in
  44959. // order to get all numeric fields that were incremented/decremented, call
  44960. // AddedFields().
  44961. func (m *WxCardMutation) Fields() []string {
  44962. fields := make([]string, 0, 18)
  44963. if m.created_at != nil {
  44964. fields = append(fields, wxcard.FieldCreatedAt)
  44965. }
  44966. if m.updated_at != nil {
  44967. fields = append(fields, wxcard.FieldUpdatedAt)
  44968. }
  44969. if m.deleted_at != nil {
  44970. fields = append(fields, wxcard.FieldDeletedAt)
  44971. }
  44972. if m.user_id != nil {
  44973. fields = append(fields, wxcard.FieldUserID)
  44974. }
  44975. if m.wx_user_id != nil {
  44976. fields = append(fields, wxcard.FieldWxUserID)
  44977. }
  44978. if m.avatar != nil {
  44979. fields = append(fields, wxcard.FieldAvatar)
  44980. }
  44981. if m.logo != nil {
  44982. fields = append(fields, wxcard.FieldLogo)
  44983. }
  44984. if m.name != nil {
  44985. fields = append(fields, wxcard.FieldName)
  44986. }
  44987. if m.company != nil {
  44988. fields = append(fields, wxcard.FieldCompany)
  44989. }
  44990. if m.address != nil {
  44991. fields = append(fields, wxcard.FieldAddress)
  44992. }
  44993. if m.phone != nil {
  44994. fields = append(fields, wxcard.FieldPhone)
  44995. }
  44996. if m.official_account != nil {
  44997. fields = append(fields, wxcard.FieldOfficialAccount)
  44998. }
  44999. if m.wechat_account != nil {
  45000. fields = append(fields, wxcard.FieldWechatAccount)
  45001. }
  45002. if m.email != nil {
  45003. fields = append(fields, wxcard.FieldEmail)
  45004. }
  45005. if m.api_base != nil {
  45006. fields = append(fields, wxcard.FieldAPIBase)
  45007. }
  45008. if m.api_key != nil {
  45009. fields = append(fields, wxcard.FieldAPIKey)
  45010. }
  45011. if m.ai_info != nil {
  45012. fields = append(fields, wxcard.FieldAiInfo)
  45013. }
  45014. if m.intro != nil {
  45015. fields = append(fields, wxcard.FieldIntro)
  45016. }
  45017. return fields
  45018. }
  45019. // Field returns the value of a field with the given name. The second boolean
  45020. // return value indicates that this field was not set, or was not defined in the
  45021. // schema.
  45022. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  45023. switch name {
  45024. case wxcard.FieldCreatedAt:
  45025. return m.CreatedAt()
  45026. case wxcard.FieldUpdatedAt:
  45027. return m.UpdatedAt()
  45028. case wxcard.FieldDeletedAt:
  45029. return m.DeletedAt()
  45030. case wxcard.FieldUserID:
  45031. return m.UserID()
  45032. case wxcard.FieldWxUserID:
  45033. return m.WxUserID()
  45034. case wxcard.FieldAvatar:
  45035. return m.Avatar()
  45036. case wxcard.FieldLogo:
  45037. return m.Logo()
  45038. case wxcard.FieldName:
  45039. return m.Name()
  45040. case wxcard.FieldCompany:
  45041. return m.Company()
  45042. case wxcard.FieldAddress:
  45043. return m.Address()
  45044. case wxcard.FieldPhone:
  45045. return m.Phone()
  45046. case wxcard.FieldOfficialAccount:
  45047. return m.OfficialAccount()
  45048. case wxcard.FieldWechatAccount:
  45049. return m.WechatAccount()
  45050. case wxcard.FieldEmail:
  45051. return m.Email()
  45052. case wxcard.FieldAPIBase:
  45053. return m.APIBase()
  45054. case wxcard.FieldAPIKey:
  45055. return m.APIKey()
  45056. case wxcard.FieldAiInfo:
  45057. return m.AiInfo()
  45058. case wxcard.FieldIntro:
  45059. return m.Intro()
  45060. }
  45061. return nil, false
  45062. }
  45063. // OldField returns the old value of the field from the database. An error is
  45064. // returned if the mutation operation is not UpdateOne, or the query to the
  45065. // database failed.
  45066. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  45067. switch name {
  45068. case wxcard.FieldCreatedAt:
  45069. return m.OldCreatedAt(ctx)
  45070. case wxcard.FieldUpdatedAt:
  45071. return m.OldUpdatedAt(ctx)
  45072. case wxcard.FieldDeletedAt:
  45073. return m.OldDeletedAt(ctx)
  45074. case wxcard.FieldUserID:
  45075. return m.OldUserID(ctx)
  45076. case wxcard.FieldWxUserID:
  45077. return m.OldWxUserID(ctx)
  45078. case wxcard.FieldAvatar:
  45079. return m.OldAvatar(ctx)
  45080. case wxcard.FieldLogo:
  45081. return m.OldLogo(ctx)
  45082. case wxcard.FieldName:
  45083. return m.OldName(ctx)
  45084. case wxcard.FieldCompany:
  45085. return m.OldCompany(ctx)
  45086. case wxcard.FieldAddress:
  45087. return m.OldAddress(ctx)
  45088. case wxcard.FieldPhone:
  45089. return m.OldPhone(ctx)
  45090. case wxcard.FieldOfficialAccount:
  45091. return m.OldOfficialAccount(ctx)
  45092. case wxcard.FieldWechatAccount:
  45093. return m.OldWechatAccount(ctx)
  45094. case wxcard.FieldEmail:
  45095. return m.OldEmail(ctx)
  45096. case wxcard.FieldAPIBase:
  45097. return m.OldAPIBase(ctx)
  45098. case wxcard.FieldAPIKey:
  45099. return m.OldAPIKey(ctx)
  45100. case wxcard.FieldAiInfo:
  45101. return m.OldAiInfo(ctx)
  45102. case wxcard.FieldIntro:
  45103. return m.OldIntro(ctx)
  45104. }
  45105. return nil, fmt.Errorf("unknown WxCard field %s", name)
  45106. }
  45107. // SetField sets the value of a field with the given name. It returns an error if
  45108. // the field is not defined in the schema, or if the type mismatched the field
  45109. // type.
  45110. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  45111. switch name {
  45112. case wxcard.FieldCreatedAt:
  45113. v, ok := value.(time.Time)
  45114. if !ok {
  45115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45116. }
  45117. m.SetCreatedAt(v)
  45118. return nil
  45119. case wxcard.FieldUpdatedAt:
  45120. v, ok := value.(time.Time)
  45121. if !ok {
  45122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45123. }
  45124. m.SetUpdatedAt(v)
  45125. return nil
  45126. case wxcard.FieldDeletedAt:
  45127. v, ok := value.(time.Time)
  45128. if !ok {
  45129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45130. }
  45131. m.SetDeletedAt(v)
  45132. return nil
  45133. case wxcard.FieldUserID:
  45134. v, ok := value.(uint64)
  45135. if !ok {
  45136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45137. }
  45138. m.SetUserID(v)
  45139. return nil
  45140. case wxcard.FieldWxUserID:
  45141. v, ok := value.(uint64)
  45142. if !ok {
  45143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45144. }
  45145. m.SetWxUserID(v)
  45146. return nil
  45147. case wxcard.FieldAvatar:
  45148. v, ok := value.(string)
  45149. if !ok {
  45150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45151. }
  45152. m.SetAvatar(v)
  45153. return nil
  45154. case wxcard.FieldLogo:
  45155. v, ok := value.(string)
  45156. if !ok {
  45157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45158. }
  45159. m.SetLogo(v)
  45160. return nil
  45161. case wxcard.FieldName:
  45162. v, ok := value.(string)
  45163. if !ok {
  45164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45165. }
  45166. m.SetName(v)
  45167. return nil
  45168. case wxcard.FieldCompany:
  45169. v, ok := value.(string)
  45170. if !ok {
  45171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45172. }
  45173. m.SetCompany(v)
  45174. return nil
  45175. case wxcard.FieldAddress:
  45176. v, ok := value.(string)
  45177. if !ok {
  45178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45179. }
  45180. m.SetAddress(v)
  45181. return nil
  45182. case wxcard.FieldPhone:
  45183. v, ok := value.(string)
  45184. if !ok {
  45185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45186. }
  45187. m.SetPhone(v)
  45188. return nil
  45189. case wxcard.FieldOfficialAccount:
  45190. v, ok := value.(string)
  45191. if !ok {
  45192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45193. }
  45194. m.SetOfficialAccount(v)
  45195. return nil
  45196. case wxcard.FieldWechatAccount:
  45197. v, ok := value.(string)
  45198. if !ok {
  45199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45200. }
  45201. m.SetWechatAccount(v)
  45202. return nil
  45203. case wxcard.FieldEmail:
  45204. v, ok := value.(string)
  45205. if !ok {
  45206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45207. }
  45208. m.SetEmail(v)
  45209. return nil
  45210. case wxcard.FieldAPIBase:
  45211. v, ok := value.(string)
  45212. if !ok {
  45213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45214. }
  45215. m.SetAPIBase(v)
  45216. return nil
  45217. case wxcard.FieldAPIKey:
  45218. v, ok := value.(string)
  45219. if !ok {
  45220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45221. }
  45222. m.SetAPIKey(v)
  45223. return nil
  45224. case wxcard.FieldAiInfo:
  45225. v, ok := value.(string)
  45226. if !ok {
  45227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45228. }
  45229. m.SetAiInfo(v)
  45230. return nil
  45231. case wxcard.FieldIntro:
  45232. v, ok := value.(string)
  45233. if !ok {
  45234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45235. }
  45236. m.SetIntro(v)
  45237. return nil
  45238. }
  45239. return fmt.Errorf("unknown WxCard field %s", name)
  45240. }
  45241. // AddedFields returns all numeric fields that were incremented/decremented during
  45242. // this mutation.
  45243. func (m *WxCardMutation) AddedFields() []string {
  45244. var fields []string
  45245. if m.adduser_id != nil {
  45246. fields = append(fields, wxcard.FieldUserID)
  45247. }
  45248. if m.addwx_user_id != nil {
  45249. fields = append(fields, wxcard.FieldWxUserID)
  45250. }
  45251. return fields
  45252. }
  45253. // AddedField returns the numeric value that was incremented/decremented on a field
  45254. // with the given name. The second boolean return value indicates that this field
  45255. // was not set, or was not defined in the schema.
  45256. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  45257. switch name {
  45258. case wxcard.FieldUserID:
  45259. return m.AddedUserID()
  45260. case wxcard.FieldWxUserID:
  45261. return m.AddedWxUserID()
  45262. }
  45263. return nil, false
  45264. }
  45265. // AddField adds the value to the field with the given name. It returns an error if
  45266. // the field is not defined in the schema, or if the type mismatched the field
  45267. // type.
  45268. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  45269. switch name {
  45270. case wxcard.FieldUserID:
  45271. v, ok := value.(int64)
  45272. if !ok {
  45273. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45274. }
  45275. m.AddUserID(v)
  45276. return nil
  45277. case wxcard.FieldWxUserID:
  45278. v, ok := value.(int64)
  45279. if !ok {
  45280. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45281. }
  45282. m.AddWxUserID(v)
  45283. return nil
  45284. }
  45285. return fmt.Errorf("unknown WxCard numeric field %s", name)
  45286. }
  45287. // ClearedFields returns all nullable fields that were cleared during this
  45288. // mutation.
  45289. func (m *WxCardMutation) ClearedFields() []string {
  45290. var fields []string
  45291. if m.FieldCleared(wxcard.FieldDeletedAt) {
  45292. fields = append(fields, wxcard.FieldDeletedAt)
  45293. }
  45294. if m.FieldCleared(wxcard.FieldUserID) {
  45295. fields = append(fields, wxcard.FieldUserID)
  45296. }
  45297. if m.FieldCleared(wxcard.FieldWxUserID) {
  45298. fields = append(fields, wxcard.FieldWxUserID)
  45299. }
  45300. if m.FieldCleared(wxcard.FieldEmail) {
  45301. fields = append(fields, wxcard.FieldEmail)
  45302. }
  45303. if m.FieldCleared(wxcard.FieldAPIBase) {
  45304. fields = append(fields, wxcard.FieldAPIBase)
  45305. }
  45306. if m.FieldCleared(wxcard.FieldAPIKey) {
  45307. fields = append(fields, wxcard.FieldAPIKey)
  45308. }
  45309. if m.FieldCleared(wxcard.FieldAiInfo) {
  45310. fields = append(fields, wxcard.FieldAiInfo)
  45311. }
  45312. if m.FieldCleared(wxcard.FieldIntro) {
  45313. fields = append(fields, wxcard.FieldIntro)
  45314. }
  45315. return fields
  45316. }
  45317. // FieldCleared returns a boolean indicating if a field with the given name was
  45318. // cleared in this mutation.
  45319. func (m *WxCardMutation) FieldCleared(name string) bool {
  45320. _, ok := m.clearedFields[name]
  45321. return ok
  45322. }
  45323. // ClearField clears the value of the field with the given name. It returns an
  45324. // error if the field is not defined in the schema.
  45325. func (m *WxCardMutation) ClearField(name string) error {
  45326. switch name {
  45327. case wxcard.FieldDeletedAt:
  45328. m.ClearDeletedAt()
  45329. return nil
  45330. case wxcard.FieldUserID:
  45331. m.ClearUserID()
  45332. return nil
  45333. case wxcard.FieldWxUserID:
  45334. m.ClearWxUserID()
  45335. return nil
  45336. case wxcard.FieldEmail:
  45337. m.ClearEmail()
  45338. return nil
  45339. case wxcard.FieldAPIBase:
  45340. m.ClearAPIBase()
  45341. return nil
  45342. case wxcard.FieldAPIKey:
  45343. m.ClearAPIKey()
  45344. return nil
  45345. case wxcard.FieldAiInfo:
  45346. m.ClearAiInfo()
  45347. return nil
  45348. case wxcard.FieldIntro:
  45349. m.ClearIntro()
  45350. return nil
  45351. }
  45352. return fmt.Errorf("unknown WxCard nullable field %s", name)
  45353. }
  45354. // ResetField resets all changes in the mutation for the field with the given name.
  45355. // It returns an error if the field is not defined in the schema.
  45356. func (m *WxCardMutation) ResetField(name string) error {
  45357. switch name {
  45358. case wxcard.FieldCreatedAt:
  45359. m.ResetCreatedAt()
  45360. return nil
  45361. case wxcard.FieldUpdatedAt:
  45362. m.ResetUpdatedAt()
  45363. return nil
  45364. case wxcard.FieldDeletedAt:
  45365. m.ResetDeletedAt()
  45366. return nil
  45367. case wxcard.FieldUserID:
  45368. m.ResetUserID()
  45369. return nil
  45370. case wxcard.FieldWxUserID:
  45371. m.ResetWxUserID()
  45372. return nil
  45373. case wxcard.FieldAvatar:
  45374. m.ResetAvatar()
  45375. return nil
  45376. case wxcard.FieldLogo:
  45377. m.ResetLogo()
  45378. return nil
  45379. case wxcard.FieldName:
  45380. m.ResetName()
  45381. return nil
  45382. case wxcard.FieldCompany:
  45383. m.ResetCompany()
  45384. return nil
  45385. case wxcard.FieldAddress:
  45386. m.ResetAddress()
  45387. return nil
  45388. case wxcard.FieldPhone:
  45389. m.ResetPhone()
  45390. return nil
  45391. case wxcard.FieldOfficialAccount:
  45392. m.ResetOfficialAccount()
  45393. return nil
  45394. case wxcard.FieldWechatAccount:
  45395. m.ResetWechatAccount()
  45396. return nil
  45397. case wxcard.FieldEmail:
  45398. m.ResetEmail()
  45399. return nil
  45400. case wxcard.FieldAPIBase:
  45401. m.ResetAPIBase()
  45402. return nil
  45403. case wxcard.FieldAPIKey:
  45404. m.ResetAPIKey()
  45405. return nil
  45406. case wxcard.FieldAiInfo:
  45407. m.ResetAiInfo()
  45408. return nil
  45409. case wxcard.FieldIntro:
  45410. m.ResetIntro()
  45411. return nil
  45412. }
  45413. return fmt.Errorf("unknown WxCard field %s", name)
  45414. }
  45415. // AddedEdges returns all edge names that were set/added in this mutation.
  45416. func (m *WxCardMutation) AddedEdges() []string {
  45417. edges := make([]string, 0, 0)
  45418. return edges
  45419. }
  45420. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  45421. // name in this mutation.
  45422. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  45423. return nil
  45424. }
  45425. // RemovedEdges returns all edge names that were removed in this mutation.
  45426. func (m *WxCardMutation) RemovedEdges() []string {
  45427. edges := make([]string, 0, 0)
  45428. return edges
  45429. }
  45430. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  45431. // the given name in this mutation.
  45432. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  45433. return nil
  45434. }
  45435. // ClearedEdges returns all edge names that were cleared in this mutation.
  45436. func (m *WxCardMutation) ClearedEdges() []string {
  45437. edges := make([]string, 0, 0)
  45438. return edges
  45439. }
  45440. // EdgeCleared returns a boolean which indicates if the edge with the given name
  45441. // was cleared in this mutation.
  45442. func (m *WxCardMutation) EdgeCleared(name string) bool {
  45443. return false
  45444. }
  45445. // ClearEdge clears the value of the edge with the given name. It returns an error
  45446. // if that edge is not defined in the schema.
  45447. func (m *WxCardMutation) ClearEdge(name string) error {
  45448. return fmt.Errorf("unknown WxCard unique edge %s", name)
  45449. }
  45450. // ResetEdge resets all changes to the edge with the given name in this mutation.
  45451. // It returns an error if the edge is not defined in the schema.
  45452. func (m *WxCardMutation) ResetEdge(name string) error {
  45453. return fmt.Errorf("unknown WxCard edge %s", name)
  45454. }
  45455. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  45456. type WxCardUserMutation struct {
  45457. config
  45458. op Op
  45459. typ string
  45460. id *uint64
  45461. created_at *time.Time
  45462. updated_at *time.Time
  45463. deleted_at *time.Time
  45464. wxid *string
  45465. account *string
  45466. avatar *string
  45467. nickname *string
  45468. remark *string
  45469. phone *string
  45470. open_id *string
  45471. union_id *string
  45472. session_key *string
  45473. is_vip *int
  45474. addis_vip *int
  45475. clearedFields map[string]struct{}
  45476. done bool
  45477. oldValue func(context.Context) (*WxCardUser, error)
  45478. predicates []predicate.WxCardUser
  45479. }
  45480. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  45481. // wxcarduserOption allows management of the mutation configuration using functional options.
  45482. type wxcarduserOption func(*WxCardUserMutation)
  45483. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  45484. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  45485. m := &WxCardUserMutation{
  45486. config: c,
  45487. op: op,
  45488. typ: TypeWxCardUser,
  45489. clearedFields: make(map[string]struct{}),
  45490. }
  45491. for _, opt := range opts {
  45492. opt(m)
  45493. }
  45494. return m
  45495. }
  45496. // withWxCardUserID sets the ID field of the mutation.
  45497. func withWxCardUserID(id uint64) wxcarduserOption {
  45498. return func(m *WxCardUserMutation) {
  45499. var (
  45500. err error
  45501. once sync.Once
  45502. value *WxCardUser
  45503. )
  45504. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  45505. once.Do(func() {
  45506. if m.done {
  45507. err = errors.New("querying old values post mutation is not allowed")
  45508. } else {
  45509. value, err = m.Client().WxCardUser.Get(ctx, id)
  45510. }
  45511. })
  45512. return value, err
  45513. }
  45514. m.id = &id
  45515. }
  45516. }
  45517. // withWxCardUser sets the old WxCardUser of the mutation.
  45518. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  45519. return func(m *WxCardUserMutation) {
  45520. m.oldValue = func(context.Context) (*WxCardUser, error) {
  45521. return node, nil
  45522. }
  45523. m.id = &node.ID
  45524. }
  45525. }
  45526. // Client returns a new `ent.Client` from the mutation. If the mutation was
  45527. // executed in a transaction (ent.Tx), a transactional client is returned.
  45528. func (m WxCardUserMutation) Client() *Client {
  45529. client := &Client{config: m.config}
  45530. client.init()
  45531. return client
  45532. }
  45533. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  45534. // it returns an error otherwise.
  45535. func (m WxCardUserMutation) Tx() (*Tx, error) {
  45536. if _, ok := m.driver.(*txDriver); !ok {
  45537. return nil, errors.New("ent: mutation is not running in a transaction")
  45538. }
  45539. tx := &Tx{config: m.config}
  45540. tx.init()
  45541. return tx, nil
  45542. }
  45543. // SetID sets the value of the id field. Note that this
  45544. // operation is only accepted on creation of WxCardUser entities.
  45545. func (m *WxCardUserMutation) SetID(id uint64) {
  45546. m.id = &id
  45547. }
  45548. // ID returns the ID value in the mutation. Note that the ID is only available
  45549. // if it was provided to the builder or after it was returned from the database.
  45550. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  45551. if m.id == nil {
  45552. return
  45553. }
  45554. return *m.id, true
  45555. }
  45556. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  45557. // That means, if the mutation is applied within a transaction with an isolation level such
  45558. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  45559. // or updated by the mutation.
  45560. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  45561. switch {
  45562. case m.op.Is(OpUpdateOne | OpDeleteOne):
  45563. id, exists := m.ID()
  45564. if exists {
  45565. return []uint64{id}, nil
  45566. }
  45567. fallthrough
  45568. case m.op.Is(OpUpdate | OpDelete):
  45569. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  45570. default:
  45571. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  45572. }
  45573. }
  45574. // SetCreatedAt sets the "created_at" field.
  45575. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  45576. m.created_at = &t
  45577. }
  45578. // CreatedAt returns the value of the "created_at" field in the mutation.
  45579. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  45580. v := m.created_at
  45581. if v == nil {
  45582. return
  45583. }
  45584. return *v, true
  45585. }
  45586. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  45587. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45588. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45589. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  45590. if !m.op.Is(OpUpdateOne) {
  45591. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  45592. }
  45593. if m.id == nil || m.oldValue == nil {
  45594. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  45595. }
  45596. oldValue, err := m.oldValue(ctx)
  45597. if err != nil {
  45598. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  45599. }
  45600. return oldValue.CreatedAt, nil
  45601. }
  45602. // ResetCreatedAt resets all changes to the "created_at" field.
  45603. func (m *WxCardUserMutation) ResetCreatedAt() {
  45604. m.created_at = nil
  45605. }
  45606. // SetUpdatedAt sets the "updated_at" field.
  45607. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  45608. m.updated_at = &t
  45609. }
  45610. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  45611. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  45612. v := m.updated_at
  45613. if v == nil {
  45614. return
  45615. }
  45616. return *v, true
  45617. }
  45618. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  45619. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45621. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  45622. if !m.op.Is(OpUpdateOne) {
  45623. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  45624. }
  45625. if m.id == nil || m.oldValue == nil {
  45626. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  45627. }
  45628. oldValue, err := m.oldValue(ctx)
  45629. if err != nil {
  45630. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  45631. }
  45632. return oldValue.UpdatedAt, nil
  45633. }
  45634. // ResetUpdatedAt resets all changes to the "updated_at" field.
  45635. func (m *WxCardUserMutation) ResetUpdatedAt() {
  45636. m.updated_at = nil
  45637. }
  45638. // SetDeletedAt sets the "deleted_at" field.
  45639. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  45640. m.deleted_at = &t
  45641. }
  45642. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  45643. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  45644. v := m.deleted_at
  45645. if v == nil {
  45646. return
  45647. }
  45648. return *v, true
  45649. }
  45650. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  45651. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45652. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45653. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  45654. if !m.op.Is(OpUpdateOne) {
  45655. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  45656. }
  45657. if m.id == nil || m.oldValue == nil {
  45658. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  45659. }
  45660. oldValue, err := m.oldValue(ctx)
  45661. if err != nil {
  45662. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  45663. }
  45664. return oldValue.DeletedAt, nil
  45665. }
  45666. // ClearDeletedAt clears the value of the "deleted_at" field.
  45667. func (m *WxCardUserMutation) ClearDeletedAt() {
  45668. m.deleted_at = nil
  45669. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  45670. }
  45671. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  45672. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  45673. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  45674. return ok
  45675. }
  45676. // ResetDeletedAt resets all changes to the "deleted_at" field.
  45677. func (m *WxCardUserMutation) ResetDeletedAt() {
  45678. m.deleted_at = nil
  45679. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  45680. }
  45681. // SetWxid sets the "wxid" field.
  45682. func (m *WxCardUserMutation) SetWxid(s string) {
  45683. m.wxid = &s
  45684. }
  45685. // Wxid returns the value of the "wxid" field in the mutation.
  45686. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  45687. v := m.wxid
  45688. if v == nil {
  45689. return
  45690. }
  45691. return *v, true
  45692. }
  45693. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  45694. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45695. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45696. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  45697. if !m.op.Is(OpUpdateOne) {
  45698. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  45699. }
  45700. if m.id == nil || m.oldValue == nil {
  45701. return v, errors.New("OldWxid requires an ID field in the mutation")
  45702. }
  45703. oldValue, err := m.oldValue(ctx)
  45704. if err != nil {
  45705. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  45706. }
  45707. return oldValue.Wxid, nil
  45708. }
  45709. // ResetWxid resets all changes to the "wxid" field.
  45710. func (m *WxCardUserMutation) ResetWxid() {
  45711. m.wxid = nil
  45712. }
  45713. // SetAccount sets the "account" field.
  45714. func (m *WxCardUserMutation) SetAccount(s string) {
  45715. m.account = &s
  45716. }
  45717. // Account returns the value of the "account" field in the mutation.
  45718. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  45719. v := m.account
  45720. if v == nil {
  45721. return
  45722. }
  45723. return *v, true
  45724. }
  45725. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  45726. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45727. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45728. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  45729. if !m.op.Is(OpUpdateOne) {
  45730. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  45731. }
  45732. if m.id == nil || m.oldValue == nil {
  45733. return v, errors.New("OldAccount requires an ID field in the mutation")
  45734. }
  45735. oldValue, err := m.oldValue(ctx)
  45736. if err != nil {
  45737. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  45738. }
  45739. return oldValue.Account, nil
  45740. }
  45741. // ResetAccount resets all changes to the "account" field.
  45742. func (m *WxCardUserMutation) ResetAccount() {
  45743. m.account = nil
  45744. }
  45745. // SetAvatar sets the "avatar" field.
  45746. func (m *WxCardUserMutation) SetAvatar(s string) {
  45747. m.avatar = &s
  45748. }
  45749. // Avatar returns the value of the "avatar" field in the mutation.
  45750. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  45751. v := m.avatar
  45752. if v == nil {
  45753. return
  45754. }
  45755. return *v, true
  45756. }
  45757. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  45758. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45759. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45760. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  45761. if !m.op.Is(OpUpdateOne) {
  45762. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  45763. }
  45764. if m.id == nil || m.oldValue == nil {
  45765. return v, errors.New("OldAvatar requires an ID field in the mutation")
  45766. }
  45767. oldValue, err := m.oldValue(ctx)
  45768. if err != nil {
  45769. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  45770. }
  45771. return oldValue.Avatar, nil
  45772. }
  45773. // ResetAvatar resets all changes to the "avatar" field.
  45774. func (m *WxCardUserMutation) ResetAvatar() {
  45775. m.avatar = nil
  45776. }
  45777. // SetNickname sets the "nickname" field.
  45778. func (m *WxCardUserMutation) SetNickname(s string) {
  45779. m.nickname = &s
  45780. }
  45781. // Nickname returns the value of the "nickname" field in the mutation.
  45782. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  45783. v := m.nickname
  45784. if v == nil {
  45785. return
  45786. }
  45787. return *v, true
  45788. }
  45789. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  45790. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45791. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45792. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  45793. if !m.op.Is(OpUpdateOne) {
  45794. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  45795. }
  45796. if m.id == nil || m.oldValue == nil {
  45797. return v, errors.New("OldNickname requires an ID field in the mutation")
  45798. }
  45799. oldValue, err := m.oldValue(ctx)
  45800. if err != nil {
  45801. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  45802. }
  45803. return oldValue.Nickname, nil
  45804. }
  45805. // ResetNickname resets all changes to the "nickname" field.
  45806. func (m *WxCardUserMutation) ResetNickname() {
  45807. m.nickname = nil
  45808. }
  45809. // SetRemark sets the "remark" field.
  45810. func (m *WxCardUserMutation) SetRemark(s string) {
  45811. m.remark = &s
  45812. }
  45813. // Remark returns the value of the "remark" field in the mutation.
  45814. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  45815. v := m.remark
  45816. if v == nil {
  45817. return
  45818. }
  45819. return *v, true
  45820. }
  45821. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  45822. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45823. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45824. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  45825. if !m.op.Is(OpUpdateOne) {
  45826. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  45827. }
  45828. if m.id == nil || m.oldValue == nil {
  45829. return v, errors.New("OldRemark requires an ID field in the mutation")
  45830. }
  45831. oldValue, err := m.oldValue(ctx)
  45832. if err != nil {
  45833. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  45834. }
  45835. return oldValue.Remark, nil
  45836. }
  45837. // ResetRemark resets all changes to the "remark" field.
  45838. func (m *WxCardUserMutation) ResetRemark() {
  45839. m.remark = nil
  45840. }
  45841. // SetPhone sets the "phone" field.
  45842. func (m *WxCardUserMutation) SetPhone(s string) {
  45843. m.phone = &s
  45844. }
  45845. // Phone returns the value of the "phone" field in the mutation.
  45846. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  45847. v := m.phone
  45848. if v == nil {
  45849. return
  45850. }
  45851. return *v, true
  45852. }
  45853. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  45854. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45855. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45856. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  45857. if !m.op.Is(OpUpdateOne) {
  45858. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  45859. }
  45860. if m.id == nil || m.oldValue == nil {
  45861. return v, errors.New("OldPhone requires an ID field in the mutation")
  45862. }
  45863. oldValue, err := m.oldValue(ctx)
  45864. if err != nil {
  45865. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  45866. }
  45867. return oldValue.Phone, nil
  45868. }
  45869. // ResetPhone resets all changes to the "phone" field.
  45870. func (m *WxCardUserMutation) ResetPhone() {
  45871. m.phone = nil
  45872. }
  45873. // SetOpenID sets the "open_id" field.
  45874. func (m *WxCardUserMutation) SetOpenID(s string) {
  45875. m.open_id = &s
  45876. }
  45877. // OpenID returns the value of the "open_id" field in the mutation.
  45878. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  45879. v := m.open_id
  45880. if v == nil {
  45881. return
  45882. }
  45883. return *v, true
  45884. }
  45885. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  45886. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45887. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45888. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  45889. if !m.op.Is(OpUpdateOne) {
  45890. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  45891. }
  45892. if m.id == nil || m.oldValue == nil {
  45893. return v, errors.New("OldOpenID requires an ID field in the mutation")
  45894. }
  45895. oldValue, err := m.oldValue(ctx)
  45896. if err != nil {
  45897. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  45898. }
  45899. return oldValue.OpenID, nil
  45900. }
  45901. // ResetOpenID resets all changes to the "open_id" field.
  45902. func (m *WxCardUserMutation) ResetOpenID() {
  45903. m.open_id = nil
  45904. }
  45905. // SetUnionID sets the "union_id" field.
  45906. func (m *WxCardUserMutation) SetUnionID(s string) {
  45907. m.union_id = &s
  45908. }
  45909. // UnionID returns the value of the "union_id" field in the mutation.
  45910. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  45911. v := m.union_id
  45912. if v == nil {
  45913. return
  45914. }
  45915. return *v, true
  45916. }
  45917. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  45918. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45919. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45920. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  45921. if !m.op.Is(OpUpdateOne) {
  45922. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  45923. }
  45924. if m.id == nil || m.oldValue == nil {
  45925. return v, errors.New("OldUnionID requires an ID field in the mutation")
  45926. }
  45927. oldValue, err := m.oldValue(ctx)
  45928. if err != nil {
  45929. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  45930. }
  45931. return oldValue.UnionID, nil
  45932. }
  45933. // ResetUnionID resets all changes to the "union_id" field.
  45934. func (m *WxCardUserMutation) ResetUnionID() {
  45935. m.union_id = nil
  45936. }
  45937. // SetSessionKey sets the "session_key" field.
  45938. func (m *WxCardUserMutation) SetSessionKey(s string) {
  45939. m.session_key = &s
  45940. }
  45941. // SessionKey returns the value of the "session_key" field in the mutation.
  45942. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  45943. v := m.session_key
  45944. if v == nil {
  45945. return
  45946. }
  45947. return *v, true
  45948. }
  45949. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  45950. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45951. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45952. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  45953. if !m.op.Is(OpUpdateOne) {
  45954. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  45955. }
  45956. if m.id == nil || m.oldValue == nil {
  45957. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  45958. }
  45959. oldValue, err := m.oldValue(ctx)
  45960. if err != nil {
  45961. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  45962. }
  45963. return oldValue.SessionKey, nil
  45964. }
  45965. // ResetSessionKey resets all changes to the "session_key" field.
  45966. func (m *WxCardUserMutation) ResetSessionKey() {
  45967. m.session_key = nil
  45968. }
  45969. // SetIsVip sets the "is_vip" field.
  45970. func (m *WxCardUserMutation) SetIsVip(i int) {
  45971. m.is_vip = &i
  45972. m.addis_vip = nil
  45973. }
  45974. // IsVip returns the value of the "is_vip" field in the mutation.
  45975. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  45976. v := m.is_vip
  45977. if v == nil {
  45978. return
  45979. }
  45980. return *v, true
  45981. }
  45982. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  45983. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45984. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45985. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  45986. if !m.op.Is(OpUpdateOne) {
  45987. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  45988. }
  45989. if m.id == nil || m.oldValue == nil {
  45990. return v, errors.New("OldIsVip requires an ID field in the mutation")
  45991. }
  45992. oldValue, err := m.oldValue(ctx)
  45993. if err != nil {
  45994. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  45995. }
  45996. return oldValue.IsVip, nil
  45997. }
  45998. // AddIsVip adds i to the "is_vip" field.
  45999. func (m *WxCardUserMutation) AddIsVip(i int) {
  46000. if m.addis_vip != nil {
  46001. *m.addis_vip += i
  46002. } else {
  46003. m.addis_vip = &i
  46004. }
  46005. }
  46006. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  46007. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  46008. v := m.addis_vip
  46009. if v == nil {
  46010. return
  46011. }
  46012. return *v, true
  46013. }
  46014. // ResetIsVip resets all changes to the "is_vip" field.
  46015. func (m *WxCardUserMutation) ResetIsVip() {
  46016. m.is_vip = nil
  46017. m.addis_vip = nil
  46018. }
  46019. // Where appends a list predicates to the WxCardUserMutation builder.
  46020. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  46021. m.predicates = append(m.predicates, ps...)
  46022. }
  46023. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  46024. // users can use type-assertion to append predicates that do not depend on any generated package.
  46025. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  46026. p := make([]predicate.WxCardUser, len(ps))
  46027. for i := range ps {
  46028. p[i] = ps[i]
  46029. }
  46030. m.Where(p...)
  46031. }
  46032. // Op returns the operation name.
  46033. func (m *WxCardUserMutation) Op() Op {
  46034. return m.op
  46035. }
  46036. // SetOp allows setting the mutation operation.
  46037. func (m *WxCardUserMutation) SetOp(op Op) {
  46038. m.op = op
  46039. }
  46040. // Type returns the node type of this mutation (WxCardUser).
  46041. func (m *WxCardUserMutation) Type() string {
  46042. return m.typ
  46043. }
  46044. // Fields returns all fields that were changed during this mutation. Note that in
  46045. // order to get all numeric fields that were incremented/decremented, call
  46046. // AddedFields().
  46047. func (m *WxCardUserMutation) Fields() []string {
  46048. fields := make([]string, 0, 13)
  46049. if m.created_at != nil {
  46050. fields = append(fields, wxcarduser.FieldCreatedAt)
  46051. }
  46052. if m.updated_at != nil {
  46053. fields = append(fields, wxcarduser.FieldUpdatedAt)
  46054. }
  46055. if m.deleted_at != nil {
  46056. fields = append(fields, wxcarduser.FieldDeletedAt)
  46057. }
  46058. if m.wxid != nil {
  46059. fields = append(fields, wxcarduser.FieldWxid)
  46060. }
  46061. if m.account != nil {
  46062. fields = append(fields, wxcarduser.FieldAccount)
  46063. }
  46064. if m.avatar != nil {
  46065. fields = append(fields, wxcarduser.FieldAvatar)
  46066. }
  46067. if m.nickname != nil {
  46068. fields = append(fields, wxcarduser.FieldNickname)
  46069. }
  46070. if m.remark != nil {
  46071. fields = append(fields, wxcarduser.FieldRemark)
  46072. }
  46073. if m.phone != nil {
  46074. fields = append(fields, wxcarduser.FieldPhone)
  46075. }
  46076. if m.open_id != nil {
  46077. fields = append(fields, wxcarduser.FieldOpenID)
  46078. }
  46079. if m.union_id != nil {
  46080. fields = append(fields, wxcarduser.FieldUnionID)
  46081. }
  46082. if m.session_key != nil {
  46083. fields = append(fields, wxcarduser.FieldSessionKey)
  46084. }
  46085. if m.is_vip != nil {
  46086. fields = append(fields, wxcarduser.FieldIsVip)
  46087. }
  46088. return fields
  46089. }
  46090. // Field returns the value of a field with the given name. The second boolean
  46091. // return value indicates that this field was not set, or was not defined in the
  46092. // schema.
  46093. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  46094. switch name {
  46095. case wxcarduser.FieldCreatedAt:
  46096. return m.CreatedAt()
  46097. case wxcarduser.FieldUpdatedAt:
  46098. return m.UpdatedAt()
  46099. case wxcarduser.FieldDeletedAt:
  46100. return m.DeletedAt()
  46101. case wxcarduser.FieldWxid:
  46102. return m.Wxid()
  46103. case wxcarduser.FieldAccount:
  46104. return m.Account()
  46105. case wxcarduser.FieldAvatar:
  46106. return m.Avatar()
  46107. case wxcarduser.FieldNickname:
  46108. return m.Nickname()
  46109. case wxcarduser.FieldRemark:
  46110. return m.Remark()
  46111. case wxcarduser.FieldPhone:
  46112. return m.Phone()
  46113. case wxcarduser.FieldOpenID:
  46114. return m.OpenID()
  46115. case wxcarduser.FieldUnionID:
  46116. return m.UnionID()
  46117. case wxcarduser.FieldSessionKey:
  46118. return m.SessionKey()
  46119. case wxcarduser.FieldIsVip:
  46120. return m.IsVip()
  46121. }
  46122. return nil, false
  46123. }
  46124. // OldField returns the old value of the field from the database. An error is
  46125. // returned if the mutation operation is not UpdateOne, or the query to the
  46126. // database failed.
  46127. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  46128. switch name {
  46129. case wxcarduser.FieldCreatedAt:
  46130. return m.OldCreatedAt(ctx)
  46131. case wxcarduser.FieldUpdatedAt:
  46132. return m.OldUpdatedAt(ctx)
  46133. case wxcarduser.FieldDeletedAt:
  46134. return m.OldDeletedAt(ctx)
  46135. case wxcarduser.FieldWxid:
  46136. return m.OldWxid(ctx)
  46137. case wxcarduser.FieldAccount:
  46138. return m.OldAccount(ctx)
  46139. case wxcarduser.FieldAvatar:
  46140. return m.OldAvatar(ctx)
  46141. case wxcarduser.FieldNickname:
  46142. return m.OldNickname(ctx)
  46143. case wxcarduser.FieldRemark:
  46144. return m.OldRemark(ctx)
  46145. case wxcarduser.FieldPhone:
  46146. return m.OldPhone(ctx)
  46147. case wxcarduser.FieldOpenID:
  46148. return m.OldOpenID(ctx)
  46149. case wxcarduser.FieldUnionID:
  46150. return m.OldUnionID(ctx)
  46151. case wxcarduser.FieldSessionKey:
  46152. return m.OldSessionKey(ctx)
  46153. case wxcarduser.FieldIsVip:
  46154. return m.OldIsVip(ctx)
  46155. }
  46156. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  46157. }
  46158. // SetField sets the value of a field with the given name. It returns an error if
  46159. // the field is not defined in the schema, or if the type mismatched the field
  46160. // type.
  46161. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  46162. switch name {
  46163. case wxcarduser.FieldCreatedAt:
  46164. v, ok := value.(time.Time)
  46165. if !ok {
  46166. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46167. }
  46168. m.SetCreatedAt(v)
  46169. return nil
  46170. case wxcarduser.FieldUpdatedAt:
  46171. v, ok := value.(time.Time)
  46172. if !ok {
  46173. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46174. }
  46175. m.SetUpdatedAt(v)
  46176. return nil
  46177. case wxcarduser.FieldDeletedAt:
  46178. v, ok := value.(time.Time)
  46179. if !ok {
  46180. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46181. }
  46182. m.SetDeletedAt(v)
  46183. return nil
  46184. case wxcarduser.FieldWxid:
  46185. v, ok := value.(string)
  46186. if !ok {
  46187. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46188. }
  46189. m.SetWxid(v)
  46190. return nil
  46191. case wxcarduser.FieldAccount:
  46192. v, ok := value.(string)
  46193. if !ok {
  46194. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46195. }
  46196. m.SetAccount(v)
  46197. return nil
  46198. case wxcarduser.FieldAvatar:
  46199. v, ok := value.(string)
  46200. if !ok {
  46201. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46202. }
  46203. m.SetAvatar(v)
  46204. return nil
  46205. case wxcarduser.FieldNickname:
  46206. v, ok := value.(string)
  46207. if !ok {
  46208. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46209. }
  46210. m.SetNickname(v)
  46211. return nil
  46212. case wxcarduser.FieldRemark:
  46213. v, ok := value.(string)
  46214. if !ok {
  46215. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46216. }
  46217. m.SetRemark(v)
  46218. return nil
  46219. case wxcarduser.FieldPhone:
  46220. v, ok := value.(string)
  46221. if !ok {
  46222. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46223. }
  46224. m.SetPhone(v)
  46225. return nil
  46226. case wxcarduser.FieldOpenID:
  46227. v, ok := value.(string)
  46228. if !ok {
  46229. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46230. }
  46231. m.SetOpenID(v)
  46232. return nil
  46233. case wxcarduser.FieldUnionID:
  46234. v, ok := value.(string)
  46235. if !ok {
  46236. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46237. }
  46238. m.SetUnionID(v)
  46239. return nil
  46240. case wxcarduser.FieldSessionKey:
  46241. v, ok := value.(string)
  46242. if !ok {
  46243. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46244. }
  46245. m.SetSessionKey(v)
  46246. return nil
  46247. case wxcarduser.FieldIsVip:
  46248. v, ok := value.(int)
  46249. if !ok {
  46250. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46251. }
  46252. m.SetIsVip(v)
  46253. return nil
  46254. }
  46255. return fmt.Errorf("unknown WxCardUser field %s", name)
  46256. }
  46257. // AddedFields returns all numeric fields that were incremented/decremented during
  46258. // this mutation.
  46259. func (m *WxCardUserMutation) AddedFields() []string {
  46260. var fields []string
  46261. if m.addis_vip != nil {
  46262. fields = append(fields, wxcarduser.FieldIsVip)
  46263. }
  46264. return fields
  46265. }
  46266. // AddedField returns the numeric value that was incremented/decremented on a field
  46267. // with the given name. The second boolean return value indicates that this field
  46268. // was not set, or was not defined in the schema.
  46269. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  46270. switch name {
  46271. case wxcarduser.FieldIsVip:
  46272. return m.AddedIsVip()
  46273. }
  46274. return nil, false
  46275. }
  46276. // AddField adds the value to the field with the given name. It returns an error if
  46277. // the field is not defined in the schema, or if the type mismatched the field
  46278. // type.
  46279. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  46280. switch name {
  46281. case wxcarduser.FieldIsVip:
  46282. v, ok := value.(int)
  46283. if !ok {
  46284. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46285. }
  46286. m.AddIsVip(v)
  46287. return nil
  46288. }
  46289. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  46290. }
  46291. // ClearedFields returns all nullable fields that were cleared during this
  46292. // mutation.
  46293. func (m *WxCardUserMutation) ClearedFields() []string {
  46294. var fields []string
  46295. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  46296. fields = append(fields, wxcarduser.FieldDeletedAt)
  46297. }
  46298. return fields
  46299. }
  46300. // FieldCleared returns a boolean indicating if a field with the given name was
  46301. // cleared in this mutation.
  46302. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  46303. _, ok := m.clearedFields[name]
  46304. return ok
  46305. }
  46306. // ClearField clears the value of the field with the given name. It returns an
  46307. // error if the field is not defined in the schema.
  46308. func (m *WxCardUserMutation) ClearField(name string) error {
  46309. switch name {
  46310. case wxcarduser.FieldDeletedAt:
  46311. m.ClearDeletedAt()
  46312. return nil
  46313. }
  46314. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  46315. }
  46316. // ResetField resets all changes in the mutation for the field with the given name.
  46317. // It returns an error if the field is not defined in the schema.
  46318. func (m *WxCardUserMutation) ResetField(name string) error {
  46319. switch name {
  46320. case wxcarduser.FieldCreatedAt:
  46321. m.ResetCreatedAt()
  46322. return nil
  46323. case wxcarduser.FieldUpdatedAt:
  46324. m.ResetUpdatedAt()
  46325. return nil
  46326. case wxcarduser.FieldDeletedAt:
  46327. m.ResetDeletedAt()
  46328. return nil
  46329. case wxcarduser.FieldWxid:
  46330. m.ResetWxid()
  46331. return nil
  46332. case wxcarduser.FieldAccount:
  46333. m.ResetAccount()
  46334. return nil
  46335. case wxcarduser.FieldAvatar:
  46336. m.ResetAvatar()
  46337. return nil
  46338. case wxcarduser.FieldNickname:
  46339. m.ResetNickname()
  46340. return nil
  46341. case wxcarduser.FieldRemark:
  46342. m.ResetRemark()
  46343. return nil
  46344. case wxcarduser.FieldPhone:
  46345. m.ResetPhone()
  46346. return nil
  46347. case wxcarduser.FieldOpenID:
  46348. m.ResetOpenID()
  46349. return nil
  46350. case wxcarduser.FieldUnionID:
  46351. m.ResetUnionID()
  46352. return nil
  46353. case wxcarduser.FieldSessionKey:
  46354. m.ResetSessionKey()
  46355. return nil
  46356. case wxcarduser.FieldIsVip:
  46357. m.ResetIsVip()
  46358. return nil
  46359. }
  46360. return fmt.Errorf("unknown WxCardUser field %s", name)
  46361. }
  46362. // AddedEdges returns all edge names that were set/added in this mutation.
  46363. func (m *WxCardUserMutation) AddedEdges() []string {
  46364. edges := make([]string, 0, 0)
  46365. return edges
  46366. }
  46367. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  46368. // name in this mutation.
  46369. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  46370. return nil
  46371. }
  46372. // RemovedEdges returns all edge names that were removed in this mutation.
  46373. func (m *WxCardUserMutation) RemovedEdges() []string {
  46374. edges := make([]string, 0, 0)
  46375. return edges
  46376. }
  46377. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  46378. // the given name in this mutation.
  46379. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  46380. return nil
  46381. }
  46382. // ClearedEdges returns all edge names that were cleared in this mutation.
  46383. func (m *WxCardUserMutation) ClearedEdges() []string {
  46384. edges := make([]string, 0, 0)
  46385. return edges
  46386. }
  46387. // EdgeCleared returns a boolean which indicates if the edge with the given name
  46388. // was cleared in this mutation.
  46389. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  46390. return false
  46391. }
  46392. // ClearEdge clears the value of the edge with the given name. It returns an error
  46393. // if that edge is not defined in the schema.
  46394. func (m *WxCardUserMutation) ClearEdge(name string) error {
  46395. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  46396. }
  46397. // ResetEdge resets all changes to the edge with the given name in this mutation.
  46398. // It returns an error if the edge is not defined in the schema.
  46399. func (m *WxCardUserMutation) ResetEdge(name string) error {
  46400. return fmt.Errorf("unknown WxCardUser edge %s", name)
  46401. }
  46402. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  46403. type WxCardVisitMutation struct {
  46404. config
  46405. op Op
  46406. typ string
  46407. id *uint64
  46408. created_at *time.Time
  46409. updated_at *time.Time
  46410. deleted_at *time.Time
  46411. user_id *uint64
  46412. adduser_id *int64
  46413. bot_id *uint64
  46414. addbot_id *int64
  46415. bot_type *uint8
  46416. addbot_type *int8
  46417. clearedFields map[string]struct{}
  46418. done bool
  46419. oldValue func(context.Context) (*WxCardVisit, error)
  46420. predicates []predicate.WxCardVisit
  46421. }
  46422. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  46423. // wxcardvisitOption allows management of the mutation configuration using functional options.
  46424. type wxcardvisitOption func(*WxCardVisitMutation)
  46425. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  46426. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  46427. m := &WxCardVisitMutation{
  46428. config: c,
  46429. op: op,
  46430. typ: TypeWxCardVisit,
  46431. clearedFields: make(map[string]struct{}),
  46432. }
  46433. for _, opt := range opts {
  46434. opt(m)
  46435. }
  46436. return m
  46437. }
  46438. // withWxCardVisitID sets the ID field of the mutation.
  46439. func withWxCardVisitID(id uint64) wxcardvisitOption {
  46440. return func(m *WxCardVisitMutation) {
  46441. var (
  46442. err error
  46443. once sync.Once
  46444. value *WxCardVisit
  46445. )
  46446. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  46447. once.Do(func() {
  46448. if m.done {
  46449. err = errors.New("querying old values post mutation is not allowed")
  46450. } else {
  46451. value, err = m.Client().WxCardVisit.Get(ctx, id)
  46452. }
  46453. })
  46454. return value, err
  46455. }
  46456. m.id = &id
  46457. }
  46458. }
  46459. // withWxCardVisit sets the old WxCardVisit of the mutation.
  46460. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  46461. return func(m *WxCardVisitMutation) {
  46462. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  46463. return node, nil
  46464. }
  46465. m.id = &node.ID
  46466. }
  46467. }
  46468. // Client returns a new `ent.Client` from the mutation. If the mutation was
  46469. // executed in a transaction (ent.Tx), a transactional client is returned.
  46470. func (m WxCardVisitMutation) Client() *Client {
  46471. client := &Client{config: m.config}
  46472. client.init()
  46473. return client
  46474. }
  46475. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  46476. // it returns an error otherwise.
  46477. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  46478. if _, ok := m.driver.(*txDriver); !ok {
  46479. return nil, errors.New("ent: mutation is not running in a transaction")
  46480. }
  46481. tx := &Tx{config: m.config}
  46482. tx.init()
  46483. return tx, nil
  46484. }
  46485. // SetID sets the value of the id field. Note that this
  46486. // operation is only accepted on creation of WxCardVisit entities.
  46487. func (m *WxCardVisitMutation) SetID(id uint64) {
  46488. m.id = &id
  46489. }
  46490. // ID returns the ID value in the mutation. Note that the ID is only available
  46491. // if it was provided to the builder or after it was returned from the database.
  46492. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  46493. if m.id == nil {
  46494. return
  46495. }
  46496. return *m.id, true
  46497. }
  46498. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  46499. // That means, if the mutation is applied within a transaction with an isolation level such
  46500. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  46501. // or updated by the mutation.
  46502. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  46503. switch {
  46504. case m.op.Is(OpUpdateOne | OpDeleteOne):
  46505. id, exists := m.ID()
  46506. if exists {
  46507. return []uint64{id}, nil
  46508. }
  46509. fallthrough
  46510. case m.op.Is(OpUpdate | OpDelete):
  46511. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  46512. default:
  46513. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  46514. }
  46515. }
  46516. // SetCreatedAt sets the "created_at" field.
  46517. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  46518. m.created_at = &t
  46519. }
  46520. // CreatedAt returns the value of the "created_at" field in the mutation.
  46521. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  46522. v := m.created_at
  46523. if v == nil {
  46524. return
  46525. }
  46526. return *v, true
  46527. }
  46528. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  46529. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  46530. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46531. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  46532. if !m.op.Is(OpUpdateOne) {
  46533. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  46534. }
  46535. if m.id == nil || m.oldValue == nil {
  46536. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  46537. }
  46538. oldValue, err := m.oldValue(ctx)
  46539. if err != nil {
  46540. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  46541. }
  46542. return oldValue.CreatedAt, nil
  46543. }
  46544. // ResetCreatedAt resets all changes to the "created_at" field.
  46545. func (m *WxCardVisitMutation) ResetCreatedAt() {
  46546. m.created_at = nil
  46547. }
  46548. // SetUpdatedAt sets the "updated_at" field.
  46549. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  46550. m.updated_at = &t
  46551. }
  46552. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  46553. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  46554. v := m.updated_at
  46555. if v == nil {
  46556. return
  46557. }
  46558. return *v, true
  46559. }
  46560. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  46561. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  46562. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46563. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  46564. if !m.op.Is(OpUpdateOne) {
  46565. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  46566. }
  46567. if m.id == nil || m.oldValue == nil {
  46568. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  46569. }
  46570. oldValue, err := m.oldValue(ctx)
  46571. if err != nil {
  46572. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  46573. }
  46574. return oldValue.UpdatedAt, nil
  46575. }
  46576. // ResetUpdatedAt resets all changes to the "updated_at" field.
  46577. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  46578. m.updated_at = nil
  46579. }
  46580. // SetDeletedAt sets the "deleted_at" field.
  46581. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  46582. m.deleted_at = &t
  46583. }
  46584. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  46585. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  46586. v := m.deleted_at
  46587. if v == nil {
  46588. return
  46589. }
  46590. return *v, true
  46591. }
  46592. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  46593. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  46594. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46595. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  46596. if !m.op.Is(OpUpdateOne) {
  46597. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  46598. }
  46599. if m.id == nil || m.oldValue == nil {
  46600. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  46601. }
  46602. oldValue, err := m.oldValue(ctx)
  46603. if err != nil {
  46604. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  46605. }
  46606. return oldValue.DeletedAt, nil
  46607. }
  46608. // ClearDeletedAt clears the value of the "deleted_at" field.
  46609. func (m *WxCardVisitMutation) ClearDeletedAt() {
  46610. m.deleted_at = nil
  46611. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  46612. }
  46613. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  46614. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  46615. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  46616. return ok
  46617. }
  46618. // ResetDeletedAt resets all changes to the "deleted_at" field.
  46619. func (m *WxCardVisitMutation) ResetDeletedAt() {
  46620. m.deleted_at = nil
  46621. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  46622. }
  46623. // SetUserID sets the "user_id" field.
  46624. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  46625. m.user_id = &u
  46626. m.adduser_id = nil
  46627. }
  46628. // UserID returns the value of the "user_id" field in the mutation.
  46629. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  46630. v := m.user_id
  46631. if v == nil {
  46632. return
  46633. }
  46634. return *v, true
  46635. }
  46636. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  46637. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  46638. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46639. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  46640. if !m.op.Is(OpUpdateOne) {
  46641. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  46642. }
  46643. if m.id == nil || m.oldValue == nil {
  46644. return v, errors.New("OldUserID requires an ID field in the mutation")
  46645. }
  46646. oldValue, err := m.oldValue(ctx)
  46647. if err != nil {
  46648. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  46649. }
  46650. return oldValue.UserID, nil
  46651. }
  46652. // AddUserID adds u to the "user_id" field.
  46653. func (m *WxCardVisitMutation) AddUserID(u int64) {
  46654. if m.adduser_id != nil {
  46655. *m.adduser_id += u
  46656. } else {
  46657. m.adduser_id = &u
  46658. }
  46659. }
  46660. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  46661. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  46662. v := m.adduser_id
  46663. if v == nil {
  46664. return
  46665. }
  46666. return *v, true
  46667. }
  46668. // ClearUserID clears the value of the "user_id" field.
  46669. func (m *WxCardVisitMutation) ClearUserID() {
  46670. m.user_id = nil
  46671. m.adduser_id = nil
  46672. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  46673. }
  46674. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  46675. func (m *WxCardVisitMutation) UserIDCleared() bool {
  46676. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  46677. return ok
  46678. }
  46679. // ResetUserID resets all changes to the "user_id" field.
  46680. func (m *WxCardVisitMutation) ResetUserID() {
  46681. m.user_id = nil
  46682. m.adduser_id = nil
  46683. delete(m.clearedFields, wxcardvisit.FieldUserID)
  46684. }
  46685. // SetBotID sets the "bot_id" field.
  46686. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  46687. m.bot_id = &u
  46688. m.addbot_id = nil
  46689. }
  46690. // BotID returns the value of the "bot_id" field in the mutation.
  46691. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  46692. v := m.bot_id
  46693. if v == nil {
  46694. return
  46695. }
  46696. return *v, true
  46697. }
  46698. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  46699. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  46700. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46701. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  46702. if !m.op.Is(OpUpdateOne) {
  46703. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  46704. }
  46705. if m.id == nil || m.oldValue == nil {
  46706. return v, errors.New("OldBotID requires an ID field in the mutation")
  46707. }
  46708. oldValue, err := m.oldValue(ctx)
  46709. if err != nil {
  46710. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  46711. }
  46712. return oldValue.BotID, nil
  46713. }
  46714. // AddBotID adds u to the "bot_id" field.
  46715. func (m *WxCardVisitMutation) AddBotID(u int64) {
  46716. if m.addbot_id != nil {
  46717. *m.addbot_id += u
  46718. } else {
  46719. m.addbot_id = &u
  46720. }
  46721. }
  46722. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  46723. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  46724. v := m.addbot_id
  46725. if v == nil {
  46726. return
  46727. }
  46728. return *v, true
  46729. }
  46730. // ResetBotID resets all changes to the "bot_id" field.
  46731. func (m *WxCardVisitMutation) ResetBotID() {
  46732. m.bot_id = nil
  46733. m.addbot_id = nil
  46734. }
  46735. // SetBotType sets the "bot_type" field.
  46736. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  46737. m.bot_type = &u
  46738. m.addbot_type = nil
  46739. }
  46740. // BotType returns the value of the "bot_type" field in the mutation.
  46741. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  46742. v := m.bot_type
  46743. if v == nil {
  46744. return
  46745. }
  46746. return *v, true
  46747. }
  46748. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  46749. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  46750. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46751. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  46752. if !m.op.Is(OpUpdateOne) {
  46753. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  46754. }
  46755. if m.id == nil || m.oldValue == nil {
  46756. return v, errors.New("OldBotType requires an ID field in the mutation")
  46757. }
  46758. oldValue, err := m.oldValue(ctx)
  46759. if err != nil {
  46760. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  46761. }
  46762. return oldValue.BotType, nil
  46763. }
  46764. // AddBotType adds u to the "bot_type" field.
  46765. func (m *WxCardVisitMutation) AddBotType(u int8) {
  46766. if m.addbot_type != nil {
  46767. *m.addbot_type += u
  46768. } else {
  46769. m.addbot_type = &u
  46770. }
  46771. }
  46772. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  46773. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  46774. v := m.addbot_type
  46775. if v == nil {
  46776. return
  46777. }
  46778. return *v, true
  46779. }
  46780. // ResetBotType resets all changes to the "bot_type" field.
  46781. func (m *WxCardVisitMutation) ResetBotType() {
  46782. m.bot_type = nil
  46783. m.addbot_type = nil
  46784. }
  46785. // Where appends a list predicates to the WxCardVisitMutation builder.
  46786. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  46787. m.predicates = append(m.predicates, ps...)
  46788. }
  46789. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  46790. // users can use type-assertion to append predicates that do not depend on any generated package.
  46791. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  46792. p := make([]predicate.WxCardVisit, len(ps))
  46793. for i := range ps {
  46794. p[i] = ps[i]
  46795. }
  46796. m.Where(p...)
  46797. }
  46798. // Op returns the operation name.
  46799. func (m *WxCardVisitMutation) Op() Op {
  46800. return m.op
  46801. }
  46802. // SetOp allows setting the mutation operation.
  46803. func (m *WxCardVisitMutation) SetOp(op Op) {
  46804. m.op = op
  46805. }
  46806. // Type returns the node type of this mutation (WxCardVisit).
  46807. func (m *WxCardVisitMutation) Type() string {
  46808. return m.typ
  46809. }
  46810. // Fields returns all fields that were changed during this mutation. Note that in
  46811. // order to get all numeric fields that were incremented/decremented, call
  46812. // AddedFields().
  46813. func (m *WxCardVisitMutation) Fields() []string {
  46814. fields := make([]string, 0, 6)
  46815. if m.created_at != nil {
  46816. fields = append(fields, wxcardvisit.FieldCreatedAt)
  46817. }
  46818. if m.updated_at != nil {
  46819. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  46820. }
  46821. if m.deleted_at != nil {
  46822. fields = append(fields, wxcardvisit.FieldDeletedAt)
  46823. }
  46824. if m.user_id != nil {
  46825. fields = append(fields, wxcardvisit.FieldUserID)
  46826. }
  46827. if m.bot_id != nil {
  46828. fields = append(fields, wxcardvisit.FieldBotID)
  46829. }
  46830. if m.bot_type != nil {
  46831. fields = append(fields, wxcardvisit.FieldBotType)
  46832. }
  46833. return fields
  46834. }
  46835. // Field returns the value of a field with the given name. The second boolean
  46836. // return value indicates that this field was not set, or was not defined in the
  46837. // schema.
  46838. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  46839. switch name {
  46840. case wxcardvisit.FieldCreatedAt:
  46841. return m.CreatedAt()
  46842. case wxcardvisit.FieldUpdatedAt:
  46843. return m.UpdatedAt()
  46844. case wxcardvisit.FieldDeletedAt:
  46845. return m.DeletedAt()
  46846. case wxcardvisit.FieldUserID:
  46847. return m.UserID()
  46848. case wxcardvisit.FieldBotID:
  46849. return m.BotID()
  46850. case wxcardvisit.FieldBotType:
  46851. return m.BotType()
  46852. }
  46853. return nil, false
  46854. }
  46855. // OldField returns the old value of the field from the database. An error is
  46856. // returned if the mutation operation is not UpdateOne, or the query to the
  46857. // database failed.
  46858. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  46859. switch name {
  46860. case wxcardvisit.FieldCreatedAt:
  46861. return m.OldCreatedAt(ctx)
  46862. case wxcardvisit.FieldUpdatedAt:
  46863. return m.OldUpdatedAt(ctx)
  46864. case wxcardvisit.FieldDeletedAt:
  46865. return m.OldDeletedAt(ctx)
  46866. case wxcardvisit.FieldUserID:
  46867. return m.OldUserID(ctx)
  46868. case wxcardvisit.FieldBotID:
  46869. return m.OldBotID(ctx)
  46870. case wxcardvisit.FieldBotType:
  46871. return m.OldBotType(ctx)
  46872. }
  46873. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  46874. }
  46875. // SetField sets the value of a field with the given name. It returns an error if
  46876. // the field is not defined in the schema, or if the type mismatched the field
  46877. // type.
  46878. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  46879. switch name {
  46880. case wxcardvisit.FieldCreatedAt:
  46881. v, ok := value.(time.Time)
  46882. if !ok {
  46883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46884. }
  46885. m.SetCreatedAt(v)
  46886. return nil
  46887. case wxcardvisit.FieldUpdatedAt:
  46888. v, ok := value.(time.Time)
  46889. if !ok {
  46890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46891. }
  46892. m.SetUpdatedAt(v)
  46893. return nil
  46894. case wxcardvisit.FieldDeletedAt:
  46895. v, ok := value.(time.Time)
  46896. if !ok {
  46897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46898. }
  46899. m.SetDeletedAt(v)
  46900. return nil
  46901. case wxcardvisit.FieldUserID:
  46902. v, ok := value.(uint64)
  46903. if !ok {
  46904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46905. }
  46906. m.SetUserID(v)
  46907. return nil
  46908. case wxcardvisit.FieldBotID:
  46909. v, ok := value.(uint64)
  46910. if !ok {
  46911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46912. }
  46913. m.SetBotID(v)
  46914. return nil
  46915. case wxcardvisit.FieldBotType:
  46916. v, ok := value.(uint8)
  46917. if !ok {
  46918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46919. }
  46920. m.SetBotType(v)
  46921. return nil
  46922. }
  46923. return fmt.Errorf("unknown WxCardVisit field %s", name)
  46924. }
  46925. // AddedFields returns all numeric fields that were incremented/decremented during
  46926. // this mutation.
  46927. func (m *WxCardVisitMutation) AddedFields() []string {
  46928. var fields []string
  46929. if m.adduser_id != nil {
  46930. fields = append(fields, wxcardvisit.FieldUserID)
  46931. }
  46932. if m.addbot_id != nil {
  46933. fields = append(fields, wxcardvisit.FieldBotID)
  46934. }
  46935. if m.addbot_type != nil {
  46936. fields = append(fields, wxcardvisit.FieldBotType)
  46937. }
  46938. return fields
  46939. }
  46940. // AddedField returns the numeric value that was incremented/decremented on a field
  46941. // with the given name. The second boolean return value indicates that this field
  46942. // was not set, or was not defined in the schema.
  46943. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  46944. switch name {
  46945. case wxcardvisit.FieldUserID:
  46946. return m.AddedUserID()
  46947. case wxcardvisit.FieldBotID:
  46948. return m.AddedBotID()
  46949. case wxcardvisit.FieldBotType:
  46950. return m.AddedBotType()
  46951. }
  46952. return nil, false
  46953. }
  46954. // AddField adds the value to the field with the given name. It returns an error if
  46955. // the field is not defined in the schema, or if the type mismatched the field
  46956. // type.
  46957. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  46958. switch name {
  46959. case wxcardvisit.FieldUserID:
  46960. v, ok := value.(int64)
  46961. if !ok {
  46962. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46963. }
  46964. m.AddUserID(v)
  46965. return nil
  46966. case wxcardvisit.FieldBotID:
  46967. v, ok := value.(int64)
  46968. if !ok {
  46969. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46970. }
  46971. m.AddBotID(v)
  46972. return nil
  46973. case wxcardvisit.FieldBotType:
  46974. v, ok := value.(int8)
  46975. if !ok {
  46976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46977. }
  46978. m.AddBotType(v)
  46979. return nil
  46980. }
  46981. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  46982. }
  46983. // ClearedFields returns all nullable fields that were cleared during this
  46984. // mutation.
  46985. func (m *WxCardVisitMutation) ClearedFields() []string {
  46986. var fields []string
  46987. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  46988. fields = append(fields, wxcardvisit.FieldDeletedAt)
  46989. }
  46990. if m.FieldCleared(wxcardvisit.FieldUserID) {
  46991. fields = append(fields, wxcardvisit.FieldUserID)
  46992. }
  46993. return fields
  46994. }
  46995. // FieldCleared returns a boolean indicating if a field with the given name was
  46996. // cleared in this mutation.
  46997. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  46998. _, ok := m.clearedFields[name]
  46999. return ok
  47000. }
  47001. // ClearField clears the value of the field with the given name. It returns an
  47002. // error if the field is not defined in the schema.
  47003. func (m *WxCardVisitMutation) ClearField(name string) error {
  47004. switch name {
  47005. case wxcardvisit.FieldDeletedAt:
  47006. m.ClearDeletedAt()
  47007. return nil
  47008. case wxcardvisit.FieldUserID:
  47009. m.ClearUserID()
  47010. return nil
  47011. }
  47012. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  47013. }
  47014. // ResetField resets all changes in the mutation for the field with the given name.
  47015. // It returns an error if the field is not defined in the schema.
  47016. func (m *WxCardVisitMutation) ResetField(name string) error {
  47017. switch name {
  47018. case wxcardvisit.FieldCreatedAt:
  47019. m.ResetCreatedAt()
  47020. return nil
  47021. case wxcardvisit.FieldUpdatedAt:
  47022. m.ResetUpdatedAt()
  47023. return nil
  47024. case wxcardvisit.FieldDeletedAt:
  47025. m.ResetDeletedAt()
  47026. return nil
  47027. case wxcardvisit.FieldUserID:
  47028. m.ResetUserID()
  47029. return nil
  47030. case wxcardvisit.FieldBotID:
  47031. m.ResetBotID()
  47032. return nil
  47033. case wxcardvisit.FieldBotType:
  47034. m.ResetBotType()
  47035. return nil
  47036. }
  47037. return fmt.Errorf("unknown WxCardVisit field %s", name)
  47038. }
  47039. // AddedEdges returns all edge names that were set/added in this mutation.
  47040. func (m *WxCardVisitMutation) AddedEdges() []string {
  47041. edges := make([]string, 0, 0)
  47042. return edges
  47043. }
  47044. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  47045. // name in this mutation.
  47046. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  47047. return nil
  47048. }
  47049. // RemovedEdges returns all edge names that were removed in this mutation.
  47050. func (m *WxCardVisitMutation) RemovedEdges() []string {
  47051. edges := make([]string, 0, 0)
  47052. return edges
  47053. }
  47054. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  47055. // the given name in this mutation.
  47056. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  47057. return nil
  47058. }
  47059. // ClearedEdges returns all edge names that were cleared in this mutation.
  47060. func (m *WxCardVisitMutation) ClearedEdges() []string {
  47061. edges := make([]string, 0, 0)
  47062. return edges
  47063. }
  47064. // EdgeCleared returns a boolean which indicates if the edge with the given name
  47065. // was cleared in this mutation.
  47066. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  47067. return false
  47068. }
  47069. // ClearEdge clears the value of the edge with the given name. It returns an error
  47070. // if that edge is not defined in the schema.
  47071. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  47072. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  47073. }
  47074. // ResetEdge resets all changes to the edge with the given name in this mutation.
  47075. // It returns an error if the edge is not defined in the schema.
  47076. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  47077. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  47078. }