mutation.go 1.4 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "sync"
  8. "time"
  9. "wechat-api/ent/agent"
  10. "wechat-api/ent/agentbase"
  11. "wechat-api/ent/aliyunavatar"
  12. "wechat-api/ent/allocagent"
  13. "wechat-api/ent/batchmsg"
  14. "wechat-api/ent/category"
  15. "wechat-api/ent/chatrecords"
  16. "wechat-api/ent/chatsession"
  17. "wechat-api/ent/contact"
  18. "wechat-api/ent/creditbalance"
  19. "wechat-api/ent/creditusage"
  20. "wechat-api/ent/custom_types"
  21. "wechat-api/ent/employee"
  22. "wechat-api/ent/employeeconfig"
  23. "wechat-api/ent/label"
  24. "wechat-api/ent/labelrelationship"
  25. "wechat-api/ent/labeltagging"
  26. "wechat-api/ent/message"
  27. "wechat-api/ent/messagerecords"
  28. "wechat-api/ent/msg"
  29. "wechat-api/ent/payrecharge"
  30. "wechat-api/ent/predicate"
  31. "wechat-api/ent/server"
  32. "wechat-api/ent/sopnode"
  33. "wechat-api/ent/sopstage"
  34. "wechat-api/ent/soptask"
  35. "wechat-api/ent/token"
  36. "wechat-api/ent/tutorial"
  37. "wechat-api/ent/usagedetail"
  38. "wechat-api/ent/usagestatisticday"
  39. "wechat-api/ent/usagestatistichour"
  40. "wechat-api/ent/usagestatisticmonth"
  41. "wechat-api/ent/usagetotal"
  42. "wechat-api/ent/whatsapp"
  43. "wechat-api/ent/whatsappchannel"
  44. "wechat-api/ent/workexperience"
  45. "wechat-api/ent/wpchatroom"
  46. "wechat-api/ent/wpchatroommember"
  47. "wechat-api/ent/wx"
  48. "wechat-api/ent/wxcard"
  49. "wechat-api/ent/wxcarduser"
  50. "wechat-api/ent/wxcardvisit"
  51. "wechat-api/ent/xunji"
  52. "entgo.io/ent"
  53. "entgo.io/ent/dialect/sql"
  54. )
  55. const (
  56. // Operation types.
  57. OpCreate = ent.OpCreate
  58. OpDelete = ent.OpDelete
  59. OpDeleteOne = ent.OpDeleteOne
  60. OpUpdate = ent.OpUpdate
  61. OpUpdateOne = ent.OpUpdateOne
  62. // Node types.
  63. TypeAgent = "Agent"
  64. TypeAgentBase = "AgentBase"
  65. TypeAliyunAvatar = "AliyunAvatar"
  66. TypeAllocAgent = "AllocAgent"
  67. TypeBatchMsg = "BatchMsg"
  68. TypeCategory = "Category"
  69. TypeChatRecords = "ChatRecords"
  70. TypeChatSession = "ChatSession"
  71. TypeContact = "Contact"
  72. TypeCreditBalance = "CreditBalance"
  73. TypeCreditUsage = "CreditUsage"
  74. TypeEmployee = "Employee"
  75. TypeEmployeeConfig = "EmployeeConfig"
  76. TypeLabel = "Label"
  77. TypeLabelRelationship = "LabelRelationship"
  78. TypeLabelTagging = "LabelTagging"
  79. TypeMessage = "Message"
  80. TypeMessageRecords = "MessageRecords"
  81. TypeMsg = "Msg"
  82. TypePayRecharge = "PayRecharge"
  83. TypeServer = "Server"
  84. TypeSopNode = "SopNode"
  85. TypeSopStage = "SopStage"
  86. TypeSopTask = "SopTask"
  87. TypeToken = "Token"
  88. TypeTutorial = "Tutorial"
  89. TypeUsageDetail = "UsageDetail"
  90. TypeUsageStatisticDay = "UsageStatisticDay"
  91. TypeUsageStatisticHour = "UsageStatisticHour"
  92. TypeUsageStatisticMonth = "UsageStatisticMonth"
  93. TypeUsageTotal = "UsageTotal"
  94. TypeWhatsapp = "Whatsapp"
  95. TypeWhatsappChannel = "WhatsappChannel"
  96. TypeWorkExperience = "WorkExperience"
  97. TypeWpChatroom = "WpChatroom"
  98. TypeWpChatroomMember = "WpChatroomMember"
  99. TypeWx = "Wx"
  100. TypeWxCard = "WxCard"
  101. TypeWxCardUser = "WxCardUser"
  102. TypeWxCardVisit = "WxCardVisit"
  103. TypeXunji = "Xunji"
  104. )
  105. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  106. type AgentMutation struct {
  107. config
  108. op Op
  109. typ string
  110. id *uint64
  111. created_at *time.Time
  112. updated_at *time.Time
  113. deleted_at *time.Time
  114. name *string
  115. role *string
  116. status *int
  117. addstatus *int
  118. background *string
  119. examples *string
  120. organization_id *uint64
  121. addorganization_id *int64
  122. dataset_id *string
  123. collection_id *string
  124. clearedFields map[string]struct{}
  125. wx_agent map[uint64]struct{}
  126. removedwx_agent map[uint64]struct{}
  127. clearedwx_agent bool
  128. token_agent map[uint64]struct{}
  129. removedtoken_agent map[uint64]struct{}
  130. clearedtoken_agent bool
  131. wa_agent map[uint64]struct{}
  132. removedwa_agent map[uint64]struct{}
  133. clearedwa_agent bool
  134. done bool
  135. oldValue func(context.Context) (*Agent, error)
  136. predicates []predicate.Agent
  137. }
  138. var _ ent.Mutation = (*AgentMutation)(nil)
  139. // agentOption allows management of the mutation configuration using functional options.
  140. type agentOption func(*AgentMutation)
  141. // newAgentMutation creates new mutation for the Agent entity.
  142. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  143. m := &AgentMutation{
  144. config: c,
  145. op: op,
  146. typ: TypeAgent,
  147. clearedFields: make(map[string]struct{}),
  148. }
  149. for _, opt := range opts {
  150. opt(m)
  151. }
  152. return m
  153. }
  154. // withAgentID sets the ID field of the mutation.
  155. func withAgentID(id uint64) agentOption {
  156. return func(m *AgentMutation) {
  157. var (
  158. err error
  159. once sync.Once
  160. value *Agent
  161. )
  162. m.oldValue = func(ctx context.Context) (*Agent, error) {
  163. once.Do(func() {
  164. if m.done {
  165. err = errors.New("querying old values post mutation is not allowed")
  166. } else {
  167. value, err = m.Client().Agent.Get(ctx, id)
  168. }
  169. })
  170. return value, err
  171. }
  172. m.id = &id
  173. }
  174. }
  175. // withAgent sets the old Agent of the mutation.
  176. func withAgent(node *Agent) agentOption {
  177. return func(m *AgentMutation) {
  178. m.oldValue = func(context.Context) (*Agent, error) {
  179. return node, nil
  180. }
  181. m.id = &node.ID
  182. }
  183. }
  184. // Client returns a new `ent.Client` from the mutation. If the mutation was
  185. // executed in a transaction (ent.Tx), a transactional client is returned.
  186. func (m AgentMutation) Client() *Client {
  187. client := &Client{config: m.config}
  188. client.init()
  189. return client
  190. }
  191. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  192. // it returns an error otherwise.
  193. func (m AgentMutation) Tx() (*Tx, error) {
  194. if _, ok := m.driver.(*txDriver); !ok {
  195. return nil, errors.New("ent: mutation is not running in a transaction")
  196. }
  197. tx := &Tx{config: m.config}
  198. tx.init()
  199. return tx, nil
  200. }
  201. // SetID sets the value of the id field. Note that this
  202. // operation is only accepted on creation of Agent entities.
  203. func (m *AgentMutation) SetID(id uint64) {
  204. m.id = &id
  205. }
  206. // ID returns the ID value in the mutation. Note that the ID is only available
  207. // if it was provided to the builder or after it was returned from the database.
  208. func (m *AgentMutation) ID() (id uint64, exists bool) {
  209. if m.id == nil {
  210. return
  211. }
  212. return *m.id, true
  213. }
  214. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  215. // That means, if the mutation is applied within a transaction with an isolation level such
  216. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  217. // or updated by the mutation.
  218. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  219. switch {
  220. case m.op.Is(OpUpdateOne | OpDeleteOne):
  221. id, exists := m.ID()
  222. if exists {
  223. return []uint64{id}, nil
  224. }
  225. fallthrough
  226. case m.op.Is(OpUpdate | OpDelete):
  227. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  228. default:
  229. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  230. }
  231. }
  232. // SetCreatedAt sets the "created_at" field.
  233. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  234. m.created_at = &t
  235. }
  236. // CreatedAt returns the value of the "created_at" field in the mutation.
  237. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  238. v := m.created_at
  239. if v == nil {
  240. return
  241. }
  242. return *v, true
  243. }
  244. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  245. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  246. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  247. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  248. if !m.op.Is(OpUpdateOne) {
  249. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  250. }
  251. if m.id == nil || m.oldValue == nil {
  252. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  253. }
  254. oldValue, err := m.oldValue(ctx)
  255. if err != nil {
  256. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  257. }
  258. return oldValue.CreatedAt, nil
  259. }
  260. // ResetCreatedAt resets all changes to the "created_at" field.
  261. func (m *AgentMutation) ResetCreatedAt() {
  262. m.created_at = nil
  263. }
  264. // SetUpdatedAt sets the "updated_at" field.
  265. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  266. m.updated_at = &t
  267. }
  268. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  269. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  270. v := m.updated_at
  271. if v == nil {
  272. return
  273. }
  274. return *v, true
  275. }
  276. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  277. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  278. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  279. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  280. if !m.op.Is(OpUpdateOne) {
  281. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  282. }
  283. if m.id == nil || m.oldValue == nil {
  284. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  285. }
  286. oldValue, err := m.oldValue(ctx)
  287. if err != nil {
  288. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  289. }
  290. return oldValue.UpdatedAt, nil
  291. }
  292. // ResetUpdatedAt resets all changes to the "updated_at" field.
  293. func (m *AgentMutation) ResetUpdatedAt() {
  294. m.updated_at = nil
  295. }
  296. // SetDeletedAt sets the "deleted_at" field.
  297. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  298. m.deleted_at = &t
  299. }
  300. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  301. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  302. v := m.deleted_at
  303. if v == nil {
  304. return
  305. }
  306. return *v, true
  307. }
  308. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  309. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  310. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  311. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  312. if !m.op.Is(OpUpdateOne) {
  313. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  314. }
  315. if m.id == nil || m.oldValue == nil {
  316. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  317. }
  318. oldValue, err := m.oldValue(ctx)
  319. if err != nil {
  320. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  321. }
  322. return oldValue.DeletedAt, nil
  323. }
  324. // ClearDeletedAt clears the value of the "deleted_at" field.
  325. func (m *AgentMutation) ClearDeletedAt() {
  326. m.deleted_at = nil
  327. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  328. }
  329. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  330. func (m *AgentMutation) DeletedAtCleared() bool {
  331. _, ok := m.clearedFields[agent.FieldDeletedAt]
  332. return ok
  333. }
  334. // ResetDeletedAt resets all changes to the "deleted_at" field.
  335. func (m *AgentMutation) ResetDeletedAt() {
  336. m.deleted_at = nil
  337. delete(m.clearedFields, agent.FieldDeletedAt)
  338. }
  339. // SetName sets the "name" field.
  340. func (m *AgentMutation) SetName(s string) {
  341. m.name = &s
  342. }
  343. // Name returns the value of the "name" field in the mutation.
  344. func (m *AgentMutation) Name() (r string, exists bool) {
  345. v := m.name
  346. if v == nil {
  347. return
  348. }
  349. return *v, true
  350. }
  351. // OldName returns the old "name" field's value of the Agent entity.
  352. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  353. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  354. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  355. if !m.op.Is(OpUpdateOne) {
  356. return v, errors.New("OldName is only allowed on UpdateOne operations")
  357. }
  358. if m.id == nil || m.oldValue == nil {
  359. return v, errors.New("OldName requires an ID field in the mutation")
  360. }
  361. oldValue, err := m.oldValue(ctx)
  362. if err != nil {
  363. return v, fmt.Errorf("querying old value for OldName: %w", err)
  364. }
  365. return oldValue.Name, nil
  366. }
  367. // ResetName resets all changes to the "name" field.
  368. func (m *AgentMutation) ResetName() {
  369. m.name = nil
  370. }
  371. // SetRole sets the "role" field.
  372. func (m *AgentMutation) SetRole(s string) {
  373. m.role = &s
  374. }
  375. // Role returns the value of the "role" field in the mutation.
  376. func (m *AgentMutation) Role() (r string, exists bool) {
  377. v := m.role
  378. if v == nil {
  379. return
  380. }
  381. return *v, true
  382. }
  383. // OldRole returns the old "role" field's value of the Agent entity.
  384. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  386. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  387. if !m.op.Is(OpUpdateOne) {
  388. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  389. }
  390. if m.id == nil || m.oldValue == nil {
  391. return v, errors.New("OldRole requires an ID field in the mutation")
  392. }
  393. oldValue, err := m.oldValue(ctx)
  394. if err != nil {
  395. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  396. }
  397. return oldValue.Role, nil
  398. }
  399. // ResetRole resets all changes to the "role" field.
  400. func (m *AgentMutation) ResetRole() {
  401. m.role = nil
  402. }
  403. // SetStatus sets the "status" field.
  404. func (m *AgentMutation) SetStatus(i int) {
  405. m.status = &i
  406. m.addstatus = nil
  407. }
  408. // Status returns the value of the "status" field in the mutation.
  409. func (m *AgentMutation) Status() (r int, exists bool) {
  410. v := m.status
  411. if v == nil {
  412. return
  413. }
  414. return *v, true
  415. }
  416. // OldStatus returns the old "status" field's value of the Agent entity.
  417. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  418. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  419. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  420. if !m.op.Is(OpUpdateOne) {
  421. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  422. }
  423. if m.id == nil || m.oldValue == nil {
  424. return v, errors.New("OldStatus requires an ID field in the mutation")
  425. }
  426. oldValue, err := m.oldValue(ctx)
  427. if err != nil {
  428. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  429. }
  430. return oldValue.Status, nil
  431. }
  432. // AddStatus adds i to the "status" field.
  433. func (m *AgentMutation) AddStatus(i int) {
  434. if m.addstatus != nil {
  435. *m.addstatus += i
  436. } else {
  437. m.addstatus = &i
  438. }
  439. }
  440. // AddedStatus returns the value that was added to the "status" field in this mutation.
  441. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  442. v := m.addstatus
  443. if v == nil {
  444. return
  445. }
  446. return *v, true
  447. }
  448. // ClearStatus clears the value of the "status" field.
  449. func (m *AgentMutation) ClearStatus() {
  450. m.status = nil
  451. m.addstatus = nil
  452. m.clearedFields[agent.FieldStatus] = struct{}{}
  453. }
  454. // StatusCleared returns if the "status" field was cleared in this mutation.
  455. func (m *AgentMutation) StatusCleared() bool {
  456. _, ok := m.clearedFields[agent.FieldStatus]
  457. return ok
  458. }
  459. // ResetStatus resets all changes to the "status" field.
  460. func (m *AgentMutation) ResetStatus() {
  461. m.status = nil
  462. m.addstatus = nil
  463. delete(m.clearedFields, agent.FieldStatus)
  464. }
  465. // SetBackground sets the "background" field.
  466. func (m *AgentMutation) SetBackground(s string) {
  467. m.background = &s
  468. }
  469. // Background returns the value of the "background" field in the mutation.
  470. func (m *AgentMutation) Background() (r string, exists bool) {
  471. v := m.background
  472. if v == nil {
  473. return
  474. }
  475. return *v, true
  476. }
  477. // OldBackground returns the old "background" field's value of the Agent entity.
  478. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  479. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  480. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  481. if !m.op.Is(OpUpdateOne) {
  482. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  483. }
  484. if m.id == nil || m.oldValue == nil {
  485. return v, errors.New("OldBackground requires an ID field in the mutation")
  486. }
  487. oldValue, err := m.oldValue(ctx)
  488. if err != nil {
  489. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  490. }
  491. return oldValue.Background, nil
  492. }
  493. // ClearBackground clears the value of the "background" field.
  494. func (m *AgentMutation) ClearBackground() {
  495. m.background = nil
  496. m.clearedFields[agent.FieldBackground] = struct{}{}
  497. }
  498. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  499. func (m *AgentMutation) BackgroundCleared() bool {
  500. _, ok := m.clearedFields[agent.FieldBackground]
  501. return ok
  502. }
  503. // ResetBackground resets all changes to the "background" field.
  504. func (m *AgentMutation) ResetBackground() {
  505. m.background = nil
  506. delete(m.clearedFields, agent.FieldBackground)
  507. }
  508. // SetExamples sets the "examples" field.
  509. func (m *AgentMutation) SetExamples(s string) {
  510. m.examples = &s
  511. }
  512. // Examples returns the value of the "examples" field in the mutation.
  513. func (m *AgentMutation) Examples() (r string, exists bool) {
  514. v := m.examples
  515. if v == nil {
  516. return
  517. }
  518. return *v, true
  519. }
  520. // OldExamples returns the old "examples" field's value of the Agent entity.
  521. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  522. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  523. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  524. if !m.op.Is(OpUpdateOne) {
  525. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  526. }
  527. if m.id == nil || m.oldValue == nil {
  528. return v, errors.New("OldExamples requires an ID field in the mutation")
  529. }
  530. oldValue, err := m.oldValue(ctx)
  531. if err != nil {
  532. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  533. }
  534. return oldValue.Examples, nil
  535. }
  536. // ClearExamples clears the value of the "examples" field.
  537. func (m *AgentMutation) ClearExamples() {
  538. m.examples = nil
  539. m.clearedFields[agent.FieldExamples] = struct{}{}
  540. }
  541. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  542. func (m *AgentMutation) ExamplesCleared() bool {
  543. _, ok := m.clearedFields[agent.FieldExamples]
  544. return ok
  545. }
  546. // ResetExamples resets all changes to the "examples" field.
  547. func (m *AgentMutation) ResetExamples() {
  548. m.examples = nil
  549. delete(m.clearedFields, agent.FieldExamples)
  550. }
  551. // SetOrganizationID sets the "organization_id" field.
  552. func (m *AgentMutation) SetOrganizationID(u uint64) {
  553. m.organization_id = &u
  554. m.addorganization_id = nil
  555. }
  556. // OrganizationID returns the value of the "organization_id" field in the mutation.
  557. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  558. v := m.organization_id
  559. if v == nil {
  560. return
  561. }
  562. return *v, true
  563. }
  564. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  565. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  566. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  567. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  568. if !m.op.Is(OpUpdateOne) {
  569. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  570. }
  571. if m.id == nil || m.oldValue == nil {
  572. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  573. }
  574. oldValue, err := m.oldValue(ctx)
  575. if err != nil {
  576. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  577. }
  578. return oldValue.OrganizationID, nil
  579. }
  580. // AddOrganizationID adds u to the "organization_id" field.
  581. func (m *AgentMutation) AddOrganizationID(u int64) {
  582. if m.addorganization_id != nil {
  583. *m.addorganization_id += u
  584. } else {
  585. m.addorganization_id = &u
  586. }
  587. }
  588. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  589. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  590. v := m.addorganization_id
  591. if v == nil {
  592. return
  593. }
  594. return *v, true
  595. }
  596. // ResetOrganizationID resets all changes to the "organization_id" field.
  597. func (m *AgentMutation) ResetOrganizationID() {
  598. m.organization_id = nil
  599. m.addorganization_id = nil
  600. }
  601. // SetDatasetID sets the "dataset_id" field.
  602. func (m *AgentMutation) SetDatasetID(s string) {
  603. m.dataset_id = &s
  604. }
  605. // DatasetID returns the value of the "dataset_id" field in the mutation.
  606. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  607. v := m.dataset_id
  608. if v == nil {
  609. return
  610. }
  611. return *v, true
  612. }
  613. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  614. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  615. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  616. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  617. if !m.op.Is(OpUpdateOne) {
  618. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  619. }
  620. if m.id == nil || m.oldValue == nil {
  621. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  622. }
  623. oldValue, err := m.oldValue(ctx)
  624. if err != nil {
  625. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  626. }
  627. return oldValue.DatasetID, nil
  628. }
  629. // ResetDatasetID resets all changes to the "dataset_id" field.
  630. func (m *AgentMutation) ResetDatasetID() {
  631. m.dataset_id = nil
  632. }
  633. // SetCollectionID sets the "collection_id" field.
  634. func (m *AgentMutation) SetCollectionID(s string) {
  635. m.collection_id = &s
  636. }
  637. // CollectionID returns the value of the "collection_id" field in the mutation.
  638. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  639. v := m.collection_id
  640. if v == nil {
  641. return
  642. }
  643. return *v, true
  644. }
  645. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  646. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  647. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  648. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  649. if !m.op.Is(OpUpdateOne) {
  650. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  651. }
  652. if m.id == nil || m.oldValue == nil {
  653. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  654. }
  655. oldValue, err := m.oldValue(ctx)
  656. if err != nil {
  657. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  658. }
  659. return oldValue.CollectionID, nil
  660. }
  661. // ResetCollectionID resets all changes to the "collection_id" field.
  662. func (m *AgentMutation) ResetCollectionID() {
  663. m.collection_id = nil
  664. }
  665. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  666. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  667. if m.wx_agent == nil {
  668. m.wx_agent = make(map[uint64]struct{})
  669. }
  670. for i := range ids {
  671. m.wx_agent[ids[i]] = struct{}{}
  672. }
  673. }
  674. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  675. func (m *AgentMutation) ClearWxAgent() {
  676. m.clearedwx_agent = true
  677. }
  678. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  679. func (m *AgentMutation) WxAgentCleared() bool {
  680. return m.clearedwx_agent
  681. }
  682. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  683. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  684. if m.removedwx_agent == nil {
  685. m.removedwx_agent = make(map[uint64]struct{})
  686. }
  687. for i := range ids {
  688. delete(m.wx_agent, ids[i])
  689. m.removedwx_agent[ids[i]] = struct{}{}
  690. }
  691. }
  692. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  693. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  694. for id := range m.removedwx_agent {
  695. ids = append(ids, id)
  696. }
  697. return
  698. }
  699. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  700. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  701. for id := range m.wx_agent {
  702. ids = append(ids, id)
  703. }
  704. return
  705. }
  706. // ResetWxAgent resets all changes to the "wx_agent" edge.
  707. func (m *AgentMutation) ResetWxAgent() {
  708. m.wx_agent = nil
  709. m.clearedwx_agent = false
  710. m.removedwx_agent = nil
  711. }
  712. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  713. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  714. if m.token_agent == nil {
  715. m.token_agent = make(map[uint64]struct{})
  716. }
  717. for i := range ids {
  718. m.token_agent[ids[i]] = struct{}{}
  719. }
  720. }
  721. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  722. func (m *AgentMutation) ClearTokenAgent() {
  723. m.clearedtoken_agent = true
  724. }
  725. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  726. func (m *AgentMutation) TokenAgentCleared() bool {
  727. return m.clearedtoken_agent
  728. }
  729. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  730. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  731. if m.removedtoken_agent == nil {
  732. m.removedtoken_agent = make(map[uint64]struct{})
  733. }
  734. for i := range ids {
  735. delete(m.token_agent, ids[i])
  736. m.removedtoken_agent[ids[i]] = struct{}{}
  737. }
  738. }
  739. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  740. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  741. for id := range m.removedtoken_agent {
  742. ids = append(ids, id)
  743. }
  744. return
  745. }
  746. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  747. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  748. for id := range m.token_agent {
  749. ids = append(ids, id)
  750. }
  751. return
  752. }
  753. // ResetTokenAgent resets all changes to the "token_agent" edge.
  754. func (m *AgentMutation) ResetTokenAgent() {
  755. m.token_agent = nil
  756. m.clearedtoken_agent = false
  757. m.removedtoken_agent = nil
  758. }
  759. // AddWaAgentIDs adds the "wa_agent" edge to the Whatsapp entity by ids.
  760. func (m *AgentMutation) AddWaAgentIDs(ids ...uint64) {
  761. if m.wa_agent == nil {
  762. m.wa_agent = make(map[uint64]struct{})
  763. }
  764. for i := range ids {
  765. m.wa_agent[ids[i]] = struct{}{}
  766. }
  767. }
  768. // ClearWaAgent clears the "wa_agent" edge to the Whatsapp entity.
  769. func (m *AgentMutation) ClearWaAgent() {
  770. m.clearedwa_agent = true
  771. }
  772. // WaAgentCleared reports if the "wa_agent" edge to the Whatsapp entity was cleared.
  773. func (m *AgentMutation) WaAgentCleared() bool {
  774. return m.clearedwa_agent
  775. }
  776. // RemoveWaAgentIDs removes the "wa_agent" edge to the Whatsapp entity by IDs.
  777. func (m *AgentMutation) RemoveWaAgentIDs(ids ...uint64) {
  778. if m.removedwa_agent == nil {
  779. m.removedwa_agent = make(map[uint64]struct{})
  780. }
  781. for i := range ids {
  782. delete(m.wa_agent, ids[i])
  783. m.removedwa_agent[ids[i]] = struct{}{}
  784. }
  785. }
  786. // RemovedWaAgent returns the removed IDs of the "wa_agent" edge to the Whatsapp entity.
  787. func (m *AgentMutation) RemovedWaAgentIDs() (ids []uint64) {
  788. for id := range m.removedwa_agent {
  789. ids = append(ids, id)
  790. }
  791. return
  792. }
  793. // WaAgentIDs returns the "wa_agent" edge IDs in the mutation.
  794. func (m *AgentMutation) WaAgentIDs() (ids []uint64) {
  795. for id := range m.wa_agent {
  796. ids = append(ids, id)
  797. }
  798. return
  799. }
  800. // ResetWaAgent resets all changes to the "wa_agent" edge.
  801. func (m *AgentMutation) ResetWaAgent() {
  802. m.wa_agent = nil
  803. m.clearedwa_agent = false
  804. m.removedwa_agent = nil
  805. }
  806. // Where appends a list predicates to the AgentMutation builder.
  807. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  808. m.predicates = append(m.predicates, ps...)
  809. }
  810. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  811. // users can use type-assertion to append predicates that do not depend on any generated package.
  812. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  813. p := make([]predicate.Agent, len(ps))
  814. for i := range ps {
  815. p[i] = ps[i]
  816. }
  817. m.Where(p...)
  818. }
  819. // Op returns the operation name.
  820. func (m *AgentMutation) Op() Op {
  821. return m.op
  822. }
  823. // SetOp allows setting the mutation operation.
  824. func (m *AgentMutation) SetOp(op Op) {
  825. m.op = op
  826. }
  827. // Type returns the node type of this mutation (Agent).
  828. func (m *AgentMutation) Type() string {
  829. return m.typ
  830. }
  831. // Fields returns all fields that were changed during this mutation. Note that in
  832. // order to get all numeric fields that were incremented/decremented, call
  833. // AddedFields().
  834. func (m *AgentMutation) Fields() []string {
  835. fields := make([]string, 0, 11)
  836. if m.created_at != nil {
  837. fields = append(fields, agent.FieldCreatedAt)
  838. }
  839. if m.updated_at != nil {
  840. fields = append(fields, agent.FieldUpdatedAt)
  841. }
  842. if m.deleted_at != nil {
  843. fields = append(fields, agent.FieldDeletedAt)
  844. }
  845. if m.name != nil {
  846. fields = append(fields, agent.FieldName)
  847. }
  848. if m.role != nil {
  849. fields = append(fields, agent.FieldRole)
  850. }
  851. if m.status != nil {
  852. fields = append(fields, agent.FieldStatus)
  853. }
  854. if m.background != nil {
  855. fields = append(fields, agent.FieldBackground)
  856. }
  857. if m.examples != nil {
  858. fields = append(fields, agent.FieldExamples)
  859. }
  860. if m.organization_id != nil {
  861. fields = append(fields, agent.FieldOrganizationID)
  862. }
  863. if m.dataset_id != nil {
  864. fields = append(fields, agent.FieldDatasetID)
  865. }
  866. if m.collection_id != nil {
  867. fields = append(fields, agent.FieldCollectionID)
  868. }
  869. return fields
  870. }
  871. // Field returns the value of a field with the given name. The second boolean
  872. // return value indicates that this field was not set, or was not defined in the
  873. // schema.
  874. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  875. switch name {
  876. case agent.FieldCreatedAt:
  877. return m.CreatedAt()
  878. case agent.FieldUpdatedAt:
  879. return m.UpdatedAt()
  880. case agent.FieldDeletedAt:
  881. return m.DeletedAt()
  882. case agent.FieldName:
  883. return m.Name()
  884. case agent.FieldRole:
  885. return m.Role()
  886. case agent.FieldStatus:
  887. return m.Status()
  888. case agent.FieldBackground:
  889. return m.Background()
  890. case agent.FieldExamples:
  891. return m.Examples()
  892. case agent.FieldOrganizationID:
  893. return m.OrganizationID()
  894. case agent.FieldDatasetID:
  895. return m.DatasetID()
  896. case agent.FieldCollectionID:
  897. return m.CollectionID()
  898. }
  899. return nil, false
  900. }
  901. // OldField returns the old value of the field from the database. An error is
  902. // returned if the mutation operation is not UpdateOne, or the query to the
  903. // database failed.
  904. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  905. switch name {
  906. case agent.FieldCreatedAt:
  907. return m.OldCreatedAt(ctx)
  908. case agent.FieldUpdatedAt:
  909. return m.OldUpdatedAt(ctx)
  910. case agent.FieldDeletedAt:
  911. return m.OldDeletedAt(ctx)
  912. case agent.FieldName:
  913. return m.OldName(ctx)
  914. case agent.FieldRole:
  915. return m.OldRole(ctx)
  916. case agent.FieldStatus:
  917. return m.OldStatus(ctx)
  918. case agent.FieldBackground:
  919. return m.OldBackground(ctx)
  920. case agent.FieldExamples:
  921. return m.OldExamples(ctx)
  922. case agent.FieldOrganizationID:
  923. return m.OldOrganizationID(ctx)
  924. case agent.FieldDatasetID:
  925. return m.OldDatasetID(ctx)
  926. case agent.FieldCollectionID:
  927. return m.OldCollectionID(ctx)
  928. }
  929. return nil, fmt.Errorf("unknown Agent field %s", name)
  930. }
  931. // SetField sets the value of a field with the given name. It returns an error if
  932. // the field is not defined in the schema, or if the type mismatched the field
  933. // type.
  934. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  935. switch name {
  936. case agent.FieldCreatedAt:
  937. v, ok := value.(time.Time)
  938. if !ok {
  939. return fmt.Errorf("unexpected type %T for field %s", value, name)
  940. }
  941. m.SetCreatedAt(v)
  942. return nil
  943. case agent.FieldUpdatedAt:
  944. v, ok := value.(time.Time)
  945. if !ok {
  946. return fmt.Errorf("unexpected type %T for field %s", value, name)
  947. }
  948. m.SetUpdatedAt(v)
  949. return nil
  950. case agent.FieldDeletedAt:
  951. v, ok := value.(time.Time)
  952. if !ok {
  953. return fmt.Errorf("unexpected type %T for field %s", value, name)
  954. }
  955. m.SetDeletedAt(v)
  956. return nil
  957. case agent.FieldName:
  958. v, ok := value.(string)
  959. if !ok {
  960. return fmt.Errorf("unexpected type %T for field %s", value, name)
  961. }
  962. m.SetName(v)
  963. return nil
  964. case agent.FieldRole:
  965. v, ok := value.(string)
  966. if !ok {
  967. return fmt.Errorf("unexpected type %T for field %s", value, name)
  968. }
  969. m.SetRole(v)
  970. return nil
  971. case agent.FieldStatus:
  972. v, ok := value.(int)
  973. if !ok {
  974. return fmt.Errorf("unexpected type %T for field %s", value, name)
  975. }
  976. m.SetStatus(v)
  977. return nil
  978. case agent.FieldBackground:
  979. v, ok := value.(string)
  980. if !ok {
  981. return fmt.Errorf("unexpected type %T for field %s", value, name)
  982. }
  983. m.SetBackground(v)
  984. return nil
  985. case agent.FieldExamples:
  986. v, ok := value.(string)
  987. if !ok {
  988. return fmt.Errorf("unexpected type %T for field %s", value, name)
  989. }
  990. m.SetExamples(v)
  991. return nil
  992. case agent.FieldOrganizationID:
  993. v, ok := value.(uint64)
  994. if !ok {
  995. return fmt.Errorf("unexpected type %T for field %s", value, name)
  996. }
  997. m.SetOrganizationID(v)
  998. return nil
  999. case agent.FieldDatasetID:
  1000. v, ok := value.(string)
  1001. if !ok {
  1002. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1003. }
  1004. m.SetDatasetID(v)
  1005. return nil
  1006. case agent.FieldCollectionID:
  1007. v, ok := value.(string)
  1008. if !ok {
  1009. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1010. }
  1011. m.SetCollectionID(v)
  1012. return nil
  1013. }
  1014. return fmt.Errorf("unknown Agent field %s", name)
  1015. }
  1016. // AddedFields returns all numeric fields that were incremented/decremented during
  1017. // this mutation.
  1018. func (m *AgentMutation) AddedFields() []string {
  1019. var fields []string
  1020. if m.addstatus != nil {
  1021. fields = append(fields, agent.FieldStatus)
  1022. }
  1023. if m.addorganization_id != nil {
  1024. fields = append(fields, agent.FieldOrganizationID)
  1025. }
  1026. return fields
  1027. }
  1028. // AddedField returns the numeric value that was incremented/decremented on a field
  1029. // with the given name. The second boolean return value indicates that this field
  1030. // was not set, or was not defined in the schema.
  1031. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  1032. switch name {
  1033. case agent.FieldStatus:
  1034. return m.AddedStatus()
  1035. case agent.FieldOrganizationID:
  1036. return m.AddedOrganizationID()
  1037. }
  1038. return nil, false
  1039. }
  1040. // AddField adds the value to the field with the given name. It returns an error if
  1041. // the field is not defined in the schema, or if the type mismatched the field
  1042. // type.
  1043. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  1044. switch name {
  1045. case agent.FieldStatus:
  1046. v, ok := value.(int)
  1047. if !ok {
  1048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1049. }
  1050. m.AddStatus(v)
  1051. return nil
  1052. case agent.FieldOrganizationID:
  1053. v, ok := value.(int64)
  1054. if !ok {
  1055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1056. }
  1057. m.AddOrganizationID(v)
  1058. return nil
  1059. }
  1060. return fmt.Errorf("unknown Agent numeric field %s", name)
  1061. }
  1062. // ClearedFields returns all nullable fields that were cleared during this
  1063. // mutation.
  1064. func (m *AgentMutation) ClearedFields() []string {
  1065. var fields []string
  1066. if m.FieldCleared(agent.FieldDeletedAt) {
  1067. fields = append(fields, agent.FieldDeletedAt)
  1068. }
  1069. if m.FieldCleared(agent.FieldStatus) {
  1070. fields = append(fields, agent.FieldStatus)
  1071. }
  1072. if m.FieldCleared(agent.FieldBackground) {
  1073. fields = append(fields, agent.FieldBackground)
  1074. }
  1075. if m.FieldCleared(agent.FieldExamples) {
  1076. fields = append(fields, agent.FieldExamples)
  1077. }
  1078. return fields
  1079. }
  1080. // FieldCleared returns a boolean indicating if a field with the given name was
  1081. // cleared in this mutation.
  1082. func (m *AgentMutation) FieldCleared(name string) bool {
  1083. _, ok := m.clearedFields[name]
  1084. return ok
  1085. }
  1086. // ClearField clears the value of the field with the given name. It returns an
  1087. // error if the field is not defined in the schema.
  1088. func (m *AgentMutation) ClearField(name string) error {
  1089. switch name {
  1090. case agent.FieldDeletedAt:
  1091. m.ClearDeletedAt()
  1092. return nil
  1093. case agent.FieldStatus:
  1094. m.ClearStatus()
  1095. return nil
  1096. case agent.FieldBackground:
  1097. m.ClearBackground()
  1098. return nil
  1099. case agent.FieldExamples:
  1100. m.ClearExamples()
  1101. return nil
  1102. }
  1103. return fmt.Errorf("unknown Agent nullable field %s", name)
  1104. }
  1105. // ResetField resets all changes in the mutation for the field with the given name.
  1106. // It returns an error if the field is not defined in the schema.
  1107. func (m *AgentMutation) ResetField(name string) error {
  1108. switch name {
  1109. case agent.FieldCreatedAt:
  1110. m.ResetCreatedAt()
  1111. return nil
  1112. case agent.FieldUpdatedAt:
  1113. m.ResetUpdatedAt()
  1114. return nil
  1115. case agent.FieldDeletedAt:
  1116. m.ResetDeletedAt()
  1117. return nil
  1118. case agent.FieldName:
  1119. m.ResetName()
  1120. return nil
  1121. case agent.FieldRole:
  1122. m.ResetRole()
  1123. return nil
  1124. case agent.FieldStatus:
  1125. m.ResetStatus()
  1126. return nil
  1127. case agent.FieldBackground:
  1128. m.ResetBackground()
  1129. return nil
  1130. case agent.FieldExamples:
  1131. m.ResetExamples()
  1132. return nil
  1133. case agent.FieldOrganizationID:
  1134. m.ResetOrganizationID()
  1135. return nil
  1136. case agent.FieldDatasetID:
  1137. m.ResetDatasetID()
  1138. return nil
  1139. case agent.FieldCollectionID:
  1140. m.ResetCollectionID()
  1141. return nil
  1142. }
  1143. return fmt.Errorf("unknown Agent field %s", name)
  1144. }
  1145. // AddedEdges returns all edge names that were set/added in this mutation.
  1146. func (m *AgentMutation) AddedEdges() []string {
  1147. edges := make([]string, 0, 3)
  1148. if m.wx_agent != nil {
  1149. edges = append(edges, agent.EdgeWxAgent)
  1150. }
  1151. if m.token_agent != nil {
  1152. edges = append(edges, agent.EdgeTokenAgent)
  1153. }
  1154. if m.wa_agent != nil {
  1155. edges = append(edges, agent.EdgeWaAgent)
  1156. }
  1157. return edges
  1158. }
  1159. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1160. // name in this mutation.
  1161. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1162. switch name {
  1163. case agent.EdgeWxAgent:
  1164. ids := make([]ent.Value, 0, len(m.wx_agent))
  1165. for id := range m.wx_agent {
  1166. ids = append(ids, id)
  1167. }
  1168. return ids
  1169. case agent.EdgeTokenAgent:
  1170. ids := make([]ent.Value, 0, len(m.token_agent))
  1171. for id := range m.token_agent {
  1172. ids = append(ids, id)
  1173. }
  1174. return ids
  1175. case agent.EdgeWaAgent:
  1176. ids := make([]ent.Value, 0, len(m.wa_agent))
  1177. for id := range m.wa_agent {
  1178. ids = append(ids, id)
  1179. }
  1180. return ids
  1181. }
  1182. return nil
  1183. }
  1184. // RemovedEdges returns all edge names that were removed in this mutation.
  1185. func (m *AgentMutation) RemovedEdges() []string {
  1186. edges := make([]string, 0, 3)
  1187. if m.removedwx_agent != nil {
  1188. edges = append(edges, agent.EdgeWxAgent)
  1189. }
  1190. if m.removedtoken_agent != nil {
  1191. edges = append(edges, agent.EdgeTokenAgent)
  1192. }
  1193. if m.removedwa_agent != nil {
  1194. edges = append(edges, agent.EdgeWaAgent)
  1195. }
  1196. return edges
  1197. }
  1198. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1199. // the given name in this mutation.
  1200. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1201. switch name {
  1202. case agent.EdgeWxAgent:
  1203. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1204. for id := range m.removedwx_agent {
  1205. ids = append(ids, id)
  1206. }
  1207. return ids
  1208. case agent.EdgeTokenAgent:
  1209. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1210. for id := range m.removedtoken_agent {
  1211. ids = append(ids, id)
  1212. }
  1213. return ids
  1214. case agent.EdgeWaAgent:
  1215. ids := make([]ent.Value, 0, len(m.removedwa_agent))
  1216. for id := range m.removedwa_agent {
  1217. ids = append(ids, id)
  1218. }
  1219. return ids
  1220. }
  1221. return nil
  1222. }
  1223. // ClearedEdges returns all edge names that were cleared in this mutation.
  1224. func (m *AgentMutation) ClearedEdges() []string {
  1225. edges := make([]string, 0, 3)
  1226. if m.clearedwx_agent {
  1227. edges = append(edges, agent.EdgeWxAgent)
  1228. }
  1229. if m.clearedtoken_agent {
  1230. edges = append(edges, agent.EdgeTokenAgent)
  1231. }
  1232. if m.clearedwa_agent {
  1233. edges = append(edges, agent.EdgeWaAgent)
  1234. }
  1235. return edges
  1236. }
  1237. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1238. // was cleared in this mutation.
  1239. func (m *AgentMutation) EdgeCleared(name string) bool {
  1240. switch name {
  1241. case agent.EdgeWxAgent:
  1242. return m.clearedwx_agent
  1243. case agent.EdgeTokenAgent:
  1244. return m.clearedtoken_agent
  1245. case agent.EdgeWaAgent:
  1246. return m.clearedwa_agent
  1247. }
  1248. return false
  1249. }
  1250. // ClearEdge clears the value of the edge with the given name. It returns an error
  1251. // if that edge is not defined in the schema.
  1252. func (m *AgentMutation) ClearEdge(name string) error {
  1253. switch name {
  1254. }
  1255. return fmt.Errorf("unknown Agent unique edge %s", name)
  1256. }
  1257. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1258. // It returns an error if the edge is not defined in the schema.
  1259. func (m *AgentMutation) ResetEdge(name string) error {
  1260. switch name {
  1261. case agent.EdgeWxAgent:
  1262. m.ResetWxAgent()
  1263. return nil
  1264. case agent.EdgeTokenAgent:
  1265. m.ResetTokenAgent()
  1266. return nil
  1267. case agent.EdgeWaAgent:
  1268. m.ResetWaAgent()
  1269. return nil
  1270. }
  1271. return fmt.Errorf("unknown Agent edge %s", name)
  1272. }
  1273. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1274. type AgentBaseMutation struct {
  1275. config
  1276. op Op
  1277. typ string
  1278. id *string
  1279. q *string
  1280. a *string
  1281. chunk_index *uint64
  1282. addchunk_index *int64
  1283. indexes *[]string
  1284. appendindexes []string
  1285. dataset_id *string
  1286. collection_id *string
  1287. source_name *string
  1288. can_write *[]bool
  1289. appendcan_write []bool
  1290. is_owner *[]bool
  1291. appendis_owner []bool
  1292. clearedFields map[string]struct{}
  1293. wx_agent map[uint64]struct{}
  1294. removedwx_agent map[uint64]struct{}
  1295. clearedwx_agent bool
  1296. done bool
  1297. oldValue func(context.Context) (*AgentBase, error)
  1298. predicates []predicate.AgentBase
  1299. }
  1300. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1301. // agentbaseOption allows management of the mutation configuration using functional options.
  1302. type agentbaseOption func(*AgentBaseMutation)
  1303. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1304. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1305. m := &AgentBaseMutation{
  1306. config: c,
  1307. op: op,
  1308. typ: TypeAgentBase,
  1309. clearedFields: make(map[string]struct{}),
  1310. }
  1311. for _, opt := range opts {
  1312. opt(m)
  1313. }
  1314. return m
  1315. }
  1316. // withAgentBaseID sets the ID field of the mutation.
  1317. func withAgentBaseID(id string) agentbaseOption {
  1318. return func(m *AgentBaseMutation) {
  1319. var (
  1320. err error
  1321. once sync.Once
  1322. value *AgentBase
  1323. )
  1324. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1325. once.Do(func() {
  1326. if m.done {
  1327. err = errors.New("querying old values post mutation is not allowed")
  1328. } else {
  1329. value, err = m.Client().AgentBase.Get(ctx, id)
  1330. }
  1331. })
  1332. return value, err
  1333. }
  1334. m.id = &id
  1335. }
  1336. }
  1337. // withAgentBase sets the old AgentBase of the mutation.
  1338. func withAgentBase(node *AgentBase) agentbaseOption {
  1339. return func(m *AgentBaseMutation) {
  1340. m.oldValue = func(context.Context) (*AgentBase, error) {
  1341. return node, nil
  1342. }
  1343. m.id = &node.ID
  1344. }
  1345. }
  1346. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1347. // executed in a transaction (ent.Tx), a transactional client is returned.
  1348. func (m AgentBaseMutation) Client() *Client {
  1349. client := &Client{config: m.config}
  1350. client.init()
  1351. return client
  1352. }
  1353. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1354. // it returns an error otherwise.
  1355. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1356. if _, ok := m.driver.(*txDriver); !ok {
  1357. return nil, errors.New("ent: mutation is not running in a transaction")
  1358. }
  1359. tx := &Tx{config: m.config}
  1360. tx.init()
  1361. return tx, nil
  1362. }
  1363. // SetID sets the value of the id field. Note that this
  1364. // operation is only accepted on creation of AgentBase entities.
  1365. func (m *AgentBaseMutation) SetID(id string) {
  1366. m.id = &id
  1367. }
  1368. // ID returns the ID value in the mutation. Note that the ID is only available
  1369. // if it was provided to the builder or after it was returned from the database.
  1370. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1371. if m.id == nil {
  1372. return
  1373. }
  1374. return *m.id, true
  1375. }
  1376. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1377. // That means, if the mutation is applied within a transaction with an isolation level such
  1378. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1379. // or updated by the mutation.
  1380. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1381. switch {
  1382. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1383. id, exists := m.ID()
  1384. if exists {
  1385. return []string{id}, nil
  1386. }
  1387. fallthrough
  1388. case m.op.Is(OpUpdate | OpDelete):
  1389. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1390. default:
  1391. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1392. }
  1393. }
  1394. // SetQ sets the "q" field.
  1395. func (m *AgentBaseMutation) SetQ(s string) {
  1396. m.q = &s
  1397. }
  1398. // Q returns the value of the "q" field in the mutation.
  1399. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1400. v := m.q
  1401. if v == nil {
  1402. return
  1403. }
  1404. return *v, true
  1405. }
  1406. // OldQ returns the old "q" field's value of the AgentBase entity.
  1407. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1408. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1409. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1410. if !m.op.Is(OpUpdateOne) {
  1411. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1412. }
  1413. if m.id == nil || m.oldValue == nil {
  1414. return v, errors.New("OldQ requires an ID field in the mutation")
  1415. }
  1416. oldValue, err := m.oldValue(ctx)
  1417. if err != nil {
  1418. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1419. }
  1420. return oldValue.Q, nil
  1421. }
  1422. // ClearQ clears the value of the "q" field.
  1423. func (m *AgentBaseMutation) ClearQ() {
  1424. m.q = nil
  1425. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1426. }
  1427. // QCleared returns if the "q" field was cleared in this mutation.
  1428. func (m *AgentBaseMutation) QCleared() bool {
  1429. _, ok := m.clearedFields[agentbase.FieldQ]
  1430. return ok
  1431. }
  1432. // ResetQ resets all changes to the "q" field.
  1433. func (m *AgentBaseMutation) ResetQ() {
  1434. m.q = nil
  1435. delete(m.clearedFields, agentbase.FieldQ)
  1436. }
  1437. // SetA sets the "a" field.
  1438. func (m *AgentBaseMutation) SetA(s string) {
  1439. m.a = &s
  1440. }
  1441. // A returns the value of the "a" field in the mutation.
  1442. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1443. v := m.a
  1444. if v == nil {
  1445. return
  1446. }
  1447. return *v, true
  1448. }
  1449. // OldA returns the old "a" field's value of the AgentBase entity.
  1450. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1451. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1452. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1453. if !m.op.Is(OpUpdateOne) {
  1454. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1455. }
  1456. if m.id == nil || m.oldValue == nil {
  1457. return v, errors.New("OldA requires an ID field in the mutation")
  1458. }
  1459. oldValue, err := m.oldValue(ctx)
  1460. if err != nil {
  1461. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1462. }
  1463. return oldValue.A, nil
  1464. }
  1465. // ClearA clears the value of the "a" field.
  1466. func (m *AgentBaseMutation) ClearA() {
  1467. m.a = nil
  1468. m.clearedFields[agentbase.FieldA] = struct{}{}
  1469. }
  1470. // ACleared returns if the "a" field was cleared in this mutation.
  1471. func (m *AgentBaseMutation) ACleared() bool {
  1472. _, ok := m.clearedFields[agentbase.FieldA]
  1473. return ok
  1474. }
  1475. // ResetA resets all changes to the "a" field.
  1476. func (m *AgentBaseMutation) ResetA() {
  1477. m.a = nil
  1478. delete(m.clearedFields, agentbase.FieldA)
  1479. }
  1480. // SetChunkIndex sets the "chunk_index" field.
  1481. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1482. m.chunk_index = &u
  1483. m.addchunk_index = nil
  1484. }
  1485. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1486. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1487. v := m.chunk_index
  1488. if v == nil {
  1489. return
  1490. }
  1491. return *v, true
  1492. }
  1493. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1494. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1495. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1496. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1497. if !m.op.Is(OpUpdateOne) {
  1498. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1499. }
  1500. if m.id == nil || m.oldValue == nil {
  1501. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1502. }
  1503. oldValue, err := m.oldValue(ctx)
  1504. if err != nil {
  1505. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1506. }
  1507. return oldValue.ChunkIndex, nil
  1508. }
  1509. // AddChunkIndex adds u to the "chunk_index" field.
  1510. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1511. if m.addchunk_index != nil {
  1512. *m.addchunk_index += u
  1513. } else {
  1514. m.addchunk_index = &u
  1515. }
  1516. }
  1517. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1518. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1519. v := m.addchunk_index
  1520. if v == nil {
  1521. return
  1522. }
  1523. return *v, true
  1524. }
  1525. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1526. func (m *AgentBaseMutation) ResetChunkIndex() {
  1527. m.chunk_index = nil
  1528. m.addchunk_index = nil
  1529. }
  1530. // SetIndexes sets the "indexes" field.
  1531. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1532. m.indexes = &s
  1533. m.appendindexes = nil
  1534. }
  1535. // Indexes returns the value of the "indexes" field in the mutation.
  1536. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1537. v := m.indexes
  1538. if v == nil {
  1539. return
  1540. }
  1541. return *v, true
  1542. }
  1543. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1544. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1545. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1546. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1547. if !m.op.Is(OpUpdateOne) {
  1548. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1549. }
  1550. if m.id == nil || m.oldValue == nil {
  1551. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1552. }
  1553. oldValue, err := m.oldValue(ctx)
  1554. if err != nil {
  1555. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1556. }
  1557. return oldValue.Indexes, nil
  1558. }
  1559. // AppendIndexes adds s to the "indexes" field.
  1560. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1561. m.appendindexes = append(m.appendindexes, s...)
  1562. }
  1563. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1564. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1565. if len(m.appendindexes) == 0 {
  1566. return nil, false
  1567. }
  1568. return m.appendindexes, true
  1569. }
  1570. // ClearIndexes clears the value of the "indexes" field.
  1571. func (m *AgentBaseMutation) ClearIndexes() {
  1572. m.indexes = nil
  1573. m.appendindexes = nil
  1574. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1575. }
  1576. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1577. func (m *AgentBaseMutation) IndexesCleared() bool {
  1578. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1579. return ok
  1580. }
  1581. // ResetIndexes resets all changes to the "indexes" field.
  1582. func (m *AgentBaseMutation) ResetIndexes() {
  1583. m.indexes = nil
  1584. m.appendindexes = nil
  1585. delete(m.clearedFields, agentbase.FieldIndexes)
  1586. }
  1587. // SetDatasetID sets the "dataset_id" field.
  1588. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1589. m.dataset_id = &s
  1590. }
  1591. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1592. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1593. v := m.dataset_id
  1594. if v == nil {
  1595. return
  1596. }
  1597. return *v, true
  1598. }
  1599. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1600. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1601. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1602. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1603. if !m.op.Is(OpUpdateOne) {
  1604. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1605. }
  1606. if m.id == nil || m.oldValue == nil {
  1607. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1608. }
  1609. oldValue, err := m.oldValue(ctx)
  1610. if err != nil {
  1611. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1612. }
  1613. return oldValue.DatasetID, nil
  1614. }
  1615. // ClearDatasetID clears the value of the "dataset_id" field.
  1616. func (m *AgentBaseMutation) ClearDatasetID() {
  1617. m.dataset_id = nil
  1618. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  1619. }
  1620. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  1621. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  1622. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  1623. return ok
  1624. }
  1625. // ResetDatasetID resets all changes to the "dataset_id" field.
  1626. func (m *AgentBaseMutation) ResetDatasetID() {
  1627. m.dataset_id = nil
  1628. delete(m.clearedFields, agentbase.FieldDatasetID)
  1629. }
  1630. // SetCollectionID sets the "collection_id" field.
  1631. func (m *AgentBaseMutation) SetCollectionID(s string) {
  1632. m.collection_id = &s
  1633. }
  1634. // CollectionID returns the value of the "collection_id" field in the mutation.
  1635. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  1636. v := m.collection_id
  1637. if v == nil {
  1638. return
  1639. }
  1640. return *v, true
  1641. }
  1642. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  1643. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1644. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1645. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1646. if !m.op.Is(OpUpdateOne) {
  1647. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1648. }
  1649. if m.id == nil || m.oldValue == nil {
  1650. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1651. }
  1652. oldValue, err := m.oldValue(ctx)
  1653. if err != nil {
  1654. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1655. }
  1656. return oldValue.CollectionID, nil
  1657. }
  1658. // ClearCollectionID clears the value of the "collection_id" field.
  1659. func (m *AgentBaseMutation) ClearCollectionID() {
  1660. m.collection_id = nil
  1661. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  1662. }
  1663. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  1664. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  1665. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  1666. return ok
  1667. }
  1668. // ResetCollectionID resets all changes to the "collection_id" field.
  1669. func (m *AgentBaseMutation) ResetCollectionID() {
  1670. m.collection_id = nil
  1671. delete(m.clearedFields, agentbase.FieldCollectionID)
  1672. }
  1673. // SetSourceName sets the "source_name" field.
  1674. func (m *AgentBaseMutation) SetSourceName(s string) {
  1675. m.source_name = &s
  1676. }
  1677. // SourceName returns the value of the "source_name" field in the mutation.
  1678. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  1679. v := m.source_name
  1680. if v == nil {
  1681. return
  1682. }
  1683. return *v, true
  1684. }
  1685. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  1686. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1687. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1688. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  1689. if !m.op.Is(OpUpdateOne) {
  1690. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  1691. }
  1692. if m.id == nil || m.oldValue == nil {
  1693. return v, errors.New("OldSourceName requires an ID field in the mutation")
  1694. }
  1695. oldValue, err := m.oldValue(ctx)
  1696. if err != nil {
  1697. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  1698. }
  1699. return oldValue.SourceName, nil
  1700. }
  1701. // ClearSourceName clears the value of the "source_name" field.
  1702. func (m *AgentBaseMutation) ClearSourceName() {
  1703. m.source_name = nil
  1704. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  1705. }
  1706. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  1707. func (m *AgentBaseMutation) SourceNameCleared() bool {
  1708. _, ok := m.clearedFields[agentbase.FieldSourceName]
  1709. return ok
  1710. }
  1711. // ResetSourceName resets all changes to the "source_name" field.
  1712. func (m *AgentBaseMutation) ResetSourceName() {
  1713. m.source_name = nil
  1714. delete(m.clearedFields, agentbase.FieldSourceName)
  1715. }
  1716. // SetCanWrite sets the "can_write" field.
  1717. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  1718. m.can_write = &b
  1719. m.appendcan_write = nil
  1720. }
  1721. // CanWrite returns the value of the "can_write" field in the mutation.
  1722. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  1723. v := m.can_write
  1724. if v == nil {
  1725. return
  1726. }
  1727. return *v, true
  1728. }
  1729. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  1730. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1731. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1732. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  1733. if !m.op.Is(OpUpdateOne) {
  1734. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  1735. }
  1736. if m.id == nil || m.oldValue == nil {
  1737. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  1738. }
  1739. oldValue, err := m.oldValue(ctx)
  1740. if err != nil {
  1741. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  1742. }
  1743. return oldValue.CanWrite, nil
  1744. }
  1745. // AppendCanWrite adds b to the "can_write" field.
  1746. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  1747. m.appendcan_write = append(m.appendcan_write, b...)
  1748. }
  1749. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  1750. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  1751. if len(m.appendcan_write) == 0 {
  1752. return nil, false
  1753. }
  1754. return m.appendcan_write, true
  1755. }
  1756. // ClearCanWrite clears the value of the "can_write" field.
  1757. func (m *AgentBaseMutation) ClearCanWrite() {
  1758. m.can_write = nil
  1759. m.appendcan_write = nil
  1760. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  1761. }
  1762. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  1763. func (m *AgentBaseMutation) CanWriteCleared() bool {
  1764. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  1765. return ok
  1766. }
  1767. // ResetCanWrite resets all changes to the "can_write" field.
  1768. func (m *AgentBaseMutation) ResetCanWrite() {
  1769. m.can_write = nil
  1770. m.appendcan_write = nil
  1771. delete(m.clearedFields, agentbase.FieldCanWrite)
  1772. }
  1773. // SetIsOwner sets the "is_owner" field.
  1774. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  1775. m.is_owner = &b
  1776. m.appendis_owner = nil
  1777. }
  1778. // IsOwner returns the value of the "is_owner" field in the mutation.
  1779. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  1780. v := m.is_owner
  1781. if v == nil {
  1782. return
  1783. }
  1784. return *v, true
  1785. }
  1786. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  1787. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1788. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1789. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  1790. if !m.op.Is(OpUpdateOne) {
  1791. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  1792. }
  1793. if m.id == nil || m.oldValue == nil {
  1794. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  1795. }
  1796. oldValue, err := m.oldValue(ctx)
  1797. if err != nil {
  1798. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  1799. }
  1800. return oldValue.IsOwner, nil
  1801. }
  1802. // AppendIsOwner adds b to the "is_owner" field.
  1803. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  1804. m.appendis_owner = append(m.appendis_owner, b...)
  1805. }
  1806. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  1807. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  1808. if len(m.appendis_owner) == 0 {
  1809. return nil, false
  1810. }
  1811. return m.appendis_owner, true
  1812. }
  1813. // ClearIsOwner clears the value of the "is_owner" field.
  1814. func (m *AgentBaseMutation) ClearIsOwner() {
  1815. m.is_owner = nil
  1816. m.appendis_owner = nil
  1817. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  1818. }
  1819. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  1820. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  1821. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  1822. return ok
  1823. }
  1824. // ResetIsOwner resets all changes to the "is_owner" field.
  1825. func (m *AgentBaseMutation) ResetIsOwner() {
  1826. m.is_owner = nil
  1827. m.appendis_owner = nil
  1828. delete(m.clearedFields, agentbase.FieldIsOwner)
  1829. }
  1830. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  1831. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  1832. if m.wx_agent == nil {
  1833. m.wx_agent = make(map[uint64]struct{})
  1834. }
  1835. for i := range ids {
  1836. m.wx_agent[ids[i]] = struct{}{}
  1837. }
  1838. }
  1839. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  1840. func (m *AgentBaseMutation) ClearWxAgent() {
  1841. m.clearedwx_agent = true
  1842. }
  1843. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  1844. func (m *AgentBaseMutation) WxAgentCleared() bool {
  1845. return m.clearedwx_agent
  1846. }
  1847. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  1848. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  1849. if m.removedwx_agent == nil {
  1850. m.removedwx_agent = make(map[uint64]struct{})
  1851. }
  1852. for i := range ids {
  1853. delete(m.wx_agent, ids[i])
  1854. m.removedwx_agent[ids[i]] = struct{}{}
  1855. }
  1856. }
  1857. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  1858. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  1859. for id := range m.removedwx_agent {
  1860. ids = append(ids, id)
  1861. }
  1862. return
  1863. }
  1864. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  1865. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  1866. for id := range m.wx_agent {
  1867. ids = append(ids, id)
  1868. }
  1869. return
  1870. }
  1871. // ResetWxAgent resets all changes to the "wx_agent" edge.
  1872. func (m *AgentBaseMutation) ResetWxAgent() {
  1873. m.wx_agent = nil
  1874. m.clearedwx_agent = false
  1875. m.removedwx_agent = nil
  1876. }
  1877. // Where appends a list predicates to the AgentBaseMutation builder.
  1878. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  1879. m.predicates = append(m.predicates, ps...)
  1880. }
  1881. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  1882. // users can use type-assertion to append predicates that do not depend on any generated package.
  1883. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  1884. p := make([]predicate.AgentBase, len(ps))
  1885. for i := range ps {
  1886. p[i] = ps[i]
  1887. }
  1888. m.Where(p...)
  1889. }
  1890. // Op returns the operation name.
  1891. func (m *AgentBaseMutation) Op() Op {
  1892. return m.op
  1893. }
  1894. // SetOp allows setting the mutation operation.
  1895. func (m *AgentBaseMutation) SetOp(op Op) {
  1896. m.op = op
  1897. }
  1898. // Type returns the node type of this mutation (AgentBase).
  1899. func (m *AgentBaseMutation) Type() string {
  1900. return m.typ
  1901. }
  1902. // Fields returns all fields that were changed during this mutation. Note that in
  1903. // order to get all numeric fields that were incremented/decremented, call
  1904. // AddedFields().
  1905. func (m *AgentBaseMutation) Fields() []string {
  1906. fields := make([]string, 0, 9)
  1907. if m.q != nil {
  1908. fields = append(fields, agentbase.FieldQ)
  1909. }
  1910. if m.a != nil {
  1911. fields = append(fields, agentbase.FieldA)
  1912. }
  1913. if m.chunk_index != nil {
  1914. fields = append(fields, agentbase.FieldChunkIndex)
  1915. }
  1916. if m.indexes != nil {
  1917. fields = append(fields, agentbase.FieldIndexes)
  1918. }
  1919. if m.dataset_id != nil {
  1920. fields = append(fields, agentbase.FieldDatasetID)
  1921. }
  1922. if m.collection_id != nil {
  1923. fields = append(fields, agentbase.FieldCollectionID)
  1924. }
  1925. if m.source_name != nil {
  1926. fields = append(fields, agentbase.FieldSourceName)
  1927. }
  1928. if m.can_write != nil {
  1929. fields = append(fields, agentbase.FieldCanWrite)
  1930. }
  1931. if m.is_owner != nil {
  1932. fields = append(fields, agentbase.FieldIsOwner)
  1933. }
  1934. return fields
  1935. }
  1936. // Field returns the value of a field with the given name. The second boolean
  1937. // return value indicates that this field was not set, or was not defined in the
  1938. // schema.
  1939. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  1940. switch name {
  1941. case agentbase.FieldQ:
  1942. return m.Q()
  1943. case agentbase.FieldA:
  1944. return m.A()
  1945. case agentbase.FieldChunkIndex:
  1946. return m.ChunkIndex()
  1947. case agentbase.FieldIndexes:
  1948. return m.Indexes()
  1949. case agentbase.FieldDatasetID:
  1950. return m.DatasetID()
  1951. case agentbase.FieldCollectionID:
  1952. return m.CollectionID()
  1953. case agentbase.FieldSourceName:
  1954. return m.SourceName()
  1955. case agentbase.FieldCanWrite:
  1956. return m.CanWrite()
  1957. case agentbase.FieldIsOwner:
  1958. return m.IsOwner()
  1959. }
  1960. return nil, false
  1961. }
  1962. // OldField returns the old value of the field from the database. An error is
  1963. // returned if the mutation operation is not UpdateOne, or the query to the
  1964. // database failed.
  1965. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1966. switch name {
  1967. case agentbase.FieldQ:
  1968. return m.OldQ(ctx)
  1969. case agentbase.FieldA:
  1970. return m.OldA(ctx)
  1971. case agentbase.FieldChunkIndex:
  1972. return m.OldChunkIndex(ctx)
  1973. case agentbase.FieldIndexes:
  1974. return m.OldIndexes(ctx)
  1975. case agentbase.FieldDatasetID:
  1976. return m.OldDatasetID(ctx)
  1977. case agentbase.FieldCollectionID:
  1978. return m.OldCollectionID(ctx)
  1979. case agentbase.FieldSourceName:
  1980. return m.OldSourceName(ctx)
  1981. case agentbase.FieldCanWrite:
  1982. return m.OldCanWrite(ctx)
  1983. case agentbase.FieldIsOwner:
  1984. return m.OldIsOwner(ctx)
  1985. }
  1986. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  1987. }
  1988. // SetField sets the value of a field with the given name. It returns an error if
  1989. // the field is not defined in the schema, or if the type mismatched the field
  1990. // type.
  1991. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  1992. switch name {
  1993. case agentbase.FieldQ:
  1994. v, ok := value.(string)
  1995. if !ok {
  1996. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1997. }
  1998. m.SetQ(v)
  1999. return nil
  2000. case agentbase.FieldA:
  2001. v, ok := value.(string)
  2002. if !ok {
  2003. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2004. }
  2005. m.SetA(v)
  2006. return nil
  2007. case agentbase.FieldChunkIndex:
  2008. v, ok := value.(uint64)
  2009. if !ok {
  2010. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2011. }
  2012. m.SetChunkIndex(v)
  2013. return nil
  2014. case agentbase.FieldIndexes:
  2015. v, ok := value.([]string)
  2016. if !ok {
  2017. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2018. }
  2019. m.SetIndexes(v)
  2020. return nil
  2021. case agentbase.FieldDatasetID:
  2022. v, ok := value.(string)
  2023. if !ok {
  2024. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2025. }
  2026. m.SetDatasetID(v)
  2027. return nil
  2028. case agentbase.FieldCollectionID:
  2029. v, ok := value.(string)
  2030. if !ok {
  2031. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2032. }
  2033. m.SetCollectionID(v)
  2034. return nil
  2035. case agentbase.FieldSourceName:
  2036. v, ok := value.(string)
  2037. if !ok {
  2038. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2039. }
  2040. m.SetSourceName(v)
  2041. return nil
  2042. case agentbase.FieldCanWrite:
  2043. v, ok := value.([]bool)
  2044. if !ok {
  2045. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2046. }
  2047. m.SetCanWrite(v)
  2048. return nil
  2049. case agentbase.FieldIsOwner:
  2050. v, ok := value.([]bool)
  2051. if !ok {
  2052. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2053. }
  2054. m.SetIsOwner(v)
  2055. return nil
  2056. }
  2057. return fmt.Errorf("unknown AgentBase field %s", name)
  2058. }
  2059. // AddedFields returns all numeric fields that were incremented/decremented during
  2060. // this mutation.
  2061. func (m *AgentBaseMutation) AddedFields() []string {
  2062. var fields []string
  2063. if m.addchunk_index != nil {
  2064. fields = append(fields, agentbase.FieldChunkIndex)
  2065. }
  2066. return fields
  2067. }
  2068. // AddedField returns the numeric value that was incremented/decremented on a field
  2069. // with the given name. The second boolean return value indicates that this field
  2070. // was not set, or was not defined in the schema.
  2071. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  2072. switch name {
  2073. case agentbase.FieldChunkIndex:
  2074. return m.AddedChunkIndex()
  2075. }
  2076. return nil, false
  2077. }
  2078. // AddField adds the value to the field with the given name. It returns an error if
  2079. // the field is not defined in the schema, or if the type mismatched the field
  2080. // type.
  2081. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  2082. switch name {
  2083. case agentbase.FieldChunkIndex:
  2084. v, ok := value.(int64)
  2085. if !ok {
  2086. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2087. }
  2088. m.AddChunkIndex(v)
  2089. return nil
  2090. }
  2091. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  2092. }
  2093. // ClearedFields returns all nullable fields that were cleared during this
  2094. // mutation.
  2095. func (m *AgentBaseMutation) ClearedFields() []string {
  2096. var fields []string
  2097. if m.FieldCleared(agentbase.FieldQ) {
  2098. fields = append(fields, agentbase.FieldQ)
  2099. }
  2100. if m.FieldCleared(agentbase.FieldA) {
  2101. fields = append(fields, agentbase.FieldA)
  2102. }
  2103. if m.FieldCleared(agentbase.FieldIndexes) {
  2104. fields = append(fields, agentbase.FieldIndexes)
  2105. }
  2106. if m.FieldCleared(agentbase.FieldDatasetID) {
  2107. fields = append(fields, agentbase.FieldDatasetID)
  2108. }
  2109. if m.FieldCleared(agentbase.FieldCollectionID) {
  2110. fields = append(fields, agentbase.FieldCollectionID)
  2111. }
  2112. if m.FieldCleared(agentbase.FieldSourceName) {
  2113. fields = append(fields, agentbase.FieldSourceName)
  2114. }
  2115. if m.FieldCleared(agentbase.FieldCanWrite) {
  2116. fields = append(fields, agentbase.FieldCanWrite)
  2117. }
  2118. if m.FieldCleared(agentbase.FieldIsOwner) {
  2119. fields = append(fields, agentbase.FieldIsOwner)
  2120. }
  2121. return fields
  2122. }
  2123. // FieldCleared returns a boolean indicating if a field with the given name was
  2124. // cleared in this mutation.
  2125. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2126. _, ok := m.clearedFields[name]
  2127. return ok
  2128. }
  2129. // ClearField clears the value of the field with the given name. It returns an
  2130. // error if the field is not defined in the schema.
  2131. func (m *AgentBaseMutation) ClearField(name string) error {
  2132. switch name {
  2133. case agentbase.FieldQ:
  2134. m.ClearQ()
  2135. return nil
  2136. case agentbase.FieldA:
  2137. m.ClearA()
  2138. return nil
  2139. case agentbase.FieldIndexes:
  2140. m.ClearIndexes()
  2141. return nil
  2142. case agentbase.FieldDatasetID:
  2143. m.ClearDatasetID()
  2144. return nil
  2145. case agentbase.FieldCollectionID:
  2146. m.ClearCollectionID()
  2147. return nil
  2148. case agentbase.FieldSourceName:
  2149. m.ClearSourceName()
  2150. return nil
  2151. case agentbase.FieldCanWrite:
  2152. m.ClearCanWrite()
  2153. return nil
  2154. case agentbase.FieldIsOwner:
  2155. m.ClearIsOwner()
  2156. return nil
  2157. }
  2158. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2159. }
  2160. // ResetField resets all changes in the mutation for the field with the given name.
  2161. // It returns an error if the field is not defined in the schema.
  2162. func (m *AgentBaseMutation) ResetField(name string) error {
  2163. switch name {
  2164. case agentbase.FieldQ:
  2165. m.ResetQ()
  2166. return nil
  2167. case agentbase.FieldA:
  2168. m.ResetA()
  2169. return nil
  2170. case agentbase.FieldChunkIndex:
  2171. m.ResetChunkIndex()
  2172. return nil
  2173. case agentbase.FieldIndexes:
  2174. m.ResetIndexes()
  2175. return nil
  2176. case agentbase.FieldDatasetID:
  2177. m.ResetDatasetID()
  2178. return nil
  2179. case agentbase.FieldCollectionID:
  2180. m.ResetCollectionID()
  2181. return nil
  2182. case agentbase.FieldSourceName:
  2183. m.ResetSourceName()
  2184. return nil
  2185. case agentbase.FieldCanWrite:
  2186. m.ResetCanWrite()
  2187. return nil
  2188. case agentbase.FieldIsOwner:
  2189. m.ResetIsOwner()
  2190. return nil
  2191. }
  2192. return fmt.Errorf("unknown AgentBase field %s", name)
  2193. }
  2194. // AddedEdges returns all edge names that were set/added in this mutation.
  2195. func (m *AgentBaseMutation) AddedEdges() []string {
  2196. edges := make([]string, 0, 1)
  2197. if m.wx_agent != nil {
  2198. edges = append(edges, agentbase.EdgeWxAgent)
  2199. }
  2200. return edges
  2201. }
  2202. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2203. // name in this mutation.
  2204. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2205. switch name {
  2206. case agentbase.EdgeWxAgent:
  2207. ids := make([]ent.Value, 0, len(m.wx_agent))
  2208. for id := range m.wx_agent {
  2209. ids = append(ids, id)
  2210. }
  2211. return ids
  2212. }
  2213. return nil
  2214. }
  2215. // RemovedEdges returns all edge names that were removed in this mutation.
  2216. func (m *AgentBaseMutation) RemovedEdges() []string {
  2217. edges := make([]string, 0, 1)
  2218. if m.removedwx_agent != nil {
  2219. edges = append(edges, agentbase.EdgeWxAgent)
  2220. }
  2221. return edges
  2222. }
  2223. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2224. // the given name in this mutation.
  2225. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2226. switch name {
  2227. case agentbase.EdgeWxAgent:
  2228. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2229. for id := range m.removedwx_agent {
  2230. ids = append(ids, id)
  2231. }
  2232. return ids
  2233. }
  2234. return nil
  2235. }
  2236. // ClearedEdges returns all edge names that were cleared in this mutation.
  2237. func (m *AgentBaseMutation) ClearedEdges() []string {
  2238. edges := make([]string, 0, 1)
  2239. if m.clearedwx_agent {
  2240. edges = append(edges, agentbase.EdgeWxAgent)
  2241. }
  2242. return edges
  2243. }
  2244. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2245. // was cleared in this mutation.
  2246. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2247. switch name {
  2248. case agentbase.EdgeWxAgent:
  2249. return m.clearedwx_agent
  2250. }
  2251. return false
  2252. }
  2253. // ClearEdge clears the value of the edge with the given name. It returns an error
  2254. // if that edge is not defined in the schema.
  2255. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2256. switch name {
  2257. }
  2258. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2259. }
  2260. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2261. // It returns an error if the edge is not defined in the schema.
  2262. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2263. switch name {
  2264. case agentbase.EdgeWxAgent:
  2265. m.ResetWxAgent()
  2266. return nil
  2267. }
  2268. return fmt.Errorf("unknown AgentBase edge %s", name)
  2269. }
  2270. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2271. type AliyunAvatarMutation struct {
  2272. config
  2273. op Op
  2274. typ string
  2275. id *uint64
  2276. created_at *time.Time
  2277. updated_at *time.Time
  2278. deleted_at *time.Time
  2279. user_id *uint64
  2280. adduser_id *int64
  2281. biz_id *string
  2282. access_key_id *string
  2283. access_key_secret *string
  2284. app_id *string
  2285. tenant_id *uint64
  2286. addtenant_id *int64
  2287. response *string
  2288. token *string
  2289. session_id *string
  2290. clearedFields map[string]struct{}
  2291. done bool
  2292. oldValue func(context.Context) (*AliyunAvatar, error)
  2293. predicates []predicate.AliyunAvatar
  2294. }
  2295. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2296. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2297. type aliyunavatarOption func(*AliyunAvatarMutation)
  2298. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2299. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2300. m := &AliyunAvatarMutation{
  2301. config: c,
  2302. op: op,
  2303. typ: TypeAliyunAvatar,
  2304. clearedFields: make(map[string]struct{}),
  2305. }
  2306. for _, opt := range opts {
  2307. opt(m)
  2308. }
  2309. return m
  2310. }
  2311. // withAliyunAvatarID sets the ID field of the mutation.
  2312. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2313. return func(m *AliyunAvatarMutation) {
  2314. var (
  2315. err error
  2316. once sync.Once
  2317. value *AliyunAvatar
  2318. )
  2319. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2320. once.Do(func() {
  2321. if m.done {
  2322. err = errors.New("querying old values post mutation is not allowed")
  2323. } else {
  2324. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2325. }
  2326. })
  2327. return value, err
  2328. }
  2329. m.id = &id
  2330. }
  2331. }
  2332. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2333. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2334. return func(m *AliyunAvatarMutation) {
  2335. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2336. return node, nil
  2337. }
  2338. m.id = &node.ID
  2339. }
  2340. }
  2341. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2342. // executed in a transaction (ent.Tx), a transactional client is returned.
  2343. func (m AliyunAvatarMutation) Client() *Client {
  2344. client := &Client{config: m.config}
  2345. client.init()
  2346. return client
  2347. }
  2348. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2349. // it returns an error otherwise.
  2350. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2351. if _, ok := m.driver.(*txDriver); !ok {
  2352. return nil, errors.New("ent: mutation is not running in a transaction")
  2353. }
  2354. tx := &Tx{config: m.config}
  2355. tx.init()
  2356. return tx, nil
  2357. }
  2358. // SetID sets the value of the id field. Note that this
  2359. // operation is only accepted on creation of AliyunAvatar entities.
  2360. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2361. m.id = &id
  2362. }
  2363. // ID returns the ID value in the mutation. Note that the ID is only available
  2364. // if it was provided to the builder or after it was returned from the database.
  2365. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2366. if m.id == nil {
  2367. return
  2368. }
  2369. return *m.id, true
  2370. }
  2371. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2372. // That means, if the mutation is applied within a transaction with an isolation level such
  2373. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2374. // or updated by the mutation.
  2375. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2376. switch {
  2377. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2378. id, exists := m.ID()
  2379. if exists {
  2380. return []uint64{id}, nil
  2381. }
  2382. fallthrough
  2383. case m.op.Is(OpUpdate | OpDelete):
  2384. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2385. default:
  2386. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2387. }
  2388. }
  2389. // SetCreatedAt sets the "created_at" field.
  2390. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2391. m.created_at = &t
  2392. }
  2393. // CreatedAt returns the value of the "created_at" field in the mutation.
  2394. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2395. v := m.created_at
  2396. if v == nil {
  2397. return
  2398. }
  2399. return *v, true
  2400. }
  2401. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2402. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2403. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2404. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2405. if !m.op.Is(OpUpdateOne) {
  2406. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2407. }
  2408. if m.id == nil || m.oldValue == nil {
  2409. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2410. }
  2411. oldValue, err := m.oldValue(ctx)
  2412. if err != nil {
  2413. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2414. }
  2415. return oldValue.CreatedAt, nil
  2416. }
  2417. // ResetCreatedAt resets all changes to the "created_at" field.
  2418. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2419. m.created_at = nil
  2420. }
  2421. // SetUpdatedAt sets the "updated_at" field.
  2422. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2423. m.updated_at = &t
  2424. }
  2425. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2426. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2427. v := m.updated_at
  2428. if v == nil {
  2429. return
  2430. }
  2431. return *v, true
  2432. }
  2433. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2434. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2435. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2436. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2437. if !m.op.Is(OpUpdateOne) {
  2438. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2439. }
  2440. if m.id == nil || m.oldValue == nil {
  2441. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2442. }
  2443. oldValue, err := m.oldValue(ctx)
  2444. if err != nil {
  2445. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2446. }
  2447. return oldValue.UpdatedAt, nil
  2448. }
  2449. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2450. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2451. m.updated_at = nil
  2452. }
  2453. // SetDeletedAt sets the "deleted_at" field.
  2454. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2455. m.deleted_at = &t
  2456. }
  2457. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2458. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2459. v := m.deleted_at
  2460. if v == nil {
  2461. return
  2462. }
  2463. return *v, true
  2464. }
  2465. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2466. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2467. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2468. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2469. if !m.op.Is(OpUpdateOne) {
  2470. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2471. }
  2472. if m.id == nil || m.oldValue == nil {
  2473. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2474. }
  2475. oldValue, err := m.oldValue(ctx)
  2476. if err != nil {
  2477. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2478. }
  2479. return oldValue.DeletedAt, nil
  2480. }
  2481. // ClearDeletedAt clears the value of the "deleted_at" field.
  2482. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2483. m.deleted_at = nil
  2484. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2485. }
  2486. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2487. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2488. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2489. return ok
  2490. }
  2491. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2492. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2493. m.deleted_at = nil
  2494. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2495. }
  2496. // SetUserID sets the "user_id" field.
  2497. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2498. m.user_id = &u
  2499. m.adduser_id = nil
  2500. }
  2501. // UserID returns the value of the "user_id" field in the mutation.
  2502. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2503. v := m.user_id
  2504. if v == nil {
  2505. return
  2506. }
  2507. return *v, true
  2508. }
  2509. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2510. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2511. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2512. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2513. if !m.op.Is(OpUpdateOne) {
  2514. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2515. }
  2516. if m.id == nil || m.oldValue == nil {
  2517. return v, errors.New("OldUserID requires an ID field in the mutation")
  2518. }
  2519. oldValue, err := m.oldValue(ctx)
  2520. if err != nil {
  2521. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  2522. }
  2523. return oldValue.UserID, nil
  2524. }
  2525. // AddUserID adds u to the "user_id" field.
  2526. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  2527. if m.adduser_id != nil {
  2528. *m.adduser_id += u
  2529. } else {
  2530. m.adduser_id = &u
  2531. }
  2532. }
  2533. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  2534. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  2535. v := m.adduser_id
  2536. if v == nil {
  2537. return
  2538. }
  2539. return *v, true
  2540. }
  2541. // ResetUserID resets all changes to the "user_id" field.
  2542. func (m *AliyunAvatarMutation) ResetUserID() {
  2543. m.user_id = nil
  2544. m.adduser_id = nil
  2545. }
  2546. // SetBizID sets the "biz_id" field.
  2547. func (m *AliyunAvatarMutation) SetBizID(s string) {
  2548. m.biz_id = &s
  2549. }
  2550. // BizID returns the value of the "biz_id" field in the mutation.
  2551. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  2552. v := m.biz_id
  2553. if v == nil {
  2554. return
  2555. }
  2556. return *v, true
  2557. }
  2558. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  2559. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2560. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2561. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  2562. if !m.op.Is(OpUpdateOne) {
  2563. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  2564. }
  2565. if m.id == nil || m.oldValue == nil {
  2566. return v, errors.New("OldBizID requires an ID field in the mutation")
  2567. }
  2568. oldValue, err := m.oldValue(ctx)
  2569. if err != nil {
  2570. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  2571. }
  2572. return oldValue.BizID, nil
  2573. }
  2574. // ResetBizID resets all changes to the "biz_id" field.
  2575. func (m *AliyunAvatarMutation) ResetBizID() {
  2576. m.biz_id = nil
  2577. }
  2578. // SetAccessKeyID sets the "access_key_id" field.
  2579. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  2580. m.access_key_id = &s
  2581. }
  2582. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  2583. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  2584. v := m.access_key_id
  2585. if v == nil {
  2586. return
  2587. }
  2588. return *v, true
  2589. }
  2590. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  2591. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2592. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2593. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  2594. if !m.op.Is(OpUpdateOne) {
  2595. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  2596. }
  2597. if m.id == nil || m.oldValue == nil {
  2598. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  2599. }
  2600. oldValue, err := m.oldValue(ctx)
  2601. if err != nil {
  2602. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  2603. }
  2604. return oldValue.AccessKeyID, nil
  2605. }
  2606. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  2607. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  2608. m.access_key_id = nil
  2609. }
  2610. // SetAccessKeySecret sets the "access_key_secret" field.
  2611. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  2612. m.access_key_secret = &s
  2613. }
  2614. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  2615. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  2616. v := m.access_key_secret
  2617. if v == nil {
  2618. return
  2619. }
  2620. return *v, true
  2621. }
  2622. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  2623. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2624. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2625. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  2626. if !m.op.Is(OpUpdateOne) {
  2627. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  2628. }
  2629. if m.id == nil || m.oldValue == nil {
  2630. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  2631. }
  2632. oldValue, err := m.oldValue(ctx)
  2633. if err != nil {
  2634. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  2635. }
  2636. return oldValue.AccessKeySecret, nil
  2637. }
  2638. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  2639. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  2640. m.access_key_secret = nil
  2641. }
  2642. // SetAppID sets the "app_id" field.
  2643. func (m *AliyunAvatarMutation) SetAppID(s string) {
  2644. m.app_id = &s
  2645. }
  2646. // AppID returns the value of the "app_id" field in the mutation.
  2647. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  2648. v := m.app_id
  2649. if v == nil {
  2650. return
  2651. }
  2652. return *v, true
  2653. }
  2654. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  2655. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2656. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2657. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  2658. if !m.op.Is(OpUpdateOne) {
  2659. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  2660. }
  2661. if m.id == nil || m.oldValue == nil {
  2662. return v, errors.New("OldAppID requires an ID field in the mutation")
  2663. }
  2664. oldValue, err := m.oldValue(ctx)
  2665. if err != nil {
  2666. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  2667. }
  2668. return oldValue.AppID, nil
  2669. }
  2670. // ClearAppID clears the value of the "app_id" field.
  2671. func (m *AliyunAvatarMutation) ClearAppID() {
  2672. m.app_id = nil
  2673. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  2674. }
  2675. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  2676. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  2677. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  2678. return ok
  2679. }
  2680. // ResetAppID resets all changes to the "app_id" field.
  2681. func (m *AliyunAvatarMutation) ResetAppID() {
  2682. m.app_id = nil
  2683. delete(m.clearedFields, aliyunavatar.FieldAppID)
  2684. }
  2685. // SetTenantID sets the "tenant_id" field.
  2686. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  2687. m.tenant_id = &u
  2688. m.addtenant_id = nil
  2689. }
  2690. // TenantID returns the value of the "tenant_id" field in the mutation.
  2691. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  2692. v := m.tenant_id
  2693. if v == nil {
  2694. return
  2695. }
  2696. return *v, true
  2697. }
  2698. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  2699. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2700. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2701. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  2702. if !m.op.Is(OpUpdateOne) {
  2703. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  2704. }
  2705. if m.id == nil || m.oldValue == nil {
  2706. return v, errors.New("OldTenantID requires an ID field in the mutation")
  2707. }
  2708. oldValue, err := m.oldValue(ctx)
  2709. if err != nil {
  2710. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  2711. }
  2712. return oldValue.TenantID, nil
  2713. }
  2714. // AddTenantID adds u to the "tenant_id" field.
  2715. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  2716. if m.addtenant_id != nil {
  2717. *m.addtenant_id += u
  2718. } else {
  2719. m.addtenant_id = &u
  2720. }
  2721. }
  2722. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  2723. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  2724. v := m.addtenant_id
  2725. if v == nil {
  2726. return
  2727. }
  2728. return *v, true
  2729. }
  2730. // ResetTenantID resets all changes to the "tenant_id" field.
  2731. func (m *AliyunAvatarMutation) ResetTenantID() {
  2732. m.tenant_id = nil
  2733. m.addtenant_id = nil
  2734. }
  2735. // SetResponse sets the "response" field.
  2736. func (m *AliyunAvatarMutation) SetResponse(s string) {
  2737. m.response = &s
  2738. }
  2739. // Response returns the value of the "response" field in the mutation.
  2740. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  2741. v := m.response
  2742. if v == nil {
  2743. return
  2744. }
  2745. return *v, true
  2746. }
  2747. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  2748. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2749. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2750. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  2751. if !m.op.Is(OpUpdateOne) {
  2752. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  2753. }
  2754. if m.id == nil || m.oldValue == nil {
  2755. return v, errors.New("OldResponse requires an ID field in the mutation")
  2756. }
  2757. oldValue, err := m.oldValue(ctx)
  2758. if err != nil {
  2759. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  2760. }
  2761. return oldValue.Response, nil
  2762. }
  2763. // ResetResponse resets all changes to the "response" field.
  2764. func (m *AliyunAvatarMutation) ResetResponse() {
  2765. m.response = nil
  2766. }
  2767. // SetToken sets the "token" field.
  2768. func (m *AliyunAvatarMutation) SetToken(s string) {
  2769. m.token = &s
  2770. }
  2771. // Token returns the value of the "token" field in the mutation.
  2772. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  2773. v := m.token
  2774. if v == nil {
  2775. return
  2776. }
  2777. return *v, true
  2778. }
  2779. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  2780. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2781. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2782. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  2783. if !m.op.Is(OpUpdateOne) {
  2784. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  2785. }
  2786. if m.id == nil || m.oldValue == nil {
  2787. return v, errors.New("OldToken requires an ID field in the mutation")
  2788. }
  2789. oldValue, err := m.oldValue(ctx)
  2790. if err != nil {
  2791. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  2792. }
  2793. return oldValue.Token, nil
  2794. }
  2795. // ResetToken resets all changes to the "token" field.
  2796. func (m *AliyunAvatarMutation) ResetToken() {
  2797. m.token = nil
  2798. }
  2799. // SetSessionID sets the "session_id" field.
  2800. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  2801. m.session_id = &s
  2802. }
  2803. // SessionID returns the value of the "session_id" field in the mutation.
  2804. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  2805. v := m.session_id
  2806. if v == nil {
  2807. return
  2808. }
  2809. return *v, true
  2810. }
  2811. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  2812. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2814. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  2815. if !m.op.Is(OpUpdateOne) {
  2816. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  2817. }
  2818. if m.id == nil || m.oldValue == nil {
  2819. return v, errors.New("OldSessionID requires an ID field in the mutation")
  2820. }
  2821. oldValue, err := m.oldValue(ctx)
  2822. if err != nil {
  2823. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  2824. }
  2825. return oldValue.SessionID, nil
  2826. }
  2827. // ResetSessionID resets all changes to the "session_id" field.
  2828. func (m *AliyunAvatarMutation) ResetSessionID() {
  2829. m.session_id = nil
  2830. }
  2831. // Where appends a list predicates to the AliyunAvatarMutation builder.
  2832. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  2833. m.predicates = append(m.predicates, ps...)
  2834. }
  2835. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  2836. // users can use type-assertion to append predicates that do not depend on any generated package.
  2837. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  2838. p := make([]predicate.AliyunAvatar, len(ps))
  2839. for i := range ps {
  2840. p[i] = ps[i]
  2841. }
  2842. m.Where(p...)
  2843. }
  2844. // Op returns the operation name.
  2845. func (m *AliyunAvatarMutation) Op() Op {
  2846. return m.op
  2847. }
  2848. // SetOp allows setting the mutation operation.
  2849. func (m *AliyunAvatarMutation) SetOp(op Op) {
  2850. m.op = op
  2851. }
  2852. // Type returns the node type of this mutation (AliyunAvatar).
  2853. func (m *AliyunAvatarMutation) Type() string {
  2854. return m.typ
  2855. }
  2856. // Fields returns all fields that were changed during this mutation. Note that in
  2857. // order to get all numeric fields that were incremented/decremented, call
  2858. // AddedFields().
  2859. func (m *AliyunAvatarMutation) Fields() []string {
  2860. fields := make([]string, 0, 12)
  2861. if m.created_at != nil {
  2862. fields = append(fields, aliyunavatar.FieldCreatedAt)
  2863. }
  2864. if m.updated_at != nil {
  2865. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  2866. }
  2867. if m.deleted_at != nil {
  2868. fields = append(fields, aliyunavatar.FieldDeletedAt)
  2869. }
  2870. if m.user_id != nil {
  2871. fields = append(fields, aliyunavatar.FieldUserID)
  2872. }
  2873. if m.biz_id != nil {
  2874. fields = append(fields, aliyunavatar.FieldBizID)
  2875. }
  2876. if m.access_key_id != nil {
  2877. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  2878. }
  2879. if m.access_key_secret != nil {
  2880. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  2881. }
  2882. if m.app_id != nil {
  2883. fields = append(fields, aliyunavatar.FieldAppID)
  2884. }
  2885. if m.tenant_id != nil {
  2886. fields = append(fields, aliyunavatar.FieldTenantID)
  2887. }
  2888. if m.response != nil {
  2889. fields = append(fields, aliyunavatar.FieldResponse)
  2890. }
  2891. if m.token != nil {
  2892. fields = append(fields, aliyunavatar.FieldToken)
  2893. }
  2894. if m.session_id != nil {
  2895. fields = append(fields, aliyunavatar.FieldSessionID)
  2896. }
  2897. return fields
  2898. }
  2899. // Field returns the value of a field with the given name. The second boolean
  2900. // return value indicates that this field was not set, or was not defined in the
  2901. // schema.
  2902. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  2903. switch name {
  2904. case aliyunavatar.FieldCreatedAt:
  2905. return m.CreatedAt()
  2906. case aliyunavatar.FieldUpdatedAt:
  2907. return m.UpdatedAt()
  2908. case aliyunavatar.FieldDeletedAt:
  2909. return m.DeletedAt()
  2910. case aliyunavatar.FieldUserID:
  2911. return m.UserID()
  2912. case aliyunavatar.FieldBizID:
  2913. return m.BizID()
  2914. case aliyunavatar.FieldAccessKeyID:
  2915. return m.AccessKeyID()
  2916. case aliyunavatar.FieldAccessKeySecret:
  2917. return m.AccessKeySecret()
  2918. case aliyunavatar.FieldAppID:
  2919. return m.AppID()
  2920. case aliyunavatar.FieldTenantID:
  2921. return m.TenantID()
  2922. case aliyunavatar.FieldResponse:
  2923. return m.Response()
  2924. case aliyunavatar.FieldToken:
  2925. return m.Token()
  2926. case aliyunavatar.FieldSessionID:
  2927. return m.SessionID()
  2928. }
  2929. return nil, false
  2930. }
  2931. // OldField returns the old value of the field from the database. An error is
  2932. // returned if the mutation operation is not UpdateOne, or the query to the
  2933. // database failed.
  2934. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2935. switch name {
  2936. case aliyunavatar.FieldCreatedAt:
  2937. return m.OldCreatedAt(ctx)
  2938. case aliyunavatar.FieldUpdatedAt:
  2939. return m.OldUpdatedAt(ctx)
  2940. case aliyunavatar.FieldDeletedAt:
  2941. return m.OldDeletedAt(ctx)
  2942. case aliyunavatar.FieldUserID:
  2943. return m.OldUserID(ctx)
  2944. case aliyunavatar.FieldBizID:
  2945. return m.OldBizID(ctx)
  2946. case aliyunavatar.FieldAccessKeyID:
  2947. return m.OldAccessKeyID(ctx)
  2948. case aliyunavatar.FieldAccessKeySecret:
  2949. return m.OldAccessKeySecret(ctx)
  2950. case aliyunavatar.FieldAppID:
  2951. return m.OldAppID(ctx)
  2952. case aliyunavatar.FieldTenantID:
  2953. return m.OldTenantID(ctx)
  2954. case aliyunavatar.FieldResponse:
  2955. return m.OldResponse(ctx)
  2956. case aliyunavatar.FieldToken:
  2957. return m.OldToken(ctx)
  2958. case aliyunavatar.FieldSessionID:
  2959. return m.OldSessionID(ctx)
  2960. }
  2961. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  2962. }
  2963. // SetField sets the value of a field with the given name. It returns an error if
  2964. // the field is not defined in the schema, or if the type mismatched the field
  2965. // type.
  2966. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  2967. switch name {
  2968. case aliyunavatar.FieldCreatedAt:
  2969. v, ok := value.(time.Time)
  2970. if !ok {
  2971. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2972. }
  2973. m.SetCreatedAt(v)
  2974. return nil
  2975. case aliyunavatar.FieldUpdatedAt:
  2976. v, ok := value.(time.Time)
  2977. if !ok {
  2978. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2979. }
  2980. m.SetUpdatedAt(v)
  2981. return nil
  2982. case aliyunavatar.FieldDeletedAt:
  2983. v, ok := value.(time.Time)
  2984. if !ok {
  2985. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2986. }
  2987. m.SetDeletedAt(v)
  2988. return nil
  2989. case aliyunavatar.FieldUserID:
  2990. v, ok := value.(uint64)
  2991. if !ok {
  2992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2993. }
  2994. m.SetUserID(v)
  2995. return nil
  2996. case aliyunavatar.FieldBizID:
  2997. v, ok := value.(string)
  2998. if !ok {
  2999. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3000. }
  3001. m.SetBizID(v)
  3002. return nil
  3003. case aliyunavatar.FieldAccessKeyID:
  3004. v, ok := value.(string)
  3005. if !ok {
  3006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3007. }
  3008. m.SetAccessKeyID(v)
  3009. return nil
  3010. case aliyunavatar.FieldAccessKeySecret:
  3011. v, ok := value.(string)
  3012. if !ok {
  3013. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3014. }
  3015. m.SetAccessKeySecret(v)
  3016. return nil
  3017. case aliyunavatar.FieldAppID:
  3018. v, ok := value.(string)
  3019. if !ok {
  3020. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3021. }
  3022. m.SetAppID(v)
  3023. return nil
  3024. case aliyunavatar.FieldTenantID:
  3025. v, ok := value.(uint64)
  3026. if !ok {
  3027. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3028. }
  3029. m.SetTenantID(v)
  3030. return nil
  3031. case aliyunavatar.FieldResponse:
  3032. v, ok := value.(string)
  3033. if !ok {
  3034. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3035. }
  3036. m.SetResponse(v)
  3037. return nil
  3038. case aliyunavatar.FieldToken:
  3039. v, ok := value.(string)
  3040. if !ok {
  3041. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3042. }
  3043. m.SetToken(v)
  3044. return nil
  3045. case aliyunavatar.FieldSessionID:
  3046. v, ok := value.(string)
  3047. if !ok {
  3048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3049. }
  3050. m.SetSessionID(v)
  3051. return nil
  3052. }
  3053. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3054. }
  3055. // AddedFields returns all numeric fields that were incremented/decremented during
  3056. // this mutation.
  3057. func (m *AliyunAvatarMutation) AddedFields() []string {
  3058. var fields []string
  3059. if m.adduser_id != nil {
  3060. fields = append(fields, aliyunavatar.FieldUserID)
  3061. }
  3062. if m.addtenant_id != nil {
  3063. fields = append(fields, aliyunavatar.FieldTenantID)
  3064. }
  3065. return fields
  3066. }
  3067. // AddedField returns the numeric value that was incremented/decremented on a field
  3068. // with the given name. The second boolean return value indicates that this field
  3069. // was not set, or was not defined in the schema.
  3070. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  3071. switch name {
  3072. case aliyunavatar.FieldUserID:
  3073. return m.AddedUserID()
  3074. case aliyunavatar.FieldTenantID:
  3075. return m.AddedTenantID()
  3076. }
  3077. return nil, false
  3078. }
  3079. // AddField adds the value to the field with the given name. It returns an error if
  3080. // the field is not defined in the schema, or if the type mismatched the field
  3081. // type.
  3082. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  3083. switch name {
  3084. case aliyunavatar.FieldUserID:
  3085. v, ok := value.(int64)
  3086. if !ok {
  3087. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3088. }
  3089. m.AddUserID(v)
  3090. return nil
  3091. case aliyunavatar.FieldTenantID:
  3092. v, ok := value.(int64)
  3093. if !ok {
  3094. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3095. }
  3096. m.AddTenantID(v)
  3097. return nil
  3098. }
  3099. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3100. }
  3101. // ClearedFields returns all nullable fields that were cleared during this
  3102. // mutation.
  3103. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3104. var fields []string
  3105. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3106. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3107. }
  3108. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3109. fields = append(fields, aliyunavatar.FieldAppID)
  3110. }
  3111. return fields
  3112. }
  3113. // FieldCleared returns a boolean indicating if a field with the given name was
  3114. // cleared in this mutation.
  3115. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3116. _, ok := m.clearedFields[name]
  3117. return ok
  3118. }
  3119. // ClearField clears the value of the field with the given name. It returns an
  3120. // error if the field is not defined in the schema.
  3121. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3122. switch name {
  3123. case aliyunavatar.FieldDeletedAt:
  3124. m.ClearDeletedAt()
  3125. return nil
  3126. case aliyunavatar.FieldAppID:
  3127. m.ClearAppID()
  3128. return nil
  3129. }
  3130. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3131. }
  3132. // ResetField resets all changes in the mutation for the field with the given name.
  3133. // It returns an error if the field is not defined in the schema.
  3134. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3135. switch name {
  3136. case aliyunavatar.FieldCreatedAt:
  3137. m.ResetCreatedAt()
  3138. return nil
  3139. case aliyunavatar.FieldUpdatedAt:
  3140. m.ResetUpdatedAt()
  3141. return nil
  3142. case aliyunavatar.FieldDeletedAt:
  3143. m.ResetDeletedAt()
  3144. return nil
  3145. case aliyunavatar.FieldUserID:
  3146. m.ResetUserID()
  3147. return nil
  3148. case aliyunavatar.FieldBizID:
  3149. m.ResetBizID()
  3150. return nil
  3151. case aliyunavatar.FieldAccessKeyID:
  3152. m.ResetAccessKeyID()
  3153. return nil
  3154. case aliyunavatar.FieldAccessKeySecret:
  3155. m.ResetAccessKeySecret()
  3156. return nil
  3157. case aliyunavatar.FieldAppID:
  3158. m.ResetAppID()
  3159. return nil
  3160. case aliyunavatar.FieldTenantID:
  3161. m.ResetTenantID()
  3162. return nil
  3163. case aliyunavatar.FieldResponse:
  3164. m.ResetResponse()
  3165. return nil
  3166. case aliyunavatar.FieldToken:
  3167. m.ResetToken()
  3168. return nil
  3169. case aliyunavatar.FieldSessionID:
  3170. m.ResetSessionID()
  3171. return nil
  3172. }
  3173. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3174. }
  3175. // AddedEdges returns all edge names that were set/added in this mutation.
  3176. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3177. edges := make([]string, 0, 0)
  3178. return edges
  3179. }
  3180. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3181. // name in this mutation.
  3182. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3183. return nil
  3184. }
  3185. // RemovedEdges returns all edge names that were removed in this mutation.
  3186. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3187. edges := make([]string, 0, 0)
  3188. return edges
  3189. }
  3190. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3191. // the given name in this mutation.
  3192. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3193. return nil
  3194. }
  3195. // ClearedEdges returns all edge names that were cleared in this mutation.
  3196. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3197. edges := make([]string, 0, 0)
  3198. return edges
  3199. }
  3200. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3201. // was cleared in this mutation.
  3202. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3203. return false
  3204. }
  3205. // ClearEdge clears the value of the edge with the given name. It returns an error
  3206. // if that edge is not defined in the schema.
  3207. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3208. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3209. }
  3210. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3211. // It returns an error if the edge is not defined in the schema.
  3212. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3213. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3214. }
  3215. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  3216. type AllocAgentMutation struct {
  3217. config
  3218. op Op
  3219. typ string
  3220. id *uint64
  3221. created_at *time.Time
  3222. updated_at *time.Time
  3223. deleted_at *time.Time
  3224. user_id *string
  3225. organization_id *uint64
  3226. addorganization_id *int64
  3227. agents *[]uint64
  3228. appendagents []uint64
  3229. status *int
  3230. addstatus *int
  3231. clearedFields map[string]struct{}
  3232. done bool
  3233. oldValue func(context.Context) (*AllocAgent, error)
  3234. predicates []predicate.AllocAgent
  3235. }
  3236. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  3237. // allocagentOption allows management of the mutation configuration using functional options.
  3238. type allocagentOption func(*AllocAgentMutation)
  3239. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  3240. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  3241. m := &AllocAgentMutation{
  3242. config: c,
  3243. op: op,
  3244. typ: TypeAllocAgent,
  3245. clearedFields: make(map[string]struct{}),
  3246. }
  3247. for _, opt := range opts {
  3248. opt(m)
  3249. }
  3250. return m
  3251. }
  3252. // withAllocAgentID sets the ID field of the mutation.
  3253. func withAllocAgentID(id uint64) allocagentOption {
  3254. return func(m *AllocAgentMutation) {
  3255. var (
  3256. err error
  3257. once sync.Once
  3258. value *AllocAgent
  3259. )
  3260. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  3261. once.Do(func() {
  3262. if m.done {
  3263. err = errors.New("querying old values post mutation is not allowed")
  3264. } else {
  3265. value, err = m.Client().AllocAgent.Get(ctx, id)
  3266. }
  3267. })
  3268. return value, err
  3269. }
  3270. m.id = &id
  3271. }
  3272. }
  3273. // withAllocAgent sets the old AllocAgent of the mutation.
  3274. func withAllocAgent(node *AllocAgent) allocagentOption {
  3275. return func(m *AllocAgentMutation) {
  3276. m.oldValue = func(context.Context) (*AllocAgent, error) {
  3277. return node, nil
  3278. }
  3279. m.id = &node.ID
  3280. }
  3281. }
  3282. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3283. // executed in a transaction (ent.Tx), a transactional client is returned.
  3284. func (m AllocAgentMutation) Client() *Client {
  3285. client := &Client{config: m.config}
  3286. client.init()
  3287. return client
  3288. }
  3289. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3290. // it returns an error otherwise.
  3291. func (m AllocAgentMutation) Tx() (*Tx, error) {
  3292. if _, ok := m.driver.(*txDriver); !ok {
  3293. return nil, errors.New("ent: mutation is not running in a transaction")
  3294. }
  3295. tx := &Tx{config: m.config}
  3296. tx.init()
  3297. return tx, nil
  3298. }
  3299. // SetID sets the value of the id field. Note that this
  3300. // operation is only accepted on creation of AllocAgent entities.
  3301. func (m *AllocAgentMutation) SetID(id uint64) {
  3302. m.id = &id
  3303. }
  3304. // ID returns the ID value in the mutation. Note that the ID is only available
  3305. // if it was provided to the builder or after it was returned from the database.
  3306. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  3307. if m.id == nil {
  3308. return
  3309. }
  3310. return *m.id, true
  3311. }
  3312. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3313. // That means, if the mutation is applied within a transaction with an isolation level such
  3314. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3315. // or updated by the mutation.
  3316. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  3317. switch {
  3318. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3319. id, exists := m.ID()
  3320. if exists {
  3321. return []uint64{id}, nil
  3322. }
  3323. fallthrough
  3324. case m.op.Is(OpUpdate | OpDelete):
  3325. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  3326. default:
  3327. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3328. }
  3329. }
  3330. // SetCreatedAt sets the "created_at" field.
  3331. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  3332. m.created_at = &t
  3333. }
  3334. // CreatedAt returns the value of the "created_at" field in the mutation.
  3335. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  3336. v := m.created_at
  3337. if v == nil {
  3338. return
  3339. }
  3340. return *v, true
  3341. }
  3342. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  3343. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3344. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3345. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3346. if !m.op.Is(OpUpdateOne) {
  3347. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3348. }
  3349. if m.id == nil || m.oldValue == nil {
  3350. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3351. }
  3352. oldValue, err := m.oldValue(ctx)
  3353. if err != nil {
  3354. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3355. }
  3356. return oldValue.CreatedAt, nil
  3357. }
  3358. // ResetCreatedAt resets all changes to the "created_at" field.
  3359. func (m *AllocAgentMutation) ResetCreatedAt() {
  3360. m.created_at = nil
  3361. }
  3362. // SetUpdatedAt sets the "updated_at" field.
  3363. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  3364. m.updated_at = &t
  3365. }
  3366. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3367. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  3368. v := m.updated_at
  3369. if v == nil {
  3370. return
  3371. }
  3372. return *v, true
  3373. }
  3374. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  3375. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3376. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3377. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3378. if !m.op.Is(OpUpdateOne) {
  3379. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3380. }
  3381. if m.id == nil || m.oldValue == nil {
  3382. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3383. }
  3384. oldValue, err := m.oldValue(ctx)
  3385. if err != nil {
  3386. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3387. }
  3388. return oldValue.UpdatedAt, nil
  3389. }
  3390. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3391. func (m *AllocAgentMutation) ResetUpdatedAt() {
  3392. m.updated_at = nil
  3393. }
  3394. // SetDeletedAt sets the "deleted_at" field.
  3395. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  3396. m.deleted_at = &t
  3397. }
  3398. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3399. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  3400. v := m.deleted_at
  3401. if v == nil {
  3402. return
  3403. }
  3404. return *v, true
  3405. }
  3406. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  3407. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3408. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3409. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3410. if !m.op.Is(OpUpdateOne) {
  3411. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3412. }
  3413. if m.id == nil || m.oldValue == nil {
  3414. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3415. }
  3416. oldValue, err := m.oldValue(ctx)
  3417. if err != nil {
  3418. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3419. }
  3420. return oldValue.DeletedAt, nil
  3421. }
  3422. // ClearDeletedAt clears the value of the "deleted_at" field.
  3423. func (m *AllocAgentMutation) ClearDeletedAt() {
  3424. m.deleted_at = nil
  3425. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  3426. }
  3427. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3428. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  3429. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  3430. return ok
  3431. }
  3432. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3433. func (m *AllocAgentMutation) ResetDeletedAt() {
  3434. m.deleted_at = nil
  3435. delete(m.clearedFields, allocagent.FieldDeletedAt)
  3436. }
  3437. // SetUserID sets the "user_id" field.
  3438. func (m *AllocAgentMutation) SetUserID(s string) {
  3439. m.user_id = &s
  3440. }
  3441. // UserID returns the value of the "user_id" field in the mutation.
  3442. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  3443. v := m.user_id
  3444. if v == nil {
  3445. return
  3446. }
  3447. return *v, true
  3448. }
  3449. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  3450. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3451. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3452. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  3453. if !m.op.Is(OpUpdateOne) {
  3454. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  3455. }
  3456. if m.id == nil || m.oldValue == nil {
  3457. return v, errors.New("OldUserID requires an ID field in the mutation")
  3458. }
  3459. oldValue, err := m.oldValue(ctx)
  3460. if err != nil {
  3461. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  3462. }
  3463. return oldValue.UserID, nil
  3464. }
  3465. // ClearUserID clears the value of the "user_id" field.
  3466. func (m *AllocAgentMutation) ClearUserID() {
  3467. m.user_id = nil
  3468. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  3469. }
  3470. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  3471. func (m *AllocAgentMutation) UserIDCleared() bool {
  3472. _, ok := m.clearedFields[allocagent.FieldUserID]
  3473. return ok
  3474. }
  3475. // ResetUserID resets all changes to the "user_id" field.
  3476. func (m *AllocAgentMutation) ResetUserID() {
  3477. m.user_id = nil
  3478. delete(m.clearedFields, allocagent.FieldUserID)
  3479. }
  3480. // SetOrganizationID sets the "organization_id" field.
  3481. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  3482. m.organization_id = &u
  3483. m.addorganization_id = nil
  3484. }
  3485. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3486. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  3487. v := m.organization_id
  3488. if v == nil {
  3489. return
  3490. }
  3491. return *v, true
  3492. }
  3493. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  3494. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3495. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3496. func (m *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3497. if !m.op.Is(OpUpdateOne) {
  3498. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3499. }
  3500. if m.id == nil || m.oldValue == nil {
  3501. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3502. }
  3503. oldValue, err := m.oldValue(ctx)
  3504. if err != nil {
  3505. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3506. }
  3507. return oldValue.OrganizationID, nil
  3508. }
  3509. // AddOrganizationID adds u to the "organization_id" field.
  3510. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  3511. if m.addorganization_id != nil {
  3512. *m.addorganization_id += u
  3513. } else {
  3514. m.addorganization_id = &u
  3515. }
  3516. }
  3517. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3518. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  3519. v := m.addorganization_id
  3520. if v == nil {
  3521. return
  3522. }
  3523. return *v, true
  3524. }
  3525. // ClearOrganizationID clears the value of the "organization_id" field.
  3526. func (m *AllocAgentMutation) ClearOrganizationID() {
  3527. m.organization_id = nil
  3528. m.addorganization_id = nil
  3529. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  3530. }
  3531. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3532. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  3533. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  3534. return ok
  3535. }
  3536. // ResetOrganizationID resets all changes to the "organization_id" field.
  3537. func (m *AllocAgentMutation) ResetOrganizationID() {
  3538. m.organization_id = nil
  3539. m.addorganization_id = nil
  3540. delete(m.clearedFields, allocagent.FieldOrganizationID)
  3541. }
  3542. // SetAgents sets the "agents" field.
  3543. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  3544. m.agents = &u
  3545. m.appendagents = nil
  3546. }
  3547. // Agents returns the value of the "agents" field in the mutation.
  3548. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  3549. v := m.agents
  3550. if v == nil {
  3551. return
  3552. }
  3553. return *v, true
  3554. }
  3555. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  3556. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3557. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3558. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  3559. if !m.op.Is(OpUpdateOne) {
  3560. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  3561. }
  3562. if m.id == nil || m.oldValue == nil {
  3563. return v, errors.New("OldAgents requires an ID field in the mutation")
  3564. }
  3565. oldValue, err := m.oldValue(ctx)
  3566. if err != nil {
  3567. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  3568. }
  3569. return oldValue.Agents, nil
  3570. }
  3571. // AppendAgents adds u to the "agents" field.
  3572. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  3573. m.appendagents = append(m.appendagents, u...)
  3574. }
  3575. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  3576. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  3577. if len(m.appendagents) == 0 {
  3578. return nil, false
  3579. }
  3580. return m.appendagents, true
  3581. }
  3582. // ResetAgents resets all changes to the "agents" field.
  3583. func (m *AllocAgentMutation) ResetAgents() {
  3584. m.agents = nil
  3585. m.appendagents = nil
  3586. }
  3587. // SetStatus sets the "status" field.
  3588. func (m *AllocAgentMutation) SetStatus(i int) {
  3589. m.status = &i
  3590. m.addstatus = nil
  3591. }
  3592. // Status returns the value of the "status" field in the mutation.
  3593. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  3594. v := m.status
  3595. if v == nil {
  3596. return
  3597. }
  3598. return *v, true
  3599. }
  3600. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  3601. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3602. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3603. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  3604. if !m.op.Is(OpUpdateOne) {
  3605. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3606. }
  3607. if m.id == nil || m.oldValue == nil {
  3608. return v, errors.New("OldStatus requires an ID field in the mutation")
  3609. }
  3610. oldValue, err := m.oldValue(ctx)
  3611. if err != nil {
  3612. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3613. }
  3614. return oldValue.Status, nil
  3615. }
  3616. // AddStatus adds i to the "status" field.
  3617. func (m *AllocAgentMutation) AddStatus(i int) {
  3618. if m.addstatus != nil {
  3619. *m.addstatus += i
  3620. } else {
  3621. m.addstatus = &i
  3622. }
  3623. }
  3624. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3625. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  3626. v := m.addstatus
  3627. if v == nil {
  3628. return
  3629. }
  3630. return *v, true
  3631. }
  3632. // ClearStatus clears the value of the "status" field.
  3633. func (m *AllocAgentMutation) ClearStatus() {
  3634. m.status = nil
  3635. m.addstatus = nil
  3636. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  3637. }
  3638. // StatusCleared returns if the "status" field was cleared in this mutation.
  3639. func (m *AllocAgentMutation) StatusCleared() bool {
  3640. _, ok := m.clearedFields[allocagent.FieldStatus]
  3641. return ok
  3642. }
  3643. // ResetStatus resets all changes to the "status" field.
  3644. func (m *AllocAgentMutation) ResetStatus() {
  3645. m.status = nil
  3646. m.addstatus = nil
  3647. delete(m.clearedFields, allocagent.FieldStatus)
  3648. }
  3649. // Where appends a list predicates to the AllocAgentMutation builder.
  3650. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  3651. m.predicates = append(m.predicates, ps...)
  3652. }
  3653. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  3654. // users can use type-assertion to append predicates that do not depend on any generated package.
  3655. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  3656. p := make([]predicate.AllocAgent, len(ps))
  3657. for i := range ps {
  3658. p[i] = ps[i]
  3659. }
  3660. m.Where(p...)
  3661. }
  3662. // Op returns the operation name.
  3663. func (m *AllocAgentMutation) Op() Op {
  3664. return m.op
  3665. }
  3666. // SetOp allows setting the mutation operation.
  3667. func (m *AllocAgentMutation) SetOp(op Op) {
  3668. m.op = op
  3669. }
  3670. // Type returns the node type of this mutation (AllocAgent).
  3671. func (m *AllocAgentMutation) Type() string {
  3672. return m.typ
  3673. }
  3674. // Fields returns all fields that were changed during this mutation. Note that in
  3675. // order to get all numeric fields that were incremented/decremented, call
  3676. // AddedFields().
  3677. func (m *AllocAgentMutation) Fields() []string {
  3678. fields := make([]string, 0, 7)
  3679. if m.created_at != nil {
  3680. fields = append(fields, allocagent.FieldCreatedAt)
  3681. }
  3682. if m.updated_at != nil {
  3683. fields = append(fields, allocagent.FieldUpdatedAt)
  3684. }
  3685. if m.deleted_at != nil {
  3686. fields = append(fields, allocagent.FieldDeletedAt)
  3687. }
  3688. if m.user_id != nil {
  3689. fields = append(fields, allocagent.FieldUserID)
  3690. }
  3691. if m.organization_id != nil {
  3692. fields = append(fields, allocagent.FieldOrganizationID)
  3693. }
  3694. if m.agents != nil {
  3695. fields = append(fields, allocagent.FieldAgents)
  3696. }
  3697. if m.status != nil {
  3698. fields = append(fields, allocagent.FieldStatus)
  3699. }
  3700. return fields
  3701. }
  3702. // Field returns the value of a field with the given name. The second boolean
  3703. // return value indicates that this field was not set, or was not defined in the
  3704. // schema.
  3705. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  3706. switch name {
  3707. case allocagent.FieldCreatedAt:
  3708. return m.CreatedAt()
  3709. case allocagent.FieldUpdatedAt:
  3710. return m.UpdatedAt()
  3711. case allocagent.FieldDeletedAt:
  3712. return m.DeletedAt()
  3713. case allocagent.FieldUserID:
  3714. return m.UserID()
  3715. case allocagent.FieldOrganizationID:
  3716. return m.OrganizationID()
  3717. case allocagent.FieldAgents:
  3718. return m.Agents()
  3719. case allocagent.FieldStatus:
  3720. return m.Status()
  3721. }
  3722. return nil, false
  3723. }
  3724. // OldField returns the old value of the field from the database. An error is
  3725. // returned if the mutation operation is not UpdateOne, or the query to the
  3726. // database failed.
  3727. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3728. switch name {
  3729. case allocagent.FieldCreatedAt:
  3730. return m.OldCreatedAt(ctx)
  3731. case allocagent.FieldUpdatedAt:
  3732. return m.OldUpdatedAt(ctx)
  3733. case allocagent.FieldDeletedAt:
  3734. return m.OldDeletedAt(ctx)
  3735. case allocagent.FieldUserID:
  3736. return m.OldUserID(ctx)
  3737. case allocagent.FieldOrganizationID:
  3738. return m.OldOrganizationID(ctx)
  3739. case allocagent.FieldAgents:
  3740. return m.OldAgents(ctx)
  3741. case allocagent.FieldStatus:
  3742. return m.OldStatus(ctx)
  3743. }
  3744. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  3745. }
  3746. // SetField sets the value of a field with the given name. It returns an error if
  3747. // the field is not defined in the schema, or if the type mismatched the field
  3748. // type.
  3749. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  3750. switch name {
  3751. case allocagent.FieldCreatedAt:
  3752. v, ok := value.(time.Time)
  3753. if !ok {
  3754. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3755. }
  3756. m.SetCreatedAt(v)
  3757. return nil
  3758. case allocagent.FieldUpdatedAt:
  3759. v, ok := value.(time.Time)
  3760. if !ok {
  3761. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3762. }
  3763. m.SetUpdatedAt(v)
  3764. return nil
  3765. case allocagent.FieldDeletedAt:
  3766. v, ok := value.(time.Time)
  3767. if !ok {
  3768. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3769. }
  3770. m.SetDeletedAt(v)
  3771. return nil
  3772. case allocagent.FieldUserID:
  3773. v, ok := value.(string)
  3774. if !ok {
  3775. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3776. }
  3777. m.SetUserID(v)
  3778. return nil
  3779. case allocagent.FieldOrganizationID:
  3780. v, ok := value.(uint64)
  3781. if !ok {
  3782. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3783. }
  3784. m.SetOrganizationID(v)
  3785. return nil
  3786. case allocagent.FieldAgents:
  3787. v, ok := value.([]uint64)
  3788. if !ok {
  3789. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3790. }
  3791. m.SetAgents(v)
  3792. return nil
  3793. case allocagent.FieldStatus:
  3794. v, ok := value.(int)
  3795. if !ok {
  3796. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3797. }
  3798. m.SetStatus(v)
  3799. return nil
  3800. }
  3801. return fmt.Errorf("unknown AllocAgent field %s", name)
  3802. }
  3803. // AddedFields returns all numeric fields that were incremented/decremented during
  3804. // this mutation.
  3805. func (m *AllocAgentMutation) AddedFields() []string {
  3806. var fields []string
  3807. if m.addorganization_id != nil {
  3808. fields = append(fields, allocagent.FieldOrganizationID)
  3809. }
  3810. if m.addstatus != nil {
  3811. fields = append(fields, allocagent.FieldStatus)
  3812. }
  3813. return fields
  3814. }
  3815. // AddedField returns the numeric value that was incremented/decremented on a field
  3816. // with the given name. The second boolean return value indicates that this field
  3817. // was not set, or was not defined in the schema.
  3818. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  3819. switch name {
  3820. case allocagent.FieldOrganizationID:
  3821. return m.AddedOrganizationID()
  3822. case allocagent.FieldStatus:
  3823. return m.AddedStatus()
  3824. }
  3825. return nil, false
  3826. }
  3827. // AddField adds the value to the field with the given name. It returns an error if
  3828. // the field is not defined in the schema, or if the type mismatched the field
  3829. // type.
  3830. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  3831. switch name {
  3832. case allocagent.FieldOrganizationID:
  3833. v, ok := value.(int64)
  3834. if !ok {
  3835. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3836. }
  3837. m.AddOrganizationID(v)
  3838. return nil
  3839. case allocagent.FieldStatus:
  3840. v, ok := value.(int)
  3841. if !ok {
  3842. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3843. }
  3844. m.AddStatus(v)
  3845. return nil
  3846. }
  3847. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  3848. }
  3849. // ClearedFields returns all nullable fields that were cleared during this
  3850. // mutation.
  3851. func (m *AllocAgentMutation) ClearedFields() []string {
  3852. var fields []string
  3853. if m.FieldCleared(allocagent.FieldDeletedAt) {
  3854. fields = append(fields, allocagent.FieldDeletedAt)
  3855. }
  3856. if m.FieldCleared(allocagent.FieldUserID) {
  3857. fields = append(fields, allocagent.FieldUserID)
  3858. }
  3859. if m.FieldCleared(allocagent.FieldOrganizationID) {
  3860. fields = append(fields, allocagent.FieldOrganizationID)
  3861. }
  3862. if m.FieldCleared(allocagent.FieldStatus) {
  3863. fields = append(fields, allocagent.FieldStatus)
  3864. }
  3865. return fields
  3866. }
  3867. // FieldCleared returns a boolean indicating if a field with the given name was
  3868. // cleared in this mutation.
  3869. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  3870. _, ok := m.clearedFields[name]
  3871. return ok
  3872. }
  3873. // ClearField clears the value of the field with the given name. It returns an
  3874. // error if the field is not defined in the schema.
  3875. func (m *AllocAgentMutation) ClearField(name string) error {
  3876. switch name {
  3877. case allocagent.FieldDeletedAt:
  3878. m.ClearDeletedAt()
  3879. return nil
  3880. case allocagent.FieldUserID:
  3881. m.ClearUserID()
  3882. return nil
  3883. case allocagent.FieldOrganizationID:
  3884. m.ClearOrganizationID()
  3885. return nil
  3886. case allocagent.FieldStatus:
  3887. m.ClearStatus()
  3888. return nil
  3889. }
  3890. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  3891. }
  3892. // ResetField resets all changes in the mutation for the field with the given name.
  3893. // It returns an error if the field is not defined in the schema.
  3894. func (m *AllocAgentMutation) ResetField(name string) error {
  3895. switch name {
  3896. case allocagent.FieldCreatedAt:
  3897. m.ResetCreatedAt()
  3898. return nil
  3899. case allocagent.FieldUpdatedAt:
  3900. m.ResetUpdatedAt()
  3901. return nil
  3902. case allocagent.FieldDeletedAt:
  3903. m.ResetDeletedAt()
  3904. return nil
  3905. case allocagent.FieldUserID:
  3906. m.ResetUserID()
  3907. return nil
  3908. case allocagent.FieldOrganizationID:
  3909. m.ResetOrganizationID()
  3910. return nil
  3911. case allocagent.FieldAgents:
  3912. m.ResetAgents()
  3913. return nil
  3914. case allocagent.FieldStatus:
  3915. m.ResetStatus()
  3916. return nil
  3917. }
  3918. return fmt.Errorf("unknown AllocAgent field %s", name)
  3919. }
  3920. // AddedEdges returns all edge names that were set/added in this mutation.
  3921. func (m *AllocAgentMutation) AddedEdges() []string {
  3922. edges := make([]string, 0, 0)
  3923. return edges
  3924. }
  3925. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3926. // name in this mutation.
  3927. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  3928. return nil
  3929. }
  3930. // RemovedEdges returns all edge names that were removed in this mutation.
  3931. func (m *AllocAgentMutation) RemovedEdges() []string {
  3932. edges := make([]string, 0, 0)
  3933. return edges
  3934. }
  3935. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3936. // the given name in this mutation.
  3937. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  3938. return nil
  3939. }
  3940. // ClearedEdges returns all edge names that were cleared in this mutation.
  3941. func (m *AllocAgentMutation) ClearedEdges() []string {
  3942. edges := make([]string, 0, 0)
  3943. return edges
  3944. }
  3945. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3946. // was cleared in this mutation.
  3947. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  3948. return false
  3949. }
  3950. // ClearEdge clears the value of the edge with the given name. It returns an error
  3951. // if that edge is not defined in the schema.
  3952. func (m *AllocAgentMutation) ClearEdge(name string) error {
  3953. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  3954. }
  3955. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3956. // It returns an error if the edge is not defined in the schema.
  3957. func (m *AllocAgentMutation) ResetEdge(name string) error {
  3958. return fmt.Errorf("unknown AllocAgent edge %s", name)
  3959. }
  3960. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  3961. type BatchMsgMutation struct {
  3962. config
  3963. op Op
  3964. typ string
  3965. id *uint64
  3966. created_at *time.Time
  3967. updated_at *time.Time
  3968. deleted_at *time.Time
  3969. status *uint8
  3970. addstatus *int8
  3971. batch_no *string
  3972. task_name *string
  3973. fromwxid *string
  3974. msg *string
  3975. tag *string
  3976. tagids *string
  3977. total *int32
  3978. addtotal *int32
  3979. success *int32
  3980. addsuccess *int32
  3981. fail *int32
  3982. addfail *int32
  3983. start_time *time.Time
  3984. stop_time *time.Time
  3985. send_time *time.Time
  3986. _type *int32
  3987. add_type *int32
  3988. organization_id *uint64
  3989. addorganization_id *int64
  3990. ctype *uint64
  3991. addctype *int64
  3992. cc *string
  3993. phone *string
  3994. template_name *string
  3995. template_code *string
  3996. lang *string
  3997. clearedFields map[string]struct{}
  3998. done bool
  3999. oldValue func(context.Context) (*BatchMsg, error)
  4000. predicates []predicate.BatchMsg
  4001. }
  4002. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  4003. // batchmsgOption allows management of the mutation configuration using functional options.
  4004. type batchmsgOption func(*BatchMsgMutation)
  4005. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  4006. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  4007. m := &BatchMsgMutation{
  4008. config: c,
  4009. op: op,
  4010. typ: TypeBatchMsg,
  4011. clearedFields: make(map[string]struct{}),
  4012. }
  4013. for _, opt := range opts {
  4014. opt(m)
  4015. }
  4016. return m
  4017. }
  4018. // withBatchMsgID sets the ID field of the mutation.
  4019. func withBatchMsgID(id uint64) batchmsgOption {
  4020. return func(m *BatchMsgMutation) {
  4021. var (
  4022. err error
  4023. once sync.Once
  4024. value *BatchMsg
  4025. )
  4026. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  4027. once.Do(func() {
  4028. if m.done {
  4029. err = errors.New("querying old values post mutation is not allowed")
  4030. } else {
  4031. value, err = m.Client().BatchMsg.Get(ctx, id)
  4032. }
  4033. })
  4034. return value, err
  4035. }
  4036. m.id = &id
  4037. }
  4038. }
  4039. // withBatchMsg sets the old BatchMsg of the mutation.
  4040. func withBatchMsg(node *BatchMsg) batchmsgOption {
  4041. return func(m *BatchMsgMutation) {
  4042. m.oldValue = func(context.Context) (*BatchMsg, error) {
  4043. return node, nil
  4044. }
  4045. m.id = &node.ID
  4046. }
  4047. }
  4048. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4049. // executed in a transaction (ent.Tx), a transactional client is returned.
  4050. func (m BatchMsgMutation) Client() *Client {
  4051. client := &Client{config: m.config}
  4052. client.init()
  4053. return client
  4054. }
  4055. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4056. // it returns an error otherwise.
  4057. func (m BatchMsgMutation) Tx() (*Tx, error) {
  4058. if _, ok := m.driver.(*txDriver); !ok {
  4059. return nil, errors.New("ent: mutation is not running in a transaction")
  4060. }
  4061. tx := &Tx{config: m.config}
  4062. tx.init()
  4063. return tx, nil
  4064. }
  4065. // SetID sets the value of the id field. Note that this
  4066. // operation is only accepted on creation of BatchMsg entities.
  4067. func (m *BatchMsgMutation) SetID(id uint64) {
  4068. m.id = &id
  4069. }
  4070. // ID returns the ID value in the mutation. Note that the ID is only available
  4071. // if it was provided to the builder or after it was returned from the database.
  4072. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  4073. if m.id == nil {
  4074. return
  4075. }
  4076. return *m.id, true
  4077. }
  4078. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4079. // That means, if the mutation is applied within a transaction with an isolation level such
  4080. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4081. // or updated by the mutation.
  4082. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  4083. switch {
  4084. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4085. id, exists := m.ID()
  4086. if exists {
  4087. return []uint64{id}, nil
  4088. }
  4089. fallthrough
  4090. case m.op.Is(OpUpdate | OpDelete):
  4091. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  4092. default:
  4093. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4094. }
  4095. }
  4096. // SetCreatedAt sets the "created_at" field.
  4097. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  4098. m.created_at = &t
  4099. }
  4100. // CreatedAt returns the value of the "created_at" field in the mutation.
  4101. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  4102. v := m.created_at
  4103. if v == nil {
  4104. return
  4105. }
  4106. return *v, true
  4107. }
  4108. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  4109. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4110. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4111. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4112. if !m.op.Is(OpUpdateOne) {
  4113. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4114. }
  4115. if m.id == nil || m.oldValue == nil {
  4116. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4117. }
  4118. oldValue, err := m.oldValue(ctx)
  4119. if err != nil {
  4120. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4121. }
  4122. return oldValue.CreatedAt, nil
  4123. }
  4124. // ResetCreatedAt resets all changes to the "created_at" field.
  4125. func (m *BatchMsgMutation) ResetCreatedAt() {
  4126. m.created_at = nil
  4127. }
  4128. // SetUpdatedAt sets the "updated_at" field.
  4129. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  4130. m.updated_at = &t
  4131. }
  4132. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4133. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  4134. v := m.updated_at
  4135. if v == nil {
  4136. return
  4137. }
  4138. return *v, true
  4139. }
  4140. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  4141. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4142. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4143. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4144. if !m.op.Is(OpUpdateOne) {
  4145. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4146. }
  4147. if m.id == nil || m.oldValue == nil {
  4148. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4149. }
  4150. oldValue, err := m.oldValue(ctx)
  4151. if err != nil {
  4152. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4153. }
  4154. return oldValue.UpdatedAt, nil
  4155. }
  4156. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4157. func (m *BatchMsgMutation) ResetUpdatedAt() {
  4158. m.updated_at = nil
  4159. }
  4160. // SetDeletedAt sets the "deleted_at" field.
  4161. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  4162. m.deleted_at = &t
  4163. }
  4164. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4165. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  4166. v := m.deleted_at
  4167. if v == nil {
  4168. return
  4169. }
  4170. return *v, true
  4171. }
  4172. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  4173. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4174. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4175. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4176. if !m.op.Is(OpUpdateOne) {
  4177. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4178. }
  4179. if m.id == nil || m.oldValue == nil {
  4180. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4181. }
  4182. oldValue, err := m.oldValue(ctx)
  4183. if err != nil {
  4184. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4185. }
  4186. return oldValue.DeletedAt, nil
  4187. }
  4188. // ClearDeletedAt clears the value of the "deleted_at" field.
  4189. func (m *BatchMsgMutation) ClearDeletedAt() {
  4190. m.deleted_at = nil
  4191. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  4192. }
  4193. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4194. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  4195. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  4196. return ok
  4197. }
  4198. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4199. func (m *BatchMsgMutation) ResetDeletedAt() {
  4200. m.deleted_at = nil
  4201. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  4202. }
  4203. // SetStatus sets the "status" field.
  4204. func (m *BatchMsgMutation) SetStatus(u uint8) {
  4205. m.status = &u
  4206. m.addstatus = nil
  4207. }
  4208. // Status returns the value of the "status" field in the mutation.
  4209. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  4210. v := m.status
  4211. if v == nil {
  4212. return
  4213. }
  4214. return *v, true
  4215. }
  4216. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  4217. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4218. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4219. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  4220. if !m.op.Is(OpUpdateOne) {
  4221. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  4222. }
  4223. if m.id == nil || m.oldValue == nil {
  4224. return v, errors.New("OldStatus requires an ID field in the mutation")
  4225. }
  4226. oldValue, err := m.oldValue(ctx)
  4227. if err != nil {
  4228. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  4229. }
  4230. return oldValue.Status, nil
  4231. }
  4232. // AddStatus adds u to the "status" field.
  4233. func (m *BatchMsgMutation) AddStatus(u int8) {
  4234. if m.addstatus != nil {
  4235. *m.addstatus += u
  4236. } else {
  4237. m.addstatus = &u
  4238. }
  4239. }
  4240. // AddedStatus returns the value that was added to the "status" field in this mutation.
  4241. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  4242. v := m.addstatus
  4243. if v == nil {
  4244. return
  4245. }
  4246. return *v, true
  4247. }
  4248. // ClearStatus clears the value of the "status" field.
  4249. func (m *BatchMsgMutation) ClearStatus() {
  4250. m.status = nil
  4251. m.addstatus = nil
  4252. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  4253. }
  4254. // StatusCleared returns if the "status" field was cleared in this mutation.
  4255. func (m *BatchMsgMutation) StatusCleared() bool {
  4256. _, ok := m.clearedFields[batchmsg.FieldStatus]
  4257. return ok
  4258. }
  4259. // ResetStatus resets all changes to the "status" field.
  4260. func (m *BatchMsgMutation) ResetStatus() {
  4261. m.status = nil
  4262. m.addstatus = nil
  4263. delete(m.clearedFields, batchmsg.FieldStatus)
  4264. }
  4265. // SetBatchNo sets the "batch_no" field.
  4266. func (m *BatchMsgMutation) SetBatchNo(s string) {
  4267. m.batch_no = &s
  4268. }
  4269. // BatchNo returns the value of the "batch_no" field in the mutation.
  4270. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  4271. v := m.batch_no
  4272. if v == nil {
  4273. return
  4274. }
  4275. return *v, true
  4276. }
  4277. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  4278. // If the BatchMsg 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 *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  4281. if !m.op.Is(OpUpdateOne) {
  4282. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  4283. }
  4284. if m.id == nil || m.oldValue == nil {
  4285. return v, errors.New("OldBatchNo 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 OldBatchNo: %w", err)
  4290. }
  4291. return oldValue.BatchNo, nil
  4292. }
  4293. // ClearBatchNo clears the value of the "batch_no" field.
  4294. func (m *BatchMsgMutation) ClearBatchNo() {
  4295. m.batch_no = nil
  4296. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  4297. }
  4298. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  4299. func (m *BatchMsgMutation) BatchNoCleared() bool {
  4300. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  4301. return ok
  4302. }
  4303. // ResetBatchNo resets all changes to the "batch_no" field.
  4304. func (m *BatchMsgMutation) ResetBatchNo() {
  4305. m.batch_no = nil
  4306. delete(m.clearedFields, batchmsg.FieldBatchNo)
  4307. }
  4308. // SetTaskName sets the "task_name" field.
  4309. func (m *BatchMsgMutation) SetTaskName(s string) {
  4310. m.task_name = &s
  4311. }
  4312. // TaskName returns the value of the "task_name" field in the mutation.
  4313. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  4314. v := m.task_name
  4315. if v == nil {
  4316. return
  4317. }
  4318. return *v, true
  4319. }
  4320. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  4321. // If the BatchMsg 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 *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  4324. if !m.op.Is(OpUpdateOne) {
  4325. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  4326. }
  4327. if m.id == nil || m.oldValue == nil {
  4328. return v, errors.New("OldTaskName 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 OldTaskName: %w", err)
  4333. }
  4334. return oldValue.TaskName, nil
  4335. }
  4336. // ClearTaskName clears the value of the "task_name" field.
  4337. func (m *BatchMsgMutation) ClearTaskName() {
  4338. m.task_name = nil
  4339. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  4340. }
  4341. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  4342. func (m *BatchMsgMutation) TaskNameCleared() bool {
  4343. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  4344. return ok
  4345. }
  4346. // ResetTaskName resets all changes to the "task_name" field.
  4347. func (m *BatchMsgMutation) ResetTaskName() {
  4348. m.task_name = nil
  4349. delete(m.clearedFields, batchmsg.FieldTaskName)
  4350. }
  4351. // SetFromwxid sets the "fromwxid" field.
  4352. func (m *BatchMsgMutation) SetFromwxid(s string) {
  4353. m.fromwxid = &s
  4354. }
  4355. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  4356. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  4357. v := m.fromwxid
  4358. if v == nil {
  4359. return
  4360. }
  4361. return *v, true
  4362. }
  4363. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  4364. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4365. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4366. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  4367. if !m.op.Is(OpUpdateOne) {
  4368. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  4369. }
  4370. if m.id == nil || m.oldValue == nil {
  4371. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  4372. }
  4373. oldValue, err := m.oldValue(ctx)
  4374. if err != nil {
  4375. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  4376. }
  4377. return oldValue.Fromwxid, nil
  4378. }
  4379. // ClearFromwxid clears the value of the "fromwxid" field.
  4380. func (m *BatchMsgMutation) ClearFromwxid() {
  4381. m.fromwxid = nil
  4382. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  4383. }
  4384. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  4385. func (m *BatchMsgMutation) FromwxidCleared() bool {
  4386. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  4387. return ok
  4388. }
  4389. // ResetFromwxid resets all changes to the "fromwxid" field.
  4390. func (m *BatchMsgMutation) ResetFromwxid() {
  4391. m.fromwxid = nil
  4392. delete(m.clearedFields, batchmsg.FieldFromwxid)
  4393. }
  4394. // SetMsg sets the "msg" field.
  4395. func (m *BatchMsgMutation) SetMsg(s string) {
  4396. m.msg = &s
  4397. }
  4398. // Msg returns the value of the "msg" field in the mutation.
  4399. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  4400. v := m.msg
  4401. if v == nil {
  4402. return
  4403. }
  4404. return *v, true
  4405. }
  4406. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  4407. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4408. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4409. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  4410. if !m.op.Is(OpUpdateOne) {
  4411. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  4412. }
  4413. if m.id == nil || m.oldValue == nil {
  4414. return v, errors.New("OldMsg requires an ID field in the mutation")
  4415. }
  4416. oldValue, err := m.oldValue(ctx)
  4417. if err != nil {
  4418. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  4419. }
  4420. return oldValue.Msg, nil
  4421. }
  4422. // ClearMsg clears the value of the "msg" field.
  4423. func (m *BatchMsgMutation) ClearMsg() {
  4424. m.msg = nil
  4425. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  4426. }
  4427. // MsgCleared returns if the "msg" field was cleared in this mutation.
  4428. func (m *BatchMsgMutation) MsgCleared() bool {
  4429. _, ok := m.clearedFields[batchmsg.FieldMsg]
  4430. return ok
  4431. }
  4432. // ResetMsg resets all changes to the "msg" field.
  4433. func (m *BatchMsgMutation) ResetMsg() {
  4434. m.msg = nil
  4435. delete(m.clearedFields, batchmsg.FieldMsg)
  4436. }
  4437. // SetTag sets the "tag" field.
  4438. func (m *BatchMsgMutation) SetTag(s string) {
  4439. m.tag = &s
  4440. }
  4441. // Tag returns the value of the "tag" field in the mutation.
  4442. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  4443. v := m.tag
  4444. if v == nil {
  4445. return
  4446. }
  4447. return *v, true
  4448. }
  4449. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  4450. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4451. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4452. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  4453. if !m.op.Is(OpUpdateOne) {
  4454. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  4455. }
  4456. if m.id == nil || m.oldValue == nil {
  4457. return v, errors.New("OldTag requires an ID field in the mutation")
  4458. }
  4459. oldValue, err := m.oldValue(ctx)
  4460. if err != nil {
  4461. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  4462. }
  4463. return oldValue.Tag, nil
  4464. }
  4465. // ClearTag clears the value of the "tag" field.
  4466. func (m *BatchMsgMutation) ClearTag() {
  4467. m.tag = nil
  4468. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  4469. }
  4470. // TagCleared returns if the "tag" field was cleared in this mutation.
  4471. func (m *BatchMsgMutation) TagCleared() bool {
  4472. _, ok := m.clearedFields[batchmsg.FieldTag]
  4473. return ok
  4474. }
  4475. // ResetTag resets all changes to the "tag" field.
  4476. func (m *BatchMsgMutation) ResetTag() {
  4477. m.tag = nil
  4478. delete(m.clearedFields, batchmsg.FieldTag)
  4479. }
  4480. // SetTagids sets the "tagids" field.
  4481. func (m *BatchMsgMutation) SetTagids(s string) {
  4482. m.tagids = &s
  4483. }
  4484. // Tagids returns the value of the "tagids" field in the mutation.
  4485. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  4486. v := m.tagids
  4487. if v == nil {
  4488. return
  4489. }
  4490. return *v, true
  4491. }
  4492. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  4493. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4494. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4495. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  4496. if !m.op.Is(OpUpdateOne) {
  4497. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  4498. }
  4499. if m.id == nil || m.oldValue == nil {
  4500. return v, errors.New("OldTagids requires an ID field in the mutation")
  4501. }
  4502. oldValue, err := m.oldValue(ctx)
  4503. if err != nil {
  4504. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  4505. }
  4506. return oldValue.Tagids, nil
  4507. }
  4508. // ClearTagids clears the value of the "tagids" field.
  4509. func (m *BatchMsgMutation) ClearTagids() {
  4510. m.tagids = nil
  4511. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  4512. }
  4513. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  4514. func (m *BatchMsgMutation) TagidsCleared() bool {
  4515. _, ok := m.clearedFields[batchmsg.FieldTagids]
  4516. return ok
  4517. }
  4518. // ResetTagids resets all changes to the "tagids" field.
  4519. func (m *BatchMsgMutation) ResetTagids() {
  4520. m.tagids = nil
  4521. delete(m.clearedFields, batchmsg.FieldTagids)
  4522. }
  4523. // SetTotal sets the "total" field.
  4524. func (m *BatchMsgMutation) SetTotal(i int32) {
  4525. m.total = &i
  4526. m.addtotal = nil
  4527. }
  4528. // Total returns the value of the "total" field in the mutation.
  4529. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  4530. v := m.total
  4531. if v == nil {
  4532. return
  4533. }
  4534. return *v, true
  4535. }
  4536. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  4537. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4538. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4539. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  4540. if !m.op.Is(OpUpdateOne) {
  4541. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  4542. }
  4543. if m.id == nil || m.oldValue == nil {
  4544. return v, errors.New("OldTotal requires an ID field in the mutation")
  4545. }
  4546. oldValue, err := m.oldValue(ctx)
  4547. if err != nil {
  4548. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  4549. }
  4550. return oldValue.Total, nil
  4551. }
  4552. // AddTotal adds i to the "total" field.
  4553. func (m *BatchMsgMutation) AddTotal(i int32) {
  4554. if m.addtotal != nil {
  4555. *m.addtotal += i
  4556. } else {
  4557. m.addtotal = &i
  4558. }
  4559. }
  4560. // AddedTotal returns the value that was added to the "total" field in this mutation.
  4561. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  4562. v := m.addtotal
  4563. if v == nil {
  4564. return
  4565. }
  4566. return *v, true
  4567. }
  4568. // ClearTotal clears the value of the "total" field.
  4569. func (m *BatchMsgMutation) ClearTotal() {
  4570. m.total = nil
  4571. m.addtotal = nil
  4572. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  4573. }
  4574. // TotalCleared returns if the "total" field was cleared in this mutation.
  4575. func (m *BatchMsgMutation) TotalCleared() bool {
  4576. _, ok := m.clearedFields[batchmsg.FieldTotal]
  4577. return ok
  4578. }
  4579. // ResetTotal resets all changes to the "total" field.
  4580. func (m *BatchMsgMutation) ResetTotal() {
  4581. m.total = nil
  4582. m.addtotal = nil
  4583. delete(m.clearedFields, batchmsg.FieldTotal)
  4584. }
  4585. // SetSuccess sets the "success" field.
  4586. func (m *BatchMsgMutation) SetSuccess(i int32) {
  4587. m.success = &i
  4588. m.addsuccess = nil
  4589. }
  4590. // Success returns the value of the "success" field in the mutation.
  4591. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  4592. v := m.success
  4593. if v == nil {
  4594. return
  4595. }
  4596. return *v, true
  4597. }
  4598. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  4599. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4601. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  4602. if !m.op.Is(OpUpdateOne) {
  4603. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  4604. }
  4605. if m.id == nil || m.oldValue == nil {
  4606. return v, errors.New("OldSuccess requires an ID field in the mutation")
  4607. }
  4608. oldValue, err := m.oldValue(ctx)
  4609. if err != nil {
  4610. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  4611. }
  4612. return oldValue.Success, nil
  4613. }
  4614. // AddSuccess adds i to the "success" field.
  4615. func (m *BatchMsgMutation) AddSuccess(i int32) {
  4616. if m.addsuccess != nil {
  4617. *m.addsuccess += i
  4618. } else {
  4619. m.addsuccess = &i
  4620. }
  4621. }
  4622. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  4623. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  4624. v := m.addsuccess
  4625. if v == nil {
  4626. return
  4627. }
  4628. return *v, true
  4629. }
  4630. // ClearSuccess clears the value of the "success" field.
  4631. func (m *BatchMsgMutation) ClearSuccess() {
  4632. m.success = nil
  4633. m.addsuccess = nil
  4634. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  4635. }
  4636. // SuccessCleared returns if the "success" field was cleared in this mutation.
  4637. func (m *BatchMsgMutation) SuccessCleared() bool {
  4638. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  4639. return ok
  4640. }
  4641. // ResetSuccess resets all changes to the "success" field.
  4642. func (m *BatchMsgMutation) ResetSuccess() {
  4643. m.success = nil
  4644. m.addsuccess = nil
  4645. delete(m.clearedFields, batchmsg.FieldSuccess)
  4646. }
  4647. // SetFail sets the "fail" field.
  4648. func (m *BatchMsgMutation) SetFail(i int32) {
  4649. m.fail = &i
  4650. m.addfail = nil
  4651. }
  4652. // Fail returns the value of the "fail" field in the mutation.
  4653. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  4654. v := m.fail
  4655. if v == nil {
  4656. return
  4657. }
  4658. return *v, true
  4659. }
  4660. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  4661. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4662. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4663. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  4664. if !m.op.Is(OpUpdateOne) {
  4665. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  4666. }
  4667. if m.id == nil || m.oldValue == nil {
  4668. return v, errors.New("OldFail requires an ID field in the mutation")
  4669. }
  4670. oldValue, err := m.oldValue(ctx)
  4671. if err != nil {
  4672. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  4673. }
  4674. return oldValue.Fail, nil
  4675. }
  4676. // AddFail adds i to the "fail" field.
  4677. func (m *BatchMsgMutation) AddFail(i int32) {
  4678. if m.addfail != nil {
  4679. *m.addfail += i
  4680. } else {
  4681. m.addfail = &i
  4682. }
  4683. }
  4684. // AddedFail returns the value that was added to the "fail" field in this mutation.
  4685. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  4686. v := m.addfail
  4687. if v == nil {
  4688. return
  4689. }
  4690. return *v, true
  4691. }
  4692. // ClearFail clears the value of the "fail" field.
  4693. func (m *BatchMsgMutation) ClearFail() {
  4694. m.fail = nil
  4695. m.addfail = nil
  4696. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  4697. }
  4698. // FailCleared returns if the "fail" field was cleared in this mutation.
  4699. func (m *BatchMsgMutation) FailCleared() bool {
  4700. _, ok := m.clearedFields[batchmsg.FieldFail]
  4701. return ok
  4702. }
  4703. // ResetFail resets all changes to the "fail" field.
  4704. func (m *BatchMsgMutation) ResetFail() {
  4705. m.fail = nil
  4706. m.addfail = nil
  4707. delete(m.clearedFields, batchmsg.FieldFail)
  4708. }
  4709. // SetStartTime sets the "start_time" field.
  4710. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  4711. m.start_time = &t
  4712. }
  4713. // StartTime returns the value of the "start_time" field in the mutation.
  4714. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  4715. v := m.start_time
  4716. if v == nil {
  4717. return
  4718. }
  4719. return *v, true
  4720. }
  4721. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  4722. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4723. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4724. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  4725. if !m.op.Is(OpUpdateOne) {
  4726. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  4727. }
  4728. if m.id == nil || m.oldValue == nil {
  4729. return v, errors.New("OldStartTime requires an ID field in the mutation")
  4730. }
  4731. oldValue, err := m.oldValue(ctx)
  4732. if err != nil {
  4733. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  4734. }
  4735. return oldValue.StartTime, nil
  4736. }
  4737. // ClearStartTime clears the value of the "start_time" field.
  4738. func (m *BatchMsgMutation) ClearStartTime() {
  4739. m.start_time = nil
  4740. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  4741. }
  4742. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  4743. func (m *BatchMsgMutation) StartTimeCleared() bool {
  4744. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  4745. return ok
  4746. }
  4747. // ResetStartTime resets all changes to the "start_time" field.
  4748. func (m *BatchMsgMutation) ResetStartTime() {
  4749. m.start_time = nil
  4750. delete(m.clearedFields, batchmsg.FieldStartTime)
  4751. }
  4752. // SetStopTime sets the "stop_time" field.
  4753. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  4754. m.stop_time = &t
  4755. }
  4756. // StopTime returns the value of the "stop_time" field in the mutation.
  4757. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  4758. v := m.stop_time
  4759. if v == nil {
  4760. return
  4761. }
  4762. return *v, true
  4763. }
  4764. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  4765. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4766. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4767. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  4768. if !m.op.Is(OpUpdateOne) {
  4769. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  4770. }
  4771. if m.id == nil || m.oldValue == nil {
  4772. return v, errors.New("OldStopTime requires an ID field in the mutation")
  4773. }
  4774. oldValue, err := m.oldValue(ctx)
  4775. if err != nil {
  4776. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  4777. }
  4778. return oldValue.StopTime, nil
  4779. }
  4780. // ClearStopTime clears the value of the "stop_time" field.
  4781. func (m *BatchMsgMutation) ClearStopTime() {
  4782. m.stop_time = nil
  4783. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  4784. }
  4785. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  4786. func (m *BatchMsgMutation) StopTimeCleared() bool {
  4787. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  4788. return ok
  4789. }
  4790. // ResetStopTime resets all changes to the "stop_time" field.
  4791. func (m *BatchMsgMutation) ResetStopTime() {
  4792. m.stop_time = nil
  4793. delete(m.clearedFields, batchmsg.FieldStopTime)
  4794. }
  4795. // SetSendTime sets the "send_time" field.
  4796. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  4797. m.send_time = &t
  4798. }
  4799. // SendTime returns the value of the "send_time" field in the mutation.
  4800. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  4801. v := m.send_time
  4802. if v == nil {
  4803. return
  4804. }
  4805. return *v, true
  4806. }
  4807. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  4808. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4809. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4810. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  4811. if !m.op.Is(OpUpdateOne) {
  4812. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  4813. }
  4814. if m.id == nil || m.oldValue == nil {
  4815. return v, errors.New("OldSendTime requires an ID field in the mutation")
  4816. }
  4817. oldValue, err := m.oldValue(ctx)
  4818. if err != nil {
  4819. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  4820. }
  4821. return oldValue.SendTime, nil
  4822. }
  4823. // ClearSendTime clears the value of the "send_time" field.
  4824. func (m *BatchMsgMutation) ClearSendTime() {
  4825. m.send_time = nil
  4826. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  4827. }
  4828. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  4829. func (m *BatchMsgMutation) SendTimeCleared() bool {
  4830. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  4831. return ok
  4832. }
  4833. // ResetSendTime resets all changes to the "send_time" field.
  4834. func (m *BatchMsgMutation) ResetSendTime() {
  4835. m.send_time = nil
  4836. delete(m.clearedFields, batchmsg.FieldSendTime)
  4837. }
  4838. // SetType sets the "type" field.
  4839. func (m *BatchMsgMutation) SetType(i int32) {
  4840. m._type = &i
  4841. m.add_type = nil
  4842. }
  4843. // GetType returns the value of the "type" field in the mutation.
  4844. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  4845. v := m._type
  4846. if v == nil {
  4847. return
  4848. }
  4849. return *v, true
  4850. }
  4851. // OldType returns the old "type" field's value of the BatchMsg entity.
  4852. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4853. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4854. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  4855. if !m.op.Is(OpUpdateOne) {
  4856. return v, errors.New("OldType is only allowed on UpdateOne operations")
  4857. }
  4858. if m.id == nil || m.oldValue == nil {
  4859. return v, errors.New("OldType requires an ID field in the mutation")
  4860. }
  4861. oldValue, err := m.oldValue(ctx)
  4862. if err != nil {
  4863. return v, fmt.Errorf("querying old value for OldType: %w", err)
  4864. }
  4865. return oldValue.Type, nil
  4866. }
  4867. // AddType adds i to the "type" field.
  4868. func (m *BatchMsgMutation) AddType(i int32) {
  4869. if m.add_type != nil {
  4870. *m.add_type += i
  4871. } else {
  4872. m.add_type = &i
  4873. }
  4874. }
  4875. // AddedType returns the value that was added to the "type" field in this mutation.
  4876. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  4877. v := m.add_type
  4878. if v == nil {
  4879. return
  4880. }
  4881. return *v, true
  4882. }
  4883. // ClearType clears the value of the "type" field.
  4884. func (m *BatchMsgMutation) ClearType() {
  4885. m._type = nil
  4886. m.add_type = nil
  4887. m.clearedFields[batchmsg.FieldType] = struct{}{}
  4888. }
  4889. // TypeCleared returns if the "type" field was cleared in this mutation.
  4890. func (m *BatchMsgMutation) TypeCleared() bool {
  4891. _, ok := m.clearedFields[batchmsg.FieldType]
  4892. return ok
  4893. }
  4894. // ResetType resets all changes to the "type" field.
  4895. func (m *BatchMsgMutation) ResetType() {
  4896. m._type = nil
  4897. m.add_type = nil
  4898. delete(m.clearedFields, batchmsg.FieldType)
  4899. }
  4900. // SetOrganizationID sets the "organization_id" field.
  4901. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  4902. m.organization_id = &u
  4903. m.addorganization_id = nil
  4904. }
  4905. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4906. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  4907. v := m.organization_id
  4908. if v == nil {
  4909. return
  4910. }
  4911. return *v, true
  4912. }
  4913. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  4914. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4915. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4916. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4917. if !m.op.Is(OpUpdateOne) {
  4918. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4919. }
  4920. if m.id == nil || m.oldValue == nil {
  4921. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4922. }
  4923. oldValue, err := m.oldValue(ctx)
  4924. if err != nil {
  4925. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4926. }
  4927. return oldValue.OrganizationID, nil
  4928. }
  4929. // AddOrganizationID adds u to the "organization_id" field.
  4930. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  4931. if m.addorganization_id != nil {
  4932. *m.addorganization_id += u
  4933. } else {
  4934. m.addorganization_id = &u
  4935. }
  4936. }
  4937. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4938. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  4939. v := m.addorganization_id
  4940. if v == nil {
  4941. return
  4942. }
  4943. return *v, true
  4944. }
  4945. // ResetOrganizationID resets all changes to the "organization_id" field.
  4946. func (m *BatchMsgMutation) ResetOrganizationID() {
  4947. m.organization_id = nil
  4948. m.addorganization_id = nil
  4949. }
  4950. // SetCtype sets the "ctype" field.
  4951. func (m *BatchMsgMutation) SetCtype(u uint64) {
  4952. m.ctype = &u
  4953. m.addctype = nil
  4954. }
  4955. // Ctype returns the value of the "ctype" field in the mutation.
  4956. func (m *BatchMsgMutation) Ctype() (r uint64, exists bool) {
  4957. v := m.ctype
  4958. if v == nil {
  4959. return
  4960. }
  4961. return *v, true
  4962. }
  4963. // OldCtype returns the old "ctype" field's value of the BatchMsg entity.
  4964. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4965. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4966. func (m *BatchMsgMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  4967. if !m.op.Is(OpUpdateOne) {
  4968. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  4969. }
  4970. if m.id == nil || m.oldValue == nil {
  4971. return v, errors.New("OldCtype requires an ID field in the mutation")
  4972. }
  4973. oldValue, err := m.oldValue(ctx)
  4974. if err != nil {
  4975. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  4976. }
  4977. return oldValue.Ctype, nil
  4978. }
  4979. // AddCtype adds u to the "ctype" field.
  4980. func (m *BatchMsgMutation) AddCtype(u int64) {
  4981. if m.addctype != nil {
  4982. *m.addctype += u
  4983. } else {
  4984. m.addctype = &u
  4985. }
  4986. }
  4987. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  4988. func (m *BatchMsgMutation) AddedCtype() (r int64, exists bool) {
  4989. v := m.addctype
  4990. if v == nil {
  4991. return
  4992. }
  4993. return *v, true
  4994. }
  4995. // ResetCtype resets all changes to the "ctype" field.
  4996. func (m *BatchMsgMutation) ResetCtype() {
  4997. m.ctype = nil
  4998. m.addctype = nil
  4999. }
  5000. // SetCc sets the "cc" field.
  5001. func (m *BatchMsgMutation) SetCc(s string) {
  5002. m.cc = &s
  5003. }
  5004. // Cc returns the value of the "cc" field in the mutation.
  5005. func (m *BatchMsgMutation) Cc() (r string, exists bool) {
  5006. v := m.cc
  5007. if v == nil {
  5008. return
  5009. }
  5010. return *v, true
  5011. }
  5012. // OldCc returns the old "cc" field's value of the BatchMsg entity.
  5013. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5014. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5015. func (m *BatchMsgMutation) OldCc(ctx context.Context) (v string, err error) {
  5016. if !m.op.Is(OpUpdateOne) {
  5017. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  5018. }
  5019. if m.id == nil || m.oldValue == nil {
  5020. return v, errors.New("OldCc requires an ID field in the mutation")
  5021. }
  5022. oldValue, err := m.oldValue(ctx)
  5023. if err != nil {
  5024. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  5025. }
  5026. return oldValue.Cc, nil
  5027. }
  5028. // ClearCc clears the value of the "cc" field.
  5029. func (m *BatchMsgMutation) ClearCc() {
  5030. m.cc = nil
  5031. m.clearedFields[batchmsg.FieldCc] = struct{}{}
  5032. }
  5033. // CcCleared returns if the "cc" field was cleared in this mutation.
  5034. func (m *BatchMsgMutation) CcCleared() bool {
  5035. _, ok := m.clearedFields[batchmsg.FieldCc]
  5036. return ok
  5037. }
  5038. // ResetCc resets all changes to the "cc" field.
  5039. func (m *BatchMsgMutation) ResetCc() {
  5040. m.cc = nil
  5041. delete(m.clearedFields, batchmsg.FieldCc)
  5042. }
  5043. // SetPhone sets the "phone" field.
  5044. func (m *BatchMsgMutation) SetPhone(s string) {
  5045. m.phone = &s
  5046. }
  5047. // Phone returns the value of the "phone" field in the mutation.
  5048. func (m *BatchMsgMutation) Phone() (r string, exists bool) {
  5049. v := m.phone
  5050. if v == nil {
  5051. return
  5052. }
  5053. return *v, true
  5054. }
  5055. // OldPhone returns the old "phone" field's value of the BatchMsg entity.
  5056. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5057. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5058. func (m *BatchMsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  5059. if !m.op.Is(OpUpdateOne) {
  5060. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  5061. }
  5062. if m.id == nil || m.oldValue == nil {
  5063. return v, errors.New("OldPhone requires an ID field in the mutation")
  5064. }
  5065. oldValue, err := m.oldValue(ctx)
  5066. if err != nil {
  5067. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  5068. }
  5069. return oldValue.Phone, nil
  5070. }
  5071. // ClearPhone clears the value of the "phone" field.
  5072. func (m *BatchMsgMutation) ClearPhone() {
  5073. m.phone = nil
  5074. m.clearedFields[batchmsg.FieldPhone] = struct{}{}
  5075. }
  5076. // PhoneCleared returns if the "phone" field was cleared in this mutation.
  5077. func (m *BatchMsgMutation) PhoneCleared() bool {
  5078. _, ok := m.clearedFields[batchmsg.FieldPhone]
  5079. return ok
  5080. }
  5081. // ResetPhone resets all changes to the "phone" field.
  5082. func (m *BatchMsgMutation) ResetPhone() {
  5083. m.phone = nil
  5084. delete(m.clearedFields, batchmsg.FieldPhone)
  5085. }
  5086. // SetTemplateName sets the "template_name" field.
  5087. func (m *BatchMsgMutation) SetTemplateName(s string) {
  5088. m.template_name = &s
  5089. }
  5090. // TemplateName returns the value of the "template_name" field in the mutation.
  5091. func (m *BatchMsgMutation) TemplateName() (r string, exists bool) {
  5092. v := m.template_name
  5093. if v == nil {
  5094. return
  5095. }
  5096. return *v, true
  5097. }
  5098. // OldTemplateName returns the old "template_name" field's value of the BatchMsg entity.
  5099. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5100. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5101. func (m *BatchMsgMutation) OldTemplateName(ctx context.Context) (v string, err error) {
  5102. if !m.op.Is(OpUpdateOne) {
  5103. return v, errors.New("OldTemplateName is only allowed on UpdateOne operations")
  5104. }
  5105. if m.id == nil || m.oldValue == nil {
  5106. return v, errors.New("OldTemplateName requires an ID field in the mutation")
  5107. }
  5108. oldValue, err := m.oldValue(ctx)
  5109. if err != nil {
  5110. return v, fmt.Errorf("querying old value for OldTemplateName: %w", err)
  5111. }
  5112. return oldValue.TemplateName, nil
  5113. }
  5114. // ClearTemplateName clears the value of the "template_name" field.
  5115. func (m *BatchMsgMutation) ClearTemplateName() {
  5116. m.template_name = nil
  5117. m.clearedFields[batchmsg.FieldTemplateName] = struct{}{}
  5118. }
  5119. // TemplateNameCleared returns if the "template_name" field was cleared in this mutation.
  5120. func (m *BatchMsgMutation) TemplateNameCleared() bool {
  5121. _, ok := m.clearedFields[batchmsg.FieldTemplateName]
  5122. return ok
  5123. }
  5124. // ResetTemplateName resets all changes to the "template_name" field.
  5125. func (m *BatchMsgMutation) ResetTemplateName() {
  5126. m.template_name = nil
  5127. delete(m.clearedFields, batchmsg.FieldTemplateName)
  5128. }
  5129. // SetTemplateCode sets the "template_code" field.
  5130. func (m *BatchMsgMutation) SetTemplateCode(s string) {
  5131. m.template_code = &s
  5132. }
  5133. // TemplateCode returns the value of the "template_code" field in the mutation.
  5134. func (m *BatchMsgMutation) TemplateCode() (r string, exists bool) {
  5135. v := m.template_code
  5136. if v == nil {
  5137. return
  5138. }
  5139. return *v, true
  5140. }
  5141. // OldTemplateCode returns the old "template_code" field's value of the BatchMsg entity.
  5142. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5143. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5144. func (m *BatchMsgMutation) OldTemplateCode(ctx context.Context) (v string, err error) {
  5145. if !m.op.Is(OpUpdateOne) {
  5146. return v, errors.New("OldTemplateCode is only allowed on UpdateOne operations")
  5147. }
  5148. if m.id == nil || m.oldValue == nil {
  5149. return v, errors.New("OldTemplateCode requires an ID field in the mutation")
  5150. }
  5151. oldValue, err := m.oldValue(ctx)
  5152. if err != nil {
  5153. return v, fmt.Errorf("querying old value for OldTemplateCode: %w", err)
  5154. }
  5155. return oldValue.TemplateCode, nil
  5156. }
  5157. // ClearTemplateCode clears the value of the "template_code" field.
  5158. func (m *BatchMsgMutation) ClearTemplateCode() {
  5159. m.template_code = nil
  5160. m.clearedFields[batchmsg.FieldTemplateCode] = struct{}{}
  5161. }
  5162. // TemplateCodeCleared returns if the "template_code" field was cleared in this mutation.
  5163. func (m *BatchMsgMutation) TemplateCodeCleared() bool {
  5164. _, ok := m.clearedFields[batchmsg.FieldTemplateCode]
  5165. return ok
  5166. }
  5167. // ResetTemplateCode resets all changes to the "template_code" field.
  5168. func (m *BatchMsgMutation) ResetTemplateCode() {
  5169. m.template_code = nil
  5170. delete(m.clearedFields, batchmsg.FieldTemplateCode)
  5171. }
  5172. // SetLang sets the "lang" field.
  5173. func (m *BatchMsgMutation) SetLang(s string) {
  5174. m.lang = &s
  5175. }
  5176. // Lang returns the value of the "lang" field in the mutation.
  5177. func (m *BatchMsgMutation) Lang() (r string, exists bool) {
  5178. v := m.lang
  5179. if v == nil {
  5180. return
  5181. }
  5182. return *v, true
  5183. }
  5184. // OldLang returns the old "lang" field's value of the BatchMsg entity.
  5185. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5186. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5187. func (m *BatchMsgMutation) OldLang(ctx context.Context) (v string, err error) {
  5188. if !m.op.Is(OpUpdateOne) {
  5189. return v, errors.New("OldLang is only allowed on UpdateOne operations")
  5190. }
  5191. if m.id == nil || m.oldValue == nil {
  5192. return v, errors.New("OldLang requires an ID field in the mutation")
  5193. }
  5194. oldValue, err := m.oldValue(ctx)
  5195. if err != nil {
  5196. return v, fmt.Errorf("querying old value for OldLang: %w", err)
  5197. }
  5198. return oldValue.Lang, nil
  5199. }
  5200. // ClearLang clears the value of the "lang" field.
  5201. func (m *BatchMsgMutation) ClearLang() {
  5202. m.lang = nil
  5203. m.clearedFields[batchmsg.FieldLang] = struct{}{}
  5204. }
  5205. // LangCleared returns if the "lang" field was cleared in this mutation.
  5206. func (m *BatchMsgMutation) LangCleared() bool {
  5207. _, ok := m.clearedFields[batchmsg.FieldLang]
  5208. return ok
  5209. }
  5210. // ResetLang resets all changes to the "lang" field.
  5211. func (m *BatchMsgMutation) ResetLang() {
  5212. m.lang = nil
  5213. delete(m.clearedFields, batchmsg.FieldLang)
  5214. }
  5215. // Where appends a list predicates to the BatchMsgMutation builder.
  5216. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  5217. m.predicates = append(m.predicates, ps...)
  5218. }
  5219. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  5220. // users can use type-assertion to append predicates that do not depend on any generated package.
  5221. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  5222. p := make([]predicate.BatchMsg, len(ps))
  5223. for i := range ps {
  5224. p[i] = ps[i]
  5225. }
  5226. m.Where(p...)
  5227. }
  5228. // Op returns the operation name.
  5229. func (m *BatchMsgMutation) Op() Op {
  5230. return m.op
  5231. }
  5232. // SetOp allows setting the mutation operation.
  5233. func (m *BatchMsgMutation) SetOp(op Op) {
  5234. m.op = op
  5235. }
  5236. // Type returns the node type of this mutation (BatchMsg).
  5237. func (m *BatchMsgMutation) Type() string {
  5238. return m.typ
  5239. }
  5240. // Fields returns all fields that were changed during this mutation. Note that in
  5241. // order to get all numeric fields that were incremented/decremented, call
  5242. // AddedFields().
  5243. func (m *BatchMsgMutation) Fields() []string {
  5244. fields := make([]string, 0, 24)
  5245. if m.created_at != nil {
  5246. fields = append(fields, batchmsg.FieldCreatedAt)
  5247. }
  5248. if m.updated_at != nil {
  5249. fields = append(fields, batchmsg.FieldUpdatedAt)
  5250. }
  5251. if m.deleted_at != nil {
  5252. fields = append(fields, batchmsg.FieldDeletedAt)
  5253. }
  5254. if m.status != nil {
  5255. fields = append(fields, batchmsg.FieldStatus)
  5256. }
  5257. if m.batch_no != nil {
  5258. fields = append(fields, batchmsg.FieldBatchNo)
  5259. }
  5260. if m.task_name != nil {
  5261. fields = append(fields, batchmsg.FieldTaskName)
  5262. }
  5263. if m.fromwxid != nil {
  5264. fields = append(fields, batchmsg.FieldFromwxid)
  5265. }
  5266. if m.msg != nil {
  5267. fields = append(fields, batchmsg.FieldMsg)
  5268. }
  5269. if m.tag != nil {
  5270. fields = append(fields, batchmsg.FieldTag)
  5271. }
  5272. if m.tagids != nil {
  5273. fields = append(fields, batchmsg.FieldTagids)
  5274. }
  5275. if m.total != nil {
  5276. fields = append(fields, batchmsg.FieldTotal)
  5277. }
  5278. if m.success != nil {
  5279. fields = append(fields, batchmsg.FieldSuccess)
  5280. }
  5281. if m.fail != nil {
  5282. fields = append(fields, batchmsg.FieldFail)
  5283. }
  5284. if m.start_time != nil {
  5285. fields = append(fields, batchmsg.FieldStartTime)
  5286. }
  5287. if m.stop_time != nil {
  5288. fields = append(fields, batchmsg.FieldStopTime)
  5289. }
  5290. if m.send_time != nil {
  5291. fields = append(fields, batchmsg.FieldSendTime)
  5292. }
  5293. if m._type != nil {
  5294. fields = append(fields, batchmsg.FieldType)
  5295. }
  5296. if m.organization_id != nil {
  5297. fields = append(fields, batchmsg.FieldOrganizationID)
  5298. }
  5299. if m.ctype != nil {
  5300. fields = append(fields, batchmsg.FieldCtype)
  5301. }
  5302. if m.cc != nil {
  5303. fields = append(fields, batchmsg.FieldCc)
  5304. }
  5305. if m.phone != nil {
  5306. fields = append(fields, batchmsg.FieldPhone)
  5307. }
  5308. if m.template_name != nil {
  5309. fields = append(fields, batchmsg.FieldTemplateName)
  5310. }
  5311. if m.template_code != nil {
  5312. fields = append(fields, batchmsg.FieldTemplateCode)
  5313. }
  5314. if m.lang != nil {
  5315. fields = append(fields, batchmsg.FieldLang)
  5316. }
  5317. return fields
  5318. }
  5319. // Field returns the value of a field with the given name. The second boolean
  5320. // return value indicates that this field was not set, or was not defined in the
  5321. // schema.
  5322. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  5323. switch name {
  5324. case batchmsg.FieldCreatedAt:
  5325. return m.CreatedAt()
  5326. case batchmsg.FieldUpdatedAt:
  5327. return m.UpdatedAt()
  5328. case batchmsg.FieldDeletedAt:
  5329. return m.DeletedAt()
  5330. case batchmsg.FieldStatus:
  5331. return m.Status()
  5332. case batchmsg.FieldBatchNo:
  5333. return m.BatchNo()
  5334. case batchmsg.FieldTaskName:
  5335. return m.TaskName()
  5336. case batchmsg.FieldFromwxid:
  5337. return m.Fromwxid()
  5338. case batchmsg.FieldMsg:
  5339. return m.Msg()
  5340. case batchmsg.FieldTag:
  5341. return m.Tag()
  5342. case batchmsg.FieldTagids:
  5343. return m.Tagids()
  5344. case batchmsg.FieldTotal:
  5345. return m.Total()
  5346. case batchmsg.FieldSuccess:
  5347. return m.Success()
  5348. case batchmsg.FieldFail:
  5349. return m.Fail()
  5350. case batchmsg.FieldStartTime:
  5351. return m.StartTime()
  5352. case batchmsg.FieldStopTime:
  5353. return m.StopTime()
  5354. case batchmsg.FieldSendTime:
  5355. return m.SendTime()
  5356. case batchmsg.FieldType:
  5357. return m.GetType()
  5358. case batchmsg.FieldOrganizationID:
  5359. return m.OrganizationID()
  5360. case batchmsg.FieldCtype:
  5361. return m.Ctype()
  5362. case batchmsg.FieldCc:
  5363. return m.Cc()
  5364. case batchmsg.FieldPhone:
  5365. return m.Phone()
  5366. case batchmsg.FieldTemplateName:
  5367. return m.TemplateName()
  5368. case batchmsg.FieldTemplateCode:
  5369. return m.TemplateCode()
  5370. case batchmsg.FieldLang:
  5371. return m.Lang()
  5372. }
  5373. return nil, false
  5374. }
  5375. // OldField returns the old value of the field from the database. An error is
  5376. // returned if the mutation operation is not UpdateOne, or the query to the
  5377. // database failed.
  5378. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5379. switch name {
  5380. case batchmsg.FieldCreatedAt:
  5381. return m.OldCreatedAt(ctx)
  5382. case batchmsg.FieldUpdatedAt:
  5383. return m.OldUpdatedAt(ctx)
  5384. case batchmsg.FieldDeletedAt:
  5385. return m.OldDeletedAt(ctx)
  5386. case batchmsg.FieldStatus:
  5387. return m.OldStatus(ctx)
  5388. case batchmsg.FieldBatchNo:
  5389. return m.OldBatchNo(ctx)
  5390. case batchmsg.FieldTaskName:
  5391. return m.OldTaskName(ctx)
  5392. case batchmsg.FieldFromwxid:
  5393. return m.OldFromwxid(ctx)
  5394. case batchmsg.FieldMsg:
  5395. return m.OldMsg(ctx)
  5396. case batchmsg.FieldTag:
  5397. return m.OldTag(ctx)
  5398. case batchmsg.FieldTagids:
  5399. return m.OldTagids(ctx)
  5400. case batchmsg.FieldTotal:
  5401. return m.OldTotal(ctx)
  5402. case batchmsg.FieldSuccess:
  5403. return m.OldSuccess(ctx)
  5404. case batchmsg.FieldFail:
  5405. return m.OldFail(ctx)
  5406. case batchmsg.FieldStartTime:
  5407. return m.OldStartTime(ctx)
  5408. case batchmsg.FieldStopTime:
  5409. return m.OldStopTime(ctx)
  5410. case batchmsg.FieldSendTime:
  5411. return m.OldSendTime(ctx)
  5412. case batchmsg.FieldType:
  5413. return m.OldType(ctx)
  5414. case batchmsg.FieldOrganizationID:
  5415. return m.OldOrganizationID(ctx)
  5416. case batchmsg.FieldCtype:
  5417. return m.OldCtype(ctx)
  5418. case batchmsg.FieldCc:
  5419. return m.OldCc(ctx)
  5420. case batchmsg.FieldPhone:
  5421. return m.OldPhone(ctx)
  5422. case batchmsg.FieldTemplateName:
  5423. return m.OldTemplateName(ctx)
  5424. case batchmsg.FieldTemplateCode:
  5425. return m.OldTemplateCode(ctx)
  5426. case batchmsg.FieldLang:
  5427. return m.OldLang(ctx)
  5428. }
  5429. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  5430. }
  5431. // SetField sets the value of a field with the given name. It returns an error if
  5432. // the field is not defined in the schema, or if the type mismatched the field
  5433. // type.
  5434. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  5435. switch name {
  5436. case batchmsg.FieldCreatedAt:
  5437. v, ok := value.(time.Time)
  5438. if !ok {
  5439. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5440. }
  5441. m.SetCreatedAt(v)
  5442. return nil
  5443. case batchmsg.FieldUpdatedAt:
  5444. v, ok := value.(time.Time)
  5445. if !ok {
  5446. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5447. }
  5448. m.SetUpdatedAt(v)
  5449. return nil
  5450. case batchmsg.FieldDeletedAt:
  5451. v, ok := value.(time.Time)
  5452. if !ok {
  5453. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5454. }
  5455. m.SetDeletedAt(v)
  5456. return nil
  5457. case batchmsg.FieldStatus:
  5458. v, ok := value.(uint8)
  5459. if !ok {
  5460. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5461. }
  5462. m.SetStatus(v)
  5463. return nil
  5464. case batchmsg.FieldBatchNo:
  5465. v, ok := value.(string)
  5466. if !ok {
  5467. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5468. }
  5469. m.SetBatchNo(v)
  5470. return nil
  5471. case batchmsg.FieldTaskName:
  5472. v, ok := value.(string)
  5473. if !ok {
  5474. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5475. }
  5476. m.SetTaskName(v)
  5477. return nil
  5478. case batchmsg.FieldFromwxid:
  5479. v, ok := value.(string)
  5480. if !ok {
  5481. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5482. }
  5483. m.SetFromwxid(v)
  5484. return nil
  5485. case batchmsg.FieldMsg:
  5486. v, ok := value.(string)
  5487. if !ok {
  5488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5489. }
  5490. m.SetMsg(v)
  5491. return nil
  5492. case batchmsg.FieldTag:
  5493. v, ok := value.(string)
  5494. if !ok {
  5495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5496. }
  5497. m.SetTag(v)
  5498. return nil
  5499. case batchmsg.FieldTagids:
  5500. v, ok := value.(string)
  5501. if !ok {
  5502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5503. }
  5504. m.SetTagids(v)
  5505. return nil
  5506. case batchmsg.FieldTotal:
  5507. v, ok := value.(int32)
  5508. if !ok {
  5509. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5510. }
  5511. m.SetTotal(v)
  5512. return nil
  5513. case batchmsg.FieldSuccess:
  5514. v, ok := value.(int32)
  5515. if !ok {
  5516. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5517. }
  5518. m.SetSuccess(v)
  5519. return nil
  5520. case batchmsg.FieldFail:
  5521. v, ok := value.(int32)
  5522. if !ok {
  5523. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5524. }
  5525. m.SetFail(v)
  5526. return nil
  5527. case batchmsg.FieldStartTime:
  5528. v, ok := value.(time.Time)
  5529. if !ok {
  5530. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5531. }
  5532. m.SetStartTime(v)
  5533. return nil
  5534. case batchmsg.FieldStopTime:
  5535. v, ok := value.(time.Time)
  5536. if !ok {
  5537. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5538. }
  5539. m.SetStopTime(v)
  5540. return nil
  5541. case batchmsg.FieldSendTime:
  5542. v, ok := value.(time.Time)
  5543. if !ok {
  5544. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5545. }
  5546. m.SetSendTime(v)
  5547. return nil
  5548. case batchmsg.FieldType:
  5549. v, ok := value.(int32)
  5550. if !ok {
  5551. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5552. }
  5553. m.SetType(v)
  5554. return nil
  5555. case batchmsg.FieldOrganizationID:
  5556. v, ok := value.(uint64)
  5557. if !ok {
  5558. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5559. }
  5560. m.SetOrganizationID(v)
  5561. return nil
  5562. case batchmsg.FieldCtype:
  5563. v, ok := value.(uint64)
  5564. if !ok {
  5565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5566. }
  5567. m.SetCtype(v)
  5568. return nil
  5569. case batchmsg.FieldCc:
  5570. v, ok := value.(string)
  5571. if !ok {
  5572. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5573. }
  5574. m.SetCc(v)
  5575. return nil
  5576. case batchmsg.FieldPhone:
  5577. v, ok := value.(string)
  5578. if !ok {
  5579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5580. }
  5581. m.SetPhone(v)
  5582. return nil
  5583. case batchmsg.FieldTemplateName:
  5584. v, ok := value.(string)
  5585. if !ok {
  5586. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5587. }
  5588. m.SetTemplateName(v)
  5589. return nil
  5590. case batchmsg.FieldTemplateCode:
  5591. v, ok := value.(string)
  5592. if !ok {
  5593. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5594. }
  5595. m.SetTemplateCode(v)
  5596. return nil
  5597. case batchmsg.FieldLang:
  5598. v, ok := value.(string)
  5599. if !ok {
  5600. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5601. }
  5602. m.SetLang(v)
  5603. return nil
  5604. }
  5605. return fmt.Errorf("unknown BatchMsg field %s", name)
  5606. }
  5607. // AddedFields returns all numeric fields that were incremented/decremented during
  5608. // this mutation.
  5609. func (m *BatchMsgMutation) AddedFields() []string {
  5610. var fields []string
  5611. if m.addstatus != nil {
  5612. fields = append(fields, batchmsg.FieldStatus)
  5613. }
  5614. if m.addtotal != nil {
  5615. fields = append(fields, batchmsg.FieldTotal)
  5616. }
  5617. if m.addsuccess != nil {
  5618. fields = append(fields, batchmsg.FieldSuccess)
  5619. }
  5620. if m.addfail != nil {
  5621. fields = append(fields, batchmsg.FieldFail)
  5622. }
  5623. if m.add_type != nil {
  5624. fields = append(fields, batchmsg.FieldType)
  5625. }
  5626. if m.addorganization_id != nil {
  5627. fields = append(fields, batchmsg.FieldOrganizationID)
  5628. }
  5629. if m.addctype != nil {
  5630. fields = append(fields, batchmsg.FieldCtype)
  5631. }
  5632. return fields
  5633. }
  5634. // AddedField returns the numeric value that was incremented/decremented on a field
  5635. // with the given name. The second boolean return value indicates that this field
  5636. // was not set, or was not defined in the schema.
  5637. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  5638. switch name {
  5639. case batchmsg.FieldStatus:
  5640. return m.AddedStatus()
  5641. case batchmsg.FieldTotal:
  5642. return m.AddedTotal()
  5643. case batchmsg.FieldSuccess:
  5644. return m.AddedSuccess()
  5645. case batchmsg.FieldFail:
  5646. return m.AddedFail()
  5647. case batchmsg.FieldType:
  5648. return m.AddedType()
  5649. case batchmsg.FieldOrganizationID:
  5650. return m.AddedOrganizationID()
  5651. case batchmsg.FieldCtype:
  5652. return m.AddedCtype()
  5653. }
  5654. return nil, false
  5655. }
  5656. // AddField adds the value to the field with the given name. It returns an error if
  5657. // the field is not defined in the schema, or if the type mismatched the field
  5658. // type.
  5659. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  5660. switch name {
  5661. case batchmsg.FieldStatus:
  5662. v, ok := value.(int8)
  5663. if !ok {
  5664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5665. }
  5666. m.AddStatus(v)
  5667. return nil
  5668. case batchmsg.FieldTotal:
  5669. v, ok := value.(int32)
  5670. if !ok {
  5671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5672. }
  5673. m.AddTotal(v)
  5674. return nil
  5675. case batchmsg.FieldSuccess:
  5676. v, ok := value.(int32)
  5677. if !ok {
  5678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5679. }
  5680. m.AddSuccess(v)
  5681. return nil
  5682. case batchmsg.FieldFail:
  5683. v, ok := value.(int32)
  5684. if !ok {
  5685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5686. }
  5687. m.AddFail(v)
  5688. return nil
  5689. case batchmsg.FieldType:
  5690. v, ok := value.(int32)
  5691. if !ok {
  5692. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5693. }
  5694. m.AddType(v)
  5695. return nil
  5696. case batchmsg.FieldOrganizationID:
  5697. v, ok := value.(int64)
  5698. if !ok {
  5699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5700. }
  5701. m.AddOrganizationID(v)
  5702. return nil
  5703. case batchmsg.FieldCtype:
  5704. v, ok := value.(int64)
  5705. if !ok {
  5706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5707. }
  5708. m.AddCtype(v)
  5709. return nil
  5710. }
  5711. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  5712. }
  5713. // ClearedFields returns all nullable fields that were cleared during this
  5714. // mutation.
  5715. func (m *BatchMsgMutation) ClearedFields() []string {
  5716. var fields []string
  5717. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  5718. fields = append(fields, batchmsg.FieldDeletedAt)
  5719. }
  5720. if m.FieldCleared(batchmsg.FieldStatus) {
  5721. fields = append(fields, batchmsg.FieldStatus)
  5722. }
  5723. if m.FieldCleared(batchmsg.FieldBatchNo) {
  5724. fields = append(fields, batchmsg.FieldBatchNo)
  5725. }
  5726. if m.FieldCleared(batchmsg.FieldTaskName) {
  5727. fields = append(fields, batchmsg.FieldTaskName)
  5728. }
  5729. if m.FieldCleared(batchmsg.FieldFromwxid) {
  5730. fields = append(fields, batchmsg.FieldFromwxid)
  5731. }
  5732. if m.FieldCleared(batchmsg.FieldMsg) {
  5733. fields = append(fields, batchmsg.FieldMsg)
  5734. }
  5735. if m.FieldCleared(batchmsg.FieldTag) {
  5736. fields = append(fields, batchmsg.FieldTag)
  5737. }
  5738. if m.FieldCleared(batchmsg.FieldTagids) {
  5739. fields = append(fields, batchmsg.FieldTagids)
  5740. }
  5741. if m.FieldCleared(batchmsg.FieldTotal) {
  5742. fields = append(fields, batchmsg.FieldTotal)
  5743. }
  5744. if m.FieldCleared(batchmsg.FieldSuccess) {
  5745. fields = append(fields, batchmsg.FieldSuccess)
  5746. }
  5747. if m.FieldCleared(batchmsg.FieldFail) {
  5748. fields = append(fields, batchmsg.FieldFail)
  5749. }
  5750. if m.FieldCleared(batchmsg.FieldStartTime) {
  5751. fields = append(fields, batchmsg.FieldStartTime)
  5752. }
  5753. if m.FieldCleared(batchmsg.FieldStopTime) {
  5754. fields = append(fields, batchmsg.FieldStopTime)
  5755. }
  5756. if m.FieldCleared(batchmsg.FieldSendTime) {
  5757. fields = append(fields, batchmsg.FieldSendTime)
  5758. }
  5759. if m.FieldCleared(batchmsg.FieldType) {
  5760. fields = append(fields, batchmsg.FieldType)
  5761. }
  5762. if m.FieldCleared(batchmsg.FieldCc) {
  5763. fields = append(fields, batchmsg.FieldCc)
  5764. }
  5765. if m.FieldCleared(batchmsg.FieldPhone) {
  5766. fields = append(fields, batchmsg.FieldPhone)
  5767. }
  5768. if m.FieldCleared(batchmsg.FieldTemplateName) {
  5769. fields = append(fields, batchmsg.FieldTemplateName)
  5770. }
  5771. if m.FieldCleared(batchmsg.FieldTemplateCode) {
  5772. fields = append(fields, batchmsg.FieldTemplateCode)
  5773. }
  5774. if m.FieldCleared(batchmsg.FieldLang) {
  5775. fields = append(fields, batchmsg.FieldLang)
  5776. }
  5777. return fields
  5778. }
  5779. // FieldCleared returns a boolean indicating if a field with the given name was
  5780. // cleared in this mutation.
  5781. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  5782. _, ok := m.clearedFields[name]
  5783. return ok
  5784. }
  5785. // ClearField clears the value of the field with the given name. It returns an
  5786. // error if the field is not defined in the schema.
  5787. func (m *BatchMsgMutation) ClearField(name string) error {
  5788. switch name {
  5789. case batchmsg.FieldDeletedAt:
  5790. m.ClearDeletedAt()
  5791. return nil
  5792. case batchmsg.FieldStatus:
  5793. m.ClearStatus()
  5794. return nil
  5795. case batchmsg.FieldBatchNo:
  5796. m.ClearBatchNo()
  5797. return nil
  5798. case batchmsg.FieldTaskName:
  5799. m.ClearTaskName()
  5800. return nil
  5801. case batchmsg.FieldFromwxid:
  5802. m.ClearFromwxid()
  5803. return nil
  5804. case batchmsg.FieldMsg:
  5805. m.ClearMsg()
  5806. return nil
  5807. case batchmsg.FieldTag:
  5808. m.ClearTag()
  5809. return nil
  5810. case batchmsg.FieldTagids:
  5811. m.ClearTagids()
  5812. return nil
  5813. case batchmsg.FieldTotal:
  5814. m.ClearTotal()
  5815. return nil
  5816. case batchmsg.FieldSuccess:
  5817. m.ClearSuccess()
  5818. return nil
  5819. case batchmsg.FieldFail:
  5820. m.ClearFail()
  5821. return nil
  5822. case batchmsg.FieldStartTime:
  5823. m.ClearStartTime()
  5824. return nil
  5825. case batchmsg.FieldStopTime:
  5826. m.ClearStopTime()
  5827. return nil
  5828. case batchmsg.FieldSendTime:
  5829. m.ClearSendTime()
  5830. return nil
  5831. case batchmsg.FieldType:
  5832. m.ClearType()
  5833. return nil
  5834. case batchmsg.FieldCc:
  5835. m.ClearCc()
  5836. return nil
  5837. case batchmsg.FieldPhone:
  5838. m.ClearPhone()
  5839. return nil
  5840. case batchmsg.FieldTemplateName:
  5841. m.ClearTemplateName()
  5842. return nil
  5843. case batchmsg.FieldTemplateCode:
  5844. m.ClearTemplateCode()
  5845. return nil
  5846. case batchmsg.FieldLang:
  5847. m.ClearLang()
  5848. return nil
  5849. }
  5850. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  5851. }
  5852. // ResetField resets all changes in the mutation for the field with the given name.
  5853. // It returns an error if the field is not defined in the schema.
  5854. func (m *BatchMsgMutation) ResetField(name string) error {
  5855. switch name {
  5856. case batchmsg.FieldCreatedAt:
  5857. m.ResetCreatedAt()
  5858. return nil
  5859. case batchmsg.FieldUpdatedAt:
  5860. m.ResetUpdatedAt()
  5861. return nil
  5862. case batchmsg.FieldDeletedAt:
  5863. m.ResetDeletedAt()
  5864. return nil
  5865. case batchmsg.FieldStatus:
  5866. m.ResetStatus()
  5867. return nil
  5868. case batchmsg.FieldBatchNo:
  5869. m.ResetBatchNo()
  5870. return nil
  5871. case batchmsg.FieldTaskName:
  5872. m.ResetTaskName()
  5873. return nil
  5874. case batchmsg.FieldFromwxid:
  5875. m.ResetFromwxid()
  5876. return nil
  5877. case batchmsg.FieldMsg:
  5878. m.ResetMsg()
  5879. return nil
  5880. case batchmsg.FieldTag:
  5881. m.ResetTag()
  5882. return nil
  5883. case batchmsg.FieldTagids:
  5884. m.ResetTagids()
  5885. return nil
  5886. case batchmsg.FieldTotal:
  5887. m.ResetTotal()
  5888. return nil
  5889. case batchmsg.FieldSuccess:
  5890. m.ResetSuccess()
  5891. return nil
  5892. case batchmsg.FieldFail:
  5893. m.ResetFail()
  5894. return nil
  5895. case batchmsg.FieldStartTime:
  5896. m.ResetStartTime()
  5897. return nil
  5898. case batchmsg.FieldStopTime:
  5899. m.ResetStopTime()
  5900. return nil
  5901. case batchmsg.FieldSendTime:
  5902. m.ResetSendTime()
  5903. return nil
  5904. case batchmsg.FieldType:
  5905. m.ResetType()
  5906. return nil
  5907. case batchmsg.FieldOrganizationID:
  5908. m.ResetOrganizationID()
  5909. return nil
  5910. case batchmsg.FieldCtype:
  5911. m.ResetCtype()
  5912. return nil
  5913. case batchmsg.FieldCc:
  5914. m.ResetCc()
  5915. return nil
  5916. case batchmsg.FieldPhone:
  5917. m.ResetPhone()
  5918. return nil
  5919. case batchmsg.FieldTemplateName:
  5920. m.ResetTemplateName()
  5921. return nil
  5922. case batchmsg.FieldTemplateCode:
  5923. m.ResetTemplateCode()
  5924. return nil
  5925. case batchmsg.FieldLang:
  5926. m.ResetLang()
  5927. return nil
  5928. }
  5929. return fmt.Errorf("unknown BatchMsg field %s", name)
  5930. }
  5931. // AddedEdges returns all edge names that were set/added in this mutation.
  5932. func (m *BatchMsgMutation) AddedEdges() []string {
  5933. edges := make([]string, 0, 0)
  5934. return edges
  5935. }
  5936. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5937. // name in this mutation.
  5938. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  5939. return nil
  5940. }
  5941. // RemovedEdges returns all edge names that were removed in this mutation.
  5942. func (m *BatchMsgMutation) RemovedEdges() []string {
  5943. edges := make([]string, 0, 0)
  5944. return edges
  5945. }
  5946. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5947. // the given name in this mutation.
  5948. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  5949. return nil
  5950. }
  5951. // ClearedEdges returns all edge names that were cleared in this mutation.
  5952. func (m *BatchMsgMutation) ClearedEdges() []string {
  5953. edges := make([]string, 0, 0)
  5954. return edges
  5955. }
  5956. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5957. // was cleared in this mutation.
  5958. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  5959. return false
  5960. }
  5961. // ClearEdge clears the value of the edge with the given name. It returns an error
  5962. // if that edge is not defined in the schema.
  5963. func (m *BatchMsgMutation) ClearEdge(name string) error {
  5964. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  5965. }
  5966. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5967. // It returns an error if the edge is not defined in the schema.
  5968. func (m *BatchMsgMutation) ResetEdge(name string) error {
  5969. return fmt.Errorf("unknown BatchMsg edge %s", name)
  5970. }
  5971. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  5972. type CategoryMutation struct {
  5973. config
  5974. op Op
  5975. typ string
  5976. id *uint64
  5977. created_at *time.Time
  5978. updated_at *time.Time
  5979. deleted_at *time.Time
  5980. name *string
  5981. organization_id *uint64
  5982. addorganization_id *int64
  5983. clearedFields map[string]struct{}
  5984. done bool
  5985. oldValue func(context.Context) (*Category, error)
  5986. predicates []predicate.Category
  5987. }
  5988. var _ ent.Mutation = (*CategoryMutation)(nil)
  5989. // categoryOption allows management of the mutation configuration using functional options.
  5990. type categoryOption func(*CategoryMutation)
  5991. // newCategoryMutation creates new mutation for the Category entity.
  5992. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  5993. m := &CategoryMutation{
  5994. config: c,
  5995. op: op,
  5996. typ: TypeCategory,
  5997. clearedFields: make(map[string]struct{}),
  5998. }
  5999. for _, opt := range opts {
  6000. opt(m)
  6001. }
  6002. return m
  6003. }
  6004. // withCategoryID sets the ID field of the mutation.
  6005. func withCategoryID(id uint64) categoryOption {
  6006. return func(m *CategoryMutation) {
  6007. var (
  6008. err error
  6009. once sync.Once
  6010. value *Category
  6011. )
  6012. m.oldValue = func(ctx context.Context) (*Category, error) {
  6013. once.Do(func() {
  6014. if m.done {
  6015. err = errors.New("querying old values post mutation is not allowed")
  6016. } else {
  6017. value, err = m.Client().Category.Get(ctx, id)
  6018. }
  6019. })
  6020. return value, err
  6021. }
  6022. m.id = &id
  6023. }
  6024. }
  6025. // withCategory sets the old Category of the mutation.
  6026. func withCategory(node *Category) categoryOption {
  6027. return func(m *CategoryMutation) {
  6028. m.oldValue = func(context.Context) (*Category, error) {
  6029. return node, nil
  6030. }
  6031. m.id = &node.ID
  6032. }
  6033. }
  6034. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6035. // executed in a transaction (ent.Tx), a transactional client is returned.
  6036. func (m CategoryMutation) Client() *Client {
  6037. client := &Client{config: m.config}
  6038. client.init()
  6039. return client
  6040. }
  6041. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6042. // it returns an error otherwise.
  6043. func (m CategoryMutation) Tx() (*Tx, error) {
  6044. if _, ok := m.driver.(*txDriver); !ok {
  6045. return nil, errors.New("ent: mutation is not running in a transaction")
  6046. }
  6047. tx := &Tx{config: m.config}
  6048. tx.init()
  6049. return tx, nil
  6050. }
  6051. // SetID sets the value of the id field. Note that this
  6052. // operation is only accepted on creation of Category entities.
  6053. func (m *CategoryMutation) SetID(id uint64) {
  6054. m.id = &id
  6055. }
  6056. // ID returns the ID value in the mutation. Note that the ID is only available
  6057. // if it was provided to the builder or after it was returned from the database.
  6058. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  6059. if m.id == nil {
  6060. return
  6061. }
  6062. return *m.id, true
  6063. }
  6064. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6065. // That means, if the mutation is applied within a transaction with an isolation level such
  6066. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6067. // or updated by the mutation.
  6068. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  6069. switch {
  6070. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6071. id, exists := m.ID()
  6072. if exists {
  6073. return []uint64{id}, nil
  6074. }
  6075. fallthrough
  6076. case m.op.Is(OpUpdate | OpDelete):
  6077. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  6078. default:
  6079. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6080. }
  6081. }
  6082. // SetCreatedAt sets the "created_at" field.
  6083. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  6084. m.created_at = &t
  6085. }
  6086. // CreatedAt returns the value of the "created_at" field in the mutation.
  6087. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  6088. v := m.created_at
  6089. if v == nil {
  6090. return
  6091. }
  6092. return *v, true
  6093. }
  6094. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  6095. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  6096. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6097. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6098. if !m.op.Is(OpUpdateOne) {
  6099. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6100. }
  6101. if m.id == nil || m.oldValue == nil {
  6102. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6103. }
  6104. oldValue, err := m.oldValue(ctx)
  6105. if err != nil {
  6106. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6107. }
  6108. return oldValue.CreatedAt, nil
  6109. }
  6110. // ResetCreatedAt resets all changes to the "created_at" field.
  6111. func (m *CategoryMutation) ResetCreatedAt() {
  6112. m.created_at = nil
  6113. }
  6114. // SetUpdatedAt sets the "updated_at" field.
  6115. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  6116. m.updated_at = &t
  6117. }
  6118. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6119. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  6120. v := m.updated_at
  6121. if v == nil {
  6122. return
  6123. }
  6124. return *v, true
  6125. }
  6126. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  6127. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  6128. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6129. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6130. if !m.op.Is(OpUpdateOne) {
  6131. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6132. }
  6133. if m.id == nil || m.oldValue == nil {
  6134. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6135. }
  6136. oldValue, err := m.oldValue(ctx)
  6137. if err != nil {
  6138. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6139. }
  6140. return oldValue.UpdatedAt, nil
  6141. }
  6142. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6143. func (m *CategoryMutation) ResetUpdatedAt() {
  6144. m.updated_at = nil
  6145. }
  6146. // SetDeletedAt sets the "deleted_at" field.
  6147. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  6148. m.deleted_at = &t
  6149. }
  6150. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6151. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  6152. v := m.deleted_at
  6153. if v == nil {
  6154. return
  6155. }
  6156. return *v, true
  6157. }
  6158. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  6159. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  6160. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6161. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6162. if !m.op.Is(OpUpdateOne) {
  6163. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6164. }
  6165. if m.id == nil || m.oldValue == nil {
  6166. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6167. }
  6168. oldValue, err := m.oldValue(ctx)
  6169. if err != nil {
  6170. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6171. }
  6172. return oldValue.DeletedAt, nil
  6173. }
  6174. // ClearDeletedAt clears the value of the "deleted_at" field.
  6175. func (m *CategoryMutation) ClearDeletedAt() {
  6176. m.deleted_at = nil
  6177. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  6178. }
  6179. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6180. func (m *CategoryMutation) DeletedAtCleared() bool {
  6181. _, ok := m.clearedFields[category.FieldDeletedAt]
  6182. return ok
  6183. }
  6184. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6185. func (m *CategoryMutation) ResetDeletedAt() {
  6186. m.deleted_at = nil
  6187. delete(m.clearedFields, category.FieldDeletedAt)
  6188. }
  6189. // SetName sets the "name" field.
  6190. func (m *CategoryMutation) SetName(s string) {
  6191. m.name = &s
  6192. }
  6193. // Name returns the value of the "name" field in the mutation.
  6194. func (m *CategoryMutation) Name() (r string, exists bool) {
  6195. v := m.name
  6196. if v == nil {
  6197. return
  6198. }
  6199. return *v, true
  6200. }
  6201. // OldName returns the old "name" field's value of the Category entity.
  6202. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  6203. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6204. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  6205. if !m.op.Is(OpUpdateOne) {
  6206. return v, errors.New("OldName is only allowed on UpdateOne operations")
  6207. }
  6208. if m.id == nil || m.oldValue == nil {
  6209. return v, errors.New("OldName requires an ID field in the mutation")
  6210. }
  6211. oldValue, err := m.oldValue(ctx)
  6212. if err != nil {
  6213. return v, fmt.Errorf("querying old value for OldName: %w", err)
  6214. }
  6215. return oldValue.Name, nil
  6216. }
  6217. // ResetName resets all changes to the "name" field.
  6218. func (m *CategoryMutation) ResetName() {
  6219. m.name = nil
  6220. }
  6221. // SetOrganizationID sets the "organization_id" field.
  6222. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  6223. m.organization_id = &u
  6224. m.addorganization_id = nil
  6225. }
  6226. // OrganizationID returns the value of the "organization_id" field in the mutation.
  6227. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  6228. v := m.organization_id
  6229. if v == nil {
  6230. return
  6231. }
  6232. return *v, true
  6233. }
  6234. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  6235. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  6236. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6237. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  6238. if !m.op.Is(OpUpdateOne) {
  6239. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  6240. }
  6241. if m.id == nil || m.oldValue == nil {
  6242. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  6243. }
  6244. oldValue, err := m.oldValue(ctx)
  6245. if err != nil {
  6246. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6247. }
  6248. return oldValue.OrganizationID, nil
  6249. }
  6250. // AddOrganizationID adds u to the "organization_id" field.
  6251. func (m *CategoryMutation) AddOrganizationID(u int64) {
  6252. if m.addorganization_id != nil {
  6253. *m.addorganization_id += u
  6254. } else {
  6255. m.addorganization_id = &u
  6256. }
  6257. }
  6258. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6259. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  6260. v := m.addorganization_id
  6261. if v == nil {
  6262. return
  6263. }
  6264. return *v, true
  6265. }
  6266. // ResetOrganizationID resets all changes to the "organization_id" field.
  6267. func (m *CategoryMutation) ResetOrganizationID() {
  6268. m.organization_id = nil
  6269. m.addorganization_id = nil
  6270. }
  6271. // Where appends a list predicates to the CategoryMutation builder.
  6272. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  6273. m.predicates = append(m.predicates, ps...)
  6274. }
  6275. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  6276. // users can use type-assertion to append predicates that do not depend on any generated package.
  6277. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  6278. p := make([]predicate.Category, len(ps))
  6279. for i := range ps {
  6280. p[i] = ps[i]
  6281. }
  6282. m.Where(p...)
  6283. }
  6284. // Op returns the operation name.
  6285. func (m *CategoryMutation) Op() Op {
  6286. return m.op
  6287. }
  6288. // SetOp allows setting the mutation operation.
  6289. func (m *CategoryMutation) SetOp(op Op) {
  6290. m.op = op
  6291. }
  6292. // Type returns the node type of this mutation (Category).
  6293. func (m *CategoryMutation) Type() string {
  6294. return m.typ
  6295. }
  6296. // Fields returns all fields that were changed during this mutation. Note that in
  6297. // order to get all numeric fields that were incremented/decremented, call
  6298. // AddedFields().
  6299. func (m *CategoryMutation) Fields() []string {
  6300. fields := make([]string, 0, 5)
  6301. if m.created_at != nil {
  6302. fields = append(fields, category.FieldCreatedAt)
  6303. }
  6304. if m.updated_at != nil {
  6305. fields = append(fields, category.FieldUpdatedAt)
  6306. }
  6307. if m.deleted_at != nil {
  6308. fields = append(fields, category.FieldDeletedAt)
  6309. }
  6310. if m.name != nil {
  6311. fields = append(fields, category.FieldName)
  6312. }
  6313. if m.organization_id != nil {
  6314. fields = append(fields, category.FieldOrganizationID)
  6315. }
  6316. return fields
  6317. }
  6318. // Field returns the value of a field with the given name. The second boolean
  6319. // return value indicates that this field was not set, or was not defined in the
  6320. // schema.
  6321. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  6322. switch name {
  6323. case category.FieldCreatedAt:
  6324. return m.CreatedAt()
  6325. case category.FieldUpdatedAt:
  6326. return m.UpdatedAt()
  6327. case category.FieldDeletedAt:
  6328. return m.DeletedAt()
  6329. case category.FieldName:
  6330. return m.Name()
  6331. case category.FieldOrganizationID:
  6332. return m.OrganizationID()
  6333. }
  6334. return nil, false
  6335. }
  6336. // OldField returns the old value of the field from the database. An error is
  6337. // returned if the mutation operation is not UpdateOne, or the query to the
  6338. // database failed.
  6339. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6340. switch name {
  6341. case category.FieldCreatedAt:
  6342. return m.OldCreatedAt(ctx)
  6343. case category.FieldUpdatedAt:
  6344. return m.OldUpdatedAt(ctx)
  6345. case category.FieldDeletedAt:
  6346. return m.OldDeletedAt(ctx)
  6347. case category.FieldName:
  6348. return m.OldName(ctx)
  6349. case category.FieldOrganizationID:
  6350. return m.OldOrganizationID(ctx)
  6351. }
  6352. return nil, fmt.Errorf("unknown Category field %s", name)
  6353. }
  6354. // SetField sets the value of a field with the given name. It returns an error if
  6355. // the field is not defined in the schema, or if the type mismatched the field
  6356. // type.
  6357. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  6358. switch name {
  6359. case category.FieldCreatedAt:
  6360. v, ok := value.(time.Time)
  6361. if !ok {
  6362. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6363. }
  6364. m.SetCreatedAt(v)
  6365. return nil
  6366. case category.FieldUpdatedAt:
  6367. v, ok := value.(time.Time)
  6368. if !ok {
  6369. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6370. }
  6371. m.SetUpdatedAt(v)
  6372. return nil
  6373. case category.FieldDeletedAt:
  6374. v, ok := value.(time.Time)
  6375. if !ok {
  6376. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6377. }
  6378. m.SetDeletedAt(v)
  6379. return nil
  6380. case category.FieldName:
  6381. v, ok := value.(string)
  6382. if !ok {
  6383. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6384. }
  6385. m.SetName(v)
  6386. return nil
  6387. case category.FieldOrganizationID:
  6388. v, ok := value.(uint64)
  6389. if !ok {
  6390. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6391. }
  6392. m.SetOrganizationID(v)
  6393. return nil
  6394. }
  6395. return fmt.Errorf("unknown Category field %s", name)
  6396. }
  6397. // AddedFields returns all numeric fields that were incremented/decremented during
  6398. // this mutation.
  6399. func (m *CategoryMutation) AddedFields() []string {
  6400. var fields []string
  6401. if m.addorganization_id != nil {
  6402. fields = append(fields, category.FieldOrganizationID)
  6403. }
  6404. return fields
  6405. }
  6406. // AddedField returns the numeric value that was incremented/decremented on a field
  6407. // with the given name. The second boolean return value indicates that this field
  6408. // was not set, or was not defined in the schema.
  6409. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  6410. switch name {
  6411. case category.FieldOrganizationID:
  6412. return m.AddedOrganizationID()
  6413. }
  6414. return nil, false
  6415. }
  6416. // AddField adds the value to the field with the given name. It returns an error if
  6417. // the field is not defined in the schema, or if the type mismatched the field
  6418. // type.
  6419. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  6420. switch name {
  6421. case category.FieldOrganizationID:
  6422. v, ok := value.(int64)
  6423. if !ok {
  6424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6425. }
  6426. m.AddOrganizationID(v)
  6427. return nil
  6428. }
  6429. return fmt.Errorf("unknown Category numeric field %s", name)
  6430. }
  6431. // ClearedFields returns all nullable fields that were cleared during this
  6432. // mutation.
  6433. func (m *CategoryMutation) ClearedFields() []string {
  6434. var fields []string
  6435. if m.FieldCleared(category.FieldDeletedAt) {
  6436. fields = append(fields, category.FieldDeletedAt)
  6437. }
  6438. return fields
  6439. }
  6440. // FieldCleared returns a boolean indicating if a field with the given name was
  6441. // cleared in this mutation.
  6442. func (m *CategoryMutation) FieldCleared(name string) bool {
  6443. _, ok := m.clearedFields[name]
  6444. return ok
  6445. }
  6446. // ClearField clears the value of the field with the given name. It returns an
  6447. // error if the field is not defined in the schema.
  6448. func (m *CategoryMutation) ClearField(name string) error {
  6449. switch name {
  6450. case category.FieldDeletedAt:
  6451. m.ClearDeletedAt()
  6452. return nil
  6453. }
  6454. return fmt.Errorf("unknown Category nullable field %s", name)
  6455. }
  6456. // ResetField resets all changes in the mutation for the field with the given name.
  6457. // It returns an error if the field is not defined in the schema.
  6458. func (m *CategoryMutation) ResetField(name string) error {
  6459. switch name {
  6460. case category.FieldCreatedAt:
  6461. m.ResetCreatedAt()
  6462. return nil
  6463. case category.FieldUpdatedAt:
  6464. m.ResetUpdatedAt()
  6465. return nil
  6466. case category.FieldDeletedAt:
  6467. m.ResetDeletedAt()
  6468. return nil
  6469. case category.FieldName:
  6470. m.ResetName()
  6471. return nil
  6472. case category.FieldOrganizationID:
  6473. m.ResetOrganizationID()
  6474. return nil
  6475. }
  6476. return fmt.Errorf("unknown Category field %s", name)
  6477. }
  6478. // AddedEdges returns all edge names that were set/added in this mutation.
  6479. func (m *CategoryMutation) AddedEdges() []string {
  6480. edges := make([]string, 0, 0)
  6481. return edges
  6482. }
  6483. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6484. // name in this mutation.
  6485. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  6486. return nil
  6487. }
  6488. // RemovedEdges returns all edge names that were removed in this mutation.
  6489. func (m *CategoryMutation) RemovedEdges() []string {
  6490. edges := make([]string, 0, 0)
  6491. return edges
  6492. }
  6493. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6494. // the given name in this mutation.
  6495. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  6496. return nil
  6497. }
  6498. // ClearedEdges returns all edge names that were cleared in this mutation.
  6499. func (m *CategoryMutation) ClearedEdges() []string {
  6500. edges := make([]string, 0, 0)
  6501. return edges
  6502. }
  6503. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6504. // was cleared in this mutation.
  6505. func (m *CategoryMutation) EdgeCleared(name string) bool {
  6506. return false
  6507. }
  6508. // ClearEdge clears the value of the edge with the given name. It returns an error
  6509. // if that edge is not defined in the schema.
  6510. func (m *CategoryMutation) ClearEdge(name string) error {
  6511. return fmt.Errorf("unknown Category unique edge %s", name)
  6512. }
  6513. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6514. // It returns an error if the edge is not defined in the schema.
  6515. func (m *CategoryMutation) ResetEdge(name string) error {
  6516. return fmt.Errorf("unknown Category edge %s", name)
  6517. }
  6518. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  6519. type ChatRecordsMutation struct {
  6520. config
  6521. op Op
  6522. typ string
  6523. id *uint64
  6524. created_at *time.Time
  6525. updated_at *time.Time
  6526. deleted_at *time.Time
  6527. content *string
  6528. content_type *uint8
  6529. addcontent_type *int8
  6530. session_id *uint64
  6531. addsession_id *int64
  6532. user_id *uint64
  6533. adduser_id *int64
  6534. bot_id *uint64
  6535. addbot_id *int64
  6536. bot_type *uint8
  6537. addbot_type *int8
  6538. clearedFields map[string]struct{}
  6539. done bool
  6540. oldValue func(context.Context) (*ChatRecords, error)
  6541. predicates []predicate.ChatRecords
  6542. }
  6543. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  6544. // chatrecordsOption allows management of the mutation configuration using functional options.
  6545. type chatrecordsOption func(*ChatRecordsMutation)
  6546. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  6547. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  6548. m := &ChatRecordsMutation{
  6549. config: c,
  6550. op: op,
  6551. typ: TypeChatRecords,
  6552. clearedFields: make(map[string]struct{}),
  6553. }
  6554. for _, opt := range opts {
  6555. opt(m)
  6556. }
  6557. return m
  6558. }
  6559. // withChatRecordsID sets the ID field of the mutation.
  6560. func withChatRecordsID(id uint64) chatrecordsOption {
  6561. return func(m *ChatRecordsMutation) {
  6562. var (
  6563. err error
  6564. once sync.Once
  6565. value *ChatRecords
  6566. )
  6567. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  6568. once.Do(func() {
  6569. if m.done {
  6570. err = errors.New("querying old values post mutation is not allowed")
  6571. } else {
  6572. value, err = m.Client().ChatRecords.Get(ctx, id)
  6573. }
  6574. })
  6575. return value, err
  6576. }
  6577. m.id = &id
  6578. }
  6579. }
  6580. // withChatRecords sets the old ChatRecords of the mutation.
  6581. func withChatRecords(node *ChatRecords) chatrecordsOption {
  6582. return func(m *ChatRecordsMutation) {
  6583. m.oldValue = func(context.Context) (*ChatRecords, error) {
  6584. return node, nil
  6585. }
  6586. m.id = &node.ID
  6587. }
  6588. }
  6589. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6590. // executed in a transaction (ent.Tx), a transactional client is returned.
  6591. func (m ChatRecordsMutation) Client() *Client {
  6592. client := &Client{config: m.config}
  6593. client.init()
  6594. return client
  6595. }
  6596. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6597. // it returns an error otherwise.
  6598. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  6599. if _, ok := m.driver.(*txDriver); !ok {
  6600. return nil, errors.New("ent: mutation is not running in a transaction")
  6601. }
  6602. tx := &Tx{config: m.config}
  6603. tx.init()
  6604. return tx, nil
  6605. }
  6606. // SetID sets the value of the id field. Note that this
  6607. // operation is only accepted on creation of ChatRecords entities.
  6608. func (m *ChatRecordsMutation) SetID(id uint64) {
  6609. m.id = &id
  6610. }
  6611. // ID returns the ID value in the mutation. Note that the ID is only available
  6612. // if it was provided to the builder or after it was returned from the database.
  6613. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  6614. if m.id == nil {
  6615. return
  6616. }
  6617. return *m.id, true
  6618. }
  6619. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6620. // That means, if the mutation is applied within a transaction with an isolation level such
  6621. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6622. // or updated by the mutation.
  6623. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  6624. switch {
  6625. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6626. id, exists := m.ID()
  6627. if exists {
  6628. return []uint64{id}, nil
  6629. }
  6630. fallthrough
  6631. case m.op.Is(OpUpdate | OpDelete):
  6632. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  6633. default:
  6634. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6635. }
  6636. }
  6637. // SetCreatedAt sets the "created_at" field.
  6638. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  6639. m.created_at = &t
  6640. }
  6641. // CreatedAt returns the value of the "created_at" field in the mutation.
  6642. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  6643. v := m.created_at
  6644. if v == nil {
  6645. return
  6646. }
  6647. return *v, true
  6648. }
  6649. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  6650. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6652. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6653. if !m.op.Is(OpUpdateOne) {
  6654. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6655. }
  6656. if m.id == nil || m.oldValue == nil {
  6657. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6658. }
  6659. oldValue, err := m.oldValue(ctx)
  6660. if err != nil {
  6661. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6662. }
  6663. return oldValue.CreatedAt, nil
  6664. }
  6665. // ResetCreatedAt resets all changes to the "created_at" field.
  6666. func (m *ChatRecordsMutation) ResetCreatedAt() {
  6667. m.created_at = nil
  6668. }
  6669. // SetUpdatedAt sets the "updated_at" field.
  6670. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  6671. m.updated_at = &t
  6672. }
  6673. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6674. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  6675. v := m.updated_at
  6676. if v == nil {
  6677. return
  6678. }
  6679. return *v, true
  6680. }
  6681. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  6682. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6683. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6684. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6685. if !m.op.Is(OpUpdateOne) {
  6686. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6687. }
  6688. if m.id == nil || m.oldValue == nil {
  6689. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6690. }
  6691. oldValue, err := m.oldValue(ctx)
  6692. if err != nil {
  6693. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6694. }
  6695. return oldValue.UpdatedAt, nil
  6696. }
  6697. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6698. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  6699. m.updated_at = nil
  6700. }
  6701. // SetDeletedAt sets the "deleted_at" field.
  6702. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  6703. m.deleted_at = &t
  6704. }
  6705. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6706. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  6707. v := m.deleted_at
  6708. if v == nil {
  6709. return
  6710. }
  6711. return *v, true
  6712. }
  6713. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  6714. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6715. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6716. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6717. if !m.op.Is(OpUpdateOne) {
  6718. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6719. }
  6720. if m.id == nil || m.oldValue == nil {
  6721. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6722. }
  6723. oldValue, err := m.oldValue(ctx)
  6724. if err != nil {
  6725. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6726. }
  6727. return oldValue.DeletedAt, nil
  6728. }
  6729. // ClearDeletedAt clears the value of the "deleted_at" field.
  6730. func (m *ChatRecordsMutation) ClearDeletedAt() {
  6731. m.deleted_at = nil
  6732. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  6733. }
  6734. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6735. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  6736. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  6737. return ok
  6738. }
  6739. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6740. func (m *ChatRecordsMutation) ResetDeletedAt() {
  6741. m.deleted_at = nil
  6742. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  6743. }
  6744. // SetContent sets the "content" field.
  6745. func (m *ChatRecordsMutation) SetContent(s string) {
  6746. m.content = &s
  6747. }
  6748. // Content returns the value of the "content" field in the mutation.
  6749. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  6750. v := m.content
  6751. if v == nil {
  6752. return
  6753. }
  6754. return *v, true
  6755. }
  6756. // OldContent returns the old "content" field's value of the ChatRecords entity.
  6757. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6758. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6759. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  6760. if !m.op.Is(OpUpdateOne) {
  6761. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  6762. }
  6763. if m.id == nil || m.oldValue == nil {
  6764. return v, errors.New("OldContent requires an ID field in the mutation")
  6765. }
  6766. oldValue, err := m.oldValue(ctx)
  6767. if err != nil {
  6768. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  6769. }
  6770. return oldValue.Content, nil
  6771. }
  6772. // ResetContent resets all changes to the "content" field.
  6773. func (m *ChatRecordsMutation) ResetContent() {
  6774. m.content = nil
  6775. }
  6776. // SetContentType sets the "content_type" field.
  6777. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  6778. m.content_type = &u
  6779. m.addcontent_type = nil
  6780. }
  6781. // ContentType returns the value of the "content_type" field in the mutation.
  6782. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  6783. v := m.content_type
  6784. if v == nil {
  6785. return
  6786. }
  6787. return *v, true
  6788. }
  6789. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  6790. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6791. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6792. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  6793. if !m.op.Is(OpUpdateOne) {
  6794. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  6795. }
  6796. if m.id == nil || m.oldValue == nil {
  6797. return v, errors.New("OldContentType requires an ID field in the mutation")
  6798. }
  6799. oldValue, err := m.oldValue(ctx)
  6800. if err != nil {
  6801. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  6802. }
  6803. return oldValue.ContentType, nil
  6804. }
  6805. // AddContentType adds u to the "content_type" field.
  6806. func (m *ChatRecordsMutation) AddContentType(u int8) {
  6807. if m.addcontent_type != nil {
  6808. *m.addcontent_type += u
  6809. } else {
  6810. m.addcontent_type = &u
  6811. }
  6812. }
  6813. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  6814. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  6815. v := m.addcontent_type
  6816. if v == nil {
  6817. return
  6818. }
  6819. return *v, true
  6820. }
  6821. // ResetContentType resets all changes to the "content_type" field.
  6822. func (m *ChatRecordsMutation) ResetContentType() {
  6823. m.content_type = nil
  6824. m.addcontent_type = nil
  6825. }
  6826. // SetSessionID sets the "session_id" field.
  6827. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  6828. m.session_id = &u
  6829. m.addsession_id = nil
  6830. }
  6831. // SessionID returns the value of the "session_id" field in the mutation.
  6832. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  6833. v := m.session_id
  6834. if v == nil {
  6835. return
  6836. }
  6837. return *v, true
  6838. }
  6839. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  6840. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6841. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6842. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  6843. if !m.op.Is(OpUpdateOne) {
  6844. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  6845. }
  6846. if m.id == nil || m.oldValue == nil {
  6847. return v, errors.New("OldSessionID requires an ID field in the mutation")
  6848. }
  6849. oldValue, err := m.oldValue(ctx)
  6850. if err != nil {
  6851. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  6852. }
  6853. return oldValue.SessionID, nil
  6854. }
  6855. // AddSessionID adds u to the "session_id" field.
  6856. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  6857. if m.addsession_id != nil {
  6858. *m.addsession_id += u
  6859. } else {
  6860. m.addsession_id = &u
  6861. }
  6862. }
  6863. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  6864. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  6865. v := m.addsession_id
  6866. if v == nil {
  6867. return
  6868. }
  6869. return *v, true
  6870. }
  6871. // ResetSessionID resets all changes to the "session_id" field.
  6872. func (m *ChatRecordsMutation) ResetSessionID() {
  6873. m.session_id = nil
  6874. m.addsession_id = nil
  6875. }
  6876. // SetUserID sets the "user_id" field.
  6877. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  6878. m.user_id = &u
  6879. m.adduser_id = nil
  6880. }
  6881. // UserID returns the value of the "user_id" field in the mutation.
  6882. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  6883. v := m.user_id
  6884. if v == nil {
  6885. return
  6886. }
  6887. return *v, true
  6888. }
  6889. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  6890. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6891. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6892. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  6893. if !m.op.Is(OpUpdateOne) {
  6894. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  6895. }
  6896. if m.id == nil || m.oldValue == nil {
  6897. return v, errors.New("OldUserID requires an ID field in the mutation")
  6898. }
  6899. oldValue, err := m.oldValue(ctx)
  6900. if err != nil {
  6901. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  6902. }
  6903. return oldValue.UserID, nil
  6904. }
  6905. // AddUserID adds u to the "user_id" field.
  6906. func (m *ChatRecordsMutation) AddUserID(u int64) {
  6907. if m.adduser_id != nil {
  6908. *m.adduser_id += u
  6909. } else {
  6910. m.adduser_id = &u
  6911. }
  6912. }
  6913. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  6914. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  6915. v := m.adduser_id
  6916. if v == nil {
  6917. return
  6918. }
  6919. return *v, true
  6920. }
  6921. // ResetUserID resets all changes to the "user_id" field.
  6922. func (m *ChatRecordsMutation) ResetUserID() {
  6923. m.user_id = nil
  6924. m.adduser_id = nil
  6925. }
  6926. // SetBotID sets the "bot_id" field.
  6927. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  6928. m.bot_id = &u
  6929. m.addbot_id = nil
  6930. }
  6931. // BotID returns the value of the "bot_id" field in the mutation.
  6932. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  6933. v := m.bot_id
  6934. if v == nil {
  6935. return
  6936. }
  6937. return *v, true
  6938. }
  6939. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  6940. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6941. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6942. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  6943. if !m.op.Is(OpUpdateOne) {
  6944. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  6945. }
  6946. if m.id == nil || m.oldValue == nil {
  6947. return v, errors.New("OldBotID requires an ID field in the mutation")
  6948. }
  6949. oldValue, err := m.oldValue(ctx)
  6950. if err != nil {
  6951. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  6952. }
  6953. return oldValue.BotID, nil
  6954. }
  6955. // AddBotID adds u to the "bot_id" field.
  6956. func (m *ChatRecordsMutation) AddBotID(u int64) {
  6957. if m.addbot_id != nil {
  6958. *m.addbot_id += u
  6959. } else {
  6960. m.addbot_id = &u
  6961. }
  6962. }
  6963. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  6964. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  6965. v := m.addbot_id
  6966. if v == nil {
  6967. return
  6968. }
  6969. return *v, true
  6970. }
  6971. // ResetBotID resets all changes to the "bot_id" field.
  6972. func (m *ChatRecordsMutation) ResetBotID() {
  6973. m.bot_id = nil
  6974. m.addbot_id = nil
  6975. }
  6976. // SetBotType sets the "bot_type" field.
  6977. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  6978. m.bot_type = &u
  6979. m.addbot_type = nil
  6980. }
  6981. // BotType returns the value of the "bot_type" field in the mutation.
  6982. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  6983. v := m.bot_type
  6984. if v == nil {
  6985. return
  6986. }
  6987. return *v, true
  6988. }
  6989. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  6990. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6991. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6992. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  6993. if !m.op.Is(OpUpdateOne) {
  6994. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  6995. }
  6996. if m.id == nil || m.oldValue == nil {
  6997. return v, errors.New("OldBotType requires an ID field in the mutation")
  6998. }
  6999. oldValue, err := m.oldValue(ctx)
  7000. if err != nil {
  7001. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  7002. }
  7003. return oldValue.BotType, nil
  7004. }
  7005. // AddBotType adds u to the "bot_type" field.
  7006. func (m *ChatRecordsMutation) AddBotType(u int8) {
  7007. if m.addbot_type != nil {
  7008. *m.addbot_type += u
  7009. } else {
  7010. m.addbot_type = &u
  7011. }
  7012. }
  7013. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  7014. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  7015. v := m.addbot_type
  7016. if v == nil {
  7017. return
  7018. }
  7019. return *v, true
  7020. }
  7021. // ResetBotType resets all changes to the "bot_type" field.
  7022. func (m *ChatRecordsMutation) ResetBotType() {
  7023. m.bot_type = nil
  7024. m.addbot_type = nil
  7025. }
  7026. // Where appends a list predicates to the ChatRecordsMutation builder.
  7027. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  7028. m.predicates = append(m.predicates, ps...)
  7029. }
  7030. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  7031. // users can use type-assertion to append predicates that do not depend on any generated package.
  7032. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  7033. p := make([]predicate.ChatRecords, len(ps))
  7034. for i := range ps {
  7035. p[i] = ps[i]
  7036. }
  7037. m.Where(p...)
  7038. }
  7039. // Op returns the operation name.
  7040. func (m *ChatRecordsMutation) Op() Op {
  7041. return m.op
  7042. }
  7043. // SetOp allows setting the mutation operation.
  7044. func (m *ChatRecordsMutation) SetOp(op Op) {
  7045. m.op = op
  7046. }
  7047. // Type returns the node type of this mutation (ChatRecords).
  7048. func (m *ChatRecordsMutation) Type() string {
  7049. return m.typ
  7050. }
  7051. // Fields returns all fields that were changed during this mutation. Note that in
  7052. // order to get all numeric fields that were incremented/decremented, call
  7053. // AddedFields().
  7054. func (m *ChatRecordsMutation) Fields() []string {
  7055. fields := make([]string, 0, 9)
  7056. if m.created_at != nil {
  7057. fields = append(fields, chatrecords.FieldCreatedAt)
  7058. }
  7059. if m.updated_at != nil {
  7060. fields = append(fields, chatrecords.FieldUpdatedAt)
  7061. }
  7062. if m.deleted_at != nil {
  7063. fields = append(fields, chatrecords.FieldDeletedAt)
  7064. }
  7065. if m.content != nil {
  7066. fields = append(fields, chatrecords.FieldContent)
  7067. }
  7068. if m.content_type != nil {
  7069. fields = append(fields, chatrecords.FieldContentType)
  7070. }
  7071. if m.session_id != nil {
  7072. fields = append(fields, chatrecords.FieldSessionID)
  7073. }
  7074. if m.user_id != nil {
  7075. fields = append(fields, chatrecords.FieldUserID)
  7076. }
  7077. if m.bot_id != nil {
  7078. fields = append(fields, chatrecords.FieldBotID)
  7079. }
  7080. if m.bot_type != nil {
  7081. fields = append(fields, chatrecords.FieldBotType)
  7082. }
  7083. return fields
  7084. }
  7085. // Field returns the value of a field with the given name. The second boolean
  7086. // return value indicates that this field was not set, or was not defined in the
  7087. // schema.
  7088. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  7089. switch name {
  7090. case chatrecords.FieldCreatedAt:
  7091. return m.CreatedAt()
  7092. case chatrecords.FieldUpdatedAt:
  7093. return m.UpdatedAt()
  7094. case chatrecords.FieldDeletedAt:
  7095. return m.DeletedAt()
  7096. case chatrecords.FieldContent:
  7097. return m.Content()
  7098. case chatrecords.FieldContentType:
  7099. return m.ContentType()
  7100. case chatrecords.FieldSessionID:
  7101. return m.SessionID()
  7102. case chatrecords.FieldUserID:
  7103. return m.UserID()
  7104. case chatrecords.FieldBotID:
  7105. return m.BotID()
  7106. case chatrecords.FieldBotType:
  7107. return m.BotType()
  7108. }
  7109. return nil, false
  7110. }
  7111. // OldField returns the old value of the field from the database. An error is
  7112. // returned if the mutation operation is not UpdateOne, or the query to the
  7113. // database failed.
  7114. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7115. switch name {
  7116. case chatrecords.FieldCreatedAt:
  7117. return m.OldCreatedAt(ctx)
  7118. case chatrecords.FieldUpdatedAt:
  7119. return m.OldUpdatedAt(ctx)
  7120. case chatrecords.FieldDeletedAt:
  7121. return m.OldDeletedAt(ctx)
  7122. case chatrecords.FieldContent:
  7123. return m.OldContent(ctx)
  7124. case chatrecords.FieldContentType:
  7125. return m.OldContentType(ctx)
  7126. case chatrecords.FieldSessionID:
  7127. return m.OldSessionID(ctx)
  7128. case chatrecords.FieldUserID:
  7129. return m.OldUserID(ctx)
  7130. case chatrecords.FieldBotID:
  7131. return m.OldBotID(ctx)
  7132. case chatrecords.FieldBotType:
  7133. return m.OldBotType(ctx)
  7134. }
  7135. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  7136. }
  7137. // SetField sets the value of a field with the given name. It returns an error if
  7138. // the field is not defined in the schema, or if the type mismatched the field
  7139. // type.
  7140. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  7141. switch name {
  7142. case chatrecords.FieldCreatedAt:
  7143. v, ok := value.(time.Time)
  7144. if !ok {
  7145. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7146. }
  7147. m.SetCreatedAt(v)
  7148. return nil
  7149. case chatrecords.FieldUpdatedAt:
  7150. v, ok := value.(time.Time)
  7151. if !ok {
  7152. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7153. }
  7154. m.SetUpdatedAt(v)
  7155. return nil
  7156. case chatrecords.FieldDeletedAt:
  7157. v, ok := value.(time.Time)
  7158. if !ok {
  7159. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7160. }
  7161. m.SetDeletedAt(v)
  7162. return nil
  7163. case chatrecords.FieldContent:
  7164. v, ok := value.(string)
  7165. if !ok {
  7166. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7167. }
  7168. m.SetContent(v)
  7169. return nil
  7170. case chatrecords.FieldContentType:
  7171. v, ok := value.(uint8)
  7172. if !ok {
  7173. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7174. }
  7175. m.SetContentType(v)
  7176. return nil
  7177. case chatrecords.FieldSessionID:
  7178. v, ok := value.(uint64)
  7179. if !ok {
  7180. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7181. }
  7182. m.SetSessionID(v)
  7183. return nil
  7184. case chatrecords.FieldUserID:
  7185. v, ok := value.(uint64)
  7186. if !ok {
  7187. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7188. }
  7189. m.SetUserID(v)
  7190. return nil
  7191. case chatrecords.FieldBotID:
  7192. v, ok := value.(uint64)
  7193. if !ok {
  7194. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7195. }
  7196. m.SetBotID(v)
  7197. return nil
  7198. case chatrecords.FieldBotType:
  7199. v, ok := value.(uint8)
  7200. if !ok {
  7201. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7202. }
  7203. m.SetBotType(v)
  7204. return nil
  7205. }
  7206. return fmt.Errorf("unknown ChatRecords field %s", name)
  7207. }
  7208. // AddedFields returns all numeric fields that were incremented/decremented during
  7209. // this mutation.
  7210. func (m *ChatRecordsMutation) AddedFields() []string {
  7211. var fields []string
  7212. if m.addcontent_type != nil {
  7213. fields = append(fields, chatrecords.FieldContentType)
  7214. }
  7215. if m.addsession_id != nil {
  7216. fields = append(fields, chatrecords.FieldSessionID)
  7217. }
  7218. if m.adduser_id != nil {
  7219. fields = append(fields, chatrecords.FieldUserID)
  7220. }
  7221. if m.addbot_id != nil {
  7222. fields = append(fields, chatrecords.FieldBotID)
  7223. }
  7224. if m.addbot_type != nil {
  7225. fields = append(fields, chatrecords.FieldBotType)
  7226. }
  7227. return fields
  7228. }
  7229. // AddedField returns the numeric value that was incremented/decremented on a field
  7230. // with the given name. The second boolean return value indicates that this field
  7231. // was not set, or was not defined in the schema.
  7232. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  7233. switch name {
  7234. case chatrecords.FieldContentType:
  7235. return m.AddedContentType()
  7236. case chatrecords.FieldSessionID:
  7237. return m.AddedSessionID()
  7238. case chatrecords.FieldUserID:
  7239. return m.AddedUserID()
  7240. case chatrecords.FieldBotID:
  7241. return m.AddedBotID()
  7242. case chatrecords.FieldBotType:
  7243. return m.AddedBotType()
  7244. }
  7245. return nil, false
  7246. }
  7247. // AddField adds the value to the field with the given name. It returns an error if
  7248. // the field is not defined in the schema, or if the type mismatched the field
  7249. // type.
  7250. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  7251. switch name {
  7252. case chatrecords.FieldContentType:
  7253. v, ok := value.(int8)
  7254. if !ok {
  7255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7256. }
  7257. m.AddContentType(v)
  7258. return nil
  7259. case chatrecords.FieldSessionID:
  7260. v, ok := value.(int64)
  7261. if !ok {
  7262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7263. }
  7264. m.AddSessionID(v)
  7265. return nil
  7266. case chatrecords.FieldUserID:
  7267. v, ok := value.(int64)
  7268. if !ok {
  7269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7270. }
  7271. m.AddUserID(v)
  7272. return nil
  7273. case chatrecords.FieldBotID:
  7274. v, ok := value.(int64)
  7275. if !ok {
  7276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7277. }
  7278. m.AddBotID(v)
  7279. return nil
  7280. case chatrecords.FieldBotType:
  7281. v, ok := value.(int8)
  7282. if !ok {
  7283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7284. }
  7285. m.AddBotType(v)
  7286. return nil
  7287. }
  7288. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  7289. }
  7290. // ClearedFields returns all nullable fields that were cleared during this
  7291. // mutation.
  7292. func (m *ChatRecordsMutation) ClearedFields() []string {
  7293. var fields []string
  7294. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  7295. fields = append(fields, chatrecords.FieldDeletedAt)
  7296. }
  7297. return fields
  7298. }
  7299. // FieldCleared returns a boolean indicating if a field with the given name was
  7300. // cleared in this mutation.
  7301. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  7302. _, ok := m.clearedFields[name]
  7303. return ok
  7304. }
  7305. // ClearField clears the value of the field with the given name. It returns an
  7306. // error if the field is not defined in the schema.
  7307. func (m *ChatRecordsMutation) ClearField(name string) error {
  7308. switch name {
  7309. case chatrecords.FieldDeletedAt:
  7310. m.ClearDeletedAt()
  7311. return nil
  7312. }
  7313. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  7314. }
  7315. // ResetField resets all changes in the mutation for the field with the given name.
  7316. // It returns an error if the field is not defined in the schema.
  7317. func (m *ChatRecordsMutation) ResetField(name string) error {
  7318. switch name {
  7319. case chatrecords.FieldCreatedAt:
  7320. m.ResetCreatedAt()
  7321. return nil
  7322. case chatrecords.FieldUpdatedAt:
  7323. m.ResetUpdatedAt()
  7324. return nil
  7325. case chatrecords.FieldDeletedAt:
  7326. m.ResetDeletedAt()
  7327. return nil
  7328. case chatrecords.FieldContent:
  7329. m.ResetContent()
  7330. return nil
  7331. case chatrecords.FieldContentType:
  7332. m.ResetContentType()
  7333. return nil
  7334. case chatrecords.FieldSessionID:
  7335. m.ResetSessionID()
  7336. return nil
  7337. case chatrecords.FieldUserID:
  7338. m.ResetUserID()
  7339. return nil
  7340. case chatrecords.FieldBotID:
  7341. m.ResetBotID()
  7342. return nil
  7343. case chatrecords.FieldBotType:
  7344. m.ResetBotType()
  7345. return nil
  7346. }
  7347. return fmt.Errorf("unknown ChatRecords field %s", name)
  7348. }
  7349. // AddedEdges returns all edge names that were set/added in this mutation.
  7350. func (m *ChatRecordsMutation) AddedEdges() []string {
  7351. edges := make([]string, 0, 0)
  7352. return edges
  7353. }
  7354. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7355. // name in this mutation.
  7356. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  7357. return nil
  7358. }
  7359. // RemovedEdges returns all edge names that were removed in this mutation.
  7360. func (m *ChatRecordsMutation) RemovedEdges() []string {
  7361. edges := make([]string, 0, 0)
  7362. return edges
  7363. }
  7364. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7365. // the given name in this mutation.
  7366. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  7367. return nil
  7368. }
  7369. // ClearedEdges returns all edge names that were cleared in this mutation.
  7370. func (m *ChatRecordsMutation) ClearedEdges() []string {
  7371. edges := make([]string, 0, 0)
  7372. return edges
  7373. }
  7374. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7375. // was cleared in this mutation.
  7376. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  7377. return false
  7378. }
  7379. // ClearEdge clears the value of the edge with the given name. It returns an error
  7380. // if that edge is not defined in the schema.
  7381. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  7382. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  7383. }
  7384. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7385. // It returns an error if the edge is not defined in the schema.
  7386. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  7387. return fmt.Errorf("unknown ChatRecords edge %s", name)
  7388. }
  7389. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  7390. type ChatSessionMutation struct {
  7391. config
  7392. op Op
  7393. typ string
  7394. id *uint64
  7395. created_at *time.Time
  7396. updated_at *time.Time
  7397. deleted_at *time.Time
  7398. name *string
  7399. user_id *uint64
  7400. adduser_id *int64
  7401. bot_id *uint64
  7402. addbot_id *int64
  7403. bot_type *uint8
  7404. addbot_type *int8
  7405. clearedFields map[string]struct{}
  7406. done bool
  7407. oldValue func(context.Context) (*ChatSession, error)
  7408. predicates []predicate.ChatSession
  7409. }
  7410. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  7411. // chatsessionOption allows management of the mutation configuration using functional options.
  7412. type chatsessionOption func(*ChatSessionMutation)
  7413. // newChatSessionMutation creates new mutation for the ChatSession entity.
  7414. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  7415. m := &ChatSessionMutation{
  7416. config: c,
  7417. op: op,
  7418. typ: TypeChatSession,
  7419. clearedFields: make(map[string]struct{}),
  7420. }
  7421. for _, opt := range opts {
  7422. opt(m)
  7423. }
  7424. return m
  7425. }
  7426. // withChatSessionID sets the ID field of the mutation.
  7427. func withChatSessionID(id uint64) chatsessionOption {
  7428. return func(m *ChatSessionMutation) {
  7429. var (
  7430. err error
  7431. once sync.Once
  7432. value *ChatSession
  7433. )
  7434. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  7435. once.Do(func() {
  7436. if m.done {
  7437. err = errors.New("querying old values post mutation is not allowed")
  7438. } else {
  7439. value, err = m.Client().ChatSession.Get(ctx, id)
  7440. }
  7441. })
  7442. return value, err
  7443. }
  7444. m.id = &id
  7445. }
  7446. }
  7447. // withChatSession sets the old ChatSession of the mutation.
  7448. func withChatSession(node *ChatSession) chatsessionOption {
  7449. return func(m *ChatSessionMutation) {
  7450. m.oldValue = func(context.Context) (*ChatSession, error) {
  7451. return node, nil
  7452. }
  7453. m.id = &node.ID
  7454. }
  7455. }
  7456. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7457. // executed in a transaction (ent.Tx), a transactional client is returned.
  7458. func (m ChatSessionMutation) Client() *Client {
  7459. client := &Client{config: m.config}
  7460. client.init()
  7461. return client
  7462. }
  7463. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7464. // it returns an error otherwise.
  7465. func (m ChatSessionMutation) Tx() (*Tx, error) {
  7466. if _, ok := m.driver.(*txDriver); !ok {
  7467. return nil, errors.New("ent: mutation is not running in a transaction")
  7468. }
  7469. tx := &Tx{config: m.config}
  7470. tx.init()
  7471. return tx, nil
  7472. }
  7473. // SetID sets the value of the id field. Note that this
  7474. // operation is only accepted on creation of ChatSession entities.
  7475. func (m *ChatSessionMutation) SetID(id uint64) {
  7476. m.id = &id
  7477. }
  7478. // ID returns the ID value in the mutation. Note that the ID is only available
  7479. // if it was provided to the builder or after it was returned from the database.
  7480. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  7481. if m.id == nil {
  7482. return
  7483. }
  7484. return *m.id, true
  7485. }
  7486. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7487. // That means, if the mutation is applied within a transaction with an isolation level such
  7488. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7489. // or updated by the mutation.
  7490. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  7491. switch {
  7492. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7493. id, exists := m.ID()
  7494. if exists {
  7495. return []uint64{id}, nil
  7496. }
  7497. fallthrough
  7498. case m.op.Is(OpUpdate | OpDelete):
  7499. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  7500. default:
  7501. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7502. }
  7503. }
  7504. // SetCreatedAt sets the "created_at" field.
  7505. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  7506. m.created_at = &t
  7507. }
  7508. // CreatedAt returns the value of the "created_at" field in the mutation.
  7509. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  7510. v := m.created_at
  7511. if v == nil {
  7512. return
  7513. }
  7514. return *v, true
  7515. }
  7516. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  7517. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7518. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7519. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7520. if !m.op.Is(OpUpdateOne) {
  7521. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7522. }
  7523. if m.id == nil || m.oldValue == nil {
  7524. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7525. }
  7526. oldValue, err := m.oldValue(ctx)
  7527. if err != nil {
  7528. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7529. }
  7530. return oldValue.CreatedAt, nil
  7531. }
  7532. // ResetCreatedAt resets all changes to the "created_at" field.
  7533. func (m *ChatSessionMutation) ResetCreatedAt() {
  7534. m.created_at = nil
  7535. }
  7536. // SetUpdatedAt sets the "updated_at" field.
  7537. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  7538. m.updated_at = &t
  7539. }
  7540. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7541. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  7542. v := m.updated_at
  7543. if v == nil {
  7544. return
  7545. }
  7546. return *v, true
  7547. }
  7548. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  7549. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7550. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7551. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7552. if !m.op.Is(OpUpdateOne) {
  7553. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7554. }
  7555. if m.id == nil || m.oldValue == nil {
  7556. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7557. }
  7558. oldValue, err := m.oldValue(ctx)
  7559. if err != nil {
  7560. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7561. }
  7562. return oldValue.UpdatedAt, nil
  7563. }
  7564. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7565. func (m *ChatSessionMutation) ResetUpdatedAt() {
  7566. m.updated_at = nil
  7567. }
  7568. // SetDeletedAt sets the "deleted_at" field.
  7569. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  7570. m.deleted_at = &t
  7571. }
  7572. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7573. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  7574. v := m.deleted_at
  7575. if v == nil {
  7576. return
  7577. }
  7578. return *v, true
  7579. }
  7580. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  7581. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7582. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7583. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7584. if !m.op.Is(OpUpdateOne) {
  7585. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7586. }
  7587. if m.id == nil || m.oldValue == nil {
  7588. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7589. }
  7590. oldValue, err := m.oldValue(ctx)
  7591. if err != nil {
  7592. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7593. }
  7594. return oldValue.DeletedAt, nil
  7595. }
  7596. // ClearDeletedAt clears the value of the "deleted_at" field.
  7597. func (m *ChatSessionMutation) ClearDeletedAt() {
  7598. m.deleted_at = nil
  7599. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  7600. }
  7601. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7602. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  7603. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  7604. return ok
  7605. }
  7606. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7607. func (m *ChatSessionMutation) ResetDeletedAt() {
  7608. m.deleted_at = nil
  7609. delete(m.clearedFields, chatsession.FieldDeletedAt)
  7610. }
  7611. // SetName sets the "name" field.
  7612. func (m *ChatSessionMutation) SetName(s string) {
  7613. m.name = &s
  7614. }
  7615. // Name returns the value of the "name" field in the mutation.
  7616. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  7617. v := m.name
  7618. if v == nil {
  7619. return
  7620. }
  7621. return *v, true
  7622. }
  7623. // OldName returns the old "name" field's value of the ChatSession entity.
  7624. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7626. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  7627. if !m.op.Is(OpUpdateOne) {
  7628. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7629. }
  7630. if m.id == nil || m.oldValue == nil {
  7631. return v, errors.New("OldName requires an ID field in the mutation")
  7632. }
  7633. oldValue, err := m.oldValue(ctx)
  7634. if err != nil {
  7635. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7636. }
  7637. return oldValue.Name, nil
  7638. }
  7639. // ResetName resets all changes to the "name" field.
  7640. func (m *ChatSessionMutation) ResetName() {
  7641. m.name = nil
  7642. }
  7643. // SetUserID sets the "user_id" field.
  7644. func (m *ChatSessionMutation) SetUserID(u uint64) {
  7645. m.user_id = &u
  7646. m.adduser_id = nil
  7647. }
  7648. // UserID returns the value of the "user_id" field in the mutation.
  7649. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  7650. v := m.user_id
  7651. if v == nil {
  7652. return
  7653. }
  7654. return *v, true
  7655. }
  7656. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  7657. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7658. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7659. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  7660. if !m.op.Is(OpUpdateOne) {
  7661. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  7662. }
  7663. if m.id == nil || m.oldValue == nil {
  7664. return v, errors.New("OldUserID requires an ID field in the mutation")
  7665. }
  7666. oldValue, err := m.oldValue(ctx)
  7667. if err != nil {
  7668. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  7669. }
  7670. return oldValue.UserID, nil
  7671. }
  7672. // AddUserID adds u to the "user_id" field.
  7673. func (m *ChatSessionMutation) AddUserID(u int64) {
  7674. if m.adduser_id != nil {
  7675. *m.adduser_id += u
  7676. } else {
  7677. m.adduser_id = &u
  7678. }
  7679. }
  7680. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  7681. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  7682. v := m.adduser_id
  7683. if v == nil {
  7684. return
  7685. }
  7686. return *v, true
  7687. }
  7688. // ResetUserID resets all changes to the "user_id" field.
  7689. func (m *ChatSessionMutation) ResetUserID() {
  7690. m.user_id = nil
  7691. m.adduser_id = nil
  7692. }
  7693. // SetBotID sets the "bot_id" field.
  7694. func (m *ChatSessionMutation) SetBotID(u uint64) {
  7695. m.bot_id = &u
  7696. m.addbot_id = nil
  7697. }
  7698. // BotID returns the value of the "bot_id" field in the mutation.
  7699. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  7700. v := m.bot_id
  7701. if v == nil {
  7702. return
  7703. }
  7704. return *v, true
  7705. }
  7706. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  7707. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7708. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7709. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  7710. if !m.op.Is(OpUpdateOne) {
  7711. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  7712. }
  7713. if m.id == nil || m.oldValue == nil {
  7714. return v, errors.New("OldBotID requires an ID field in the mutation")
  7715. }
  7716. oldValue, err := m.oldValue(ctx)
  7717. if err != nil {
  7718. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  7719. }
  7720. return oldValue.BotID, nil
  7721. }
  7722. // AddBotID adds u to the "bot_id" field.
  7723. func (m *ChatSessionMutation) AddBotID(u int64) {
  7724. if m.addbot_id != nil {
  7725. *m.addbot_id += u
  7726. } else {
  7727. m.addbot_id = &u
  7728. }
  7729. }
  7730. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  7731. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  7732. v := m.addbot_id
  7733. if v == nil {
  7734. return
  7735. }
  7736. return *v, true
  7737. }
  7738. // ResetBotID resets all changes to the "bot_id" field.
  7739. func (m *ChatSessionMutation) ResetBotID() {
  7740. m.bot_id = nil
  7741. m.addbot_id = nil
  7742. }
  7743. // SetBotType sets the "bot_type" field.
  7744. func (m *ChatSessionMutation) SetBotType(u uint8) {
  7745. m.bot_type = &u
  7746. m.addbot_type = nil
  7747. }
  7748. // BotType returns the value of the "bot_type" field in the mutation.
  7749. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  7750. v := m.bot_type
  7751. if v == nil {
  7752. return
  7753. }
  7754. return *v, true
  7755. }
  7756. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  7757. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7758. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7759. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  7760. if !m.op.Is(OpUpdateOne) {
  7761. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  7762. }
  7763. if m.id == nil || m.oldValue == nil {
  7764. return v, errors.New("OldBotType requires an ID field in the mutation")
  7765. }
  7766. oldValue, err := m.oldValue(ctx)
  7767. if err != nil {
  7768. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  7769. }
  7770. return oldValue.BotType, nil
  7771. }
  7772. // AddBotType adds u to the "bot_type" field.
  7773. func (m *ChatSessionMutation) AddBotType(u int8) {
  7774. if m.addbot_type != nil {
  7775. *m.addbot_type += u
  7776. } else {
  7777. m.addbot_type = &u
  7778. }
  7779. }
  7780. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  7781. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  7782. v := m.addbot_type
  7783. if v == nil {
  7784. return
  7785. }
  7786. return *v, true
  7787. }
  7788. // ResetBotType resets all changes to the "bot_type" field.
  7789. func (m *ChatSessionMutation) ResetBotType() {
  7790. m.bot_type = nil
  7791. m.addbot_type = nil
  7792. }
  7793. // Where appends a list predicates to the ChatSessionMutation builder.
  7794. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  7795. m.predicates = append(m.predicates, ps...)
  7796. }
  7797. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  7798. // users can use type-assertion to append predicates that do not depend on any generated package.
  7799. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  7800. p := make([]predicate.ChatSession, len(ps))
  7801. for i := range ps {
  7802. p[i] = ps[i]
  7803. }
  7804. m.Where(p...)
  7805. }
  7806. // Op returns the operation name.
  7807. func (m *ChatSessionMutation) Op() Op {
  7808. return m.op
  7809. }
  7810. // SetOp allows setting the mutation operation.
  7811. func (m *ChatSessionMutation) SetOp(op Op) {
  7812. m.op = op
  7813. }
  7814. // Type returns the node type of this mutation (ChatSession).
  7815. func (m *ChatSessionMutation) Type() string {
  7816. return m.typ
  7817. }
  7818. // Fields returns all fields that were changed during this mutation. Note that in
  7819. // order to get all numeric fields that were incremented/decremented, call
  7820. // AddedFields().
  7821. func (m *ChatSessionMutation) Fields() []string {
  7822. fields := make([]string, 0, 7)
  7823. if m.created_at != nil {
  7824. fields = append(fields, chatsession.FieldCreatedAt)
  7825. }
  7826. if m.updated_at != nil {
  7827. fields = append(fields, chatsession.FieldUpdatedAt)
  7828. }
  7829. if m.deleted_at != nil {
  7830. fields = append(fields, chatsession.FieldDeletedAt)
  7831. }
  7832. if m.name != nil {
  7833. fields = append(fields, chatsession.FieldName)
  7834. }
  7835. if m.user_id != nil {
  7836. fields = append(fields, chatsession.FieldUserID)
  7837. }
  7838. if m.bot_id != nil {
  7839. fields = append(fields, chatsession.FieldBotID)
  7840. }
  7841. if m.bot_type != nil {
  7842. fields = append(fields, chatsession.FieldBotType)
  7843. }
  7844. return fields
  7845. }
  7846. // Field returns the value of a field with the given name. The second boolean
  7847. // return value indicates that this field was not set, or was not defined in the
  7848. // schema.
  7849. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  7850. switch name {
  7851. case chatsession.FieldCreatedAt:
  7852. return m.CreatedAt()
  7853. case chatsession.FieldUpdatedAt:
  7854. return m.UpdatedAt()
  7855. case chatsession.FieldDeletedAt:
  7856. return m.DeletedAt()
  7857. case chatsession.FieldName:
  7858. return m.Name()
  7859. case chatsession.FieldUserID:
  7860. return m.UserID()
  7861. case chatsession.FieldBotID:
  7862. return m.BotID()
  7863. case chatsession.FieldBotType:
  7864. return m.BotType()
  7865. }
  7866. return nil, false
  7867. }
  7868. // OldField returns the old value of the field from the database. An error is
  7869. // returned if the mutation operation is not UpdateOne, or the query to the
  7870. // database failed.
  7871. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7872. switch name {
  7873. case chatsession.FieldCreatedAt:
  7874. return m.OldCreatedAt(ctx)
  7875. case chatsession.FieldUpdatedAt:
  7876. return m.OldUpdatedAt(ctx)
  7877. case chatsession.FieldDeletedAt:
  7878. return m.OldDeletedAt(ctx)
  7879. case chatsession.FieldName:
  7880. return m.OldName(ctx)
  7881. case chatsession.FieldUserID:
  7882. return m.OldUserID(ctx)
  7883. case chatsession.FieldBotID:
  7884. return m.OldBotID(ctx)
  7885. case chatsession.FieldBotType:
  7886. return m.OldBotType(ctx)
  7887. }
  7888. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  7889. }
  7890. // SetField sets the value of a field with the given name. It returns an error if
  7891. // the field is not defined in the schema, or if the type mismatched the field
  7892. // type.
  7893. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  7894. switch name {
  7895. case chatsession.FieldCreatedAt:
  7896. v, ok := value.(time.Time)
  7897. if !ok {
  7898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7899. }
  7900. m.SetCreatedAt(v)
  7901. return nil
  7902. case chatsession.FieldUpdatedAt:
  7903. v, ok := value.(time.Time)
  7904. if !ok {
  7905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7906. }
  7907. m.SetUpdatedAt(v)
  7908. return nil
  7909. case chatsession.FieldDeletedAt:
  7910. v, ok := value.(time.Time)
  7911. if !ok {
  7912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7913. }
  7914. m.SetDeletedAt(v)
  7915. return nil
  7916. case chatsession.FieldName:
  7917. v, ok := value.(string)
  7918. if !ok {
  7919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7920. }
  7921. m.SetName(v)
  7922. return nil
  7923. case chatsession.FieldUserID:
  7924. v, ok := value.(uint64)
  7925. if !ok {
  7926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7927. }
  7928. m.SetUserID(v)
  7929. return nil
  7930. case chatsession.FieldBotID:
  7931. v, ok := value.(uint64)
  7932. if !ok {
  7933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7934. }
  7935. m.SetBotID(v)
  7936. return nil
  7937. case chatsession.FieldBotType:
  7938. v, ok := value.(uint8)
  7939. if !ok {
  7940. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7941. }
  7942. m.SetBotType(v)
  7943. return nil
  7944. }
  7945. return fmt.Errorf("unknown ChatSession field %s", name)
  7946. }
  7947. // AddedFields returns all numeric fields that were incremented/decremented during
  7948. // this mutation.
  7949. func (m *ChatSessionMutation) AddedFields() []string {
  7950. var fields []string
  7951. if m.adduser_id != nil {
  7952. fields = append(fields, chatsession.FieldUserID)
  7953. }
  7954. if m.addbot_id != nil {
  7955. fields = append(fields, chatsession.FieldBotID)
  7956. }
  7957. if m.addbot_type != nil {
  7958. fields = append(fields, chatsession.FieldBotType)
  7959. }
  7960. return fields
  7961. }
  7962. // AddedField returns the numeric value that was incremented/decremented on a field
  7963. // with the given name. The second boolean return value indicates that this field
  7964. // was not set, or was not defined in the schema.
  7965. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  7966. switch name {
  7967. case chatsession.FieldUserID:
  7968. return m.AddedUserID()
  7969. case chatsession.FieldBotID:
  7970. return m.AddedBotID()
  7971. case chatsession.FieldBotType:
  7972. return m.AddedBotType()
  7973. }
  7974. return nil, false
  7975. }
  7976. // AddField adds the value to the field with the given name. It returns an error if
  7977. // the field is not defined in the schema, or if the type mismatched the field
  7978. // type.
  7979. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  7980. switch name {
  7981. case chatsession.FieldUserID:
  7982. v, ok := value.(int64)
  7983. if !ok {
  7984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7985. }
  7986. m.AddUserID(v)
  7987. return nil
  7988. case chatsession.FieldBotID:
  7989. v, ok := value.(int64)
  7990. if !ok {
  7991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7992. }
  7993. m.AddBotID(v)
  7994. return nil
  7995. case chatsession.FieldBotType:
  7996. v, ok := value.(int8)
  7997. if !ok {
  7998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7999. }
  8000. m.AddBotType(v)
  8001. return nil
  8002. }
  8003. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  8004. }
  8005. // ClearedFields returns all nullable fields that were cleared during this
  8006. // mutation.
  8007. func (m *ChatSessionMutation) ClearedFields() []string {
  8008. var fields []string
  8009. if m.FieldCleared(chatsession.FieldDeletedAt) {
  8010. fields = append(fields, chatsession.FieldDeletedAt)
  8011. }
  8012. return fields
  8013. }
  8014. // FieldCleared returns a boolean indicating if a field with the given name was
  8015. // cleared in this mutation.
  8016. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  8017. _, ok := m.clearedFields[name]
  8018. return ok
  8019. }
  8020. // ClearField clears the value of the field with the given name. It returns an
  8021. // error if the field is not defined in the schema.
  8022. func (m *ChatSessionMutation) ClearField(name string) error {
  8023. switch name {
  8024. case chatsession.FieldDeletedAt:
  8025. m.ClearDeletedAt()
  8026. return nil
  8027. }
  8028. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  8029. }
  8030. // ResetField resets all changes in the mutation for the field with the given name.
  8031. // It returns an error if the field is not defined in the schema.
  8032. func (m *ChatSessionMutation) ResetField(name string) error {
  8033. switch name {
  8034. case chatsession.FieldCreatedAt:
  8035. m.ResetCreatedAt()
  8036. return nil
  8037. case chatsession.FieldUpdatedAt:
  8038. m.ResetUpdatedAt()
  8039. return nil
  8040. case chatsession.FieldDeletedAt:
  8041. m.ResetDeletedAt()
  8042. return nil
  8043. case chatsession.FieldName:
  8044. m.ResetName()
  8045. return nil
  8046. case chatsession.FieldUserID:
  8047. m.ResetUserID()
  8048. return nil
  8049. case chatsession.FieldBotID:
  8050. m.ResetBotID()
  8051. return nil
  8052. case chatsession.FieldBotType:
  8053. m.ResetBotType()
  8054. return nil
  8055. }
  8056. return fmt.Errorf("unknown ChatSession field %s", name)
  8057. }
  8058. // AddedEdges returns all edge names that were set/added in this mutation.
  8059. func (m *ChatSessionMutation) AddedEdges() []string {
  8060. edges := make([]string, 0, 0)
  8061. return edges
  8062. }
  8063. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8064. // name in this mutation.
  8065. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  8066. return nil
  8067. }
  8068. // RemovedEdges returns all edge names that were removed in this mutation.
  8069. func (m *ChatSessionMutation) RemovedEdges() []string {
  8070. edges := make([]string, 0, 0)
  8071. return edges
  8072. }
  8073. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8074. // the given name in this mutation.
  8075. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  8076. return nil
  8077. }
  8078. // ClearedEdges returns all edge names that were cleared in this mutation.
  8079. func (m *ChatSessionMutation) ClearedEdges() []string {
  8080. edges := make([]string, 0, 0)
  8081. return edges
  8082. }
  8083. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8084. // was cleared in this mutation.
  8085. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  8086. return false
  8087. }
  8088. // ClearEdge clears the value of the edge with the given name. It returns an error
  8089. // if that edge is not defined in the schema.
  8090. func (m *ChatSessionMutation) ClearEdge(name string) error {
  8091. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  8092. }
  8093. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8094. // It returns an error if the edge is not defined in the schema.
  8095. func (m *ChatSessionMutation) ResetEdge(name string) error {
  8096. return fmt.Errorf("unknown ChatSession edge %s", name)
  8097. }
  8098. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  8099. type ContactMutation struct {
  8100. config
  8101. op Op
  8102. typ string
  8103. id *uint64
  8104. created_at *time.Time
  8105. updated_at *time.Time
  8106. status *uint8
  8107. addstatus *int8
  8108. deleted_at *time.Time
  8109. wx_wxid *string
  8110. _type *int
  8111. add_type *int
  8112. wxid *string
  8113. account *string
  8114. nickname *string
  8115. markname *string
  8116. headimg *string
  8117. sex *int
  8118. addsex *int
  8119. starrole *string
  8120. dontseeit *int
  8121. adddontseeit *int
  8122. dontseeme *int
  8123. adddontseeme *int
  8124. lag *string
  8125. gid *string
  8126. gname *string
  8127. v3 *string
  8128. organization_id *uint64
  8129. addorganization_id *int64
  8130. ctype *uint64
  8131. addctype *int64
  8132. cage *int
  8133. addcage *int
  8134. cname *string
  8135. carea *string
  8136. cbirthday *string
  8137. cbirtharea *string
  8138. cidcard_no *string
  8139. ctitle *string
  8140. cc *string
  8141. phone *string
  8142. clearedFields map[string]struct{}
  8143. contact_relationships map[uint64]struct{}
  8144. removedcontact_relationships map[uint64]struct{}
  8145. clearedcontact_relationships bool
  8146. contact_messages map[uint64]struct{}
  8147. removedcontact_messages map[uint64]struct{}
  8148. clearedcontact_messages bool
  8149. done bool
  8150. oldValue func(context.Context) (*Contact, error)
  8151. predicates []predicate.Contact
  8152. }
  8153. var _ ent.Mutation = (*ContactMutation)(nil)
  8154. // contactOption allows management of the mutation configuration using functional options.
  8155. type contactOption func(*ContactMutation)
  8156. // newContactMutation creates new mutation for the Contact entity.
  8157. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  8158. m := &ContactMutation{
  8159. config: c,
  8160. op: op,
  8161. typ: TypeContact,
  8162. clearedFields: make(map[string]struct{}),
  8163. }
  8164. for _, opt := range opts {
  8165. opt(m)
  8166. }
  8167. return m
  8168. }
  8169. // withContactID sets the ID field of the mutation.
  8170. func withContactID(id uint64) contactOption {
  8171. return func(m *ContactMutation) {
  8172. var (
  8173. err error
  8174. once sync.Once
  8175. value *Contact
  8176. )
  8177. m.oldValue = func(ctx context.Context) (*Contact, error) {
  8178. once.Do(func() {
  8179. if m.done {
  8180. err = errors.New("querying old values post mutation is not allowed")
  8181. } else {
  8182. value, err = m.Client().Contact.Get(ctx, id)
  8183. }
  8184. })
  8185. return value, err
  8186. }
  8187. m.id = &id
  8188. }
  8189. }
  8190. // withContact sets the old Contact of the mutation.
  8191. func withContact(node *Contact) contactOption {
  8192. return func(m *ContactMutation) {
  8193. m.oldValue = func(context.Context) (*Contact, error) {
  8194. return node, nil
  8195. }
  8196. m.id = &node.ID
  8197. }
  8198. }
  8199. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8200. // executed in a transaction (ent.Tx), a transactional client is returned.
  8201. func (m ContactMutation) Client() *Client {
  8202. client := &Client{config: m.config}
  8203. client.init()
  8204. return client
  8205. }
  8206. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8207. // it returns an error otherwise.
  8208. func (m ContactMutation) Tx() (*Tx, error) {
  8209. if _, ok := m.driver.(*txDriver); !ok {
  8210. return nil, errors.New("ent: mutation is not running in a transaction")
  8211. }
  8212. tx := &Tx{config: m.config}
  8213. tx.init()
  8214. return tx, nil
  8215. }
  8216. // SetID sets the value of the id field. Note that this
  8217. // operation is only accepted on creation of Contact entities.
  8218. func (m *ContactMutation) SetID(id uint64) {
  8219. m.id = &id
  8220. }
  8221. // ID returns the ID value in the mutation. Note that the ID is only available
  8222. // if it was provided to the builder or after it was returned from the database.
  8223. func (m *ContactMutation) ID() (id uint64, exists bool) {
  8224. if m.id == nil {
  8225. return
  8226. }
  8227. return *m.id, true
  8228. }
  8229. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8230. // That means, if the mutation is applied within a transaction with an isolation level such
  8231. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8232. // or updated by the mutation.
  8233. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  8234. switch {
  8235. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8236. id, exists := m.ID()
  8237. if exists {
  8238. return []uint64{id}, nil
  8239. }
  8240. fallthrough
  8241. case m.op.Is(OpUpdate | OpDelete):
  8242. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  8243. default:
  8244. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8245. }
  8246. }
  8247. // SetCreatedAt sets the "created_at" field.
  8248. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  8249. m.created_at = &t
  8250. }
  8251. // CreatedAt returns the value of the "created_at" field in the mutation.
  8252. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  8253. v := m.created_at
  8254. if v == nil {
  8255. return
  8256. }
  8257. return *v, true
  8258. }
  8259. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  8260. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8261. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8262. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8263. if !m.op.Is(OpUpdateOne) {
  8264. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8265. }
  8266. if m.id == nil || m.oldValue == nil {
  8267. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8268. }
  8269. oldValue, err := m.oldValue(ctx)
  8270. if err != nil {
  8271. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8272. }
  8273. return oldValue.CreatedAt, nil
  8274. }
  8275. // ResetCreatedAt resets all changes to the "created_at" field.
  8276. func (m *ContactMutation) ResetCreatedAt() {
  8277. m.created_at = nil
  8278. }
  8279. // SetUpdatedAt sets the "updated_at" field.
  8280. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  8281. m.updated_at = &t
  8282. }
  8283. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8284. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  8285. v := m.updated_at
  8286. if v == nil {
  8287. return
  8288. }
  8289. return *v, true
  8290. }
  8291. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  8292. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8294. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8295. if !m.op.Is(OpUpdateOne) {
  8296. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8297. }
  8298. if m.id == nil || m.oldValue == nil {
  8299. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8300. }
  8301. oldValue, err := m.oldValue(ctx)
  8302. if err != nil {
  8303. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8304. }
  8305. return oldValue.UpdatedAt, nil
  8306. }
  8307. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8308. func (m *ContactMutation) ResetUpdatedAt() {
  8309. m.updated_at = nil
  8310. }
  8311. // SetStatus sets the "status" field.
  8312. func (m *ContactMutation) SetStatus(u uint8) {
  8313. m.status = &u
  8314. m.addstatus = nil
  8315. }
  8316. // Status returns the value of the "status" field in the mutation.
  8317. func (m *ContactMutation) Status() (r uint8, exists bool) {
  8318. v := m.status
  8319. if v == nil {
  8320. return
  8321. }
  8322. return *v, true
  8323. }
  8324. // OldStatus returns the old "status" field's value of the Contact entity.
  8325. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8326. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8327. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  8328. if !m.op.Is(OpUpdateOne) {
  8329. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  8330. }
  8331. if m.id == nil || m.oldValue == nil {
  8332. return v, errors.New("OldStatus requires an ID field in the mutation")
  8333. }
  8334. oldValue, err := m.oldValue(ctx)
  8335. if err != nil {
  8336. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  8337. }
  8338. return oldValue.Status, nil
  8339. }
  8340. // AddStatus adds u to the "status" field.
  8341. func (m *ContactMutation) AddStatus(u int8) {
  8342. if m.addstatus != nil {
  8343. *m.addstatus += u
  8344. } else {
  8345. m.addstatus = &u
  8346. }
  8347. }
  8348. // AddedStatus returns the value that was added to the "status" field in this mutation.
  8349. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  8350. v := m.addstatus
  8351. if v == nil {
  8352. return
  8353. }
  8354. return *v, true
  8355. }
  8356. // ClearStatus clears the value of the "status" field.
  8357. func (m *ContactMutation) ClearStatus() {
  8358. m.status = nil
  8359. m.addstatus = nil
  8360. m.clearedFields[contact.FieldStatus] = struct{}{}
  8361. }
  8362. // StatusCleared returns if the "status" field was cleared in this mutation.
  8363. func (m *ContactMutation) StatusCleared() bool {
  8364. _, ok := m.clearedFields[contact.FieldStatus]
  8365. return ok
  8366. }
  8367. // ResetStatus resets all changes to the "status" field.
  8368. func (m *ContactMutation) ResetStatus() {
  8369. m.status = nil
  8370. m.addstatus = nil
  8371. delete(m.clearedFields, contact.FieldStatus)
  8372. }
  8373. // SetDeletedAt sets the "deleted_at" field.
  8374. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  8375. m.deleted_at = &t
  8376. }
  8377. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8378. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  8379. v := m.deleted_at
  8380. if v == nil {
  8381. return
  8382. }
  8383. return *v, true
  8384. }
  8385. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  8386. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8387. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8388. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8389. if !m.op.Is(OpUpdateOne) {
  8390. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8391. }
  8392. if m.id == nil || m.oldValue == nil {
  8393. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8394. }
  8395. oldValue, err := m.oldValue(ctx)
  8396. if err != nil {
  8397. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8398. }
  8399. return oldValue.DeletedAt, nil
  8400. }
  8401. // ClearDeletedAt clears the value of the "deleted_at" field.
  8402. func (m *ContactMutation) ClearDeletedAt() {
  8403. m.deleted_at = nil
  8404. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  8405. }
  8406. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8407. func (m *ContactMutation) DeletedAtCleared() bool {
  8408. _, ok := m.clearedFields[contact.FieldDeletedAt]
  8409. return ok
  8410. }
  8411. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8412. func (m *ContactMutation) ResetDeletedAt() {
  8413. m.deleted_at = nil
  8414. delete(m.clearedFields, contact.FieldDeletedAt)
  8415. }
  8416. // SetWxWxid sets the "wx_wxid" field.
  8417. func (m *ContactMutation) SetWxWxid(s string) {
  8418. m.wx_wxid = &s
  8419. }
  8420. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  8421. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  8422. v := m.wx_wxid
  8423. if v == nil {
  8424. return
  8425. }
  8426. return *v, true
  8427. }
  8428. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  8429. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8430. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8431. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  8432. if !m.op.Is(OpUpdateOne) {
  8433. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  8434. }
  8435. if m.id == nil || m.oldValue == nil {
  8436. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  8437. }
  8438. oldValue, err := m.oldValue(ctx)
  8439. if err != nil {
  8440. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  8441. }
  8442. return oldValue.WxWxid, nil
  8443. }
  8444. // ResetWxWxid resets all changes to the "wx_wxid" field.
  8445. func (m *ContactMutation) ResetWxWxid() {
  8446. m.wx_wxid = nil
  8447. }
  8448. // SetType sets the "type" field.
  8449. func (m *ContactMutation) SetType(i int) {
  8450. m._type = &i
  8451. m.add_type = nil
  8452. }
  8453. // GetType returns the value of the "type" field in the mutation.
  8454. func (m *ContactMutation) GetType() (r int, exists bool) {
  8455. v := m._type
  8456. if v == nil {
  8457. return
  8458. }
  8459. return *v, true
  8460. }
  8461. // OldType returns the old "type" field's value of the Contact entity.
  8462. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8463. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8464. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  8465. if !m.op.Is(OpUpdateOne) {
  8466. return v, errors.New("OldType is only allowed on UpdateOne operations")
  8467. }
  8468. if m.id == nil || m.oldValue == nil {
  8469. return v, errors.New("OldType requires an ID field in the mutation")
  8470. }
  8471. oldValue, err := m.oldValue(ctx)
  8472. if err != nil {
  8473. return v, fmt.Errorf("querying old value for OldType: %w", err)
  8474. }
  8475. return oldValue.Type, nil
  8476. }
  8477. // AddType adds i to the "type" field.
  8478. func (m *ContactMutation) AddType(i int) {
  8479. if m.add_type != nil {
  8480. *m.add_type += i
  8481. } else {
  8482. m.add_type = &i
  8483. }
  8484. }
  8485. // AddedType returns the value that was added to the "type" field in this mutation.
  8486. func (m *ContactMutation) AddedType() (r int, exists bool) {
  8487. v := m.add_type
  8488. if v == nil {
  8489. return
  8490. }
  8491. return *v, true
  8492. }
  8493. // ClearType clears the value of the "type" field.
  8494. func (m *ContactMutation) ClearType() {
  8495. m._type = nil
  8496. m.add_type = nil
  8497. m.clearedFields[contact.FieldType] = struct{}{}
  8498. }
  8499. // TypeCleared returns if the "type" field was cleared in this mutation.
  8500. func (m *ContactMutation) TypeCleared() bool {
  8501. _, ok := m.clearedFields[contact.FieldType]
  8502. return ok
  8503. }
  8504. // ResetType resets all changes to the "type" field.
  8505. func (m *ContactMutation) ResetType() {
  8506. m._type = nil
  8507. m.add_type = nil
  8508. delete(m.clearedFields, contact.FieldType)
  8509. }
  8510. // SetWxid sets the "wxid" field.
  8511. func (m *ContactMutation) SetWxid(s string) {
  8512. m.wxid = &s
  8513. }
  8514. // Wxid returns the value of the "wxid" field in the mutation.
  8515. func (m *ContactMutation) Wxid() (r string, exists bool) {
  8516. v := m.wxid
  8517. if v == nil {
  8518. return
  8519. }
  8520. return *v, true
  8521. }
  8522. // OldWxid returns the old "wxid" field's value of the Contact entity.
  8523. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8524. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8525. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  8526. if !m.op.Is(OpUpdateOne) {
  8527. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  8528. }
  8529. if m.id == nil || m.oldValue == nil {
  8530. return v, errors.New("OldWxid requires an ID field in the mutation")
  8531. }
  8532. oldValue, err := m.oldValue(ctx)
  8533. if err != nil {
  8534. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  8535. }
  8536. return oldValue.Wxid, nil
  8537. }
  8538. // ResetWxid resets all changes to the "wxid" field.
  8539. func (m *ContactMutation) ResetWxid() {
  8540. m.wxid = nil
  8541. }
  8542. // SetAccount sets the "account" field.
  8543. func (m *ContactMutation) SetAccount(s string) {
  8544. m.account = &s
  8545. }
  8546. // Account returns the value of the "account" field in the mutation.
  8547. func (m *ContactMutation) Account() (r string, exists bool) {
  8548. v := m.account
  8549. if v == nil {
  8550. return
  8551. }
  8552. return *v, true
  8553. }
  8554. // OldAccount returns the old "account" field's value of the Contact entity.
  8555. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8556. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8557. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  8558. if !m.op.Is(OpUpdateOne) {
  8559. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  8560. }
  8561. if m.id == nil || m.oldValue == nil {
  8562. return v, errors.New("OldAccount requires an ID field in the mutation")
  8563. }
  8564. oldValue, err := m.oldValue(ctx)
  8565. if err != nil {
  8566. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  8567. }
  8568. return oldValue.Account, nil
  8569. }
  8570. // ResetAccount resets all changes to the "account" field.
  8571. func (m *ContactMutation) ResetAccount() {
  8572. m.account = nil
  8573. }
  8574. // SetNickname sets the "nickname" field.
  8575. func (m *ContactMutation) SetNickname(s string) {
  8576. m.nickname = &s
  8577. }
  8578. // Nickname returns the value of the "nickname" field in the mutation.
  8579. func (m *ContactMutation) Nickname() (r string, exists bool) {
  8580. v := m.nickname
  8581. if v == nil {
  8582. return
  8583. }
  8584. return *v, true
  8585. }
  8586. // OldNickname returns the old "nickname" field's value of the Contact entity.
  8587. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8588. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8589. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  8590. if !m.op.Is(OpUpdateOne) {
  8591. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  8592. }
  8593. if m.id == nil || m.oldValue == nil {
  8594. return v, errors.New("OldNickname requires an ID field in the mutation")
  8595. }
  8596. oldValue, err := m.oldValue(ctx)
  8597. if err != nil {
  8598. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  8599. }
  8600. return oldValue.Nickname, nil
  8601. }
  8602. // ResetNickname resets all changes to the "nickname" field.
  8603. func (m *ContactMutation) ResetNickname() {
  8604. m.nickname = nil
  8605. }
  8606. // SetMarkname sets the "markname" field.
  8607. func (m *ContactMutation) SetMarkname(s string) {
  8608. m.markname = &s
  8609. }
  8610. // Markname returns the value of the "markname" field in the mutation.
  8611. func (m *ContactMutation) Markname() (r string, exists bool) {
  8612. v := m.markname
  8613. if v == nil {
  8614. return
  8615. }
  8616. return *v, true
  8617. }
  8618. // OldMarkname returns the old "markname" field's value of the Contact entity.
  8619. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8621. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  8622. if !m.op.Is(OpUpdateOne) {
  8623. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  8624. }
  8625. if m.id == nil || m.oldValue == nil {
  8626. return v, errors.New("OldMarkname requires an ID field in the mutation")
  8627. }
  8628. oldValue, err := m.oldValue(ctx)
  8629. if err != nil {
  8630. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  8631. }
  8632. return oldValue.Markname, nil
  8633. }
  8634. // ResetMarkname resets all changes to the "markname" field.
  8635. func (m *ContactMutation) ResetMarkname() {
  8636. m.markname = nil
  8637. }
  8638. // SetHeadimg sets the "headimg" field.
  8639. func (m *ContactMutation) SetHeadimg(s string) {
  8640. m.headimg = &s
  8641. }
  8642. // Headimg returns the value of the "headimg" field in the mutation.
  8643. func (m *ContactMutation) Headimg() (r string, exists bool) {
  8644. v := m.headimg
  8645. if v == nil {
  8646. return
  8647. }
  8648. return *v, true
  8649. }
  8650. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  8651. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8652. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8653. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  8654. if !m.op.Is(OpUpdateOne) {
  8655. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  8656. }
  8657. if m.id == nil || m.oldValue == nil {
  8658. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  8659. }
  8660. oldValue, err := m.oldValue(ctx)
  8661. if err != nil {
  8662. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  8663. }
  8664. return oldValue.Headimg, nil
  8665. }
  8666. // ResetHeadimg resets all changes to the "headimg" field.
  8667. func (m *ContactMutation) ResetHeadimg() {
  8668. m.headimg = nil
  8669. }
  8670. // SetSex sets the "sex" field.
  8671. func (m *ContactMutation) SetSex(i int) {
  8672. m.sex = &i
  8673. m.addsex = nil
  8674. }
  8675. // Sex returns the value of the "sex" field in the mutation.
  8676. func (m *ContactMutation) Sex() (r int, exists bool) {
  8677. v := m.sex
  8678. if v == nil {
  8679. return
  8680. }
  8681. return *v, true
  8682. }
  8683. // OldSex returns the old "sex" field's value of the Contact entity.
  8684. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8685. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8686. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  8687. if !m.op.Is(OpUpdateOne) {
  8688. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  8689. }
  8690. if m.id == nil || m.oldValue == nil {
  8691. return v, errors.New("OldSex requires an ID field in the mutation")
  8692. }
  8693. oldValue, err := m.oldValue(ctx)
  8694. if err != nil {
  8695. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  8696. }
  8697. return oldValue.Sex, nil
  8698. }
  8699. // AddSex adds i to the "sex" field.
  8700. func (m *ContactMutation) AddSex(i int) {
  8701. if m.addsex != nil {
  8702. *m.addsex += i
  8703. } else {
  8704. m.addsex = &i
  8705. }
  8706. }
  8707. // AddedSex returns the value that was added to the "sex" field in this mutation.
  8708. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  8709. v := m.addsex
  8710. if v == nil {
  8711. return
  8712. }
  8713. return *v, true
  8714. }
  8715. // ResetSex resets all changes to the "sex" field.
  8716. func (m *ContactMutation) ResetSex() {
  8717. m.sex = nil
  8718. m.addsex = nil
  8719. }
  8720. // SetStarrole sets the "starrole" field.
  8721. func (m *ContactMutation) SetStarrole(s string) {
  8722. m.starrole = &s
  8723. }
  8724. // Starrole returns the value of the "starrole" field in the mutation.
  8725. func (m *ContactMutation) Starrole() (r string, exists bool) {
  8726. v := m.starrole
  8727. if v == nil {
  8728. return
  8729. }
  8730. return *v, true
  8731. }
  8732. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  8733. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8734. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8735. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  8736. if !m.op.Is(OpUpdateOne) {
  8737. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  8738. }
  8739. if m.id == nil || m.oldValue == nil {
  8740. return v, errors.New("OldStarrole requires an ID field in the mutation")
  8741. }
  8742. oldValue, err := m.oldValue(ctx)
  8743. if err != nil {
  8744. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  8745. }
  8746. return oldValue.Starrole, nil
  8747. }
  8748. // ResetStarrole resets all changes to the "starrole" field.
  8749. func (m *ContactMutation) ResetStarrole() {
  8750. m.starrole = nil
  8751. }
  8752. // SetDontseeit sets the "dontseeit" field.
  8753. func (m *ContactMutation) SetDontseeit(i int) {
  8754. m.dontseeit = &i
  8755. m.adddontseeit = nil
  8756. }
  8757. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  8758. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  8759. v := m.dontseeit
  8760. if v == nil {
  8761. return
  8762. }
  8763. return *v, true
  8764. }
  8765. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  8766. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8767. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8768. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  8769. if !m.op.Is(OpUpdateOne) {
  8770. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  8771. }
  8772. if m.id == nil || m.oldValue == nil {
  8773. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  8774. }
  8775. oldValue, err := m.oldValue(ctx)
  8776. if err != nil {
  8777. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  8778. }
  8779. return oldValue.Dontseeit, nil
  8780. }
  8781. // AddDontseeit adds i to the "dontseeit" field.
  8782. func (m *ContactMutation) AddDontseeit(i int) {
  8783. if m.adddontseeit != nil {
  8784. *m.adddontseeit += i
  8785. } else {
  8786. m.adddontseeit = &i
  8787. }
  8788. }
  8789. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  8790. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  8791. v := m.adddontseeit
  8792. if v == nil {
  8793. return
  8794. }
  8795. return *v, true
  8796. }
  8797. // ResetDontseeit resets all changes to the "dontseeit" field.
  8798. func (m *ContactMutation) ResetDontseeit() {
  8799. m.dontseeit = nil
  8800. m.adddontseeit = nil
  8801. }
  8802. // SetDontseeme sets the "dontseeme" field.
  8803. func (m *ContactMutation) SetDontseeme(i int) {
  8804. m.dontseeme = &i
  8805. m.adddontseeme = nil
  8806. }
  8807. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  8808. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  8809. v := m.dontseeme
  8810. if v == nil {
  8811. return
  8812. }
  8813. return *v, true
  8814. }
  8815. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  8816. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8817. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8818. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  8819. if !m.op.Is(OpUpdateOne) {
  8820. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  8821. }
  8822. if m.id == nil || m.oldValue == nil {
  8823. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  8824. }
  8825. oldValue, err := m.oldValue(ctx)
  8826. if err != nil {
  8827. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  8828. }
  8829. return oldValue.Dontseeme, nil
  8830. }
  8831. // AddDontseeme adds i to the "dontseeme" field.
  8832. func (m *ContactMutation) AddDontseeme(i int) {
  8833. if m.adddontseeme != nil {
  8834. *m.adddontseeme += i
  8835. } else {
  8836. m.adddontseeme = &i
  8837. }
  8838. }
  8839. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  8840. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  8841. v := m.adddontseeme
  8842. if v == nil {
  8843. return
  8844. }
  8845. return *v, true
  8846. }
  8847. // ResetDontseeme resets all changes to the "dontseeme" field.
  8848. func (m *ContactMutation) ResetDontseeme() {
  8849. m.dontseeme = nil
  8850. m.adddontseeme = nil
  8851. }
  8852. // SetLag sets the "lag" field.
  8853. func (m *ContactMutation) SetLag(s string) {
  8854. m.lag = &s
  8855. }
  8856. // Lag returns the value of the "lag" field in the mutation.
  8857. func (m *ContactMutation) Lag() (r string, exists bool) {
  8858. v := m.lag
  8859. if v == nil {
  8860. return
  8861. }
  8862. return *v, true
  8863. }
  8864. // OldLag returns the old "lag" field's value of the Contact entity.
  8865. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8866. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8867. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  8868. if !m.op.Is(OpUpdateOne) {
  8869. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  8870. }
  8871. if m.id == nil || m.oldValue == nil {
  8872. return v, errors.New("OldLag requires an ID field in the mutation")
  8873. }
  8874. oldValue, err := m.oldValue(ctx)
  8875. if err != nil {
  8876. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  8877. }
  8878. return oldValue.Lag, nil
  8879. }
  8880. // ResetLag resets all changes to the "lag" field.
  8881. func (m *ContactMutation) ResetLag() {
  8882. m.lag = nil
  8883. }
  8884. // SetGid sets the "gid" field.
  8885. func (m *ContactMutation) SetGid(s string) {
  8886. m.gid = &s
  8887. }
  8888. // Gid returns the value of the "gid" field in the mutation.
  8889. func (m *ContactMutation) Gid() (r string, exists bool) {
  8890. v := m.gid
  8891. if v == nil {
  8892. return
  8893. }
  8894. return *v, true
  8895. }
  8896. // OldGid returns the old "gid" field's value of the Contact entity.
  8897. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8898. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8899. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  8900. if !m.op.Is(OpUpdateOne) {
  8901. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  8902. }
  8903. if m.id == nil || m.oldValue == nil {
  8904. return v, errors.New("OldGid requires an ID field in the mutation")
  8905. }
  8906. oldValue, err := m.oldValue(ctx)
  8907. if err != nil {
  8908. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  8909. }
  8910. return oldValue.Gid, nil
  8911. }
  8912. // ResetGid resets all changes to the "gid" field.
  8913. func (m *ContactMutation) ResetGid() {
  8914. m.gid = nil
  8915. }
  8916. // SetGname sets the "gname" field.
  8917. func (m *ContactMutation) SetGname(s string) {
  8918. m.gname = &s
  8919. }
  8920. // Gname returns the value of the "gname" field in the mutation.
  8921. func (m *ContactMutation) Gname() (r string, exists bool) {
  8922. v := m.gname
  8923. if v == nil {
  8924. return
  8925. }
  8926. return *v, true
  8927. }
  8928. // OldGname returns the old "gname" field's value of the Contact entity.
  8929. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8930. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8931. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  8932. if !m.op.Is(OpUpdateOne) {
  8933. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  8934. }
  8935. if m.id == nil || m.oldValue == nil {
  8936. return v, errors.New("OldGname requires an ID field in the mutation")
  8937. }
  8938. oldValue, err := m.oldValue(ctx)
  8939. if err != nil {
  8940. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  8941. }
  8942. return oldValue.Gname, nil
  8943. }
  8944. // ResetGname resets all changes to the "gname" field.
  8945. func (m *ContactMutation) ResetGname() {
  8946. m.gname = nil
  8947. }
  8948. // SetV3 sets the "v3" field.
  8949. func (m *ContactMutation) SetV3(s string) {
  8950. m.v3 = &s
  8951. }
  8952. // V3 returns the value of the "v3" field in the mutation.
  8953. func (m *ContactMutation) V3() (r string, exists bool) {
  8954. v := m.v3
  8955. if v == nil {
  8956. return
  8957. }
  8958. return *v, true
  8959. }
  8960. // OldV3 returns the old "v3" field's value of the Contact entity.
  8961. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8962. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8963. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  8964. if !m.op.Is(OpUpdateOne) {
  8965. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  8966. }
  8967. if m.id == nil || m.oldValue == nil {
  8968. return v, errors.New("OldV3 requires an ID field in the mutation")
  8969. }
  8970. oldValue, err := m.oldValue(ctx)
  8971. if err != nil {
  8972. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  8973. }
  8974. return oldValue.V3, nil
  8975. }
  8976. // ResetV3 resets all changes to the "v3" field.
  8977. func (m *ContactMutation) ResetV3() {
  8978. m.v3 = nil
  8979. }
  8980. // SetOrganizationID sets the "organization_id" field.
  8981. func (m *ContactMutation) SetOrganizationID(u uint64) {
  8982. m.organization_id = &u
  8983. m.addorganization_id = nil
  8984. }
  8985. // OrganizationID returns the value of the "organization_id" field in the mutation.
  8986. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  8987. v := m.organization_id
  8988. if v == nil {
  8989. return
  8990. }
  8991. return *v, true
  8992. }
  8993. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  8994. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8995. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8996. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  8997. if !m.op.Is(OpUpdateOne) {
  8998. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  8999. }
  9000. if m.id == nil || m.oldValue == nil {
  9001. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  9002. }
  9003. oldValue, err := m.oldValue(ctx)
  9004. if err != nil {
  9005. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  9006. }
  9007. return oldValue.OrganizationID, nil
  9008. }
  9009. // AddOrganizationID adds u to the "organization_id" field.
  9010. func (m *ContactMutation) AddOrganizationID(u int64) {
  9011. if m.addorganization_id != nil {
  9012. *m.addorganization_id += u
  9013. } else {
  9014. m.addorganization_id = &u
  9015. }
  9016. }
  9017. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  9018. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  9019. v := m.addorganization_id
  9020. if v == nil {
  9021. return
  9022. }
  9023. return *v, true
  9024. }
  9025. // ClearOrganizationID clears the value of the "organization_id" field.
  9026. func (m *ContactMutation) ClearOrganizationID() {
  9027. m.organization_id = nil
  9028. m.addorganization_id = nil
  9029. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  9030. }
  9031. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  9032. func (m *ContactMutation) OrganizationIDCleared() bool {
  9033. _, ok := m.clearedFields[contact.FieldOrganizationID]
  9034. return ok
  9035. }
  9036. // ResetOrganizationID resets all changes to the "organization_id" field.
  9037. func (m *ContactMutation) ResetOrganizationID() {
  9038. m.organization_id = nil
  9039. m.addorganization_id = nil
  9040. delete(m.clearedFields, contact.FieldOrganizationID)
  9041. }
  9042. // SetCtype sets the "ctype" field.
  9043. func (m *ContactMutation) SetCtype(u uint64) {
  9044. m.ctype = &u
  9045. m.addctype = nil
  9046. }
  9047. // Ctype returns the value of the "ctype" field in the mutation.
  9048. func (m *ContactMutation) Ctype() (r uint64, exists bool) {
  9049. v := m.ctype
  9050. if v == nil {
  9051. return
  9052. }
  9053. return *v, true
  9054. }
  9055. // OldCtype returns the old "ctype" field's value of the Contact entity.
  9056. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9057. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9058. func (m *ContactMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  9059. if !m.op.Is(OpUpdateOne) {
  9060. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  9061. }
  9062. if m.id == nil || m.oldValue == nil {
  9063. return v, errors.New("OldCtype requires an ID field in the mutation")
  9064. }
  9065. oldValue, err := m.oldValue(ctx)
  9066. if err != nil {
  9067. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  9068. }
  9069. return oldValue.Ctype, nil
  9070. }
  9071. // AddCtype adds u to the "ctype" field.
  9072. func (m *ContactMutation) AddCtype(u int64) {
  9073. if m.addctype != nil {
  9074. *m.addctype += u
  9075. } else {
  9076. m.addctype = &u
  9077. }
  9078. }
  9079. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  9080. func (m *ContactMutation) AddedCtype() (r int64, exists bool) {
  9081. v := m.addctype
  9082. if v == nil {
  9083. return
  9084. }
  9085. return *v, true
  9086. }
  9087. // ResetCtype resets all changes to the "ctype" field.
  9088. func (m *ContactMutation) ResetCtype() {
  9089. m.ctype = nil
  9090. m.addctype = nil
  9091. }
  9092. // SetCage sets the "cage" field.
  9093. func (m *ContactMutation) SetCage(i int) {
  9094. m.cage = &i
  9095. m.addcage = nil
  9096. }
  9097. // Cage returns the value of the "cage" field in the mutation.
  9098. func (m *ContactMutation) Cage() (r int, exists bool) {
  9099. v := m.cage
  9100. if v == nil {
  9101. return
  9102. }
  9103. return *v, true
  9104. }
  9105. // OldCage returns the old "cage" field's value of the Contact entity.
  9106. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9107. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9108. func (m *ContactMutation) OldCage(ctx context.Context) (v int, err error) {
  9109. if !m.op.Is(OpUpdateOne) {
  9110. return v, errors.New("OldCage is only allowed on UpdateOne operations")
  9111. }
  9112. if m.id == nil || m.oldValue == nil {
  9113. return v, errors.New("OldCage requires an ID field in the mutation")
  9114. }
  9115. oldValue, err := m.oldValue(ctx)
  9116. if err != nil {
  9117. return v, fmt.Errorf("querying old value for OldCage: %w", err)
  9118. }
  9119. return oldValue.Cage, nil
  9120. }
  9121. // AddCage adds i to the "cage" field.
  9122. func (m *ContactMutation) AddCage(i int) {
  9123. if m.addcage != nil {
  9124. *m.addcage += i
  9125. } else {
  9126. m.addcage = &i
  9127. }
  9128. }
  9129. // AddedCage returns the value that was added to the "cage" field in this mutation.
  9130. func (m *ContactMutation) AddedCage() (r int, exists bool) {
  9131. v := m.addcage
  9132. if v == nil {
  9133. return
  9134. }
  9135. return *v, true
  9136. }
  9137. // ResetCage resets all changes to the "cage" field.
  9138. func (m *ContactMutation) ResetCage() {
  9139. m.cage = nil
  9140. m.addcage = nil
  9141. }
  9142. // SetCname sets the "cname" field.
  9143. func (m *ContactMutation) SetCname(s string) {
  9144. m.cname = &s
  9145. }
  9146. // Cname returns the value of the "cname" field in the mutation.
  9147. func (m *ContactMutation) Cname() (r string, exists bool) {
  9148. v := m.cname
  9149. if v == nil {
  9150. return
  9151. }
  9152. return *v, true
  9153. }
  9154. // OldCname returns the old "cname" field's value of the Contact entity.
  9155. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9156. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9157. func (m *ContactMutation) OldCname(ctx context.Context) (v string, err error) {
  9158. if !m.op.Is(OpUpdateOne) {
  9159. return v, errors.New("OldCname is only allowed on UpdateOne operations")
  9160. }
  9161. if m.id == nil || m.oldValue == nil {
  9162. return v, errors.New("OldCname requires an ID field in the mutation")
  9163. }
  9164. oldValue, err := m.oldValue(ctx)
  9165. if err != nil {
  9166. return v, fmt.Errorf("querying old value for OldCname: %w", err)
  9167. }
  9168. return oldValue.Cname, nil
  9169. }
  9170. // ResetCname resets all changes to the "cname" field.
  9171. func (m *ContactMutation) ResetCname() {
  9172. m.cname = nil
  9173. }
  9174. // SetCarea sets the "carea" field.
  9175. func (m *ContactMutation) SetCarea(s string) {
  9176. m.carea = &s
  9177. }
  9178. // Carea returns the value of the "carea" field in the mutation.
  9179. func (m *ContactMutation) Carea() (r string, exists bool) {
  9180. v := m.carea
  9181. if v == nil {
  9182. return
  9183. }
  9184. return *v, true
  9185. }
  9186. // OldCarea returns the old "carea" field's value of the Contact entity.
  9187. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9189. func (m *ContactMutation) OldCarea(ctx context.Context) (v string, err error) {
  9190. if !m.op.Is(OpUpdateOne) {
  9191. return v, errors.New("OldCarea is only allowed on UpdateOne operations")
  9192. }
  9193. if m.id == nil || m.oldValue == nil {
  9194. return v, errors.New("OldCarea requires an ID field in the mutation")
  9195. }
  9196. oldValue, err := m.oldValue(ctx)
  9197. if err != nil {
  9198. return v, fmt.Errorf("querying old value for OldCarea: %w", err)
  9199. }
  9200. return oldValue.Carea, nil
  9201. }
  9202. // ResetCarea resets all changes to the "carea" field.
  9203. func (m *ContactMutation) ResetCarea() {
  9204. m.carea = nil
  9205. }
  9206. // SetCbirthday sets the "cbirthday" field.
  9207. func (m *ContactMutation) SetCbirthday(s string) {
  9208. m.cbirthday = &s
  9209. }
  9210. // Cbirthday returns the value of the "cbirthday" field in the mutation.
  9211. func (m *ContactMutation) Cbirthday() (r string, exists bool) {
  9212. v := m.cbirthday
  9213. if v == nil {
  9214. return
  9215. }
  9216. return *v, true
  9217. }
  9218. // OldCbirthday returns the old "cbirthday" field's value of the Contact entity.
  9219. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9220. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9221. func (m *ContactMutation) OldCbirthday(ctx context.Context) (v string, err error) {
  9222. if !m.op.Is(OpUpdateOne) {
  9223. return v, errors.New("OldCbirthday is only allowed on UpdateOne operations")
  9224. }
  9225. if m.id == nil || m.oldValue == nil {
  9226. return v, errors.New("OldCbirthday requires an ID field in the mutation")
  9227. }
  9228. oldValue, err := m.oldValue(ctx)
  9229. if err != nil {
  9230. return v, fmt.Errorf("querying old value for OldCbirthday: %w", err)
  9231. }
  9232. return oldValue.Cbirthday, nil
  9233. }
  9234. // ResetCbirthday resets all changes to the "cbirthday" field.
  9235. func (m *ContactMutation) ResetCbirthday() {
  9236. m.cbirthday = nil
  9237. }
  9238. // SetCbirtharea sets the "cbirtharea" field.
  9239. func (m *ContactMutation) SetCbirtharea(s string) {
  9240. m.cbirtharea = &s
  9241. }
  9242. // Cbirtharea returns the value of the "cbirtharea" field in the mutation.
  9243. func (m *ContactMutation) Cbirtharea() (r string, exists bool) {
  9244. v := m.cbirtharea
  9245. if v == nil {
  9246. return
  9247. }
  9248. return *v, true
  9249. }
  9250. // OldCbirtharea returns the old "cbirtharea" field's value of the Contact entity.
  9251. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9252. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9253. func (m *ContactMutation) OldCbirtharea(ctx context.Context) (v string, err error) {
  9254. if !m.op.Is(OpUpdateOne) {
  9255. return v, errors.New("OldCbirtharea is only allowed on UpdateOne operations")
  9256. }
  9257. if m.id == nil || m.oldValue == nil {
  9258. return v, errors.New("OldCbirtharea requires an ID field in the mutation")
  9259. }
  9260. oldValue, err := m.oldValue(ctx)
  9261. if err != nil {
  9262. return v, fmt.Errorf("querying old value for OldCbirtharea: %w", err)
  9263. }
  9264. return oldValue.Cbirtharea, nil
  9265. }
  9266. // ResetCbirtharea resets all changes to the "cbirtharea" field.
  9267. func (m *ContactMutation) ResetCbirtharea() {
  9268. m.cbirtharea = nil
  9269. }
  9270. // SetCidcardNo sets the "cidcard_no" field.
  9271. func (m *ContactMutation) SetCidcardNo(s string) {
  9272. m.cidcard_no = &s
  9273. }
  9274. // CidcardNo returns the value of the "cidcard_no" field in the mutation.
  9275. func (m *ContactMutation) CidcardNo() (r string, exists bool) {
  9276. v := m.cidcard_no
  9277. if v == nil {
  9278. return
  9279. }
  9280. return *v, true
  9281. }
  9282. // OldCidcardNo returns the old "cidcard_no" field's value of the Contact entity.
  9283. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9284. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9285. func (m *ContactMutation) OldCidcardNo(ctx context.Context) (v string, err error) {
  9286. if !m.op.Is(OpUpdateOne) {
  9287. return v, errors.New("OldCidcardNo is only allowed on UpdateOne operations")
  9288. }
  9289. if m.id == nil || m.oldValue == nil {
  9290. return v, errors.New("OldCidcardNo requires an ID field in the mutation")
  9291. }
  9292. oldValue, err := m.oldValue(ctx)
  9293. if err != nil {
  9294. return v, fmt.Errorf("querying old value for OldCidcardNo: %w", err)
  9295. }
  9296. return oldValue.CidcardNo, nil
  9297. }
  9298. // ResetCidcardNo resets all changes to the "cidcard_no" field.
  9299. func (m *ContactMutation) ResetCidcardNo() {
  9300. m.cidcard_no = nil
  9301. }
  9302. // SetCtitle sets the "ctitle" field.
  9303. func (m *ContactMutation) SetCtitle(s string) {
  9304. m.ctitle = &s
  9305. }
  9306. // Ctitle returns the value of the "ctitle" field in the mutation.
  9307. func (m *ContactMutation) Ctitle() (r string, exists bool) {
  9308. v := m.ctitle
  9309. if v == nil {
  9310. return
  9311. }
  9312. return *v, true
  9313. }
  9314. // OldCtitle returns the old "ctitle" field's value of the Contact entity.
  9315. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9316. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9317. func (m *ContactMutation) OldCtitle(ctx context.Context) (v string, err error) {
  9318. if !m.op.Is(OpUpdateOne) {
  9319. return v, errors.New("OldCtitle is only allowed on UpdateOne operations")
  9320. }
  9321. if m.id == nil || m.oldValue == nil {
  9322. return v, errors.New("OldCtitle requires an ID field in the mutation")
  9323. }
  9324. oldValue, err := m.oldValue(ctx)
  9325. if err != nil {
  9326. return v, fmt.Errorf("querying old value for OldCtitle: %w", err)
  9327. }
  9328. return oldValue.Ctitle, nil
  9329. }
  9330. // ResetCtitle resets all changes to the "ctitle" field.
  9331. func (m *ContactMutation) ResetCtitle() {
  9332. m.ctitle = nil
  9333. }
  9334. // SetCc sets the "cc" field.
  9335. func (m *ContactMutation) SetCc(s string) {
  9336. m.cc = &s
  9337. }
  9338. // Cc returns the value of the "cc" field in the mutation.
  9339. func (m *ContactMutation) Cc() (r string, exists bool) {
  9340. v := m.cc
  9341. if v == nil {
  9342. return
  9343. }
  9344. return *v, true
  9345. }
  9346. // OldCc returns the old "cc" field's value of the Contact entity.
  9347. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9348. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9349. func (m *ContactMutation) OldCc(ctx context.Context) (v string, err error) {
  9350. if !m.op.Is(OpUpdateOne) {
  9351. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  9352. }
  9353. if m.id == nil || m.oldValue == nil {
  9354. return v, errors.New("OldCc requires an ID field in the mutation")
  9355. }
  9356. oldValue, err := m.oldValue(ctx)
  9357. if err != nil {
  9358. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  9359. }
  9360. return oldValue.Cc, nil
  9361. }
  9362. // ResetCc resets all changes to the "cc" field.
  9363. func (m *ContactMutation) ResetCc() {
  9364. m.cc = nil
  9365. }
  9366. // SetPhone sets the "phone" field.
  9367. func (m *ContactMutation) SetPhone(s string) {
  9368. m.phone = &s
  9369. }
  9370. // Phone returns the value of the "phone" field in the mutation.
  9371. func (m *ContactMutation) Phone() (r string, exists bool) {
  9372. v := m.phone
  9373. if v == nil {
  9374. return
  9375. }
  9376. return *v, true
  9377. }
  9378. // OldPhone returns the old "phone" field's value of the Contact entity.
  9379. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9380. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9381. func (m *ContactMutation) OldPhone(ctx context.Context) (v string, err error) {
  9382. if !m.op.Is(OpUpdateOne) {
  9383. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  9384. }
  9385. if m.id == nil || m.oldValue == nil {
  9386. return v, errors.New("OldPhone requires an ID field in the mutation")
  9387. }
  9388. oldValue, err := m.oldValue(ctx)
  9389. if err != nil {
  9390. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  9391. }
  9392. return oldValue.Phone, nil
  9393. }
  9394. // ResetPhone resets all changes to the "phone" field.
  9395. func (m *ContactMutation) ResetPhone() {
  9396. m.phone = nil
  9397. }
  9398. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  9399. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  9400. if m.contact_relationships == nil {
  9401. m.contact_relationships = make(map[uint64]struct{})
  9402. }
  9403. for i := range ids {
  9404. m.contact_relationships[ids[i]] = struct{}{}
  9405. }
  9406. }
  9407. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  9408. func (m *ContactMutation) ClearContactRelationships() {
  9409. m.clearedcontact_relationships = true
  9410. }
  9411. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  9412. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  9413. return m.clearedcontact_relationships
  9414. }
  9415. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  9416. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  9417. if m.removedcontact_relationships == nil {
  9418. m.removedcontact_relationships = make(map[uint64]struct{})
  9419. }
  9420. for i := range ids {
  9421. delete(m.contact_relationships, ids[i])
  9422. m.removedcontact_relationships[ids[i]] = struct{}{}
  9423. }
  9424. }
  9425. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  9426. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  9427. for id := range m.removedcontact_relationships {
  9428. ids = append(ids, id)
  9429. }
  9430. return
  9431. }
  9432. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  9433. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  9434. for id := range m.contact_relationships {
  9435. ids = append(ids, id)
  9436. }
  9437. return
  9438. }
  9439. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  9440. func (m *ContactMutation) ResetContactRelationships() {
  9441. m.contact_relationships = nil
  9442. m.clearedcontact_relationships = false
  9443. m.removedcontact_relationships = nil
  9444. }
  9445. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  9446. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  9447. if m.contact_messages == nil {
  9448. m.contact_messages = make(map[uint64]struct{})
  9449. }
  9450. for i := range ids {
  9451. m.contact_messages[ids[i]] = struct{}{}
  9452. }
  9453. }
  9454. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  9455. func (m *ContactMutation) ClearContactMessages() {
  9456. m.clearedcontact_messages = true
  9457. }
  9458. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  9459. func (m *ContactMutation) ContactMessagesCleared() bool {
  9460. return m.clearedcontact_messages
  9461. }
  9462. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  9463. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  9464. if m.removedcontact_messages == nil {
  9465. m.removedcontact_messages = make(map[uint64]struct{})
  9466. }
  9467. for i := range ids {
  9468. delete(m.contact_messages, ids[i])
  9469. m.removedcontact_messages[ids[i]] = struct{}{}
  9470. }
  9471. }
  9472. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  9473. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  9474. for id := range m.removedcontact_messages {
  9475. ids = append(ids, id)
  9476. }
  9477. return
  9478. }
  9479. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  9480. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  9481. for id := range m.contact_messages {
  9482. ids = append(ids, id)
  9483. }
  9484. return
  9485. }
  9486. // ResetContactMessages resets all changes to the "contact_messages" edge.
  9487. func (m *ContactMutation) ResetContactMessages() {
  9488. m.contact_messages = nil
  9489. m.clearedcontact_messages = false
  9490. m.removedcontact_messages = nil
  9491. }
  9492. // Where appends a list predicates to the ContactMutation builder.
  9493. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  9494. m.predicates = append(m.predicates, ps...)
  9495. }
  9496. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  9497. // users can use type-assertion to append predicates that do not depend on any generated package.
  9498. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  9499. p := make([]predicate.Contact, len(ps))
  9500. for i := range ps {
  9501. p[i] = ps[i]
  9502. }
  9503. m.Where(p...)
  9504. }
  9505. // Op returns the operation name.
  9506. func (m *ContactMutation) Op() Op {
  9507. return m.op
  9508. }
  9509. // SetOp allows setting the mutation operation.
  9510. func (m *ContactMutation) SetOp(op Op) {
  9511. m.op = op
  9512. }
  9513. // Type returns the node type of this mutation (Contact).
  9514. func (m *ContactMutation) Type() string {
  9515. return m.typ
  9516. }
  9517. // Fields returns all fields that were changed during this mutation. Note that in
  9518. // order to get all numeric fields that were incremented/decremented, call
  9519. // AddedFields().
  9520. func (m *ContactMutation) Fields() []string {
  9521. fields := make([]string, 0, 30)
  9522. if m.created_at != nil {
  9523. fields = append(fields, contact.FieldCreatedAt)
  9524. }
  9525. if m.updated_at != nil {
  9526. fields = append(fields, contact.FieldUpdatedAt)
  9527. }
  9528. if m.status != nil {
  9529. fields = append(fields, contact.FieldStatus)
  9530. }
  9531. if m.deleted_at != nil {
  9532. fields = append(fields, contact.FieldDeletedAt)
  9533. }
  9534. if m.wx_wxid != nil {
  9535. fields = append(fields, contact.FieldWxWxid)
  9536. }
  9537. if m._type != nil {
  9538. fields = append(fields, contact.FieldType)
  9539. }
  9540. if m.wxid != nil {
  9541. fields = append(fields, contact.FieldWxid)
  9542. }
  9543. if m.account != nil {
  9544. fields = append(fields, contact.FieldAccount)
  9545. }
  9546. if m.nickname != nil {
  9547. fields = append(fields, contact.FieldNickname)
  9548. }
  9549. if m.markname != nil {
  9550. fields = append(fields, contact.FieldMarkname)
  9551. }
  9552. if m.headimg != nil {
  9553. fields = append(fields, contact.FieldHeadimg)
  9554. }
  9555. if m.sex != nil {
  9556. fields = append(fields, contact.FieldSex)
  9557. }
  9558. if m.starrole != nil {
  9559. fields = append(fields, contact.FieldStarrole)
  9560. }
  9561. if m.dontseeit != nil {
  9562. fields = append(fields, contact.FieldDontseeit)
  9563. }
  9564. if m.dontseeme != nil {
  9565. fields = append(fields, contact.FieldDontseeme)
  9566. }
  9567. if m.lag != nil {
  9568. fields = append(fields, contact.FieldLag)
  9569. }
  9570. if m.gid != nil {
  9571. fields = append(fields, contact.FieldGid)
  9572. }
  9573. if m.gname != nil {
  9574. fields = append(fields, contact.FieldGname)
  9575. }
  9576. if m.v3 != nil {
  9577. fields = append(fields, contact.FieldV3)
  9578. }
  9579. if m.organization_id != nil {
  9580. fields = append(fields, contact.FieldOrganizationID)
  9581. }
  9582. if m.ctype != nil {
  9583. fields = append(fields, contact.FieldCtype)
  9584. }
  9585. if m.cage != nil {
  9586. fields = append(fields, contact.FieldCage)
  9587. }
  9588. if m.cname != nil {
  9589. fields = append(fields, contact.FieldCname)
  9590. }
  9591. if m.carea != nil {
  9592. fields = append(fields, contact.FieldCarea)
  9593. }
  9594. if m.cbirthday != nil {
  9595. fields = append(fields, contact.FieldCbirthday)
  9596. }
  9597. if m.cbirtharea != nil {
  9598. fields = append(fields, contact.FieldCbirtharea)
  9599. }
  9600. if m.cidcard_no != nil {
  9601. fields = append(fields, contact.FieldCidcardNo)
  9602. }
  9603. if m.ctitle != nil {
  9604. fields = append(fields, contact.FieldCtitle)
  9605. }
  9606. if m.cc != nil {
  9607. fields = append(fields, contact.FieldCc)
  9608. }
  9609. if m.phone != nil {
  9610. fields = append(fields, contact.FieldPhone)
  9611. }
  9612. return fields
  9613. }
  9614. // Field returns the value of a field with the given name. The second boolean
  9615. // return value indicates that this field was not set, or was not defined in the
  9616. // schema.
  9617. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  9618. switch name {
  9619. case contact.FieldCreatedAt:
  9620. return m.CreatedAt()
  9621. case contact.FieldUpdatedAt:
  9622. return m.UpdatedAt()
  9623. case contact.FieldStatus:
  9624. return m.Status()
  9625. case contact.FieldDeletedAt:
  9626. return m.DeletedAt()
  9627. case contact.FieldWxWxid:
  9628. return m.WxWxid()
  9629. case contact.FieldType:
  9630. return m.GetType()
  9631. case contact.FieldWxid:
  9632. return m.Wxid()
  9633. case contact.FieldAccount:
  9634. return m.Account()
  9635. case contact.FieldNickname:
  9636. return m.Nickname()
  9637. case contact.FieldMarkname:
  9638. return m.Markname()
  9639. case contact.FieldHeadimg:
  9640. return m.Headimg()
  9641. case contact.FieldSex:
  9642. return m.Sex()
  9643. case contact.FieldStarrole:
  9644. return m.Starrole()
  9645. case contact.FieldDontseeit:
  9646. return m.Dontseeit()
  9647. case contact.FieldDontseeme:
  9648. return m.Dontseeme()
  9649. case contact.FieldLag:
  9650. return m.Lag()
  9651. case contact.FieldGid:
  9652. return m.Gid()
  9653. case contact.FieldGname:
  9654. return m.Gname()
  9655. case contact.FieldV3:
  9656. return m.V3()
  9657. case contact.FieldOrganizationID:
  9658. return m.OrganizationID()
  9659. case contact.FieldCtype:
  9660. return m.Ctype()
  9661. case contact.FieldCage:
  9662. return m.Cage()
  9663. case contact.FieldCname:
  9664. return m.Cname()
  9665. case contact.FieldCarea:
  9666. return m.Carea()
  9667. case contact.FieldCbirthday:
  9668. return m.Cbirthday()
  9669. case contact.FieldCbirtharea:
  9670. return m.Cbirtharea()
  9671. case contact.FieldCidcardNo:
  9672. return m.CidcardNo()
  9673. case contact.FieldCtitle:
  9674. return m.Ctitle()
  9675. case contact.FieldCc:
  9676. return m.Cc()
  9677. case contact.FieldPhone:
  9678. return m.Phone()
  9679. }
  9680. return nil, false
  9681. }
  9682. // OldField returns the old value of the field from the database. An error is
  9683. // returned if the mutation operation is not UpdateOne, or the query to the
  9684. // database failed.
  9685. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9686. switch name {
  9687. case contact.FieldCreatedAt:
  9688. return m.OldCreatedAt(ctx)
  9689. case contact.FieldUpdatedAt:
  9690. return m.OldUpdatedAt(ctx)
  9691. case contact.FieldStatus:
  9692. return m.OldStatus(ctx)
  9693. case contact.FieldDeletedAt:
  9694. return m.OldDeletedAt(ctx)
  9695. case contact.FieldWxWxid:
  9696. return m.OldWxWxid(ctx)
  9697. case contact.FieldType:
  9698. return m.OldType(ctx)
  9699. case contact.FieldWxid:
  9700. return m.OldWxid(ctx)
  9701. case contact.FieldAccount:
  9702. return m.OldAccount(ctx)
  9703. case contact.FieldNickname:
  9704. return m.OldNickname(ctx)
  9705. case contact.FieldMarkname:
  9706. return m.OldMarkname(ctx)
  9707. case contact.FieldHeadimg:
  9708. return m.OldHeadimg(ctx)
  9709. case contact.FieldSex:
  9710. return m.OldSex(ctx)
  9711. case contact.FieldStarrole:
  9712. return m.OldStarrole(ctx)
  9713. case contact.FieldDontseeit:
  9714. return m.OldDontseeit(ctx)
  9715. case contact.FieldDontseeme:
  9716. return m.OldDontseeme(ctx)
  9717. case contact.FieldLag:
  9718. return m.OldLag(ctx)
  9719. case contact.FieldGid:
  9720. return m.OldGid(ctx)
  9721. case contact.FieldGname:
  9722. return m.OldGname(ctx)
  9723. case contact.FieldV3:
  9724. return m.OldV3(ctx)
  9725. case contact.FieldOrganizationID:
  9726. return m.OldOrganizationID(ctx)
  9727. case contact.FieldCtype:
  9728. return m.OldCtype(ctx)
  9729. case contact.FieldCage:
  9730. return m.OldCage(ctx)
  9731. case contact.FieldCname:
  9732. return m.OldCname(ctx)
  9733. case contact.FieldCarea:
  9734. return m.OldCarea(ctx)
  9735. case contact.FieldCbirthday:
  9736. return m.OldCbirthday(ctx)
  9737. case contact.FieldCbirtharea:
  9738. return m.OldCbirtharea(ctx)
  9739. case contact.FieldCidcardNo:
  9740. return m.OldCidcardNo(ctx)
  9741. case contact.FieldCtitle:
  9742. return m.OldCtitle(ctx)
  9743. case contact.FieldCc:
  9744. return m.OldCc(ctx)
  9745. case contact.FieldPhone:
  9746. return m.OldPhone(ctx)
  9747. }
  9748. return nil, fmt.Errorf("unknown Contact field %s", name)
  9749. }
  9750. // SetField sets the value of a field with the given name. It returns an error if
  9751. // the field is not defined in the schema, or if the type mismatched the field
  9752. // type.
  9753. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  9754. switch name {
  9755. case contact.FieldCreatedAt:
  9756. v, ok := value.(time.Time)
  9757. if !ok {
  9758. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9759. }
  9760. m.SetCreatedAt(v)
  9761. return nil
  9762. case contact.FieldUpdatedAt:
  9763. v, ok := value.(time.Time)
  9764. if !ok {
  9765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9766. }
  9767. m.SetUpdatedAt(v)
  9768. return nil
  9769. case contact.FieldStatus:
  9770. v, ok := value.(uint8)
  9771. if !ok {
  9772. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9773. }
  9774. m.SetStatus(v)
  9775. return nil
  9776. case contact.FieldDeletedAt:
  9777. v, ok := value.(time.Time)
  9778. if !ok {
  9779. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9780. }
  9781. m.SetDeletedAt(v)
  9782. return nil
  9783. case contact.FieldWxWxid:
  9784. v, ok := value.(string)
  9785. if !ok {
  9786. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9787. }
  9788. m.SetWxWxid(v)
  9789. return nil
  9790. case contact.FieldType:
  9791. v, ok := value.(int)
  9792. if !ok {
  9793. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9794. }
  9795. m.SetType(v)
  9796. return nil
  9797. case contact.FieldWxid:
  9798. v, ok := value.(string)
  9799. if !ok {
  9800. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9801. }
  9802. m.SetWxid(v)
  9803. return nil
  9804. case contact.FieldAccount:
  9805. v, ok := value.(string)
  9806. if !ok {
  9807. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9808. }
  9809. m.SetAccount(v)
  9810. return nil
  9811. case contact.FieldNickname:
  9812. v, ok := value.(string)
  9813. if !ok {
  9814. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9815. }
  9816. m.SetNickname(v)
  9817. return nil
  9818. case contact.FieldMarkname:
  9819. v, ok := value.(string)
  9820. if !ok {
  9821. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9822. }
  9823. m.SetMarkname(v)
  9824. return nil
  9825. case contact.FieldHeadimg:
  9826. v, ok := value.(string)
  9827. if !ok {
  9828. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9829. }
  9830. m.SetHeadimg(v)
  9831. return nil
  9832. case contact.FieldSex:
  9833. v, ok := value.(int)
  9834. if !ok {
  9835. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9836. }
  9837. m.SetSex(v)
  9838. return nil
  9839. case contact.FieldStarrole:
  9840. v, ok := value.(string)
  9841. if !ok {
  9842. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9843. }
  9844. m.SetStarrole(v)
  9845. return nil
  9846. case contact.FieldDontseeit:
  9847. v, ok := value.(int)
  9848. if !ok {
  9849. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9850. }
  9851. m.SetDontseeit(v)
  9852. return nil
  9853. case contact.FieldDontseeme:
  9854. v, ok := value.(int)
  9855. if !ok {
  9856. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9857. }
  9858. m.SetDontseeme(v)
  9859. return nil
  9860. case contact.FieldLag:
  9861. v, ok := value.(string)
  9862. if !ok {
  9863. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9864. }
  9865. m.SetLag(v)
  9866. return nil
  9867. case contact.FieldGid:
  9868. v, ok := value.(string)
  9869. if !ok {
  9870. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9871. }
  9872. m.SetGid(v)
  9873. return nil
  9874. case contact.FieldGname:
  9875. v, ok := value.(string)
  9876. if !ok {
  9877. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9878. }
  9879. m.SetGname(v)
  9880. return nil
  9881. case contact.FieldV3:
  9882. v, ok := value.(string)
  9883. if !ok {
  9884. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9885. }
  9886. m.SetV3(v)
  9887. return nil
  9888. case contact.FieldOrganizationID:
  9889. v, ok := value.(uint64)
  9890. if !ok {
  9891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9892. }
  9893. m.SetOrganizationID(v)
  9894. return nil
  9895. case contact.FieldCtype:
  9896. v, ok := value.(uint64)
  9897. if !ok {
  9898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9899. }
  9900. m.SetCtype(v)
  9901. return nil
  9902. case contact.FieldCage:
  9903. v, ok := value.(int)
  9904. if !ok {
  9905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9906. }
  9907. m.SetCage(v)
  9908. return nil
  9909. case contact.FieldCname:
  9910. v, ok := value.(string)
  9911. if !ok {
  9912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9913. }
  9914. m.SetCname(v)
  9915. return nil
  9916. case contact.FieldCarea:
  9917. v, ok := value.(string)
  9918. if !ok {
  9919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9920. }
  9921. m.SetCarea(v)
  9922. return nil
  9923. case contact.FieldCbirthday:
  9924. v, ok := value.(string)
  9925. if !ok {
  9926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9927. }
  9928. m.SetCbirthday(v)
  9929. return nil
  9930. case contact.FieldCbirtharea:
  9931. v, ok := value.(string)
  9932. if !ok {
  9933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9934. }
  9935. m.SetCbirtharea(v)
  9936. return nil
  9937. case contact.FieldCidcardNo:
  9938. v, ok := value.(string)
  9939. if !ok {
  9940. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9941. }
  9942. m.SetCidcardNo(v)
  9943. return nil
  9944. case contact.FieldCtitle:
  9945. v, ok := value.(string)
  9946. if !ok {
  9947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9948. }
  9949. m.SetCtitle(v)
  9950. return nil
  9951. case contact.FieldCc:
  9952. v, ok := value.(string)
  9953. if !ok {
  9954. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9955. }
  9956. m.SetCc(v)
  9957. return nil
  9958. case contact.FieldPhone:
  9959. v, ok := value.(string)
  9960. if !ok {
  9961. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9962. }
  9963. m.SetPhone(v)
  9964. return nil
  9965. }
  9966. return fmt.Errorf("unknown Contact field %s", name)
  9967. }
  9968. // AddedFields returns all numeric fields that were incremented/decremented during
  9969. // this mutation.
  9970. func (m *ContactMutation) AddedFields() []string {
  9971. var fields []string
  9972. if m.addstatus != nil {
  9973. fields = append(fields, contact.FieldStatus)
  9974. }
  9975. if m.add_type != nil {
  9976. fields = append(fields, contact.FieldType)
  9977. }
  9978. if m.addsex != nil {
  9979. fields = append(fields, contact.FieldSex)
  9980. }
  9981. if m.adddontseeit != nil {
  9982. fields = append(fields, contact.FieldDontseeit)
  9983. }
  9984. if m.adddontseeme != nil {
  9985. fields = append(fields, contact.FieldDontseeme)
  9986. }
  9987. if m.addorganization_id != nil {
  9988. fields = append(fields, contact.FieldOrganizationID)
  9989. }
  9990. if m.addctype != nil {
  9991. fields = append(fields, contact.FieldCtype)
  9992. }
  9993. if m.addcage != nil {
  9994. fields = append(fields, contact.FieldCage)
  9995. }
  9996. return fields
  9997. }
  9998. // AddedField returns the numeric value that was incremented/decremented on a field
  9999. // with the given name. The second boolean return value indicates that this field
  10000. // was not set, or was not defined in the schema.
  10001. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  10002. switch name {
  10003. case contact.FieldStatus:
  10004. return m.AddedStatus()
  10005. case contact.FieldType:
  10006. return m.AddedType()
  10007. case contact.FieldSex:
  10008. return m.AddedSex()
  10009. case contact.FieldDontseeit:
  10010. return m.AddedDontseeit()
  10011. case contact.FieldDontseeme:
  10012. return m.AddedDontseeme()
  10013. case contact.FieldOrganizationID:
  10014. return m.AddedOrganizationID()
  10015. case contact.FieldCtype:
  10016. return m.AddedCtype()
  10017. case contact.FieldCage:
  10018. return m.AddedCage()
  10019. }
  10020. return nil, false
  10021. }
  10022. // AddField adds the value to the field with the given name. It returns an error if
  10023. // the field is not defined in the schema, or if the type mismatched the field
  10024. // type.
  10025. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  10026. switch name {
  10027. case contact.FieldStatus:
  10028. v, ok := value.(int8)
  10029. if !ok {
  10030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10031. }
  10032. m.AddStatus(v)
  10033. return nil
  10034. case contact.FieldType:
  10035. v, ok := value.(int)
  10036. if !ok {
  10037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10038. }
  10039. m.AddType(v)
  10040. return nil
  10041. case contact.FieldSex:
  10042. v, ok := value.(int)
  10043. if !ok {
  10044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10045. }
  10046. m.AddSex(v)
  10047. return nil
  10048. case contact.FieldDontseeit:
  10049. v, ok := value.(int)
  10050. if !ok {
  10051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10052. }
  10053. m.AddDontseeit(v)
  10054. return nil
  10055. case contact.FieldDontseeme:
  10056. v, ok := value.(int)
  10057. if !ok {
  10058. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10059. }
  10060. m.AddDontseeme(v)
  10061. return nil
  10062. case contact.FieldOrganizationID:
  10063. v, ok := value.(int64)
  10064. if !ok {
  10065. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10066. }
  10067. m.AddOrganizationID(v)
  10068. return nil
  10069. case contact.FieldCtype:
  10070. v, ok := value.(int64)
  10071. if !ok {
  10072. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10073. }
  10074. m.AddCtype(v)
  10075. return nil
  10076. case contact.FieldCage:
  10077. v, ok := value.(int)
  10078. if !ok {
  10079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10080. }
  10081. m.AddCage(v)
  10082. return nil
  10083. }
  10084. return fmt.Errorf("unknown Contact numeric field %s", name)
  10085. }
  10086. // ClearedFields returns all nullable fields that were cleared during this
  10087. // mutation.
  10088. func (m *ContactMutation) ClearedFields() []string {
  10089. var fields []string
  10090. if m.FieldCleared(contact.FieldStatus) {
  10091. fields = append(fields, contact.FieldStatus)
  10092. }
  10093. if m.FieldCleared(contact.FieldDeletedAt) {
  10094. fields = append(fields, contact.FieldDeletedAt)
  10095. }
  10096. if m.FieldCleared(contact.FieldType) {
  10097. fields = append(fields, contact.FieldType)
  10098. }
  10099. if m.FieldCleared(contact.FieldOrganizationID) {
  10100. fields = append(fields, contact.FieldOrganizationID)
  10101. }
  10102. return fields
  10103. }
  10104. // FieldCleared returns a boolean indicating if a field with the given name was
  10105. // cleared in this mutation.
  10106. func (m *ContactMutation) FieldCleared(name string) bool {
  10107. _, ok := m.clearedFields[name]
  10108. return ok
  10109. }
  10110. // ClearField clears the value of the field with the given name. It returns an
  10111. // error if the field is not defined in the schema.
  10112. func (m *ContactMutation) ClearField(name string) error {
  10113. switch name {
  10114. case contact.FieldStatus:
  10115. m.ClearStatus()
  10116. return nil
  10117. case contact.FieldDeletedAt:
  10118. m.ClearDeletedAt()
  10119. return nil
  10120. case contact.FieldType:
  10121. m.ClearType()
  10122. return nil
  10123. case contact.FieldOrganizationID:
  10124. m.ClearOrganizationID()
  10125. return nil
  10126. }
  10127. return fmt.Errorf("unknown Contact nullable field %s", name)
  10128. }
  10129. // ResetField resets all changes in the mutation for the field with the given name.
  10130. // It returns an error if the field is not defined in the schema.
  10131. func (m *ContactMutation) ResetField(name string) error {
  10132. switch name {
  10133. case contact.FieldCreatedAt:
  10134. m.ResetCreatedAt()
  10135. return nil
  10136. case contact.FieldUpdatedAt:
  10137. m.ResetUpdatedAt()
  10138. return nil
  10139. case contact.FieldStatus:
  10140. m.ResetStatus()
  10141. return nil
  10142. case contact.FieldDeletedAt:
  10143. m.ResetDeletedAt()
  10144. return nil
  10145. case contact.FieldWxWxid:
  10146. m.ResetWxWxid()
  10147. return nil
  10148. case contact.FieldType:
  10149. m.ResetType()
  10150. return nil
  10151. case contact.FieldWxid:
  10152. m.ResetWxid()
  10153. return nil
  10154. case contact.FieldAccount:
  10155. m.ResetAccount()
  10156. return nil
  10157. case contact.FieldNickname:
  10158. m.ResetNickname()
  10159. return nil
  10160. case contact.FieldMarkname:
  10161. m.ResetMarkname()
  10162. return nil
  10163. case contact.FieldHeadimg:
  10164. m.ResetHeadimg()
  10165. return nil
  10166. case contact.FieldSex:
  10167. m.ResetSex()
  10168. return nil
  10169. case contact.FieldStarrole:
  10170. m.ResetStarrole()
  10171. return nil
  10172. case contact.FieldDontseeit:
  10173. m.ResetDontseeit()
  10174. return nil
  10175. case contact.FieldDontseeme:
  10176. m.ResetDontseeme()
  10177. return nil
  10178. case contact.FieldLag:
  10179. m.ResetLag()
  10180. return nil
  10181. case contact.FieldGid:
  10182. m.ResetGid()
  10183. return nil
  10184. case contact.FieldGname:
  10185. m.ResetGname()
  10186. return nil
  10187. case contact.FieldV3:
  10188. m.ResetV3()
  10189. return nil
  10190. case contact.FieldOrganizationID:
  10191. m.ResetOrganizationID()
  10192. return nil
  10193. case contact.FieldCtype:
  10194. m.ResetCtype()
  10195. return nil
  10196. case contact.FieldCage:
  10197. m.ResetCage()
  10198. return nil
  10199. case contact.FieldCname:
  10200. m.ResetCname()
  10201. return nil
  10202. case contact.FieldCarea:
  10203. m.ResetCarea()
  10204. return nil
  10205. case contact.FieldCbirthday:
  10206. m.ResetCbirthday()
  10207. return nil
  10208. case contact.FieldCbirtharea:
  10209. m.ResetCbirtharea()
  10210. return nil
  10211. case contact.FieldCidcardNo:
  10212. m.ResetCidcardNo()
  10213. return nil
  10214. case contact.FieldCtitle:
  10215. m.ResetCtitle()
  10216. return nil
  10217. case contact.FieldCc:
  10218. m.ResetCc()
  10219. return nil
  10220. case contact.FieldPhone:
  10221. m.ResetPhone()
  10222. return nil
  10223. }
  10224. return fmt.Errorf("unknown Contact field %s", name)
  10225. }
  10226. // AddedEdges returns all edge names that were set/added in this mutation.
  10227. func (m *ContactMutation) AddedEdges() []string {
  10228. edges := make([]string, 0, 2)
  10229. if m.contact_relationships != nil {
  10230. edges = append(edges, contact.EdgeContactRelationships)
  10231. }
  10232. if m.contact_messages != nil {
  10233. edges = append(edges, contact.EdgeContactMessages)
  10234. }
  10235. return edges
  10236. }
  10237. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10238. // name in this mutation.
  10239. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  10240. switch name {
  10241. case contact.EdgeContactRelationships:
  10242. ids := make([]ent.Value, 0, len(m.contact_relationships))
  10243. for id := range m.contact_relationships {
  10244. ids = append(ids, id)
  10245. }
  10246. return ids
  10247. case contact.EdgeContactMessages:
  10248. ids := make([]ent.Value, 0, len(m.contact_messages))
  10249. for id := range m.contact_messages {
  10250. ids = append(ids, id)
  10251. }
  10252. return ids
  10253. }
  10254. return nil
  10255. }
  10256. // RemovedEdges returns all edge names that were removed in this mutation.
  10257. func (m *ContactMutation) RemovedEdges() []string {
  10258. edges := make([]string, 0, 2)
  10259. if m.removedcontact_relationships != nil {
  10260. edges = append(edges, contact.EdgeContactRelationships)
  10261. }
  10262. if m.removedcontact_messages != nil {
  10263. edges = append(edges, contact.EdgeContactMessages)
  10264. }
  10265. return edges
  10266. }
  10267. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10268. // the given name in this mutation.
  10269. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  10270. switch name {
  10271. case contact.EdgeContactRelationships:
  10272. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  10273. for id := range m.removedcontact_relationships {
  10274. ids = append(ids, id)
  10275. }
  10276. return ids
  10277. case contact.EdgeContactMessages:
  10278. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  10279. for id := range m.removedcontact_messages {
  10280. ids = append(ids, id)
  10281. }
  10282. return ids
  10283. }
  10284. return nil
  10285. }
  10286. // ClearedEdges returns all edge names that were cleared in this mutation.
  10287. func (m *ContactMutation) ClearedEdges() []string {
  10288. edges := make([]string, 0, 2)
  10289. if m.clearedcontact_relationships {
  10290. edges = append(edges, contact.EdgeContactRelationships)
  10291. }
  10292. if m.clearedcontact_messages {
  10293. edges = append(edges, contact.EdgeContactMessages)
  10294. }
  10295. return edges
  10296. }
  10297. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10298. // was cleared in this mutation.
  10299. func (m *ContactMutation) EdgeCleared(name string) bool {
  10300. switch name {
  10301. case contact.EdgeContactRelationships:
  10302. return m.clearedcontact_relationships
  10303. case contact.EdgeContactMessages:
  10304. return m.clearedcontact_messages
  10305. }
  10306. return false
  10307. }
  10308. // ClearEdge clears the value of the edge with the given name. It returns an error
  10309. // if that edge is not defined in the schema.
  10310. func (m *ContactMutation) ClearEdge(name string) error {
  10311. switch name {
  10312. }
  10313. return fmt.Errorf("unknown Contact unique edge %s", name)
  10314. }
  10315. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10316. // It returns an error if the edge is not defined in the schema.
  10317. func (m *ContactMutation) ResetEdge(name string) error {
  10318. switch name {
  10319. case contact.EdgeContactRelationships:
  10320. m.ResetContactRelationships()
  10321. return nil
  10322. case contact.EdgeContactMessages:
  10323. m.ResetContactMessages()
  10324. return nil
  10325. }
  10326. return fmt.Errorf("unknown Contact edge %s", name)
  10327. }
  10328. // CreditBalanceMutation represents an operation that mutates the CreditBalance nodes in the graph.
  10329. type CreditBalanceMutation struct {
  10330. config
  10331. op Op
  10332. typ string
  10333. id *uint64
  10334. created_at *time.Time
  10335. updated_at *time.Time
  10336. deleted_at *time.Time
  10337. user_id *string
  10338. balance *float32
  10339. addbalance *float32
  10340. status *int
  10341. addstatus *int
  10342. organization_id *uint64
  10343. addorganization_id *int64
  10344. clearedFields map[string]struct{}
  10345. done bool
  10346. oldValue func(context.Context) (*CreditBalance, error)
  10347. predicates []predicate.CreditBalance
  10348. }
  10349. var _ ent.Mutation = (*CreditBalanceMutation)(nil)
  10350. // creditbalanceOption allows management of the mutation configuration using functional options.
  10351. type creditbalanceOption func(*CreditBalanceMutation)
  10352. // newCreditBalanceMutation creates new mutation for the CreditBalance entity.
  10353. func newCreditBalanceMutation(c config, op Op, opts ...creditbalanceOption) *CreditBalanceMutation {
  10354. m := &CreditBalanceMutation{
  10355. config: c,
  10356. op: op,
  10357. typ: TypeCreditBalance,
  10358. clearedFields: make(map[string]struct{}),
  10359. }
  10360. for _, opt := range opts {
  10361. opt(m)
  10362. }
  10363. return m
  10364. }
  10365. // withCreditBalanceID sets the ID field of the mutation.
  10366. func withCreditBalanceID(id uint64) creditbalanceOption {
  10367. return func(m *CreditBalanceMutation) {
  10368. var (
  10369. err error
  10370. once sync.Once
  10371. value *CreditBalance
  10372. )
  10373. m.oldValue = func(ctx context.Context) (*CreditBalance, error) {
  10374. once.Do(func() {
  10375. if m.done {
  10376. err = errors.New("querying old values post mutation is not allowed")
  10377. } else {
  10378. value, err = m.Client().CreditBalance.Get(ctx, id)
  10379. }
  10380. })
  10381. return value, err
  10382. }
  10383. m.id = &id
  10384. }
  10385. }
  10386. // withCreditBalance sets the old CreditBalance of the mutation.
  10387. func withCreditBalance(node *CreditBalance) creditbalanceOption {
  10388. return func(m *CreditBalanceMutation) {
  10389. m.oldValue = func(context.Context) (*CreditBalance, error) {
  10390. return node, nil
  10391. }
  10392. m.id = &node.ID
  10393. }
  10394. }
  10395. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10396. // executed in a transaction (ent.Tx), a transactional client is returned.
  10397. func (m CreditBalanceMutation) Client() *Client {
  10398. client := &Client{config: m.config}
  10399. client.init()
  10400. return client
  10401. }
  10402. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10403. // it returns an error otherwise.
  10404. func (m CreditBalanceMutation) Tx() (*Tx, error) {
  10405. if _, ok := m.driver.(*txDriver); !ok {
  10406. return nil, errors.New("ent: mutation is not running in a transaction")
  10407. }
  10408. tx := &Tx{config: m.config}
  10409. tx.init()
  10410. return tx, nil
  10411. }
  10412. // SetID sets the value of the id field. Note that this
  10413. // operation is only accepted on creation of CreditBalance entities.
  10414. func (m *CreditBalanceMutation) SetID(id uint64) {
  10415. m.id = &id
  10416. }
  10417. // ID returns the ID value in the mutation. Note that the ID is only available
  10418. // if it was provided to the builder or after it was returned from the database.
  10419. func (m *CreditBalanceMutation) ID() (id uint64, exists bool) {
  10420. if m.id == nil {
  10421. return
  10422. }
  10423. return *m.id, true
  10424. }
  10425. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10426. // That means, if the mutation is applied within a transaction with an isolation level such
  10427. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10428. // or updated by the mutation.
  10429. func (m *CreditBalanceMutation) IDs(ctx context.Context) ([]uint64, error) {
  10430. switch {
  10431. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10432. id, exists := m.ID()
  10433. if exists {
  10434. return []uint64{id}, nil
  10435. }
  10436. fallthrough
  10437. case m.op.Is(OpUpdate | OpDelete):
  10438. return m.Client().CreditBalance.Query().Where(m.predicates...).IDs(ctx)
  10439. default:
  10440. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10441. }
  10442. }
  10443. // SetCreatedAt sets the "created_at" field.
  10444. func (m *CreditBalanceMutation) SetCreatedAt(t time.Time) {
  10445. m.created_at = &t
  10446. }
  10447. // CreatedAt returns the value of the "created_at" field in the mutation.
  10448. func (m *CreditBalanceMutation) CreatedAt() (r time.Time, exists bool) {
  10449. v := m.created_at
  10450. if v == nil {
  10451. return
  10452. }
  10453. return *v, true
  10454. }
  10455. // OldCreatedAt returns the old "created_at" field's value of the CreditBalance entity.
  10456. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  10457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10458. func (m *CreditBalanceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10459. if !m.op.Is(OpUpdateOne) {
  10460. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10461. }
  10462. if m.id == nil || m.oldValue == nil {
  10463. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10464. }
  10465. oldValue, err := m.oldValue(ctx)
  10466. if err != nil {
  10467. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10468. }
  10469. return oldValue.CreatedAt, nil
  10470. }
  10471. // ResetCreatedAt resets all changes to the "created_at" field.
  10472. func (m *CreditBalanceMutation) ResetCreatedAt() {
  10473. m.created_at = nil
  10474. }
  10475. // SetUpdatedAt sets the "updated_at" field.
  10476. func (m *CreditBalanceMutation) SetUpdatedAt(t time.Time) {
  10477. m.updated_at = &t
  10478. }
  10479. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10480. func (m *CreditBalanceMutation) UpdatedAt() (r time.Time, exists bool) {
  10481. v := m.updated_at
  10482. if v == nil {
  10483. return
  10484. }
  10485. return *v, true
  10486. }
  10487. // OldUpdatedAt returns the old "updated_at" field's value of the CreditBalance entity.
  10488. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  10489. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10490. func (m *CreditBalanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10491. if !m.op.Is(OpUpdateOne) {
  10492. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10493. }
  10494. if m.id == nil || m.oldValue == nil {
  10495. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10496. }
  10497. oldValue, err := m.oldValue(ctx)
  10498. if err != nil {
  10499. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10500. }
  10501. return oldValue.UpdatedAt, nil
  10502. }
  10503. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10504. func (m *CreditBalanceMutation) ResetUpdatedAt() {
  10505. m.updated_at = nil
  10506. }
  10507. // SetDeletedAt sets the "deleted_at" field.
  10508. func (m *CreditBalanceMutation) SetDeletedAt(t time.Time) {
  10509. m.deleted_at = &t
  10510. }
  10511. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10512. func (m *CreditBalanceMutation) DeletedAt() (r time.Time, exists bool) {
  10513. v := m.deleted_at
  10514. if v == nil {
  10515. return
  10516. }
  10517. return *v, true
  10518. }
  10519. // OldDeletedAt returns the old "deleted_at" field's value of the CreditBalance entity.
  10520. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  10521. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10522. func (m *CreditBalanceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10523. if !m.op.Is(OpUpdateOne) {
  10524. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10525. }
  10526. if m.id == nil || m.oldValue == nil {
  10527. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10528. }
  10529. oldValue, err := m.oldValue(ctx)
  10530. if err != nil {
  10531. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10532. }
  10533. return oldValue.DeletedAt, nil
  10534. }
  10535. // ClearDeletedAt clears the value of the "deleted_at" field.
  10536. func (m *CreditBalanceMutation) ClearDeletedAt() {
  10537. m.deleted_at = nil
  10538. m.clearedFields[creditbalance.FieldDeletedAt] = struct{}{}
  10539. }
  10540. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10541. func (m *CreditBalanceMutation) DeletedAtCleared() bool {
  10542. _, ok := m.clearedFields[creditbalance.FieldDeletedAt]
  10543. return ok
  10544. }
  10545. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10546. func (m *CreditBalanceMutation) ResetDeletedAt() {
  10547. m.deleted_at = nil
  10548. delete(m.clearedFields, creditbalance.FieldDeletedAt)
  10549. }
  10550. // SetUserID sets the "user_id" field.
  10551. func (m *CreditBalanceMutation) SetUserID(s string) {
  10552. m.user_id = &s
  10553. }
  10554. // UserID returns the value of the "user_id" field in the mutation.
  10555. func (m *CreditBalanceMutation) UserID() (r string, exists bool) {
  10556. v := m.user_id
  10557. if v == nil {
  10558. return
  10559. }
  10560. return *v, true
  10561. }
  10562. // OldUserID returns the old "user_id" field's value of the CreditBalance entity.
  10563. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  10564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10565. func (m *CreditBalanceMutation) OldUserID(ctx context.Context) (v string, err error) {
  10566. if !m.op.Is(OpUpdateOne) {
  10567. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  10568. }
  10569. if m.id == nil || m.oldValue == nil {
  10570. return v, errors.New("OldUserID requires an ID field in the mutation")
  10571. }
  10572. oldValue, err := m.oldValue(ctx)
  10573. if err != nil {
  10574. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  10575. }
  10576. return oldValue.UserID, nil
  10577. }
  10578. // ClearUserID clears the value of the "user_id" field.
  10579. func (m *CreditBalanceMutation) ClearUserID() {
  10580. m.user_id = nil
  10581. m.clearedFields[creditbalance.FieldUserID] = struct{}{}
  10582. }
  10583. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  10584. func (m *CreditBalanceMutation) UserIDCleared() bool {
  10585. _, ok := m.clearedFields[creditbalance.FieldUserID]
  10586. return ok
  10587. }
  10588. // ResetUserID resets all changes to the "user_id" field.
  10589. func (m *CreditBalanceMutation) ResetUserID() {
  10590. m.user_id = nil
  10591. delete(m.clearedFields, creditbalance.FieldUserID)
  10592. }
  10593. // SetBalance sets the "balance" field.
  10594. func (m *CreditBalanceMutation) SetBalance(f float32) {
  10595. m.balance = &f
  10596. m.addbalance = nil
  10597. }
  10598. // Balance returns the value of the "balance" field in the mutation.
  10599. func (m *CreditBalanceMutation) Balance() (r float32, exists bool) {
  10600. v := m.balance
  10601. if v == nil {
  10602. return
  10603. }
  10604. return *v, true
  10605. }
  10606. // OldBalance returns the old "balance" field's value of the CreditBalance entity.
  10607. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  10608. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10609. func (m *CreditBalanceMutation) OldBalance(ctx context.Context) (v float32, err error) {
  10610. if !m.op.Is(OpUpdateOne) {
  10611. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  10612. }
  10613. if m.id == nil || m.oldValue == nil {
  10614. return v, errors.New("OldBalance requires an ID field in the mutation")
  10615. }
  10616. oldValue, err := m.oldValue(ctx)
  10617. if err != nil {
  10618. return v, fmt.Errorf("querying old value for OldBalance: %w", err)
  10619. }
  10620. return oldValue.Balance, nil
  10621. }
  10622. // AddBalance adds f to the "balance" field.
  10623. func (m *CreditBalanceMutation) AddBalance(f float32) {
  10624. if m.addbalance != nil {
  10625. *m.addbalance += f
  10626. } else {
  10627. m.addbalance = &f
  10628. }
  10629. }
  10630. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  10631. func (m *CreditBalanceMutation) AddedBalance() (r float32, exists bool) {
  10632. v := m.addbalance
  10633. if v == nil {
  10634. return
  10635. }
  10636. return *v, true
  10637. }
  10638. // ResetBalance resets all changes to the "balance" field.
  10639. func (m *CreditBalanceMutation) ResetBalance() {
  10640. m.balance = nil
  10641. m.addbalance = nil
  10642. }
  10643. // SetStatus sets the "status" field.
  10644. func (m *CreditBalanceMutation) SetStatus(i int) {
  10645. m.status = &i
  10646. m.addstatus = nil
  10647. }
  10648. // Status returns the value of the "status" field in the mutation.
  10649. func (m *CreditBalanceMutation) Status() (r int, exists bool) {
  10650. v := m.status
  10651. if v == nil {
  10652. return
  10653. }
  10654. return *v, true
  10655. }
  10656. // OldStatus returns the old "status" field's value of the CreditBalance entity.
  10657. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  10658. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10659. func (m *CreditBalanceMutation) OldStatus(ctx context.Context) (v int, err error) {
  10660. if !m.op.Is(OpUpdateOne) {
  10661. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  10662. }
  10663. if m.id == nil || m.oldValue == nil {
  10664. return v, errors.New("OldStatus requires an ID field in the mutation")
  10665. }
  10666. oldValue, err := m.oldValue(ctx)
  10667. if err != nil {
  10668. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  10669. }
  10670. return oldValue.Status, nil
  10671. }
  10672. // AddStatus adds i to the "status" field.
  10673. func (m *CreditBalanceMutation) AddStatus(i int) {
  10674. if m.addstatus != nil {
  10675. *m.addstatus += i
  10676. } else {
  10677. m.addstatus = &i
  10678. }
  10679. }
  10680. // AddedStatus returns the value that was added to the "status" field in this mutation.
  10681. func (m *CreditBalanceMutation) AddedStatus() (r int, exists bool) {
  10682. v := m.addstatus
  10683. if v == nil {
  10684. return
  10685. }
  10686. return *v, true
  10687. }
  10688. // ClearStatus clears the value of the "status" field.
  10689. func (m *CreditBalanceMutation) ClearStatus() {
  10690. m.status = nil
  10691. m.addstatus = nil
  10692. m.clearedFields[creditbalance.FieldStatus] = struct{}{}
  10693. }
  10694. // StatusCleared returns if the "status" field was cleared in this mutation.
  10695. func (m *CreditBalanceMutation) StatusCleared() bool {
  10696. _, ok := m.clearedFields[creditbalance.FieldStatus]
  10697. return ok
  10698. }
  10699. // ResetStatus resets all changes to the "status" field.
  10700. func (m *CreditBalanceMutation) ResetStatus() {
  10701. m.status = nil
  10702. m.addstatus = nil
  10703. delete(m.clearedFields, creditbalance.FieldStatus)
  10704. }
  10705. // SetOrganizationID sets the "organization_id" field.
  10706. func (m *CreditBalanceMutation) SetOrganizationID(u uint64) {
  10707. m.organization_id = &u
  10708. m.addorganization_id = nil
  10709. }
  10710. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10711. func (m *CreditBalanceMutation) OrganizationID() (r uint64, exists bool) {
  10712. v := m.organization_id
  10713. if v == nil {
  10714. return
  10715. }
  10716. return *v, true
  10717. }
  10718. // OldOrganizationID returns the old "organization_id" field's value of the CreditBalance entity.
  10719. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  10720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10721. func (m *CreditBalanceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10722. if !m.op.Is(OpUpdateOne) {
  10723. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10724. }
  10725. if m.id == nil || m.oldValue == nil {
  10726. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10727. }
  10728. oldValue, err := m.oldValue(ctx)
  10729. if err != nil {
  10730. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10731. }
  10732. return oldValue.OrganizationID, nil
  10733. }
  10734. // AddOrganizationID adds u to the "organization_id" field.
  10735. func (m *CreditBalanceMutation) AddOrganizationID(u int64) {
  10736. if m.addorganization_id != nil {
  10737. *m.addorganization_id += u
  10738. } else {
  10739. m.addorganization_id = &u
  10740. }
  10741. }
  10742. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10743. func (m *CreditBalanceMutation) AddedOrganizationID() (r int64, exists bool) {
  10744. v := m.addorganization_id
  10745. if v == nil {
  10746. return
  10747. }
  10748. return *v, true
  10749. }
  10750. // ClearOrganizationID clears the value of the "organization_id" field.
  10751. func (m *CreditBalanceMutation) ClearOrganizationID() {
  10752. m.organization_id = nil
  10753. m.addorganization_id = nil
  10754. m.clearedFields[creditbalance.FieldOrganizationID] = struct{}{}
  10755. }
  10756. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  10757. func (m *CreditBalanceMutation) OrganizationIDCleared() bool {
  10758. _, ok := m.clearedFields[creditbalance.FieldOrganizationID]
  10759. return ok
  10760. }
  10761. // ResetOrganizationID resets all changes to the "organization_id" field.
  10762. func (m *CreditBalanceMutation) ResetOrganizationID() {
  10763. m.organization_id = nil
  10764. m.addorganization_id = nil
  10765. delete(m.clearedFields, creditbalance.FieldOrganizationID)
  10766. }
  10767. // Where appends a list predicates to the CreditBalanceMutation builder.
  10768. func (m *CreditBalanceMutation) Where(ps ...predicate.CreditBalance) {
  10769. m.predicates = append(m.predicates, ps...)
  10770. }
  10771. // WhereP appends storage-level predicates to the CreditBalanceMutation builder. Using this method,
  10772. // users can use type-assertion to append predicates that do not depend on any generated package.
  10773. func (m *CreditBalanceMutation) WhereP(ps ...func(*sql.Selector)) {
  10774. p := make([]predicate.CreditBalance, len(ps))
  10775. for i := range ps {
  10776. p[i] = ps[i]
  10777. }
  10778. m.Where(p...)
  10779. }
  10780. // Op returns the operation name.
  10781. func (m *CreditBalanceMutation) Op() Op {
  10782. return m.op
  10783. }
  10784. // SetOp allows setting the mutation operation.
  10785. func (m *CreditBalanceMutation) SetOp(op Op) {
  10786. m.op = op
  10787. }
  10788. // Type returns the node type of this mutation (CreditBalance).
  10789. func (m *CreditBalanceMutation) Type() string {
  10790. return m.typ
  10791. }
  10792. // Fields returns all fields that were changed during this mutation. Note that in
  10793. // order to get all numeric fields that were incremented/decremented, call
  10794. // AddedFields().
  10795. func (m *CreditBalanceMutation) Fields() []string {
  10796. fields := make([]string, 0, 7)
  10797. if m.created_at != nil {
  10798. fields = append(fields, creditbalance.FieldCreatedAt)
  10799. }
  10800. if m.updated_at != nil {
  10801. fields = append(fields, creditbalance.FieldUpdatedAt)
  10802. }
  10803. if m.deleted_at != nil {
  10804. fields = append(fields, creditbalance.FieldDeletedAt)
  10805. }
  10806. if m.user_id != nil {
  10807. fields = append(fields, creditbalance.FieldUserID)
  10808. }
  10809. if m.balance != nil {
  10810. fields = append(fields, creditbalance.FieldBalance)
  10811. }
  10812. if m.status != nil {
  10813. fields = append(fields, creditbalance.FieldStatus)
  10814. }
  10815. if m.organization_id != nil {
  10816. fields = append(fields, creditbalance.FieldOrganizationID)
  10817. }
  10818. return fields
  10819. }
  10820. // Field returns the value of a field with the given name. The second boolean
  10821. // return value indicates that this field was not set, or was not defined in the
  10822. // schema.
  10823. func (m *CreditBalanceMutation) Field(name string) (ent.Value, bool) {
  10824. switch name {
  10825. case creditbalance.FieldCreatedAt:
  10826. return m.CreatedAt()
  10827. case creditbalance.FieldUpdatedAt:
  10828. return m.UpdatedAt()
  10829. case creditbalance.FieldDeletedAt:
  10830. return m.DeletedAt()
  10831. case creditbalance.FieldUserID:
  10832. return m.UserID()
  10833. case creditbalance.FieldBalance:
  10834. return m.Balance()
  10835. case creditbalance.FieldStatus:
  10836. return m.Status()
  10837. case creditbalance.FieldOrganizationID:
  10838. return m.OrganizationID()
  10839. }
  10840. return nil, false
  10841. }
  10842. // OldField returns the old value of the field from the database. An error is
  10843. // returned if the mutation operation is not UpdateOne, or the query to the
  10844. // database failed.
  10845. func (m *CreditBalanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10846. switch name {
  10847. case creditbalance.FieldCreatedAt:
  10848. return m.OldCreatedAt(ctx)
  10849. case creditbalance.FieldUpdatedAt:
  10850. return m.OldUpdatedAt(ctx)
  10851. case creditbalance.FieldDeletedAt:
  10852. return m.OldDeletedAt(ctx)
  10853. case creditbalance.FieldUserID:
  10854. return m.OldUserID(ctx)
  10855. case creditbalance.FieldBalance:
  10856. return m.OldBalance(ctx)
  10857. case creditbalance.FieldStatus:
  10858. return m.OldStatus(ctx)
  10859. case creditbalance.FieldOrganizationID:
  10860. return m.OldOrganizationID(ctx)
  10861. }
  10862. return nil, fmt.Errorf("unknown CreditBalance field %s", name)
  10863. }
  10864. // SetField sets the value of a field with the given name. It returns an error if
  10865. // the field is not defined in the schema, or if the type mismatched the field
  10866. // type.
  10867. func (m *CreditBalanceMutation) SetField(name string, value ent.Value) error {
  10868. switch name {
  10869. case creditbalance.FieldCreatedAt:
  10870. v, ok := value.(time.Time)
  10871. if !ok {
  10872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10873. }
  10874. m.SetCreatedAt(v)
  10875. return nil
  10876. case creditbalance.FieldUpdatedAt:
  10877. v, ok := value.(time.Time)
  10878. if !ok {
  10879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10880. }
  10881. m.SetUpdatedAt(v)
  10882. return nil
  10883. case creditbalance.FieldDeletedAt:
  10884. v, ok := value.(time.Time)
  10885. if !ok {
  10886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10887. }
  10888. m.SetDeletedAt(v)
  10889. return nil
  10890. case creditbalance.FieldUserID:
  10891. v, ok := value.(string)
  10892. if !ok {
  10893. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10894. }
  10895. m.SetUserID(v)
  10896. return nil
  10897. case creditbalance.FieldBalance:
  10898. v, ok := value.(float32)
  10899. if !ok {
  10900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10901. }
  10902. m.SetBalance(v)
  10903. return nil
  10904. case creditbalance.FieldStatus:
  10905. v, ok := value.(int)
  10906. if !ok {
  10907. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10908. }
  10909. m.SetStatus(v)
  10910. return nil
  10911. case creditbalance.FieldOrganizationID:
  10912. v, ok := value.(uint64)
  10913. if !ok {
  10914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10915. }
  10916. m.SetOrganizationID(v)
  10917. return nil
  10918. }
  10919. return fmt.Errorf("unknown CreditBalance field %s", name)
  10920. }
  10921. // AddedFields returns all numeric fields that were incremented/decremented during
  10922. // this mutation.
  10923. func (m *CreditBalanceMutation) AddedFields() []string {
  10924. var fields []string
  10925. if m.addbalance != nil {
  10926. fields = append(fields, creditbalance.FieldBalance)
  10927. }
  10928. if m.addstatus != nil {
  10929. fields = append(fields, creditbalance.FieldStatus)
  10930. }
  10931. if m.addorganization_id != nil {
  10932. fields = append(fields, creditbalance.FieldOrganizationID)
  10933. }
  10934. return fields
  10935. }
  10936. // AddedField returns the numeric value that was incremented/decremented on a field
  10937. // with the given name. The second boolean return value indicates that this field
  10938. // was not set, or was not defined in the schema.
  10939. func (m *CreditBalanceMutation) AddedField(name string) (ent.Value, bool) {
  10940. switch name {
  10941. case creditbalance.FieldBalance:
  10942. return m.AddedBalance()
  10943. case creditbalance.FieldStatus:
  10944. return m.AddedStatus()
  10945. case creditbalance.FieldOrganizationID:
  10946. return m.AddedOrganizationID()
  10947. }
  10948. return nil, false
  10949. }
  10950. // AddField adds the value to the field with the given name. It returns an error if
  10951. // the field is not defined in the schema, or if the type mismatched the field
  10952. // type.
  10953. func (m *CreditBalanceMutation) AddField(name string, value ent.Value) error {
  10954. switch name {
  10955. case creditbalance.FieldBalance:
  10956. v, ok := value.(float32)
  10957. if !ok {
  10958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10959. }
  10960. m.AddBalance(v)
  10961. return nil
  10962. case creditbalance.FieldStatus:
  10963. v, ok := value.(int)
  10964. if !ok {
  10965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10966. }
  10967. m.AddStatus(v)
  10968. return nil
  10969. case creditbalance.FieldOrganizationID:
  10970. v, ok := value.(int64)
  10971. if !ok {
  10972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10973. }
  10974. m.AddOrganizationID(v)
  10975. return nil
  10976. }
  10977. return fmt.Errorf("unknown CreditBalance numeric field %s", name)
  10978. }
  10979. // ClearedFields returns all nullable fields that were cleared during this
  10980. // mutation.
  10981. func (m *CreditBalanceMutation) ClearedFields() []string {
  10982. var fields []string
  10983. if m.FieldCleared(creditbalance.FieldDeletedAt) {
  10984. fields = append(fields, creditbalance.FieldDeletedAt)
  10985. }
  10986. if m.FieldCleared(creditbalance.FieldUserID) {
  10987. fields = append(fields, creditbalance.FieldUserID)
  10988. }
  10989. if m.FieldCleared(creditbalance.FieldStatus) {
  10990. fields = append(fields, creditbalance.FieldStatus)
  10991. }
  10992. if m.FieldCleared(creditbalance.FieldOrganizationID) {
  10993. fields = append(fields, creditbalance.FieldOrganizationID)
  10994. }
  10995. return fields
  10996. }
  10997. // FieldCleared returns a boolean indicating if a field with the given name was
  10998. // cleared in this mutation.
  10999. func (m *CreditBalanceMutation) FieldCleared(name string) bool {
  11000. _, ok := m.clearedFields[name]
  11001. return ok
  11002. }
  11003. // ClearField clears the value of the field with the given name. It returns an
  11004. // error if the field is not defined in the schema.
  11005. func (m *CreditBalanceMutation) ClearField(name string) error {
  11006. switch name {
  11007. case creditbalance.FieldDeletedAt:
  11008. m.ClearDeletedAt()
  11009. return nil
  11010. case creditbalance.FieldUserID:
  11011. m.ClearUserID()
  11012. return nil
  11013. case creditbalance.FieldStatus:
  11014. m.ClearStatus()
  11015. return nil
  11016. case creditbalance.FieldOrganizationID:
  11017. m.ClearOrganizationID()
  11018. return nil
  11019. }
  11020. return fmt.Errorf("unknown CreditBalance nullable field %s", name)
  11021. }
  11022. // ResetField resets all changes in the mutation for the field with the given name.
  11023. // It returns an error if the field is not defined in the schema.
  11024. func (m *CreditBalanceMutation) ResetField(name string) error {
  11025. switch name {
  11026. case creditbalance.FieldCreatedAt:
  11027. m.ResetCreatedAt()
  11028. return nil
  11029. case creditbalance.FieldUpdatedAt:
  11030. m.ResetUpdatedAt()
  11031. return nil
  11032. case creditbalance.FieldDeletedAt:
  11033. m.ResetDeletedAt()
  11034. return nil
  11035. case creditbalance.FieldUserID:
  11036. m.ResetUserID()
  11037. return nil
  11038. case creditbalance.FieldBalance:
  11039. m.ResetBalance()
  11040. return nil
  11041. case creditbalance.FieldStatus:
  11042. m.ResetStatus()
  11043. return nil
  11044. case creditbalance.FieldOrganizationID:
  11045. m.ResetOrganizationID()
  11046. return nil
  11047. }
  11048. return fmt.Errorf("unknown CreditBalance field %s", name)
  11049. }
  11050. // AddedEdges returns all edge names that were set/added in this mutation.
  11051. func (m *CreditBalanceMutation) AddedEdges() []string {
  11052. edges := make([]string, 0, 0)
  11053. return edges
  11054. }
  11055. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11056. // name in this mutation.
  11057. func (m *CreditBalanceMutation) AddedIDs(name string) []ent.Value {
  11058. return nil
  11059. }
  11060. // RemovedEdges returns all edge names that were removed in this mutation.
  11061. func (m *CreditBalanceMutation) RemovedEdges() []string {
  11062. edges := make([]string, 0, 0)
  11063. return edges
  11064. }
  11065. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11066. // the given name in this mutation.
  11067. func (m *CreditBalanceMutation) RemovedIDs(name string) []ent.Value {
  11068. return nil
  11069. }
  11070. // ClearedEdges returns all edge names that were cleared in this mutation.
  11071. func (m *CreditBalanceMutation) ClearedEdges() []string {
  11072. edges := make([]string, 0, 0)
  11073. return edges
  11074. }
  11075. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11076. // was cleared in this mutation.
  11077. func (m *CreditBalanceMutation) EdgeCleared(name string) bool {
  11078. return false
  11079. }
  11080. // ClearEdge clears the value of the edge with the given name. It returns an error
  11081. // if that edge is not defined in the schema.
  11082. func (m *CreditBalanceMutation) ClearEdge(name string) error {
  11083. return fmt.Errorf("unknown CreditBalance unique edge %s", name)
  11084. }
  11085. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11086. // It returns an error if the edge is not defined in the schema.
  11087. func (m *CreditBalanceMutation) ResetEdge(name string) error {
  11088. return fmt.Errorf("unknown CreditBalance edge %s", name)
  11089. }
  11090. // CreditUsageMutation represents an operation that mutates the CreditUsage nodes in the graph.
  11091. type CreditUsageMutation struct {
  11092. config
  11093. op Op
  11094. typ string
  11095. id *uint64
  11096. created_at *time.Time
  11097. updated_at *time.Time
  11098. deleted_at *time.Time
  11099. user_id *string
  11100. number *float32
  11101. addnumber *float32
  11102. status *int
  11103. addstatus *int
  11104. ntype *int
  11105. addntype *int
  11106. table *string
  11107. organization_id *uint64
  11108. addorganization_id *int64
  11109. nid *uint64
  11110. addnid *int64
  11111. reason *string
  11112. operator *string
  11113. clearedFields map[string]struct{}
  11114. done bool
  11115. oldValue func(context.Context) (*CreditUsage, error)
  11116. predicates []predicate.CreditUsage
  11117. }
  11118. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  11119. // creditusageOption allows management of the mutation configuration using functional options.
  11120. type creditusageOption func(*CreditUsageMutation)
  11121. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  11122. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  11123. m := &CreditUsageMutation{
  11124. config: c,
  11125. op: op,
  11126. typ: TypeCreditUsage,
  11127. clearedFields: make(map[string]struct{}),
  11128. }
  11129. for _, opt := range opts {
  11130. opt(m)
  11131. }
  11132. return m
  11133. }
  11134. // withCreditUsageID sets the ID field of the mutation.
  11135. func withCreditUsageID(id uint64) creditusageOption {
  11136. return func(m *CreditUsageMutation) {
  11137. var (
  11138. err error
  11139. once sync.Once
  11140. value *CreditUsage
  11141. )
  11142. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  11143. once.Do(func() {
  11144. if m.done {
  11145. err = errors.New("querying old values post mutation is not allowed")
  11146. } else {
  11147. value, err = m.Client().CreditUsage.Get(ctx, id)
  11148. }
  11149. })
  11150. return value, err
  11151. }
  11152. m.id = &id
  11153. }
  11154. }
  11155. // withCreditUsage sets the old CreditUsage of the mutation.
  11156. func withCreditUsage(node *CreditUsage) creditusageOption {
  11157. return func(m *CreditUsageMutation) {
  11158. m.oldValue = func(context.Context) (*CreditUsage, error) {
  11159. return node, nil
  11160. }
  11161. m.id = &node.ID
  11162. }
  11163. }
  11164. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11165. // executed in a transaction (ent.Tx), a transactional client is returned.
  11166. func (m CreditUsageMutation) Client() *Client {
  11167. client := &Client{config: m.config}
  11168. client.init()
  11169. return client
  11170. }
  11171. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11172. // it returns an error otherwise.
  11173. func (m CreditUsageMutation) Tx() (*Tx, error) {
  11174. if _, ok := m.driver.(*txDriver); !ok {
  11175. return nil, errors.New("ent: mutation is not running in a transaction")
  11176. }
  11177. tx := &Tx{config: m.config}
  11178. tx.init()
  11179. return tx, nil
  11180. }
  11181. // SetID sets the value of the id field. Note that this
  11182. // operation is only accepted on creation of CreditUsage entities.
  11183. func (m *CreditUsageMutation) SetID(id uint64) {
  11184. m.id = &id
  11185. }
  11186. // ID returns the ID value in the mutation. Note that the ID is only available
  11187. // if it was provided to the builder or after it was returned from the database.
  11188. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  11189. if m.id == nil {
  11190. return
  11191. }
  11192. return *m.id, true
  11193. }
  11194. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11195. // That means, if the mutation is applied within a transaction with an isolation level such
  11196. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11197. // or updated by the mutation.
  11198. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  11199. switch {
  11200. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11201. id, exists := m.ID()
  11202. if exists {
  11203. return []uint64{id}, nil
  11204. }
  11205. fallthrough
  11206. case m.op.Is(OpUpdate | OpDelete):
  11207. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  11208. default:
  11209. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11210. }
  11211. }
  11212. // SetCreatedAt sets the "created_at" field.
  11213. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  11214. m.created_at = &t
  11215. }
  11216. // CreatedAt returns the value of the "created_at" field in the mutation.
  11217. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  11218. v := m.created_at
  11219. if v == nil {
  11220. return
  11221. }
  11222. return *v, true
  11223. }
  11224. // OldCreatedAt returns the old "created_at" field's value of the CreditUsage entity.
  11225. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11226. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11227. func (m *CreditUsageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11228. if !m.op.Is(OpUpdateOne) {
  11229. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11230. }
  11231. if m.id == nil || m.oldValue == nil {
  11232. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11233. }
  11234. oldValue, err := m.oldValue(ctx)
  11235. if err != nil {
  11236. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11237. }
  11238. return oldValue.CreatedAt, nil
  11239. }
  11240. // ResetCreatedAt resets all changes to the "created_at" field.
  11241. func (m *CreditUsageMutation) ResetCreatedAt() {
  11242. m.created_at = nil
  11243. }
  11244. // SetUpdatedAt sets the "updated_at" field.
  11245. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  11246. m.updated_at = &t
  11247. }
  11248. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11249. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  11250. v := m.updated_at
  11251. if v == nil {
  11252. return
  11253. }
  11254. return *v, true
  11255. }
  11256. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  11257. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11258. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11259. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11260. if !m.op.Is(OpUpdateOne) {
  11261. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11262. }
  11263. if m.id == nil || m.oldValue == nil {
  11264. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11265. }
  11266. oldValue, err := m.oldValue(ctx)
  11267. if err != nil {
  11268. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11269. }
  11270. return oldValue.UpdatedAt, nil
  11271. }
  11272. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11273. func (m *CreditUsageMutation) ResetUpdatedAt() {
  11274. m.updated_at = nil
  11275. }
  11276. // SetDeletedAt sets the "deleted_at" field.
  11277. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  11278. m.deleted_at = &t
  11279. }
  11280. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11281. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  11282. v := m.deleted_at
  11283. if v == nil {
  11284. return
  11285. }
  11286. return *v, true
  11287. }
  11288. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  11289. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11290. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11291. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11292. if !m.op.Is(OpUpdateOne) {
  11293. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11294. }
  11295. if m.id == nil || m.oldValue == nil {
  11296. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11297. }
  11298. oldValue, err := m.oldValue(ctx)
  11299. if err != nil {
  11300. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11301. }
  11302. return oldValue.DeletedAt, nil
  11303. }
  11304. // ClearDeletedAt clears the value of the "deleted_at" field.
  11305. func (m *CreditUsageMutation) ClearDeletedAt() {
  11306. m.deleted_at = nil
  11307. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  11308. }
  11309. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11310. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  11311. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  11312. return ok
  11313. }
  11314. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11315. func (m *CreditUsageMutation) ResetDeletedAt() {
  11316. m.deleted_at = nil
  11317. delete(m.clearedFields, creditusage.FieldDeletedAt)
  11318. }
  11319. // SetUserID sets the "user_id" field.
  11320. func (m *CreditUsageMutation) SetUserID(s string) {
  11321. m.user_id = &s
  11322. }
  11323. // UserID returns the value of the "user_id" field in the mutation.
  11324. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  11325. v := m.user_id
  11326. if v == nil {
  11327. return
  11328. }
  11329. return *v, true
  11330. }
  11331. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  11332. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11333. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11334. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  11335. if !m.op.Is(OpUpdateOne) {
  11336. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  11337. }
  11338. if m.id == nil || m.oldValue == nil {
  11339. return v, errors.New("OldUserID requires an ID field in the mutation")
  11340. }
  11341. oldValue, err := m.oldValue(ctx)
  11342. if err != nil {
  11343. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  11344. }
  11345. return oldValue.UserID, nil
  11346. }
  11347. // ClearUserID clears the value of the "user_id" field.
  11348. func (m *CreditUsageMutation) ClearUserID() {
  11349. m.user_id = nil
  11350. m.clearedFields[creditusage.FieldUserID] = struct{}{}
  11351. }
  11352. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  11353. func (m *CreditUsageMutation) UserIDCleared() bool {
  11354. _, ok := m.clearedFields[creditusage.FieldUserID]
  11355. return ok
  11356. }
  11357. // ResetUserID resets all changes to the "user_id" field.
  11358. func (m *CreditUsageMutation) ResetUserID() {
  11359. m.user_id = nil
  11360. delete(m.clearedFields, creditusage.FieldUserID)
  11361. }
  11362. // SetNumber sets the "number" field.
  11363. func (m *CreditUsageMutation) SetNumber(f float32) {
  11364. m.number = &f
  11365. m.addnumber = nil
  11366. }
  11367. // Number returns the value of the "number" field in the mutation.
  11368. func (m *CreditUsageMutation) Number() (r float32, exists bool) {
  11369. v := m.number
  11370. if v == nil {
  11371. return
  11372. }
  11373. return *v, true
  11374. }
  11375. // OldNumber returns the old "number" field's value of the CreditUsage entity.
  11376. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11377. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11378. func (m *CreditUsageMutation) OldNumber(ctx context.Context) (v float32, err error) {
  11379. if !m.op.Is(OpUpdateOne) {
  11380. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  11381. }
  11382. if m.id == nil || m.oldValue == nil {
  11383. return v, errors.New("OldNumber requires an ID field in the mutation")
  11384. }
  11385. oldValue, err := m.oldValue(ctx)
  11386. if err != nil {
  11387. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  11388. }
  11389. return oldValue.Number, nil
  11390. }
  11391. // AddNumber adds f to the "number" field.
  11392. func (m *CreditUsageMutation) AddNumber(f float32) {
  11393. if m.addnumber != nil {
  11394. *m.addnumber += f
  11395. } else {
  11396. m.addnumber = &f
  11397. }
  11398. }
  11399. // AddedNumber returns the value that was added to the "number" field in this mutation.
  11400. func (m *CreditUsageMutation) AddedNumber() (r float32, exists bool) {
  11401. v := m.addnumber
  11402. if v == nil {
  11403. return
  11404. }
  11405. return *v, true
  11406. }
  11407. // ResetNumber resets all changes to the "number" field.
  11408. func (m *CreditUsageMutation) ResetNumber() {
  11409. m.number = nil
  11410. m.addnumber = nil
  11411. }
  11412. // SetStatus sets the "status" field.
  11413. func (m *CreditUsageMutation) SetStatus(i int) {
  11414. m.status = &i
  11415. m.addstatus = nil
  11416. }
  11417. // Status returns the value of the "status" field in the mutation.
  11418. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  11419. v := m.status
  11420. if v == nil {
  11421. return
  11422. }
  11423. return *v, true
  11424. }
  11425. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  11426. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11427. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11428. func (m *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  11429. if !m.op.Is(OpUpdateOne) {
  11430. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11431. }
  11432. if m.id == nil || m.oldValue == nil {
  11433. return v, errors.New("OldStatus requires an ID field in the mutation")
  11434. }
  11435. oldValue, err := m.oldValue(ctx)
  11436. if err != nil {
  11437. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11438. }
  11439. return oldValue.Status, nil
  11440. }
  11441. // AddStatus adds i to the "status" field.
  11442. func (m *CreditUsageMutation) AddStatus(i int) {
  11443. if m.addstatus != nil {
  11444. *m.addstatus += i
  11445. } else {
  11446. m.addstatus = &i
  11447. }
  11448. }
  11449. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11450. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  11451. v := m.addstatus
  11452. if v == nil {
  11453. return
  11454. }
  11455. return *v, true
  11456. }
  11457. // ClearStatus clears the value of the "status" field.
  11458. func (m *CreditUsageMutation) ClearStatus() {
  11459. m.status = nil
  11460. m.addstatus = nil
  11461. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  11462. }
  11463. // StatusCleared returns if the "status" field was cleared in this mutation.
  11464. func (m *CreditUsageMutation) StatusCleared() bool {
  11465. _, ok := m.clearedFields[creditusage.FieldStatus]
  11466. return ok
  11467. }
  11468. // ResetStatus resets all changes to the "status" field.
  11469. func (m *CreditUsageMutation) ResetStatus() {
  11470. m.status = nil
  11471. m.addstatus = nil
  11472. delete(m.clearedFields, creditusage.FieldStatus)
  11473. }
  11474. // SetNtype sets the "ntype" field.
  11475. func (m *CreditUsageMutation) SetNtype(i int) {
  11476. m.ntype = &i
  11477. m.addntype = nil
  11478. }
  11479. // Ntype returns the value of the "ntype" field in the mutation.
  11480. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  11481. v := m.ntype
  11482. if v == nil {
  11483. return
  11484. }
  11485. return *v, true
  11486. }
  11487. // OldNtype returns the old "ntype" field's value of the CreditUsage entity.
  11488. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11489. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11490. func (m *CreditUsageMutation) OldNtype(ctx context.Context) (v int, err error) {
  11491. if !m.op.Is(OpUpdateOne) {
  11492. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  11493. }
  11494. if m.id == nil || m.oldValue == nil {
  11495. return v, errors.New("OldNtype requires an ID field in the mutation")
  11496. }
  11497. oldValue, err := m.oldValue(ctx)
  11498. if err != nil {
  11499. return v, fmt.Errorf("querying old value for OldNtype: %w", err)
  11500. }
  11501. return oldValue.Ntype, nil
  11502. }
  11503. // AddNtype adds i to the "ntype" field.
  11504. func (m *CreditUsageMutation) AddNtype(i int) {
  11505. if m.addntype != nil {
  11506. *m.addntype += i
  11507. } else {
  11508. m.addntype = &i
  11509. }
  11510. }
  11511. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  11512. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  11513. v := m.addntype
  11514. if v == nil {
  11515. return
  11516. }
  11517. return *v, true
  11518. }
  11519. // ResetNtype resets all changes to the "ntype" field.
  11520. func (m *CreditUsageMutation) ResetNtype() {
  11521. m.ntype = nil
  11522. m.addntype = nil
  11523. }
  11524. // SetTable sets the "table" field.
  11525. func (m *CreditUsageMutation) SetTable(s string) {
  11526. m.table = &s
  11527. }
  11528. // Table returns the value of the "table" field in the mutation.
  11529. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  11530. v := m.table
  11531. if v == nil {
  11532. return
  11533. }
  11534. return *v, true
  11535. }
  11536. // OldTable returns the old "table" field's value of the CreditUsage entity.
  11537. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11538. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11539. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  11540. if !m.op.Is(OpUpdateOne) {
  11541. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  11542. }
  11543. if m.id == nil || m.oldValue == nil {
  11544. return v, errors.New("OldTable requires an ID field in the mutation")
  11545. }
  11546. oldValue, err := m.oldValue(ctx)
  11547. if err != nil {
  11548. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  11549. }
  11550. return oldValue.Table, nil
  11551. }
  11552. // ResetTable resets all changes to the "table" field.
  11553. func (m *CreditUsageMutation) ResetTable() {
  11554. m.table = nil
  11555. }
  11556. // SetOrganizationID sets the "organization_id" field.
  11557. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  11558. m.organization_id = &u
  11559. m.addorganization_id = nil
  11560. }
  11561. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11562. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  11563. v := m.organization_id
  11564. if v == nil {
  11565. return
  11566. }
  11567. return *v, true
  11568. }
  11569. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  11570. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11572. func (m *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11573. if !m.op.Is(OpUpdateOne) {
  11574. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11575. }
  11576. if m.id == nil || m.oldValue == nil {
  11577. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11578. }
  11579. oldValue, err := m.oldValue(ctx)
  11580. if err != nil {
  11581. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11582. }
  11583. return oldValue.OrganizationID, nil
  11584. }
  11585. // AddOrganizationID adds u to the "organization_id" field.
  11586. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  11587. if m.addorganization_id != nil {
  11588. *m.addorganization_id += u
  11589. } else {
  11590. m.addorganization_id = &u
  11591. }
  11592. }
  11593. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11594. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  11595. v := m.addorganization_id
  11596. if v == nil {
  11597. return
  11598. }
  11599. return *v, true
  11600. }
  11601. // ClearOrganizationID clears the value of the "organization_id" field.
  11602. func (m *CreditUsageMutation) ClearOrganizationID() {
  11603. m.organization_id = nil
  11604. m.addorganization_id = nil
  11605. m.clearedFields[creditusage.FieldOrganizationID] = struct{}{}
  11606. }
  11607. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  11608. func (m *CreditUsageMutation) OrganizationIDCleared() bool {
  11609. _, ok := m.clearedFields[creditusage.FieldOrganizationID]
  11610. return ok
  11611. }
  11612. // ResetOrganizationID resets all changes to the "organization_id" field.
  11613. func (m *CreditUsageMutation) ResetOrganizationID() {
  11614. m.organization_id = nil
  11615. m.addorganization_id = nil
  11616. delete(m.clearedFields, creditusage.FieldOrganizationID)
  11617. }
  11618. // SetNid sets the "nid" field.
  11619. func (m *CreditUsageMutation) SetNid(u uint64) {
  11620. m.nid = &u
  11621. m.addnid = nil
  11622. }
  11623. // Nid returns the value of the "nid" field in the mutation.
  11624. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  11625. v := m.nid
  11626. if v == nil {
  11627. return
  11628. }
  11629. return *v, true
  11630. }
  11631. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  11632. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11633. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11634. func (m *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  11635. if !m.op.Is(OpUpdateOne) {
  11636. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  11637. }
  11638. if m.id == nil || m.oldValue == nil {
  11639. return v, errors.New("OldNid requires an ID field in the mutation")
  11640. }
  11641. oldValue, err := m.oldValue(ctx)
  11642. if err != nil {
  11643. return v, fmt.Errorf("querying old value for OldNid: %w", err)
  11644. }
  11645. return oldValue.Nid, nil
  11646. }
  11647. // AddNid adds u to the "nid" field.
  11648. func (m *CreditUsageMutation) AddNid(u int64) {
  11649. if m.addnid != nil {
  11650. *m.addnid += u
  11651. } else {
  11652. m.addnid = &u
  11653. }
  11654. }
  11655. // AddedNid returns the value that was added to the "nid" field in this mutation.
  11656. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  11657. v := m.addnid
  11658. if v == nil {
  11659. return
  11660. }
  11661. return *v, true
  11662. }
  11663. // ResetNid resets all changes to the "nid" field.
  11664. func (m *CreditUsageMutation) ResetNid() {
  11665. m.nid = nil
  11666. m.addnid = nil
  11667. }
  11668. // SetReason sets the "reason" field.
  11669. func (m *CreditUsageMutation) SetReason(s string) {
  11670. m.reason = &s
  11671. }
  11672. // Reason returns the value of the "reason" field in the mutation.
  11673. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  11674. v := m.reason
  11675. if v == nil {
  11676. return
  11677. }
  11678. return *v, true
  11679. }
  11680. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  11681. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11682. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11683. func (m *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  11684. if !m.op.Is(OpUpdateOne) {
  11685. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  11686. }
  11687. if m.id == nil || m.oldValue == nil {
  11688. return v, errors.New("OldReason requires an ID field in the mutation")
  11689. }
  11690. oldValue, err := m.oldValue(ctx)
  11691. if err != nil {
  11692. return v, fmt.Errorf("querying old value for OldReason: %w", err)
  11693. }
  11694. return oldValue.Reason, nil
  11695. }
  11696. // ResetReason resets all changes to the "reason" field.
  11697. func (m *CreditUsageMutation) ResetReason() {
  11698. m.reason = nil
  11699. }
  11700. // SetOperator sets the "operator" field.
  11701. func (m *CreditUsageMutation) SetOperator(s string) {
  11702. m.operator = &s
  11703. }
  11704. // Operator returns the value of the "operator" field in the mutation.
  11705. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  11706. v := m.operator
  11707. if v == nil {
  11708. return
  11709. }
  11710. return *v, true
  11711. }
  11712. // OldOperator returns the old "operator" field's value of the CreditUsage entity.
  11713. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11714. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11715. func (m *CreditUsageMutation) OldOperator(ctx context.Context) (v string, err error) {
  11716. if !m.op.Is(OpUpdateOne) {
  11717. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  11718. }
  11719. if m.id == nil || m.oldValue == nil {
  11720. return v, errors.New("OldOperator requires an ID field in the mutation")
  11721. }
  11722. oldValue, err := m.oldValue(ctx)
  11723. if err != nil {
  11724. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  11725. }
  11726. return oldValue.Operator, nil
  11727. }
  11728. // ResetOperator resets all changes to the "operator" field.
  11729. func (m *CreditUsageMutation) ResetOperator() {
  11730. m.operator = nil
  11731. }
  11732. // Where appends a list predicates to the CreditUsageMutation builder.
  11733. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  11734. m.predicates = append(m.predicates, ps...)
  11735. }
  11736. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  11737. // users can use type-assertion to append predicates that do not depend on any generated package.
  11738. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  11739. p := make([]predicate.CreditUsage, len(ps))
  11740. for i := range ps {
  11741. p[i] = ps[i]
  11742. }
  11743. m.Where(p...)
  11744. }
  11745. // Op returns the operation name.
  11746. func (m *CreditUsageMutation) Op() Op {
  11747. return m.op
  11748. }
  11749. // SetOp allows setting the mutation operation.
  11750. func (m *CreditUsageMutation) SetOp(op Op) {
  11751. m.op = op
  11752. }
  11753. // Type returns the node type of this mutation (CreditUsage).
  11754. func (m *CreditUsageMutation) Type() string {
  11755. return m.typ
  11756. }
  11757. // Fields returns all fields that were changed during this mutation. Note that in
  11758. // order to get all numeric fields that were incremented/decremented, call
  11759. // AddedFields().
  11760. func (m *CreditUsageMutation) Fields() []string {
  11761. fields := make([]string, 0, 12)
  11762. if m.created_at != nil {
  11763. fields = append(fields, creditusage.FieldCreatedAt)
  11764. }
  11765. if m.updated_at != nil {
  11766. fields = append(fields, creditusage.FieldUpdatedAt)
  11767. }
  11768. if m.deleted_at != nil {
  11769. fields = append(fields, creditusage.FieldDeletedAt)
  11770. }
  11771. if m.user_id != nil {
  11772. fields = append(fields, creditusage.FieldUserID)
  11773. }
  11774. if m.number != nil {
  11775. fields = append(fields, creditusage.FieldNumber)
  11776. }
  11777. if m.status != nil {
  11778. fields = append(fields, creditusage.FieldStatus)
  11779. }
  11780. if m.ntype != nil {
  11781. fields = append(fields, creditusage.FieldNtype)
  11782. }
  11783. if m.table != nil {
  11784. fields = append(fields, creditusage.FieldTable)
  11785. }
  11786. if m.organization_id != nil {
  11787. fields = append(fields, creditusage.FieldOrganizationID)
  11788. }
  11789. if m.nid != nil {
  11790. fields = append(fields, creditusage.FieldNid)
  11791. }
  11792. if m.reason != nil {
  11793. fields = append(fields, creditusage.FieldReason)
  11794. }
  11795. if m.operator != nil {
  11796. fields = append(fields, creditusage.FieldOperator)
  11797. }
  11798. return fields
  11799. }
  11800. // Field returns the value of a field with the given name. The second boolean
  11801. // return value indicates that this field was not set, or was not defined in the
  11802. // schema.
  11803. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  11804. switch name {
  11805. case creditusage.FieldCreatedAt:
  11806. return m.CreatedAt()
  11807. case creditusage.FieldUpdatedAt:
  11808. return m.UpdatedAt()
  11809. case creditusage.FieldDeletedAt:
  11810. return m.DeletedAt()
  11811. case creditusage.FieldUserID:
  11812. return m.UserID()
  11813. case creditusage.FieldNumber:
  11814. return m.Number()
  11815. case creditusage.FieldStatus:
  11816. return m.Status()
  11817. case creditusage.FieldNtype:
  11818. return m.Ntype()
  11819. case creditusage.FieldTable:
  11820. return m.Table()
  11821. case creditusage.FieldOrganizationID:
  11822. return m.OrganizationID()
  11823. case creditusage.FieldNid:
  11824. return m.Nid()
  11825. case creditusage.FieldReason:
  11826. return m.Reason()
  11827. case creditusage.FieldOperator:
  11828. return m.Operator()
  11829. }
  11830. return nil, false
  11831. }
  11832. // OldField returns the old value of the field from the database. An error is
  11833. // returned if the mutation operation is not UpdateOne, or the query to the
  11834. // database failed.
  11835. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11836. switch name {
  11837. case creditusage.FieldCreatedAt:
  11838. return m.OldCreatedAt(ctx)
  11839. case creditusage.FieldUpdatedAt:
  11840. return m.OldUpdatedAt(ctx)
  11841. case creditusage.FieldDeletedAt:
  11842. return m.OldDeletedAt(ctx)
  11843. case creditusage.FieldUserID:
  11844. return m.OldUserID(ctx)
  11845. case creditusage.FieldNumber:
  11846. return m.OldNumber(ctx)
  11847. case creditusage.FieldStatus:
  11848. return m.OldStatus(ctx)
  11849. case creditusage.FieldNtype:
  11850. return m.OldNtype(ctx)
  11851. case creditusage.FieldTable:
  11852. return m.OldTable(ctx)
  11853. case creditusage.FieldOrganizationID:
  11854. return m.OldOrganizationID(ctx)
  11855. case creditusage.FieldNid:
  11856. return m.OldNid(ctx)
  11857. case creditusage.FieldReason:
  11858. return m.OldReason(ctx)
  11859. case creditusage.FieldOperator:
  11860. return m.OldOperator(ctx)
  11861. }
  11862. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  11863. }
  11864. // SetField sets the value of a field with the given name. It returns an error if
  11865. // the field is not defined in the schema, or if the type mismatched the field
  11866. // type.
  11867. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  11868. switch name {
  11869. case creditusage.FieldCreatedAt:
  11870. v, ok := value.(time.Time)
  11871. if !ok {
  11872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11873. }
  11874. m.SetCreatedAt(v)
  11875. return nil
  11876. case creditusage.FieldUpdatedAt:
  11877. v, ok := value.(time.Time)
  11878. if !ok {
  11879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11880. }
  11881. m.SetUpdatedAt(v)
  11882. return nil
  11883. case creditusage.FieldDeletedAt:
  11884. v, ok := value.(time.Time)
  11885. if !ok {
  11886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11887. }
  11888. m.SetDeletedAt(v)
  11889. return nil
  11890. case creditusage.FieldUserID:
  11891. v, ok := value.(string)
  11892. if !ok {
  11893. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11894. }
  11895. m.SetUserID(v)
  11896. return nil
  11897. case creditusage.FieldNumber:
  11898. v, ok := value.(float32)
  11899. if !ok {
  11900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11901. }
  11902. m.SetNumber(v)
  11903. return nil
  11904. case creditusage.FieldStatus:
  11905. v, ok := value.(int)
  11906. if !ok {
  11907. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11908. }
  11909. m.SetStatus(v)
  11910. return nil
  11911. case creditusage.FieldNtype:
  11912. v, ok := value.(int)
  11913. if !ok {
  11914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11915. }
  11916. m.SetNtype(v)
  11917. return nil
  11918. case creditusage.FieldTable:
  11919. v, ok := value.(string)
  11920. if !ok {
  11921. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11922. }
  11923. m.SetTable(v)
  11924. return nil
  11925. case creditusage.FieldOrganizationID:
  11926. v, ok := value.(uint64)
  11927. if !ok {
  11928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11929. }
  11930. m.SetOrganizationID(v)
  11931. return nil
  11932. case creditusage.FieldNid:
  11933. v, ok := value.(uint64)
  11934. if !ok {
  11935. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11936. }
  11937. m.SetNid(v)
  11938. return nil
  11939. case creditusage.FieldReason:
  11940. v, ok := value.(string)
  11941. if !ok {
  11942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11943. }
  11944. m.SetReason(v)
  11945. return nil
  11946. case creditusage.FieldOperator:
  11947. v, ok := value.(string)
  11948. if !ok {
  11949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11950. }
  11951. m.SetOperator(v)
  11952. return nil
  11953. }
  11954. return fmt.Errorf("unknown CreditUsage field %s", name)
  11955. }
  11956. // AddedFields returns all numeric fields that were incremented/decremented during
  11957. // this mutation.
  11958. func (m *CreditUsageMutation) AddedFields() []string {
  11959. var fields []string
  11960. if m.addnumber != nil {
  11961. fields = append(fields, creditusage.FieldNumber)
  11962. }
  11963. if m.addstatus != nil {
  11964. fields = append(fields, creditusage.FieldStatus)
  11965. }
  11966. if m.addntype != nil {
  11967. fields = append(fields, creditusage.FieldNtype)
  11968. }
  11969. if m.addorganization_id != nil {
  11970. fields = append(fields, creditusage.FieldOrganizationID)
  11971. }
  11972. if m.addnid != nil {
  11973. fields = append(fields, creditusage.FieldNid)
  11974. }
  11975. return fields
  11976. }
  11977. // AddedField returns the numeric value that was incremented/decremented on a field
  11978. // with the given name. The second boolean return value indicates that this field
  11979. // was not set, or was not defined in the schema.
  11980. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  11981. switch name {
  11982. case creditusage.FieldNumber:
  11983. return m.AddedNumber()
  11984. case creditusage.FieldStatus:
  11985. return m.AddedStatus()
  11986. case creditusage.FieldNtype:
  11987. return m.AddedNtype()
  11988. case creditusage.FieldOrganizationID:
  11989. return m.AddedOrganizationID()
  11990. case creditusage.FieldNid:
  11991. return m.AddedNid()
  11992. }
  11993. return nil, false
  11994. }
  11995. // AddField adds the value to the field with the given name. It returns an error if
  11996. // the field is not defined in the schema, or if the type mismatched the field
  11997. // type.
  11998. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  11999. switch name {
  12000. case creditusage.FieldNumber:
  12001. v, ok := value.(float32)
  12002. if !ok {
  12003. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12004. }
  12005. m.AddNumber(v)
  12006. return nil
  12007. case creditusage.FieldStatus:
  12008. v, ok := value.(int)
  12009. if !ok {
  12010. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12011. }
  12012. m.AddStatus(v)
  12013. return nil
  12014. case creditusage.FieldNtype:
  12015. v, ok := value.(int)
  12016. if !ok {
  12017. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12018. }
  12019. m.AddNtype(v)
  12020. return nil
  12021. case creditusage.FieldOrganizationID:
  12022. v, ok := value.(int64)
  12023. if !ok {
  12024. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12025. }
  12026. m.AddOrganizationID(v)
  12027. return nil
  12028. case creditusage.FieldNid:
  12029. v, ok := value.(int64)
  12030. if !ok {
  12031. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12032. }
  12033. m.AddNid(v)
  12034. return nil
  12035. }
  12036. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  12037. }
  12038. // ClearedFields returns all nullable fields that were cleared during this
  12039. // mutation.
  12040. func (m *CreditUsageMutation) ClearedFields() []string {
  12041. var fields []string
  12042. if m.FieldCleared(creditusage.FieldDeletedAt) {
  12043. fields = append(fields, creditusage.FieldDeletedAt)
  12044. }
  12045. if m.FieldCleared(creditusage.FieldUserID) {
  12046. fields = append(fields, creditusage.FieldUserID)
  12047. }
  12048. if m.FieldCleared(creditusage.FieldStatus) {
  12049. fields = append(fields, creditusage.FieldStatus)
  12050. }
  12051. if m.FieldCleared(creditusage.FieldOrganizationID) {
  12052. fields = append(fields, creditusage.FieldOrganizationID)
  12053. }
  12054. return fields
  12055. }
  12056. // FieldCleared returns a boolean indicating if a field with the given name was
  12057. // cleared in this mutation.
  12058. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  12059. _, ok := m.clearedFields[name]
  12060. return ok
  12061. }
  12062. // ClearField clears the value of the field with the given name. It returns an
  12063. // error if the field is not defined in the schema.
  12064. func (m *CreditUsageMutation) ClearField(name string) error {
  12065. switch name {
  12066. case creditusage.FieldDeletedAt:
  12067. m.ClearDeletedAt()
  12068. return nil
  12069. case creditusage.FieldUserID:
  12070. m.ClearUserID()
  12071. return nil
  12072. case creditusage.FieldStatus:
  12073. m.ClearStatus()
  12074. return nil
  12075. case creditusage.FieldOrganizationID:
  12076. m.ClearOrganizationID()
  12077. return nil
  12078. }
  12079. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  12080. }
  12081. // ResetField resets all changes in the mutation for the field with the given name.
  12082. // It returns an error if the field is not defined in the schema.
  12083. func (m *CreditUsageMutation) ResetField(name string) error {
  12084. switch name {
  12085. case creditusage.FieldCreatedAt:
  12086. m.ResetCreatedAt()
  12087. return nil
  12088. case creditusage.FieldUpdatedAt:
  12089. m.ResetUpdatedAt()
  12090. return nil
  12091. case creditusage.FieldDeletedAt:
  12092. m.ResetDeletedAt()
  12093. return nil
  12094. case creditusage.FieldUserID:
  12095. m.ResetUserID()
  12096. return nil
  12097. case creditusage.FieldNumber:
  12098. m.ResetNumber()
  12099. return nil
  12100. case creditusage.FieldStatus:
  12101. m.ResetStatus()
  12102. return nil
  12103. case creditusage.FieldNtype:
  12104. m.ResetNtype()
  12105. return nil
  12106. case creditusage.FieldTable:
  12107. m.ResetTable()
  12108. return nil
  12109. case creditusage.FieldOrganizationID:
  12110. m.ResetOrganizationID()
  12111. return nil
  12112. case creditusage.FieldNid:
  12113. m.ResetNid()
  12114. return nil
  12115. case creditusage.FieldReason:
  12116. m.ResetReason()
  12117. return nil
  12118. case creditusage.FieldOperator:
  12119. m.ResetOperator()
  12120. return nil
  12121. }
  12122. return fmt.Errorf("unknown CreditUsage field %s", name)
  12123. }
  12124. // AddedEdges returns all edge names that were set/added in this mutation.
  12125. func (m *CreditUsageMutation) AddedEdges() []string {
  12126. edges := make([]string, 0, 0)
  12127. return edges
  12128. }
  12129. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12130. // name in this mutation.
  12131. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  12132. return nil
  12133. }
  12134. // RemovedEdges returns all edge names that were removed in this mutation.
  12135. func (m *CreditUsageMutation) RemovedEdges() []string {
  12136. edges := make([]string, 0, 0)
  12137. return edges
  12138. }
  12139. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12140. // the given name in this mutation.
  12141. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  12142. return nil
  12143. }
  12144. // ClearedEdges returns all edge names that were cleared in this mutation.
  12145. func (m *CreditUsageMutation) ClearedEdges() []string {
  12146. edges := make([]string, 0, 0)
  12147. return edges
  12148. }
  12149. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12150. // was cleared in this mutation.
  12151. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  12152. return false
  12153. }
  12154. // ClearEdge clears the value of the edge with the given name. It returns an error
  12155. // if that edge is not defined in the schema.
  12156. func (m *CreditUsageMutation) ClearEdge(name string) error {
  12157. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  12158. }
  12159. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12160. // It returns an error if the edge is not defined in the schema.
  12161. func (m *CreditUsageMutation) ResetEdge(name string) error {
  12162. return fmt.Errorf("unknown CreditUsage edge %s", name)
  12163. }
  12164. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  12165. type EmployeeMutation struct {
  12166. config
  12167. op Op
  12168. typ string
  12169. id *uint64
  12170. created_at *time.Time
  12171. updated_at *time.Time
  12172. deleted_at *time.Time
  12173. title *string
  12174. avatar *string
  12175. tags *string
  12176. hire_count *int
  12177. addhire_count *int
  12178. service_count *int
  12179. addservice_count *int
  12180. achievement_count *int
  12181. addachievement_count *int
  12182. intro *string
  12183. estimate *string
  12184. skill *string
  12185. ability_type *string
  12186. scene *string
  12187. switch_in *string
  12188. video_url *string
  12189. organization_id *uint64
  12190. addorganization_id *int64
  12191. category_id *uint64
  12192. addcategory_id *int64
  12193. api_base *string
  12194. api_key *string
  12195. ai_info *string
  12196. is_vip *int
  12197. addis_vip *int
  12198. chat_url *string
  12199. clearedFields map[string]struct{}
  12200. em_work_experiences map[uint64]struct{}
  12201. removedem_work_experiences map[uint64]struct{}
  12202. clearedem_work_experiences bool
  12203. em_tutorial map[uint64]struct{}
  12204. removedem_tutorial map[uint64]struct{}
  12205. clearedem_tutorial bool
  12206. done bool
  12207. oldValue func(context.Context) (*Employee, error)
  12208. predicates []predicate.Employee
  12209. }
  12210. var _ ent.Mutation = (*EmployeeMutation)(nil)
  12211. // employeeOption allows management of the mutation configuration using functional options.
  12212. type employeeOption func(*EmployeeMutation)
  12213. // newEmployeeMutation creates new mutation for the Employee entity.
  12214. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  12215. m := &EmployeeMutation{
  12216. config: c,
  12217. op: op,
  12218. typ: TypeEmployee,
  12219. clearedFields: make(map[string]struct{}),
  12220. }
  12221. for _, opt := range opts {
  12222. opt(m)
  12223. }
  12224. return m
  12225. }
  12226. // withEmployeeID sets the ID field of the mutation.
  12227. func withEmployeeID(id uint64) employeeOption {
  12228. return func(m *EmployeeMutation) {
  12229. var (
  12230. err error
  12231. once sync.Once
  12232. value *Employee
  12233. )
  12234. m.oldValue = func(ctx context.Context) (*Employee, error) {
  12235. once.Do(func() {
  12236. if m.done {
  12237. err = errors.New("querying old values post mutation is not allowed")
  12238. } else {
  12239. value, err = m.Client().Employee.Get(ctx, id)
  12240. }
  12241. })
  12242. return value, err
  12243. }
  12244. m.id = &id
  12245. }
  12246. }
  12247. // withEmployee sets the old Employee of the mutation.
  12248. func withEmployee(node *Employee) employeeOption {
  12249. return func(m *EmployeeMutation) {
  12250. m.oldValue = func(context.Context) (*Employee, error) {
  12251. return node, nil
  12252. }
  12253. m.id = &node.ID
  12254. }
  12255. }
  12256. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12257. // executed in a transaction (ent.Tx), a transactional client is returned.
  12258. func (m EmployeeMutation) Client() *Client {
  12259. client := &Client{config: m.config}
  12260. client.init()
  12261. return client
  12262. }
  12263. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12264. // it returns an error otherwise.
  12265. func (m EmployeeMutation) Tx() (*Tx, error) {
  12266. if _, ok := m.driver.(*txDriver); !ok {
  12267. return nil, errors.New("ent: mutation is not running in a transaction")
  12268. }
  12269. tx := &Tx{config: m.config}
  12270. tx.init()
  12271. return tx, nil
  12272. }
  12273. // SetID sets the value of the id field. Note that this
  12274. // operation is only accepted on creation of Employee entities.
  12275. func (m *EmployeeMutation) SetID(id uint64) {
  12276. m.id = &id
  12277. }
  12278. // ID returns the ID value in the mutation. Note that the ID is only available
  12279. // if it was provided to the builder or after it was returned from the database.
  12280. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  12281. if m.id == nil {
  12282. return
  12283. }
  12284. return *m.id, true
  12285. }
  12286. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12287. // That means, if the mutation is applied within a transaction with an isolation level such
  12288. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12289. // or updated by the mutation.
  12290. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  12291. switch {
  12292. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12293. id, exists := m.ID()
  12294. if exists {
  12295. return []uint64{id}, nil
  12296. }
  12297. fallthrough
  12298. case m.op.Is(OpUpdate | OpDelete):
  12299. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  12300. default:
  12301. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12302. }
  12303. }
  12304. // SetCreatedAt sets the "created_at" field.
  12305. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  12306. m.created_at = &t
  12307. }
  12308. // CreatedAt returns the value of the "created_at" field in the mutation.
  12309. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  12310. v := m.created_at
  12311. if v == nil {
  12312. return
  12313. }
  12314. return *v, true
  12315. }
  12316. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  12317. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12319. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12320. if !m.op.Is(OpUpdateOne) {
  12321. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12322. }
  12323. if m.id == nil || m.oldValue == nil {
  12324. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12325. }
  12326. oldValue, err := m.oldValue(ctx)
  12327. if err != nil {
  12328. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12329. }
  12330. return oldValue.CreatedAt, nil
  12331. }
  12332. // ResetCreatedAt resets all changes to the "created_at" field.
  12333. func (m *EmployeeMutation) ResetCreatedAt() {
  12334. m.created_at = nil
  12335. }
  12336. // SetUpdatedAt sets the "updated_at" field.
  12337. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  12338. m.updated_at = &t
  12339. }
  12340. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12341. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  12342. v := m.updated_at
  12343. if v == nil {
  12344. return
  12345. }
  12346. return *v, true
  12347. }
  12348. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  12349. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12350. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12351. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12352. if !m.op.Is(OpUpdateOne) {
  12353. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12354. }
  12355. if m.id == nil || m.oldValue == nil {
  12356. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12357. }
  12358. oldValue, err := m.oldValue(ctx)
  12359. if err != nil {
  12360. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12361. }
  12362. return oldValue.UpdatedAt, nil
  12363. }
  12364. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12365. func (m *EmployeeMutation) ResetUpdatedAt() {
  12366. m.updated_at = nil
  12367. }
  12368. // SetDeletedAt sets the "deleted_at" field.
  12369. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  12370. m.deleted_at = &t
  12371. }
  12372. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12373. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  12374. v := m.deleted_at
  12375. if v == nil {
  12376. return
  12377. }
  12378. return *v, true
  12379. }
  12380. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  12381. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12382. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12383. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12384. if !m.op.Is(OpUpdateOne) {
  12385. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12386. }
  12387. if m.id == nil || m.oldValue == nil {
  12388. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12389. }
  12390. oldValue, err := m.oldValue(ctx)
  12391. if err != nil {
  12392. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12393. }
  12394. return oldValue.DeletedAt, nil
  12395. }
  12396. // ClearDeletedAt clears the value of the "deleted_at" field.
  12397. func (m *EmployeeMutation) ClearDeletedAt() {
  12398. m.deleted_at = nil
  12399. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  12400. }
  12401. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12402. func (m *EmployeeMutation) DeletedAtCleared() bool {
  12403. _, ok := m.clearedFields[employee.FieldDeletedAt]
  12404. return ok
  12405. }
  12406. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12407. func (m *EmployeeMutation) ResetDeletedAt() {
  12408. m.deleted_at = nil
  12409. delete(m.clearedFields, employee.FieldDeletedAt)
  12410. }
  12411. // SetTitle sets the "title" field.
  12412. func (m *EmployeeMutation) SetTitle(s string) {
  12413. m.title = &s
  12414. }
  12415. // Title returns the value of the "title" field in the mutation.
  12416. func (m *EmployeeMutation) Title() (r string, exists bool) {
  12417. v := m.title
  12418. if v == nil {
  12419. return
  12420. }
  12421. return *v, true
  12422. }
  12423. // OldTitle returns the old "title" field's value of the Employee entity.
  12424. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12425. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12426. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  12427. if !m.op.Is(OpUpdateOne) {
  12428. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  12429. }
  12430. if m.id == nil || m.oldValue == nil {
  12431. return v, errors.New("OldTitle requires an ID field in the mutation")
  12432. }
  12433. oldValue, err := m.oldValue(ctx)
  12434. if err != nil {
  12435. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  12436. }
  12437. return oldValue.Title, nil
  12438. }
  12439. // ResetTitle resets all changes to the "title" field.
  12440. func (m *EmployeeMutation) ResetTitle() {
  12441. m.title = nil
  12442. }
  12443. // SetAvatar sets the "avatar" field.
  12444. func (m *EmployeeMutation) SetAvatar(s string) {
  12445. m.avatar = &s
  12446. }
  12447. // Avatar returns the value of the "avatar" field in the mutation.
  12448. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  12449. v := m.avatar
  12450. if v == nil {
  12451. return
  12452. }
  12453. return *v, true
  12454. }
  12455. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  12456. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12458. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  12459. if !m.op.Is(OpUpdateOne) {
  12460. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  12461. }
  12462. if m.id == nil || m.oldValue == nil {
  12463. return v, errors.New("OldAvatar requires an ID field in the mutation")
  12464. }
  12465. oldValue, err := m.oldValue(ctx)
  12466. if err != nil {
  12467. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  12468. }
  12469. return oldValue.Avatar, nil
  12470. }
  12471. // ResetAvatar resets all changes to the "avatar" field.
  12472. func (m *EmployeeMutation) ResetAvatar() {
  12473. m.avatar = nil
  12474. }
  12475. // SetTags sets the "tags" field.
  12476. func (m *EmployeeMutation) SetTags(s string) {
  12477. m.tags = &s
  12478. }
  12479. // Tags returns the value of the "tags" field in the mutation.
  12480. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  12481. v := m.tags
  12482. if v == nil {
  12483. return
  12484. }
  12485. return *v, true
  12486. }
  12487. // OldTags returns the old "tags" field's value of the Employee entity.
  12488. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12489. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12490. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  12491. if !m.op.Is(OpUpdateOne) {
  12492. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  12493. }
  12494. if m.id == nil || m.oldValue == nil {
  12495. return v, errors.New("OldTags requires an ID field in the mutation")
  12496. }
  12497. oldValue, err := m.oldValue(ctx)
  12498. if err != nil {
  12499. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  12500. }
  12501. return oldValue.Tags, nil
  12502. }
  12503. // ResetTags resets all changes to the "tags" field.
  12504. func (m *EmployeeMutation) ResetTags() {
  12505. m.tags = nil
  12506. }
  12507. // SetHireCount sets the "hire_count" field.
  12508. func (m *EmployeeMutation) SetHireCount(i int) {
  12509. m.hire_count = &i
  12510. m.addhire_count = nil
  12511. }
  12512. // HireCount returns the value of the "hire_count" field in the mutation.
  12513. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  12514. v := m.hire_count
  12515. if v == nil {
  12516. return
  12517. }
  12518. return *v, true
  12519. }
  12520. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  12521. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12522. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12523. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  12524. if !m.op.Is(OpUpdateOne) {
  12525. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  12526. }
  12527. if m.id == nil || m.oldValue == nil {
  12528. return v, errors.New("OldHireCount requires an ID field in the mutation")
  12529. }
  12530. oldValue, err := m.oldValue(ctx)
  12531. if err != nil {
  12532. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  12533. }
  12534. return oldValue.HireCount, nil
  12535. }
  12536. // AddHireCount adds i to the "hire_count" field.
  12537. func (m *EmployeeMutation) AddHireCount(i int) {
  12538. if m.addhire_count != nil {
  12539. *m.addhire_count += i
  12540. } else {
  12541. m.addhire_count = &i
  12542. }
  12543. }
  12544. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  12545. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  12546. v := m.addhire_count
  12547. if v == nil {
  12548. return
  12549. }
  12550. return *v, true
  12551. }
  12552. // ResetHireCount resets all changes to the "hire_count" field.
  12553. func (m *EmployeeMutation) ResetHireCount() {
  12554. m.hire_count = nil
  12555. m.addhire_count = nil
  12556. }
  12557. // SetServiceCount sets the "service_count" field.
  12558. func (m *EmployeeMutation) SetServiceCount(i int) {
  12559. m.service_count = &i
  12560. m.addservice_count = nil
  12561. }
  12562. // ServiceCount returns the value of the "service_count" field in the mutation.
  12563. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  12564. v := m.service_count
  12565. if v == nil {
  12566. return
  12567. }
  12568. return *v, true
  12569. }
  12570. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  12571. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12572. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12573. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  12574. if !m.op.Is(OpUpdateOne) {
  12575. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  12576. }
  12577. if m.id == nil || m.oldValue == nil {
  12578. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  12579. }
  12580. oldValue, err := m.oldValue(ctx)
  12581. if err != nil {
  12582. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  12583. }
  12584. return oldValue.ServiceCount, nil
  12585. }
  12586. // AddServiceCount adds i to the "service_count" field.
  12587. func (m *EmployeeMutation) AddServiceCount(i int) {
  12588. if m.addservice_count != nil {
  12589. *m.addservice_count += i
  12590. } else {
  12591. m.addservice_count = &i
  12592. }
  12593. }
  12594. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  12595. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  12596. v := m.addservice_count
  12597. if v == nil {
  12598. return
  12599. }
  12600. return *v, true
  12601. }
  12602. // ResetServiceCount resets all changes to the "service_count" field.
  12603. func (m *EmployeeMutation) ResetServiceCount() {
  12604. m.service_count = nil
  12605. m.addservice_count = nil
  12606. }
  12607. // SetAchievementCount sets the "achievement_count" field.
  12608. func (m *EmployeeMutation) SetAchievementCount(i int) {
  12609. m.achievement_count = &i
  12610. m.addachievement_count = nil
  12611. }
  12612. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  12613. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  12614. v := m.achievement_count
  12615. if v == nil {
  12616. return
  12617. }
  12618. return *v, true
  12619. }
  12620. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  12621. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12622. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12623. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  12624. if !m.op.Is(OpUpdateOne) {
  12625. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  12626. }
  12627. if m.id == nil || m.oldValue == nil {
  12628. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  12629. }
  12630. oldValue, err := m.oldValue(ctx)
  12631. if err != nil {
  12632. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  12633. }
  12634. return oldValue.AchievementCount, nil
  12635. }
  12636. // AddAchievementCount adds i to the "achievement_count" field.
  12637. func (m *EmployeeMutation) AddAchievementCount(i int) {
  12638. if m.addachievement_count != nil {
  12639. *m.addachievement_count += i
  12640. } else {
  12641. m.addachievement_count = &i
  12642. }
  12643. }
  12644. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  12645. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  12646. v := m.addachievement_count
  12647. if v == nil {
  12648. return
  12649. }
  12650. return *v, true
  12651. }
  12652. // ResetAchievementCount resets all changes to the "achievement_count" field.
  12653. func (m *EmployeeMutation) ResetAchievementCount() {
  12654. m.achievement_count = nil
  12655. m.addachievement_count = nil
  12656. }
  12657. // SetIntro sets the "intro" field.
  12658. func (m *EmployeeMutation) SetIntro(s string) {
  12659. m.intro = &s
  12660. }
  12661. // Intro returns the value of the "intro" field in the mutation.
  12662. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  12663. v := m.intro
  12664. if v == nil {
  12665. return
  12666. }
  12667. return *v, true
  12668. }
  12669. // OldIntro returns the old "intro" field's value of the Employee entity.
  12670. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12671. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12672. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  12673. if !m.op.Is(OpUpdateOne) {
  12674. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  12675. }
  12676. if m.id == nil || m.oldValue == nil {
  12677. return v, errors.New("OldIntro requires an ID field in the mutation")
  12678. }
  12679. oldValue, err := m.oldValue(ctx)
  12680. if err != nil {
  12681. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  12682. }
  12683. return oldValue.Intro, nil
  12684. }
  12685. // ResetIntro resets all changes to the "intro" field.
  12686. func (m *EmployeeMutation) ResetIntro() {
  12687. m.intro = nil
  12688. }
  12689. // SetEstimate sets the "estimate" field.
  12690. func (m *EmployeeMutation) SetEstimate(s string) {
  12691. m.estimate = &s
  12692. }
  12693. // Estimate returns the value of the "estimate" field in the mutation.
  12694. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  12695. v := m.estimate
  12696. if v == nil {
  12697. return
  12698. }
  12699. return *v, true
  12700. }
  12701. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  12702. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12703. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12704. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  12705. if !m.op.Is(OpUpdateOne) {
  12706. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  12707. }
  12708. if m.id == nil || m.oldValue == nil {
  12709. return v, errors.New("OldEstimate requires an ID field in the mutation")
  12710. }
  12711. oldValue, err := m.oldValue(ctx)
  12712. if err != nil {
  12713. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  12714. }
  12715. return oldValue.Estimate, nil
  12716. }
  12717. // ResetEstimate resets all changes to the "estimate" field.
  12718. func (m *EmployeeMutation) ResetEstimate() {
  12719. m.estimate = nil
  12720. }
  12721. // SetSkill sets the "skill" field.
  12722. func (m *EmployeeMutation) SetSkill(s string) {
  12723. m.skill = &s
  12724. }
  12725. // Skill returns the value of the "skill" field in the mutation.
  12726. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  12727. v := m.skill
  12728. if v == nil {
  12729. return
  12730. }
  12731. return *v, true
  12732. }
  12733. // OldSkill returns the old "skill" field's value of the Employee entity.
  12734. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12735. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12736. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  12737. if !m.op.Is(OpUpdateOne) {
  12738. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  12739. }
  12740. if m.id == nil || m.oldValue == nil {
  12741. return v, errors.New("OldSkill requires an ID field in the mutation")
  12742. }
  12743. oldValue, err := m.oldValue(ctx)
  12744. if err != nil {
  12745. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  12746. }
  12747. return oldValue.Skill, nil
  12748. }
  12749. // ResetSkill resets all changes to the "skill" field.
  12750. func (m *EmployeeMutation) ResetSkill() {
  12751. m.skill = nil
  12752. }
  12753. // SetAbilityType sets the "ability_type" field.
  12754. func (m *EmployeeMutation) SetAbilityType(s string) {
  12755. m.ability_type = &s
  12756. }
  12757. // AbilityType returns the value of the "ability_type" field in the mutation.
  12758. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  12759. v := m.ability_type
  12760. if v == nil {
  12761. return
  12762. }
  12763. return *v, true
  12764. }
  12765. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  12766. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12767. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12768. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  12769. if !m.op.Is(OpUpdateOne) {
  12770. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  12771. }
  12772. if m.id == nil || m.oldValue == nil {
  12773. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  12774. }
  12775. oldValue, err := m.oldValue(ctx)
  12776. if err != nil {
  12777. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  12778. }
  12779. return oldValue.AbilityType, nil
  12780. }
  12781. // ResetAbilityType resets all changes to the "ability_type" field.
  12782. func (m *EmployeeMutation) ResetAbilityType() {
  12783. m.ability_type = nil
  12784. }
  12785. // SetScene sets the "scene" field.
  12786. func (m *EmployeeMutation) SetScene(s string) {
  12787. m.scene = &s
  12788. }
  12789. // Scene returns the value of the "scene" field in the mutation.
  12790. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  12791. v := m.scene
  12792. if v == nil {
  12793. return
  12794. }
  12795. return *v, true
  12796. }
  12797. // OldScene returns the old "scene" field's value of the Employee entity.
  12798. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12799. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12800. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  12801. if !m.op.Is(OpUpdateOne) {
  12802. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  12803. }
  12804. if m.id == nil || m.oldValue == nil {
  12805. return v, errors.New("OldScene requires an ID field in the mutation")
  12806. }
  12807. oldValue, err := m.oldValue(ctx)
  12808. if err != nil {
  12809. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  12810. }
  12811. return oldValue.Scene, nil
  12812. }
  12813. // ResetScene resets all changes to the "scene" field.
  12814. func (m *EmployeeMutation) ResetScene() {
  12815. m.scene = nil
  12816. }
  12817. // SetSwitchIn sets the "switch_in" field.
  12818. func (m *EmployeeMutation) SetSwitchIn(s string) {
  12819. m.switch_in = &s
  12820. }
  12821. // SwitchIn returns the value of the "switch_in" field in the mutation.
  12822. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  12823. v := m.switch_in
  12824. if v == nil {
  12825. return
  12826. }
  12827. return *v, true
  12828. }
  12829. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  12830. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12831. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12832. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  12833. if !m.op.Is(OpUpdateOne) {
  12834. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  12835. }
  12836. if m.id == nil || m.oldValue == nil {
  12837. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  12838. }
  12839. oldValue, err := m.oldValue(ctx)
  12840. if err != nil {
  12841. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  12842. }
  12843. return oldValue.SwitchIn, nil
  12844. }
  12845. // ResetSwitchIn resets all changes to the "switch_in" field.
  12846. func (m *EmployeeMutation) ResetSwitchIn() {
  12847. m.switch_in = nil
  12848. }
  12849. // SetVideoURL sets the "video_url" field.
  12850. func (m *EmployeeMutation) SetVideoURL(s string) {
  12851. m.video_url = &s
  12852. }
  12853. // VideoURL returns the value of the "video_url" field in the mutation.
  12854. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  12855. v := m.video_url
  12856. if v == nil {
  12857. return
  12858. }
  12859. return *v, true
  12860. }
  12861. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  12862. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12863. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12864. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  12865. if !m.op.Is(OpUpdateOne) {
  12866. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  12867. }
  12868. if m.id == nil || m.oldValue == nil {
  12869. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  12870. }
  12871. oldValue, err := m.oldValue(ctx)
  12872. if err != nil {
  12873. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  12874. }
  12875. return oldValue.VideoURL, nil
  12876. }
  12877. // ResetVideoURL resets all changes to the "video_url" field.
  12878. func (m *EmployeeMutation) ResetVideoURL() {
  12879. m.video_url = nil
  12880. }
  12881. // SetOrganizationID sets the "organization_id" field.
  12882. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  12883. m.organization_id = &u
  12884. m.addorganization_id = nil
  12885. }
  12886. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12887. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  12888. v := m.organization_id
  12889. if v == nil {
  12890. return
  12891. }
  12892. return *v, true
  12893. }
  12894. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  12895. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12896. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12897. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12898. if !m.op.Is(OpUpdateOne) {
  12899. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12900. }
  12901. if m.id == nil || m.oldValue == nil {
  12902. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12903. }
  12904. oldValue, err := m.oldValue(ctx)
  12905. if err != nil {
  12906. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12907. }
  12908. return oldValue.OrganizationID, nil
  12909. }
  12910. // AddOrganizationID adds u to the "organization_id" field.
  12911. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  12912. if m.addorganization_id != nil {
  12913. *m.addorganization_id += u
  12914. } else {
  12915. m.addorganization_id = &u
  12916. }
  12917. }
  12918. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12919. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  12920. v := m.addorganization_id
  12921. if v == nil {
  12922. return
  12923. }
  12924. return *v, true
  12925. }
  12926. // ResetOrganizationID resets all changes to the "organization_id" field.
  12927. func (m *EmployeeMutation) ResetOrganizationID() {
  12928. m.organization_id = nil
  12929. m.addorganization_id = nil
  12930. }
  12931. // SetCategoryID sets the "category_id" field.
  12932. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  12933. m.category_id = &u
  12934. m.addcategory_id = nil
  12935. }
  12936. // CategoryID returns the value of the "category_id" field in the mutation.
  12937. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  12938. v := m.category_id
  12939. if v == nil {
  12940. return
  12941. }
  12942. return *v, true
  12943. }
  12944. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  12945. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12946. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12947. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  12948. if !m.op.Is(OpUpdateOne) {
  12949. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  12950. }
  12951. if m.id == nil || m.oldValue == nil {
  12952. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  12953. }
  12954. oldValue, err := m.oldValue(ctx)
  12955. if err != nil {
  12956. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  12957. }
  12958. return oldValue.CategoryID, nil
  12959. }
  12960. // AddCategoryID adds u to the "category_id" field.
  12961. func (m *EmployeeMutation) AddCategoryID(u int64) {
  12962. if m.addcategory_id != nil {
  12963. *m.addcategory_id += u
  12964. } else {
  12965. m.addcategory_id = &u
  12966. }
  12967. }
  12968. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  12969. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  12970. v := m.addcategory_id
  12971. if v == nil {
  12972. return
  12973. }
  12974. return *v, true
  12975. }
  12976. // ResetCategoryID resets all changes to the "category_id" field.
  12977. func (m *EmployeeMutation) ResetCategoryID() {
  12978. m.category_id = nil
  12979. m.addcategory_id = nil
  12980. }
  12981. // SetAPIBase sets the "api_base" field.
  12982. func (m *EmployeeMutation) SetAPIBase(s string) {
  12983. m.api_base = &s
  12984. }
  12985. // APIBase returns the value of the "api_base" field in the mutation.
  12986. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  12987. v := m.api_base
  12988. if v == nil {
  12989. return
  12990. }
  12991. return *v, true
  12992. }
  12993. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  12994. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12995. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12996. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  12997. if !m.op.Is(OpUpdateOne) {
  12998. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  12999. }
  13000. if m.id == nil || m.oldValue == nil {
  13001. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  13002. }
  13003. oldValue, err := m.oldValue(ctx)
  13004. if err != nil {
  13005. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  13006. }
  13007. return oldValue.APIBase, nil
  13008. }
  13009. // ResetAPIBase resets all changes to the "api_base" field.
  13010. func (m *EmployeeMutation) ResetAPIBase() {
  13011. m.api_base = nil
  13012. }
  13013. // SetAPIKey sets the "api_key" field.
  13014. func (m *EmployeeMutation) SetAPIKey(s string) {
  13015. m.api_key = &s
  13016. }
  13017. // APIKey returns the value of the "api_key" field in the mutation.
  13018. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  13019. v := m.api_key
  13020. if v == nil {
  13021. return
  13022. }
  13023. return *v, true
  13024. }
  13025. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  13026. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13027. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13028. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  13029. if !m.op.Is(OpUpdateOne) {
  13030. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  13031. }
  13032. if m.id == nil || m.oldValue == nil {
  13033. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  13034. }
  13035. oldValue, err := m.oldValue(ctx)
  13036. if err != nil {
  13037. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  13038. }
  13039. return oldValue.APIKey, nil
  13040. }
  13041. // ResetAPIKey resets all changes to the "api_key" field.
  13042. func (m *EmployeeMutation) ResetAPIKey() {
  13043. m.api_key = nil
  13044. }
  13045. // SetAiInfo sets the "ai_info" field.
  13046. func (m *EmployeeMutation) SetAiInfo(s string) {
  13047. m.ai_info = &s
  13048. }
  13049. // AiInfo returns the value of the "ai_info" field in the mutation.
  13050. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  13051. v := m.ai_info
  13052. if v == nil {
  13053. return
  13054. }
  13055. return *v, true
  13056. }
  13057. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  13058. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13059. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13060. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  13061. if !m.op.Is(OpUpdateOne) {
  13062. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  13063. }
  13064. if m.id == nil || m.oldValue == nil {
  13065. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  13066. }
  13067. oldValue, err := m.oldValue(ctx)
  13068. if err != nil {
  13069. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  13070. }
  13071. return oldValue.AiInfo, nil
  13072. }
  13073. // ClearAiInfo clears the value of the "ai_info" field.
  13074. func (m *EmployeeMutation) ClearAiInfo() {
  13075. m.ai_info = nil
  13076. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  13077. }
  13078. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  13079. func (m *EmployeeMutation) AiInfoCleared() bool {
  13080. _, ok := m.clearedFields[employee.FieldAiInfo]
  13081. return ok
  13082. }
  13083. // ResetAiInfo resets all changes to the "ai_info" field.
  13084. func (m *EmployeeMutation) ResetAiInfo() {
  13085. m.ai_info = nil
  13086. delete(m.clearedFields, employee.FieldAiInfo)
  13087. }
  13088. // SetIsVip sets the "is_vip" field.
  13089. func (m *EmployeeMutation) SetIsVip(i int) {
  13090. m.is_vip = &i
  13091. m.addis_vip = nil
  13092. }
  13093. // IsVip returns the value of the "is_vip" field in the mutation.
  13094. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  13095. v := m.is_vip
  13096. if v == nil {
  13097. return
  13098. }
  13099. return *v, true
  13100. }
  13101. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  13102. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13103. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13104. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  13105. if !m.op.Is(OpUpdateOne) {
  13106. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  13107. }
  13108. if m.id == nil || m.oldValue == nil {
  13109. return v, errors.New("OldIsVip requires an ID field in the mutation")
  13110. }
  13111. oldValue, err := m.oldValue(ctx)
  13112. if err != nil {
  13113. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  13114. }
  13115. return oldValue.IsVip, nil
  13116. }
  13117. // AddIsVip adds i to the "is_vip" field.
  13118. func (m *EmployeeMutation) AddIsVip(i int) {
  13119. if m.addis_vip != nil {
  13120. *m.addis_vip += i
  13121. } else {
  13122. m.addis_vip = &i
  13123. }
  13124. }
  13125. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  13126. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  13127. v := m.addis_vip
  13128. if v == nil {
  13129. return
  13130. }
  13131. return *v, true
  13132. }
  13133. // ResetIsVip resets all changes to the "is_vip" field.
  13134. func (m *EmployeeMutation) ResetIsVip() {
  13135. m.is_vip = nil
  13136. m.addis_vip = nil
  13137. }
  13138. // SetChatURL sets the "chat_url" field.
  13139. func (m *EmployeeMutation) SetChatURL(s string) {
  13140. m.chat_url = &s
  13141. }
  13142. // ChatURL returns the value of the "chat_url" field in the mutation.
  13143. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  13144. v := m.chat_url
  13145. if v == nil {
  13146. return
  13147. }
  13148. return *v, true
  13149. }
  13150. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  13151. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13152. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13153. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  13154. if !m.op.Is(OpUpdateOne) {
  13155. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  13156. }
  13157. if m.id == nil || m.oldValue == nil {
  13158. return v, errors.New("OldChatURL requires an ID field in the mutation")
  13159. }
  13160. oldValue, err := m.oldValue(ctx)
  13161. if err != nil {
  13162. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  13163. }
  13164. return oldValue.ChatURL, nil
  13165. }
  13166. // ResetChatURL resets all changes to the "chat_url" field.
  13167. func (m *EmployeeMutation) ResetChatURL() {
  13168. m.chat_url = nil
  13169. }
  13170. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  13171. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  13172. if m.em_work_experiences == nil {
  13173. m.em_work_experiences = make(map[uint64]struct{})
  13174. }
  13175. for i := range ids {
  13176. m.em_work_experiences[ids[i]] = struct{}{}
  13177. }
  13178. }
  13179. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  13180. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  13181. m.clearedem_work_experiences = true
  13182. }
  13183. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  13184. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  13185. return m.clearedem_work_experiences
  13186. }
  13187. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  13188. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  13189. if m.removedem_work_experiences == nil {
  13190. m.removedem_work_experiences = make(map[uint64]struct{})
  13191. }
  13192. for i := range ids {
  13193. delete(m.em_work_experiences, ids[i])
  13194. m.removedem_work_experiences[ids[i]] = struct{}{}
  13195. }
  13196. }
  13197. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  13198. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  13199. for id := range m.removedem_work_experiences {
  13200. ids = append(ids, id)
  13201. }
  13202. return
  13203. }
  13204. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  13205. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  13206. for id := range m.em_work_experiences {
  13207. ids = append(ids, id)
  13208. }
  13209. return
  13210. }
  13211. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  13212. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  13213. m.em_work_experiences = nil
  13214. m.clearedem_work_experiences = false
  13215. m.removedem_work_experiences = nil
  13216. }
  13217. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  13218. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  13219. if m.em_tutorial == nil {
  13220. m.em_tutorial = make(map[uint64]struct{})
  13221. }
  13222. for i := range ids {
  13223. m.em_tutorial[ids[i]] = struct{}{}
  13224. }
  13225. }
  13226. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  13227. func (m *EmployeeMutation) ClearEmTutorial() {
  13228. m.clearedem_tutorial = true
  13229. }
  13230. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  13231. func (m *EmployeeMutation) EmTutorialCleared() bool {
  13232. return m.clearedem_tutorial
  13233. }
  13234. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  13235. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  13236. if m.removedem_tutorial == nil {
  13237. m.removedem_tutorial = make(map[uint64]struct{})
  13238. }
  13239. for i := range ids {
  13240. delete(m.em_tutorial, ids[i])
  13241. m.removedem_tutorial[ids[i]] = struct{}{}
  13242. }
  13243. }
  13244. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  13245. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  13246. for id := range m.removedem_tutorial {
  13247. ids = append(ids, id)
  13248. }
  13249. return
  13250. }
  13251. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  13252. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  13253. for id := range m.em_tutorial {
  13254. ids = append(ids, id)
  13255. }
  13256. return
  13257. }
  13258. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  13259. func (m *EmployeeMutation) ResetEmTutorial() {
  13260. m.em_tutorial = nil
  13261. m.clearedem_tutorial = false
  13262. m.removedem_tutorial = nil
  13263. }
  13264. // Where appends a list predicates to the EmployeeMutation builder.
  13265. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  13266. m.predicates = append(m.predicates, ps...)
  13267. }
  13268. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  13269. // users can use type-assertion to append predicates that do not depend on any generated package.
  13270. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  13271. p := make([]predicate.Employee, len(ps))
  13272. for i := range ps {
  13273. p[i] = ps[i]
  13274. }
  13275. m.Where(p...)
  13276. }
  13277. // Op returns the operation name.
  13278. func (m *EmployeeMutation) Op() Op {
  13279. return m.op
  13280. }
  13281. // SetOp allows setting the mutation operation.
  13282. func (m *EmployeeMutation) SetOp(op Op) {
  13283. m.op = op
  13284. }
  13285. // Type returns the node type of this mutation (Employee).
  13286. func (m *EmployeeMutation) Type() string {
  13287. return m.typ
  13288. }
  13289. // Fields returns all fields that were changed during this mutation. Note that in
  13290. // order to get all numeric fields that were incremented/decremented, call
  13291. // AddedFields().
  13292. func (m *EmployeeMutation) Fields() []string {
  13293. fields := make([]string, 0, 23)
  13294. if m.created_at != nil {
  13295. fields = append(fields, employee.FieldCreatedAt)
  13296. }
  13297. if m.updated_at != nil {
  13298. fields = append(fields, employee.FieldUpdatedAt)
  13299. }
  13300. if m.deleted_at != nil {
  13301. fields = append(fields, employee.FieldDeletedAt)
  13302. }
  13303. if m.title != nil {
  13304. fields = append(fields, employee.FieldTitle)
  13305. }
  13306. if m.avatar != nil {
  13307. fields = append(fields, employee.FieldAvatar)
  13308. }
  13309. if m.tags != nil {
  13310. fields = append(fields, employee.FieldTags)
  13311. }
  13312. if m.hire_count != nil {
  13313. fields = append(fields, employee.FieldHireCount)
  13314. }
  13315. if m.service_count != nil {
  13316. fields = append(fields, employee.FieldServiceCount)
  13317. }
  13318. if m.achievement_count != nil {
  13319. fields = append(fields, employee.FieldAchievementCount)
  13320. }
  13321. if m.intro != nil {
  13322. fields = append(fields, employee.FieldIntro)
  13323. }
  13324. if m.estimate != nil {
  13325. fields = append(fields, employee.FieldEstimate)
  13326. }
  13327. if m.skill != nil {
  13328. fields = append(fields, employee.FieldSkill)
  13329. }
  13330. if m.ability_type != nil {
  13331. fields = append(fields, employee.FieldAbilityType)
  13332. }
  13333. if m.scene != nil {
  13334. fields = append(fields, employee.FieldScene)
  13335. }
  13336. if m.switch_in != nil {
  13337. fields = append(fields, employee.FieldSwitchIn)
  13338. }
  13339. if m.video_url != nil {
  13340. fields = append(fields, employee.FieldVideoURL)
  13341. }
  13342. if m.organization_id != nil {
  13343. fields = append(fields, employee.FieldOrganizationID)
  13344. }
  13345. if m.category_id != nil {
  13346. fields = append(fields, employee.FieldCategoryID)
  13347. }
  13348. if m.api_base != nil {
  13349. fields = append(fields, employee.FieldAPIBase)
  13350. }
  13351. if m.api_key != nil {
  13352. fields = append(fields, employee.FieldAPIKey)
  13353. }
  13354. if m.ai_info != nil {
  13355. fields = append(fields, employee.FieldAiInfo)
  13356. }
  13357. if m.is_vip != nil {
  13358. fields = append(fields, employee.FieldIsVip)
  13359. }
  13360. if m.chat_url != nil {
  13361. fields = append(fields, employee.FieldChatURL)
  13362. }
  13363. return fields
  13364. }
  13365. // Field returns the value of a field with the given name. The second boolean
  13366. // return value indicates that this field was not set, or was not defined in the
  13367. // schema.
  13368. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  13369. switch name {
  13370. case employee.FieldCreatedAt:
  13371. return m.CreatedAt()
  13372. case employee.FieldUpdatedAt:
  13373. return m.UpdatedAt()
  13374. case employee.FieldDeletedAt:
  13375. return m.DeletedAt()
  13376. case employee.FieldTitle:
  13377. return m.Title()
  13378. case employee.FieldAvatar:
  13379. return m.Avatar()
  13380. case employee.FieldTags:
  13381. return m.Tags()
  13382. case employee.FieldHireCount:
  13383. return m.HireCount()
  13384. case employee.FieldServiceCount:
  13385. return m.ServiceCount()
  13386. case employee.FieldAchievementCount:
  13387. return m.AchievementCount()
  13388. case employee.FieldIntro:
  13389. return m.Intro()
  13390. case employee.FieldEstimate:
  13391. return m.Estimate()
  13392. case employee.FieldSkill:
  13393. return m.Skill()
  13394. case employee.FieldAbilityType:
  13395. return m.AbilityType()
  13396. case employee.FieldScene:
  13397. return m.Scene()
  13398. case employee.FieldSwitchIn:
  13399. return m.SwitchIn()
  13400. case employee.FieldVideoURL:
  13401. return m.VideoURL()
  13402. case employee.FieldOrganizationID:
  13403. return m.OrganizationID()
  13404. case employee.FieldCategoryID:
  13405. return m.CategoryID()
  13406. case employee.FieldAPIBase:
  13407. return m.APIBase()
  13408. case employee.FieldAPIKey:
  13409. return m.APIKey()
  13410. case employee.FieldAiInfo:
  13411. return m.AiInfo()
  13412. case employee.FieldIsVip:
  13413. return m.IsVip()
  13414. case employee.FieldChatURL:
  13415. return m.ChatURL()
  13416. }
  13417. return nil, false
  13418. }
  13419. // OldField returns the old value of the field from the database. An error is
  13420. // returned if the mutation operation is not UpdateOne, or the query to the
  13421. // database failed.
  13422. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13423. switch name {
  13424. case employee.FieldCreatedAt:
  13425. return m.OldCreatedAt(ctx)
  13426. case employee.FieldUpdatedAt:
  13427. return m.OldUpdatedAt(ctx)
  13428. case employee.FieldDeletedAt:
  13429. return m.OldDeletedAt(ctx)
  13430. case employee.FieldTitle:
  13431. return m.OldTitle(ctx)
  13432. case employee.FieldAvatar:
  13433. return m.OldAvatar(ctx)
  13434. case employee.FieldTags:
  13435. return m.OldTags(ctx)
  13436. case employee.FieldHireCount:
  13437. return m.OldHireCount(ctx)
  13438. case employee.FieldServiceCount:
  13439. return m.OldServiceCount(ctx)
  13440. case employee.FieldAchievementCount:
  13441. return m.OldAchievementCount(ctx)
  13442. case employee.FieldIntro:
  13443. return m.OldIntro(ctx)
  13444. case employee.FieldEstimate:
  13445. return m.OldEstimate(ctx)
  13446. case employee.FieldSkill:
  13447. return m.OldSkill(ctx)
  13448. case employee.FieldAbilityType:
  13449. return m.OldAbilityType(ctx)
  13450. case employee.FieldScene:
  13451. return m.OldScene(ctx)
  13452. case employee.FieldSwitchIn:
  13453. return m.OldSwitchIn(ctx)
  13454. case employee.FieldVideoURL:
  13455. return m.OldVideoURL(ctx)
  13456. case employee.FieldOrganizationID:
  13457. return m.OldOrganizationID(ctx)
  13458. case employee.FieldCategoryID:
  13459. return m.OldCategoryID(ctx)
  13460. case employee.FieldAPIBase:
  13461. return m.OldAPIBase(ctx)
  13462. case employee.FieldAPIKey:
  13463. return m.OldAPIKey(ctx)
  13464. case employee.FieldAiInfo:
  13465. return m.OldAiInfo(ctx)
  13466. case employee.FieldIsVip:
  13467. return m.OldIsVip(ctx)
  13468. case employee.FieldChatURL:
  13469. return m.OldChatURL(ctx)
  13470. }
  13471. return nil, fmt.Errorf("unknown Employee field %s", name)
  13472. }
  13473. // SetField sets the value of a field with the given name. It returns an error if
  13474. // the field is not defined in the schema, or if the type mismatched the field
  13475. // type.
  13476. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  13477. switch name {
  13478. case employee.FieldCreatedAt:
  13479. v, ok := value.(time.Time)
  13480. if !ok {
  13481. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13482. }
  13483. m.SetCreatedAt(v)
  13484. return nil
  13485. case employee.FieldUpdatedAt:
  13486. v, ok := value.(time.Time)
  13487. if !ok {
  13488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13489. }
  13490. m.SetUpdatedAt(v)
  13491. return nil
  13492. case employee.FieldDeletedAt:
  13493. v, ok := value.(time.Time)
  13494. if !ok {
  13495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13496. }
  13497. m.SetDeletedAt(v)
  13498. return nil
  13499. case employee.FieldTitle:
  13500. v, ok := value.(string)
  13501. if !ok {
  13502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13503. }
  13504. m.SetTitle(v)
  13505. return nil
  13506. case employee.FieldAvatar:
  13507. v, ok := value.(string)
  13508. if !ok {
  13509. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13510. }
  13511. m.SetAvatar(v)
  13512. return nil
  13513. case employee.FieldTags:
  13514. v, ok := value.(string)
  13515. if !ok {
  13516. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13517. }
  13518. m.SetTags(v)
  13519. return nil
  13520. case employee.FieldHireCount:
  13521. v, ok := value.(int)
  13522. if !ok {
  13523. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13524. }
  13525. m.SetHireCount(v)
  13526. return nil
  13527. case employee.FieldServiceCount:
  13528. v, ok := value.(int)
  13529. if !ok {
  13530. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13531. }
  13532. m.SetServiceCount(v)
  13533. return nil
  13534. case employee.FieldAchievementCount:
  13535. v, ok := value.(int)
  13536. if !ok {
  13537. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13538. }
  13539. m.SetAchievementCount(v)
  13540. return nil
  13541. case employee.FieldIntro:
  13542. v, ok := value.(string)
  13543. if !ok {
  13544. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13545. }
  13546. m.SetIntro(v)
  13547. return nil
  13548. case employee.FieldEstimate:
  13549. v, ok := value.(string)
  13550. if !ok {
  13551. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13552. }
  13553. m.SetEstimate(v)
  13554. return nil
  13555. case employee.FieldSkill:
  13556. v, ok := value.(string)
  13557. if !ok {
  13558. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13559. }
  13560. m.SetSkill(v)
  13561. return nil
  13562. case employee.FieldAbilityType:
  13563. v, ok := value.(string)
  13564. if !ok {
  13565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13566. }
  13567. m.SetAbilityType(v)
  13568. return nil
  13569. case employee.FieldScene:
  13570. v, ok := value.(string)
  13571. if !ok {
  13572. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13573. }
  13574. m.SetScene(v)
  13575. return nil
  13576. case employee.FieldSwitchIn:
  13577. v, ok := value.(string)
  13578. if !ok {
  13579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13580. }
  13581. m.SetSwitchIn(v)
  13582. return nil
  13583. case employee.FieldVideoURL:
  13584. v, ok := value.(string)
  13585. if !ok {
  13586. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13587. }
  13588. m.SetVideoURL(v)
  13589. return nil
  13590. case employee.FieldOrganizationID:
  13591. v, ok := value.(uint64)
  13592. if !ok {
  13593. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13594. }
  13595. m.SetOrganizationID(v)
  13596. return nil
  13597. case employee.FieldCategoryID:
  13598. v, ok := value.(uint64)
  13599. if !ok {
  13600. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13601. }
  13602. m.SetCategoryID(v)
  13603. return nil
  13604. case employee.FieldAPIBase:
  13605. v, ok := value.(string)
  13606. if !ok {
  13607. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13608. }
  13609. m.SetAPIBase(v)
  13610. return nil
  13611. case employee.FieldAPIKey:
  13612. v, ok := value.(string)
  13613. if !ok {
  13614. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13615. }
  13616. m.SetAPIKey(v)
  13617. return nil
  13618. case employee.FieldAiInfo:
  13619. v, ok := value.(string)
  13620. if !ok {
  13621. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13622. }
  13623. m.SetAiInfo(v)
  13624. return nil
  13625. case employee.FieldIsVip:
  13626. v, ok := value.(int)
  13627. if !ok {
  13628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13629. }
  13630. m.SetIsVip(v)
  13631. return nil
  13632. case employee.FieldChatURL:
  13633. v, ok := value.(string)
  13634. if !ok {
  13635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13636. }
  13637. m.SetChatURL(v)
  13638. return nil
  13639. }
  13640. return fmt.Errorf("unknown Employee field %s", name)
  13641. }
  13642. // AddedFields returns all numeric fields that were incremented/decremented during
  13643. // this mutation.
  13644. func (m *EmployeeMutation) AddedFields() []string {
  13645. var fields []string
  13646. if m.addhire_count != nil {
  13647. fields = append(fields, employee.FieldHireCount)
  13648. }
  13649. if m.addservice_count != nil {
  13650. fields = append(fields, employee.FieldServiceCount)
  13651. }
  13652. if m.addachievement_count != nil {
  13653. fields = append(fields, employee.FieldAchievementCount)
  13654. }
  13655. if m.addorganization_id != nil {
  13656. fields = append(fields, employee.FieldOrganizationID)
  13657. }
  13658. if m.addcategory_id != nil {
  13659. fields = append(fields, employee.FieldCategoryID)
  13660. }
  13661. if m.addis_vip != nil {
  13662. fields = append(fields, employee.FieldIsVip)
  13663. }
  13664. return fields
  13665. }
  13666. // AddedField returns the numeric value that was incremented/decremented on a field
  13667. // with the given name. The second boolean return value indicates that this field
  13668. // was not set, or was not defined in the schema.
  13669. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  13670. switch name {
  13671. case employee.FieldHireCount:
  13672. return m.AddedHireCount()
  13673. case employee.FieldServiceCount:
  13674. return m.AddedServiceCount()
  13675. case employee.FieldAchievementCount:
  13676. return m.AddedAchievementCount()
  13677. case employee.FieldOrganizationID:
  13678. return m.AddedOrganizationID()
  13679. case employee.FieldCategoryID:
  13680. return m.AddedCategoryID()
  13681. case employee.FieldIsVip:
  13682. return m.AddedIsVip()
  13683. }
  13684. return nil, false
  13685. }
  13686. // AddField adds the value to the field with the given name. It returns an error if
  13687. // the field is not defined in the schema, or if the type mismatched the field
  13688. // type.
  13689. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  13690. switch name {
  13691. case employee.FieldHireCount:
  13692. v, ok := value.(int)
  13693. if !ok {
  13694. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13695. }
  13696. m.AddHireCount(v)
  13697. return nil
  13698. case employee.FieldServiceCount:
  13699. v, ok := value.(int)
  13700. if !ok {
  13701. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13702. }
  13703. m.AddServiceCount(v)
  13704. return nil
  13705. case employee.FieldAchievementCount:
  13706. v, ok := value.(int)
  13707. if !ok {
  13708. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13709. }
  13710. m.AddAchievementCount(v)
  13711. return nil
  13712. case employee.FieldOrganizationID:
  13713. v, ok := value.(int64)
  13714. if !ok {
  13715. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13716. }
  13717. m.AddOrganizationID(v)
  13718. return nil
  13719. case employee.FieldCategoryID:
  13720. v, ok := value.(int64)
  13721. if !ok {
  13722. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13723. }
  13724. m.AddCategoryID(v)
  13725. return nil
  13726. case employee.FieldIsVip:
  13727. v, ok := value.(int)
  13728. if !ok {
  13729. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13730. }
  13731. m.AddIsVip(v)
  13732. return nil
  13733. }
  13734. return fmt.Errorf("unknown Employee numeric field %s", name)
  13735. }
  13736. // ClearedFields returns all nullable fields that were cleared during this
  13737. // mutation.
  13738. func (m *EmployeeMutation) ClearedFields() []string {
  13739. var fields []string
  13740. if m.FieldCleared(employee.FieldDeletedAt) {
  13741. fields = append(fields, employee.FieldDeletedAt)
  13742. }
  13743. if m.FieldCleared(employee.FieldAiInfo) {
  13744. fields = append(fields, employee.FieldAiInfo)
  13745. }
  13746. return fields
  13747. }
  13748. // FieldCleared returns a boolean indicating if a field with the given name was
  13749. // cleared in this mutation.
  13750. func (m *EmployeeMutation) FieldCleared(name string) bool {
  13751. _, ok := m.clearedFields[name]
  13752. return ok
  13753. }
  13754. // ClearField clears the value of the field with the given name. It returns an
  13755. // error if the field is not defined in the schema.
  13756. func (m *EmployeeMutation) ClearField(name string) error {
  13757. switch name {
  13758. case employee.FieldDeletedAt:
  13759. m.ClearDeletedAt()
  13760. return nil
  13761. case employee.FieldAiInfo:
  13762. m.ClearAiInfo()
  13763. return nil
  13764. }
  13765. return fmt.Errorf("unknown Employee nullable field %s", name)
  13766. }
  13767. // ResetField resets all changes in the mutation for the field with the given name.
  13768. // It returns an error if the field is not defined in the schema.
  13769. func (m *EmployeeMutation) ResetField(name string) error {
  13770. switch name {
  13771. case employee.FieldCreatedAt:
  13772. m.ResetCreatedAt()
  13773. return nil
  13774. case employee.FieldUpdatedAt:
  13775. m.ResetUpdatedAt()
  13776. return nil
  13777. case employee.FieldDeletedAt:
  13778. m.ResetDeletedAt()
  13779. return nil
  13780. case employee.FieldTitle:
  13781. m.ResetTitle()
  13782. return nil
  13783. case employee.FieldAvatar:
  13784. m.ResetAvatar()
  13785. return nil
  13786. case employee.FieldTags:
  13787. m.ResetTags()
  13788. return nil
  13789. case employee.FieldHireCount:
  13790. m.ResetHireCount()
  13791. return nil
  13792. case employee.FieldServiceCount:
  13793. m.ResetServiceCount()
  13794. return nil
  13795. case employee.FieldAchievementCount:
  13796. m.ResetAchievementCount()
  13797. return nil
  13798. case employee.FieldIntro:
  13799. m.ResetIntro()
  13800. return nil
  13801. case employee.FieldEstimate:
  13802. m.ResetEstimate()
  13803. return nil
  13804. case employee.FieldSkill:
  13805. m.ResetSkill()
  13806. return nil
  13807. case employee.FieldAbilityType:
  13808. m.ResetAbilityType()
  13809. return nil
  13810. case employee.FieldScene:
  13811. m.ResetScene()
  13812. return nil
  13813. case employee.FieldSwitchIn:
  13814. m.ResetSwitchIn()
  13815. return nil
  13816. case employee.FieldVideoURL:
  13817. m.ResetVideoURL()
  13818. return nil
  13819. case employee.FieldOrganizationID:
  13820. m.ResetOrganizationID()
  13821. return nil
  13822. case employee.FieldCategoryID:
  13823. m.ResetCategoryID()
  13824. return nil
  13825. case employee.FieldAPIBase:
  13826. m.ResetAPIBase()
  13827. return nil
  13828. case employee.FieldAPIKey:
  13829. m.ResetAPIKey()
  13830. return nil
  13831. case employee.FieldAiInfo:
  13832. m.ResetAiInfo()
  13833. return nil
  13834. case employee.FieldIsVip:
  13835. m.ResetIsVip()
  13836. return nil
  13837. case employee.FieldChatURL:
  13838. m.ResetChatURL()
  13839. return nil
  13840. }
  13841. return fmt.Errorf("unknown Employee field %s", name)
  13842. }
  13843. // AddedEdges returns all edge names that were set/added in this mutation.
  13844. func (m *EmployeeMutation) AddedEdges() []string {
  13845. edges := make([]string, 0, 2)
  13846. if m.em_work_experiences != nil {
  13847. edges = append(edges, employee.EdgeEmWorkExperiences)
  13848. }
  13849. if m.em_tutorial != nil {
  13850. edges = append(edges, employee.EdgeEmTutorial)
  13851. }
  13852. return edges
  13853. }
  13854. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13855. // name in this mutation.
  13856. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  13857. switch name {
  13858. case employee.EdgeEmWorkExperiences:
  13859. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  13860. for id := range m.em_work_experiences {
  13861. ids = append(ids, id)
  13862. }
  13863. return ids
  13864. case employee.EdgeEmTutorial:
  13865. ids := make([]ent.Value, 0, len(m.em_tutorial))
  13866. for id := range m.em_tutorial {
  13867. ids = append(ids, id)
  13868. }
  13869. return ids
  13870. }
  13871. return nil
  13872. }
  13873. // RemovedEdges returns all edge names that were removed in this mutation.
  13874. func (m *EmployeeMutation) RemovedEdges() []string {
  13875. edges := make([]string, 0, 2)
  13876. if m.removedem_work_experiences != nil {
  13877. edges = append(edges, employee.EdgeEmWorkExperiences)
  13878. }
  13879. if m.removedem_tutorial != nil {
  13880. edges = append(edges, employee.EdgeEmTutorial)
  13881. }
  13882. return edges
  13883. }
  13884. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13885. // the given name in this mutation.
  13886. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  13887. switch name {
  13888. case employee.EdgeEmWorkExperiences:
  13889. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  13890. for id := range m.removedem_work_experiences {
  13891. ids = append(ids, id)
  13892. }
  13893. return ids
  13894. case employee.EdgeEmTutorial:
  13895. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  13896. for id := range m.removedem_tutorial {
  13897. ids = append(ids, id)
  13898. }
  13899. return ids
  13900. }
  13901. return nil
  13902. }
  13903. // ClearedEdges returns all edge names that were cleared in this mutation.
  13904. func (m *EmployeeMutation) ClearedEdges() []string {
  13905. edges := make([]string, 0, 2)
  13906. if m.clearedem_work_experiences {
  13907. edges = append(edges, employee.EdgeEmWorkExperiences)
  13908. }
  13909. if m.clearedem_tutorial {
  13910. edges = append(edges, employee.EdgeEmTutorial)
  13911. }
  13912. return edges
  13913. }
  13914. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13915. // was cleared in this mutation.
  13916. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  13917. switch name {
  13918. case employee.EdgeEmWorkExperiences:
  13919. return m.clearedem_work_experiences
  13920. case employee.EdgeEmTutorial:
  13921. return m.clearedem_tutorial
  13922. }
  13923. return false
  13924. }
  13925. // ClearEdge clears the value of the edge with the given name. It returns an error
  13926. // if that edge is not defined in the schema.
  13927. func (m *EmployeeMutation) ClearEdge(name string) error {
  13928. switch name {
  13929. }
  13930. return fmt.Errorf("unknown Employee unique edge %s", name)
  13931. }
  13932. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13933. // It returns an error if the edge is not defined in the schema.
  13934. func (m *EmployeeMutation) ResetEdge(name string) error {
  13935. switch name {
  13936. case employee.EdgeEmWorkExperiences:
  13937. m.ResetEmWorkExperiences()
  13938. return nil
  13939. case employee.EdgeEmTutorial:
  13940. m.ResetEmTutorial()
  13941. return nil
  13942. }
  13943. return fmt.Errorf("unknown Employee edge %s", name)
  13944. }
  13945. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  13946. type EmployeeConfigMutation struct {
  13947. config
  13948. op Op
  13949. typ string
  13950. id *uint64
  13951. created_at *time.Time
  13952. updated_at *time.Time
  13953. deleted_at *time.Time
  13954. stype *string
  13955. title *string
  13956. photo *string
  13957. organization_id *uint64
  13958. addorganization_id *int64
  13959. clearedFields map[string]struct{}
  13960. done bool
  13961. oldValue func(context.Context) (*EmployeeConfig, error)
  13962. predicates []predicate.EmployeeConfig
  13963. }
  13964. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  13965. // employeeconfigOption allows management of the mutation configuration using functional options.
  13966. type employeeconfigOption func(*EmployeeConfigMutation)
  13967. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  13968. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  13969. m := &EmployeeConfigMutation{
  13970. config: c,
  13971. op: op,
  13972. typ: TypeEmployeeConfig,
  13973. clearedFields: make(map[string]struct{}),
  13974. }
  13975. for _, opt := range opts {
  13976. opt(m)
  13977. }
  13978. return m
  13979. }
  13980. // withEmployeeConfigID sets the ID field of the mutation.
  13981. func withEmployeeConfigID(id uint64) employeeconfigOption {
  13982. return func(m *EmployeeConfigMutation) {
  13983. var (
  13984. err error
  13985. once sync.Once
  13986. value *EmployeeConfig
  13987. )
  13988. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  13989. once.Do(func() {
  13990. if m.done {
  13991. err = errors.New("querying old values post mutation is not allowed")
  13992. } else {
  13993. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  13994. }
  13995. })
  13996. return value, err
  13997. }
  13998. m.id = &id
  13999. }
  14000. }
  14001. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  14002. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  14003. return func(m *EmployeeConfigMutation) {
  14004. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  14005. return node, nil
  14006. }
  14007. m.id = &node.ID
  14008. }
  14009. }
  14010. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14011. // executed in a transaction (ent.Tx), a transactional client is returned.
  14012. func (m EmployeeConfigMutation) Client() *Client {
  14013. client := &Client{config: m.config}
  14014. client.init()
  14015. return client
  14016. }
  14017. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14018. // it returns an error otherwise.
  14019. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  14020. if _, ok := m.driver.(*txDriver); !ok {
  14021. return nil, errors.New("ent: mutation is not running in a transaction")
  14022. }
  14023. tx := &Tx{config: m.config}
  14024. tx.init()
  14025. return tx, nil
  14026. }
  14027. // SetID sets the value of the id field. Note that this
  14028. // operation is only accepted on creation of EmployeeConfig entities.
  14029. func (m *EmployeeConfigMutation) SetID(id uint64) {
  14030. m.id = &id
  14031. }
  14032. // ID returns the ID value in the mutation. Note that the ID is only available
  14033. // if it was provided to the builder or after it was returned from the database.
  14034. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  14035. if m.id == nil {
  14036. return
  14037. }
  14038. return *m.id, true
  14039. }
  14040. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14041. // That means, if the mutation is applied within a transaction with an isolation level such
  14042. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14043. // or updated by the mutation.
  14044. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  14045. switch {
  14046. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14047. id, exists := m.ID()
  14048. if exists {
  14049. return []uint64{id}, nil
  14050. }
  14051. fallthrough
  14052. case m.op.Is(OpUpdate | OpDelete):
  14053. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  14054. default:
  14055. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14056. }
  14057. }
  14058. // SetCreatedAt sets the "created_at" field.
  14059. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  14060. m.created_at = &t
  14061. }
  14062. // CreatedAt returns the value of the "created_at" field in the mutation.
  14063. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  14064. v := m.created_at
  14065. if v == nil {
  14066. return
  14067. }
  14068. return *v, true
  14069. }
  14070. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  14071. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  14072. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14073. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14074. if !m.op.Is(OpUpdateOne) {
  14075. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14076. }
  14077. if m.id == nil || m.oldValue == nil {
  14078. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14079. }
  14080. oldValue, err := m.oldValue(ctx)
  14081. if err != nil {
  14082. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14083. }
  14084. return oldValue.CreatedAt, nil
  14085. }
  14086. // ResetCreatedAt resets all changes to the "created_at" field.
  14087. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  14088. m.created_at = nil
  14089. }
  14090. // SetUpdatedAt sets the "updated_at" field.
  14091. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  14092. m.updated_at = &t
  14093. }
  14094. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14095. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  14096. v := m.updated_at
  14097. if v == nil {
  14098. return
  14099. }
  14100. return *v, true
  14101. }
  14102. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  14103. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  14104. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14105. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14106. if !m.op.Is(OpUpdateOne) {
  14107. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14108. }
  14109. if m.id == nil || m.oldValue == nil {
  14110. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14111. }
  14112. oldValue, err := m.oldValue(ctx)
  14113. if err != nil {
  14114. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14115. }
  14116. return oldValue.UpdatedAt, nil
  14117. }
  14118. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14119. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  14120. m.updated_at = nil
  14121. }
  14122. // SetDeletedAt sets the "deleted_at" field.
  14123. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  14124. m.deleted_at = &t
  14125. }
  14126. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14127. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  14128. v := m.deleted_at
  14129. if v == nil {
  14130. return
  14131. }
  14132. return *v, true
  14133. }
  14134. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  14135. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  14136. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14137. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14138. if !m.op.Is(OpUpdateOne) {
  14139. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14140. }
  14141. if m.id == nil || m.oldValue == nil {
  14142. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14143. }
  14144. oldValue, err := m.oldValue(ctx)
  14145. if err != nil {
  14146. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14147. }
  14148. return oldValue.DeletedAt, nil
  14149. }
  14150. // ClearDeletedAt clears the value of the "deleted_at" field.
  14151. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  14152. m.deleted_at = nil
  14153. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  14154. }
  14155. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14156. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  14157. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  14158. return ok
  14159. }
  14160. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14161. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  14162. m.deleted_at = nil
  14163. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  14164. }
  14165. // SetStype sets the "stype" field.
  14166. func (m *EmployeeConfigMutation) SetStype(s string) {
  14167. m.stype = &s
  14168. }
  14169. // Stype returns the value of the "stype" field in the mutation.
  14170. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  14171. v := m.stype
  14172. if v == nil {
  14173. return
  14174. }
  14175. return *v, true
  14176. }
  14177. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  14178. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  14179. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14180. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  14181. if !m.op.Is(OpUpdateOne) {
  14182. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  14183. }
  14184. if m.id == nil || m.oldValue == nil {
  14185. return v, errors.New("OldStype requires an ID field in the mutation")
  14186. }
  14187. oldValue, err := m.oldValue(ctx)
  14188. if err != nil {
  14189. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  14190. }
  14191. return oldValue.Stype, nil
  14192. }
  14193. // ResetStype resets all changes to the "stype" field.
  14194. func (m *EmployeeConfigMutation) ResetStype() {
  14195. m.stype = nil
  14196. }
  14197. // SetTitle sets the "title" field.
  14198. func (m *EmployeeConfigMutation) SetTitle(s string) {
  14199. m.title = &s
  14200. }
  14201. // Title returns the value of the "title" field in the mutation.
  14202. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  14203. v := m.title
  14204. if v == nil {
  14205. return
  14206. }
  14207. return *v, true
  14208. }
  14209. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  14210. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  14211. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14212. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  14213. if !m.op.Is(OpUpdateOne) {
  14214. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  14215. }
  14216. if m.id == nil || m.oldValue == nil {
  14217. return v, errors.New("OldTitle requires an ID field in the mutation")
  14218. }
  14219. oldValue, err := m.oldValue(ctx)
  14220. if err != nil {
  14221. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  14222. }
  14223. return oldValue.Title, nil
  14224. }
  14225. // ResetTitle resets all changes to the "title" field.
  14226. func (m *EmployeeConfigMutation) ResetTitle() {
  14227. m.title = nil
  14228. }
  14229. // SetPhoto sets the "photo" field.
  14230. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  14231. m.photo = &s
  14232. }
  14233. // Photo returns the value of the "photo" field in the mutation.
  14234. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  14235. v := m.photo
  14236. if v == nil {
  14237. return
  14238. }
  14239. return *v, true
  14240. }
  14241. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  14242. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  14243. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14244. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  14245. if !m.op.Is(OpUpdateOne) {
  14246. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  14247. }
  14248. if m.id == nil || m.oldValue == nil {
  14249. return v, errors.New("OldPhoto requires an ID field in the mutation")
  14250. }
  14251. oldValue, err := m.oldValue(ctx)
  14252. if err != nil {
  14253. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  14254. }
  14255. return oldValue.Photo, nil
  14256. }
  14257. // ResetPhoto resets all changes to the "photo" field.
  14258. func (m *EmployeeConfigMutation) ResetPhoto() {
  14259. m.photo = nil
  14260. }
  14261. // SetOrganizationID sets the "organization_id" field.
  14262. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  14263. m.organization_id = &u
  14264. m.addorganization_id = nil
  14265. }
  14266. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14267. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  14268. v := m.organization_id
  14269. if v == nil {
  14270. return
  14271. }
  14272. return *v, true
  14273. }
  14274. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  14275. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  14276. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14277. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14278. if !m.op.Is(OpUpdateOne) {
  14279. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14280. }
  14281. if m.id == nil || m.oldValue == nil {
  14282. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14283. }
  14284. oldValue, err := m.oldValue(ctx)
  14285. if err != nil {
  14286. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14287. }
  14288. return oldValue.OrganizationID, nil
  14289. }
  14290. // AddOrganizationID adds u to the "organization_id" field.
  14291. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  14292. if m.addorganization_id != nil {
  14293. *m.addorganization_id += u
  14294. } else {
  14295. m.addorganization_id = &u
  14296. }
  14297. }
  14298. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14299. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  14300. v := m.addorganization_id
  14301. if v == nil {
  14302. return
  14303. }
  14304. return *v, true
  14305. }
  14306. // ClearOrganizationID clears the value of the "organization_id" field.
  14307. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  14308. m.organization_id = nil
  14309. m.addorganization_id = nil
  14310. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  14311. }
  14312. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14313. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  14314. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  14315. return ok
  14316. }
  14317. // ResetOrganizationID resets all changes to the "organization_id" field.
  14318. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  14319. m.organization_id = nil
  14320. m.addorganization_id = nil
  14321. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  14322. }
  14323. // Where appends a list predicates to the EmployeeConfigMutation builder.
  14324. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  14325. m.predicates = append(m.predicates, ps...)
  14326. }
  14327. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  14328. // users can use type-assertion to append predicates that do not depend on any generated package.
  14329. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  14330. p := make([]predicate.EmployeeConfig, len(ps))
  14331. for i := range ps {
  14332. p[i] = ps[i]
  14333. }
  14334. m.Where(p...)
  14335. }
  14336. // Op returns the operation name.
  14337. func (m *EmployeeConfigMutation) Op() Op {
  14338. return m.op
  14339. }
  14340. // SetOp allows setting the mutation operation.
  14341. func (m *EmployeeConfigMutation) SetOp(op Op) {
  14342. m.op = op
  14343. }
  14344. // Type returns the node type of this mutation (EmployeeConfig).
  14345. func (m *EmployeeConfigMutation) Type() string {
  14346. return m.typ
  14347. }
  14348. // Fields returns all fields that were changed during this mutation. Note that in
  14349. // order to get all numeric fields that were incremented/decremented, call
  14350. // AddedFields().
  14351. func (m *EmployeeConfigMutation) Fields() []string {
  14352. fields := make([]string, 0, 7)
  14353. if m.created_at != nil {
  14354. fields = append(fields, employeeconfig.FieldCreatedAt)
  14355. }
  14356. if m.updated_at != nil {
  14357. fields = append(fields, employeeconfig.FieldUpdatedAt)
  14358. }
  14359. if m.deleted_at != nil {
  14360. fields = append(fields, employeeconfig.FieldDeletedAt)
  14361. }
  14362. if m.stype != nil {
  14363. fields = append(fields, employeeconfig.FieldStype)
  14364. }
  14365. if m.title != nil {
  14366. fields = append(fields, employeeconfig.FieldTitle)
  14367. }
  14368. if m.photo != nil {
  14369. fields = append(fields, employeeconfig.FieldPhoto)
  14370. }
  14371. if m.organization_id != nil {
  14372. fields = append(fields, employeeconfig.FieldOrganizationID)
  14373. }
  14374. return fields
  14375. }
  14376. // Field returns the value of a field with the given name. The second boolean
  14377. // return value indicates that this field was not set, or was not defined in the
  14378. // schema.
  14379. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  14380. switch name {
  14381. case employeeconfig.FieldCreatedAt:
  14382. return m.CreatedAt()
  14383. case employeeconfig.FieldUpdatedAt:
  14384. return m.UpdatedAt()
  14385. case employeeconfig.FieldDeletedAt:
  14386. return m.DeletedAt()
  14387. case employeeconfig.FieldStype:
  14388. return m.Stype()
  14389. case employeeconfig.FieldTitle:
  14390. return m.Title()
  14391. case employeeconfig.FieldPhoto:
  14392. return m.Photo()
  14393. case employeeconfig.FieldOrganizationID:
  14394. return m.OrganizationID()
  14395. }
  14396. return nil, false
  14397. }
  14398. // OldField returns the old value of the field from the database. An error is
  14399. // returned if the mutation operation is not UpdateOne, or the query to the
  14400. // database failed.
  14401. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14402. switch name {
  14403. case employeeconfig.FieldCreatedAt:
  14404. return m.OldCreatedAt(ctx)
  14405. case employeeconfig.FieldUpdatedAt:
  14406. return m.OldUpdatedAt(ctx)
  14407. case employeeconfig.FieldDeletedAt:
  14408. return m.OldDeletedAt(ctx)
  14409. case employeeconfig.FieldStype:
  14410. return m.OldStype(ctx)
  14411. case employeeconfig.FieldTitle:
  14412. return m.OldTitle(ctx)
  14413. case employeeconfig.FieldPhoto:
  14414. return m.OldPhoto(ctx)
  14415. case employeeconfig.FieldOrganizationID:
  14416. return m.OldOrganizationID(ctx)
  14417. }
  14418. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  14419. }
  14420. // SetField sets the value of a field with the given name. It returns an error if
  14421. // the field is not defined in the schema, or if the type mismatched the field
  14422. // type.
  14423. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  14424. switch name {
  14425. case employeeconfig.FieldCreatedAt:
  14426. v, ok := value.(time.Time)
  14427. if !ok {
  14428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14429. }
  14430. m.SetCreatedAt(v)
  14431. return nil
  14432. case employeeconfig.FieldUpdatedAt:
  14433. v, ok := value.(time.Time)
  14434. if !ok {
  14435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14436. }
  14437. m.SetUpdatedAt(v)
  14438. return nil
  14439. case employeeconfig.FieldDeletedAt:
  14440. v, ok := value.(time.Time)
  14441. if !ok {
  14442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14443. }
  14444. m.SetDeletedAt(v)
  14445. return nil
  14446. case employeeconfig.FieldStype:
  14447. v, ok := value.(string)
  14448. if !ok {
  14449. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14450. }
  14451. m.SetStype(v)
  14452. return nil
  14453. case employeeconfig.FieldTitle:
  14454. v, ok := value.(string)
  14455. if !ok {
  14456. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14457. }
  14458. m.SetTitle(v)
  14459. return nil
  14460. case employeeconfig.FieldPhoto:
  14461. v, ok := value.(string)
  14462. if !ok {
  14463. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14464. }
  14465. m.SetPhoto(v)
  14466. return nil
  14467. case employeeconfig.FieldOrganizationID:
  14468. v, ok := value.(uint64)
  14469. if !ok {
  14470. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14471. }
  14472. m.SetOrganizationID(v)
  14473. return nil
  14474. }
  14475. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  14476. }
  14477. // AddedFields returns all numeric fields that were incremented/decremented during
  14478. // this mutation.
  14479. func (m *EmployeeConfigMutation) AddedFields() []string {
  14480. var fields []string
  14481. if m.addorganization_id != nil {
  14482. fields = append(fields, employeeconfig.FieldOrganizationID)
  14483. }
  14484. return fields
  14485. }
  14486. // AddedField returns the numeric value that was incremented/decremented on a field
  14487. // with the given name. The second boolean return value indicates that this field
  14488. // was not set, or was not defined in the schema.
  14489. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  14490. switch name {
  14491. case employeeconfig.FieldOrganizationID:
  14492. return m.AddedOrganizationID()
  14493. }
  14494. return nil, false
  14495. }
  14496. // AddField adds the value to the field with the given name. It returns an error if
  14497. // the field is not defined in the schema, or if the type mismatched the field
  14498. // type.
  14499. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  14500. switch name {
  14501. case employeeconfig.FieldOrganizationID:
  14502. v, ok := value.(int64)
  14503. if !ok {
  14504. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14505. }
  14506. m.AddOrganizationID(v)
  14507. return nil
  14508. }
  14509. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  14510. }
  14511. // ClearedFields returns all nullable fields that were cleared during this
  14512. // mutation.
  14513. func (m *EmployeeConfigMutation) ClearedFields() []string {
  14514. var fields []string
  14515. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  14516. fields = append(fields, employeeconfig.FieldDeletedAt)
  14517. }
  14518. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  14519. fields = append(fields, employeeconfig.FieldOrganizationID)
  14520. }
  14521. return fields
  14522. }
  14523. // FieldCleared returns a boolean indicating if a field with the given name was
  14524. // cleared in this mutation.
  14525. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  14526. _, ok := m.clearedFields[name]
  14527. return ok
  14528. }
  14529. // ClearField clears the value of the field with the given name. It returns an
  14530. // error if the field is not defined in the schema.
  14531. func (m *EmployeeConfigMutation) ClearField(name string) error {
  14532. switch name {
  14533. case employeeconfig.FieldDeletedAt:
  14534. m.ClearDeletedAt()
  14535. return nil
  14536. case employeeconfig.FieldOrganizationID:
  14537. m.ClearOrganizationID()
  14538. return nil
  14539. }
  14540. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  14541. }
  14542. // ResetField resets all changes in the mutation for the field with the given name.
  14543. // It returns an error if the field is not defined in the schema.
  14544. func (m *EmployeeConfigMutation) ResetField(name string) error {
  14545. switch name {
  14546. case employeeconfig.FieldCreatedAt:
  14547. m.ResetCreatedAt()
  14548. return nil
  14549. case employeeconfig.FieldUpdatedAt:
  14550. m.ResetUpdatedAt()
  14551. return nil
  14552. case employeeconfig.FieldDeletedAt:
  14553. m.ResetDeletedAt()
  14554. return nil
  14555. case employeeconfig.FieldStype:
  14556. m.ResetStype()
  14557. return nil
  14558. case employeeconfig.FieldTitle:
  14559. m.ResetTitle()
  14560. return nil
  14561. case employeeconfig.FieldPhoto:
  14562. m.ResetPhoto()
  14563. return nil
  14564. case employeeconfig.FieldOrganizationID:
  14565. m.ResetOrganizationID()
  14566. return nil
  14567. }
  14568. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  14569. }
  14570. // AddedEdges returns all edge names that were set/added in this mutation.
  14571. func (m *EmployeeConfigMutation) AddedEdges() []string {
  14572. edges := make([]string, 0, 0)
  14573. return edges
  14574. }
  14575. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14576. // name in this mutation.
  14577. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  14578. return nil
  14579. }
  14580. // RemovedEdges returns all edge names that were removed in this mutation.
  14581. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  14582. edges := make([]string, 0, 0)
  14583. return edges
  14584. }
  14585. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14586. // the given name in this mutation.
  14587. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  14588. return nil
  14589. }
  14590. // ClearedEdges returns all edge names that were cleared in this mutation.
  14591. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  14592. edges := make([]string, 0, 0)
  14593. return edges
  14594. }
  14595. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14596. // was cleared in this mutation.
  14597. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  14598. return false
  14599. }
  14600. // ClearEdge clears the value of the edge with the given name. It returns an error
  14601. // if that edge is not defined in the schema.
  14602. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  14603. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  14604. }
  14605. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14606. // It returns an error if the edge is not defined in the schema.
  14607. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  14608. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  14609. }
  14610. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  14611. type LabelMutation struct {
  14612. config
  14613. op Op
  14614. typ string
  14615. id *uint64
  14616. created_at *time.Time
  14617. updated_at *time.Time
  14618. status *uint8
  14619. addstatus *int8
  14620. _type *int
  14621. add_type *int
  14622. name *string
  14623. from *int
  14624. addfrom *int
  14625. mode *int
  14626. addmode *int
  14627. conditions *string
  14628. organization_id *uint64
  14629. addorganization_id *int64
  14630. clearedFields map[string]struct{}
  14631. label_relationships map[uint64]struct{}
  14632. removedlabel_relationships map[uint64]struct{}
  14633. clearedlabel_relationships bool
  14634. done bool
  14635. oldValue func(context.Context) (*Label, error)
  14636. predicates []predicate.Label
  14637. }
  14638. var _ ent.Mutation = (*LabelMutation)(nil)
  14639. // labelOption allows management of the mutation configuration using functional options.
  14640. type labelOption func(*LabelMutation)
  14641. // newLabelMutation creates new mutation for the Label entity.
  14642. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  14643. m := &LabelMutation{
  14644. config: c,
  14645. op: op,
  14646. typ: TypeLabel,
  14647. clearedFields: make(map[string]struct{}),
  14648. }
  14649. for _, opt := range opts {
  14650. opt(m)
  14651. }
  14652. return m
  14653. }
  14654. // withLabelID sets the ID field of the mutation.
  14655. func withLabelID(id uint64) labelOption {
  14656. return func(m *LabelMutation) {
  14657. var (
  14658. err error
  14659. once sync.Once
  14660. value *Label
  14661. )
  14662. m.oldValue = func(ctx context.Context) (*Label, error) {
  14663. once.Do(func() {
  14664. if m.done {
  14665. err = errors.New("querying old values post mutation is not allowed")
  14666. } else {
  14667. value, err = m.Client().Label.Get(ctx, id)
  14668. }
  14669. })
  14670. return value, err
  14671. }
  14672. m.id = &id
  14673. }
  14674. }
  14675. // withLabel sets the old Label of the mutation.
  14676. func withLabel(node *Label) labelOption {
  14677. return func(m *LabelMutation) {
  14678. m.oldValue = func(context.Context) (*Label, error) {
  14679. return node, nil
  14680. }
  14681. m.id = &node.ID
  14682. }
  14683. }
  14684. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14685. // executed in a transaction (ent.Tx), a transactional client is returned.
  14686. func (m LabelMutation) Client() *Client {
  14687. client := &Client{config: m.config}
  14688. client.init()
  14689. return client
  14690. }
  14691. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14692. // it returns an error otherwise.
  14693. func (m LabelMutation) Tx() (*Tx, error) {
  14694. if _, ok := m.driver.(*txDriver); !ok {
  14695. return nil, errors.New("ent: mutation is not running in a transaction")
  14696. }
  14697. tx := &Tx{config: m.config}
  14698. tx.init()
  14699. return tx, nil
  14700. }
  14701. // SetID sets the value of the id field. Note that this
  14702. // operation is only accepted on creation of Label entities.
  14703. func (m *LabelMutation) SetID(id uint64) {
  14704. m.id = &id
  14705. }
  14706. // ID returns the ID value in the mutation. Note that the ID is only available
  14707. // if it was provided to the builder or after it was returned from the database.
  14708. func (m *LabelMutation) ID() (id uint64, exists bool) {
  14709. if m.id == nil {
  14710. return
  14711. }
  14712. return *m.id, true
  14713. }
  14714. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14715. // That means, if the mutation is applied within a transaction with an isolation level such
  14716. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14717. // or updated by the mutation.
  14718. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  14719. switch {
  14720. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14721. id, exists := m.ID()
  14722. if exists {
  14723. return []uint64{id}, nil
  14724. }
  14725. fallthrough
  14726. case m.op.Is(OpUpdate | OpDelete):
  14727. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  14728. default:
  14729. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14730. }
  14731. }
  14732. // SetCreatedAt sets the "created_at" field.
  14733. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  14734. m.created_at = &t
  14735. }
  14736. // CreatedAt returns the value of the "created_at" field in the mutation.
  14737. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  14738. v := m.created_at
  14739. if v == nil {
  14740. return
  14741. }
  14742. return *v, true
  14743. }
  14744. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  14745. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14746. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14747. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14748. if !m.op.Is(OpUpdateOne) {
  14749. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14750. }
  14751. if m.id == nil || m.oldValue == nil {
  14752. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14753. }
  14754. oldValue, err := m.oldValue(ctx)
  14755. if err != nil {
  14756. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14757. }
  14758. return oldValue.CreatedAt, nil
  14759. }
  14760. // ResetCreatedAt resets all changes to the "created_at" field.
  14761. func (m *LabelMutation) ResetCreatedAt() {
  14762. m.created_at = nil
  14763. }
  14764. // SetUpdatedAt sets the "updated_at" field.
  14765. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  14766. m.updated_at = &t
  14767. }
  14768. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14769. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  14770. v := m.updated_at
  14771. if v == nil {
  14772. return
  14773. }
  14774. return *v, true
  14775. }
  14776. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  14777. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14779. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14780. if !m.op.Is(OpUpdateOne) {
  14781. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14782. }
  14783. if m.id == nil || m.oldValue == nil {
  14784. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14785. }
  14786. oldValue, err := m.oldValue(ctx)
  14787. if err != nil {
  14788. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14789. }
  14790. return oldValue.UpdatedAt, nil
  14791. }
  14792. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14793. func (m *LabelMutation) ResetUpdatedAt() {
  14794. m.updated_at = nil
  14795. }
  14796. // SetStatus sets the "status" field.
  14797. func (m *LabelMutation) SetStatus(u uint8) {
  14798. m.status = &u
  14799. m.addstatus = nil
  14800. }
  14801. // Status returns the value of the "status" field in the mutation.
  14802. func (m *LabelMutation) Status() (r uint8, exists bool) {
  14803. v := m.status
  14804. if v == nil {
  14805. return
  14806. }
  14807. return *v, true
  14808. }
  14809. // OldStatus returns the old "status" field's value of the Label entity.
  14810. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14811. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14812. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14813. if !m.op.Is(OpUpdateOne) {
  14814. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14815. }
  14816. if m.id == nil || m.oldValue == nil {
  14817. return v, errors.New("OldStatus requires an ID field in the mutation")
  14818. }
  14819. oldValue, err := m.oldValue(ctx)
  14820. if err != nil {
  14821. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14822. }
  14823. return oldValue.Status, nil
  14824. }
  14825. // AddStatus adds u to the "status" field.
  14826. func (m *LabelMutation) AddStatus(u int8) {
  14827. if m.addstatus != nil {
  14828. *m.addstatus += u
  14829. } else {
  14830. m.addstatus = &u
  14831. }
  14832. }
  14833. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14834. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  14835. v := m.addstatus
  14836. if v == nil {
  14837. return
  14838. }
  14839. return *v, true
  14840. }
  14841. // ClearStatus clears the value of the "status" field.
  14842. func (m *LabelMutation) ClearStatus() {
  14843. m.status = nil
  14844. m.addstatus = nil
  14845. m.clearedFields[label.FieldStatus] = struct{}{}
  14846. }
  14847. // StatusCleared returns if the "status" field was cleared in this mutation.
  14848. func (m *LabelMutation) StatusCleared() bool {
  14849. _, ok := m.clearedFields[label.FieldStatus]
  14850. return ok
  14851. }
  14852. // ResetStatus resets all changes to the "status" field.
  14853. func (m *LabelMutation) ResetStatus() {
  14854. m.status = nil
  14855. m.addstatus = nil
  14856. delete(m.clearedFields, label.FieldStatus)
  14857. }
  14858. // SetType sets the "type" field.
  14859. func (m *LabelMutation) SetType(i int) {
  14860. m._type = &i
  14861. m.add_type = nil
  14862. }
  14863. // GetType returns the value of the "type" field in the mutation.
  14864. func (m *LabelMutation) GetType() (r int, exists bool) {
  14865. v := m._type
  14866. if v == nil {
  14867. return
  14868. }
  14869. return *v, true
  14870. }
  14871. // OldType returns the old "type" field's value of the Label entity.
  14872. // If the Label 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 *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  14875. if !m.op.Is(OpUpdateOne) {
  14876. return v, errors.New("OldType is only allowed on UpdateOne operations")
  14877. }
  14878. if m.id == nil || m.oldValue == nil {
  14879. return v, errors.New("OldType 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 OldType: %w", err)
  14884. }
  14885. return oldValue.Type, nil
  14886. }
  14887. // AddType adds i to the "type" field.
  14888. func (m *LabelMutation) AddType(i int) {
  14889. if m.add_type != nil {
  14890. *m.add_type += i
  14891. } else {
  14892. m.add_type = &i
  14893. }
  14894. }
  14895. // AddedType returns the value that was added to the "type" field in this mutation.
  14896. func (m *LabelMutation) AddedType() (r int, exists bool) {
  14897. v := m.add_type
  14898. if v == nil {
  14899. return
  14900. }
  14901. return *v, true
  14902. }
  14903. // ResetType resets all changes to the "type" field.
  14904. func (m *LabelMutation) ResetType() {
  14905. m._type = nil
  14906. m.add_type = nil
  14907. }
  14908. // SetName sets the "name" field.
  14909. func (m *LabelMutation) SetName(s string) {
  14910. m.name = &s
  14911. }
  14912. // Name returns the value of the "name" field in the mutation.
  14913. func (m *LabelMutation) Name() (r string, exists bool) {
  14914. v := m.name
  14915. if v == nil {
  14916. return
  14917. }
  14918. return *v, true
  14919. }
  14920. // OldName returns the old "name" field's value of the Label entity.
  14921. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14922. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14923. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  14924. if !m.op.Is(OpUpdateOne) {
  14925. return v, errors.New("OldName is only allowed on UpdateOne operations")
  14926. }
  14927. if m.id == nil || m.oldValue == nil {
  14928. return v, errors.New("OldName requires an ID field in the mutation")
  14929. }
  14930. oldValue, err := m.oldValue(ctx)
  14931. if err != nil {
  14932. return v, fmt.Errorf("querying old value for OldName: %w", err)
  14933. }
  14934. return oldValue.Name, nil
  14935. }
  14936. // ResetName resets all changes to the "name" field.
  14937. func (m *LabelMutation) ResetName() {
  14938. m.name = nil
  14939. }
  14940. // SetFrom sets the "from" field.
  14941. func (m *LabelMutation) SetFrom(i int) {
  14942. m.from = &i
  14943. m.addfrom = nil
  14944. }
  14945. // From returns the value of the "from" field in the mutation.
  14946. func (m *LabelMutation) From() (r int, exists bool) {
  14947. v := m.from
  14948. if v == nil {
  14949. return
  14950. }
  14951. return *v, true
  14952. }
  14953. // OldFrom returns the old "from" field's value of the Label entity.
  14954. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14955. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14956. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  14957. if !m.op.Is(OpUpdateOne) {
  14958. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  14959. }
  14960. if m.id == nil || m.oldValue == nil {
  14961. return v, errors.New("OldFrom requires an ID field in the mutation")
  14962. }
  14963. oldValue, err := m.oldValue(ctx)
  14964. if err != nil {
  14965. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  14966. }
  14967. return oldValue.From, nil
  14968. }
  14969. // AddFrom adds i to the "from" field.
  14970. func (m *LabelMutation) AddFrom(i int) {
  14971. if m.addfrom != nil {
  14972. *m.addfrom += i
  14973. } else {
  14974. m.addfrom = &i
  14975. }
  14976. }
  14977. // AddedFrom returns the value that was added to the "from" field in this mutation.
  14978. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  14979. v := m.addfrom
  14980. if v == nil {
  14981. return
  14982. }
  14983. return *v, true
  14984. }
  14985. // ResetFrom resets all changes to the "from" field.
  14986. func (m *LabelMutation) ResetFrom() {
  14987. m.from = nil
  14988. m.addfrom = nil
  14989. }
  14990. // SetMode sets the "mode" field.
  14991. func (m *LabelMutation) SetMode(i int) {
  14992. m.mode = &i
  14993. m.addmode = nil
  14994. }
  14995. // Mode returns the value of the "mode" field in the mutation.
  14996. func (m *LabelMutation) Mode() (r int, exists bool) {
  14997. v := m.mode
  14998. if v == nil {
  14999. return
  15000. }
  15001. return *v, true
  15002. }
  15003. // OldMode returns the old "mode" field's value of the Label entity.
  15004. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  15005. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15006. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  15007. if !m.op.Is(OpUpdateOne) {
  15008. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  15009. }
  15010. if m.id == nil || m.oldValue == nil {
  15011. return v, errors.New("OldMode requires an ID field in the mutation")
  15012. }
  15013. oldValue, err := m.oldValue(ctx)
  15014. if err != nil {
  15015. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  15016. }
  15017. return oldValue.Mode, nil
  15018. }
  15019. // AddMode adds i to the "mode" field.
  15020. func (m *LabelMutation) AddMode(i int) {
  15021. if m.addmode != nil {
  15022. *m.addmode += i
  15023. } else {
  15024. m.addmode = &i
  15025. }
  15026. }
  15027. // AddedMode returns the value that was added to the "mode" field in this mutation.
  15028. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  15029. v := m.addmode
  15030. if v == nil {
  15031. return
  15032. }
  15033. return *v, true
  15034. }
  15035. // ResetMode resets all changes to the "mode" field.
  15036. func (m *LabelMutation) ResetMode() {
  15037. m.mode = nil
  15038. m.addmode = nil
  15039. }
  15040. // SetConditions sets the "conditions" field.
  15041. func (m *LabelMutation) SetConditions(s string) {
  15042. m.conditions = &s
  15043. }
  15044. // Conditions returns the value of the "conditions" field in the mutation.
  15045. func (m *LabelMutation) Conditions() (r string, exists bool) {
  15046. v := m.conditions
  15047. if v == nil {
  15048. return
  15049. }
  15050. return *v, true
  15051. }
  15052. // OldConditions returns the old "conditions" field's value of the Label entity.
  15053. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  15054. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15055. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  15056. if !m.op.Is(OpUpdateOne) {
  15057. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  15058. }
  15059. if m.id == nil || m.oldValue == nil {
  15060. return v, errors.New("OldConditions requires an ID field in the mutation")
  15061. }
  15062. oldValue, err := m.oldValue(ctx)
  15063. if err != nil {
  15064. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  15065. }
  15066. return oldValue.Conditions, nil
  15067. }
  15068. // ClearConditions clears the value of the "conditions" field.
  15069. func (m *LabelMutation) ClearConditions() {
  15070. m.conditions = nil
  15071. m.clearedFields[label.FieldConditions] = struct{}{}
  15072. }
  15073. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  15074. func (m *LabelMutation) ConditionsCleared() bool {
  15075. _, ok := m.clearedFields[label.FieldConditions]
  15076. return ok
  15077. }
  15078. // ResetConditions resets all changes to the "conditions" field.
  15079. func (m *LabelMutation) ResetConditions() {
  15080. m.conditions = nil
  15081. delete(m.clearedFields, label.FieldConditions)
  15082. }
  15083. // SetOrganizationID sets the "organization_id" field.
  15084. func (m *LabelMutation) SetOrganizationID(u uint64) {
  15085. m.organization_id = &u
  15086. m.addorganization_id = nil
  15087. }
  15088. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15089. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  15090. v := m.organization_id
  15091. if v == nil {
  15092. return
  15093. }
  15094. return *v, true
  15095. }
  15096. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  15097. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  15098. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15099. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15100. if !m.op.Is(OpUpdateOne) {
  15101. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15102. }
  15103. if m.id == nil || m.oldValue == nil {
  15104. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15105. }
  15106. oldValue, err := m.oldValue(ctx)
  15107. if err != nil {
  15108. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15109. }
  15110. return oldValue.OrganizationID, nil
  15111. }
  15112. // AddOrganizationID adds u to the "organization_id" field.
  15113. func (m *LabelMutation) AddOrganizationID(u int64) {
  15114. if m.addorganization_id != nil {
  15115. *m.addorganization_id += u
  15116. } else {
  15117. m.addorganization_id = &u
  15118. }
  15119. }
  15120. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15121. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  15122. v := m.addorganization_id
  15123. if v == nil {
  15124. return
  15125. }
  15126. return *v, true
  15127. }
  15128. // ClearOrganizationID clears the value of the "organization_id" field.
  15129. func (m *LabelMutation) ClearOrganizationID() {
  15130. m.organization_id = nil
  15131. m.addorganization_id = nil
  15132. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  15133. }
  15134. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  15135. func (m *LabelMutation) OrganizationIDCleared() bool {
  15136. _, ok := m.clearedFields[label.FieldOrganizationID]
  15137. return ok
  15138. }
  15139. // ResetOrganizationID resets all changes to the "organization_id" field.
  15140. func (m *LabelMutation) ResetOrganizationID() {
  15141. m.organization_id = nil
  15142. m.addorganization_id = nil
  15143. delete(m.clearedFields, label.FieldOrganizationID)
  15144. }
  15145. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  15146. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  15147. if m.label_relationships == nil {
  15148. m.label_relationships = make(map[uint64]struct{})
  15149. }
  15150. for i := range ids {
  15151. m.label_relationships[ids[i]] = struct{}{}
  15152. }
  15153. }
  15154. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  15155. func (m *LabelMutation) ClearLabelRelationships() {
  15156. m.clearedlabel_relationships = true
  15157. }
  15158. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  15159. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  15160. return m.clearedlabel_relationships
  15161. }
  15162. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  15163. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  15164. if m.removedlabel_relationships == nil {
  15165. m.removedlabel_relationships = make(map[uint64]struct{})
  15166. }
  15167. for i := range ids {
  15168. delete(m.label_relationships, ids[i])
  15169. m.removedlabel_relationships[ids[i]] = struct{}{}
  15170. }
  15171. }
  15172. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  15173. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  15174. for id := range m.removedlabel_relationships {
  15175. ids = append(ids, id)
  15176. }
  15177. return
  15178. }
  15179. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  15180. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  15181. for id := range m.label_relationships {
  15182. ids = append(ids, id)
  15183. }
  15184. return
  15185. }
  15186. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  15187. func (m *LabelMutation) ResetLabelRelationships() {
  15188. m.label_relationships = nil
  15189. m.clearedlabel_relationships = false
  15190. m.removedlabel_relationships = nil
  15191. }
  15192. // Where appends a list predicates to the LabelMutation builder.
  15193. func (m *LabelMutation) Where(ps ...predicate.Label) {
  15194. m.predicates = append(m.predicates, ps...)
  15195. }
  15196. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  15197. // users can use type-assertion to append predicates that do not depend on any generated package.
  15198. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  15199. p := make([]predicate.Label, len(ps))
  15200. for i := range ps {
  15201. p[i] = ps[i]
  15202. }
  15203. m.Where(p...)
  15204. }
  15205. // Op returns the operation name.
  15206. func (m *LabelMutation) Op() Op {
  15207. return m.op
  15208. }
  15209. // SetOp allows setting the mutation operation.
  15210. func (m *LabelMutation) SetOp(op Op) {
  15211. m.op = op
  15212. }
  15213. // Type returns the node type of this mutation (Label).
  15214. func (m *LabelMutation) Type() string {
  15215. return m.typ
  15216. }
  15217. // Fields returns all fields that were changed during this mutation. Note that in
  15218. // order to get all numeric fields that were incremented/decremented, call
  15219. // AddedFields().
  15220. func (m *LabelMutation) Fields() []string {
  15221. fields := make([]string, 0, 9)
  15222. if m.created_at != nil {
  15223. fields = append(fields, label.FieldCreatedAt)
  15224. }
  15225. if m.updated_at != nil {
  15226. fields = append(fields, label.FieldUpdatedAt)
  15227. }
  15228. if m.status != nil {
  15229. fields = append(fields, label.FieldStatus)
  15230. }
  15231. if m._type != nil {
  15232. fields = append(fields, label.FieldType)
  15233. }
  15234. if m.name != nil {
  15235. fields = append(fields, label.FieldName)
  15236. }
  15237. if m.from != nil {
  15238. fields = append(fields, label.FieldFrom)
  15239. }
  15240. if m.mode != nil {
  15241. fields = append(fields, label.FieldMode)
  15242. }
  15243. if m.conditions != nil {
  15244. fields = append(fields, label.FieldConditions)
  15245. }
  15246. if m.organization_id != nil {
  15247. fields = append(fields, label.FieldOrganizationID)
  15248. }
  15249. return fields
  15250. }
  15251. // Field returns the value of a field with the given name. The second boolean
  15252. // return value indicates that this field was not set, or was not defined in the
  15253. // schema.
  15254. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  15255. switch name {
  15256. case label.FieldCreatedAt:
  15257. return m.CreatedAt()
  15258. case label.FieldUpdatedAt:
  15259. return m.UpdatedAt()
  15260. case label.FieldStatus:
  15261. return m.Status()
  15262. case label.FieldType:
  15263. return m.GetType()
  15264. case label.FieldName:
  15265. return m.Name()
  15266. case label.FieldFrom:
  15267. return m.From()
  15268. case label.FieldMode:
  15269. return m.Mode()
  15270. case label.FieldConditions:
  15271. return m.Conditions()
  15272. case label.FieldOrganizationID:
  15273. return m.OrganizationID()
  15274. }
  15275. return nil, false
  15276. }
  15277. // OldField returns the old value of the field from the database. An error is
  15278. // returned if the mutation operation is not UpdateOne, or the query to the
  15279. // database failed.
  15280. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15281. switch name {
  15282. case label.FieldCreatedAt:
  15283. return m.OldCreatedAt(ctx)
  15284. case label.FieldUpdatedAt:
  15285. return m.OldUpdatedAt(ctx)
  15286. case label.FieldStatus:
  15287. return m.OldStatus(ctx)
  15288. case label.FieldType:
  15289. return m.OldType(ctx)
  15290. case label.FieldName:
  15291. return m.OldName(ctx)
  15292. case label.FieldFrom:
  15293. return m.OldFrom(ctx)
  15294. case label.FieldMode:
  15295. return m.OldMode(ctx)
  15296. case label.FieldConditions:
  15297. return m.OldConditions(ctx)
  15298. case label.FieldOrganizationID:
  15299. return m.OldOrganizationID(ctx)
  15300. }
  15301. return nil, fmt.Errorf("unknown Label field %s", name)
  15302. }
  15303. // SetField sets the value of a field with the given name. It returns an error if
  15304. // the field is not defined in the schema, or if the type mismatched the field
  15305. // type.
  15306. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  15307. switch name {
  15308. case label.FieldCreatedAt:
  15309. v, ok := value.(time.Time)
  15310. if !ok {
  15311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15312. }
  15313. m.SetCreatedAt(v)
  15314. return nil
  15315. case label.FieldUpdatedAt:
  15316. v, ok := value.(time.Time)
  15317. if !ok {
  15318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15319. }
  15320. m.SetUpdatedAt(v)
  15321. return nil
  15322. case label.FieldStatus:
  15323. v, ok := value.(uint8)
  15324. if !ok {
  15325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15326. }
  15327. m.SetStatus(v)
  15328. return nil
  15329. case label.FieldType:
  15330. v, ok := value.(int)
  15331. if !ok {
  15332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15333. }
  15334. m.SetType(v)
  15335. return nil
  15336. case label.FieldName:
  15337. v, ok := value.(string)
  15338. if !ok {
  15339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15340. }
  15341. m.SetName(v)
  15342. return nil
  15343. case label.FieldFrom:
  15344. v, ok := value.(int)
  15345. if !ok {
  15346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15347. }
  15348. m.SetFrom(v)
  15349. return nil
  15350. case label.FieldMode:
  15351. v, ok := value.(int)
  15352. if !ok {
  15353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15354. }
  15355. m.SetMode(v)
  15356. return nil
  15357. case label.FieldConditions:
  15358. v, ok := value.(string)
  15359. if !ok {
  15360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15361. }
  15362. m.SetConditions(v)
  15363. return nil
  15364. case label.FieldOrganizationID:
  15365. v, ok := value.(uint64)
  15366. if !ok {
  15367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15368. }
  15369. m.SetOrganizationID(v)
  15370. return nil
  15371. }
  15372. return fmt.Errorf("unknown Label field %s", name)
  15373. }
  15374. // AddedFields returns all numeric fields that were incremented/decremented during
  15375. // this mutation.
  15376. func (m *LabelMutation) AddedFields() []string {
  15377. var fields []string
  15378. if m.addstatus != nil {
  15379. fields = append(fields, label.FieldStatus)
  15380. }
  15381. if m.add_type != nil {
  15382. fields = append(fields, label.FieldType)
  15383. }
  15384. if m.addfrom != nil {
  15385. fields = append(fields, label.FieldFrom)
  15386. }
  15387. if m.addmode != nil {
  15388. fields = append(fields, label.FieldMode)
  15389. }
  15390. if m.addorganization_id != nil {
  15391. fields = append(fields, label.FieldOrganizationID)
  15392. }
  15393. return fields
  15394. }
  15395. // AddedField returns the numeric value that was incremented/decremented on a field
  15396. // with the given name. The second boolean return value indicates that this field
  15397. // was not set, or was not defined in the schema.
  15398. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  15399. switch name {
  15400. case label.FieldStatus:
  15401. return m.AddedStatus()
  15402. case label.FieldType:
  15403. return m.AddedType()
  15404. case label.FieldFrom:
  15405. return m.AddedFrom()
  15406. case label.FieldMode:
  15407. return m.AddedMode()
  15408. case label.FieldOrganizationID:
  15409. return m.AddedOrganizationID()
  15410. }
  15411. return nil, false
  15412. }
  15413. // AddField adds the value to the field with the given name. It returns an error if
  15414. // the field is not defined in the schema, or if the type mismatched the field
  15415. // type.
  15416. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  15417. switch name {
  15418. case label.FieldStatus:
  15419. v, ok := value.(int8)
  15420. if !ok {
  15421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15422. }
  15423. m.AddStatus(v)
  15424. return nil
  15425. case label.FieldType:
  15426. v, ok := value.(int)
  15427. if !ok {
  15428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15429. }
  15430. m.AddType(v)
  15431. return nil
  15432. case label.FieldFrom:
  15433. v, ok := value.(int)
  15434. if !ok {
  15435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15436. }
  15437. m.AddFrom(v)
  15438. return nil
  15439. case label.FieldMode:
  15440. v, ok := value.(int)
  15441. if !ok {
  15442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15443. }
  15444. m.AddMode(v)
  15445. return nil
  15446. case label.FieldOrganizationID:
  15447. v, ok := value.(int64)
  15448. if !ok {
  15449. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15450. }
  15451. m.AddOrganizationID(v)
  15452. return nil
  15453. }
  15454. return fmt.Errorf("unknown Label numeric field %s", name)
  15455. }
  15456. // ClearedFields returns all nullable fields that were cleared during this
  15457. // mutation.
  15458. func (m *LabelMutation) ClearedFields() []string {
  15459. var fields []string
  15460. if m.FieldCleared(label.FieldStatus) {
  15461. fields = append(fields, label.FieldStatus)
  15462. }
  15463. if m.FieldCleared(label.FieldConditions) {
  15464. fields = append(fields, label.FieldConditions)
  15465. }
  15466. if m.FieldCleared(label.FieldOrganizationID) {
  15467. fields = append(fields, label.FieldOrganizationID)
  15468. }
  15469. return fields
  15470. }
  15471. // FieldCleared returns a boolean indicating if a field with the given name was
  15472. // cleared in this mutation.
  15473. func (m *LabelMutation) FieldCleared(name string) bool {
  15474. _, ok := m.clearedFields[name]
  15475. return ok
  15476. }
  15477. // ClearField clears the value of the field with the given name. It returns an
  15478. // error if the field is not defined in the schema.
  15479. func (m *LabelMutation) ClearField(name string) error {
  15480. switch name {
  15481. case label.FieldStatus:
  15482. m.ClearStatus()
  15483. return nil
  15484. case label.FieldConditions:
  15485. m.ClearConditions()
  15486. return nil
  15487. case label.FieldOrganizationID:
  15488. m.ClearOrganizationID()
  15489. return nil
  15490. }
  15491. return fmt.Errorf("unknown Label nullable field %s", name)
  15492. }
  15493. // ResetField resets all changes in the mutation for the field with the given name.
  15494. // It returns an error if the field is not defined in the schema.
  15495. func (m *LabelMutation) ResetField(name string) error {
  15496. switch name {
  15497. case label.FieldCreatedAt:
  15498. m.ResetCreatedAt()
  15499. return nil
  15500. case label.FieldUpdatedAt:
  15501. m.ResetUpdatedAt()
  15502. return nil
  15503. case label.FieldStatus:
  15504. m.ResetStatus()
  15505. return nil
  15506. case label.FieldType:
  15507. m.ResetType()
  15508. return nil
  15509. case label.FieldName:
  15510. m.ResetName()
  15511. return nil
  15512. case label.FieldFrom:
  15513. m.ResetFrom()
  15514. return nil
  15515. case label.FieldMode:
  15516. m.ResetMode()
  15517. return nil
  15518. case label.FieldConditions:
  15519. m.ResetConditions()
  15520. return nil
  15521. case label.FieldOrganizationID:
  15522. m.ResetOrganizationID()
  15523. return nil
  15524. }
  15525. return fmt.Errorf("unknown Label field %s", name)
  15526. }
  15527. // AddedEdges returns all edge names that were set/added in this mutation.
  15528. func (m *LabelMutation) AddedEdges() []string {
  15529. edges := make([]string, 0, 1)
  15530. if m.label_relationships != nil {
  15531. edges = append(edges, label.EdgeLabelRelationships)
  15532. }
  15533. return edges
  15534. }
  15535. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15536. // name in this mutation.
  15537. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  15538. switch name {
  15539. case label.EdgeLabelRelationships:
  15540. ids := make([]ent.Value, 0, len(m.label_relationships))
  15541. for id := range m.label_relationships {
  15542. ids = append(ids, id)
  15543. }
  15544. return ids
  15545. }
  15546. return nil
  15547. }
  15548. // RemovedEdges returns all edge names that were removed in this mutation.
  15549. func (m *LabelMutation) RemovedEdges() []string {
  15550. edges := make([]string, 0, 1)
  15551. if m.removedlabel_relationships != nil {
  15552. edges = append(edges, label.EdgeLabelRelationships)
  15553. }
  15554. return edges
  15555. }
  15556. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15557. // the given name in this mutation.
  15558. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  15559. switch name {
  15560. case label.EdgeLabelRelationships:
  15561. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  15562. for id := range m.removedlabel_relationships {
  15563. ids = append(ids, id)
  15564. }
  15565. return ids
  15566. }
  15567. return nil
  15568. }
  15569. // ClearedEdges returns all edge names that were cleared in this mutation.
  15570. func (m *LabelMutation) ClearedEdges() []string {
  15571. edges := make([]string, 0, 1)
  15572. if m.clearedlabel_relationships {
  15573. edges = append(edges, label.EdgeLabelRelationships)
  15574. }
  15575. return edges
  15576. }
  15577. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15578. // was cleared in this mutation.
  15579. func (m *LabelMutation) EdgeCleared(name string) bool {
  15580. switch name {
  15581. case label.EdgeLabelRelationships:
  15582. return m.clearedlabel_relationships
  15583. }
  15584. return false
  15585. }
  15586. // ClearEdge clears the value of the edge with the given name. It returns an error
  15587. // if that edge is not defined in the schema.
  15588. func (m *LabelMutation) ClearEdge(name string) error {
  15589. switch name {
  15590. }
  15591. return fmt.Errorf("unknown Label unique edge %s", name)
  15592. }
  15593. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15594. // It returns an error if the edge is not defined in the schema.
  15595. func (m *LabelMutation) ResetEdge(name string) error {
  15596. switch name {
  15597. case label.EdgeLabelRelationships:
  15598. m.ResetLabelRelationships()
  15599. return nil
  15600. }
  15601. return fmt.Errorf("unknown Label edge %s", name)
  15602. }
  15603. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  15604. type LabelRelationshipMutation struct {
  15605. config
  15606. op Op
  15607. typ string
  15608. id *uint64
  15609. created_at *time.Time
  15610. updated_at *time.Time
  15611. status *uint8
  15612. addstatus *int8
  15613. organization_id *uint64
  15614. addorganization_id *int64
  15615. clearedFields map[string]struct{}
  15616. contacts *uint64
  15617. clearedcontacts bool
  15618. labels *uint64
  15619. clearedlabels bool
  15620. done bool
  15621. oldValue func(context.Context) (*LabelRelationship, error)
  15622. predicates []predicate.LabelRelationship
  15623. }
  15624. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  15625. // labelrelationshipOption allows management of the mutation configuration using functional options.
  15626. type labelrelationshipOption func(*LabelRelationshipMutation)
  15627. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  15628. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  15629. m := &LabelRelationshipMutation{
  15630. config: c,
  15631. op: op,
  15632. typ: TypeLabelRelationship,
  15633. clearedFields: make(map[string]struct{}),
  15634. }
  15635. for _, opt := range opts {
  15636. opt(m)
  15637. }
  15638. return m
  15639. }
  15640. // withLabelRelationshipID sets the ID field of the mutation.
  15641. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  15642. return func(m *LabelRelationshipMutation) {
  15643. var (
  15644. err error
  15645. once sync.Once
  15646. value *LabelRelationship
  15647. )
  15648. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  15649. once.Do(func() {
  15650. if m.done {
  15651. err = errors.New("querying old values post mutation is not allowed")
  15652. } else {
  15653. value, err = m.Client().LabelRelationship.Get(ctx, id)
  15654. }
  15655. })
  15656. return value, err
  15657. }
  15658. m.id = &id
  15659. }
  15660. }
  15661. // withLabelRelationship sets the old LabelRelationship of the mutation.
  15662. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  15663. return func(m *LabelRelationshipMutation) {
  15664. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  15665. return node, nil
  15666. }
  15667. m.id = &node.ID
  15668. }
  15669. }
  15670. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15671. // executed in a transaction (ent.Tx), a transactional client is returned.
  15672. func (m LabelRelationshipMutation) Client() *Client {
  15673. client := &Client{config: m.config}
  15674. client.init()
  15675. return client
  15676. }
  15677. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15678. // it returns an error otherwise.
  15679. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  15680. if _, ok := m.driver.(*txDriver); !ok {
  15681. return nil, errors.New("ent: mutation is not running in a transaction")
  15682. }
  15683. tx := &Tx{config: m.config}
  15684. tx.init()
  15685. return tx, nil
  15686. }
  15687. // SetID sets the value of the id field. Note that this
  15688. // operation is only accepted on creation of LabelRelationship entities.
  15689. func (m *LabelRelationshipMutation) SetID(id uint64) {
  15690. m.id = &id
  15691. }
  15692. // ID returns the ID value in the mutation. Note that the ID is only available
  15693. // if it was provided to the builder or after it was returned from the database.
  15694. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  15695. if m.id == nil {
  15696. return
  15697. }
  15698. return *m.id, true
  15699. }
  15700. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15701. // That means, if the mutation is applied within a transaction with an isolation level such
  15702. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15703. // or updated by the mutation.
  15704. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  15705. switch {
  15706. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15707. id, exists := m.ID()
  15708. if exists {
  15709. return []uint64{id}, nil
  15710. }
  15711. fallthrough
  15712. case m.op.Is(OpUpdate | OpDelete):
  15713. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  15714. default:
  15715. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15716. }
  15717. }
  15718. // SetCreatedAt sets the "created_at" field.
  15719. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  15720. m.created_at = &t
  15721. }
  15722. // CreatedAt returns the value of the "created_at" field in the mutation.
  15723. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  15724. v := m.created_at
  15725. if v == nil {
  15726. return
  15727. }
  15728. return *v, true
  15729. }
  15730. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  15731. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  15732. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15733. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15734. if !m.op.Is(OpUpdateOne) {
  15735. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15736. }
  15737. if m.id == nil || m.oldValue == nil {
  15738. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15739. }
  15740. oldValue, err := m.oldValue(ctx)
  15741. if err != nil {
  15742. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15743. }
  15744. return oldValue.CreatedAt, nil
  15745. }
  15746. // ResetCreatedAt resets all changes to the "created_at" field.
  15747. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  15748. m.created_at = nil
  15749. }
  15750. // SetUpdatedAt sets the "updated_at" field.
  15751. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  15752. m.updated_at = &t
  15753. }
  15754. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15755. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  15756. v := m.updated_at
  15757. if v == nil {
  15758. return
  15759. }
  15760. return *v, true
  15761. }
  15762. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  15763. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  15764. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15765. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15766. if !m.op.Is(OpUpdateOne) {
  15767. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15768. }
  15769. if m.id == nil || m.oldValue == nil {
  15770. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15771. }
  15772. oldValue, err := m.oldValue(ctx)
  15773. if err != nil {
  15774. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15775. }
  15776. return oldValue.UpdatedAt, nil
  15777. }
  15778. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15779. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  15780. m.updated_at = nil
  15781. }
  15782. // SetStatus sets the "status" field.
  15783. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  15784. m.status = &u
  15785. m.addstatus = nil
  15786. }
  15787. // Status returns the value of the "status" field in the mutation.
  15788. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  15789. v := m.status
  15790. if v == nil {
  15791. return
  15792. }
  15793. return *v, true
  15794. }
  15795. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  15796. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  15797. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15798. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15799. if !m.op.Is(OpUpdateOne) {
  15800. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15801. }
  15802. if m.id == nil || m.oldValue == nil {
  15803. return v, errors.New("OldStatus requires an ID field in the mutation")
  15804. }
  15805. oldValue, err := m.oldValue(ctx)
  15806. if err != nil {
  15807. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15808. }
  15809. return oldValue.Status, nil
  15810. }
  15811. // AddStatus adds u to the "status" field.
  15812. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  15813. if m.addstatus != nil {
  15814. *m.addstatus += u
  15815. } else {
  15816. m.addstatus = &u
  15817. }
  15818. }
  15819. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15820. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  15821. v := m.addstatus
  15822. if v == nil {
  15823. return
  15824. }
  15825. return *v, true
  15826. }
  15827. // ClearStatus clears the value of the "status" field.
  15828. func (m *LabelRelationshipMutation) ClearStatus() {
  15829. m.status = nil
  15830. m.addstatus = nil
  15831. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  15832. }
  15833. // StatusCleared returns if the "status" field was cleared in this mutation.
  15834. func (m *LabelRelationshipMutation) StatusCleared() bool {
  15835. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  15836. return ok
  15837. }
  15838. // ResetStatus resets all changes to the "status" field.
  15839. func (m *LabelRelationshipMutation) ResetStatus() {
  15840. m.status = nil
  15841. m.addstatus = nil
  15842. delete(m.clearedFields, labelrelationship.FieldStatus)
  15843. }
  15844. // SetLabelID sets the "label_id" field.
  15845. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  15846. m.labels = &u
  15847. }
  15848. // LabelID returns the value of the "label_id" field in the mutation.
  15849. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  15850. v := m.labels
  15851. if v == nil {
  15852. return
  15853. }
  15854. return *v, true
  15855. }
  15856. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  15857. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  15858. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15859. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  15860. if !m.op.Is(OpUpdateOne) {
  15861. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  15862. }
  15863. if m.id == nil || m.oldValue == nil {
  15864. return v, errors.New("OldLabelID requires an ID field in the mutation")
  15865. }
  15866. oldValue, err := m.oldValue(ctx)
  15867. if err != nil {
  15868. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  15869. }
  15870. return oldValue.LabelID, nil
  15871. }
  15872. // ResetLabelID resets all changes to the "label_id" field.
  15873. func (m *LabelRelationshipMutation) ResetLabelID() {
  15874. m.labels = nil
  15875. }
  15876. // SetContactID sets the "contact_id" field.
  15877. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  15878. m.contacts = &u
  15879. }
  15880. // ContactID returns the value of the "contact_id" field in the mutation.
  15881. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  15882. v := m.contacts
  15883. if v == nil {
  15884. return
  15885. }
  15886. return *v, true
  15887. }
  15888. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  15889. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  15890. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15891. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  15892. if !m.op.Is(OpUpdateOne) {
  15893. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  15894. }
  15895. if m.id == nil || m.oldValue == nil {
  15896. return v, errors.New("OldContactID requires an ID field in the mutation")
  15897. }
  15898. oldValue, err := m.oldValue(ctx)
  15899. if err != nil {
  15900. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  15901. }
  15902. return oldValue.ContactID, nil
  15903. }
  15904. // ResetContactID resets all changes to the "contact_id" field.
  15905. func (m *LabelRelationshipMutation) ResetContactID() {
  15906. m.contacts = nil
  15907. }
  15908. // SetOrganizationID sets the "organization_id" field.
  15909. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  15910. m.organization_id = &u
  15911. m.addorganization_id = nil
  15912. }
  15913. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15914. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  15915. v := m.organization_id
  15916. if v == nil {
  15917. return
  15918. }
  15919. return *v, true
  15920. }
  15921. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  15922. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  15923. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15924. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15925. if !m.op.Is(OpUpdateOne) {
  15926. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15927. }
  15928. if m.id == nil || m.oldValue == nil {
  15929. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15930. }
  15931. oldValue, err := m.oldValue(ctx)
  15932. if err != nil {
  15933. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15934. }
  15935. return oldValue.OrganizationID, nil
  15936. }
  15937. // AddOrganizationID adds u to the "organization_id" field.
  15938. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  15939. if m.addorganization_id != nil {
  15940. *m.addorganization_id += u
  15941. } else {
  15942. m.addorganization_id = &u
  15943. }
  15944. }
  15945. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15946. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  15947. v := m.addorganization_id
  15948. if v == nil {
  15949. return
  15950. }
  15951. return *v, true
  15952. }
  15953. // ClearOrganizationID clears the value of the "organization_id" field.
  15954. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  15955. m.organization_id = nil
  15956. m.addorganization_id = nil
  15957. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  15958. }
  15959. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  15960. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  15961. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  15962. return ok
  15963. }
  15964. // ResetOrganizationID resets all changes to the "organization_id" field.
  15965. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  15966. m.organization_id = nil
  15967. m.addorganization_id = nil
  15968. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  15969. }
  15970. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  15971. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  15972. m.contacts = &id
  15973. }
  15974. // ClearContacts clears the "contacts" edge to the Contact entity.
  15975. func (m *LabelRelationshipMutation) ClearContacts() {
  15976. m.clearedcontacts = true
  15977. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  15978. }
  15979. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  15980. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  15981. return m.clearedcontacts
  15982. }
  15983. // ContactsID returns the "contacts" edge ID in the mutation.
  15984. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  15985. if m.contacts != nil {
  15986. return *m.contacts, true
  15987. }
  15988. return
  15989. }
  15990. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  15991. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  15992. // ContactsID instead. It exists only for internal usage by the builders.
  15993. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  15994. if id := m.contacts; id != nil {
  15995. ids = append(ids, *id)
  15996. }
  15997. return
  15998. }
  15999. // ResetContacts resets all changes to the "contacts" edge.
  16000. func (m *LabelRelationshipMutation) ResetContacts() {
  16001. m.contacts = nil
  16002. m.clearedcontacts = false
  16003. }
  16004. // SetLabelsID sets the "labels" edge to the Label entity by id.
  16005. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  16006. m.labels = &id
  16007. }
  16008. // ClearLabels clears the "labels" edge to the Label entity.
  16009. func (m *LabelRelationshipMutation) ClearLabels() {
  16010. m.clearedlabels = true
  16011. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  16012. }
  16013. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  16014. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  16015. return m.clearedlabels
  16016. }
  16017. // LabelsID returns the "labels" edge ID in the mutation.
  16018. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  16019. if m.labels != nil {
  16020. return *m.labels, true
  16021. }
  16022. return
  16023. }
  16024. // LabelsIDs returns the "labels" edge IDs in the mutation.
  16025. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  16026. // LabelsID instead. It exists only for internal usage by the builders.
  16027. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  16028. if id := m.labels; id != nil {
  16029. ids = append(ids, *id)
  16030. }
  16031. return
  16032. }
  16033. // ResetLabels resets all changes to the "labels" edge.
  16034. func (m *LabelRelationshipMutation) ResetLabels() {
  16035. m.labels = nil
  16036. m.clearedlabels = false
  16037. }
  16038. // Where appends a list predicates to the LabelRelationshipMutation builder.
  16039. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  16040. m.predicates = append(m.predicates, ps...)
  16041. }
  16042. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  16043. // users can use type-assertion to append predicates that do not depend on any generated package.
  16044. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  16045. p := make([]predicate.LabelRelationship, len(ps))
  16046. for i := range ps {
  16047. p[i] = ps[i]
  16048. }
  16049. m.Where(p...)
  16050. }
  16051. // Op returns the operation name.
  16052. func (m *LabelRelationshipMutation) Op() Op {
  16053. return m.op
  16054. }
  16055. // SetOp allows setting the mutation operation.
  16056. func (m *LabelRelationshipMutation) SetOp(op Op) {
  16057. m.op = op
  16058. }
  16059. // Type returns the node type of this mutation (LabelRelationship).
  16060. func (m *LabelRelationshipMutation) Type() string {
  16061. return m.typ
  16062. }
  16063. // Fields returns all fields that were changed during this mutation. Note that in
  16064. // order to get all numeric fields that were incremented/decremented, call
  16065. // AddedFields().
  16066. func (m *LabelRelationshipMutation) Fields() []string {
  16067. fields := make([]string, 0, 6)
  16068. if m.created_at != nil {
  16069. fields = append(fields, labelrelationship.FieldCreatedAt)
  16070. }
  16071. if m.updated_at != nil {
  16072. fields = append(fields, labelrelationship.FieldUpdatedAt)
  16073. }
  16074. if m.status != nil {
  16075. fields = append(fields, labelrelationship.FieldStatus)
  16076. }
  16077. if m.labels != nil {
  16078. fields = append(fields, labelrelationship.FieldLabelID)
  16079. }
  16080. if m.contacts != nil {
  16081. fields = append(fields, labelrelationship.FieldContactID)
  16082. }
  16083. if m.organization_id != nil {
  16084. fields = append(fields, labelrelationship.FieldOrganizationID)
  16085. }
  16086. return fields
  16087. }
  16088. // Field returns the value of a field with the given name. The second boolean
  16089. // return value indicates that this field was not set, or was not defined in the
  16090. // schema.
  16091. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  16092. switch name {
  16093. case labelrelationship.FieldCreatedAt:
  16094. return m.CreatedAt()
  16095. case labelrelationship.FieldUpdatedAt:
  16096. return m.UpdatedAt()
  16097. case labelrelationship.FieldStatus:
  16098. return m.Status()
  16099. case labelrelationship.FieldLabelID:
  16100. return m.LabelID()
  16101. case labelrelationship.FieldContactID:
  16102. return m.ContactID()
  16103. case labelrelationship.FieldOrganizationID:
  16104. return m.OrganizationID()
  16105. }
  16106. return nil, false
  16107. }
  16108. // OldField returns the old value of the field from the database. An error is
  16109. // returned if the mutation operation is not UpdateOne, or the query to the
  16110. // database failed.
  16111. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16112. switch name {
  16113. case labelrelationship.FieldCreatedAt:
  16114. return m.OldCreatedAt(ctx)
  16115. case labelrelationship.FieldUpdatedAt:
  16116. return m.OldUpdatedAt(ctx)
  16117. case labelrelationship.FieldStatus:
  16118. return m.OldStatus(ctx)
  16119. case labelrelationship.FieldLabelID:
  16120. return m.OldLabelID(ctx)
  16121. case labelrelationship.FieldContactID:
  16122. return m.OldContactID(ctx)
  16123. case labelrelationship.FieldOrganizationID:
  16124. return m.OldOrganizationID(ctx)
  16125. }
  16126. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  16127. }
  16128. // SetField sets the value of a field with the given name. It returns an error if
  16129. // the field is not defined in the schema, or if the type mismatched the field
  16130. // type.
  16131. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  16132. switch name {
  16133. case labelrelationship.FieldCreatedAt:
  16134. v, ok := value.(time.Time)
  16135. if !ok {
  16136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16137. }
  16138. m.SetCreatedAt(v)
  16139. return nil
  16140. case labelrelationship.FieldUpdatedAt:
  16141. v, ok := value.(time.Time)
  16142. if !ok {
  16143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16144. }
  16145. m.SetUpdatedAt(v)
  16146. return nil
  16147. case labelrelationship.FieldStatus:
  16148. v, ok := value.(uint8)
  16149. if !ok {
  16150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16151. }
  16152. m.SetStatus(v)
  16153. return nil
  16154. case labelrelationship.FieldLabelID:
  16155. v, ok := value.(uint64)
  16156. if !ok {
  16157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16158. }
  16159. m.SetLabelID(v)
  16160. return nil
  16161. case labelrelationship.FieldContactID:
  16162. v, ok := value.(uint64)
  16163. if !ok {
  16164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16165. }
  16166. m.SetContactID(v)
  16167. return nil
  16168. case labelrelationship.FieldOrganizationID:
  16169. v, ok := value.(uint64)
  16170. if !ok {
  16171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16172. }
  16173. m.SetOrganizationID(v)
  16174. return nil
  16175. }
  16176. return fmt.Errorf("unknown LabelRelationship field %s", name)
  16177. }
  16178. // AddedFields returns all numeric fields that were incremented/decremented during
  16179. // this mutation.
  16180. func (m *LabelRelationshipMutation) AddedFields() []string {
  16181. var fields []string
  16182. if m.addstatus != nil {
  16183. fields = append(fields, labelrelationship.FieldStatus)
  16184. }
  16185. if m.addorganization_id != nil {
  16186. fields = append(fields, labelrelationship.FieldOrganizationID)
  16187. }
  16188. return fields
  16189. }
  16190. // AddedField returns the numeric value that was incremented/decremented on a field
  16191. // with the given name. The second boolean return value indicates that this field
  16192. // was not set, or was not defined in the schema.
  16193. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  16194. switch name {
  16195. case labelrelationship.FieldStatus:
  16196. return m.AddedStatus()
  16197. case labelrelationship.FieldOrganizationID:
  16198. return m.AddedOrganizationID()
  16199. }
  16200. return nil, false
  16201. }
  16202. // AddField adds the value to the field with the given name. It returns an error if
  16203. // the field is not defined in the schema, or if the type mismatched the field
  16204. // type.
  16205. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  16206. switch name {
  16207. case labelrelationship.FieldStatus:
  16208. v, ok := value.(int8)
  16209. if !ok {
  16210. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16211. }
  16212. m.AddStatus(v)
  16213. return nil
  16214. case labelrelationship.FieldOrganizationID:
  16215. v, ok := value.(int64)
  16216. if !ok {
  16217. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16218. }
  16219. m.AddOrganizationID(v)
  16220. return nil
  16221. }
  16222. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  16223. }
  16224. // ClearedFields returns all nullable fields that were cleared during this
  16225. // mutation.
  16226. func (m *LabelRelationshipMutation) ClearedFields() []string {
  16227. var fields []string
  16228. if m.FieldCleared(labelrelationship.FieldStatus) {
  16229. fields = append(fields, labelrelationship.FieldStatus)
  16230. }
  16231. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  16232. fields = append(fields, labelrelationship.FieldOrganizationID)
  16233. }
  16234. return fields
  16235. }
  16236. // FieldCleared returns a boolean indicating if a field with the given name was
  16237. // cleared in this mutation.
  16238. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  16239. _, ok := m.clearedFields[name]
  16240. return ok
  16241. }
  16242. // ClearField clears the value of the field with the given name. It returns an
  16243. // error if the field is not defined in the schema.
  16244. func (m *LabelRelationshipMutation) ClearField(name string) error {
  16245. switch name {
  16246. case labelrelationship.FieldStatus:
  16247. m.ClearStatus()
  16248. return nil
  16249. case labelrelationship.FieldOrganizationID:
  16250. m.ClearOrganizationID()
  16251. return nil
  16252. }
  16253. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  16254. }
  16255. // ResetField resets all changes in the mutation for the field with the given name.
  16256. // It returns an error if the field is not defined in the schema.
  16257. func (m *LabelRelationshipMutation) ResetField(name string) error {
  16258. switch name {
  16259. case labelrelationship.FieldCreatedAt:
  16260. m.ResetCreatedAt()
  16261. return nil
  16262. case labelrelationship.FieldUpdatedAt:
  16263. m.ResetUpdatedAt()
  16264. return nil
  16265. case labelrelationship.FieldStatus:
  16266. m.ResetStatus()
  16267. return nil
  16268. case labelrelationship.FieldLabelID:
  16269. m.ResetLabelID()
  16270. return nil
  16271. case labelrelationship.FieldContactID:
  16272. m.ResetContactID()
  16273. return nil
  16274. case labelrelationship.FieldOrganizationID:
  16275. m.ResetOrganizationID()
  16276. return nil
  16277. }
  16278. return fmt.Errorf("unknown LabelRelationship field %s", name)
  16279. }
  16280. // AddedEdges returns all edge names that were set/added in this mutation.
  16281. func (m *LabelRelationshipMutation) AddedEdges() []string {
  16282. edges := make([]string, 0, 2)
  16283. if m.contacts != nil {
  16284. edges = append(edges, labelrelationship.EdgeContacts)
  16285. }
  16286. if m.labels != nil {
  16287. edges = append(edges, labelrelationship.EdgeLabels)
  16288. }
  16289. return edges
  16290. }
  16291. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16292. // name in this mutation.
  16293. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  16294. switch name {
  16295. case labelrelationship.EdgeContacts:
  16296. if id := m.contacts; id != nil {
  16297. return []ent.Value{*id}
  16298. }
  16299. case labelrelationship.EdgeLabels:
  16300. if id := m.labels; id != nil {
  16301. return []ent.Value{*id}
  16302. }
  16303. }
  16304. return nil
  16305. }
  16306. // RemovedEdges returns all edge names that were removed in this mutation.
  16307. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  16308. edges := make([]string, 0, 2)
  16309. return edges
  16310. }
  16311. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16312. // the given name in this mutation.
  16313. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  16314. return nil
  16315. }
  16316. // ClearedEdges returns all edge names that were cleared in this mutation.
  16317. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  16318. edges := make([]string, 0, 2)
  16319. if m.clearedcontacts {
  16320. edges = append(edges, labelrelationship.EdgeContacts)
  16321. }
  16322. if m.clearedlabels {
  16323. edges = append(edges, labelrelationship.EdgeLabels)
  16324. }
  16325. return edges
  16326. }
  16327. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16328. // was cleared in this mutation.
  16329. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  16330. switch name {
  16331. case labelrelationship.EdgeContacts:
  16332. return m.clearedcontacts
  16333. case labelrelationship.EdgeLabels:
  16334. return m.clearedlabels
  16335. }
  16336. return false
  16337. }
  16338. // ClearEdge clears the value of the edge with the given name. It returns an error
  16339. // if that edge is not defined in the schema.
  16340. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  16341. switch name {
  16342. case labelrelationship.EdgeContacts:
  16343. m.ClearContacts()
  16344. return nil
  16345. case labelrelationship.EdgeLabels:
  16346. m.ClearLabels()
  16347. return nil
  16348. }
  16349. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  16350. }
  16351. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16352. // It returns an error if the edge is not defined in the schema.
  16353. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  16354. switch name {
  16355. case labelrelationship.EdgeContacts:
  16356. m.ResetContacts()
  16357. return nil
  16358. case labelrelationship.EdgeLabels:
  16359. m.ResetLabels()
  16360. return nil
  16361. }
  16362. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  16363. }
  16364. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  16365. type LabelTaggingMutation struct {
  16366. config
  16367. op Op
  16368. typ string
  16369. id *uint64
  16370. created_at *time.Time
  16371. updated_at *time.Time
  16372. status *uint8
  16373. addstatus *int8
  16374. deleted_at *time.Time
  16375. organization_id *uint64
  16376. addorganization_id *int64
  16377. _type *int
  16378. add_type *int
  16379. conditions *string
  16380. action_label_add *[]uint64
  16381. appendaction_label_add []uint64
  16382. action_label_del *[]uint64
  16383. appendaction_label_del []uint64
  16384. clearedFields map[string]struct{}
  16385. done bool
  16386. oldValue func(context.Context) (*LabelTagging, error)
  16387. predicates []predicate.LabelTagging
  16388. }
  16389. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  16390. // labeltaggingOption allows management of the mutation configuration using functional options.
  16391. type labeltaggingOption func(*LabelTaggingMutation)
  16392. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  16393. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  16394. m := &LabelTaggingMutation{
  16395. config: c,
  16396. op: op,
  16397. typ: TypeLabelTagging,
  16398. clearedFields: make(map[string]struct{}),
  16399. }
  16400. for _, opt := range opts {
  16401. opt(m)
  16402. }
  16403. return m
  16404. }
  16405. // withLabelTaggingID sets the ID field of the mutation.
  16406. func withLabelTaggingID(id uint64) labeltaggingOption {
  16407. return func(m *LabelTaggingMutation) {
  16408. var (
  16409. err error
  16410. once sync.Once
  16411. value *LabelTagging
  16412. )
  16413. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  16414. once.Do(func() {
  16415. if m.done {
  16416. err = errors.New("querying old values post mutation is not allowed")
  16417. } else {
  16418. value, err = m.Client().LabelTagging.Get(ctx, id)
  16419. }
  16420. })
  16421. return value, err
  16422. }
  16423. m.id = &id
  16424. }
  16425. }
  16426. // withLabelTagging sets the old LabelTagging of the mutation.
  16427. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  16428. return func(m *LabelTaggingMutation) {
  16429. m.oldValue = func(context.Context) (*LabelTagging, error) {
  16430. return node, nil
  16431. }
  16432. m.id = &node.ID
  16433. }
  16434. }
  16435. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16436. // executed in a transaction (ent.Tx), a transactional client is returned.
  16437. func (m LabelTaggingMutation) Client() *Client {
  16438. client := &Client{config: m.config}
  16439. client.init()
  16440. return client
  16441. }
  16442. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16443. // it returns an error otherwise.
  16444. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  16445. if _, ok := m.driver.(*txDriver); !ok {
  16446. return nil, errors.New("ent: mutation is not running in a transaction")
  16447. }
  16448. tx := &Tx{config: m.config}
  16449. tx.init()
  16450. return tx, nil
  16451. }
  16452. // SetID sets the value of the id field. Note that this
  16453. // operation is only accepted on creation of LabelTagging entities.
  16454. func (m *LabelTaggingMutation) SetID(id uint64) {
  16455. m.id = &id
  16456. }
  16457. // ID returns the ID value in the mutation. Note that the ID is only available
  16458. // if it was provided to the builder or after it was returned from the database.
  16459. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  16460. if m.id == nil {
  16461. return
  16462. }
  16463. return *m.id, true
  16464. }
  16465. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16466. // That means, if the mutation is applied within a transaction with an isolation level such
  16467. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16468. // or updated by the mutation.
  16469. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  16470. switch {
  16471. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16472. id, exists := m.ID()
  16473. if exists {
  16474. return []uint64{id}, nil
  16475. }
  16476. fallthrough
  16477. case m.op.Is(OpUpdate | OpDelete):
  16478. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  16479. default:
  16480. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16481. }
  16482. }
  16483. // SetCreatedAt sets the "created_at" field.
  16484. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  16485. m.created_at = &t
  16486. }
  16487. // CreatedAt returns the value of the "created_at" field in the mutation.
  16488. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  16489. v := m.created_at
  16490. if v == nil {
  16491. return
  16492. }
  16493. return *v, true
  16494. }
  16495. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  16496. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16497. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16498. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16499. if !m.op.Is(OpUpdateOne) {
  16500. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16501. }
  16502. if m.id == nil || m.oldValue == nil {
  16503. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16504. }
  16505. oldValue, err := m.oldValue(ctx)
  16506. if err != nil {
  16507. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16508. }
  16509. return oldValue.CreatedAt, nil
  16510. }
  16511. // ResetCreatedAt resets all changes to the "created_at" field.
  16512. func (m *LabelTaggingMutation) ResetCreatedAt() {
  16513. m.created_at = nil
  16514. }
  16515. // SetUpdatedAt sets the "updated_at" field.
  16516. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  16517. m.updated_at = &t
  16518. }
  16519. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16520. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  16521. v := m.updated_at
  16522. if v == nil {
  16523. return
  16524. }
  16525. return *v, true
  16526. }
  16527. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  16528. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16529. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16530. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16531. if !m.op.Is(OpUpdateOne) {
  16532. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16533. }
  16534. if m.id == nil || m.oldValue == nil {
  16535. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16536. }
  16537. oldValue, err := m.oldValue(ctx)
  16538. if err != nil {
  16539. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16540. }
  16541. return oldValue.UpdatedAt, nil
  16542. }
  16543. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16544. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  16545. m.updated_at = nil
  16546. }
  16547. // SetStatus sets the "status" field.
  16548. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  16549. m.status = &u
  16550. m.addstatus = nil
  16551. }
  16552. // Status returns the value of the "status" field in the mutation.
  16553. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  16554. v := m.status
  16555. if v == nil {
  16556. return
  16557. }
  16558. return *v, true
  16559. }
  16560. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  16561. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16562. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16563. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16564. if !m.op.Is(OpUpdateOne) {
  16565. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16566. }
  16567. if m.id == nil || m.oldValue == nil {
  16568. return v, errors.New("OldStatus requires an ID field in the mutation")
  16569. }
  16570. oldValue, err := m.oldValue(ctx)
  16571. if err != nil {
  16572. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16573. }
  16574. return oldValue.Status, nil
  16575. }
  16576. // AddStatus adds u to the "status" field.
  16577. func (m *LabelTaggingMutation) AddStatus(u int8) {
  16578. if m.addstatus != nil {
  16579. *m.addstatus += u
  16580. } else {
  16581. m.addstatus = &u
  16582. }
  16583. }
  16584. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16585. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  16586. v := m.addstatus
  16587. if v == nil {
  16588. return
  16589. }
  16590. return *v, true
  16591. }
  16592. // ClearStatus clears the value of the "status" field.
  16593. func (m *LabelTaggingMutation) ClearStatus() {
  16594. m.status = nil
  16595. m.addstatus = nil
  16596. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  16597. }
  16598. // StatusCleared returns if the "status" field was cleared in this mutation.
  16599. func (m *LabelTaggingMutation) StatusCleared() bool {
  16600. _, ok := m.clearedFields[labeltagging.FieldStatus]
  16601. return ok
  16602. }
  16603. // ResetStatus resets all changes to the "status" field.
  16604. func (m *LabelTaggingMutation) ResetStatus() {
  16605. m.status = nil
  16606. m.addstatus = nil
  16607. delete(m.clearedFields, labeltagging.FieldStatus)
  16608. }
  16609. // SetDeletedAt sets the "deleted_at" field.
  16610. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  16611. m.deleted_at = &t
  16612. }
  16613. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16614. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  16615. v := m.deleted_at
  16616. if v == nil {
  16617. return
  16618. }
  16619. return *v, true
  16620. }
  16621. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  16622. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16623. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16624. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16625. if !m.op.Is(OpUpdateOne) {
  16626. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16627. }
  16628. if m.id == nil || m.oldValue == nil {
  16629. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16630. }
  16631. oldValue, err := m.oldValue(ctx)
  16632. if err != nil {
  16633. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16634. }
  16635. return oldValue.DeletedAt, nil
  16636. }
  16637. // ClearDeletedAt clears the value of the "deleted_at" field.
  16638. func (m *LabelTaggingMutation) ClearDeletedAt() {
  16639. m.deleted_at = nil
  16640. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  16641. }
  16642. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16643. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  16644. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  16645. return ok
  16646. }
  16647. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16648. func (m *LabelTaggingMutation) ResetDeletedAt() {
  16649. m.deleted_at = nil
  16650. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  16651. }
  16652. // SetOrganizationID sets the "organization_id" field.
  16653. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  16654. m.organization_id = &u
  16655. m.addorganization_id = nil
  16656. }
  16657. // OrganizationID returns the value of the "organization_id" field in the mutation.
  16658. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  16659. v := m.organization_id
  16660. if v == nil {
  16661. return
  16662. }
  16663. return *v, true
  16664. }
  16665. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  16666. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16667. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16668. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  16669. if !m.op.Is(OpUpdateOne) {
  16670. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  16671. }
  16672. if m.id == nil || m.oldValue == nil {
  16673. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  16674. }
  16675. oldValue, err := m.oldValue(ctx)
  16676. if err != nil {
  16677. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  16678. }
  16679. return oldValue.OrganizationID, nil
  16680. }
  16681. // AddOrganizationID adds u to the "organization_id" field.
  16682. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  16683. if m.addorganization_id != nil {
  16684. *m.addorganization_id += u
  16685. } else {
  16686. m.addorganization_id = &u
  16687. }
  16688. }
  16689. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  16690. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  16691. v := m.addorganization_id
  16692. if v == nil {
  16693. return
  16694. }
  16695. return *v, true
  16696. }
  16697. // ResetOrganizationID resets all changes to the "organization_id" field.
  16698. func (m *LabelTaggingMutation) ResetOrganizationID() {
  16699. m.organization_id = nil
  16700. m.addorganization_id = nil
  16701. }
  16702. // SetType sets the "type" field.
  16703. func (m *LabelTaggingMutation) SetType(i int) {
  16704. m._type = &i
  16705. m.add_type = nil
  16706. }
  16707. // GetType returns the value of the "type" field in the mutation.
  16708. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  16709. v := m._type
  16710. if v == nil {
  16711. return
  16712. }
  16713. return *v, true
  16714. }
  16715. // OldType returns the old "type" field's value of the LabelTagging entity.
  16716. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16717. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16718. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  16719. if !m.op.Is(OpUpdateOne) {
  16720. return v, errors.New("OldType is only allowed on UpdateOne operations")
  16721. }
  16722. if m.id == nil || m.oldValue == nil {
  16723. return v, errors.New("OldType requires an ID field in the mutation")
  16724. }
  16725. oldValue, err := m.oldValue(ctx)
  16726. if err != nil {
  16727. return v, fmt.Errorf("querying old value for OldType: %w", err)
  16728. }
  16729. return oldValue.Type, nil
  16730. }
  16731. // AddType adds i to the "type" field.
  16732. func (m *LabelTaggingMutation) AddType(i int) {
  16733. if m.add_type != nil {
  16734. *m.add_type += i
  16735. } else {
  16736. m.add_type = &i
  16737. }
  16738. }
  16739. // AddedType returns the value that was added to the "type" field in this mutation.
  16740. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  16741. v := m.add_type
  16742. if v == nil {
  16743. return
  16744. }
  16745. return *v, true
  16746. }
  16747. // ResetType resets all changes to the "type" field.
  16748. func (m *LabelTaggingMutation) ResetType() {
  16749. m._type = nil
  16750. m.add_type = nil
  16751. }
  16752. // SetConditions sets the "conditions" field.
  16753. func (m *LabelTaggingMutation) SetConditions(s string) {
  16754. m.conditions = &s
  16755. }
  16756. // Conditions returns the value of the "conditions" field in the mutation.
  16757. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  16758. v := m.conditions
  16759. if v == nil {
  16760. return
  16761. }
  16762. return *v, true
  16763. }
  16764. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  16765. // If the LabelTagging 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 *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  16768. if !m.op.Is(OpUpdateOne) {
  16769. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  16770. }
  16771. if m.id == nil || m.oldValue == nil {
  16772. return v, errors.New("OldConditions 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 OldConditions: %w", err)
  16777. }
  16778. return oldValue.Conditions, nil
  16779. }
  16780. // ResetConditions resets all changes to the "conditions" field.
  16781. func (m *LabelTaggingMutation) ResetConditions() {
  16782. m.conditions = nil
  16783. }
  16784. // SetActionLabelAdd sets the "action_label_add" field.
  16785. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  16786. m.action_label_add = &u
  16787. m.appendaction_label_add = nil
  16788. }
  16789. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  16790. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  16791. v := m.action_label_add
  16792. if v == nil {
  16793. return
  16794. }
  16795. return *v, true
  16796. }
  16797. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  16798. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16799. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16800. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  16801. if !m.op.Is(OpUpdateOne) {
  16802. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  16803. }
  16804. if m.id == nil || m.oldValue == nil {
  16805. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  16806. }
  16807. oldValue, err := m.oldValue(ctx)
  16808. if err != nil {
  16809. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  16810. }
  16811. return oldValue.ActionLabelAdd, nil
  16812. }
  16813. // AppendActionLabelAdd adds u to the "action_label_add" field.
  16814. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  16815. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  16816. }
  16817. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  16818. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  16819. if len(m.appendaction_label_add) == 0 {
  16820. return nil, false
  16821. }
  16822. return m.appendaction_label_add, true
  16823. }
  16824. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  16825. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  16826. m.action_label_add = nil
  16827. m.appendaction_label_add = nil
  16828. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  16829. }
  16830. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  16831. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  16832. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  16833. return ok
  16834. }
  16835. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  16836. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  16837. m.action_label_add = nil
  16838. m.appendaction_label_add = nil
  16839. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  16840. }
  16841. // SetActionLabelDel sets the "action_label_del" field.
  16842. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  16843. m.action_label_del = &u
  16844. m.appendaction_label_del = nil
  16845. }
  16846. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  16847. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  16848. v := m.action_label_del
  16849. if v == nil {
  16850. return
  16851. }
  16852. return *v, true
  16853. }
  16854. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  16855. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16856. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16857. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  16858. if !m.op.Is(OpUpdateOne) {
  16859. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  16860. }
  16861. if m.id == nil || m.oldValue == nil {
  16862. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  16863. }
  16864. oldValue, err := m.oldValue(ctx)
  16865. if err != nil {
  16866. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  16867. }
  16868. return oldValue.ActionLabelDel, nil
  16869. }
  16870. // AppendActionLabelDel adds u to the "action_label_del" field.
  16871. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  16872. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  16873. }
  16874. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  16875. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  16876. if len(m.appendaction_label_del) == 0 {
  16877. return nil, false
  16878. }
  16879. return m.appendaction_label_del, true
  16880. }
  16881. // ClearActionLabelDel clears the value of the "action_label_del" field.
  16882. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  16883. m.action_label_del = nil
  16884. m.appendaction_label_del = nil
  16885. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  16886. }
  16887. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  16888. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  16889. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  16890. return ok
  16891. }
  16892. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  16893. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  16894. m.action_label_del = nil
  16895. m.appendaction_label_del = nil
  16896. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  16897. }
  16898. // Where appends a list predicates to the LabelTaggingMutation builder.
  16899. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  16900. m.predicates = append(m.predicates, ps...)
  16901. }
  16902. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  16903. // users can use type-assertion to append predicates that do not depend on any generated package.
  16904. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  16905. p := make([]predicate.LabelTagging, len(ps))
  16906. for i := range ps {
  16907. p[i] = ps[i]
  16908. }
  16909. m.Where(p...)
  16910. }
  16911. // Op returns the operation name.
  16912. func (m *LabelTaggingMutation) Op() Op {
  16913. return m.op
  16914. }
  16915. // SetOp allows setting the mutation operation.
  16916. func (m *LabelTaggingMutation) SetOp(op Op) {
  16917. m.op = op
  16918. }
  16919. // Type returns the node type of this mutation (LabelTagging).
  16920. func (m *LabelTaggingMutation) Type() string {
  16921. return m.typ
  16922. }
  16923. // Fields returns all fields that were changed during this mutation. Note that in
  16924. // order to get all numeric fields that were incremented/decremented, call
  16925. // AddedFields().
  16926. func (m *LabelTaggingMutation) Fields() []string {
  16927. fields := make([]string, 0, 9)
  16928. if m.created_at != nil {
  16929. fields = append(fields, labeltagging.FieldCreatedAt)
  16930. }
  16931. if m.updated_at != nil {
  16932. fields = append(fields, labeltagging.FieldUpdatedAt)
  16933. }
  16934. if m.status != nil {
  16935. fields = append(fields, labeltagging.FieldStatus)
  16936. }
  16937. if m.deleted_at != nil {
  16938. fields = append(fields, labeltagging.FieldDeletedAt)
  16939. }
  16940. if m.organization_id != nil {
  16941. fields = append(fields, labeltagging.FieldOrganizationID)
  16942. }
  16943. if m._type != nil {
  16944. fields = append(fields, labeltagging.FieldType)
  16945. }
  16946. if m.conditions != nil {
  16947. fields = append(fields, labeltagging.FieldConditions)
  16948. }
  16949. if m.action_label_add != nil {
  16950. fields = append(fields, labeltagging.FieldActionLabelAdd)
  16951. }
  16952. if m.action_label_del != nil {
  16953. fields = append(fields, labeltagging.FieldActionLabelDel)
  16954. }
  16955. return fields
  16956. }
  16957. // Field returns the value of a field with the given name. The second boolean
  16958. // return value indicates that this field was not set, or was not defined in the
  16959. // schema.
  16960. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  16961. switch name {
  16962. case labeltagging.FieldCreatedAt:
  16963. return m.CreatedAt()
  16964. case labeltagging.FieldUpdatedAt:
  16965. return m.UpdatedAt()
  16966. case labeltagging.FieldStatus:
  16967. return m.Status()
  16968. case labeltagging.FieldDeletedAt:
  16969. return m.DeletedAt()
  16970. case labeltagging.FieldOrganizationID:
  16971. return m.OrganizationID()
  16972. case labeltagging.FieldType:
  16973. return m.GetType()
  16974. case labeltagging.FieldConditions:
  16975. return m.Conditions()
  16976. case labeltagging.FieldActionLabelAdd:
  16977. return m.ActionLabelAdd()
  16978. case labeltagging.FieldActionLabelDel:
  16979. return m.ActionLabelDel()
  16980. }
  16981. return nil, false
  16982. }
  16983. // OldField returns the old value of the field from the database. An error is
  16984. // returned if the mutation operation is not UpdateOne, or the query to the
  16985. // database failed.
  16986. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16987. switch name {
  16988. case labeltagging.FieldCreatedAt:
  16989. return m.OldCreatedAt(ctx)
  16990. case labeltagging.FieldUpdatedAt:
  16991. return m.OldUpdatedAt(ctx)
  16992. case labeltagging.FieldStatus:
  16993. return m.OldStatus(ctx)
  16994. case labeltagging.FieldDeletedAt:
  16995. return m.OldDeletedAt(ctx)
  16996. case labeltagging.FieldOrganizationID:
  16997. return m.OldOrganizationID(ctx)
  16998. case labeltagging.FieldType:
  16999. return m.OldType(ctx)
  17000. case labeltagging.FieldConditions:
  17001. return m.OldConditions(ctx)
  17002. case labeltagging.FieldActionLabelAdd:
  17003. return m.OldActionLabelAdd(ctx)
  17004. case labeltagging.FieldActionLabelDel:
  17005. return m.OldActionLabelDel(ctx)
  17006. }
  17007. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  17008. }
  17009. // SetField sets the value of a field with the given name. It returns an error if
  17010. // the field is not defined in the schema, or if the type mismatched the field
  17011. // type.
  17012. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  17013. switch name {
  17014. case labeltagging.FieldCreatedAt:
  17015. v, ok := value.(time.Time)
  17016. if !ok {
  17017. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17018. }
  17019. m.SetCreatedAt(v)
  17020. return nil
  17021. case labeltagging.FieldUpdatedAt:
  17022. v, ok := value.(time.Time)
  17023. if !ok {
  17024. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17025. }
  17026. m.SetUpdatedAt(v)
  17027. return nil
  17028. case labeltagging.FieldStatus:
  17029. v, ok := value.(uint8)
  17030. if !ok {
  17031. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17032. }
  17033. m.SetStatus(v)
  17034. return nil
  17035. case labeltagging.FieldDeletedAt:
  17036. v, ok := value.(time.Time)
  17037. if !ok {
  17038. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17039. }
  17040. m.SetDeletedAt(v)
  17041. return nil
  17042. case labeltagging.FieldOrganizationID:
  17043. v, ok := value.(uint64)
  17044. if !ok {
  17045. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17046. }
  17047. m.SetOrganizationID(v)
  17048. return nil
  17049. case labeltagging.FieldType:
  17050. v, ok := value.(int)
  17051. if !ok {
  17052. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17053. }
  17054. m.SetType(v)
  17055. return nil
  17056. case labeltagging.FieldConditions:
  17057. v, ok := value.(string)
  17058. if !ok {
  17059. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17060. }
  17061. m.SetConditions(v)
  17062. return nil
  17063. case labeltagging.FieldActionLabelAdd:
  17064. v, ok := value.([]uint64)
  17065. if !ok {
  17066. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17067. }
  17068. m.SetActionLabelAdd(v)
  17069. return nil
  17070. case labeltagging.FieldActionLabelDel:
  17071. v, ok := value.([]uint64)
  17072. if !ok {
  17073. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17074. }
  17075. m.SetActionLabelDel(v)
  17076. return nil
  17077. }
  17078. return fmt.Errorf("unknown LabelTagging field %s", name)
  17079. }
  17080. // AddedFields returns all numeric fields that were incremented/decremented during
  17081. // this mutation.
  17082. func (m *LabelTaggingMutation) AddedFields() []string {
  17083. var fields []string
  17084. if m.addstatus != nil {
  17085. fields = append(fields, labeltagging.FieldStatus)
  17086. }
  17087. if m.addorganization_id != nil {
  17088. fields = append(fields, labeltagging.FieldOrganizationID)
  17089. }
  17090. if m.add_type != nil {
  17091. fields = append(fields, labeltagging.FieldType)
  17092. }
  17093. return fields
  17094. }
  17095. // AddedField returns the numeric value that was incremented/decremented on a field
  17096. // with the given name. The second boolean return value indicates that this field
  17097. // was not set, or was not defined in the schema.
  17098. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  17099. switch name {
  17100. case labeltagging.FieldStatus:
  17101. return m.AddedStatus()
  17102. case labeltagging.FieldOrganizationID:
  17103. return m.AddedOrganizationID()
  17104. case labeltagging.FieldType:
  17105. return m.AddedType()
  17106. }
  17107. return nil, false
  17108. }
  17109. // AddField adds the value to the field with the given name. It returns an error if
  17110. // the field is not defined in the schema, or if the type mismatched the field
  17111. // type.
  17112. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  17113. switch name {
  17114. case labeltagging.FieldStatus:
  17115. v, ok := value.(int8)
  17116. if !ok {
  17117. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17118. }
  17119. m.AddStatus(v)
  17120. return nil
  17121. case labeltagging.FieldOrganizationID:
  17122. v, ok := value.(int64)
  17123. if !ok {
  17124. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17125. }
  17126. m.AddOrganizationID(v)
  17127. return nil
  17128. case labeltagging.FieldType:
  17129. v, ok := value.(int)
  17130. if !ok {
  17131. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17132. }
  17133. m.AddType(v)
  17134. return nil
  17135. }
  17136. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  17137. }
  17138. // ClearedFields returns all nullable fields that were cleared during this
  17139. // mutation.
  17140. func (m *LabelTaggingMutation) ClearedFields() []string {
  17141. var fields []string
  17142. if m.FieldCleared(labeltagging.FieldStatus) {
  17143. fields = append(fields, labeltagging.FieldStatus)
  17144. }
  17145. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  17146. fields = append(fields, labeltagging.FieldDeletedAt)
  17147. }
  17148. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  17149. fields = append(fields, labeltagging.FieldActionLabelAdd)
  17150. }
  17151. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  17152. fields = append(fields, labeltagging.FieldActionLabelDel)
  17153. }
  17154. return fields
  17155. }
  17156. // FieldCleared returns a boolean indicating if a field with the given name was
  17157. // cleared in this mutation.
  17158. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  17159. _, ok := m.clearedFields[name]
  17160. return ok
  17161. }
  17162. // ClearField clears the value of the field with the given name. It returns an
  17163. // error if the field is not defined in the schema.
  17164. func (m *LabelTaggingMutation) ClearField(name string) error {
  17165. switch name {
  17166. case labeltagging.FieldStatus:
  17167. m.ClearStatus()
  17168. return nil
  17169. case labeltagging.FieldDeletedAt:
  17170. m.ClearDeletedAt()
  17171. return nil
  17172. case labeltagging.FieldActionLabelAdd:
  17173. m.ClearActionLabelAdd()
  17174. return nil
  17175. case labeltagging.FieldActionLabelDel:
  17176. m.ClearActionLabelDel()
  17177. return nil
  17178. }
  17179. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  17180. }
  17181. // ResetField resets all changes in the mutation for the field with the given name.
  17182. // It returns an error if the field is not defined in the schema.
  17183. func (m *LabelTaggingMutation) ResetField(name string) error {
  17184. switch name {
  17185. case labeltagging.FieldCreatedAt:
  17186. m.ResetCreatedAt()
  17187. return nil
  17188. case labeltagging.FieldUpdatedAt:
  17189. m.ResetUpdatedAt()
  17190. return nil
  17191. case labeltagging.FieldStatus:
  17192. m.ResetStatus()
  17193. return nil
  17194. case labeltagging.FieldDeletedAt:
  17195. m.ResetDeletedAt()
  17196. return nil
  17197. case labeltagging.FieldOrganizationID:
  17198. m.ResetOrganizationID()
  17199. return nil
  17200. case labeltagging.FieldType:
  17201. m.ResetType()
  17202. return nil
  17203. case labeltagging.FieldConditions:
  17204. m.ResetConditions()
  17205. return nil
  17206. case labeltagging.FieldActionLabelAdd:
  17207. m.ResetActionLabelAdd()
  17208. return nil
  17209. case labeltagging.FieldActionLabelDel:
  17210. m.ResetActionLabelDel()
  17211. return nil
  17212. }
  17213. return fmt.Errorf("unknown LabelTagging field %s", name)
  17214. }
  17215. // AddedEdges returns all edge names that were set/added in this mutation.
  17216. func (m *LabelTaggingMutation) AddedEdges() []string {
  17217. edges := make([]string, 0, 0)
  17218. return edges
  17219. }
  17220. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17221. // name in this mutation.
  17222. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  17223. return nil
  17224. }
  17225. // RemovedEdges returns all edge names that were removed in this mutation.
  17226. func (m *LabelTaggingMutation) RemovedEdges() []string {
  17227. edges := make([]string, 0, 0)
  17228. return edges
  17229. }
  17230. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17231. // the given name in this mutation.
  17232. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  17233. return nil
  17234. }
  17235. // ClearedEdges returns all edge names that were cleared in this mutation.
  17236. func (m *LabelTaggingMutation) ClearedEdges() []string {
  17237. edges := make([]string, 0, 0)
  17238. return edges
  17239. }
  17240. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17241. // was cleared in this mutation.
  17242. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  17243. return false
  17244. }
  17245. // ClearEdge clears the value of the edge with the given name. It returns an error
  17246. // if that edge is not defined in the schema.
  17247. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  17248. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  17249. }
  17250. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17251. // It returns an error if the edge is not defined in the schema.
  17252. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  17253. return fmt.Errorf("unknown LabelTagging edge %s", name)
  17254. }
  17255. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  17256. type MessageMutation struct {
  17257. config
  17258. op Op
  17259. typ string
  17260. id *int
  17261. wx_wxid *string
  17262. wxid *string
  17263. content *string
  17264. clearedFields map[string]struct{}
  17265. done bool
  17266. oldValue func(context.Context) (*Message, error)
  17267. predicates []predicate.Message
  17268. }
  17269. var _ ent.Mutation = (*MessageMutation)(nil)
  17270. // messageOption allows management of the mutation configuration using functional options.
  17271. type messageOption func(*MessageMutation)
  17272. // newMessageMutation creates new mutation for the Message entity.
  17273. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  17274. m := &MessageMutation{
  17275. config: c,
  17276. op: op,
  17277. typ: TypeMessage,
  17278. clearedFields: make(map[string]struct{}),
  17279. }
  17280. for _, opt := range opts {
  17281. opt(m)
  17282. }
  17283. return m
  17284. }
  17285. // withMessageID sets the ID field of the mutation.
  17286. func withMessageID(id int) messageOption {
  17287. return func(m *MessageMutation) {
  17288. var (
  17289. err error
  17290. once sync.Once
  17291. value *Message
  17292. )
  17293. m.oldValue = func(ctx context.Context) (*Message, error) {
  17294. once.Do(func() {
  17295. if m.done {
  17296. err = errors.New("querying old values post mutation is not allowed")
  17297. } else {
  17298. value, err = m.Client().Message.Get(ctx, id)
  17299. }
  17300. })
  17301. return value, err
  17302. }
  17303. m.id = &id
  17304. }
  17305. }
  17306. // withMessage sets the old Message of the mutation.
  17307. func withMessage(node *Message) messageOption {
  17308. return func(m *MessageMutation) {
  17309. m.oldValue = func(context.Context) (*Message, error) {
  17310. return node, nil
  17311. }
  17312. m.id = &node.ID
  17313. }
  17314. }
  17315. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17316. // executed in a transaction (ent.Tx), a transactional client is returned.
  17317. func (m MessageMutation) Client() *Client {
  17318. client := &Client{config: m.config}
  17319. client.init()
  17320. return client
  17321. }
  17322. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17323. // it returns an error otherwise.
  17324. func (m MessageMutation) Tx() (*Tx, error) {
  17325. if _, ok := m.driver.(*txDriver); !ok {
  17326. return nil, errors.New("ent: mutation is not running in a transaction")
  17327. }
  17328. tx := &Tx{config: m.config}
  17329. tx.init()
  17330. return tx, nil
  17331. }
  17332. // ID returns the ID value in the mutation. Note that the ID is only available
  17333. // if it was provided to the builder or after it was returned from the database.
  17334. func (m *MessageMutation) ID() (id int, exists bool) {
  17335. if m.id == nil {
  17336. return
  17337. }
  17338. return *m.id, true
  17339. }
  17340. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17341. // That means, if the mutation is applied within a transaction with an isolation level such
  17342. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17343. // or updated by the mutation.
  17344. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  17345. switch {
  17346. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17347. id, exists := m.ID()
  17348. if exists {
  17349. return []int{id}, nil
  17350. }
  17351. fallthrough
  17352. case m.op.Is(OpUpdate | OpDelete):
  17353. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  17354. default:
  17355. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17356. }
  17357. }
  17358. // SetWxWxid sets the "wx_wxid" field.
  17359. func (m *MessageMutation) SetWxWxid(s string) {
  17360. m.wx_wxid = &s
  17361. }
  17362. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  17363. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  17364. v := m.wx_wxid
  17365. if v == nil {
  17366. return
  17367. }
  17368. return *v, true
  17369. }
  17370. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  17371. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  17372. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17373. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  17374. if !m.op.Is(OpUpdateOne) {
  17375. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  17376. }
  17377. if m.id == nil || m.oldValue == nil {
  17378. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  17379. }
  17380. oldValue, err := m.oldValue(ctx)
  17381. if err != nil {
  17382. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  17383. }
  17384. return oldValue.WxWxid, nil
  17385. }
  17386. // ClearWxWxid clears the value of the "wx_wxid" field.
  17387. func (m *MessageMutation) ClearWxWxid() {
  17388. m.wx_wxid = nil
  17389. m.clearedFields[message.FieldWxWxid] = struct{}{}
  17390. }
  17391. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  17392. func (m *MessageMutation) WxWxidCleared() bool {
  17393. _, ok := m.clearedFields[message.FieldWxWxid]
  17394. return ok
  17395. }
  17396. // ResetWxWxid resets all changes to the "wx_wxid" field.
  17397. func (m *MessageMutation) ResetWxWxid() {
  17398. m.wx_wxid = nil
  17399. delete(m.clearedFields, message.FieldWxWxid)
  17400. }
  17401. // SetWxid sets the "wxid" field.
  17402. func (m *MessageMutation) SetWxid(s string) {
  17403. m.wxid = &s
  17404. }
  17405. // Wxid returns the value of the "wxid" field in the mutation.
  17406. func (m *MessageMutation) Wxid() (r string, exists bool) {
  17407. v := m.wxid
  17408. if v == nil {
  17409. return
  17410. }
  17411. return *v, true
  17412. }
  17413. // OldWxid returns the old "wxid" field's value of the Message entity.
  17414. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  17415. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17416. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  17417. if !m.op.Is(OpUpdateOne) {
  17418. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  17419. }
  17420. if m.id == nil || m.oldValue == nil {
  17421. return v, errors.New("OldWxid requires an ID field in the mutation")
  17422. }
  17423. oldValue, err := m.oldValue(ctx)
  17424. if err != nil {
  17425. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  17426. }
  17427. return oldValue.Wxid, nil
  17428. }
  17429. // ResetWxid resets all changes to the "wxid" field.
  17430. func (m *MessageMutation) ResetWxid() {
  17431. m.wxid = nil
  17432. }
  17433. // SetContent sets the "content" field.
  17434. func (m *MessageMutation) SetContent(s string) {
  17435. m.content = &s
  17436. }
  17437. // Content returns the value of the "content" field in the mutation.
  17438. func (m *MessageMutation) Content() (r string, exists bool) {
  17439. v := m.content
  17440. if v == nil {
  17441. return
  17442. }
  17443. return *v, true
  17444. }
  17445. // OldContent returns the old "content" field's value of the Message entity.
  17446. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  17447. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17448. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  17449. if !m.op.Is(OpUpdateOne) {
  17450. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  17451. }
  17452. if m.id == nil || m.oldValue == nil {
  17453. return v, errors.New("OldContent requires an ID field in the mutation")
  17454. }
  17455. oldValue, err := m.oldValue(ctx)
  17456. if err != nil {
  17457. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  17458. }
  17459. return oldValue.Content, nil
  17460. }
  17461. // ResetContent resets all changes to the "content" field.
  17462. func (m *MessageMutation) ResetContent() {
  17463. m.content = nil
  17464. }
  17465. // Where appends a list predicates to the MessageMutation builder.
  17466. func (m *MessageMutation) Where(ps ...predicate.Message) {
  17467. m.predicates = append(m.predicates, ps...)
  17468. }
  17469. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  17470. // users can use type-assertion to append predicates that do not depend on any generated package.
  17471. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  17472. p := make([]predicate.Message, len(ps))
  17473. for i := range ps {
  17474. p[i] = ps[i]
  17475. }
  17476. m.Where(p...)
  17477. }
  17478. // Op returns the operation name.
  17479. func (m *MessageMutation) Op() Op {
  17480. return m.op
  17481. }
  17482. // SetOp allows setting the mutation operation.
  17483. func (m *MessageMutation) SetOp(op Op) {
  17484. m.op = op
  17485. }
  17486. // Type returns the node type of this mutation (Message).
  17487. func (m *MessageMutation) Type() string {
  17488. return m.typ
  17489. }
  17490. // Fields returns all fields that were changed during this mutation. Note that in
  17491. // order to get all numeric fields that were incremented/decremented, call
  17492. // AddedFields().
  17493. func (m *MessageMutation) Fields() []string {
  17494. fields := make([]string, 0, 3)
  17495. if m.wx_wxid != nil {
  17496. fields = append(fields, message.FieldWxWxid)
  17497. }
  17498. if m.wxid != nil {
  17499. fields = append(fields, message.FieldWxid)
  17500. }
  17501. if m.content != nil {
  17502. fields = append(fields, message.FieldContent)
  17503. }
  17504. return fields
  17505. }
  17506. // Field returns the value of a field with the given name. The second boolean
  17507. // return value indicates that this field was not set, or was not defined in the
  17508. // schema.
  17509. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  17510. switch name {
  17511. case message.FieldWxWxid:
  17512. return m.WxWxid()
  17513. case message.FieldWxid:
  17514. return m.Wxid()
  17515. case message.FieldContent:
  17516. return m.Content()
  17517. }
  17518. return nil, false
  17519. }
  17520. // OldField returns the old value of the field from the database. An error is
  17521. // returned if the mutation operation is not UpdateOne, or the query to the
  17522. // database failed.
  17523. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17524. switch name {
  17525. case message.FieldWxWxid:
  17526. return m.OldWxWxid(ctx)
  17527. case message.FieldWxid:
  17528. return m.OldWxid(ctx)
  17529. case message.FieldContent:
  17530. return m.OldContent(ctx)
  17531. }
  17532. return nil, fmt.Errorf("unknown Message field %s", name)
  17533. }
  17534. // SetField sets the value of a field with the given name. It returns an error if
  17535. // the field is not defined in the schema, or if the type mismatched the field
  17536. // type.
  17537. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  17538. switch name {
  17539. case message.FieldWxWxid:
  17540. v, ok := value.(string)
  17541. if !ok {
  17542. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17543. }
  17544. m.SetWxWxid(v)
  17545. return nil
  17546. case message.FieldWxid:
  17547. v, ok := value.(string)
  17548. if !ok {
  17549. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17550. }
  17551. m.SetWxid(v)
  17552. return nil
  17553. case message.FieldContent:
  17554. v, ok := value.(string)
  17555. if !ok {
  17556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17557. }
  17558. m.SetContent(v)
  17559. return nil
  17560. }
  17561. return fmt.Errorf("unknown Message field %s", name)
  17562. }
  17563. // AddedFields returns all numeric fields that were incremented/decremented during
  17564. // this mutation.
  17565. func (m *MessageMutation) AddedFields() []string {
  17566. return nil
  17567. }
  17568. // AddedField returns the numeric value that was incremented/decremented on a field
  17569. // with the given name. The second boolean return value indicates that this field
  17570. // was not set, or was not defined in the schema.
  17571. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  17572. return nil, false
  17573. }
  17574. // AddField adds the value to the field with the given name. It returns an error if
  17575. // the field is not defined in the schema, or if the type mismatched the field
  17576. // type.
  17577. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  17578. switch name {
  17579. }
  17580. return fmt.Errorf("unknown Message numeric field %s", name)
  17581. }
  17582. // ClearedFields returns all nullable fields that were cleared during this
  17583. // mutation.
  17584. func (m *MessageMutation) ClearedFields() []string {
  17585. var fields []string
  17586. if m.FieldCleared(message.FieldWxWxid) {
  17587. fields = append(fields, message.FieldWxWxid)
  17588. }
  17589. return fields
  17590. }
  17591. // FieldCleared returns a boolean indicating if a field with the given name was
  17592. // cleared in this mutation.
  17593. func (m *MessageMutation) FieldCleared(name string) bool {
  17594. _, ok := m.clearedFields[name]
  17595. return ok
  17596. }
  17597. // ClearField clears the value of the field with the given name. It returns an
  17598. // error if the field is not defined in the schema.
  17599. func (m *MessageMutation) ClearField(name string) error {
  17600. switch name {
  17601. case message.FieldWxWxid:
  17602. m.ClearWxWxid()
  17603. return nil
  17604. }
  17605. return fmt.Errorf("unknown Message nullable field %s", name)
  17606. }
  17607. // ResetField resets all changes in the mutation for the field with the given name.
  17608. // It returns an error if the field is not defined in the schema.
  17609. func (m *MessageMutation) ResetField(name string) error {
  17610. switch name {
  17611. case message.FieldWxWxid:
  17612. m.ResetWxWxid()
  17613. return nil
  17614. case message.FieldWxid:
  17615. m.ResetWxid()
  17616. return nil
  17617. case message.FieldContent:
  17618. m.ResetContent()
  17619. return nil
  17620. }
  17621. return fmt.Errorf("unknown Message field %s", name)
  17622. }
  17623. // AddedEdges returns all edge names that were set/added in this mutation.
  17624. func (m *MessageMutation) AddedEdges() []string {
  17625. edges := make([]string, 0, 0)
  17626. return edges
  17627. }
  17628. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17629. // name in this mutation.
  17630. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  17631. return nil
  17632. }
  17633. // RemovedEdges returns all edge names that were removed in this mutation.
  17634. func (m *MessageMutation) RemovedEdges() []string {
  17635. edges := make([]string, 0, 0)
  17636. return edges
  17637. }
  17638. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17639. // the given name in this mutation.
  17640. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  17641. return nil
  17642. }
  17643. // ClearedEdges returns all edge names that were cleared in this mutation.
  17644. func (m *MessageMutation) ClearedEdges() []string {
  17645. edges := make([]string, 0, 0)
  17646. return edges
  17647. }
  17648. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17649. // was cleared in this mutation.
  17650. func (m *MessageMutation) EdgeCleared(name string) bool {
  17651. return false
  17652. }
  17653. // ClearEdge clears the value of the edge with the given name. It returns an error
  17654. // if that edge is not defined in the schema.
  17655. func (m *MessageMutation) ClearEdge(name string) error {
  17656. return fmt.Errorf("unknown Message unique edge %s", name)
  17657. }
  17658. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17659. // It returns an error if the edge is not defined in the schema.
  17660. func (m *MessageMutation) ResetEdge(name string) error {
  17661. return fmt.Errorf("unknown Message edge %s", name)
  17662. }
  17663. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  17664. type MessageRecordsMutation struct {
  17665. config
  17666. op Op
  17667. typ string
  17668. id *uint64
  17669. created_at *time.Time
  17670. updated_at *time.Time
  17671. status *uint8
  17672. addstatus *int8
  17673. bot_wxid *string
  17674. contact_type *int
  17675. addcontact_type *int
  17676. contact_wxid *string
  17677. content_type *int
  17678. addcontent_type *int
  17679. content *string
  17680. meta *custom_types.Meta
  17681. error_detail *string
  17682. send_time *time.Time
  17683. source_type *int
  17684. addsource_type *int
  17685. organization_id *uint64
  17686. addorganization_id *int64
  17687. clearedFields map[string]struct{}
  17688. sop_stage *uint64
  17689. clearedsop_stage bool
  17690. sop_node *uint64
  17691. clearedsop_node bool
  17692. message_contact *uint64
  17693. clearedmessage_contact bool
  17694. done bool
  17695. oldValue func(context.Context) (*MessageRecords, error)
  17696. predicates []predicate.MessageRecords
  17697. }
  17698. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  17699. // messagerecordsOption allows management of the mutation configuration using functional options.
  17700. type messagerecordsOption func(*MessageRecordsMutation)
  17701. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  17702. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  17703. m := &MessageRecordsMutation{
  17704. config: c,
  17705. op: op,
  17706. typ: TypeMessageRecords,
  17707. clearedFields: make(map[string]struct{}),
  17708. }
  17709. for _, opt := range opts {
  17710. opt(m)
  17711. }
  17712. return m
  17713. }
  17714. // withMessageRecordsID sets the ID field of the mutation.
  17715. func withMessageRecordsID(id uint64) messagerecordsOption {
  17716. return func(m *MessageRecordsMutation) {
  17717. var (
  17718. err error
  17719. once sync.Once
  17720. value *MessageRecords
  17721. )
  17722. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  17723. once.Do(func() {
  17724. if m.done {
  17725. err = errors.New("querying old values post mutation is not allowed")
  17726. } else {
  17727. value, err = m.Client().MessageRecords.Get(ctx, id)
  17728. }
  17729. })
  17730. return value, err
  17731. }
  17732. m.id = &id
  17733. }
  17734. }
  17735. // withMessageRecords sets the old MessageRecords of the mutation.
  17736. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  17737. return func(m *MessageRecordsMutation) {
  17738. m.oldValue = func(context.Context) (*MessageRecords, error) {
  17739. return node, nil
  17740. }
  17741. m.id = &node.ID
  17742. }
  17743. }
  17744. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17745. // executed in a transaction (ent.Tx), a transactional client is returned.
  17746. func (m MessageRecordsMutation) Client() *Client {
  17747. client := &Client{config: m.config}
  17748. client.init()
  17749. return client
  17750. }
  17751. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17752. // it returns an error otherwise.
  17753. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  17754. if _, ok := m.driver.(*txDriver); !ok {
  17755. return nil, errors.New("ent: mutation is not running in a transaction")
  17756. }
  17757. tx := &Tx{config: m.config}
  17758. tx.init()
  17759. return tx, nil
  17760. }
  17761. // SetID sets the value of the id field. Note that this
  17762. // operation is only accepted on creation of MessageRecords entities.
  17763. func (m *MessageRecordsMutation) SetID(id uint64) {
  17764. m.id = &id
  17765. }
  17766. // ID returns the ID value in the mutation. Note that the ID is only available
  17767. // if it was provided to the builder or after it was returned from the database.
  17768. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  17769. if m.id == nil {
  17770. return
  17771. }
  17772. return *m.id, true
  17773. }
  17774. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17775. // That means, if the mutation is applied within a transaction with an isolation level such
  17776. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17777. // or updated by the mutation.
  17778. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  17779. switch {
  17780. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17781. id, exists := m.ID()
  17782. if exists {
  17783. return []uint64{id}, nil
  17784. }
  17785. fallthrough
  17786. case m.op.Is(OpUpdate | OpDelete):
  17787. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  17788. default:
  17789. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17790. }
  17791. }
  17792. // SetCreatedAt sets the "created_at" field.
  17793. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  17794. m.created_at = &t
  17795. }
  17796. // CreatedAt returns the value of the "created_at" field in the mutation.
  17797. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  17798. v := m.created_at
  17799. if v == nil {
  17800. return
  17801. }
  17802. return *v, true
  17803. }
  17804. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  17805. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17807. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17808. if !m.op.Is(OpUpdateOne) {
  17809. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17810. }
  17811. if m.id == nil || m.oldValue == nil {
  17812. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17813. }
  17814. oldValue, err := m.oldValue(ctx)
  17815. if err != nil {
  17816. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17817. }
  17818. return oldValue.CreatedAt, nil
  17819. }
  17820. // ResetCreatedAt resets all changes to the "created_at" field.
  17821. func (m *MessageRecordsMutation) ResetCreatedAt() {
  17822. m.created_at = nil
  17823. }
  17824. // SetUpdatedAt sets the "updated_at" field.
  17825. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  17826. m.updated_at = &t
  17827. }
  17828. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17829. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  17830. v := m.updated_at
  17831. if v == nil {
  17832. return
  17833. }
  17834. return *v, true
  17835. }
  17836. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  17837. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17838. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17839. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17840. if !m.op.Is(OpUpdateOne) {
  17841. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17842. }
  17843. if m.id == nil || m.oldValue == nil {
  17844. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17845. }
  17846. oldValue, err := m.oldValue(ctx)
  17847. if err != nil {
  17848. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17849. }
  17850. return oldValue.UpdatedAt, nil
  17851. }
  17852. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17853. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  17854. m.updated_at = nil
  17855. }
  17856. // SetStatus sets the "status" field.
  17857. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  17858. m.status = &u
  17859. m.addstatus = nil
  17860. }
  17861. // Status returns the value of the "status" field in the mutation.
  17862. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  17863. v := m.status
  17864. if v == nil {
  17865. return
  17866. }
  17867. return *v, true
  17868. }
  17869. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  17870. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17871. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17872. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  17873. if !m.op.Is(OpUpdateOne) {
  17874. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  17875. }
  17876. if m.id == nil || m.oldValue == nil {
  17877. return v, errors.New("OldStatus requires an ID field in the mutation")
  17878. }
  17879. oldValue, err := m.oldValue(ctx)
  17880. if err != nil {
  17881. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  17882. }
  17883. return oldValue.Status, nil
  17884. }
  17885. // AddStatus adds u to the "status" field.
  17886. func (m *MessageRecordsMutation) AddStatus(u int8) {
  17887. if m.addstatus != nil {
  17888. *m.addstatus += u
  17889. } else {
  17890. m.addstatus = &u
  17891. }
  17892. }
  17893. // AddedStatus returns the value that was added to the "status" field in this mutation.
  17894. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  17895. v := m.addstatus
  17896. if v == nil {
  17897. return
  17898. }
  17899. return *v, true
  17900. }
  17901. // ClearStatus clears the value of the "status" field.
  17902. func (m *MessageRecordsMutation) ClearStatus() {
  17903. m.status = nil
  17904. m.addstatus = nil
  17905. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  17906. }
  17907. // StatusCleared returns if the "status" field was cleared in this mutation.
  17908. func (m *MessageRecordsMutation) StatusCleared() bool {
  17909. _, ok := m.clearedFields[messagerecords.FieldStatus]
  17910. return ok
  17911. }
  17912. // ResetStatus resets all changes to the "status" field.
  17913. func (m *MessageRecordsMutation) ResetStatus() {
  17914. m.status = nil
  17915. m.addstatus = nil
  17916. delete(m.clearedFields, messagerecords.FieldStatus)
  17917. }
  17918. // SetBotWxid sets the "bot_wxid" field.
  17919. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  17920. m.bot_wxid = &s
  17921. }
  17922. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  17923. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  17924. v := m.bot_wxid
  17925. if v == nil {
  17926. return
  17927. }
  17928. return *v, true
  17929. }
  17930. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  17931. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17932. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17933. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  17934. if !m.op.Is(OpUpdateOne) {
  17935. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  17936. }
  17937. if m.id == nil || m.oldValue == nil {
  17938. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  17939. }
  17940. oldValue, err := m.oldValue(ctx)
  17941. if err != nil {
  17942. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  17943. }
  17944. return oldValue.BotWxid, nil
  17945. }
  17946. // ResetBotWxid resets all changes to the "bot_wxid" field.
  17947. func (m *MessageRecordsMutation) ResetBotWxid() {
  17948. m.bot_wxid = nil
  17949. }
  17950. // SetContactID sets the "contact_id" field.
  17951. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  17952. m.message_contact = &u
  17953. }
  17954. // ContactID returns the value of the "contact_id" field in the mutation.
  17955. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  17956. v := m.message_contact
  17957. if v == nil {
  17958. return
  17959. }
  17960. return *v, true
  17961. }
  17962. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  17963. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17964. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17965. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  17966. if !m.op.Is(OpUpdateOne) {
  17967. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  17968. }
  17969. if m.id == nil || m.oldValue == nil {
  17970. return v, errors.New("OldContactID requires an ID field in the mutation")
  17971. }
  17972. oldValue, err := m.oldValue(ctx)
  17973. if err != nil {
  17974. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  17975. }
  17976. return oldValue.ContactID, nil
  17977. }
  17978. // ClearContactID clears the value of the "contact_id" field.
  17979. func (m *MessageRecordsMutation) ClearContactID() {
  17980. m.message_contact = nil
  17981. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  17982. }
  17983. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  17984. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  17985. _, ok := m.clearedFields[messagerecords.FieldContactID]
  17986. return ok
  17987. }
  17988. // ResetContactID resets all changes to the "contact_id" field.
  17989. func (m *MessageRecordsMutation) ResetContactID() {
  17990. m.message_contact = nil
  17991. delete(m.clearedFields, messagerecords.FieldContactID)
  17992. }
  17993. // SetContactType sets the "contact_type" field.
  17994. func (m *MessageRecordsMutation) SetContactType(i int) {
  17995. m.contact_type = &i
  17996. m.addcontact_type = nil
  17997. }
  17998. // ContactType returns the value of the "contact_type" field in the mutation.
  17999. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  18000. v := m.contact_type
  18001. if v == nil {
  18002. return
  18003. }
  18004. return *v, true
  18005. }
  18006. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  18007. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18008. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18009. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  18010. if !m.op.Is(OpUpdateOne) {
  18011. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  18012. }
  18013. if m.id == nil || m.oldValue == nil {
  18014. return v, errors.New("OldContactType requires an ID field in the mutation")
  18015. }
  18016. oldValue, err := m.oldValue(ctx)
  18017. if err != nil {
  18018. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  18019. }
  18020. return oldValue.ContactType, nil
  18021. }
  18022. // AddContactType adds i to the "contact_type" field.
  18023. func (m *MessageRecordsMutation) AddContactType(i int) {
  18024. if m.addcontact_type != nil {
  18025. *m.addcontact_type += i
  18026. } else {
  18027. m.addcontact_type = &i
  18028. }
  18029. }
  18030. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  18031. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  18032. v := m.addcontact_type
  18033. if v == nil {
  18034. return
  18035. }
  18036. return *v, true
  18037. }
  18038. // ResetContactType resets all changes to the "contact_type" field.
  18039. func (m *MessageRecordsMutation) ResetContactType() {
  18040. m.contact_type = nil
  18041. m.addcontact_type = nil
  18042. }
  18043. // SetContactWxid sets the "contact_wxid" field.
  18044. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  18045. m.contact_wxid = &s
  18046. }
  18047. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  18048. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  18049. v := m.contact_wxid
  18050. if v == nil {
  18051. return
  18052. }
  18053. return *v, true
  18054. }
  18055. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  18056. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18057. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18058. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  18059. if !m.op.Is(OpUpdateOne) {
  18060. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  18061. }
  18062. if m.id == nil || m.oldValue == nil {
  18063. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  18064. }
  18065. oldValue, err := m.oldValue(ctx)
  18066. if err != nil {
  18067. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  18068. }
  18069. return oldValue.ContactWxid, nil
  18070. }
  18071. // ResetContactWxid resets all changes to the "contact_wxid" field.
  18072. func (m *MessageRecordsMutation) ResetContactWxid() {
  18073. m.contact_wxid = nil
  18074. }
  18075. // SetContentType sets the "content_type" field.
  18076. func (m *MessageRecordsMutation) SetContentType(i int) {
  18077. m.content_type = &i
  18078. m.addcontent_type = nil
  18079. }
  18080. // ContentType returns the value of the "content_type" field in the mutation.
  18081. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  18082. v := m.content_type
  18083. if v == nil {
  18084. return
  18085. }
  18086. return *v, true
  18087. }
  18088. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  18089. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18090. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18091. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  18092. if !m.op.Is(OpUpdateOne) {
  18093. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  18094. }
  18095. if m.id == nil || m.oldValue == nil {
  18096. return v, errors.New("OldContentType requires an ID field in the mutation")
  18097. }
  18098. oldValue, err := m.oldValue(ctx)
  18099. if err != nil {
  18100. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  18101. }
  18102. return oldValue.ContentType, nil
  18103. }
  18104. // AddContentType adds i to the "content_type" field.
  18105. func (m *MessageRecordsMutation) AddContentType(i int) {
  18106. if m.addcontent_type != nil {
  18107. *m.addcontent_type += i
  18108. } else {
  18109. m.addcontent_type = &i
  18110. }
  18111. }
  18112. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  18113. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  18114. v := m.addcontent_type
  18115. if v == nil {
  18116. return
  18117. }
  18118. return *v, true
  18119. }
  18120. // ResetContentType resets all changes to the "content_type" field.
  18121. func (m *MessageRecordsMutation) ResetContentType() {
  18122. m.content_type = nil
  18123. m.addcontent_type = nil
  18124. }
  18125. // SetContent sets the "content" field.
  18126. func (m *MessageRecordsMutation) SetContent(s string) {
  18127. m.content = &s
  18128. }
  18129. // Content returns the value of the "content" field in the mutation.
  18130. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  18131. v := m.content
  18132. if v == nil {
  18133. return
  18134. }
  18135. return *v, true
  18136. }
  18137. // OldContent returns the old "content" field's value of the MessageRecords entity.
  18138. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18139. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18140. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  18141. if !m.op.Is(OpUpdateOne) {
  18142. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  18143. }
  18144. if m.id == nil || m.oldValue == nil {
  18145. return v, errors.New("OldContent requires an ID field in the mutation")
  18146. }
  18147. oldValue, err := m.oldValue(ctx)
  18148. if err != nil {
  18149. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  18150. }
  18151. return oldValue.Content, nil
  18152. }
  18153. // ResetContent resets all changes to the "content" field.
  18154. func (m *MessageRecordsMutation) ResetContent() {
  18155. m.content = nil
  18156. }
  18157. // SetMeta sets the "meta" field.
  18158. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  18159. m.meta = &ct
  18160. }
  18161. // Meta returns the value of the "meta" field in the mutation.
  18162. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  18163. v := m.meta
  18164. if v == nil {
  18165. return
  18166. }
  18167. return *v, true
  18168. }
  18169. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  18170. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18171. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18172. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  18173. if !m.op.Is(OpUpdateOne) {
  18174. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  18175. }
  18176. if m.id == nil || m.oldValue == nil {
  18177. return v, errors.New("OldMeta requires an ID field in the mutation")
  18178. }
  18179. oldValue, err := m.oldValue(ctx)
  18180. if err != nil {
  18181. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  18182. }
  18183. return oldValue.Meta, nil
  18184. }
  18185. // ClearMeta clears the value of the "meta" field.
  18186. func (m *MessageRecordsMutation) ClearMeta() {
  18187. m.meta = nil
  18188. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  18189. }
  18190. // MetaCleared returns if the "meta" field was cleared in this mutation.
  18191. func (m *MessageRecordsMutation) MetaCleared() bool {
  18192. _, ok := m.clearedFields[messagerecords.FieldMeta]
  18193. return ok
  18194. }
  18195. // ResetMeta resets all changes to the "meta" field.
  18196. func (m *MessageRecordsMutation) ResetMeta() {
  18197. m.meta = nil
  18198. delete(m.clearedFields, messagerecords.FieldMeta)
  18199. }
  18200. // SetErrorDetail sets the "error_detail" field.
  18201. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  18202. m.error_detail = &s
  18203. }
  18204. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  18205. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  18206. v := m.error_detail
  18207. if v == nil {
  18208. return
  18209. }
  18210. return *v, true
  18211. }
  18212. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  18213. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18214. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18215. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  18216. if !m.op.Is(OpUpdateOne) {
  18217. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  18218. }
  18219. if m.id == nil || m.oldValue == nil {
  18220. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  18221. }
  18222. oldValue, err := m.oldValue(ctx)
  18223. if err != nil {
  18224. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  18225. }
  18226. return oldValue.ErrorDetail, nil
  18227. }
  18228. // ResetErrorDetail resets all changes to the "error_detail" field.
  18229. func (m *MessageRecordsMutation) ResetErrorDetail() {
  18230. m.error_detail = nil
  18231. }
  18232. // SetSendTime sets the "send_time" field.
  18233. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  18234. m.send_time = &t
  18235. }
  18236. // SendTime returns the value of the "send_time" field in the mutation.
  18237. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  18238. v := m.send_time
  18239. if v == nil {
  18240. return
  18241. }
  18242. return *v, true
  18243. }
  18244. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  18245. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18246. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18247. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  18248. if !m.op.Is(OpUpdateOne) {
  18249. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  18250. }
  18251. if m.id == nil || m.oldValue == nil {
  18252. return v, errors.New("OldSendTime requires an ID field in the mutation")
  18253. }
  18254. oldValue, err := m.oldValue(ctx)
  18255. if err != nil {
  18256. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  18257. }
  18258. return oldValue.SendTime, nil
  18259. }
  18260. // ClearSendTime clears the value of the "send_time" field.
  18261. func (m *MessageRecordsMutation) ClearSendTime() {
  18262. m.send_time = nil
  18263. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  18264. }
  18265. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  18266. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  18267. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  18268. return ok
  18269. }
  18270. // ResetSendTime resets all changes to the "send_time" field.
  18271. func (m *MessageRecordsMutation) ResetSendTime() {
  18272. m.send_time = nil
  18273. delete(m.clearedFields, messagerecords.FieldSendTime)
  18274. }
  18275. // SetSourceType sets the "source_type" field.
  18276. func (m *MessageRecordsMutation) SetSourceType(i int) {
  18277. m.source_type = &i
  18278. m.addsource_type = nil
  18279. }
  18280. // SourceType returns the value of the "source_type" field in the mutation.
  18281. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  18282. v := m.source_type
  18283. if v == nil {
  18284. return
  18285. }
  18286. return *v, true
  18287. }
  18288. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  18289. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18290. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18291. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  18292. if !m.op.Is(OpUpdateOne) {
  18293. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  18294. }
  18295. if m.id == nil || m.oldValue == nil {
  18296. return v, errors.New("OldSourceType requires an ID field in the mutation")
  18297. }
  18298. oldValue, err := m.oldValue(ctx)
  18299. if err != nil {
  18300. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  18301. }
  18302. return oldValue.SourceType, nil
  18303. }
  18304. // AddSourceType adds i to the "source_type" field.
  18305. func (m *MessageRecordsMutation) AddSourceType(i int) {
  18306. if m.addsource_type != nil {
  18307. *m.addsource_type += i
  18308. } else {
  18309. m.addsource_type = &i
  18310. }
  18311. }
  18312. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  18313. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  18314. v := m.addsource_type
  18315. if v == nil {
  18316. return
  18317. }
  18318. return *v, true
  18319. }
  18320. // ResetSourceType resets all changes to the "source_type" field.
  18321. func (m *MessageRecordsMutation) ResetSourceType() {
  18322. m.source_type = nil
  18323. m.addsource_type = nil
  18324. }
  18325. // SetSourceID sets the "source_id" field.
  18326. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  18327. m.sop_stage = &u
  18328. }
  18329. // SourceID returns the value of the "source_id" field in the mutation.
  18330. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  18331. v := m.sop_stage
  18332. if v == nil {
  18333. return
  18334. }
  18335. return *v, true
  18336. }
  18337. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  18338. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18339. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18340. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  18341. if !m.op.Is(OpUpdateOne) {
  18342. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  18343. }
  18344. if m.id == nil || m.oldValue == nil {
  18345. return v, errors.New("OldSourceID requires an ID field in the mutation")
  18346. }
  18347. oldValue, err := m.oldValue(ctx)
  18348. if err != nil {
  18349. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  18350. }
  18351. return oldValue.SourceID, nil
  18352. }
  18353. // ClearSourceID clears the value of the "source_id" field.
  18354. func (m *MessageRecordsMutation) ClearSourceID() {
  18355. m.sop_stage = nil
  18356. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  18357. }
  18358. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  18359. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  18360. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  18361. return ok
  18362. }
  18363. // ResetSourceID resets all changes to the "source_id" field.
  18364. func (m *MessageRecordsMutation) ResetSourceID() {
  18365. m.sop_stage = nil
  18366. delete(m.clearedFields, messagerecords.FieldSourceID)
  18367. }
  18368. // SetSubSourceID sets the "sub_source_id" field.
  18369. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  18370. m.sop_node = &u
  18371. }
  18372. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  18373. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  18374. v := m.sop_node
  18375. if v == nil {
  18376. return
  18377. }
  18378. return *v, true
  18379. }
  18380. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  18381. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18382. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18383. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  18384. if !m.op.Is(OpUpdateOne) {
  18385. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  18386. }
  18387. if m.id == nil || m.oldValue == nil {
  18388. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  18389. }
  18390. oldValue, err := m.oldValue(ctx)
  18391. if err != nil {
  18392. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  18393. }
  18394. return oldValue.SubSourceID, nil
  18395. }
  18396. // ClearSubSourceID clears the value of the "sub_source_id" field.
  18397. func (m *MessageRecordsMutation) ClearSubSourceID() {
  18398. m.sop_node = nil
  18399. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  18400. }
  18401. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  18402. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  18403. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  18404. return ok
  18405. }
  18406. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  18407. func (m *MessageRecordsMutation) ResetSubSourceID() {
  18408. m.sop_node = nil
  18409. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  18410. }
  18411. // SetOrganizationID sets the "organization_id" field.
  18412. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  18413. m.organization_id = &u
  18414. m.addorganization_id = nil
  18415. }
  18416. // OrganizationID returns the value of the "organization_id" field in the mutation.
  18417. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  18418. v := m.organization_id
  18419. if v == nil {
  18420. return
  18421. }
  18422. return *v, true
  18423. }
  18424. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  18425. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18426. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18427. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  18428. if !m.op.Is(OpUpdateOne) {
  18429. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  18430. }
  18431. if m.id == nil || m.oldValue == nil {
  18432. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  18433. }
  18434. oldValue, err := m.oldValue(ctx)
  18435. if err != nil {
  18436. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  18437. }
  18438. return oldValue.OrganizationID, nil
  18439. }
  18440. // AddOrganizationID adds u to the "organization_id" field.
  18441. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  18442. if m.addorganization_id != nil {
  18443. *m.addorganization_id += u
  18444. } else {
  18445. m.addorganization_id = &u
  18446. }
  18447. }
  18448. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  18449. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  18450. v := m.addorganization_id
  18451. if v == nil {
  18452. return
  18453. }
  18454. return *v, true
  18455. }
  18456. // ClearOrganizationID clears the value of the "organization_id" field.
  18457. func (m *MessageRecordsMutation) ClearOrganizationID() {
  18458. m.organization_id = nil
  18459. m.addorganization_id = nil
  18460. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  18461. }
  18462. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  18463. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  18464. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  18465. return ok
  18466. }
  18467. // ResetOrganizationID resets all changes to the "organization_id" field.
  18468. func (m *MessageRecordsMutation) ResetOrganizationID() {
  18469. m.organization_id = nil
  18470. m.addorganization_id = nil
  18471. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  18472. }
  18473. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  18474. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  18475. m.sop_stage = &id
  18476. }
  18477. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  18478. func (m *MessageRecordsMutation) ClearSopStage() {
  18479. m.clearedsop_stage = true
  18480. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  18481. }
  18482. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  18483. func (m *MessageRecordsMutation) SopStageCleared() bool {
  18484. return m.SourceIDCleared() || m.clearedsop_stage
  18485. }
  18486. // SopStageID returns the "sop_stage" edge ID in the mutation.
  18487. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  18488. if m.sop_stage != nil {
  18489. return *m.sop_stage, true
  18490. }
  18491. return
  18492. }
  18493. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  18494. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18495. // SopStageID instead. It exists only for internal usage by the builders.
  18496. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  18497. if id := m.sop_stage; id != nil {
  18498. ids = append(ids, *id)
  18499. }
  18500. return
  18501. }
  18502. // ResetSopStage resets all changes to the "sop_stage" edge.
  18503. func (m *MessageRecordsMutation) ResetSopStage() {
  18504. m.sop_stage = nil
  18505. m.clearedsop_stage = false
  18506. }
  18507. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  18508. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  18509. m.sop_node = &id
  18510. }
  18511. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  18512. func (m *MessageRecordsMutation) ClearSopNode() {
  18513. m.clearedsop_node = true
  18514. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  18515. }
  18516. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  18517. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  18518. return m.SubSourceIDCleared() || m.clearedsop_node
  18519. }
  18520. // SopNodeID returns the "sop_node" edge ID in the mutation.
  18521. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  18522. if m.sop_node != nil {
  18523. return *m.sop_node, true
  18524. }
  18525. return
  18526. }
  18527. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  18528. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18529. // SopNodeID instead. It exists only for internal usage by the builders.
  18530. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  18531. if id := m.sop_node; id != nil {
  18532. ids = append(ids, *id)
  18533. }
  18534. return
  18535. }
  18536. // ResetSopNode resets all changes to the "sop_node" edge.
  18537. func (m *MessageRecordsMutation) ResetSopNode() {
  18538. m.sop_node = nil
  18539. m.clearedsop_node = false
  18540. }
  18541. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  18542. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  18543. m.message_contact = &id
  18544. }
  18545. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  18546. func (m *MessageRecordsMutation) ClearMessageContact() {
  18547. m.clearedmessage_contact = true
  18548. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  18549. }
  18550. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  18551. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  18552. return m.ContactIDCleared() || m.clearedmessage_contact
  18553. }
  18554. // MessageContactID returns the "message_contact" edge ID in the mutation.
  18555. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  18556. if m.message_contact != nil {
  18557. return *m.message_contact, true
  18558. }
  18559. return
  18560. }
  18561. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  18562. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18563. // MessageContactID instead. It exists only for internal usage by the builders.
  18564. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  18565. if id := m.message_contact; id != nil {
  18566. ids = append(ids, *id)
  18567. }
  18568. return
  18569. }
  18570. // ResetMessageContact resets all changes to the "message_contact" edge.
  18571. func (m *MessageRecordsMutation) ResetMessageContact() {
  18572. m.message_contact = nil
  18573. m.clearedmessage_contact = false
  18574. }
  18575. // Where appends a list predicates to the MessageRecordsMutation builder.
  18576. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  18577. m.predicates = append(m.predicates, ps...)
  18578. }
  18579. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  18580. // users can use type-assertion to append predicates that do not depend on any generated package.
  18581. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  18582. p := make([]predicate.MessageRecords, len(ps))
  18583. for i := range ps {
  18584. p[i] = ps[i]
  18585. }
  18586. m.Where(p...)
  18587. }
  18588. // Op returns the operation name.
  18589. func (m *MessageRecordsMutation) Op() Op {
  18590. return m.op
  18591. }
  18592. // SetOp allows setting the mutation operation.
  18593. func (m *MessageRecordsMutation) SetOp(op Op) {
  18594. m.op = op
  18595. }
  18596. // Type returns the node type of this mutation (MessageRecords).
  18597. func (m *MessageRecordsMutation) Type() string {
  18598. return m.typ
  18599. }
  18600. // Fields returns all fields that were changed during this mutation. Note that in
  18601. // order to get all numeric fields that were incremented/decremented, call
  18602. // AddedFields().
  18603. func (m *MessageRecordsMutation) Fields() []string {
  18604. fields := make([]string, 0, 16)
  18605. if m.created_at != nil {
  18606. fields = append(fields, messagerecords.FieldCreatedAt)
  18607. }
  18608. if m.updated_at != nil {
  18609. fields = append(fields, messagerecords.FieldUpdatedAt)
  18610. }
  18611. if m.status != nil {
  18612. fields = append(fields, messagerecords.FieldStatus)
  18613. }
  18614. if m.bot_wxid != nil {
  18615. fields = append(fields, messagerecords.FieldBotWxid)
  18616. }
  18617. if m.message_contact != nil {
  18618. fields = append(fields, messagerecords.FieldContactID)
  18619. }
  18620. if m.contact_type != nil {
  18621. fields = append(fields, messagerecords.FieldContactType)
  18622. }
  18623. if m.contact_wxid != nil {
  18624. fields = append(fields, messagerecords.FieldContactWxid)
  18625. }
  18626. if m.content_type != nil {
  18627. fields = append(fields, messagerecords.FieldContentType)
  18628. }
  18629. if m.content != nil {
  18630. fields = append(fields, messagerecords.FieldContent)
  18631. }
  18632. if m.meta != nil {
  18633. fields = append(fields, messagerecords.FieldMeta)
  18634. }
  18635. if m.error_detail != nil {
  18636. fields = append(fields, messagerecords.FieldErrorDetail)
  18637. }
  18638. if m.send_time != nil {
  18639. fields = append(fields, messagerecords.FieldSendTime)
  18640. }
  18641. if m.source_type != nil {
  18642. fields = append(fields, messagerecords.FieldSourceType)
  18643. }
  18644. if m.sop_stage != nil {
  18645. fields = append(fields, messagerecords.FieldSourceID)
  18646. }
  18647. if m.sop_node != nil {
  18648. fields = append(fields, messagerecords.FieldSubSourceID)
  18649. }
  18650. if m.organization_id != nil {
  18651. fields = append(fields, messagerecords.FieldOrganizationID)
  18652. }
  18653. return fields
  18654. }
  18655. // Field returns the value of a field with the given name. The second boolean
  18656. // return value indicates that this field was not set, or was not defined in the
  18657. // schema.
  18658. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  18659. switch name {
  18660. case messagerecords.FieldCreatedAt:
  18661. return m.CreatedAt()
  18662. case messagerecords.FieldUpdatedAt:
  18663. return m.UpdatedAt()
  18664. case messagerecords.FieldStatus:
  18665. return m.Status()
  18666. case messagerecords.FieldBotWxid:
  18667. return m.BotWxid()
  18668. case messagerecords.FieldContactID:
  18669. return m.ContactID()
  18670. case messagerecords.FieldContactType:
  18671. return m.ContactType()
  18672. case messagerecords.FieldContactWxid:
  18673. return m.ContactWxid()
  18674. case messagerecords.FieldContentType:
  18675. return m.ContentType()
  18676. case messagerecords.FieldContent:
  18677. return m.Content()
  18678. case messagerecords.FieldMeta:
  18679. return m.Meta()
  18680. case messagerecords.FieldErrorDetail:
  18681. return m.ErrorDetail()
  18682. case messagerecords.FieldSendTime:
  18683. return m.SendTime()
  18684. case messagerecords.FieldSourceType:
  18685. return m.SourceType()
  18686. case messagerecords.FieldSourceID:
  18687. return m.SourceID()
  18688. case messagerecords.FieldSubSourceID:
  18689. return m.SubSourceID()
  18690. case messagerecords.FieldOrganizationID:
  18691. return m.OrganizationID()
  18692. }
  18693. return nil, false
  18694. }
  18695. // OldField returns the old value of the field from the database. An error is
  18696. // returned if the mutation operation is not UpdateOne, or the query to the
  18697. // database failed.
  18698. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18699. switch name {
  18700. case messagerecords.FieldCreatedAt:
  18701. return m.OldCreatedAt(ctx)
  18702. case messagerecords.FieldUpdatedAt:
  18703. return m.OldUpdatedAt(ctx)
  18704. case messagerecords.FieldStatus:
  18705. return m.OldStatus(ctx)
  18706. case messagerecords.FieldBotWxid:
  18707. return m.OldBotWxid(ctx)
  18708. case messagerecords.FieldContactID:
  18709. return m.OldContactID(ctx)
  18710. case messagerecords.FieldContactType:
  18711. return m.OldContactType(ctx)
  18712. case messagerecords.FieldContactWxid:
  18713. return m.OldContactWxid(ctx)
  18714. case messagerecords.FieldContentType:
  18715. return m.OldContentType(ctx)
  18716. case messagerecords.FieldContent:
  18717. return m.OldContent(ctx)
  18718. case messagerecords.FieldMeta:
  18719. return m.OldMeta(ctx)
  18720. case messagerecords.FieldErrorDetail:
  18721. return m.OldErrorDetail(ctx)
  18722. case messagerecords.FieldSendTime:
  18723. return m.OldSendTime(ctx)
  18724. case messagerecords.FieldSourceType:
  18725. return m.OldSourceType(ctx)
  18726. case messagerecords.FieldSourceID:
  18727. return m.OldSourceID(ctx)
  18728. case messagerecords.FieldSubSourceID:
  18729. return m.OldSubSourceID(ctx)
  18730. case messagerecords.FieldOrganizationID:
  18731. return m.OldOrganizationID(ctx)
  18732. }
  18733. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  18734. }
  18735. // SetField sets the value of a field with the given name. It returns an error if
  18736. // the field is not defined in the schema, or if the type mismatched the field
  18737. // type.
  18738. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  18739. switch name {
  18740. case messagerecords.FieldCreatedAt:
  18741. v, ok := value.(time.Time)
  18742. if !ok {
  18743. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18744. }
  18745. m.SetCreatedAt(v)
  18746. return nil
  18747. case messagerecords.FieldUpdatedAt:
  18748. v, ok := value.(time.Time)
  18749. if !ok {
  18750. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18751. }
  18752. m.SetUpdatedAt(v)
  18753. return nil
  18754. case messagerecords.FieldStatus:
  18755. v, ok := value.(uint8)
  18756. if !ok {
  18757. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18758. }
  18759. m.SetStatus(v)
  18760. return nil
  18761. case messagerecords.FieldBotWxid:
  18762. v, ok := value.(string)
  18763. if !ok {
  18764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18765. }
  18766. m.SetBotWxid(v)
  18767. return nil
  18768. case messagerecords.FieldContactID:
  18769. v, ok := value.(uint64)
  18770. if !ok {
  18771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18772. }
  18773. m.SetContactID(v)
  18774. return nil
  18775. case messagerecords.FieldContactType:
  18776. v, ok := value.(int)
  18777. if !ok {
  18778. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18779. }
  18780. m.SetContactType(v)
  18781. return nil
  18782. case messagerecords.FieldContactWxid:
  18783. v, ok := value.(string)
  18784. if !ok {
  18785. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18786. }
  18787. m.SetContactWxid(v)
  18788. return nil
  18789. case messagerecords.FieldContentType:
  18790. v, ok := value.(int)
  18791. if !ok {
  18792. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18793. }
  18794. m.SetContentType(v)
  18795. return nil
  18796. case messagerecords.FieldContent:
  18797. v, ok := value.(string)
  18798. if !ok {
  18799. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18800. }
  18801. m.SetContent(v)
  18802. return nil
  18803. case messagerecords.FieldMeta:
  18804. v, ok := value.(custom_types.Meta)
  18805. if !ok {
  18806. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18807. }
  18808. m.SetMeta(v)
  18809. return nil
  18810. case messagerecords.FieldErrorDetail:
  18811. v, ok := value.(string)
  18812. if !ok {
  18813. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18814. }
  18815. m.SetErrorDetail(v)
  18816. return nil
  18817. case messagerecords.FieldSendTime:
  18818. v, ok := value.(time.Time)
  18819. if !ok {
  18820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18821. }
  18822. m.SetSendTime(v)
  18823. return nil
  18824. case messagerecords.FieldSourceType:
  18825. v, ok := value.(int)
  18826. if !ok {
  18827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18828. }
  18829. m.SetSourceType(v)
  18830. return nil
  18831. case messagerecords.FieldSourceID:
  18832. v, ok := value.(uint64)
  18833. if !ok {
  18834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18835. }
  18836. m.SetSourceID(v)
  18837. return nil
  18838. case messagerecords.FieldSubSourceID:
  18839. v, ok := value.(uint64)
  18840. if !ok {
  18841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18842. }
  18843. m.SetSubSourceID(v)
  18844. return nil
  18845. case messagerecords.FieldOrganizationID:
  18846. v, ok := value.(uint64)
  18847. if !ok {
  18848. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18849. }
  18850. m.SetOrganizationID(v)
  18851. return nil
  18852. }
  18853. return fmt.Errorf("unknown MessageRecords field %s", name)
  18854. }
  18855. // AddedFields returns all numeric fields that were incremented/decremented during
  18856. // this mutation.
  18857. func (m *MessageRecordsMutation) AddedFields() []string {
  18858. var fields []string
  18859. if m.addstatus != nil {
  18860. fields = append(fields, messagerecords.FieldStatus)
  18861. }
  18862. if m.addcontact_type != nil {
  18863. fields = append(fields, messagerecords.FieldContactType)
  18864. }
  18865. if m.addcontent_type != nil {
  18866. fields = append(fields, messagerecords.FieldContentType)
  18867. }
  18868. if m.addsource_type != nil {
  18869. fields = append(fields, messagerecords.FieldSourceType)
  18870. }
  18871. if m.addorganization_id != nil {
  18872. fields = append(fields, messagerecords.FieldOrganizationID)
  18873. }
  18874. return fields
  18875. }
  18876. // AddedField returns the numeric value that was incremented/decremented on a field
  18877. // with the given name. The second boolean return value indicates that this field
  18878. // was not set, or was not defined in the schema.
  18879. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  18880. switch name {
  18881. case messagerecords.FieldStatus:
  18882. return m.AddedStatus()
  18883. case messagerecords.FieldContactType:
  18884. return m.AddedContactType()
  18885. case messagerecords.FieldContentType:
  18886. return m.AddedContentType()
  18887. case messagerecords.FieldSourceType:
  18888. return m.AddedSourceType()
  18889. case messagerecords.FieldOrganizationID:
  18890. return m.AddedOrganizationID()
  18891. }
  18892. return nil, false
  18893. }
  18894. // AddField adds the value to the field with the given name. It returns an error if
  18895. // the field is not defined in the schema, or if the type mismatched the field
  18896. // type.
  18897. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  18898. switch name {
  18899. case messagerecords.FieldStatus:
  18900. v, ok := value.(int8)
  18901. if !ok {
  18902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18903. }
  18904. m.AddStatus(v)
  18905. return nil
  18906. case messagerecords.FieldContactType:
  18907. v, ok := value.(int)
  18908. if !ok {
  18909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18910. }
  18911. m.AddContactType(v)
  18912. return nil
  18913. case messagerecords.FieldContentType:
  18914. v, ok := value.(int)
  18915. if !ok {
  18916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18917. }
  18918. m.AddContentType(v)
  18919. return nil
  18920. case messagerecords.FieldSourceType:
  18921. v, ok := value.(int)
  18922. if !ok {
  18923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18924. }
  18925. m.AddSourceType(v)
  18926. return nil
  18927. case messagerecords.FieldOrganizationID:
  18928. v, ok := value.(int64)
  18929. if !ok {
  18930. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18931. }
  18932. m.AddOrganizationID(v)
  18933. return nil
  18934. }
  18935. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  18936. }
  18937. // ClearedFields returns all nullable fields that were cleared during this
  18938. // mutation.
  18939. func (m *MessageRecordsMutation) ClearedFields() []string {
  18940. var fields []string
  18941. if m.FieldCleared(messagerecords.FieldStatus) {
  18942. fields = append(fields, messagerecords.FieldStatus)
  18943. }
  18944. if m.FieldCleared(messagerecords.FieldContactID) {
  18945. fields = append(fields, messagerecords.FieldContactID)
  18946. }
  18947. if m.FieldCleared(messagerecords.FieldMeta) {
  18948. fields = append(fields, messagerecords.FieldMeta)
  18949. }
  18950. if m.FieldCleared(messagerecords.FieldSendTime) {
  18951. fields = append(fields, messagerecords.FieldSendTime)
  18952. }
  18953. if m.FieldCleared(messagerecords.FieldSourceID) {
  18954. fields = append(fields, messagerecords.FieldSourceID)
  18955. }
  18956. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  18957. fields = append(fields, messagerecords.FieldSubSourceID)
  18958. }
  18959. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  18960. fields = append(fields, messagerecords.FieldOrganizationID)
  18961. }
  18962. return fields
  18963. }
  18964. // FieldCleared returns a boolean indicating if a field with the given name was
  18965. // cleared in this mutation.
  18966. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  18967. _, ok := m.clearedFields[name]
  18968. return ok
  18969. }
  18970. // ClearField clears the value of the field with the given name. It returns an
  18971. // error if the field is not defined in the schema.
  18972. func (m *MessageRecordsMutation) ClearField(name string) error {
  18973. switch name {
  18974. case messagerecords.FieldStatus:
  18975. m.ClearStatus()
  18976. return nil
  18977. case messagerecords.FieldContactID:
  18978. m.ClearContactID()
  18979. return nil
  18980. case messagerecords.FieldMeta:
  18981. m.ClearMeta()
  18982. return nil
  18983. case messagerecords.FieldSendTime:
  18984. m.ClearSendTime()
  18985. return nil
  18986. case messagerecords.FieldSourceID:
  18987. m.ClearSourceID()
  18988. return nil
  18989. case messagerecords.FieldSubSourceID:
  18990. m.ClearSubSourceID()
  18991. return nil
  18992. case messagerecords.FieldOrganizationID:
  18993. m.ClearOrganizationID()
  18994. return nil
  18995. }
  18996. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  18997. }
  18998. // ResetField resets all changes in the mutation for the field with the given name.
  18999. // It returns an error if the field is not defined in the schema.
  19000. func (m *MessageRecordsMutation) ResetField(name string) error {
  19001. switch name {
  19002. case messagerecords.FieldCreatedAt:
  19003. m.ResetCreatedAt()
  19004. return nil
  19005. case messagerecords.FieldUpdatedAt:
  19006. m.ResetUpdatedAt()
  19007. return nil
  19008. case messagerecords.FieldStatus:
  19009. m.ResetStatus()
  19010. return nil
  19011. case messagerecords.FieldBotWxid:
  19012. m.ResetBotWxid()
  19013. return nil
  19014. case messagerecords.FieldContactID:
  19015. m.ResetContactID()
  19016. return nil
  19017. case messagerecords.FieldContactType:
  19018. m.ResetContactType()
  19019. return nil
  19020. case messagerecords.FieldContactWxid:
  19021. m.ResetContactWxid()
  19022. return nil
  19023. case messagerecords.FieldContentType:
  19024. m.ResetContentType()
  19025. return nil
  19026. case messagerecords.FieldContent:
  19027. m.ResetContent()
  19028. return nil
  19029. case messagerecords.FieldMeta:
  19030. m.ResetMeta()
  19031. return nil
  19032. case messagerecords.FieldErrorDetail:
  19033. m.ResetErrorDetail()
  19034. return nil
  19035. case messagerecords.FieldSendTime:
  19036. m.ResetSendTime()
  19037. return nil
  19038. case messagerecords.FieldSourceType:
  19039. m.ResetSourceType()
  19040. return nil
  19041. case messagerecords.FieldSourceID:
  19042. m.ResetSourceID()
  19043. return nil
  19044. case messagerecords.FieldSubSourceID:
  19045. m.ResetSubSourceID()
  19046. return nil
  19047. case messagerecords.FieldOrganizationID:
  19048. m.ResetOrganizationID()
  19049. return nil
  19050. }
  19051. return fmt.Errorf("unknown MessageRecords field %s", name)
  19052. }
  19053. // AddedEdges returns all edge names that were set/added in this mutation.
  19054. func (m *MessageRecordsMutation) AddedEdges() []string {
  19055. edges := make([]string, 0, 3)
  19056. if m.sop_stage != nil {
  19057. edges = append(edges, messagerecords.EdgeSopStage)
  19058. }
  19059. if m.sop_node != nil {
  19060. edges = append(edges, messagerecords.EdgeSopNode)
  19061. }
  19062. if m.message_contact != nil {
  19063. edges = append(edges, messagerecords.EdgeMessageContact)
  19064. }
  19065. return edges
  19066. }
  19067. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19068. // name in this mutation.
  19069. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  19070. switch name {
  19071. case messagerecords.EdgeSopStage:
  19072. if id := m.sop_stage; id != nil {
  19073. return []ent.Value{*id}
  19074. }
  19075. case messagerecords.EdgeSopNode:
  19076. if id := m.sop_node; id != nil {
  19077. return []ent.Value{*id}
  19078. }
  19079. case messagerecords.EdgeMessageContact:
  19080. if id := m.message_contact; id != nil {
  19081. return []ent.Value{*id}
  19082. }
  19083. }
  19084. return nil
  19085. }
  19086. // RemovedEdges returns all edge names that were removed in this mutation.
  19087. func (m *MessageRecordsMutation) RemovedEdges() []string {
  19088. edges := make([]string, 0, 3)
  19089. return edges
  19090. }
  19091. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19092. // the given name in this mutation.
  19093. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  19094. return nil
  19095. }
  19096. // ClearedEdges returns all edge names that were cleared in this mutation.
  19097. func (m *MessageRecordsMutation) ClearedEdges() []string {
  19098. edges := make([]string, 0, 3)
  19099. if m.clearedsop_stage {
  19100. edges = append(edges, messagerecords.EdgeSopStage)
  19101. }
  19102. if m.clearedsop_node {
  19103. edges = append(edges, messagerecords.EdgeSopNode)
  19104. }
  19105. if m.clearedmessage_contact {
  19106. edges = append(edges, messagerecords.EdgeMessageContact)
  19107. }
  19108. return edges
  19109. }
  19110. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19111. // was cleared in this mutation.
  19112. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  19113. switch name {
  19114. case messagerecords.EdgeSopStage:
  19115. return m.clearedsop_stage
  19116. case messagerecords.EdgeSopNode:
  19117. return m.clearedsop_node
  19118. case messagerecords.EdgeMessageContact:
  19119. return m.clearedmessage_contact
  19120. }
  19121. return false
  19122. }
  19123. // ClearEdge clears the value of the edge with the given name. It returns an error
  19124. // if that edge is not defined in the schema.
  19125. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  19126. switch name {
  19127. case messagerecords.EdgeSopStage:
  19128. m.ClearSopStage()
  19129. return nil
  19130. case messagerecords.EdgeSopNode:
  19131. m.ClearSopNode()
  19132. return nil
  19133. case messagerecords.EdgeMessageContact:
  19134. m.ClearMessageContact()
  19135. return nil
  19136. }
  19137. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  19138. }
  19139. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19140. // It returns an error if the edge is not defined in the schema.
  19141. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  19142. switch name {
  19143. case messagerecords.EdgeSopStage:
  19144. m.ResetSopStage()
  19145. return nil
  19146. case messagerecords.EdgeSopNode:
  19147. m.ResetSopNode()
  19148. return nil
  19149. case messagerecords.EdgeMessageContact:
  19150. m.ResetMessageContact()
  19151. return nil
  19152. }
  19153. return fmt.Errorf("unknown MessageRecords edge %s", name)
  19154. }
  19155. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  19156. type MsgMutation struct {
  19157. config
  19158. op Op
  19159. typ string
  19160. id *uint64
  19161. created_at *time.Time
  19162. updated_at *time.Time
  19163. deleted_at *time.Time
  19164. status *uint8
  19165. addstatus *int8
  19166. fromwxid *string
  19167. toid *string
  19168. msgtype *int32
  19169. addmsgtype *int32
  19170. msg *string
  19171. batch_no *string
  19172. cc *string
  19173. phone *string
  19174. clearedFields map[string]struct{}
  19175. done bool
  19176. oldValue func(context.Context) (*Msg, error)
  19177. predicates []predicate.Msg
  19178. }
  19179. var _ ent.Mutation = (*MsgMutation)(nil)
  19180. // msgOption allows management of the mutation configuration using functional options.
  19181. type msgOption func(*MsgMutation)
  19182. // newMsgMutation creates new mutation for the Msg entity.
  19183. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  19184. m := &MsgMutation{
  19185. config: c,
  19186. op: op,
  19187. typ: TypeMsg,
  19188. clearedFields: make(map[string]struct{}),
  19189. }
  19190. for _, opt := range opts {
  19191. opt(m)
  19192. }
  19193. return m
  19194. }
  19195. // withMsgID sets the ID field of the mutation.
  19196. func withMsgID(id uint64) msgOption {
  19197. return func(m *MsgMutation) {
  19198. var (
  19199. err error
  19200. once sync.Once
  19201. value *Msg
  19202. )
  19203. m.oldValue = func(ctx context.Context) (*Msg, error) {
  19204. once.Do(func() {
  19205. if m.done {
  19206. err = errors.New("querying old values post mutation is not allowed")
  19207. } else {
  19208. value, err = m.Client().Msg.Get(ctx, id)
  19209. }
  19210. })
  19211. return value, err
  19212. }
  19213. m.id = &id
  19214. }
  19215. }
  19216. // withMsg sets the old Msg of the mutation.
  19217. func withMsg(node *Msg) msgOption {
  19218. return func(m *MsgMutation) {
  19219. m.oldValue = func(context.Context) (*Msg, error) {
  19220. return node, nil
  19221. }
  19222. m.id = &node.ID
  19223. }
  19224. }
  19225. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19226. // executed in a transaction (ent.Tx), a transactional client is returned.
  19227. func (m MsgMutation) Client() *Client {
  19228. client := &Client{config: m.config}
  19229. client.init()
  19230. return client
  19231. }
  19232. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19233. // it returns an error otherwise.
  19234. func (m MsgMutation) Tx() (*Tx, error) {
  19235. if _, ok := m.driver.(*txDriver); !ok {
  19236. return nil, errors.New("ent: mutation is not running in a transaction")
  19237. }
  19238. tx := &Tx{config: m.config}
  19239. tx.init()
  19240. return tx, nil
  19241. }
  19242. // SetID sets the value of the id field. Note that this
  19243. // operation is only accepted on creation of Msg entities.
  19244. func (m *MsgMutation) SetID(id uint64) {
  19245. m.id = &id
  19246. }
  19247. // ID returns the ID value in the mutation. Note that the ID is only available
  19248. // if it was provided to the builder or after it was returned from the database.
  19249. func (m *MsgMutation) ID() (id uint64, exists bool) {
  19250. if m.id == nil {
  19251. return
  19252. }
  19253. return *m.id, true
  19254. }
  19255. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19256. // That means, if the mutation is applied within a transaction with an isolation level such
  19257. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19258. // or updated by the mutation.
  19259. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  19260. switch {
  19261. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19262. id, exists := m.ID()
  19263. if exists {
  19264. return []uint64{id}, nil
  19265. }
  19266. fallthrough
  19267. case m.op.Is(OpUpdate | OpDelete):
  19268. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  19269. default:
  19270. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19271. }
  19272. }
  19273. // SetCreatedAt sets the "created_at" field.
  19274. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  19275. m.created_at = &t
  19276. }
  19277. // CreatedAt returns the value of the "created_at" field in the mutation.
  19278. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  19279. v := m.created_at
  19280. if v == nil {
  19281. return
  19282. }
  19283. return *v, true
  19284. }
  19285. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  19286. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19287. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19288. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19289. if !m.op.Is(OpUpdateOne) {
  19290. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19291. }
  19292. if m.id == nil || m.oldValue == nil {
  19293. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19294. }
  19295. oldValue, err := m.oldValue(ctx)
  19296. if err != nil {
  19297. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19298. }
  19299. return oldValue.CreatedAt, nil
  19300. }
  19301. // ResetCreatedAt resets all changes to the "created_at" field.
  19302. func (m *MsgMutation) ResetCreatedAt() {
  19303. m.created_at = nil
  19304. }
  19305. // SetUpdatedAt sets the "updated_at" field.
  19306. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  19307. m.updated_at = &t
  19308. }
  19309. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19310. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  19311. v := m.updated_at
  19312. if v == nil {
  19313. return
  19314. }
  19315. return *v, true
  19316. }
  19317. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  19318. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19319. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19320. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19321. if !m.op.Is(OpUpdateOne) {
  19322. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19323. }
  19324. if m.id == nil || m.oldValue == nil {
  19325. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19326. }
  19327. oldValue, err := m.oldValue(ctx)
  19328. if err != nil {
  19329. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19330. }
  19331. return oldValue.UpdatedAt, nil
  19332. }
  19333. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19334. func (m *MsgMutation) ResetUpdatedAt() {
  19335. m.updated_at = nil
  19336. }
  19337. // SetDeletedAt sets the "deleted_at" field.
  19338. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  19339. m.deleted_at = &t
  19340. }
  19341. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19342. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  19343. v := m.deleted_at
  19344. if v == nil {
  19345. return
  19346. }
  19347. return *v, true
  19348. }
  19349. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  19350. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19351. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19352. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19353. if !m.op.Is(OpUpdateOne) {
  19354. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19355. }
  19356. if m.id == nil || m.oldValue == nil {
  19357. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19358. }
  19359. oldValue, err := m.oldValue(ctx)
  19360. if err != nil {
  19361. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19362. }
  19363. return oldValue.DeletedAt, nil
  19364. }
  19365. // ClearDeletedAt clears the value of the "deleted_at" field.
  19366. func (m *MsgMutation) ClearDeletedAt() {
  19367. m.deleted_at = nil
  19368. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  19369. }
  19370. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19371. func (m *MsgMutation) DeletedAtCleared() bool {
  19372. _, ok := m.clearedFields[msg.FieldDeletedAt]
  19373. return ok
  19374. }
  19375. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19376. func (m *MsgMutation) ResetDeletedAt() {
  19377. m.deleted_at = nil
  19378. delete(m.clearedFields, msg.FieldDeletedAt)
  19379. }
  19380. // SetStatus sets the "status" field.
  19381. func (m *MsgMutation) SetStatus(u uint8) {
  19382. m.status = &u
  19383. m.addstatus = nil
  19384. }
  19385. // Status returns the value of the "status" field in the mutation.
  19386. func (m *MsgMutation) Status() (r uint8, exists bool) {
  19387. v := m.status
  19388. if v == nil {
  19389. return
  19390. }
  19391. return *v, true
  19392. }
  19393. // OldStatus returns the old "status" field's value of the Msg entity.
  19394. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19395. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19396. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  19397. if !m.op.Is(OpUpdateOne) {
  19398. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19399. }
  19400. if m.id == nil || m.oldValue == nil {
  19401. return v, errors.New("OldStatus requires an ID field in the mutation")
  19402. }
  19403. oldValue, err := m.oldValue(ctx)
  19404. if err != nil {
  19405. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19406. }
  19407. return oldValue.Status, nil
  19408. }
  19409. // AddStatus adds u to the "status" field.
  19410. func (m *MsgMutation) AddStatus(u int8) {
  19411. if m.addstatus != nil {
  19412. *m.addstatus += u
  19413. } else {
  19414. m.addstatus = &u
  19415. }
  19416. }
  19417. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19418. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  19419. v := m.addstatus
  19420. if v == nil {
  19421. return
  19422. }
  19423. return *v, true
  19424. }
  19425. // ClearStatus clears the value of the "status" field.
  19426. func (m *MsgMutation) ClearStatus() {
  19427. m.status = nil
  19428. m.addstatus = nil
  19429. m.clearedFields[msg.FieldStatus] = struct{}{}
  19430. }
  19431. // StatusCleared returns if the "status" field was cleared in this mutation.
  19432. func (m *MsgMutation) StatusCleared() bool {
  19433. _, ok := m.clearedFields[msg.FieldStatus]
  19434. return ok
  19435. }
  19436. // ResetStatus resets all changes to the "status" field.
  19437. func (m *MsgMutation) ResetStatus() {
  19438. m.status = nil
  19439. m.addstatus = nil
  19440. delete(m.clearedFields, msg.FieldStatus)
  19441. }
  19442. // SetFromwxid sets the "fromwxid" field.
  19443. func (m *MsgMutation) SetFromwxid(s string) {
  19444. m.fromwxid = &s
  19445. }
  19446. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  19447. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  19448. v := m.fromwxid
  19449. if v == nil {
  19450. return
  19451. }
  19452. return *v, true
  19453. }
  19454. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  19455. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19456. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19457. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  19458. if !m.op.Is(OpUpdateOne) {
  19459. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  19460. }
  19461. if m.id == nil || m.oldValue == nil {
  19462. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  19463. }
  19464. oldValue, err := m.oldValue(ctx)
  19465. if err != nil {
  19466. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  19467. }
  19468. return oldValue.Fromwxid, nil
  19469. }
  19470. // ClearFromwxid clears the value of the "fromwxid" field.
  19471. func (m *MsgMutation) ClearFromwxid() {
  19472. m.fromwxid = nil
  19473. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  19474. }
  19475. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  19476. func (m *MsgMutation) FromwxidCleared() bool {
  19477. _, ok := m.clearedFields[msg.FieldFromwxid]
  19478. return ok
  19479. }
  19480. // ResetFromwxid resets all changes to the "fromwxid" field.
  19481. func (m *MsgMutation) ResetFromwxid() {
  19482. m.fromwxid = nil
  19483. delete(m.clearedFields, msg.FieldFromwxid)
  19484. }
  19485. // SetToid sets the "toid" field.
  19486. func (m *MsgMutation) SetToid(s string) {
  19487. m.toid = &s
  19488. }
  19489. // Toid returns the value of the "toid" field in the mutation.
  19490. func (m *MsgMutation) Toid() (r string, exists bool) {
  19491. v := m.toid
  19492. if v == nil {
  19493. return
  19494. }
  19495. return *v, true
  19496. }
  19497. // OldToid returns the old "toid" field's value of the Msg entity.
  19498. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19499. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19500. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  19501. if !m.op.Is(OpUpdateOne) {
  19502. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  19503. }
  19504. if m.id == nil || m.oldValue == nil {
  19505. return v, errors.New("OldToid requires an ID field in the mutation")
  19506. }
  19507. oldValue, err := m.oldValue(ctx)
  19508. if err != nil {
  19509. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  19510. }
  19511. return oldValue.Toid, nil
  19512. }
  19513. // ClearToid clears the value of the "toid" field.
  19514. func (m *MsgMutation) ClearToid() {
  19515. m.toid = nil
  19516. m.clearedFields[msg.FieldToid] = struct{}{}
  19517. }
  19518. // ToidCleared returns if the "toid" field was cleared in this mutation.
  19519. func (m *MsgMutation) ToidCleared() bool {
  19520. _, ok := m.clearedFields[msg.FieldToid]
  19521. return ok
  19522. }
  19523. // ResetToid resets all changes to the "toid" field.
  19524. func (m *MsgMutation) ResetToid() {
  19525. m.toid = nil
  19526. delete(m.clearedFields, msg.FieldToid)
  19527. }
  19528. // SetMsgtype sets the "msgtype" field.
  19529. func (m *MsgMutation) SetMsgtype(i int32) {
  19530. m.msgtype = &i
  19531. m.addmsgtype = nil
  19532. }
  19533. // Msgtype returns the value of the "msgtype" field in the mutation.
  19534. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  19535. v := m.msgtype
  19536. if v == nil {
  19537. return
  19538. }
  19539. return *v, true
  19540. }
  19541. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  19542. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19543. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19544. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  19545. if !m.op.Is(OpUpdateOne) {
  19546. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  19547. }
  19548. if m.id == nil || m.oldValue == nil {
  19549. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  19550. }
  19551. oldValue, err := m.oldValue(ctx)
  19552. if err != nil {
  19553. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  19554. }
  19555. return oldValue.Msgtype, nil
  19556. }
  19557. // AddMsgtype adds i to the "msgtype" field.
  19558. func (m *MsgMutation) AddMsgtype(i int32) {
  19559. if m.addmsgtype != nil {
  19560. *m.addmsgtype += i
  19561. } else {
  19562. m.addmsgtype = &i
  19563. }
  19564. }
  19565. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  19566. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  19567. v := m.addmsgtype
  19568. if v == nil {
  19569. return
  19570. }
  19571. return *v, true
  19572. }
  19573. // ClearMsgtype clears the value of the "msgtype" field.
  19574. func (m *MsgMutation) ClearMsgtype() {
  19575. m.msgtype = nil
  19576. m.addmsgtype = nil
  19577. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  19578. }
  19579. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  19580. func (m *MsgMutation) MsgtypeCleared() bool {
  19581. _, ok := m.clearedFields[msg.FieldMsgtype]
  19582. return ok
  19583. }
  19584. // ResetMsgtype resets all changes to the "msgtype" field.
  19585. func (m *MsgMutation) ResetMsgtype() {
  19586. m.msgtype = nil
  19587. m.addmsgtype = nil
  19588. delete(m.clearedFields, msg.FieldMsgtype)
  19589. }
  19590. // SetMsg sets the "msg" field.
  19591. func (m *MsgMutation) SetMsg(s string) {
  19592. m.msg = &s
  19593. }
  19594. // Msg returns the value of the "msg" field in the mutation.
  19595. func (m *MsgMutation) Msg() (r string, exists bool) {
  19596. v := m.msg
  19597. if v == nil {
  19598. return
  19599. }
  19600. return *v, true
  19601. }
  19602. // OldMsg returns the old "msg" field's value of the Msg entity.
  19603. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19604. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19605. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  19606. if !m.op.Is(OpUpdateOne) {
  19607. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  19608. }
  19609. if m.id == nil || m.oldValue == nil {
  19610. return v, errors.New("OldMsg requires an ID field in the mutation")
  19611. }
  19612. oldValue, err := m.oldValue(ctx)
  19613. if err != nil {
  19614. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  19615. }
  19616. return oldValue.Msg, nil
  19617. }
  19618. // ClearMsg clears the value of the "msg" field.
  19619. func (m *MsgMutation) ClearMsg() {
  19620. m.msg = nil
  19621. m.clearedFields[msg.FieldMsg] = struct{}{}
  19622. }
  19623. // MsgCleared returns if the "msg" field was cleared in this mutation.
  19624. func (m *MsgMutation) MsgCleared() bool {
  19625. _, ok := m.clearedFields[msg.FieldMsg]
  19626. return ok
  19627. }
  19628. // ResetMsg resets all changes to the "msg" field.
  19629. func (m *MsgMutation) ResetMsg() {
  19630. m.msg = nil
  19631. delete(m.clearedFields, msg.FieldMsg)
  19632. }
  19633. // SetBatchNo sets the "batch_no" field.
  19634. func (m *MsgMutation) SetBatchNo(s string) {
  19635. m.batch_no = &s
  19636. }
  19637. // BatchNo returns the value of the "batch_no" field in the mutation.
  19638. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  19639. v := m.batch_no
  19640. if v == nil {
  19641. return
  19642. }
  19643. return *v, true
  19644. }
  19645. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  19646. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19647. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19648. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  19649. if !m.op.Is(OpUpdateOne) {
  19650. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  19651. }
  19652. if m.id == nil || m.oldValue == nil {
  19653. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  19654. }
  19655. oldValue, err := m.oldValue(ctx)
  19656. if err != nil {
  19657. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  19658. }
  19659. return oldValue.BatchNo, nil
  19660. }
  19661. // ClearBatchNo clears the value of the "batch_no" field.
  19662. func (m *MsgMutation) ClearBatchNo() {
  19663. m.batch_no = nil
  19664. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  19665. }
  19666. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  19667. func (m *MsgMutation) BatchNoCleared() bool {
  19668. _, ok := m.clearedFields[msg.FieldBatchNo]
  19669. return ok
  19670. }
  19671. // ResetBatchNo resets all changes to the "batch_no" field.
  19672. func (m *MsgMutation) ResetBatchNo() {
  19673. m.batch_no = nil
  19674. delete(m.clearedFields, msg.FieldBatchNo)
  19675. }
  19676. // SetCc sets the "cc" field.
  19677. func (m *MsgMutation) SetCc(s string) {
  19678. m.cc = &s
  19679. }
  19680. // Cc returns the value of the "cc" field in the mutation.
  19681. func (m *MsgMutation) Cc() (r string, exists bool) {
  19682. v := m.cc
  19683. if v == nil {
  19684. return
  19685. }
  19686. return *v, true
  19687. }
  19688. // OldCc returns the old "cc" field's value of the Msg entity.
  19689. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19690. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19691. func (m *MsgMutation) OldCc(ctx context.Context) (v string, err error) {
  19692. if !m.op.Is(OpUpdateOne) {
  19693. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  19694. }
  19695. if m.id == nil || m.oldValue == nil {
  19696. return v, errors.New("OldCc requires an ID field in the mutation")
  19697. }
  19698. oldValue, err := m.oldValue(ctx)
  19699. if err != nil {
  19700. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  19701. }
  19702. return oldValue.Cc, nil
  19703. }
  19704. // ResetCc resets all changes to the "cc" field.
  19705. func (m *MsgMutation) ResetCc() {
  19706. m.cc = nil
  19707. }
  19708. // SetPhone sets the "phone" field.
  19709. func (m *MsgMutation) SetPhone(s string) {
  19710. m.phone = &s
  19711. }
  19712. // Phone returns the value of the "phone" field in the mutation.
  19713. func (m *MsgMutation) Phone() (r string, exists bool) {
  19714. v := m.phone
  19715. if v == nil {
  19716. return
  19717. }
  19718. return *v, true
  19719. }
  19720. // OldPhone returns the old "phone" field's value of the Msg entity.
  19721. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19722. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19723. func (m *MsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  19724. if !m.op.Is(OpUpdateOne) {
  19725. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  19726. }
  19727. if m.id == nil || m.oldValue == nil {
  19728. return v, errors.New("OldPhone requires an ID field in the mutation")
  19729. }
  19730. oldValue, err := m.oldValue(ctx)
  19731. if err != nil {
  19732. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  19733. }
  19734. return oldValue.Phone, nil
  19735. }
  19736. // ResetPhone resets all changes to the "phone" field.
  19737. func (m *MsgMutation) ResetPhone() {
  19738. m.phone = nil
  19739. }
  19740. // Where appends a list predicates to the MsgMutation builder.
  19741. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  19742. m.predicates = append(m.predicates, ps...)
  19743. }
  19744. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  19745. // users can use type-assertion to append predicates that do not depend on any generated package.
  19746. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  19747. p := make([]predicate.Msg, len(ps))
  19748. for i := range ps {
  19749. p[i] = ps[i]
  19750. }
  19751. m.Where(p...)
  19752. }
  19753. // Op returns the operation name.
  19754. func (m *MsgMutation) Op() Op {
  19755. return m.op
  19756. }
  19757. // SetOp allows setting the mutation operation.
  19758. func (m *MsgMutation) SetOp(op Op) {
  19759. m.op = op
  19760. }
  19761. // Type returns the node type of this mutation (Msg).
  19762. func (m *MsgMutation) Type() string {
  19763. return m.typ
  19764. }
  19765. // Fields returns all fields that were changed during this mutation. Note that in
  19766. // order to get all numeric fields that were incremented/decremented, call
  19767. // AddedFields().
  19768. func (m *MsgMutation) Fields() []string {
  19769. fields := make([]string, 0, 11)
  19770. if m.created_at != nil {
  19771. fields = append(fields, msg.FieldCreatedAt)
  19772. }
  19773. if m.updated_at != nil {
  19774. fields = append(fields, msg.FieldUpdatedAt)
  19775. }
  19776. if m.deleted_at != nil {
  19777. fields = append(fields, msg.FieldDeletedAt)
  19778. }
  19779. if m.status != nil {
  19780. fields = append(fields, msg.FieldStatus)
  19781. }
  19782. if m.fromwxid != nil {
  19783. fields = append(fields, msg.FieldFromwxid)
  19784. }
  19785. if m.toid != nil {
  19786. fields = append(fields, msg.FieldToid)
  19787. }
  19788. if m.msgtype != nil {
  19789. fields = append(fields, msg.FieldMsgtype)
  19790. }
  19791. if m.msg != nil {
  19792. fields = append(fields, msg.FieldMsg)
  19793. }
  19794. if m.batch_no != nil {
  19795. fields = append(fields, msg.FieldBatchNo)
  19796. }
  19797. if m.cc != nil {
  19798. fields = append(fields, msg.FieldCc)
  19799. }
  19800. if m.phone != nil {
  19801. fields = append(fields, msg.FieldPhone)
  19802. }
  19803. return fields
  19804. }
  19805. // Field returns the value of a field with the given name. The second boolean
  19806. // return value indicates that this field was not set, or was not defined in the
  19807. // schema.
  19808. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  19809. switch name {
  19810. case msg.FieldCreatedAt:
  19811. return m.CreatedAt()
  19812. case msg.FieldUpdatedAt:
  19813. return m.UpdatedAt()
  19814. case msg.FieldDeletedAt:
  19815. return m.DeletedAt()
  19816. case msg.FieldStatus:
  19817. return m.Status()
  19818. case msg.FieldFromwxid:
  19819. return m.Fromwxid()
  19820. case msg.FieldToid:
  19821. return m.Toid()
  19822. case msg.FieldMsgtype:
  19823. return m.Msgtype()
  19824. case msg.FieldMsg:
  19825. return m.Msg()
  19826. case msg.FieldBatchNo:
  19827. return m.BatchNo()
  19828. case msg.FieldCc:
  19829. return m.Cc()
  19830. case msg.FieldPhone:
  19831. return m.Phone()
  19832. }
  19833. return nil, false
  19834. }
  19835. // OldField returns the old value of the field from the database. An error is
  19836. // returned if the mutation operation is not UpdateOne, or the query to the
  19837. // database failed.
  19838. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19839. switch name {
  19840. case msg.FieldCreatedAt:
  19841. return m.OldCreatedAt(ctx)
  19842. case msg.FieldUpdatedAt:
  19843. return m.OldUpdatedAt(ctx)
  19844. case msg.FieldDeletedAt:
  19845. return m.OldDeletedAt(ctx)
  19846. case msg.FieldStatus:
  19847. return m.OldStatus(ctx)
  19848. case msg.FieldFromwxid:
  19849. return m.OldFromwxid(ctx)
  19850. case msg.FieldToid:
  19851. return m.OldToid(ctx)
  19852. case msg.FieldMsgtype:
  19853. return m.OldMsgtype(ctx)
  19854. case msg.FieldMsg:
  19855. return m.OldMsg(ctx)
  19856. case msg.FieldBatchNo:
  19857. return m.OldBatchNo(ctx)
  19858. case msg.FieldCc:
  19859. return m.OldCc(ctx)
  19860. case msg.FieldPhone:
  19861. return m.OldPhone(ctx)
  19862. }
  19863. return nil, fmt.Errorf("unknown Msg field %s", name)
  19864. }
  19865. // SetField sets the value of a field with the given name. It returns an error if
  19866. // the field is not defined in the schema, or if the type mismatched the field
  19867. // type.
  19868. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  19869. switch name {
  19870. case msg.FieldCreatedAt:
  19871. v, ok := value.(time.Time)
  19872. if !ok {
  19873. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19874. }
  19875. m.SetCreatedAt(v)
  19876. return nil
  19877. case msg.FieldUpdatedAt:
  19878. v, ok := value.(time.Time)
  19879. if !ok {
  19880. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19881. }
  19882. m.SetUpdatedAt(v)
  19883. return nil
  19884. case msg.FieldDeletedAt:
  19885. v, ok := value.(time.Time)
  19886. if !ok {
  19887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19888. }
  19889. m.SetDeletedAt(v)
  19890. return nil
  19891. case msg.FieldStatus:
  19892. v, ok := value.(uint8)
  19893. if !ok {
  19894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19895. }
  19896. m.SetStatus(v)
  19897. return nil
  19898. case msg.FieldFromwxid:
  19899. v, ok := value.(string)
  19900. if !ok {
  19901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19902. }
  19903. m.SetFromwxid(v)
  19904. return nil
  19905. case msg.FieldToid:
  19906. v, ok := value.(string)
  19907. if !ok {
  19908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19909. }
  19910. m.SetToid(v)
  19911. return nil
  19912. case msg.FieldMsgtype:
  19913. v, ok := value.(int32)
  19914. if !ok {
  19915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19916. }
  19917. m.SetMsgtype(v)
  19918. return nil
  19919. case msg.FieldMsg:
  19920. v, ok := value.(string)
  19921. if !ok {
  19922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19923. }
  19924. m.SetMsg(v)
  19925. return nil
  19926. case msg.FieldBatchNo:
  19927. v, ok := value.(string)
  19928. if !ok {
  19929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19930. }
  19931. m.SetBatchNo(v)
  19932. return nil
  19933. case msg.FieldCc:
  19934. v, ok := value.(string)
  19935. if !ok {
  19936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19937. }
  19938. m.SetCc(v)
  19939. return nil
  19940. case msg.FieldPhone:
  19941. v, ok := value.(string)
  19942. if !ok {
  19943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19944. }
  19945. m.SetPhone(v)
  19946. return nil
  19947. }
  19948. return fmt.Errorf("unknown Msg field %s", name)
  19949. }
  19950. // AddedFields returns all numeric fields that were incremented/decremented during
  19951. // this mutation.
  19952. func (m *MsgMutation) AddedFields() []string {
  19953. var fields []string
  19954. if m.addstatus != nil {
  19955. fields = append(fields, msg.FieldStatus)
  19956. }
  19957. if m.addmsgtype != nil {
  19958. fields = append(fields, msg.FieldMsgtype)
  19959. }
  19960. return fields
  19961. }
  19962. // AddedField returns the numeric value that was incremented/decremented on a field
  19963. // with the given name. The second boolean return value indicates that this field
  19964. // was not set, or was not defined in the schema.
  19965. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  19966. switch name {
  19967. case msg.FieldStatus:
  19968. return m.AddedStatus()
  19969. case msg.FieldMsgtype:
  19970. return m.AddedMsgtype()
  19971. }
  19972. return nil, false
  19973. }
  19974. // AddField adds the value to the field with the given name. It returns an error if
  19975. // the field is not defined in the schema, or if the type mismatched the field
  19976. // type.
  19977. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  19978. switch name {
  19979. case msg.FieldStatus:
  19980. v, ok := value.(int8)
  19981. if !ok {
  19982. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19983. }
  19984. m.AddStatus(v)
  19985. return nil
  19986. case msg.FieldMsgtype:
  19987. v, ok := value.(int32)
  19988. if !ok {
  19989. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19990. }
  19991. m.AddMsgtype(v)
  19992. return nil
  19993. }
  19994. return fmt.Errorf("unknown Msg numeric field %s", name)
  19995. }
  19996. // ClearedFields returns all nullable fields that were cleared during this
  19997. // mutation.
  19998. func (m *MsgMutation) ClearedFields() []string {
  19999. var fields []string
  20000. if m.FieldCleared(msg.FieldDeletedAt) {
  20001. fields = append(fields, msg.FieldDeletedAt)
  20002. }
  20003. if m.FieldCleared(msg.FieldStatus) {
  20004. fields = append(fields, msg.FieldStatus)
  20005. }
  20006. if m.FieldCleared(msg.FieldFromwxid) {
  20007. fields = append(fields, msg.FieldFromwxid)
  20008. }
  20009. if m.FieldCleared(msg.FieldToid) {
  20010. fields = append(fields, msg.FieldToid)
  20011. }
  20012. if m.FieldCleared(msg.FieldMsgtype) {
  20013. fields = append(fields, msg.FieldMsgtype)
  20014. }
  20015. if m.FieldCleared(msg.FieldMsg) {
  20016. fields = append(fields, msg.FieldMsg)
  20017. }
  20018. if m.FieldCleared(msg.FieldBatchNo) {
  20019. fields = append(fields, msg.FieldBatchNo)
  20020. }
  20021. return fields
  20022. }
  20023. // FieldCleared returns a boolean indicating if a field with the given name was
  20024. // cleared in this mutation.
  20025. func (m *MsgMutation) FieldCleared(name string) bool {
  20026. _, ok := m.clearedFields[name]
  20027. return ok
  20028. }
  20029. // ClearField clears the value of the field with the given name. It returns an
  20030. // error if the field is not defined in the schema.
  20031. func (m *MsgMutation) ClearField(name string) error {
  20032. switch name {
  20033. case msg.FieldDeletedAt:
  20034. m.ClearDeletedAt()
  20035. return nil
  20036. case msg.FieldStatus:
  20037. m.ClearStatus()
  20038. return nil
  20039. case msg.FieldFromwxid:
  20040. m.ClearFromwxid()
  20041. return nil
  20042. case msg.FieldToid:
  20043. m.ClearToid()
  20044. return nil
  20045. case msg.FieldMsgtype:
  20046. m.ClearMsgtype()
  20047. return nil
  20048. case msg.FieldMsg:
  20049. m.ClearMsg()
  20050. return nil
  20051. case msg.FieldBatchNo:
  20052. m.ClearBatchNo()
  20053. return nil
  20054. }
  20055. return fmt.Errorf("unknown Msg nullable field %s", name)
  20056. }
  20057. // ResetField resets all changes in the mutation for the field with the given name.
  20058. // It returns an error if the field is not defined in the schema.
  20059. func (m *MsgMutation) ResetField(name string) error {
  20060. switch name {
  20061. case msg.FieldCreatedAt:
  20062. m.ResetCreatedAt()
  20063. return nil
  20064. case msg.FieldUpdatedAt:
  20065. m.ResetUpdatedAt()
  20066. return nil
  20067. case msg.FieldDeletedAt:
  20068. m.ResetDeletedAt()
  20069. return nil
  20070. case msg.FieldStatus:
  20071. m.ResetStatus()
  20072. return nil
  20073. case msg.FieldFromwxid:
  20074. m.ResetFromwxid()
  20075. return nil
  20076. case msg.FieldToid:
  20077. m.ResetToid()
  20078. return nil
  20079. case msg.FieldMsgtype:
  20080. m.ResetMsgtype()
  20081. return nil
  20082. case msg.FieldMsg:
  20083. m.ResetMsg()
  20084. return nil
  20085. case msg.FieldBatchNo:
  20086. m.ResetBatchNo()
  20087. return nil
  20088. case msg.FieldCc:
  20089. m.ResetCc()
  20090. return nil
  20091. case msg.FieldPhone:
  20092. m.ResetPhone()
  20093. return nil
  20094. }
  20095. return fmt.Errorf("unknown Msg field %s", name)
  20096. }
  20097. // AddedEdges returns all edge names that were set/added in this mutation.
  20098. func (m *MsgMutation) AddedEdges() []string {
  20099. edges := make([]string, 0, 0)
  20100. return edges
  20101. }
  20102. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20103. // name in this mutation.
  20104. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  20105. return nil
  20106. }
  20107. // RemovedEdges returns all edge names that were removed in this mutation.
  20108. func (m *MsgMutation) RemovedEdges() []string {
  20109. edges := make([]string, 0, 0)
  20110. return edges
  20111. }
  20112. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20113. // the given name in this mutation.
  20114. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  20115. return nil
  20116. }
  20117. // ClearedEdges returns all edge names that were cleared in this mutation.
  20118. func (m *MsgMutation) ClearedEdges() []string {
  20119. edges := make([]string, 0, 0)
  20120. return edges
  20121. }
  20122. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20123. // was cleared in this mutation.
  20124. func (m *MsgMutation) EdgeCleared(name string) bool {
  20125. return false
  20126. }
  20127. // ClearEdge clears the value of the edge with the given name. It returns an error
  20128. // if that edge is not defined in the schema.
  20129. func (m *MsgMutation) ClearEdge(name string) error {
  20130. return fmt.Errorf("unknown Msg unique edge %s", name)
  20131. }
  20132. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20133. // It returns an error if the edge is not defined in the schema.
  20134. func (m *MsgMutation) ResetEdge(name string) error {
  20135. return fmt.Errorf("unknown Msg edge %s", name)
  20136. }
  20137. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  20138. type PayRechargeMutation struct {
  20139. config
  20140. op Op
  20141. typ string
  20142. id *uint64
  20143. created_at *time.Time
  20144. updated_at *time.Time
  20145. deleted_at *time.Time
  20146. user_id *string
  20147. number *float32
  20148. addnumber *float32
  20149. status *int
  20150. addstatus *int
  20151. money *float32
  20152. addmoney *float32
  20153. out_trade_no *string
  20154. organization_id *uint64
  20155. addorganization_id *int64
  20156. clearedFields map[string]struct{}
  20157. done bool
  20158. oldValue func(context.Context) (*PayRecharge, error)
  20159. predicates []predicate.PayRecharge
  20160. }
  20161. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  20162. // payrechargeOption allows management of the mutation configuration using functional options.
  20163. type payrechargeOption func(*PayRechargeMutation)
  20164. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  20165. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  20166. m := &PayRechargeMutation{
  20167. config: c,
  20168. op: op,
  20169. typ: TypePayRecharge,
  20170. clearedFields: make(map[string]struct{}),
  20171. }
  20172. for _, opt := range opts {
  20173. opt(m)
  20174. }
  20175. return m
  20176. }
  20177. // withPayRechargeID sets the ID field of the mutation.
  20178. func withPayRechargeID(id uint64) payrechargeOption {
  20179. return func(m *PayRechargeMutation) {
  20180. var (
  20181. err error
  20182. once sync.Once
  20183. value *PayRecharge
  20184. )
  20185. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  20186. once.Do(func() {
  20187. if m.done {
  20188. err = errors.New("querying old values post mutation is not allowed")
  20189. } else {
  20190. value, err = m.Client().PayRecharge.Get(ctx, id)
  20191. }
  20192. })
  20193. return value, err
  20194. }
  20195. m.id = &id
  20196. }
  20197. }
  20198. // withPayRecharge sets the old PayRecharge of the mutation.
  20199. func withPayRecharge(node *PayRecharge) payrechargeOption {
  20200. return func(m *PayRechargeMutation) {
  20201. m.oldValue = func(context.Context) (*PayRecharge, error) {
  20202. return node, nil
  20203. }
  20204. m.id = &node.ID
  20205. }
  20206. }
  20207. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20208. // executed in a transaction (ent.Tx), a transactional client is returned.
  20209. func (m PayRechargeMutation) Client() *Client {
  20210. client := &Client{config: m.config}
  20211. client.init()
  20212. return client
  20213. }
  20214. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20215. // it returns an error otherwise.
  20216. func (m PayRechargeMutation) Tx() (*Tx, error) {
  20217. if _, ok := m.driver.(*txDriver); !ok {
  20218. return nil, errors.New("ent: mutation is not running in a transaction")
  20219. }
  20220. tx := &Tx{config: m.config}
  20221. tx.init()
  20222. return tx, nil
  20223. }
  20224. // SetID sets the value of the id field. Note that this
  20225. // operation is only accepted on creation of PayRecharge entities.
  20226. func (m *PayRechargeMutation) SetID(id uint64) {
  20227. m.id = &id
  20228. }
  20229. // ID returns the ID value in the mutation. Note that the ID is only available
  20230. // if it was provided to the builder or after it was returned from the database.
  20231. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  20232. if m.id == nil {
  20233. return
  20234. }
  20235. return *m.id, true
  20236. }
  20237. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20238. // That means, if the mutation is applied within a transaction with an isolation level such
  20239. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20240. // or updated by the mutation.
  20241. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  20242. switch {
  20243. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20244. id, exists := m.ID()
  20245. if exists {
  20246. return []uint64{id}, nil
  20247. }
  20248. fallthrough
  20249. case m.op.Is(OpUpdate | OpDelete):
  20250. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  20251. default:
  20252. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20253. }
  20254. }
  20255. // SetCreatedAt sets the "created_at" field.
  20256. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  20257. m.created_at = &t
  20258. }
  20259. // CreatedAt returns the value of the "created_at" field in the mutation.
  20260. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  20261. v := m.created_at
  20262. if v == nil {
  20263. return
  20264. }
  20265. return *v, true
  20266. }
  20267. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  20268. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20269. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20270. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20271. if !m.op.Is(OpUpdateOne) {
  20272. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20273. }
  20274. if m.id == nil || m.oldValue == nil {
  20275. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20276. }
  20277. oldValue, err := m.oldValue(ctx)
  20278. if err != nil {
  20279. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20280. }
  20281. return oldValue.CreatedAt, nil
  20282. }
  20283. // ResetCreatedAt resets all changes to the "created_at" field.
  20284. func (m *PayRechargeMutation) ResetCreatedAt() {
  20285. m.created_at = nil
  20286. }
  20287. // SetUpdatedAt sets the "updated_at" field.
  20288. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  20289. m.updated_at = &t
  20290. }
  20291. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20292. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  20293. v := m.updated_at
  20294. if v == nil {
  20295. return
  20296. }
  20297. return *v, true
  20298. }
  20299. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  20300. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20301. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20302. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20303. if !m.op.Is(OpUpdateOne) {
  20304. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20305. }
  20306. if m.id == nil || m.oldValue == nil {
  20307. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20308. }
  20309. oldValue, err := m.oldValue(ctx)
  20310. if err != nil {
  20311. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20312. }
  20313. return oldValue.UpdatedAt, nil
  20314. }
  20315. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20316. func (m *PayRechargeMutation) ResetUpdatedAt() {
  20317. m.updated_at = nil
  20318. }
  20319. // SetDeletedAt sets the "deleted_at" field.
  20320. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  20321. m.deleted_at = &t
  20322. }
  20323. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20324. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  20325. v := m.deleted_at
  20326. if v == nil {
  20327. return
  20328. }
  20329. return *v, true
  20330. }
  20331. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  20332. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20333. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20334. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20335. if !m.op.Is(OpUpdateOne) {
  20336. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20337. }
  20338. if m.id == nil || m.oldValue == nil {
  20339. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20340. }
  20341. oldValue, err := m.oldValue(ctx)
  20342. if err != nil {
  20343. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20344. }
  20345. return oldValue.DeletedAt, nil
  20346. }
  20347. // ClearDeletedAt clears the value of the "deleted_at" field.
  20348. func (m *PayRechargeMutation) ClearDeletedAt() {
  20349. m.deleted_at = nil
  20350. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  20351. }
  20352. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20353. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  20354. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  20355. return ok
  20356. }
  20357. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20358. func (m *PayRechargeMutation) ResetDeletedAt() {
  20359. m.deleted_at = nil
  20360. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  20361. }
  20362. // SetUserID sets the "user_id" field.
  20363. func (m *PayRechargeMutation) SetUserID(s string) {
  20364. m.user_id = &s
  20365. }
  20366. // UserID returns the value of the "user_id" field in the mutation.
  20367. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  20368. v := m.user_id
  20369. if v == nil {
  20370. return
  20371. }
  20372. return *v, true
  20373. }
  20374. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  20375. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20376. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20377. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  20378. if !m.op.Is(OpUpdateOne) {
  20379. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  20380. }
  20381. if m.id == nil || m.oldValue == nil {
  20382. return v, errors.New("OldUserID requires an ID field in the mutation")
  20383. }
  20384. oldValue, err := m.oldValue(ctx)
  20385. if err != nil {
  20386. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  20387. }
  20388. return oldValue.UserID, nil
  20389. }
  20390. // ResetUserID resets all changes to the "user_id" field.
  20391. func (m *PayRechargeMutation) ResetUserID() {
  20392. m.user_id = nil
  20393. }
  20394. // SetNumber sets the "number" field.
  20395. func (m *PayRechargeMutation) SetNumber(f float32) {
  20396. m.number = &f
  20397. m.addnumber = nil
  20398. }
  20399. // Number returns the value of the "number" field in the mutation.
  20400. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  20401. v := m.number
  20402. if v == nil {
  20403. return
  20404. }
  20405. return *v, true
  20406. }
  20407. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  20408. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20409. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20410. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  20411. if !m.op.Is(OpUpdateOne) {
  20412. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  20413. }
  20414. if m.id == nil || m.oldValue == nil {
  20415. return v, errors.New("OldNumber requires an ID field in the mutation")
  20416. }
  20417. oldValue, err := m.oldValue(ctx)
  20418. if err != nil {
  20419. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  20420. }
  20421. return oldValue.Number, nil
  20422. }
  20423. // AddNumber adds f to the "number" field.
  20424. func (m *PayRechargeMutation) AddNumber(f float32) {
  20425. if m.addnumber != nil {
  20426. *m.addnumber += f
  20427. } else {
  20428. m.addnumber = &f
  20429. }
  20430. }
  20431. // AddedNumber returns the value that was added to the "number" field in this mutation.
  20432. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  20433. v := m.addnumber
  20434. if v == nil {
  20435. return
  20436. }
  20437. return *v, true
  20438. }
  20439. // ResetNumber resets all changes to the "number" field.
  20440. func (m *PayRechargeMutation) ResetNumber() {
  20441. m.number = nil
  20442. m.addnumber = nil
  20443. }
  20444. // SetStatus sets the "status" field.
  20445. func (m *PayRechargeMutation) SetStatus(i int) {
  20446. m.status = &i
  20447. m.addstatus = nil
  20448. }
  20449. // Status returns the value of the "status" field in the mutation.
  20450. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  20451. v := m.status
  20452. if v == nil {
  20453. return
  20454. }
  20455. return *v, true
  20456. }
  20457. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  20458. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20459. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20460. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  20461. if !m.op.Is(OpUpdateOne) {
  20462. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20463. }
  20464. if m.id == nil || m.oldValue == nil {
  20465. return v, errors.New("OldStatus requires an ID field in the mutation")
  20466. }
  20467. oldValue, err := m.oldValue(ctx)
  20468. if err != nil {
  20469. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20470. }
  20471. return oldValue.Status, nil
  20472. }
  20473. // AddStatus adds i to the "status" field.
  20474. func (m *PayRechargeMutation) AddStatus(i int) {
  20475. if m.addstatus != nil {
  20476. *m.addstatus += i
  20477. } else {
  20478. m.addstatus = &i
  20479. }
  20480. }
  20481. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20482. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  20483. v := m.addstatus
  20484. if v == nil {
  20485. return
  20486. }
  20487. return *v, true
  20488. }
  20489. // ClearStatus clears the value of the "status" field.
  20490. func (m *PayRechargeMutation) ClearStatus() {
  20491. m.status = nil
  20492. m.addstatus = nil
  20493. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  20494. }
  20495. // StatusCleared returns if the "status" field was cleared in this mutation.
  20496. func (m *PayRechargeMutation) StatusCleared() bool {
  20497. _, ok := m.clearedFields[payrecharge.FieldStatus]
  20498. return ok
  20499. }
  20500. // ResetStatus resets all changes to the "status" field.
  20501. func (m *PayRechargeMutation) ResetStatus() {
  20502. m.status = nil
  20503. m.addstatus = nil
  20504. delete(m.clearedFields, payrecharge.FieldStatus)
  20505. }
  20506. // SetMoney sets the "money" field.
  20507. func (m *PayRechargeMutation) SetMoney(f float32) {
  20508. m.money = &f
  20509. m.addmoney = nil
  20510. }
  20511. // Money returns the value of the "money" field in the mutation.
  20512. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  20513. v := m.money
  20514. if v == nil {
  20515. return
  20516. }
  20517. return *v, true
  20518. }
  20519. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  20520. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20521. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20522. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  20523. if !m.op.Is(OpUpdateOne) {
  20524. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  20525. }
  20526. if m.id == nil || m.oldValue == nil {
  20527. return v, errors.New("OldMoney requires an ID field in the mutation")
  20528. }
  20529. oldValue, err := m.oldValue(ctx)
  20530. if err != nil {
  20531. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  20532. }
  20533. return oldValue.Money, nil
  20534. }
  20535. // AddMoney adds f to the "money" field.
  20536. func (m *PayRechargeMutation) AddMoney(f float32) {
  20537. if m.addmoney != nil {
  20538. *m.addmoney += f
  20539. } else {
  20540. m.addmoney = &f
  20541. }
  20542. }
  20543. // AddedMoney returns the value that was added to the "money" field in this mutation.
  20544. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  20545. v := m.addmoney
  20546. if v == nil {
  20547. return
  20548. }
  20549. return *v, true
  20550. }
  20551. // ClearMoney clears the value of the "money" field.
  20552. func (m *PayRechargeMutation) ClearMoney() {
  20553. m.money = nil
  20554. m.addmoney = nil
  20555. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  20556. }
  20557. // MoneyCleared returns if the "money" field was cleared in this mutation.
  20558. func (m *PayRechargeMutation) MoneyCleared() bool {
  20559. _, ok := m.clearedFields[payrecharge.FieldMoney]
  20560. return ok
  20561. }
  20562. // ResetMoney resets all changes to the "money" field.
  20563. func (m *PayRechargeMutation) ResetMoney() {
  20564. m.money = nil
  20565. m.addmoney = nil
  20566. delete(m.clearedFields, payrecharge.FieldMoney)
  20567. }
  20568. // SetOutTradeNo sets the "out_trade_no" field.
  20569. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  20570. m.out_trade_no = &s
  20571. }
  20572. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  20573. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  20574. v := m.out_trade_no
  20575. if v == nil {
  20576. return
  20577. }
  20578. return *v, true
  20579. }
  20580. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  20581. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20582. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20583. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  20584. if !m.op.Is(OpUpdateOne) {
  20585. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  20586. }
  20587. if m.id == nil || m.oldValue == nil {
  20588. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  20589. }
  20590. oldValue, err := m.oldValue(ctx)
  20591. if err != nil {
  20592. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  20593. }
  20594. return oldValue.OutTradeNo, nil
  20595. }
  20596. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  20597. func (m *PayRechargeMutation) ClearOutTradeNo() {
  20598. m.out_trade_no = nil
  20599. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  20600. }
  20601. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  20602. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  20603. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  20604. return ok
  20605. }
  20606. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  20607. func (m *PayRechargeMutation) ResetOutTradeNo() {
  20608. m.out_trade_no = nil
  20609. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  20610. }
  20611. // SetOrganizationID sets the "organization_id" field.
  20612. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  20613. m.organization_id = &u
  20614. m.addorganization_id = nil
  20615. }
  20616. // OrganizationID returns the value of the "organization_id" field in the mutation.
  20617. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  20618. v := m.organization_id
  20619. if v == nil {
  20620. return
  20621. }
  20622. return *v, true
  20623. }
  20624. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  20625. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20626. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20627. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  20628. if !m.op.Is(OpUpdateOne) {
  20629. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  20630. }
  20631. if m.id == nil || m.oldValue == nil {
  20632. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  20633. }
  20634. oldValue, err := m.oldValue(ctx)
  20635. if err != nil {
  20636. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  20637. }
  20638. return oldValue.OrganizationID, nil
  20639. }
  20640. // AddOrganizationID adds u to the "organization_id" field.
  20641. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  20642. if m.addorganization_id != nil {
  20643. *m.addorganization_id += u
  20644. } else {
  20645. m.addorganization_id = &u
  20646. }
  20647. }
  20648. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  20649. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  20650. v := m.addorganization_id
  20651. if v == nil {
  20652. return
  20653. }
  20654. return *v, true
  20655. }
  20656. // ResetOrganizationID resets all changes to the "organization_id" field.
  20657. func (m *PayRechargeMutation) ResetOrganizationID() {
  20658. m.organization_id = nil
  20659. m.addorganization_id = nil
  20660. }
  20661. // Where appends a list predicates to the PayRechargeMutation builder.
  20662. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  20663. m.predicates = append(m.predicates, ps...)
  20664. }
  20665. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  20666. // users can use type-assertion to append predicates that do not depend on any generated package.
  20667. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  20668. p := make([]predicate.PayRecharge, len(ps))
  20669. for i := range ps {
  20670. p[i] = ps[i]
  20671. }
  20672. m.Where(p...)
  20673. }
  20674. // Op returns the operation name.
  20675. func (m *PayRechargeMutation) Op() Op {
  20676. return m.op
  20677. }
  20678. // SetOp allows setting the mutation operation.
  20679. func (m *PayRechargeMutation) SetOp(op Op) {
  20680. m.op = op
  20681. }
  20682. // Type returns the node type of this mutation (PayRecharge).
  20683. func (m *PayRechargeMutation) Type() string {
  20684. return m.typ
  20685. }
  20686. // Fields returns all fields that were changed during this mutation. Note that in
  20687. // order to get all numeric fields that were incremented/decremented, call
  20688. // AddedFields().
  20689. func (m *PayRechargeMutation) Fields() []string {
  20690. fields := make([]string, 0, 9)
  20691. if m.created_at != nil {
  20692. fields = append(fields, payrecharge.FieldCreatedAt)
  20693. }
  20694. if m.updated_at != nil {
  20695. fields = append(fields, payrecharge.FieldUpdatedAt)
  20696. }
  20697. if m.deleted_at != nil {
  20698. fields = append(fields, payrecharge.FieldDeletedAt)
  20699. }
  20700. if m.user_id != nil {
  20701. fields = append(fields, payrecharge.FieldUserID)
  20702. }
  20703. if m.number != nil {
  20704. fields = append(fields, payrecharge.FieldNumber)
  20705. }
  20706. if m.status != nil {
  20707. fields = append(fields, payrecharge.FieldStatus)
  20708. }
  20709. if m.money != nil {
  20710. fields = append(fields, payrecharge.FieldMoney)
  20711. }
  20712. if m.out_trade_no != nil {
  20713. fields = append(fields, payrecharge.FieldOutTradeNo)
  20714. }
  20715. if m.organization_id != nil {
  20716. fields = append(fields, payrecharge.FieldOrganizationID)
  20717. }
  20718. return fields
  20719. }
  20720. // Field returns the value of a field with the given name. The second boolean
  20721. // return value indicates that this field was not set, or was not defined in the
  20722. // schema.
  20723. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  20724. switch name {
  20725. case payrecharge.FieldCreatedAt:
  20726. return m.CreatedAt()
  20727. case payrecharge.FieldUpdatedAt:
  20728. return m.UpdatedAt()
  20729. case payrecharge.FieldDeletedAt:
  20730. return m.DeletedAt()
  20731. case payrecharge.FieldUserID:
  20732. return m.UserID()
  20733. case payrecharge.FieldNumber:
  20734. return m.Number()
  20735. case payrecharge.FieldStatus:
  20736. return m.Status()
  20737. case payrecharge.FieldMoney:
  20738. return m.Money()
  20739. case payrecharge.FieldOutTradeNo:
  20740. return m.OutTradeNo()
  20741. case payrecharge.FieldOrganizationID:
  20742. return m.OrganizationID()
  20743. }
  20744. return nil, false
  20745. }
  20746. // OldField returns the old value of the field from the database. An error is
  20747. // returned if the mutation operation is not UpdateOne, or the query to the
  20748. // database failed.
  20749. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20750. switch name {
  20751. case payrecharge.FieldCreatedAt:
  20752. return m.OldCreatedAt(ctx)
  20753. case payrecharge.FieldUpdatedAt:
  20754. return m.OldUpdatedAt(ctx)
  20755. case payrecharge.FieldDeletedAt:
  20756. return m.OldDeletedAt(ctx)
  20757. case payrecharge.FieldUserID:
  20758. return m.OldUserID(ctx)
  20759. case payrecharge.FieldNumber:
  20760. return m.OldNumber(ctx)
  20761. case payrecharge.FieldStatus:
  20762. return m.OldStatus(ctx)
  20763. case payrecharge.FieldMoney:
  20764. return m.OldMoney(ctx)
  20765. case payrecharge.FieldOutTradeNo:
  20766. return m.OldOutTradeNo(ctx)
  20767. case payrecharge.FieldOrganizationID:
  20768. return m.OldOrganizationID(ctx)
  20769. }
  20770. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  20771. }
  20772. // SetField sets the value of a field with the given name. It returns an error if
  20773. // the field is not defined in the schema, or if the type mismatched the field
  20774. // type.
  20775. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  20776. switch name {
  20777. case payrecharge.FieldCreatedAt:
  20778. v, ok := value.(time.Time)
  20779. if !ok {
  20780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20781. }
  20782. m.SetCreatedAt(v)
  20783. return nil
  20784. case payrecharge.FieldUpdatedAt:
  20785. v, ok := value.(time.Time)
  20786. if !ok {
  20787. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20788. }
  20789. m.SetUpdatedAt(v)
  20790. return nil
  20791. case payrecharge.FieldDeletedAt:
  20792. v, ok := value.(time.Time)
  20793. if !ok {
  20794. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20795. }
  20796. m.SetDeletedAt(v)
  20797. return nil
  20798. case payrecharge.FieldUserID:
  20799. v, ok := value.(string)
  20800. if !ok {
  20801. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20802. }
  20803. m.SetUserID(v)
  20804. return nil
  20805. case payrecharge.FieldNumber:
  20806. v, ok := value.(float32)
  20807. if !ok {
  20808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20809. }
  20810. m.SetNumber(v)
  20811. return nil
  20812. case payrecharge.FieldStatus:
  20813. v, ok := value.(int)
  20814. if !ok {
  20815. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20816. }
  20817. m.SetStatus(v)
  20818. return nil
  20819. case payrecharge.FieldMoney:
  20820. v, ok := value.(float32)
  20821. if !ok {
  20822. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20823. }
  20824. m.SetMoney(v)
  20825. return nil
  20826. case payrecharge.FieldOutTradeNo:
  20827. v, ok := value.(string)
  20828. if !ok {
  20829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20830. }
  20831. m.SetOutTradeNo(v)
  20832. return nil
  20833. case payrecharge.FieldOrganizationID:
  20834. v, ok := value.(uint64)
  20835. if !ok {
  20836. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20837. }
  20838. m.SetOrganizationID(v)
  20839. return nil
  20840. }
  20841. return fmt.Errorf("unknown PayRecharge field %s", name)
  20842. }
  20843. // AddedFields returns all numeric fields that were incremented/decremented during
  20844. // this mutation.
  20845. func (m *PayRechargeMutation) AddedFields() []string {
  20846. var fields []string
  20847. if m.addnumber != nil {
  20848. fields = append(fields, payrecharge.FieldNumber)
  20849. }
  20850. if m.addstatus != nil {
  20851. fields = append(fields, payrecharge.FieldStatus)
  20852. }
  20853. if m.addmoney != nil {
  20854. fields = append(fields, payrecharge.FieldMoney)
  20855. }
  20856. if m.addorganization_id != nil {
  20857. fields = append(fields, payrecharge.FieldOrganizationID)
  20858. }
  20859. return fields
  20860. }
  20861. // AddedField returns the numeric value that was incremented/decremented on a field
  20862. // with the given name. The second boolean return value indicates that this field
  20863. // was not set, or was not defined in the schema.
  20864. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  20865. switch name {
  20866. case payrecharge.FieldNumber:
  20867. return m.AddedNumber()
  20868. case payrecharge.FieldStatus:
  20869. return m.AddedStatus()
  20870. case payrecharge.FieldMoney:
  20871. return m.AddedMoney()
  20872. case payrecharge.FieldOrganizationID:
  20873. return m.AddedOrganizationID()
  20874. }
  20875. return nil, false
  20876. }
  20877. // AddField adds the value to the field with the given name. It returns an error if
  20878. // the field is not defined in the schema, or if the type mismatched the field
  20879. // type.
  20880. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  20881. switch name {
  20882. case payrecharge.FieldNumber:
  20883. v, ok := value.(float32)
  20884. if !ok {
  20885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20886. }
  20887. m.AddNumber(v)
  20888. return nil
  20889. case payrecharge.FieldStatus:
  20890. v, ok := value.(int)
  20891. if !ok {
  20892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20893. }
  20894. m.AddStatus(v)
  20895. return nil
  20896. case payrecharge.FieldMoney:
  20897. v, ok := value.(float32)
  20898. if !ok {
  20899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20900. }
  20901. m.AddMoney(v)
  20902. return nil
  20903. case payrecharge.FieldOrganizationID:
  20904. v, ok := value.(int64)
  20905. if !ok {
  20906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20907. }
  20908. m.AddOrganizationID(v)
  20909. return nil
  20910. }
  20911. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  20912. }
  20913. // ClearedFields returns all nullable fields that were cleared during this
  20914. // mutation.
  20915. func (m *PayRechargeMutation) ClearedFields() []string {
  20916. var fields []string
  20917. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  20918. fields = append(fields, payrecharge.FieldDeletedAt)
  20919. }
  20920. if m.FieldCleared(payrecharge.FieldStatus) {
  20921. fields = append(fields, payrecharge.FieldStatus)
  20922. }
  20923. if m.FieldCleared(payrecharge.FieldMoney) {
  20924. fields = append(fields, payrecharge.FieldMoney)
  20925. }
  20926. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  20927. fields = append(fields, payrecharge.FieldOutTradeNo)
  20928. }
  20929. return fields
  20930. }
  20931. // FieldCleared returns a boolean indicating if a field with the given name was
  20932. // cleared in this mutation.
  20933. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  20934. _, ok := m.clearedFields[name]
  20935. return ok
  20936. }
  20937. // ClearField clears the value of the field with the given name. It returns an
  20938. // error if the field is not defined in the schema.
  20939. func (m *PayRechargeMutation) ClearField(name string) error {
  20940. switch name {
  20941. case payrecharge.FieldDeletedAt:
  20942. m.ClearDeletedAt()
  20943. return nil
  20944. case payrecharge.FieldStatus:
  20945. m.ClearStatus()
  20946. return nil
  20947. case payrecharge.FieldMoney:
  20948. m.ClearMoney()
  20949. return nil
  20950. case payrecharge.FieldOutTradeNo:
  20951. m.ClearOutTradeNo()
  20952. return nil
  20953. }
  20954. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  20955. }
  20956. // ResetField resets all changes in the mutation for the field with the given name.
  20957. // It returns an error if the field is not defined in the schema.
  20958. func (m *PayRechargeMutation) ResetField(name string) error {
  20959. switch name {
  20960. case payrecharge.FieldCreatedAt:
  20961. m.ResetCreatedAt()
  20962. return nil
  20963. case payrecharge.FieldUpdatedAt:
  20964. m.ResetUpdatedAt()
  20965. return nil
  20966. case payrecharge.FieldDeletedAt:
  20967. m.ResetDeletedAt()
  20968. return nil
  20969. case payrecharge.FieldUserID:
  20970. m.ResetUserID()
  20971. return nil
  20972. case payrecharge.FieldNumber:
  20973. m.ResetNumber()
  20974. return nil
  20975. case payrecharge.FieldStatus:
  20976. m.ResetStatus()
  20977. return nil
  20978. case payrecharge.FieldMoney:
  20979. m.ResetMoney()
  20980. return nil
  20981. case payrecharge.FieldOutTradeNo:
  20982. m.ResetOutTradeNo()
  20983. return nil
  20984. case payrecharge.FieldOrganizationID:
  20985. m.ResetOrganizationID()
  20986. return nil
  20987. }
  20988. return fmt.Errorf("unknown PayRecharge field %s", name)
  20989. }
  20990. // AddedEdges returns all edge names that were set/added in this mutation.
  20991. func (m *PayRechargeMutation) AddedEdges() []string {
  20992. edges := make([]string, 0, 0)
  20993. return edges
  20994. }
  20995. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20996. // name in this mutation.
  20997. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  20998. return nil
  20999. }
  21000. // RemovedEdges returns all edge names that were removed in this mutation.
  21001. func (m *PayRechargeMutation) RemovedEdges() []string {
  21002. edges := make([]string, 0, 0)
  21003. return edges
  21004. }
  21005. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21006. // the given name in this mutation.
  21007. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  21008. return nil
  21009. }
  21010. // ClearedEdges returns all edge names that were cleared in this mutation.
  21011. func (m *PayRechargeMutation) ClearedEdges() []string {
  21012. edges := make([]string, 0, 0)
  21013. return edges
  21014. }
  21015. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21016. // was cleared in this mutation.
  21017. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  21018. return false
  21019. }
  21020. // ClearEdge clears the value of the edge with the given name. It returns an error
  21021. // if that edge is not defined in the schema.
  21022. func (m *PayRechargeMutation) ClearEdge(name string) error {
  21023. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  21024. }
  21025. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21026. // It returns an error if the edge is not defined in the schema.
  21027. func (m *PayRechargeMutation) ResetEdge(name string) error {
  21028. return fmt.Errorf("unknown PayRecharge edge %s", name)
  21029. }
  21030. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  21031. type ServerMutation struct {
  21032. config
  21033. op Op
  21034. typ string
  21035. id *uint64
  21036. created_at *time.Time
  21037. updated_at *time.Time
  21038. status *uint8
  21039. addstatus *int8
  21040. deleted_at *time.Time
  21041. name *string
  21042. public_ip *string
  21043. private_ip *string
  21044. admin_port *string
  21045. clearedFields map[string]struct{}
  21046. wxs map[uint64]struct{}
  21047. removedwxs map[uint64]struct{}
  21048. clearedwxs bool
  21049. done bool
  21050. oldValue func(context.Context) (*Server, error)
  21051. predicates []predicate.Server
  21052. }
  21053. var _ ent.Mutation = (*ServerMutation)(nil)
  21054. // serverOption allows management of the mutation configuration using functional options.
  21055. type serverOption func(*ServerMutation)
  21056. // newServerMutation creates new mutation for the Server entity.
  21057. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  21058. m := &ServerMutation{
  21059. config: c,
  21060. op: op,
  21061. typ: TypeServer,
  21062. clearedFields: make(map[string]struct{}),
  21063. }
  21064. for _, opt := range opts {
  21065. opt(m)
  21066. }
  21067. return m
  21068. }
  21069. // withServerID sets the ID field of the mutation.
  21070. func withServerID(id uint64) serverOption {
  21071. return func(m *ServerMutation) {
  21072. var (
  21073. err error
  21074. once sync.Once
  21075. value *Server
  21076. )
  21077. m.oldValue = func(ctx context.Context) (*Server, error) {
  21078. once.Do(func() {
  21079. if m.done {
  21080. err = errors.New("querying old values post mutation is not allowed")
  21081. } else {
  21082. value, err = m.Client().Server.Get(ctx, id)
  21083. }
  21084. })
  21085. return value, err
  21086. }
  21087. m.id = &id
  21088. }
  21089. }
  21090. // withServer sets the old Server of the mutation.
  21091. func withServer(node *Server) serverOption {
  21092. return func(m *ServerMutation) {
  21093. m.oldValue = func(context.Context) (*Server, error) {
  21094. return node, nil
  21095. }
  21096. m.id = &node.ID
  21097. }
  21098. }
  21099. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21100. // executed in a transaction (ent.Tx), a transactional client is returned.
  21101. func (m ServerMutation) Client() *Client {
  21102. client := &Client{config: m.config}
  21103. client.init()
  21104. return client
  21105. }
  21106. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21107. // it returns an error otherwise.
  21108. func (m ServerMutation) Tx() (*Tx, error) {
  21109. if _, ok := m.driver.(*txDriver); !ok {
  21110. return nil, errors.New("ent: mutation is not running in a transaction")
  21111. }
  21112. tx := &Tx{config: m.config}
  21113. tx.init()
  21114. return tx, nil
  21115. }
  21116. // SetID sets the value of the id field. Note that this
  21117. // operation is only accepted on creation of Server entities.
  21118. func (m *ServerMutation) SetID(id uint64) {
  21119. m.id = &id
  21120. }
  21121. // ID returns the ID value in the mutation. Note that the ID is only available
  21122. // if it was provided to the builder or after it was returned from the database.
  21123. func (m *ServerMutation) ID() (id uint64, exists bool) {
  21124. if m.id == nil {
  21125. return
  21126. }
  21127. return *m.id, true
  21128. }
  21129. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21130. // That means, if the mutation is applied within a transaction with an isolation level such
  21131. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21132. // or updated by the mutation.
  21133. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  21134. switch {
  21135. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21136. id, exists := m.ID()
  21137. if exists {
  21138. return []uint64{id}, nil
  21139. }
  21140. fallthrough
  21141. case m.op.Is(OpUpdate | OpDelete):
  21142. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  21143. default:
  21144. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21145. }
  21146. }
  21147. // SetCreatedAt sets the "created_at" field.
  21148. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  21149. m.created_at = &t
  21150. }
  21151. // CreatedAt returns the value of the "created_at" field in the mutation.
  21152. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  21153. v := m.created_at
  21154. if v == nil {
  21155. return
  21156. }
  21157. return *v, true
  21158. }
  21159. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  21160. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21161. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21162. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21163. if !m.op.Is(OpUpdateOne) {
  21164. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21165. }
  21166. if m.id == nil || m.oldValue == nil {
  21167. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21168. }
  21169. oldValue, err := m.oldValue(ctx)
  21170. if err != nil {
  21171. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21172. }
  21173. return oldValue.CreatedAt, nil
  21174. }
  21175. // ResetCreatedAt resets all changes to the "created_at" field.
  21176. func (m *ServerMutation) ResetCreatedAt() {
  21177. m.created_at = nil
  21178. }
  21179. // SetUpdatedAt sets the "updated_at" field.
  21180. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  21181. m.updated_at = &t
  21182. }
  21183. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21184. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  21185. v := m.updated_at
  21186. if v == nil {
  21187. return
  21188. }
  21189. return *v, true
  21190. }
  21191. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  21192. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21193. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21194. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21195. if !m.op.Is(OpUpdateOne) {
  21196. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21197. }
  21198. if m.id == nil || m.oldValue == nil {
  21199. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21200. }
  21201. oldValue, err := m.oldValue(ctx)
  21202. if err != nil {
  21203. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21204. }
  21205. return oldValue.UpdatedAt, nil
  21206. }
  21207. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21208. func (m *ServerMutation) ResetUpdatedAt() {
  21209. m.updated_at = nil
  21210. }
  21211. // SetStatus sets the "status" field.
  21212. func (m *ServerMutation) SetStatus(u uint8) {
  21213. m.status = &u
  21214. m.addstatus = nil
  21215. }
  21216. // Status returns the value of the "status" field in the mutation.
  21217. func (m *ServerMutation) Status() (r uint8, exists bool) {
  21218. v := m.status
  21219. if v == nil {
  21220. return
  21221. }
  21222. return *v, true
  21223. }
  21224. // OldStatus returns the old "status" field's value of the Server entity.
  21225. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21226. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21227. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  21228. if !m.op.Is(OpUpdateOne) {
  21229. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  21230. }
  21231. if m.id == nil || m.oldValue == nil {
  21232. return v, errors.New("OldStatus requires an ID field in the mutation")
  21233. }
  21234. oldValue, err := m.oldValue(ctx)
  21235. if err != nil {
  21236. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  21237. }
  21238. return oldValue.Status, nil
  21239. }
  21240. // AddStatus adds u to the "status" field.
  21241. func (m *ServerMutation) AddStatus(u int8) {
  21242. if m.addstatus != nil {
  21243. *m.addstatus += u
  21244. } else {
  21245. m.addstatus = &u
  21246. }
  21247. }
  21248. // AddedStatus returns the value that was added to the "status" field in this mutation.
  21249. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  21250. v := m.addstatus
  21251. if v == nil {
  21252. return
  21253. }
  21254. return *v, true
  21255. }
  21256. // ClearStatus clears the value of the "status" field.
  21257. func (m *ServerMutation) ClearStatus() {
  21258. m.status = nil
  21259. m.addstatus = nil
  21260. m.clearedFields[server.FieldStatus] = struct{}{}
  21261. }
  21262. // StatusCleared returns if the "status" field was cleared in this mutation.
  21263. func (m *ServerMutation) StatusCleared() bool {
  21264. _, ok := m.clearedFields[server.FieldStatus]
  21265. return ok
  21266. }
  21267. // ResetStatus resets all changes to the "status" field.
  21268. func (m *ServerMutation) ResetStatus() {
  21269. m.status = nil
  21270. m.addstatus = nil
  21271. delete(m.clearedFields, server.FieldStatus)
  21272. }
  21273. // SetDeletedAt sets the "deleted_at" field.
  21274. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  21275. m.deleted_at = &t
  21276. }
  21277. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21278. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  21279. v := m.deleted_at
  21280. if v == nil {
  21281. return
  21282. }
  21283. return *v, true
  21284. }
  21285. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  21286. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21287. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21288. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21289. if !m.op.Is(OpUpdateOne) {
  21290. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21291. }
  21292. if m.id == nil || m.oldValue == nil {
  21293. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21294. }
  21295. oldValue, err := m.oldValue(ctx)
  21296. if err != nil {
  21297. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21298. }
  21299. return oldValue.DeletedAt, nil
  21300. }
  21301. // ClearDeletedAt clears the value of the "deleted_at" field.
  21302. func (m *ServerMutation) ClearDeletedAt() {
  21303. m.deleted_at = nil
  21304. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  21305. }
  21306. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21307. func (m *ServerMutation) DeletedAtCleared() bool {
  21308. _, ok := m.clearedFields[server.FieldDeletedAt]
  21309. return ok
  21310. }
  21311. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21312. func (m *ServerMutation) ResetDeletedAt() {
  21313. m.deleted_at = nil
  21314. delete(m.clearedFields, server.FieldDeletedAt)
  21315. }
  21316. // SetName sets the "name" field.
  21317. func (m *ServerMutation) SetName(s string) {
  21318. m.name = &s
  21319. }
  21320. // Name returns the value of the "name" field in the mutation.
  21321. func (m *ServerMutation) Name() (r string, exists bool) {
  21322. v := m.name
  21323. if v == nil {
  21324. return
  21325. }
  21326. return *v, true
  21327. }
  21328. // OldName returns the old "name" field's value of the Server entity.
  21329. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21330. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21331. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  21332. if !m.op.Is(OpUpdateOne) {
  21333. return v, errors.New("OldName is only allowed on UpdateOne operations")
  21334. }
  21335. if m.id == nil || m.oldValue == nil {
  21336. return v, errors.New("OldName requires an ID field in the mutation")
  21337. }
  21338. oldValue, err := m.oldValue(ctx)
  21339. if err != nil {
  21340. return v, fmt.Errorf("querying old value for OldName: %w", err)
  21341. }
  21342. return oldValue.Name, nil
  21343. }
  21344. // ResetName resets all changes to the "name" field.
  21345. func (m *ServerMutation) ResetName() {
  21346. m.name = nil
  21347. }
  21348. // SetPublicIP sets the "public_ip" field.
  21349. func (m *ServerMutation) SetPublicIP(s string) {
  21350. m.public_ip = &s
  21351. }
  21352. // PublicIP returns the value of the "public_ip" field in the mutation.
  21353. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  21354. v := m.public_ip
  21355. if v == nil {
  21356. return
  21357. }
  21358. return *v, true
  21359. }
  21360. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  21361. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21363. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  21364. if !m.op.Is(OpUpdateOne) {
  21365. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  21366. }
  21367. if m.id == nil || m.oldValue == nil {
  21368. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  21369. }
  21370. oldValue, err := m.oldValue(ctx)
  21371. if err != nil {
  21372. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  21373. }
  21374. return oldValue.PublicIP, nil
  21375. }
  21376. // ResetPublicIP resets all changes to the "public_ip" field.
  21377. func (m *ServerMutation) ResetPublicIP() {
  21378. m.public_ip = nil
  21379. }
  21380. // SetPrivateIP sets the "private_ip" field.
  21381. func (m *ServerMutation) SetPrivateIP(s string) {
  21382. m.private_ip = &s
  21383. }
  21384. // PrivateIP returns the value of the "private_ip" field in the mutation.
  21385. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  21386. v := m.private_ip
  21387. if v == nil {
  21388. return
  21389. }
  21390. return *v, true
  21391. }
  21392. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  21393. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21395. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  21396. if !m.op.Is(OpUpdateOne) {
  21397. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  21398. }
  21399. if m.id == nil || m.oldValue == nil {
  21400. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  21401. }
  21402. oldValue, err := m.oldValue(ctx)
  21403. if err != nil {
  21404. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  21405. }
  21406. return oldValue.PrivateIP, nil
  21407. }
  21408. // ResetPrivateIP resets all changes to the "private_ip" field.
  21409. func (m *ServerMutation) ResetPrivateIP() {
  21410. m.private_ip = nil
  21411. }
  21412. // SetAdminPort sets the "admin_port" field.
  21413. func (m *ServerMutation) SetAdminPort(s string) {
  21414. m.admin_port = &s
  21415. }
  21416. // AdminPort returns the value of the "admin_port" field in the mutation.
  21417. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  21418. v := m.admin_port
  21419. if v == nil {
  21420. return
  21421. }
  21422. return *v, true
  21423. }
  21424. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  21425. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21426. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21427. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  21428. if !m.op.Is(OpUpdateOne) {
  21429. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  21430. }
  21431. if m.id == nil || m.oldValue == nil {
  21432. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  21433. }
  21434. oldValue, err := m.oldValue(ctx)
  21435. if err != nil {
  21436. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  21437. }
  21438. return oldValue.AdminPort, nil
  21439. }
  21440. // ResetAdminPort resets all changes to the "admin_port" field.
  21441. func (m *ServerMutation) ResetAdminPort() {
  21442. m.admin_port = nil
  21443. }
  21444. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  21445. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  21446. if m.wxs == nil {
  21447. m.wxs = make(map[uint64]struct{})
  21448. }
  21449. for i := range ids {
  21450. m.wxs[ids[i]] = struct{}{}
  21451. }
  21452. }
  21453. // ClearWxs clears the "wxs" edge to the Wx entity.
  21454. func (m *ServerMutation) ClearWxs() {
  21455. m.clearedwxs = true
  21456. }
  21457. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  21458. func (m *ServerMutation) WxsCleared() bool {
  21459. return m.clearedwxs
  21460. }
  21461. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  21462. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  21463. if m.removedwxs == nil {
  21464. m.removedwxs = make(map[uint64]struct{})
  21465. }
  21466. for i := range ids {
  21467. delete(m.wxs, ids[i])
  21468. m.removedwxs[ids[i]] = struct{}{}
  21469. }
  21470. }
  21471. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  21472. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  21473. for id := range m.removedwxs {
  21474. ids = append(ids, id)
  21475. }
  21476. return
  21477. }
  21478. // WxsIDs returns the "wxs" edge IDs in the mutation.
  21479. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  21480. for id := range m.wxs {
  21481. ids = append(ids, id)
  21482. }
  21483. return
  21484. }
  21485. // ResetWxs resets all changes to the "wxs" edge.
  21486. func (m *ServerMutation) ResetWxs() {
  21487. m.wxs = nil
  21488. m.clearedwxs = false
  21489. m.removedwxs = nil
  21490. }
  21491. // Where appends a list predicates to the ServerMutation builder.
  21492. func (m *ServerMutation) Where(ps ...predicate.Server) {
  21493. m.predicates = append(m.predicates, ps...)
  21494. }
  21495. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  21496. // users can use type-assertion to append predicates that do not depend on any generated package.
  21497. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  21498. p := make([]predicate.Server, len(ps))
  21499. for i := range ps {
  21500. p[i] = ps[i]
  21501. }
  21502. m.Where(p...)
  21503. }
  21504. // Op returns the operation name.
  21505. func (m *ServerMutation) Op() Op {
  21506. return m.op
  21507. }
  21508. // SetOp allows setting the mutation operation.
  21509. func (m *ServerMutation) SetOp(op Op) {
  21510. m.op = op
  21511. }
  21512. // Type returns the node type of this mutation (Server).
  21513. func (m *ServerMutation) Type() string {
  21514. return m.typ
  21515. }
  21516. // Fields returns all fields that were changed during this mutation. Note that in
  21517. // order to get all numeric fields that were incremented/decremented, call
  21518. // AddedFields().
  21519. func (m *ServerMutation) Fields() []string {
  21520. fields := make([]string, 0, 8)
  21521. if m.created_at != nil {
  21522. fields = append(fields, server.FieldCreatedAt)
  21523. }
  21524. if m.updated_at != nil {
  21525. fields = append(fields, server.FieldUpdatedAt)
  21526. }
  21527. if m.status != nil {
  21528. fields = append(fields, server.FieldStatus)
  21529. }
  21530. if m.deleted_at != nil {
  21531. fields = append(fields, server.FieldDeletedAt)
  21532. }
  21533. if m.name != nil {
  21534. fields = append(fields, server.FieldName)
  21535. }
  21536. if m.public_ip != nil {
  21537. fields = append(fields, server.FieldPublicIP)
  21538. }
  21539. if m.private_ip != nil {
  21540. fields = append(fields, server.FieldPrivateIP)
  21541. }
  21542. if m.admin_port != nil {
  21543. fields = append(fields, server.FieldAdminPort)
  21544. }
  21545. return fields
  21546. }
  21547. // Field returns the value of a field with the given name. The second boolean
  21548. // return value indicates that this field was not set, or was not defined in the
  21549. // schema.
  21550. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  21551. switch name {
  21552. case server.FieldCreatedAt:
  21553. return m.CreatedAt()
  21554. case server.FieldUpdatedAt:
  21555. return m.UpdatedAt()
  21556. case server.FieldStatus:
  21557. return m.Status()
  21558. case server.FieldDeletedAt:
  21559. return m.DeletedAt()
  21560. case server.FieldName:
  21561. return m.Name()
  21562. case server.FieldPublicIP:
  21563. return m.PublicIP()
  21564. case server.FieldPrivateIP:
  21565. return m.PrivateIP()
  21566. case server.FieldAdminPort:
  21567. return m.AdminPort()
  21568. }
  21569. return nil, false
  21570. }
  21571. // OldField returns the old value of the field from the database. An error is
  21572. // returned if the mutation operation is not UpdateOne, or the query to the
  21573. // database failed.
  21574. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21575. switch name {
  21576. case server.FieldCreatedAt:
  21577. return m.OldCreatedAt(ctx)
  21578. case server.FieldUpdatedAt:
  21579. return m.OldUpdatedAt(ctx)
  21580. case server.FieldStatus:
  21581. return m.OldStatus(ctx)
  21582. case server.FieldDeletedAt:
  21583. return m.OldDeletedAt(ctx)
  21584. case server.FieldName:
  21585. return m.OldName(ctx)
  21586. case server.FieldPublicIP:
  21587. return m.OldPublicIP(ctx)
  21588. case server.FieldPrivateIP:
  21589. return m.OldPrivateIP(ctx)
  21590. case server.FieldAdminPort:
  21591. return m.OldAdminPort(ctx)
  21592. }
  21593. return nil, fmt.Errorf("unknown Server field %s", name)
  21594. }
  21595. // SetField sets the value of a field with the given name. It returns an error if
  21596. // the field is not defined in the schema, or if the type mismatched the field
  21597. // type.
  21598. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  21599. switch name {
  21600. case server.FieldCreatedAt:
  21601. v, ok := value.(time.Time)
  21602. if !ok {
  21603. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21604. }
  21605. m.SetCreatedAt(v)
  21606. return nil
  21607. case server.FieldUpdatedAt:
  21608. v, ok := value.(time.Time)
  21609. if !ok {
  21610. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21611. }
  21612. m.SetUpdatedAt(v)
  21613. return nil
  21614. case server.FieldStatus:
  21615. v, ok := value.(uint8)
  21616. if !ok {
  21617. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21618. }
  21619. m.SetStatus(v)
  21620. return nil
  21621. case server.FieldDeletedAt:
  21622. v, ok := value.(time.Time)
  21623. if !ok {
  21624. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21625. }
  21626. m.SetDeletedAt(v)
  21627. return nil
  21628. case server.FieldName:
  21629. v, ok := value.(string)
  21630. if !ok {
  21631. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21632. }
  21633. m.SetName(v)
  21634. return nil
  21635. case server.FieldPublicIP:
  21636. v, ok := value.(string)
  21637. if !ok {
  21638. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21639. }
  21640. m.SetPublicIP(v)
  21641. return nil
  21642. case server.FieldPrivateIP:
  21643. v, ok := value.(string)
  21644. if !ok {
  21645. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21646. }
  21647. m.SetPrivateIP(v)
  21648. return nil
  21649. case server.FieldAdminPort:
  21650. v, ok := value.(string)
  21651. if !ok {
  21652. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21653. }
  21654. m.SetAdminPort(v)
  21655. return nil
  21656. }
  21657. return fmt.Errorf("unknown Server field %s", name)
  21658. }
  21659. // AddedFields returns all numeric fields that were incremented/decremented during
  21660. // this mutation.
  21661. func (m *ServerMutation) AddedFields() []string {
  21662. var fields []string
  21663. if m.addstatus != nil {
  21664. fields = append(fields, server.FieldStatus)
  21665. }
  21666. return fields
  21667. }
  21668. // AddedField returns the numeric value that was incremented/decremented on a field
  21669. // with the given name. The second boolean return value indicates that this field
  21670. // was not set, or was not defined in the schema.
  21671. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  21672. switch name {
  21673. case server.FieldStatus:
  21674. return m.AddedStatus()
  21675. }
  21676. return nil, false
  21677. }
  21678. // AddField adds the value to the field with the given name. It returns an error if
  21679. // the field is not defined in the schema, or if the type mismatched the field
  21680. // type.
  21681. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  21682. switch name {
  21683. case server.FieldStatus:
  21684. v, ok := value.(int8)
  21685. if !ok {
  21686. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21687. }
  21688. m.AddStatus(v)
  21689. return nil
  21690. }
  21691. return fmt.Errorf("unknown Server numeric field %s", name)
  21692. }
  21693. // ClearedFields returns all nullable fields that were cleared during this
  21694. // mutation.
  21695. func (m *ServerMutation) ClearedFields() []string {
  21696. var fields []string
  21697. if m.FieldCleared(server.FieldStatus) {
  21698. fields = append(fields, server.FieldStatus)
  21699. }
  21700. if m.FieldCleared(server.FieldDeletedAt) {
  21701. fields = append(fields, server.FieldDeletedAt)
  21702. }
  21703. return fields
  21704. }
  21705. // FieldCleared returns a boolean indicating if a field with the given name was
  21706. // cleared in this mutation.
  21707. func (m *ServerMutation) FieldCleared(name string) bool {
  21708. _, ok := m.clearedFields[name]
  21709. return ok
  21710. }
  21711. // ClearField clears the value of the field with the given name. It returns an
  21712. // error if the field is not defined in the schema.
  21713. func (m *ServerMutation) ClearField(name string) error {
  21714. switch name {
  21715. case server.FieldStatus:
  21716. m.ClearStatus()
  21717. return nil
  21718. case server.FieldDeletedAt:
  21719. m.ClearDeletedAt()
  21720. return nil
  21721. }
  21722. return fmt.Errorf("unknown Server nullable field %s", name)
  21723. }
  21724. // ResetField resets all changes in the mutation for the field with the given name.
  21725. // It returns an error if the field is not defined in the schema.
  21726. func (m *ServerMutation) ResetField(name string) error {
  21727. switch name {
  21728. case server.FieldCreatedAt:
  21729. m.ResetCreatedAt()
  21730. return nil
  21731. case server.FieldUpdatedAt:
  21732. m.ResetUpdatedAt()
  21733. return nil
  21734. case server.FieldStatus:
  21735. m.ResetStatus()
  21736. return nil
  21737. case server.FieldDeletedAt:
  21738. m.ResetDeletedAt()
  21739. return nil
  21740. case server.FieldName:
  21741. m.ResetName()
  21742. return nil
  21743. case server.FieldPublicIP:
  21744. m.ResetPublicIP()
  21745. return nil
  21746. case server.FieldPrivateIP:
  21747. m.ResetPrivateIP()
  21748. return nil
  21749. case server.FieldAdminPort:
  21750. m.ResetAdminPort()
  21751. return nil
  21752. }
  21753. return fmt.Errorf("unknown Server field %s", name)
  21754. }
  21755. // AddedEdges returns all edge names that were set/added in this mutation.
  21756. func (m *ServerMutation) AddedEdges() []string {
  21757. edges := make([]string, 0, 1)
  21758. if m.wxs != nil {
  21759. edges = append(edges, server.EdgeWxs)
  21760. }
  21761. return edges
  21762. }
  21763. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21764. // name in this mutation.
  21765. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  21766. switch name {
  21767. case server.EdgeWxs:
  21768. ids := make([]ent.Value, 0, len(m.wxs))
  21769. for id := range m.wxs {
  21770. ids = append(ids, id)
  21771. }
  21772. return ids
  21773. }
  21774. return nil
  21775. }
  21776. // RemovedEdges returns all edge names that were removed in this mutation.
  21777. func (m *ServerMutation) RemovedEdges() []string {
  21778. edges := make([]string, 0, 1)
  21779. if m.removedwxs != nil {
  21780. edges = append(edges, server.EdgeWxs)
  21781. }
  21782. return edges
  21783. }
  21784. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21785. // the given name in this mutation.
  21786. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  21787. switch name {
  21788. case server.EdgeWxs:
  21789. ids := make([]ent.Value, 0, len(m.removedwxs))
  21790. for id := range m.removedwxs {
  21791. ids = append(ids, id)
  21792. }
  21793. return ids
  21794. }
  21795. return nil
  21796. }
  21797. // ClearedEdges returns all edge names that were cleared in this mutation.
  21798. func (m *ServerMutation) ClearedEdges() []string {
  21799. edges := make([]string, 0, 1)
  21800. if m.clearedwxs {
  21801. edges = append(edges, server.EdgeWxs)
  21802. }
  21803. return edges
  21804. }
  21805. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21806. // was cleared in this mutation.
  21807. func (m *ServerMutation) EdgeCleared(name string) bool {
  21808. switch name {
  21809. case server.EdgeWxs:
  21810. return m.clearedwxs
  21811. }
  21812. return false
  21813. }
  21814. // ClearEdge clears the value of the edge with the given name. It returns an error
  21815. // if that edge is not defined in the schema.
  21816. func (m *ServerMutation) ClearEdge(name string) error {
  21817. switch name {
  21818. }
  21819. return fmt.Errorf("unknown Server unique edge %s", name)
  21820. }
  21821. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21822. // It returns an error if the edge is not defined in the schema.
  21823. func (m *ServerMutation) ResetEdge(name string) error {
  21824. switch name {
  21825. case server.EdgeWxs:
  21826. m.ResetWxs()
  21827. return nil
  21828. }
  21829. return fmt.Errorf("unknown Server edge %s", name)
  21830. }
  21831. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  21832. type SopNodeMutation struct {
  21833. config
  21834. op Op
  21835. typ string
  21836. id *uint64
  21837. created_at *time.Time
  21838. updated_at *time.Time
  21839. status *uint8
  21840. addstatus *int8
  21841. deleted_at *time.Time
  21842. parent_id *uint64
  21843. addparent_id *int64
  21844. name *string
  21845. condition_type *int
  21846. addcondition_type *int
  21847. condition_list *[]string
  21848. appendcondition_list []string
  21849. no_reply_condition *uint64
  21850. addno_reply_condition *int64
  21851. no_reply_unit *string
  21852. action_message *[]custom_types.Action
  21853. appendaction_message []custom_types.Action
  21854. action_label_add *[]uint64
  21855. appendaction_label_add []uint64
  21856. action_label_del *[]uint64
  21857. appendaction_label_del []uint64
  21858. action_forward **custom_types.ActionForward
  21859. clearedFields map[string]struct{}
  21860. sop_stage *uint64
  21861. clearedsop_stage bool
  21862. node_messages map[uint64]struct{}
  21863. removednode_messages map[uint64]struct{}
  21864. clearednode_messages bool
  21865. done bool
  21866. oldValue func(context.Context) (*SopNode, error)
  21867. predicates []predicate.SopNode
  21868. }
  21869. var _ ent.Mutation = (*SopNodeMutation)(nil)
  21870. // sopnodeOption allows management of the mutation configuration using functional options.
  21871. type sopnodeOption func(*SopNodeMutation)
  21872. // newSopNodeMutation creates new mutation for the SopNode entity.
  21873. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  21874. m := &SopNodeMutation{
  21875. config: c,
  21876. op: op,
  21877. typ: TypeSopNode,
  21878. clearedFields: make(map[string]struct{}),
  21879. }
  21880. for _, opt := range opts {
  21881. opt(m)
  21882. }
  21883. return m
  21884. }
  21885. // withSopNodeID sets the ID field of the mutation.
  21886. func withSopNodeID(id uint64) sopnodeOption {
  21887. return func(m *SopNodeMutation) {
  21888. var (
  21889. err error
  21890. once sync.Once
  21891. value *SopNode
  21892. )
  21893. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  21894. once.Do(func() {
  21895. if m.done {
  21896. err = errors.New("querying old values post mutation is not allowed")
  21897. } else {
  21898. value, err = m.Client().SopNode.Get(ctx, id)
  21899. }
  21900. })
  21901. return value, err
  21902. }
  21903. m.id = &id
  21904. }
  21905. }
  21906. // withSopNode sets the old SopNode of the mutation.
  21907. func withSopNode(node *SopNode) sopnodeOption {
  21908. return func(m *SopNodeMutation) {
  21909. m.oldValue = func(context.Context) (*SopNode, error) {
  21910. return node, nil
  21911. }
  21912. m.id = &node.ID
  21913. }
  21914. }
  21915. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21916. // executed in a transaction (ent.Tx), a transactional client is returned.
  21917. func (m SopNodeMutation) Client() *Client {
  21918. client := &Client{config: m.config}
  21919. client.init()
  21920. return client
  21921. }
  21922. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21923. // it returns an error otherwise.
  21924. func (m SopNodeMutation) Tx() (*Tx, error) {
  21925. if _, ok := m.driver.(*txDriver); !ok {
  21926. return nil, errors.New("ent: mutation is not running in a transaction")
  21927. }
  21928. tx := &Tx{config: m.config}
  21929. tx.init()
  21930. return tx, nil
  21931. }
  21932. // SetID sets the value of the id field. Note that this
  21933. // operation is only accepted on creation of SopNode entities.
  21934. func (m *SopNodeMutation) SetID(id uint64) {
  21935. m.id = &id
  21936. }
  21937. // ID returns the ID value in the mutation. Note that the ID is only available
  21938. // if it was provided to the builder or after it was returned from the database.
  21939. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  21940. if m.id == nil {
  21941. return
  21942. }
  21943. return *m.id, true
  21944. }
  21945. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21946. // That means, if the mutation is applied within a transaction with an isolation level such
  21947. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21948. // or updated by the mutation.
  21949. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  21950. switch {
  21951. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21952. id, exists := m.ID()
  21953. if exists {
  21954. return []uint64{id}, nil
  21955. }
  21956. fallthrough
  21957. case m.op.Is(OpUpdate | OpDelete):
  21958. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  21959. default:
  21960. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21961. }
  21962. }
  21963. // SetCreatedAt sets the "created_at" field.
  21964. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  21965. m.created_at = &t
  21966. }
  21967. // CreatedAt returns the value of the "created_at" field in the mutation.
  21968. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  21969. v := m.created_at
  21970. if v == nil {
  21971. return
  21972. }
  21973. return *v, true
  21974. }
  21975. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  21976. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21977. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21978. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21979. if !m.op.Is(OpUpdateOne) {
  21980. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21981. }
  21982. if m.id == nil || m.oldValue == nil {
  21983. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21984. }
  21985. oldValue, err := m.oldValue(ctx)
  21986. if err != nil {
  21987. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21988. }
  21989. return oldValue.CreatedAt, nil
  21990. }
  21991. // ResetCreatedAt resets all changes to the "created_at" field.
  21992. func (m *SopNodeMutation) ResetCreatedAt() {
  21993. m.created_at = nil
  21994. }
  21995. // SetUpdatedAt sets the "updated_at" field.
  21996. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  21997. m.updated_at = &t
  21998. }
  21999. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22000. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  22001. v := m.updated_at
  22002. if v == nil {
  22003. return
  22004. }
  22005. return *v, true
  22006. }
  22007. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  22008. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22009. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22010. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22011. if !m.op.Is(OpUpdateOne) {
  22012. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22013. }
  22014. if m.id == nil || m.oldValue == nil {
  22015. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22016. }
  22017. oldValue, err := m.oldValue(ctx)
  22018. if err != nil {
  22019. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22020. }
  22021. return oldValue.UpdatedAt, nil
  22022. }
  22023. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22024. func (m *SopNodeMutation) ResetUpdatedAt() {
  22025. m.updated_at = nil
  22026. }
  22027. // SetStatus sets the "status" field.
  22028. func (m *SopNodeMutation) SetStatus(u uint8) {
  22029. m.status = &u
  22030. m.addstatus = nil
  22031. }
  22032. // Status returns the value of the "status" field in the mutation.
  22033. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  22034. v := m.status
  22035. if v == nil {
  22036. return
  22037. }
  22038. return *v, true
  22039. }
  22040. // OldStatus returns the old "status" field's value of the SopNode entity.
  22041. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22042. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22043. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22044. if !m.op.Is(OpUpdateOne) {
  22045. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22046. }
  22047. if m.id == nil || m.oldValue == nil {
  22048. return v, errors.New("OldStatus requires an ID field in the mutation")
  22049. }
  22050. oldValue, err := m.oldValue(ctx)
  22051. if err != nil {
  22052. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22053. }
  22054. return oldValue.Status, nil
  22055. }
  22056. // AddStatus adds u to the "status" field.
  22057. func (m *SopNodeMutation) AddStatus(u int8) {
  22058. if m.addstatus != nil {
  22059. *m.addstatus += u
  22060. } else {
  22061. m.addstatus = &u
  22062. }
  22063. }
  22064. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22065. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  22066. v := m.addstatus
  22067. if v == nil {
  22068. return
  22069. }
  22070. return *v, true
  22071. }
  22072. // ClearStatus clears the value of the "status" field.
  22073. func (m *SopNodeMutation) ClearStatus() {
  22074. m.status = nil
  22075. m.addstatus = nil
  22076. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  22077. }
  22078. // StatusCleared returns if the "status" field was cleared in this mutation.
  22079. func (m *SopNodeMutation) StatusCleared() bool {
  22080. _, ok := m.clearedFields[sopnode.FieldStatus]
  22081. return ok
  22082. }
  22083. // ResetStatus resets all changes to the "status" field.
  22084. func (m *SopNodeMutation) ResetStatus() {
  22085. m.status = nil
  22086. m.addstatus = nil
  22087. delete(m.clearedFields, sopnode.FieldStatus)
  22088. }
  22089. // SetDeletedAt sets the "deleted_at" field.
  22090. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  22091. m.deleted_at = &t
  22092. }
  22093. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22094. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  22095. v := m.deleted_at
  22096. if v == nil {
  22097. return
  22098. }
  22099. return *v, true
  22100. }
  22101. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  22102. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22103. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22104. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22105. if !m.op.Is(OpUpdateOne) {
  22106. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22107. }
  22108. if m.id == nil || m.oldValue == nil {
  22109. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22110. }
  22111. oldValue, err := m.oldValue(ctx)
  22112. if err != nil {
  22113. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22114. }
  22115. return oldValue.DeletedAt, nil
  22116. }
  22117. // ClearDeletedAt clears the value of the "deleted_at" field.
  22118. func (m *SopNodeMutation) ClearDeletedAt() {
  22119. m.deleted_at = nil
  22120. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  22121. }
  22122. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22123. func (m *SopNodeMutation) DeletedAtCleared() bool {
  22124. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  22125. return ok
  22126. }
  22127. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22128. func (m *SopNodeMutation) ResetDeletedAt() {
  22129. m.deleted_at = nil
  22130. delete(m.clearedFields, sopnode.FieldDeletedAt)
  22131. }
  22132. // SetStageID sets the "stage_id" field.
  22133. func (m *SopNodeMutation) SetStageID(u uint64) {
  22134. m.sop_stage = &u
  22135. }
  22136. // StageID returns the value of the "stage_id" field in the mutation.
  22137. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  22138. v := m.sop_stage
  22139. if v == nil {
  22140. return
  22141. }
  22142. return *v, true
  22143. }
  22144. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  22145. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22146. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22147. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  22148. if !m.op.Is(OpUpdateOne) {
  22149. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  22150. }
  22151. if m.id == nil || m.oldValue == nil {
  22152. return v, errors.New("OldStageID requires an ID field in the mutation")
  22153. }
  22154. oldValue, err := m.oldValue(ctx)
  22155. if err != nil {
  22156. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  22157. }
  22158. return oldValue.StageID, nil
  22159. }
  22160. // ResetStageID resets all changes to the "stage_id" field.
  22161. func (m *SopNodeMutation) ResetStageID() {
  22162. m.sop_stage = nil
  22163. }
  22164. // SetParentID sets the "parent_id" field.
  22165. func (m *SopNodeMutation) SetParentID(u uint64) {
  22166. m.parent_id = &u
  22167. m.addparent_id = nil
  22168. }
  22169. // ParentID returns the value of the "parent_id" field in the mutation.
  22170. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  22171. v := m.parent_id
  22172. if v == nil {
  22173. return
  22174. }
  22175. return *v, true
  22176. }
  22177. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  22178. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22179. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22180. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  22181. if !m.op.Is(OpUpdateOne) {
  22182. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  22183. }
  22184. if m.id == nil || m.oldValue == nil {
  22185. return v, errors.New("OldParentID requires an ID field in the mutation")
  22186. }
  22187. oldValue, err := m.oldValue(ctx)
  22188. if err != nil {
  22189. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  22190. }
  22191. return oldValue.ParentID, nil
  22192. }
  22193. // AddParentID adds u to the "parent_id" field.
  22194. func (m *SopNodeMutation) AddParentID(u int64) {
  22195. if m.addparent_id != nil {
  22196. *m.addparent_id += u
  22197. } else {
  22198. m.addparent_id = &u
  22199. }
  22200. }
  22201. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  22202. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  22203. v := m.addparent_id
  22204. if v == nil {
  22205. return
  22206. }
  22207. return *v, true
  22208. }
  22209. // ResetParentID resets all changes to the "parent_id" field.
  22210. func (m *SopNodeMutation) ResetParentID() {
  22211. m.parent_id = nil
  22212. m.addparent_id = nil
  22213. }
  22214. // SetName sets the "name" field.
  22215. func (m *SopNodeMutation) SetName(s string) {
  22216. m.name = &s
  22217. }
  22218. // Name returns the value of the "name" field in the mutation.
  22219. func (m *SopNodeMutation) Name() (r string, exists bool) {
  22220. v := m.name
  22221. if v == nil {
  22222. return
  22223. }
  22224. return *v, true
  22225. }
  22226. // OldName returns the old "name" field's value of the SopNode entity.
  22227. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22228. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22229. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  22230. if !m.op.Is(OpUpdateOne) {
  22231. return v, errors.New("OldName is only allowed on UpdateOne operations")
  22232. }
  22233. if m.id == nil || m.oldValue == nil {
  22234. return v, errors.New("OldName requires an ID field in the mutation")
  22235. }
  22236. oldValue, err := m.oldValue(ctx)
  22237. if err != nil {
  22238. return v, fmt.Errorf("querying old value for OldName: %w", err)
  22239. }
  22240. return oldValue.Name, nil
  22241. }
  22242. // ResetName resets all changes to the "name" field.
  22243. func (m *SopNodeMutation) ResetName() {
  22244. m.name = nil
  22245. }
  22246. // SetConditionType sets the "condition_type" field.
  22247. func (m *SopNodeMutation) SetConditionType(i int) {
  22248. m.condition_type = &i
  22249. m.addcondition_type = nil
  22250. }
  22251. // ConditionType returns the value of the "condition_type" field in the mutation.
  22252. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  22253. v := m.condition_type
  22254. if v == nil {
  22255. return
  22256. }
  22257. return *v, true
  22258. }
  22259. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  22260. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22261. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22262. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  22263. if !m.op.Is(OpUpdateOne) {
  22264. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  22265. }
  22266. if m.id == nil || m.oldValue == nil {
  22267. return v, errors.New("OldConditionType requires an ID field in the mutation")
  22268. }
  22269. oldValue, err := m.oldValue(ctx)
  22270. if err != nil {
  22271. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  22272. }
  22273. return oldValue.ConditionType, nil
  22274. }
  22275. // AddConditionType adds i to the "condition_type" field.
  22276. func (m *SopNodeMutation) AddConditionType(i int) {
  22277. if m.addcondition_type != nil {
  22278. *m.addcondition_type += i
  22279. } else {
  22280. m.addcondition_type = &i
  22281. }
  22282. }
  22283. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  22284. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  22285. v := m.addcondition_type
  22286. if v == nil {
  22287. return
  22288. }
  22289. return *v, true
  22290. }
  22291. // ResetConditionType resets all changes to the "condition_type" field.
  22292. func (m *SopNodeMutation) ResetConditionType() {
  22293. m.condition_type = nil
  22294. m.addcondition_type = nil
  22295. }
  22296. // SetConditionList sets the "condition_list" field.
  22297. func (m *SopNodeMutation) SetConditionList(s []string) {
  22298. m.condition_list = &s
  22299. m.appendcondition_list = nil
  22300. }
  22301. // ConditionList returns the value of the "condition_list" field in the mutation.
  22302. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  22303. v := m.condition_list
  22304. if v == nil {
  22305. return
  22306. }
  22307. return *v, true
  22308. }
  22309. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  22310. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22311. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22312. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  22313. if !m.op.Is(OpUpdateOne) {
  22314. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  22315. }
  22316. if m.id == nil || m.oldValue == nil {
  22317. return v, errors.New("OldConditionList requires an ID field in the mutation")
  22318. }
  22319. oldValue, err := m.oldValue(ctx)
  22320. if err != nil {
  22321. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  22322. }
  22323. return oldValue.ConditionList, nil
  22324. }
  22325. // AppendConditionList adds s to the "condition_list" field.
  22326. func (m *SopNodeMutation) AppendConditionList(s []string) {
  22327. m.appendcondition_list = append(m.appendcondition_list, s...)
  22328. }
  22329. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  22330. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  22331. if len(m.appendcondition_list) == 0 {
  22332. return nil, false
  22333. }
  22334. return m.appendcondition_list, true
  22335. }
  22336. // ClearConditionList clears the value of the "condition_list" field.
  22337. func (m *SopNodeMutation) ClearConditionList() {
  22338. m.condition_list = nil
  22339. m.appendcondition_list = nil
  22340. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  22341. }
  22342. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  22343. func (m *SopNodeMutation) ConditionListCleared() bool {
  22344. _, ok := m.clearedFields[sopnode.FieldConditionList]
  22345. return ok
  22346. }
  22347. // ResetConditionList resets all changes to the "condition_list" field.
  22348. func (m *SopNodeMutation) ResetConditionList() {
  22349. m.condition_list = nil
  22350. m.appendcondition_list = nil
  22351. delete(m.clearedFields, sopnode.FieldConditionList)
  22352. }
  22353. // SetNoReplyCondition sets the "no_reply_condition" field.
  22354. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  22355. m.no_reply_condition = &u
  22356. m.addno_reply_condition = nil
  22357. }
  22358. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  22359. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  22360. v := m.no_reply_condition
  22361. if v == nil {
  22362. return
  22363. }
  22364. return *v, true
  22365. }
  22366. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  22367. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22368. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22369. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  22370. if !m.op.Is(OpUpdateOne) {
  22371. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  22372. }
  22373. if m.id == nil || m.oldValue == nil {
  22374. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  22375. }
  22376. oldValue, err := m.oldValue(ctx)
  22377. if err != nil {
  22378. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  22379. }
  22380. return oldValue.NoReplyCondition, nil
  22381. }
  22382. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  22383. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  22384. if m.addno_reply_condition != nil {
  22385. *m.addno_reply_condition += u
  22386. } else {
  22387. m.addno_reply_condition = &u
  22388. }
  22389. }
  22390. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  22391. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  22392. v := m.addno_reply_condition
  22393. if v == nil {
  22394. return
  22395. }
  22396. return *v, true
  22397. }
  22398. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  22399. func (m *SopNodeMutation) ResetNoReplyCondition() {
  22400. m.no_reply_condition = nil
  22401. m.addno_reply_condition = nil
  22402. }
  22403. // SetNoReplyUnit sets the "no_reply_unit" field.
  22404. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  22405. m.no_reply_unit = &s
  22406. }
  22407. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  22408. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  22409. v := m.no_reply_unit
  22410. if v == nil {
  22411. return
  22412. }
  22413. return *v, true
  22414. }
  22415. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  22416. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22417. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22418. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  22419. if !m.op.Is(OpUpdateOne) {
  22420. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  22421. }
  22422. if m.id == nil || m.oldValue == nil {
  22423. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  22424. }
  22425. oldValue, err := m.oldValue(ctx)
  22426. if err != nil {
  22427. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  22428. }
  22429. return oldValue.NoReplyUnit, nil
  22430. }
  22431. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  22432. func (m *SopNodeMutation) ResetNoReplyUnit() {
  22433. m.no_reply_unit = nil
  22434. }
  22435. // SetActionMessage sets the "action_message" field.
  22436. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  22437. m.action_message = &ct
  22438. m.appendaction_message = nil
  22439. }
  22440. // ActionMessage returns the value of the "action_message" field in the mutation.
  22441. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  22442. v := m.action_message
  22443. if v == nil {
  22444. return
  22445. }
  22446. return *v, true
  22447. }
  22448. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  22449. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22450. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22451. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  22452. if !m.op.Is(OpUpdateOne) {
  22453. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  22454. }
  22455. if m.id == nil || m.oldValue == nil {
  22456. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  22457. }
  22458. oldValue, err := m.oldValue(ctx)
  22459. if err != nil {
  22460. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  22461. }
  22462. return oldValue.ActionMessage, nil
  22463. }
  22464. // AppendActionMessage adds ct to the "action_message" field.
  22465. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  22466. m.appendaction_message = append(m.appendaction_message, ct...)
  22467. }
  22468. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  22469. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  22470. if len(m.appendaction_message) == 0 {
  22471. return nil, false
  22472. }
  22473. return m.appendaction_message, true
  22474. }
  22475. // ClearActionMessage clears the value of the "action_message" field.
  22476. func (m *SopNodeMutation) ClearActionMessage() {
  22477. m.action_message = nil
  22478. m.appendaction_message = nil
  22479. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  22480. }
  22481. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  22482. func (m *SopNodeMutation) ActionMessageCleared() bool {
  22483. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  22484. return ok
  22485. }
  22486. // ResetActionMessage resets all changes to the "action_message" field.
  22487. func (m *SopNodeMutation) ResetActionMessage() {
  22488. m.action_message = nil
  22489. m.appendaction_message = nil
  22490. delete(m.clearedFields, sopnode.FieldActionMessage)
  22491. }
  22492. // SetActionLabelAdd sets the "action_label_add" field.
  22493. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  22494. m.action_label_add = &u
  22495. m.appendaction_label_add = nil
  22496. }
  22497. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  22498. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  22499. v := m.action_label_add
  22500. if v == nil {
  22501. return
  22502. }
  22503. return *v, true
  22504. }
  22505. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  22506. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22507. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22508. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  22509. if !m.op.Is(OpUpdateOne) {
  22510. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  22511. }
  22512. if m.id == nil || m.oldValue == nil {
  22513. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  22514. }
  22515. oldValue, err := m.oldValue(ctx)
  22516. if err != nil {
  22517. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  22518. }
  22519. return oldValue.ActionLabelAdd, nil
  22520. }
  22521. // AppendActionLabelAdd adds u to the "action_label_add" field.
  22522. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  22523. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  22524. }
  22525. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  22526. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  22527. if len(m.appendaction_label_add) == 0 {
  22528. return nil, false
  22529. }
  22530. return m.appendaction_label_add, true
  22531. }
  22532. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  22533. func (m *SopNodeMutation) ClearActionLabelAdd() {
  22534. m.action_label_add = nil
  22535. m.appendaction_label_add = nil
  22536. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  22537. }
  22538. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  22539. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  22540. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  22541. return ok
  22542. }
  22543. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  22544. func (m *SopNodeMutation) ResetActionLabelAdd() {
  22545. m.action_label_add = nil
  22546. m.appendaction_label_add = nil
  22547. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  22548. }
  22549. // SetActionLabelDel sets the "action_label_del" field.
  22550. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  22551. m.action_label_del = &u
  22552. m.appendaction_label_del = nil
  22553. }
  22554. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  22555. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  22556. v := m.action_label_del
  22557. if v == nil {
  22558. return
  22559. }
  22560. return *v, true
  22561. }
  22562. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  22563. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22565. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  22566. if !m.op.Is(OpUpdateOne) {
  22567. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  22568. }
  22569. if m.id == nil || m.oldValue == nil {
  22570. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  22571. }
  22572. oldValue, err := m.oldValue(ctx)
  22573. if err != nil {
  22574. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  22575. }
  22576. return oldValue.ActionLabelDel, nil
  22577. }
  22578. // AppendActionLabelDel adds u to the "action_label_del" field.
  22579. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  22580. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  22581. }
  22582. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  22583. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  22584. if len(m.appendaction_label_del) == 0 {
  22585. return nil, false
  22586. }
  22587. return m.appendaction_label_del, true
  22588. }
  22589. // ClearActionLabelDel clears the value of the "action_label_del" field.
  22590. func (m *SopNodeMutation) ClearActionLabelDel() {
  22591. m.action_label_del = nil
  22592. m.appendaction_label_del = nil
  22593. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  22594. }
  22595. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  22596. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  22597. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  22598. return ok
  22599. }
  22600. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  22601. func (m *SopNodeMutation) ResetActionLabelDel() {
  22602. m.action_label_del = nil
  22603. m.appendaction_label_del = nil
  22604. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  22605. }
  22606. // SetActionForward sets the "action_forward" field.
  22607. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  22608. m.action_forward = &ctf
  22609. }
  22610. // ActionForward returns the value of the "action_forward" field in the mutation.
  22611. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  22612. v := m.action_forward
  22613. if v == nil {
  22614. return
  22615. }
  22616. return *v, true
  22617. }
  22618. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  22619. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22621. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  22622. if !m.op.Is(OpUpdateOne) {
  22623. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  22624. }
  22625. if m.id == nil || m.oldValue == nil {
  22626. return v, errors.New("OldActionForward requires an ID field in the mutation")
  22627. }
  22628. oldValue, err := m.oldValue(ctx)
  22629. if err != nil {
  22630. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  22631. }
  22632. return oldValue.ActionForward, nil
  22633. }
  22634. // ClearActionForward clears the value of the "action_forward" field.
  22635. func (m *SopNodeMutation) ClearActionForward() {
  22636. m.action_forward = nil
  22637. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  22638. }
  22639. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  22640. func (m *SopNodeMutation) ActionForwardCleared() bool {
  22641. _, ok := m.clearedFields[sopnode.FieldActionForward]
  22642. return ok
  22643. }
  22644. // ResetActionForward resets all changes to the "action_forward" field.
  22645. func (m *SopNodeMutation) ResetActionForward() {
  22646. m.action_forward = nil
  22647. delete(m.clearedFields, sopnode.FieldActionForward)
  22648. }
  22649. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  22650. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  22651. m.sop_stage = &id
  22652. }
  22653. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  22654. func (m *SopNodeMutation) ClearSopStage() {
  22655. m.clearedsop_stage = true
  22656. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  22657. }
  22658. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  22659. func (m *SopNodeMutation) SopStageCleared() bool {
  22660. return m.clearedsop_stage
  22661. }
  22662. // SopStageID returns the "sop_stage" edge ID in the mutation.
  22663. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  22664. if m.sop_stage != nil {
  22665. return *m.sop_stage, true
  22666. }
  22667. return
  22668. }
  22669. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  22670. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22671. // SopStageID instead. It exists only for internal usage by the builders.
  22672. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  22673. if id := m.sop_stage; id != nil {
  22674. ids = append(ids, *id)
  22675. }
  22676. return
  22677. }
  22678. // ResetSopStage resets all changes to the "sop_stage" edge.
  22679. func (m *SopNodeMutation) ResetSopStage() {
  22680. m.sop_stage = nil
  22681. m.clearedsop_stage = false
  22682. }
  22683. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  22684. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  22685. if m.node_messages == nil {
  22686. m.node_messages = make(map[uint64]struct{})
  22687. }
  22688. for i := range ids {
  22689. m.node_messages[ids[i]] = struct{}{}
  22690. }
  22691. }
  22692. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  22693. func (m *SopNodeMutation) ClearNodeMessages() {
  22694. m.clearednode_messages = true
  22695. }
  22696. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  22697. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  22698. return m.clearednode_messages
  22699. }
  22700. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  22701. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  22702. if m.removednode_messages == nil {
  22703. m.removednode_messages = make(map[uint64]struct{})
  22704. }
  22705. for i := range ids {
  22706. delete(m.node_messages, ids[i])
  22707. m.removednode_messages[ids[i]] = struct{}{}
  22708. }
  22709. }
  22710. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  22711. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  22712. for id := range m.removednode_messages {
  22713. ids = append(ids, id)
  22714. }
  22715. return
  22716. }
  22717. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  22718. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  22719. for id := range m.node_messages {
  22720. ids = append(ids, id)
  22721. }
  22722. return
  22723. }
  22724. // ResetNodeMessages resets all changes to the "node_messages" edge.
  22725. func (m *SopNodeMutation) ResetNodeMessages() {
  22726. m.node_messages = nil
  22727. m.clearednode_messages = false
  22728. m.removednode_messages = nil
  22729. }
  22730. // Where appends a list predicates to the SopNodeMutation builder.
  22731. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  22732. m.predicates = append(m.predicates, ps...)
  22733. }
  22734. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  22735. // users can use type-assertion to append predicates that do not depend on any generated package.
  22736. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  22737. p := make([]predicate.SopNode, len(ps))
  22738. for i := range ps {
  22739. p[i] = ps[i]
  22740. }
  22741. m.Where(p...)
  22742. }
  22743. // Op returns the operation name.
  22744. func (m *SopNodeMutation) Op() Op {
  22745. return m.op
  22746. }
  22747. // SetOp allows setting the mutation operation.
  22748. func (m *SopNodeMutation) SetOp(op Op) {
  22749. m.op = op
  22750. }
  22751. // Type returns the node type of this mutation (SopNode).
  22752. func (m *SopNodeMutation) Type() string {
  22753. return m.typ
  22754. }
  22755. // Fields returns all fields that were changed during this mutation. Note that in
  22756. // order to get all numeric fields that were incremented/decremented, call
  22757. // AddedFields().
  22758. func (m *SopNodeMutation) Fields() []string {
  22759. fields := make([]string, 0, 15)
  22760. if m.created_at != nil {
  22761. fields = append(fields, sopnode.FieldCreatedAt)
  22762. }
  22763. if m.updated_at != nil {
  22764. fields = append(fields, sopnode.FieldUpdatedAt)
  22765. }
  22766. if m.status != nil {
  22767. fields = append(fields, sopnode.FieldStatus)
  22768. }
  22769. if m.deleted_at != nil {
  22770. fields = append(fields, sopnode.FieldDeletedAt)
  22771. }
  22772. if m.sop_stage != nil {
  22773. fields = append(fields, sopnode.FieldStageID)
  22774. }
  22775. if m.parent_id != nil {
  22776. fields = append(fields, sopnode.FieldParentID)
  22777. }
  22778. if m.name != nil {
  22779. fields = append(fields, sopnode.FieldName)
  22780. }
  22781. if m.condition_type != nil {
  22782. fields = append(fields, sopnode.FieldConditionType)
  22783. }
  22784. if m.condition_list != nil {
  22785. fields = append(fields, sopnode.FieldConditionList)
  22786. }
  22787. if m.no_reply_condition != nil {
  22788. fields = append(fields, sopnode.FieldNoReplyCondition)
  22789. }
  22790. if m.no_reply_unit != nil {
  22791. fields = append(fields, sopnode.FieldNoReplyUnit)
  22792. }
  22793. if m.action_message != nil {
  22794. fields = append(fields, sopnode.FieldActionMessage)
  22795. }
  22796. if m.action_label_add != nil {
  22797. fields = append(fields, sopnode.FieldActionLabelAdd)
  22798. }
  22799. if m.action_label_del != nil {
  22800. fields = append(fields, sopnode.FieldActionLabelDel)
  22801. }
  22802. if m.action_forward != nil {
  22803. fields = append(fields, sopnode.FieldActionForward)
  22804. }
  22805. return fields
  22806. }
  22807. // Field returns the value of a field with the given name. The second boolean
  22808. // return value indicates that this field was not set, or was not defined in the
  22809. // schema.
  22810. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  22811. switch name {
  22812. case sopnode.FieldCreatedAt:
  22813. return m.CreatedAt()
  22814. case sopnode.FieldUpdatedAt:
  22815. return m.UpdatedAt()
  22816. case sopnode.FieldStatus:
  22817. return m.Status()
  22818. case sopnode.FieldDeletedAt:
  22819. return m.DeletedAt()
  22820. case sopnode.FieldStageID:
  22821. return m.StageID()
  22822. case sopnode.FieldParentID:
  22823. return m.ParentID()
  22824. case sopnode.FieldName:
  22825. return m.Name()
  22826. case sopnode.FieldConditionType:
  22827. return m.ConditionType()
  22828. case sopnode.FieldConditionList:
  22829. return m.ConditionList()
  22830. case sopnode.FieldNoReplyCondition:
  22831. return m.NoReplyCondition()
  22832. case sopnode.FieldNoReplyUnit:
  22833. return m.NoReplyUnit()
  22834. case sopnode.FieldActionMessage:
  22835. return m.ActionMessage()
  22836. case sopnode.FieldActionLabelAdd:
  22837. return m.ActionLabelAdd()
  22838. case sopnode.FieldActionLabelDel:
  22839. return m.ActionLabelDel()
  22840. case sopnode.FieldActionForward:
  22841. return m.ActionForward()
  22842. }
  22843. return nil, false
  22844. }
  22845. // OldField returns the old value of the field from the database. An error is
  22846. // returned if the mutation operation is not UpdateOne, or the query to the
  22847. // database failed.
  22848. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22849. switch name {
  22850. case sopnode.FieldCreatedAt:
  22851. return m.OldCreatedAt(ctx)
  22852. case sopnode.FieldUpdatedAt:
  22853. return m.OldUpdatedAt(ctx)
  22854. case sopnode.FieldStatus:
  22855. return m.OldStatus(ctx)
  22856. case sopnode.FieldDeletedAt:
  22857. return m.OldDeletedAt(ctx)
  22858. case sopnode.FieldStageID:
  22859. return m.OldStageID(ctx)
  22860. case sopnode.FieldParentID:
  22861. return m.OldParentID(ctx)
  22862. case sopnode.FieldName:
  22863. return m.OldName(ctx)
  22864. case sopnode.FieldConditionType:
  22865. return m.OldConditionType(ctx)
  22866. case sopnode.FieldConditionList:
  22867. return m.OldConditionList(ctx)
  22868. case sopnode.FieldNoReplyCondition:
  22869. return m.OldNoReplyCondition(ctx)
  22870. case sopnode.FieldNoReplyUnit:
  22871. return m.OldNoReplyUnit(ctx)
  22872. case sopnode.FieldActionMessage:
  22873. return m.OldActionMessage(ctx)
  22874. case sopnode.FieldActionLabelAdd:
  22875. return m.OldActionLabelAdd(ctx)
  22876. case sopnode.FieldActionLabelDel:
  22877. return m.OldActionLabelDel(ctx)
  22878. case sopnode.FieldActionForward:
  22879. return m.OldActionForward(ctx)
  22880. }
  22881. return nil, fmt.Errorf("unknown SopNode field %s", name)
  22882. }
  22883. // SetField sets the value of a field with the given name. It returns an error if
  22884. // the field is not defined in the schema, or if the type mismatched the field
  22885. // type.
  22886. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  22887. switch name {
  22888. case sopnode.FieldCreatedAt:
  22889. v, ok := value.(time.Time)
  22890. if !ok {
  22891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22892. }
  22893. m.SetCreatedAt(v)
  22894. return nil
  22895. case sopnode.FieldUpdatedAt:
  22896. v, ok := value.(time.Time)
  22897. if !ok {
  22898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22899. }
  22900. m.SetUpdatedAt(v)
  22901. return nil
  22902. case sopnode.FieldStatus:
  22903. v, ok := value.(uint8)
  22904. if !ok {
  22905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22906. }
  22907. m.SetStatus(v)
  22908. return nil
  22909. case sopnode.FieldDeletedAt:
  22910. v, ok := value.(time.Time)
  22911. if !ok {
  22912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22913. }
  22914. m.SetDeletedAt(v)
  22915. return nil
  22916. case sopnode.FieldStageID:
  22917. v, ok := value.(uint64)
  22918. if !ok {
  22919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22920. }
  22921. m.SetStageID(v)
  22922. return nil
  22923. case sopnode.FieldParentID:
  22924. v, ok := value.(uint64)
  22925. if !ok {
  22926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22927. }
  22928. m.SetParentID(v)
  22929. return nil
  22930. case sopnode.FieldName:
  22931. v, ok := value.(string)
  22932. if !ok {
  22933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22934. }
  22935. m.SetName(v)
  22936. return nil
  22937. case sopnode.FieldConditionType:
  22938. v, ok := value.(int)
  22939. if !ok {
  22940. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22941. }
  22942. m.SetConditionType(v)
  22943. return nil
  22944. case sopnode.FieldConditionList:
  22945. v, ok := value.([]string)
  22946. if !ok {
  22947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22948. }
  22949. m.SetConditionList(v)
  22950. return nil
  22951. case sopnode.FieldNoReplyCondition:
  22952. v, ok := value.(uint64)
  22953. if !ok {
  22954. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22955. }
  22956. m.SetNoReplyCondition(v)
  22957. return nil
  22958. case sopnode.FieldNoReplyUnit:
  22959. v, ok := value.(string)
  22960. if !ok {
  22961. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22962. }
  22963. m.SetNoReplyUnit(v)
  22964. return nil
  22965. case sopnode.FieldActionMessage:
  22966. v, ok := value.([]custom_types.Action)
  22967. if !ok {
  22968. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22969. }
  22970. m.SetActionMessage(v)
  22971. return nil
  22972. case sopnode.FieldActionLabelAdd:
  22973. v, ok := value.([]uint64)
  22974. if !ok {
  22975. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22976. }
  22977. m.SetActionLabelAdd(v)
  22978. return nil
  22979. case sopnode.FieldActionLabelDel:
  22980. v, ok := value.([]uint64)
  22981. if !ok {
  22982. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22983. }
  22984. m.SetActionLabelDel(v)
  22985. return nil
  22986. case sopnode.FieldActionForward:
  22987. v, ok := value.(*custom_types.ActionForward)
  22988. if !ok {
  22989. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22990. }
  22991. m.SetActionForward(v)
  22992. return nil
  22993. }
  22994. return fmt.Errorf("unknown SopNode field %s", name)
  22995. }
  22996. // AddedFields returns all numeric fields that were incremented/decremented during
  22997. // this mutation.
  22998. func (m *SopNodeMutation) AddedFields() []string {
  22999. var fields []string
  23000. if m.addstatus != nil {
  23001. fields = append(fields, sopnode.FieldStatus)
  23002. }
  23003. if m.addparent_id != nil {
  23004. fields = append(fields, sopnode.FieldParentID)
  23005. }
  23006. if m.addcondition_type != nil {
  23007. fields = append(fields, sopnode.FieldConditionType)
  23008. }
  23009. if m.addno_reply_condition != nil {
  23010. fields = append(fields, sopnode.FieldNoReplyCondition)
  23011. }
  23012. return fields
  23013. }
  23014. // AddedField returns the numeric value that was incremented/decremented on a field
  23015. // with the given name. The second boolean return value indicates that this field
  23016. // was not set, or was not defined in the schema.
  23017. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  23018. switch name {
  23019. case sopnode.FieldStatus:
  23020. return m.AddedStatus()
  23021. case sopnode.FieldParentID:
  23022. return m.AddedParentID()
  23023. case sopnode.FieldConditionType:
  23024. return m.AddedConditionType()
  23025. case sopnode.FieldNoReplyCondition:
  23026. return m.AddedNoReplyCondition()
  23027. }
  23028. return nil, false
  23029. }
  23030. // AddField adds the value to the field with the given name. It returns an error if
  23031. // the field is not defined in the schema, or if the type mismatched the field
  23032. // type.
  23033. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  23034. switch name {
  23035. case sopnode.FieldStatus:
  23036. v, ok := value.(int8)
  23037. if !ok {
  23038. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23039. }
  23040. m.AddStatus(v)
  23041. return nil
  23042. case sopnode.FieldParentID:
  23043. v, ok := value.(int64)
  23044. if !ok {
  23045. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23046. }
  23047. m.AddParentID(v)
  23048. return nil
  23049. case sopnode.FieldConditionType:
  23050. v, ok := value.(int)
  23051. if !ok {
  23052. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23053. }
  23054. m.AddConditionType(v)
  23055. return nil
  23056. case sopnode.FieldNoReplyCondition:
  23057. v, ok := value.(int64)
  23058. if !ok {
  23059. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23060. }
  23061. m.AddNoReplyCondition(v)
  23062. return nil
  23063. }
  23064. return fmt.Errorf("unknown SopNode numeric field %s", name)
  23065. }
  23066. // ClearedFields returns all nullable fields that were cleared during this
  23067. // mutation.
  23068. func (m *SopNodeMutation) ClearedFields() []string {
  23069. var fields []string
  23070. if m.FieldCleared(sopnode.FieldStatus) {
  23071. fields = append(fields, sopnode.FieldStatus)
  23072. }
  23073. if m.FieldCleared(sopnode.FieldDeletedAt) {
  23074. fields = append(fields, sopnode.FieldDeletedAt)
  23075. }
  23076. if m.FieldCleared(sopnode.FieldConditionList) {
  23077. fields = append(fields, sopnode.FieldConditionList)
  23078. }
  23079. if m.FieldCleared(sopnode.FieldActionMessage) {
  23080. fields = append(fields, sopnode.FieldActionMessage)
  23081. }
  23082. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  23083. fields = append(fields, sopnode.FieldActionLabelAdd)
  23084. }
  23085. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  23086. fields = append(fields, sopnode.FieldActionLabelDel)
  23087. }
  23088. if m.FieldCleared(sopnode.FieldActionForward) {
  23089. fields = append(fields, sopnode.FieldActionForward)
  23090. }
  23091. return fields
  23092. }
  23093. // FieldCleared returns a boolean indicating if a field with the given name was
  23094. // cleared in this mutation.
  23095. func (m *SopNodeMutation) FieldCleared(name string) bool {
  23096. _, ok := m.clearedFields[name]
  23097. return ok
  23098. }
  23099. // ClearField clears the value of the field with the given name. It returns an
  23100. // error if the field is not defined in the schema.
  23101. func (m *SopNodeMutation) ClearField(name string) error {
  23102. switch name {
  23103. case sopnode.FieldStatus:
  23104. m.ClearStatus()
  23105. return nil
  23106. case sopnode.FieldDeletedAt:
  23107. m.ClearDeletedAt()
  23108. return nil
  23109. case sopnode.FieldConditionList:
  23110. m.ClearConditionList()
  23111. return nil
  23112. case sopnode.FieldActionMessage:
  23113. m.ClearActionMessage()
  23114. return nil
  23115. case sopnode.FieldActionLabelAdd:
  23116. m.ClearActionLabelAdd()
  23117. return nil
  23118. case sopnode.FieldActionLabelDel:
  23119. m.ClearActionLabelDel()
  23120. return nil
  23121. case sopnode.FieldActionForward:
  23122. m.ClearActionForward()
  23123. return nil
  23124. }
  23125. return fmt.Errorf("unknown SopNode nullable field %s", name)
  23126. }
  23127. // ResetField resets all changes in the mutation for the field with the given name.
  23128. // It returns an error if the field is not defined in the schema.
  23129. func (m *SopNodeMutation) ResetField(name string) error {
  23130. switch name {
  23131. case sopnode.FieldCreatedAt:
  23132. m.ResetCreatedAt()
  23133. return nil
  23134. case sopnode.FieldUpdatedAt:
  23135. m.ResetUpdatedAt()
  23136. return nil
  23137. case sopnode.FieldStatus:
  23138. m.ResetStatus()
  23139. return nil
  23140. case sopnode.FieldDeletedAt:
  23141. m.ResetDeletedAt()
  23142. return nil
  23143. case sopnode.FieldStageID:
  23144. m.ResetStageID()
  23145. return nil
  23146. case sopnode.FieldParentID:
  23147. m.ResetParentID()
  23148. return nil
  23149. case sopnode.FieldName:
  23150. m.ResetName()
  23151. return nil
  23152. case sopnode.FieldConditionType:
  23153. m.ResetConditionType()
  23154. return nil
  23155. case sopnode.FieldConditionList:
  23156. m.ResetConditionList()
  23157. return nil
  23158. case sopnode.FieldNoReplyCondition:
  23159. m.ResetNoReplyCondition()
  23160. return nil
  23161. case sopnode.FieldNoReplyUnit:
  23162. m.ResetNoReplyUnit()
  23163. return nil
  23164. case sopnode.FieldActionMessage:
  23165. m.ResetActionMessage()
  23166. return nil
  23167. case sopnode.FieldActionLabelAdd:
  23168. m.ResetActionLabelAdd()
  23169. return nil
  23170. case sopnode.FieldActionLabelDel:
  23171. m.ResetActionLabelDel()
  23172. return nil
  23173. case sopnode.FieldActionForward:
  23174. m.ResetActionForward()
  23175. return nil
  23176. }
  23177. return fmt.Errorf("unknown SopNode field %s", name)
  23178. }
  23179. // AddedEdges returns all edge names that were set/added in this mutation.
  23180. func (m *SopNodeMutation) AddedEdges() []string {
  23181. edges := make([]string, 0, 2)
  23182. if m.sop_stage != nil {
  23183. edges = append(edges, sopnode.EdgeSopStage)
  23184. }
  23185. if m.node_messages != nil {
  23186. edges = append(edges, sopnode.EdgeNodeMessages)
  23187. }
  23188. return edges
  23189. }
  23190. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23191. // name in this mutation.
  23192. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  23193. switch name {
  23194. case sopnode.EdgeSopStage:
  23195. if id := m.sop_stage; id != nil {
  23196. return []ent.Value{*id}
  23197. }
  23198. case sopnode.EdgeNodeMessages:
  23199. ids := make([]ent.Value, 0, len(m.node_messages))
  23200. for id := range m.node_messages {
  23201. ids = append(ids, id)
  23202. }
  23203. return ids
  23204. }
  23205. return nil
  23206. }
  23207. // RemovedEdges returns all edge names that were removed in this mutation.
  23208. func (m *SopNodeMutation) RemovedEdges() []string {
  23209. edges := make([]string, 0, 2)
  23210. if m.removednode_messages != nil {
  23211. edges = append(edges, sopnode.EdgeNodeMessages)
  23212. }
  23213. return edges
  23214. }
  23215. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23216. // the given name in this mutation.
  23217. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  23218. switch name {
  23219. case sopnode.EdgeNodeMessages:
  23220. ids := make([]ent.Value, 0, len(m.removednode_messages))
  23221. for id := range m.removednode_messages {
  23222. ids = append(ids, id)
  23223. }
  23224. return ids
  23225. }
  23226. return nil
  23227. }
  23228. // ClearedEdges returns all edge names that were cleared in this mutation.
  23229. func (m *SopNodeMutation) ClearedEdges() []string {
  23230. edges := make([]string, 0, 2)
  23231. if m.clearedsop_stage {
  23232. edges = append(edges, sopnode.EdgeSopStage)
  23233. }
  23234. if m.clearednode_messages {
  23235. edges = append(edges, sopnode.EdgeNodeMessages)
  23236. }
  23237. return edges
  23238. }
  23239. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23240. // was cleared in this mutation.
  23241. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  23242. switch name {
  23243. case sopnode.EdgeSopStage:
  23244. return m.clearedsop_stage
  23245. case sopnode.EdgeNodeMessages:
  23246. return m.clearednode_messages
  23247. }
  23248. return false
  23249. }
  23250. // ClearEdge clears the value of the edge with the given name. It returns an error
  23251. // if that edge is not defined in the schema.
  23252. func (m *SopNodeMutation) ClearEdge(name string) error {
  23253. switch name {
  23254. case sopnode.EdgeSopStage:
  23255. m.ClearSopStage()
  23256. return nil
  23257. }
  23258. return fmt.Errorf("unknown SopNode unique edge %s", name)
  23259. }
  23260. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23261. // It returns an error if the edge is not defined in the schema.
  23262. func (m *SopNodeMutation) ResetEdge(name string) error {
  23263. switch name {
  23264. case sopnode.EdgeSopStage:
  23265. m.ResetSopStage()
  23266. return nil
  23267. case sopnode.EdgeNodeMessages:
  23268. m.ResetNodeMessages()
  23269. return nil
  23270. }
  23271. return fmt.Errorf("unknown SopNode edge %s", name)
  23272. }
  23273. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  23274. type SopStageMutation struct {
  23275. config
  23276. op Op
  23277. typ string
  23278. id *uint64
  23279. created_at *time.Time
  23280. updated_at *time.Time
  23281. status *uint8
  23282. addstatus *int8
  23283. deleted_at *time.Time
  23284. name *string
  23285. condition_type *int
  23286. addcondition_type *int
  23287. condition_operator *int
  23288. addcondition_operator *int
  23289. condition_list *[]custom_types.Condition
  23290. appendcondition_list []custom_types.Condition
  23291. action_message *[]custom_types.Action
  23292. appendaction_message []custom_types.Action
  23293. action_label_add *[]uint64
  23294. appendaction_label_add []uint64
  23295. action_label_del *[]uint64
  23296. appendaction_label_del []uint64
  23297. action_forward **custom_types.ActionForward
  23298. index_sort *int
  23299. addindex_sort *int
  23300. clearedFields map[string]struct{}
  23301. sop_task *uint64
  23302. clearedsop_task bool
  23303. stage_nodes map[uint64]struct{}
  23304. removedstage_nodes map[uint64]struct{}
  23305. clearedstage_nodes bool
  23306. stage_messages map[uint64]struct{}
  23307. removedstage_messages map[uint64]struct{}
  23308. clearedstage_messages bool
  23309. done bool
  23310. oldValue func(context.Context) (*SopStage, error)
  23311. predicates []predicate.SopStage
  23312. }
  23313. var _ ent.Mutation = (*SopStageMutation)(nil)
  23314. // sopstageOption allows management of the mutation configuration using functional options.
  23315. type sopstageOption func(*SopStageMutation)
  23316. // newSopStageMutation creates new mutation for the SopStage entity.
  23317. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  23318. m := &SopStageMutation{
  23319. config: c,
  23320. op: op,
  23321. typ: TypeSopStage,
  23322. clearedFields: make(map[string]struct{}),
  23323. }
  23324. for _, opt := range opts {
  23325. opt(m)
  23326. }
  23327. return m
  23328. }
  23329. // withSopStageID sets the ID field of the mutation.
  23330. func withSopStageID(id uint64) sopstageOption {
  23331. return func(m *SopStageMutation) {
  23332. var (
  23333. err error
  23334. once sync.Once
  23335. value *SopStage
  23336. )
  23337. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  23338. once.Do(func() {
  23339. if m.done {
  23340. err = errors.New("querying old values post mutation is not allowed")
  23341. } else {
  23342. value, err = m.Client().SopStage.Get(ctx, id)
  23343. }
  23344. })
  23345. return value, err
  23346. }
  23347. m.id = &id
  23348. }
  23349. }
  23350. // withSopStage sets the old SopStage of the mutation.
  23351. func withSopStage(node *SopStage) sopstageOption {
  23352. return func(m *SopStageMutation) {
  23353. m.oldValue = func(context.Context) (*SopStage, error) {
  23354. return node, nil
  23355. }
  23356. m.id = &node.ID
  23357. }
  23358. }
  23359. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23360. // executed in a transaction (ent.Tx), a transactional client is returned.
  23361. func (m SopStageMutation) Client() *Client {
  23362. client := &Client{config: m.config}
  23363. client.init()
  23364. return client
  23365. }
  23366. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23367. // it returns an error otherwise.
  23368. func (m SopStageMutation) Tx() (*Tx, error) {
  23369. if _, ok := m.driver.(*txDriver); !ok {
  23370. return nil, errors.New("ent: mutation is not running in a transaction")
  23371. }
  23372. tx := &Tx{config: m.config}
  23373. tx.init()
  23374. return tx, nil
  23375. }
  23376. // SetID sets the value of the id field. Note that this
  23377. // operation is only accepted on creation of SopStage entities.
  23378. func (m *SopStageMutation) SetID(id uint64) {
  23379. m.id = &id
  23380. }
  23381. // ID returns the ID value in the mutation. Note that the ID is only available
  23382. // if it was provided to the builder or after it was returned from the database.
  23383. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  23384. if m.id == nil {
  23385. return
  23386. }
  23387. return *m.id, true
  23388. }
  23389. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23390. // That means, if the mutation is applied within a transaction with an isolation level such
  23391. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23392. // or updated by the mutation.
  23393. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  23394. switch {
  23395. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23396. id, exists := m.ID()
  23397. if exists {
  23398. return []uint64{id}, nil
  23399. }
  23400. fallthrough
  23401. case m.op.Is(OpUpdate | OpDelete):
  23402. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  23403. default:
  23404. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23405. }
  23406. }
  23407. // SetCreatedAt sets the "created_at" field.
  23408. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  23409. m.created_at = &t
  23410. }
  23411. // CreatedAt returns the value of the "created_at" field in the mutation.
  23412. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  23413. v := m.created_at
  23414. if v == nil {
  23415. return
  23416. }
  23417. return *v, true
  23418. }
  23419. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  23420. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23421. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23422. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23423. if !m.op.Is(OpUpdateOne) {
  23424. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23425. }
  23426. if m.id == nil || m.oldValue == nil {
  23427. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23428. }
  23429. oldValue, err := m.oldValue(ctx)
  23430. if err != nil {
  23431. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23432. }
  23433. return oldValue.CreatedAt, nil
  23434. }
  23435. // ResetCreatedAt resets all changes to the "created_at" field.
  23436. func (m *SopStageMutation) ResetCreatedAt() {
  23437. m.created_at = nil
  23438. }
  23439. // SetUpdatedAt sets the "updated_at" field.
  23440. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  23441. m.updated_at = &t
  23442. }
  23443. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23444. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  23445. v := m.updated_at
  23446. if v == nil {
  23447. return
  23448. }
  23449. return *v, true
  23450. }
  23451. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  23452. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23453. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23454. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23455. if !m.op.Is(OpUpdateOne) {
  23456. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23457. }
  23458. if m.id == nil || m.oldValue == nil {
  23459. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23460. }
  23461. oldValue, err := m.oldValue(ctx)
  23462. if err != nil {
  23463. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23464. }
  23465. return oldValue.UpdatedAt, nil
  23466. }
  23467. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23468. func (m *SopStageMutation) ResetUpdatedAt() {
  23469. m.updated_at = nil
  23470. }
  23471. // SetStatus sets the "status" field.
  23472. func (m *SopStageMutation) SetStatus(u uint8) {
  23473. m.status = &u
  23474. m.addstatus = nil
  23475. }
  23476. // Status returns the value of the "status" field in the mutation.
  23477. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  23478. v := m.status
  23479. if v == nil {
  23480. return
  23481. }
  23482. return *v, true
  23483. }
  23484. // OldStatus returns the old "status" field's value of the SopStage entity.
  23485. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23486. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23487. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23488. if !m.op.Is(OpUpdateOne) {
  23489. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23490. }
  23491. if m.id == nil || m.oldValue == nil {
  23492. return v, errors.New("OldStatus requires an ID field in the mutation")
  23493. }
  23494. oldValue, err := m.oldValue(ctx)
  23495. if err != nil {
  23496. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23497. }
  23498. return oldValue.Status, nil
  23499. }
  23500. // AddStatus adds u to the "status" field.
  23501. func (m *SopStageMutation) AddStatus(u int8) {
  23502. if m.addstatus != nil {
  23503. *m.addstatus += u
  23504. } else {
  23505. m.addstatus = &u
  23506. }
  23507. }
  23508. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23509. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  23510. v := m.addstatus
  23511. if v == nil {
  23512. return
  23513. }
  23514. return *v, true
  23515. }
  23516. // ClearStatus clears the value of the "status" field.
  23517. func (m *SopStageMutation) ClearStatus() {
  23518. m.status = nil
  23519. m.addstatus = nil
  23520. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  23521. }
  23522. // StatusCleared returns if the "status" field was cleared in this mutation.
  23523. func (m *SopStageMutation) StatusCleared() bool {
  23524. _, ok := m.clearedFields[sopstage.FieldStatus]
  23525. return ok
  23526. }
  23527. // ResetStatus resets all changes to the "status" field.
  23528. func (m *SopStageMutation) ResetStatus() {
  23529. m.status = nil
  23530. m.addstatus = nil
  23531. delete(m.clearedFields, sopstage.FieldStatus)
  23532. }
  23533. // SetDeletedAt sets the "deleted_at" field.
  23534. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  23535. m.deleted_at = &t
  23536. }
  23537. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23538. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  23539. v := m.deleted_at
  23540. if v == nil {
  23541. return
  23542. }
  23543. return *v, true
  23544. }
  23545. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  23546. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23547. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23548. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23549. if !m.op.Is(OpUpdateOne) {
  23550. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23551. }
  23552. if m.id == nil || m.oldValue == nil {
  23553. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23554. }
  23555. oldValue, err := m.oldValue(ctx)
  23556. if err != nil {
  23557. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23558. }
  23559. return oldValue.DeletedAt, nil
  23560. }
  23561. // ClearDeletedAt clears the value of the "deleted_at" field.
  23562. func (m *SopStageMutation) ClearDeletedAt() {
  23563. m.deleted_at = nil
  23564. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  23565. }
  23566. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23567. func (m *SopStageMutation) DeletedAtCleared() bool {
  23568. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  23569. return ok
  23570. }
  23571. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23572. func (m *SopStageMutation) ResetDeletedAt() {
  23573. m.deleted_at = nil
  23574. delete(m.clearedFields, sopstage.FieldDeletedAt)
  23575. }
  23576. // SetTaskID sets the "task_id" field.
  23577. func (m *SopStageMutation) SetTaskID(u uint64) {
  23578. m.sop_task = &u
  23579. }
  23580. // TaskID returns the value of the "task_id" field in the mutation.
  23581. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  23582. v := m.sop_task
  23583. if v == nil {
  23584. return
  23585. }
  23586. return *v, true
  23587. }
  23588. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  23589. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23590. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23591. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  23592. if !m.op.Is(OpUpdateOne) {
  23593. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  23594. }
  23595. if m.id == nil || m.oldValue == nil {
  23596. return v, errors.New("OldTaskID requires an ID field in the mutation")
  23597. }
  23598. oldValue, err := m.oldValue(ctx)
  23599. if err != nil {
  23600. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  23601. }
  23602. return oldValue.TaskID, nil
  23603. }
  23604. // ResetTaskID resets all changes to the "task_id" field.
  23605. func (m *SopStageMutation) ResetTaskID() {
  23606. m.sop_task = nil
  23607. }
  23608. // SetName sets the "name" field.
  23609. func (m *SopStageMutation) SetName(s string) {
  23610. m.name = &s
  23611. }
  23612. // Name returns the value of the "name" field in the mutation.
  23613. func (m *SopStageMutation) Name() (r string, exists bool) {
  23614. v := m.name
  23615. if v == nil {
  23616. return
  23617. }
  23618. return *v, true
  23619. }
  23620. // OldName returns the old "name" field's value of the SopStage entity.
  23621. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23622. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23623. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  23624. if !m.op.Is(OpUpdateOne) {
  23625. return v, errors.New("OldName is only allowed on UpdateOne operations")
  23626. }
  23627. if m.id == nil || m.oldValue == nil {
  23628. return v, errors.New("OldName requires an ID field in the mutation")
  23629. }
  23630. oldValue, err := m.oldValue(ctx)
  23631. if err != nil {
  23632. return v, fmt.Errorf("querying old value for OldName: %w", err)
  23633. }
  23634. return oldValue.Name, nil
  23635. }
  23636. // ResetName resets all changes to the "name" field.
  23637. func (m *SopStageMutation) ResetName() {
  23638. m.name = nil
  23639. }
  23640. // SetConditionType sets the "condition_type" field.
  23641. func (m *SopStageMutation) SetConditionType(i int) {
  23642. m.condition_type = &i
  23643. m.addcondition_type = nil
  23644. }
  23645. // ConditionType returns the value of the "condition_type" field in the mutation.
  23646. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  23647. v := m.condition_type
  23648. if v == nil {
  23649. return
  23650. }
  23651. return *v, true
  23652. }
  23653. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  23654. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23655. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23656. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  23657. if !m.op.Is(OpUpdateOne) {
  23658. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  23659. }
  23660. if m.id == nil || m.oldValue == nil {
  23661. return v, errors.New("OldConditionType requires an ID field in the mutation")
  23662. }
  23663. oldValue, err := m.oldValue(ctx)
  23664. if err != nil {
  23665. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  23666. }
  23667. return oldValue.ConditionType, nil
  23668. }
  23669. // AddConditionType adds i to the "condition_type" field.
  23670. func (m *SopStageMutation) AddConditionType(i int) {
  23671. if m.addcondition_type != nil {
  23672. *m.addcondition_type += i
  23673. } else {
  23674. m.addcondition_type = &i
  23675. }
  23676. }
  23677. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  23678. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  23679. v := m.addcondition_type
  23680. if v == nil {
  23681. return
  23682. }
  23683. return *v, true
  23684. }
  23685. // ResetConditionType resets all changes to the "condition_type" field.
  23686. func (m *SopStageMutation) ResetConditionType() {
  23687. m.condition_type = nil
  23688. m.addcondition_type = nil
  23689. }
  23690. // SetConditionOperator sets the "condition_operator" field.
  23691. func (m *SopStageMutation) SetConditionOperator(i int) {
  23692. m.condition_operator = &i
  23693. m.addcondition_operator = nil
  23694. }
  23695. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  23696. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  23697. v := m.condition_operator
  23698. if v == nil {
  23699. return
  23700. }
  23701. return *v, true
  23702. }
  23703. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  23704. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23705. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23706. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  23707. if !m.op.Is(OpUpdateOne) {
  23708. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  23709. }
  23710. if m.id == nil || m.oldValue == nil {
  23711. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  23712. }
  23713. oldValue, err := m.oldValue(ctx)
  23714. if err != nil {
  23715. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  23716. }
  23717. return oldValue.ConditionOperator, nil
  23718. }
  23719. // AddConditionOperator adds i to the "condition_operator" field.
  23720. func (m *SopStageMutation) AddConditionOperator(i int) {
  23721. if m.addcondition_operator != nil {
  23722. *m.addcondition_operator += i
  23723. } else {
  23724. m.addcondition_operator = &i
  23725. }
  23726. }
  23727. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  23728. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  23729. v := m.addcondition_operator
  23730. if v == nil {
  23731. return
  23732. }
  23733. return *v, true
  23734. }
  23735. // ResetConditionOperator resets all changes to the "condition_operator" field.
  23736. func (m *SopStageMutation) ResetConditionOperator() {
  23737. m.condition_operator = nil
  23738. m.addcondition_operator = nil
  23739. }
  23740. // SetConditionList sets the "condition_list" field.
  23741. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  23742. m.condition_list = &ct
  23743. m.appendcondition_list = nil
  23744. }
  23745. // ConditionList returns the value of the "condition_list" field in the mutation.
  23746. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  23747. v := m.condition_list
  23748. if v == nil {
  23749. return
  23750. }
  23751. return *v, true
  23752. }
  23753. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  23754. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23755. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23756. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  23757. if !m.op.Is(OpUpdateOne) {
  23758. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  23759. }
  23760. if m.id == nil || m.oldValue == nil {
  23761. return v, errors.New("OldConditionList requires an ID field in the mutation")
  23762. }
  23763. oldValue, err := m.oldValue(ctx)
  23764. if err != nil {
  23765. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  23766. }
  23767. return oldValue.ConditionList, nil
  23768. }
  23769. // AppendConditionList adds ct to the "condition_list" field.
  23770. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  23771. m.appendcondition_list = append(m.appendcondition_list, ct...)
  23772. }
  23773. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  23774. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  23775. if len(m.appendcondition_list) == 0 {
  23776. return nil, false
  23777. }
  23778. return m.appendcondition_list, true
  23779. }
  23780. // ResetConditionList resets all changes to the "condition_list" field.
  23781. func (m *SopStageMutation) ResetConditionList() {
  23782. m.condition_list = nil
  23783. m.appendcondition_list = nil
  23784. }
  23785. // SetActionMessage sets the "action_message" field.
  23786. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  23787. m.action_message = &ct
  23788. m.appendaction_message = nil
  23789. }
  23790. // ActionMessage returns the value of the "action_message" field in the mutation.
  23791. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  23792. v := m.action_message
  23793. if v == nil {
  23794. return
  23795. }
  23796. return *v, true
  23797. }
  23798. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  23799. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23801. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  23802. if !m.op.Is(OpUpdateOne) {
  23803. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  23804. }
  23805. if m.id == nil || m.oldValue == nil {
  23806. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  23807. }
  23808. oldValue, err := m.oldValue(ctx)
  23809. if err != nil {
  23810. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  23811. }
  23812. return oldValue.ActionMessage, nil
  23813. }
  23814. // AppendActionMessage adds ct to the "action_message" field.
  23815. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  23816. m.appendaction_message = append(m.appendaction_message, ct...)
  23817. }
  23818. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  23819. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  23820. if len(m.appendaction_message) == 0 {
  23821. return nil, false
  23822. }
  23823. return m.appendaction_message, true
  23824. }
  23825. // ClearActionMessage clears the value of the "action_message" field.
  23826. func (m *SopStageMutation) ClearActionMessage() {
  23827. m.action_message = nil
  23828. m.appendaction_message = nil
  23829. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  23830. }
  23831. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  23832. func (m *SopStageMutation) ActionMessageCleared() bool {
  23833. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  23834. return ok
  23835. }
  23836. // ResetActionMessage resets all changes to the "action_message" field.
  23837. func (m *SopStageMutation) ResetActionMessage() {
  23838. m.action_message = nil
  23839. m.appendaction_message = nil
  23840. delete(m.clearedFields, sopstage.FieldActionMessage)
  23841. }
  23842. // SetActionLabelAdd sets the "action_label_add" field.
  23843. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  23844. m.action_label_add = &u
  23845. m.appendaction_label_add = nil
  23846. }
  23847. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  23848. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  23849. v := m.action_label_add
  23850. if v == nil {
  23851. return
  23852. }
  23853. return *v, true
  23854. }
  23855. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  23856. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23857. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23858. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  23859. if !m.op.Is(OpUpdateOne) {
  23860. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  23861. }
  23862. if m.id == nil || m.oldValue == nil {
  23863. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  23864. }
  23865. oldValue, err := m.oldValue(ctx)
  23866. if err != nil {
  23867. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  23868. }
  23869. return oldValue.ActionLabelAdd, nil
  23870. }
  23871. // AppendActionLabelAdd adds u to the "action_label_add" field.
  23872. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  23873. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  23874. }
  23875. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  23876. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  23877. if len(m.appendaction_label_add) == 0 {
  23878. return nil, false
  23879. }
  23880. return m.appendaction_label_add, true
  23881. }
  23882. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  23883. func (m *SopStageMutation) ClearActionLabelAdd() {
  23884. m.action_label_add = nil
  23885. m.appendaction_label_add = nil
  23886. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  23887. }
  23888. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  23889. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  23890. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  23891. return ok
  23892. }
  23893. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  23894. func (m *SopStageMutation) ResetActionLabelAdd() {
  23895. m.action_label_add = nil
  23896. m.appendaction_label_add = nil
  23897. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  23898. }
  23899. // SetActionLabelDel sets the "action_label_del" field.
  23900. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  23901. m.action_label_del = &u
  23902. m.appendaction_label_del = nil
  23903. }
  23904. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  23905. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  23906. v := m.action_label_del
  23907. if v == nil {
  23908. return
  23909. }
  23910. return *v, true
  23911. }
  23912. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  23913. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23914. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23915. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  23916. if !m.op.Is(OpUpdateOne) {
  23917. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  23918. }
  23919. if m.id == nil || m.oldValue == nil {
  23920. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  23921. }
  23922. oldValue, err := m.oldValue(ctx)
  23923. if err != nil {
  23924. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  23925. }
  23926. return oldValue.ActionLabelDel, nil
  23927. }
  23928. // AppendActionLabelDel adds u to the "action_label_del" field.
  23929. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  23930. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  23931. }
  23932. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  23933. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  23934. if len(m.appendaction_label_del) == 0 {
  23935. return nil, false
  23936. }
  23937. return m.appendaction_label_del, true
  23938. }
  23939. // ClearActionLabelDel clears the value of the "action_label_del" field.
  23940. func (m *SopStageMutation) ClearActionLabelDel() {
  23941. m.action_label_del = nil
  23942. m.appendaction_label_del = nil
  23943. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  23944. }
  23945. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  23946. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  23947. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  23948. return ok
  23949. }
  23950. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  23951. func (m *SopStageMutation) ResetActionLabelDel() {
  23952. m.action_label_del = nil
  23953. m.appendaction_label_del = nil
  23954. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  23955. }
  23956. // SetActionForward sets the "action_forward" field.
  23957. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  23958. m.action_forward = &ctf
  23959. }
  23960. // ActionForward returns the value of the "action_forward" field in the mutation.
  23961. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  23962. v := m.action_forward
  23963. if v == nil {
  23964. return
  23965. }
  23966. return *v, true
  23967. }
  23968. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  23969. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23970. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23971. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  23972. if !m.op.Is(OpUpdateOne) {
  23973. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  23974. }
  23975. if m.id == nil || m.oldValue == nil {
  23976. return v, errors.New("OldActionForward requires an ID field in the mutation")
  23977. }
  23978. oldValue, err := m.oldValue(ctx)
  23979. if err != nil {
  23980. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  23981. }
  23982. return oldValue.ActionForward, nil
  23983. }
  23984. // ClearActionForward clears the value of the "action_forward" field.
  23985. func (m *SopStageMutation) ClearActionForward() {
  23986. m.action_forward = nil
  23987. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  23988. }
  23989. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  23990. func (m *SopStageMutation) ActionForwardCleared() bool {
  23991. _, ok := m.clearedFields[sopstage.FieldActionForward]
  23992. return ok
  23993. }
  23994. // ResetActionForward resets all changes to the "action_forward" field.
  23995. func (m *SopStageMutation) ResetActionForward() {
  23996. m.action_forward = nil
  23997. delete(m.clearedFields, sopstage.FieldActionForward)
  23998. }
  23999. // SetIndexSort sets the "index_sort" field.
  24000. func (m *SopStageMutation) SetIndexSort(i int) {
  24001. m.index_sort = &i
  24002. m.addindex_sort = nil
  24003. }
  24004. // IndexSort returns the value of the "index_sort" field in the mutation.
  24005. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  24006. v := m.index_sort
  24007. if v == nil {
  24008. return
  24009. }
  24010. return *v, true
  24011. }
  24012. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  24013. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24014. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24015. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  24016. if !m.op.Is(OpUpdateOne) {
  24017. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  24018. }
  24019. if m.id == nil || m.oldValue == nil {
  24020. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  24021. }
  24022. oldValue, err := m.oldValue(ctx)
  24023. if err != nil {
  24024. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  24025. }
  24026. return oldValue.IndexSort, nil
  24027. }
  24028. // AddIndexSort adds i to the "index_sort" field.
  24029. func (m *SopStageMutation) AddIndexSort(i int) {
  24030. if m.addindex_sort != nil {
  24031. *m.addindex_sort += i
  24032. } else {
  24033. m.addindex_sort = &i
  24034. }
  24035. }
  24036. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  24037. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  24038. v := m.addindex_sort
  24039. if v == nil {
  24040. return
  24041. }
  24042. return *v, true
  24043. }
  24044. // ClearIndexSort clears the value of the "index_sort" field.
  24045. func (m *SopStageMutation) ClearIndexSort() {
  24046. m.index_sort = nil
  24047. m.addindex_sort = nil
  24048. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  24049. }
  24050. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  24051. func (m *SopStageMutation) IndexSortCleared() bool {
  24052. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  24053. return ok
  24054. }
  24055. // ResetIndexSort resets all changes to the "index_sort" field.
  24056. func (m *SopStageMutation) ResetIndexSort() {
  24057. m.index_sort = nil
  24058. m.addindex_sort = nil
  24059. delete(m.clearedFields, sopstage.FieldIndexSort)
  24060. }
  24061. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  24062. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  24063. m.sop_task = &id
  24064. }
  24065. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  24066. func (m *SopStageMutation) ClearSopTask() {
  24067. m.clearedsop_task = true
  24068. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  24069. }
  24070. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  24071. func (m *SopStageMutation) SopTaskCleared() bool {
  24072. return m.clearedsop_task
  24073. }
  24074. // SopTaskID returns the "sop_task" edge ID in the mutation.
  24075. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  24076. if m.sop_task != nil {
  24077. return *m.sop_task, true
  24078. }
  24079. return
  24080. }
  24081. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  24082. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  24083. // SopTaskID instead. It exists only for internal usage by the builders.
  24084. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  24085. if id := m.sop_task; id != nil {
  24086. ids = append(ids, *id)
  24087. }
  24088. return
  24089. }
  24090. // ResetSopTask resets all changes to the "sop_task" edge.
  24091. func (m *SopStageMutation) ResetSopTask() {
  24092. m.sop_task = nil
  24093. m.clearedsop_task = false
  24094. }
  24095. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  24096. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  24097. if m.stage_nodes == nil {
  24098. m.stage_nodes = make(map[uint64]struct{})
  24099. }
  24100. for i := range ids {
  24101. m.stage_nodes[ids[i]] = struct{}{}
  24102. }
  24103. }
  24104. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  24105. func (m *SopStageMutation) ClearStageNodes() {
  24106. m.clearedstage_nodes = true
  24107. }
  24108. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  24109. func (m *SopStageMutation) StageNodesCleared() bool {
  24110. return m.clearedstage_nodes
  24111. }
  24112. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  24113. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  24114. if m.removedstage_nodes == nil {
  24115. m.removedstage_nodes = make(map[uint64]struct{})
  24116. }
  24117. for i := range ids {
  24118. delete(m.stage_nodes, ids[i])
  24119. m.removedstage_nodes[ids[i]] = struct{}{}
  24120. }
  24121. }
  24122. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  24123. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  24124. for id := range m.removedstage_nodes {
  24125. ids = append(ids, id)
  24126. }
  24127. return
  24128. }
  24129. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  24130. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  24131. for id := range m.stage_nodes {
  24132. ids = append(ids, id)
  24133. }
  24134. return
  24135. }
  24136. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  24137. func (m *SopStageMutation) ResetStageNodes() {
  24138. m.stage_nodes = nil
  24139. m.clearedstage_nodes = false
  24140. m.removedstage_nodes = nil
  24141. }
  24142. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  24143. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  24144. if m.stage_messages == nil {
  24145. m.stage_messages = make(map[uint64]struct{})
  24146. }
  24147. for i := range ids {
  24148. m.stage_messages[ids[i]] = struct{}{}
  24149. }
  24150. }
  24151. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  24152. func (m *SopStageMutation) ClearStageMessages() {
  24153. m.clearedstage_messages = true
  24154. }
  24155. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  24156. func (m *SopStageMutation) StageMessagesCleared() bool {
  24157. return m.clearedstage_messages
  24158. }
  24159. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  24160. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  24161. if m.removedstage_messages == nil {
  24162. m.removedstage_messages = make(map[uint64]struct{})
  24163. }
  24164. for i := range ids {
  24165. delete(m.stage_messages, ids[i])
  24166. m.removedstage_messages[ids[i]] = struct{}{}
  24167. }
  24168. }
  24169. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  24170. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  24171. for id := range m.removedstage_messages {
  24172. ids = append(ids, id)
  24173. }
  24174. return
  24175. }
  24176. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  24177. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  24178. for id := range m.stage_messages {
  24179. ids = append(ids, id)
  24180. }
  24181. return
  24182. }
  24183. // ResetStageMessages resets all changes to the "stage_messages" edge.
  24184. func (m *SopStageMutation) ResetStageMessages() {
  24185. m.stage_messages = nil
  24186. m.clearedstage_messages = false
  24187. m.removedstage_messages = nil
  24188. }
  24189. // Where appends a list predicates to the SopStageMutation builder.
  24190. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  24191. m.predicates = append(m.predicates, ps...)
  24192. }
  24193. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  24194. // users can use type-assertion to append predicates that do not depend on any generated package.
  24195. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  24196. p := make([]predicate.SopStage, len(ps))
  24197. for i := range ps {
  24198. p[i] = ps[i]
  24199. }
  24200. m.Where(p...)
  24201. }
  24202. // Op returns the operation name.
  24203. func (m *SopStageMutation) Op() Op {
  24204. return m.op
  24205. }
  24206. // SetOp allows setting the mutation operation.
  24207. func (m *SopStageMutation) SetOp(op Op) {
  24208. m.op = op
  24209. }
  24210. // Type returns the node type of this mutation (SopStage).
  24211. func (m *SopStageMutation) Type() string {
  24212. return m.typ
  24213. }
  24214. // Fields returns all fields that were changed during this mutation. Note that in
  24215. // order to get all numeric fields that were incremented/decremented, call
  24216. // AddedFields().
  24217. func (m *SopStageMutation) Fields() []string {
  24218. fields := make([]string, 0, 14)
  24219. if m.created_at != nil {
  24220. fields = append(fields, sopstage.FieldCreatedAt)
  24221. }
  24222. if m.updated_at != nil {
  24223. fields = append(fields, sopstage.FieldUpdatedAt)
  24224. }
  24225. if m.status != nil {
  24226. fields = append(fields, sopstage.FieldStatus)
  24227. }
  24228. if m.deleted_at != nil {
  24229. fields = append(fields, sopstage.FieldDeletedAt)
  24230. }
  24231. if m.sop_task != nil {
  24232. fields = append(fields, sopstage.FieldTaskID)
  24233. }
  24234. if m.name != nil {
  24235. fields = append(fields, sopstage.FieldName)
  24236. }
  24237. if m.condition_type != nil {
  24238. fields = append(fields, sopstage.FieldConditionType)
  24239. }
  24240. if m.condition_operator != nil {
  24241. fields = append(fields, sopstage.FieldConditionOperator)
  24242. }
  24243. if m.condition_list != nil {
  24244. fields = append(fields, sopstage.FieldConditionList)
  24245. }
  24246. if m.action_message != nil {
  24247. fields = append(fields, sopstage.FieldActionMessage)
  24248. }
  24249. if m.action_label_add != nil {
  24250. fields = append(fields, sopstage.FieldActionLabelAdd)
  24251. }
  24252. if m.action_label_del != nil {
  24253. fields = append(fields, sopstage.FieldActionLabelDel)
  24254. }
  24255. if m.action_forward != nil {
  24256. fields = append(fields, sopstage.FieldActionForward)
  24257. }
  24258. if m.index_sort != nil {
  24259. fields = append(fields, sopstage.FieldIndexSort)
  24260. }
  24261. return fields
  24262. }
  24263. // Field returns the value of a field with the given name. The second boolean
  24264. // return value indicates that this field was not set, or was not defined in the
  24265. // schema.
  24266. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  24267. switch name {
  24268. case sopstage.FieldCreatedAt:
  24269. return m.CreatedAt()
  24270. case sopstage.FieldUpdatedAt:
  24271. return m.UpdatedAt()
  24272. case sopstage.FieldStatus:
  24273. return m.Status()
  24274. case sopstage.FieldDeletedAt:
  24275. return m.DeletedAt()
  24276. case sopstage.FieldTaskID:
  24277. return m.TaskID()
  24278. case sopstage.FieldName:
  24279. return m.Name()
  24280. case sopstage.FieldConditionType:
  24281. return m.ConditionType()
  24282. case sopstage.FieldConditionOperator:
  24283. return m.ConditionOperator()
  24284. case sopstage.FieldConditionList:
  24285. return m.ConditionList()
  24286. case sopstage.FieldActionMessage:
  24287. return m.ActionMessage()
  24288. case sopstage.FieldActionLabelAdd:
  24289. return m.ActionLabelAdd()
  24290. case sopstage.FieldActionLabelDel:
  24291. return m.ActionLabelDel()
  24292. case sopstage.FieldActionForward:
  24293. return m.ActionForward()
  24294. case sopstage.FieldIndexSort:
  24295. return m.IndexSort()
  24296. }
  24297. return nil, false
  24298. }
  24299. // OldField returns the old value of the field from the database. An error is
  24300. // returned if the mutation operation is not UpdateOne, or the query to the
  24301. // database failed.
  24302. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24303. switch name {
  24304. case sopstage.FieldCreatedAt:
  24305. return m.OldCreatedAt(ctx)
  24306. case sopstage.FieldUpdatedAt:
  24307. return m.OldUpdatedAt(ctx)
  24308. case sopstage.FieldStatus:
  24309. return m.OldStatus(ctx)
  24310. case sopstage.FieldDeletedAt:
  24311. return m.OldDeletedAt(ctx)
  24312. case sopstage.FieldTaskID:
  24313. return m.OldTaskID(ctx)
  24314. case sopstage.FieldName:
  24315. return m.OldName(ctx)
  24316. case sopstage.FieldConditionType:
  24317. return m.OldConditionType(ctx)
  24318. case sopstage.FieldConditionOperator:
  24319. return m.OldConditionOperator(ctx)
  24320. case sopstage.FieldConditionList:
  24321. return m.OldConditionList(ctx)
  24322. case sopstage.FieldActionMessage:
  24323. return m.OldActionMessage(ctx)
  24324. case sopstage.FieldActionLabelAdd:
  24325. return m.OldActionLabelAdd(ctx)
  24326. case sopstage.FieldActionLabelDel:
  24327. return m.OldActionLabelDel(ctx)
  24328. case sopstage.FieldActionForward:
  24329. return m.OldActionForward(ctx)
  24330. case sopstage.FieldIndexSort:
  24331. return m.OldIndexSort(ctx)
  24332. }
  24333. return nil, fmt.Errorf("unknown SopStage field %s", name)
  24334. }
  24335. // SetField sets the value of a field with the given name. It returns an error if
  24336. // the field is not defined in the schema, or if the type mismatched the field
  24337. // type.
  24338. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  24339. switch name {
  24340. case sopstage.FieldCreatedAt:
  24341. v, ok := value.(time.Time)
  24342. if !ok {
  24343. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24344. }
  24345. m.SetCreatedAt(v)
  24346. return nil
  24347. case sopstage.FieldUpdatedAt:
  24348. v, ok := value.(time.Time)
  24349. if !ok {
  24350. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24351. }
  24352. m.SetUpdatedAt(v)
  24353. return nil
  24354. case sopstage.FieldStatus:
  24355. v, ok := value.(uint8)
  24356. if !ok {
  24357. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24358. }
  24359. m.SetStatus(v)
  24360. return nil
  24361. case sopstage.FieldDeletedAt:
  24362. v, ok := value.(time.Time)
  24363. if !ok {
  24364. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24365. }
  24366. m.SetDeletedAt(v)
  24367. return nil
  24368. case sopstage.FieldTaskID:
  24369. v, ok := value.(uint64)
  24370. if !ok {
  24371. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24372. }
  24373. m.SetTaskID(v)
  24374. return nil
  24375. case sopstage.FieldName:
  24376. v, ok := value.(string)
  24377. if !ok {
  24378. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24379. }
  24380. m.SetName(v)
  24381. return nil
  24382. case sopstage.FieldConditionType:
  24383. v, ok := value.(int)
  24384. if !ok {
  24385. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24386. }
  24387. m.SetConditionType(v)
  24388. return nil
  24389. case sopstage.FieldConditionOperator:
  24390. v, ok := value.(int)
  24391. if !ok {
  24392. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24393. }
  24394. m.SetConditionOperator(v)
  24395. return nil
  24396. case sopstage.FieldConditionList:
  24397. v, ok := value.([]custom_types.Condition)
  24398. if !ok {
  24399. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24400. }
  24401. m.SetConditionList(v)
  24402. return nil
  24403. case sopstage.FieldActionMessage:
  24404. v, ok := value.([]custom_types.Action)
  24405. if !ok {
  24406. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24407. }
  24408. m.SetActionMessage(v)
  24409. return nil
  24410. case sopstage.FieldActionLabelAdd:
  24411. v, ok := value.([]uint64)
  24412. if !ok {
  24413. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24414. }
  24415. m.SetActionLabelAdd(v)
  24416. return nil
  24417. case sopstage.FieldActionLabelDel:
  24418. v, ok := value.([]uint64)
  24419. if !ok {
  24420. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24421. }
  24422. m.SetActionLabelDel(v)
  24423. return nil
  24424. case sopstage.FieldActionForward:
  24425. v, ok := value.(*custom_types.ActionForward)
  24426. if !ok {
  24427. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24428. }
  24429. m.SetActionForward(v)
  24430. return nil
  24431. case sopstage.FieldIndexSort:
  24432. v, ok := value.(int)
  24433. if !ok {
  24434. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24435. }
  24436. m.SetIndexSort(v)
  24437. return nil
  24438. }
  24439. return fmt.Errorf("unknown SopStage field %s", name)
  24440. }
  24441. // AddedFields returns all numeric fields that were incremented/decremented during
  24442. // this mutation.
  24443. func (m *SopStageMutation) AddedFields() []string {
  24444. var fields []string
  24445. if m.addstatus != nil {
  24446. fields = append(fields, sopstage.FieldStatus)
  24447. }
  24448. if m.addcondition_type != nil {
  24449. fields = append(fields, sopstage.FieldConditionType)
  24450. }
  24451. if m.addcondition_operator != nil {
  24452. fields = append(fields, sopstage.FieldConditionOperator)
  24453. }
  24454. if m.addindex_sort != nil {
  24455. fields = append(fields, sopstage.FieldIndexSort)
  24456. }
  24457. return fields
  24458. }
  24459. // AddedField returns the numeric value that was incremented/decremented on a field
  24460. // with the given name. The second boolean return value indicates that this field
  24461. // was not set, or was not defined in the schema.
  24462. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  24463. switch name {
  24464. case sopstage.FieldStatus:
  24465. return m.AddedStatus()
  24466. case sopstage.FieldConditionType:
  24467. return m.AddedConditionType()
  24468. case sopstage.FieldConditionOperator:
  24469. return m.AddedConditionOperator()
  24470. case sopstage.FieldIndexSort:
  24471. return m.AddedIndexSort()
  24472. }
  24473. return nil, false
  24474. }
  24475. // AddField adds the value to the field with the given name. It returns an error if
  24476. // the field is not defined in the schema, or if the type mismatched the field
  24477. // type.
  24478. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  24479. switch name {
  24480. case sopstage.FieldStatus:
  24481. v, ok := value.(int8)
  24482. if !ok {
  24483. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24484. }
  24485. m.AddStatus(v)
  24486. return nil
  24487. case sopstage.FieldConditionType:
  24488. v, ok := value.(int)
  24489. if !ok {
  24490. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24491. }
  24492. m.AddConditionType(v)
  24493. return nil
  24494. case sopstage.FieldConditionOperator:
  24495. v, ok := value.(int)
  24496. if !ok {
  24497. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24498. }
  24499. m.AddConditionOperator(v)
  24500. return nil
  24501. case sopstage.FieldIndexSort:
  24502. v, ok := value.(int)
  24503. if !ok {
  24504. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24505. }
  24506. m.AddIndexSort(v)
  24507. return nil
  24508. }
  24509. return fmt.Errorf("unknown SopStage numeric field %s", name)
  24510. }
  24511. // ClearedFields returns all nullable fields that were cleared during this
  24512. // mutation.
  24513. func (m *SopStageMutation) ClearedFields() []string {
  24514. var fields []string
  24515. if m.FieldCleared(sopstage.FieldStatus) {
  24516. fields = append(fields, sopstage.FieldStatus)
  24517. }
  24518. if m.FieldCleared(sopstage.FieldDeletedAt) {
  24519. fields = append(fields, sopstage.FieldDeletedAt)
  24520. }
  24521. if m.FieldCleared(sopstage.FieldActionMessage) {
  24522. fields = append(fields, sopstage.FieldActionMessage)
  24523. }
  24524. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  24525. fields = append(fields, sopstage.FieldActionLabelAdd)
  24526. }
  24527. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  24528. fields = append(fields, sopstage.FieldActionLabelDel)
  24529. }
  24530. if m.FieldCleared(sopstage.FieldActionForward) {
  24531. fields = append(fields, sopstage.FieldActionForward)
  24532. }
  24533. if m.FieldCleared(sopstage.FieldIndexSort) {
  24534. fields = append(fields, sopstage.FieldIndexSort)
  24535. }
  24536. return fields
  24537. }
  24538. // FieldCleared returns a boolean indicating if a field with the given name was
  24539. // cleared in this mutation.
  24540. func (m *SopStageMutation) FieldCleared(name string) bool {
  24541. _, ok := m.clearedFields[name]
  24542. return ok
  24543. }
  24544. // ClearField clears the value of the field with the given name. It returns an
  24545. // error if the field is not defined in the schema.
  24546. func (m *SopStageMutation) ClearField(name string) error {
  24547. switch name {
  24548. case sopstage.FieldStatus:
  24549. m.ClearStatus()
  24550. return nil
  24551. case sopstage.FieldDeletedAt:
  24552. m.ClearDeletedAt()
  24553. return nil
  24554. case sopstage.FieldActionMessage:
  24555. m.ClearActionMessage()
  24556. return nil
  24557. case sopstage.FieldActionLabelAdd:
  24558. m.ClearActionLabelAdd()
  24559. return nil
  24560. case sopstage.FieldActionLabelDel:
  24561. m.ClearActionLabelDel()
  24562. return nil
  24563. case sopstage.FieldActionForward:
  24564. m.ClearActionForward()
  24565. return nil
  24566. case sopstage.FieldIndexSort:
  24567. m.ClearIndexSort()
  24568. return nil
  24569. }
  24570. return fmt.Errorf("unknown SopStage nullable field %s", name)
  24571. }
  24572. // ResetField resets all changes in the mutation for the field with the given name.
  24573. // It returns an error if the field is not defined in the schema.
  24574. func (m *SopStageMutation) ResetField(name string) error {
  24575. switch name {
  24576. case sopstage.FieldCreatedAt:
  24577. m.ResetCreatedAt()
  24578. return nil
  24579. case sopstage.FieldUpdatedAt:
  24580. m.ResetUpdatedAt()
  24581. return nil
  24582. case sopstage.FieldStatus:
  24583. m.ResetStatus()
  24584. return nil
  24585. case sopstage.FieldDeletedAt:
  24586. m.ResetDeletedAt()
  24587. return nil
  24588. case sopstage.FieldTaskID:
  24589. m.ResetTaskID()
  24590. return nil
  24591. case sopstage.FieldName:
  24592. m.ResetName()
  24593. return nil
  24594. case sopstage.FieldConditionType:
  24595. m.ResetConditionType()
  24596. return nil
  24597. case sopstage.FieldConditionOperator:
  24598. m.ResetConditionOperator()
  24599. return nil
  24600. case sopstage.FieldConditionList:
  24601. m.ResetConditionList()
  24602. return nil
  24603. case sopstage.FieldActionMessage:
  24604. m.ResetActionMessage()
  24605. return nil
  24606. case sopstage.FieldActionLabelAdd:
  24607. m.ResetActionLabelAdd()
  24608. return nil
  24609. case sopstage.FieldActionLabelDel:
  24610. m.ResetActionLabelDel()
  24611. return nil
  24612. case sopstage.FieldActionForward:
  24613. m.ResetActionForward()
  24614. return nil
  24615. case sopstage.FieldIndexSort:
  24616. m.ResetIndexSort()
  24617. return nil
  24618. }
  24619. return fmt.Errorf("unknown SopStage field %s", name)
  24620. }
  24621. // AddedEdges returns all edge names that were set/added in this mutation.
  24622. func (m *SopStageMutation) AddedEdges() []string {
  24623. edges := make([]string, 0, 3)
  24624. if m.sop_task != nil {
  24625. edges = append(edges, sopstage.EdgeSopTask)
  24626. }
  24627. if m.stage_nodes != nil {
  24628. edges = append(edges, sopstage.EdgeStageNodes)
  24629. }
  24630. if m.stage_messages != nil {
  24631. edges = append(edges, sopstage.EdgeStageMessages)
  24632. }
  24633. return edges
  24634. }
  24635. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24636. // name in this mutation.
  24637. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  24638. switch name {
  24639. case sopstage.EdgeSopTask:
  24640. if id := m.sop_task; id != nil {
  24641. return []ent.Value{*id}
  24642. }
  24643. case sopstage.EdgeStageNodes:
  24644. ids := make([]ent.Value, 0, len(m.stage_nodes))
  24645. for id := range m.stage_nodes {
  24646. ids = append(ids, id)
  24647. }
  24648. return ids
  24649. case sopstage.EdgeStageMessages:
  24650. ids := make([]ent.Value, 0, len(m.stage_messages))
  24651. for id := range m.stage_messages {
  24652. ids = append(ids, id)
  24653. }
  24654. return ids
  24655. }
  24656. return nil
  24657. }
  24658. // RemovedEdges returns all edge names that were removed in this mutation.
  24659. func (m *SopStageMutation) RemovedEdges() []string {
  24660. edges := make([]string, 0, 3)
  24661. if m.removedstage_nodes != nil {
  24662. edges = append(edges, sopstage.EdgeStageNodes)
  24663. }
  24664. if m.removedstage_messages != nil {
  24665. edges = append(edges, sopstage.EdgeStageMessages)
  24666. }
  24667. return edges
  24668. }
  24669. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24670. // the given name in this mutation.
  24671. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  24672. switch name {
  24673. case sopstage.EdgeStageNodes:
  24674. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  24675. for id := range m.removedstage_nodes {
  24676. ids = append(ids, id)
  24677. }
  24678. return ids
  24679. case sopstage.EdgeStageMessages:
  24680. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  24681. for id := range m.removedstage_messages {
  24682. ids = append(ids, id)
  24683. }
  24684. return ids
  24685. }
  24686. return nil
  24687. }
  24688. // ClearedEdges returns all edge names that were cleared in this mutation.
  24689. func (m *SopStageMutation) ClearedEdges() []string {
  24690. edges := make([]string, 0, 3)
  24691. if m.clearedsop_task {
  24692. edges = append(edges, sopstage.EdgeSopTask)
  24693. }
  24694. if m.clearedstage_nodes {
  24695. edges = append(edges, sopstage.EdgeStageNodes)
  24696. }
  24697. if m.clearedstage_messages {
  24698. edges = append(edges, sopstage.EdgeStageMessages)
  24699. }
  24700. return edges
  24701. }
  24702. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24703. // was cleared in this mutation.
  24704. func (m *SopStageMutation) EdgeCleared(name string) bool {
  24705. switch name {
  24706. case sopstage.EdgeSopTask:
  24707. return m.clearedsop_task
  24708. case sopstage.EdgeStageNodes:
  24709. return m.clearedstage_nodes
  24710. case sopstage.EdgeStageMessages:
  24711. return m.clearedstage_messages
  24712. }
  24713. return false
  24714. }
  24715. // ClearEdge clears the value of the edge with the given name. It returns an error
  24716. // if that edge is not defined in the schema.
  24717. func (m *SopStageMutation) ClearEdge(name string) error {
  24718. switch name {
  24719. case sopstage.EdgeSopTask:
  24720. m.ClearSopTask()
  24721. return nil
  24722. }
  24723. return fmt.Errorf("unknown SopStage unique edge %s", name)
  24724. }
  24725. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24726. // It returns an error if the edge is not defined in the schema.
  24727. func (m *SopStageMutation) ResetEdge(name string) error {
  24728. switch name {
  24729. case sopstage.EdgeSopTask:
  24730. m.ResetSopTask()
  24731. return nil
  24732. case sopstage.EdgeStageNodes:
  24733. m.ResetStageNodes()
  24734. return nil
  24735. case sopstage.EdgeStageMessages:
  24736. m.ResetStageMessages()
  24737. return nil
  24738. }
  24739. return fmt.Errorf("unknown SopStage edge %s", name)
  24740. }
  24741. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  24742. type SopTaskMutation struct {
  24743. config
  24744. op Op
  24745. typ string
  24746. id *uint64
  24747. created_at *time.Time
  24748. updated_at *time.Time
  24749. status *uint8
  24750. addstatus *int8
  24751. deleted_at *time.Time
  24752. name *string
  24753. bot_wxid_list *[]string
  24754. appendbot_wxid_list []string
  24755. _type *int
  24756. add_type *int
  24757. plan_start_time *time.Time
  24758. plan_end_time *time.Time
  24759. creator_id *string
  24760. organization_id *uint64
  24761. addorganization_id *int64
  24762. token *[]string
  24763. appendtoken []string
  24764. clearedFields map[string]struct{}
  24765. task_stages map[uint64]struct{}
  24766. removedtask_stages map[uint64]struct{}
  24767. clearedtask_stages bool
  24768. done bool
  24769. oldValue func(context.Context) (*SopTask, error)
  24770. predicates []predicate.SopTask
  24771. }
  24772. var _ ent.Mutation = (*SopTaskMutation)(nil)
  24773. // soptaskOption allows management of the mutation configuration using functional options.
  24774. type soptaskOption func(*SopTaskMutation)
  24775. // newSopTaskMutation creates new mutation for the SopTask entity.
  24776. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  24777. m := &SopTaskMutation{
  24778. config: c,
  24779. op: op,
  24780. typ: TypeSopTask,
  24781. clearedFields: make(map[string]struct{}),
  24782. }
  24783. for _, opt := range opts {
  24784. opt(m)
  24785. }
  24786. return m
  24787. }
  24788. // withSopTaskID sets the ID field of the mutation.
  24789. func withSopTaskID(id uint64) soptaskOption {
  24790. return func(m *SopTaskMutation) {
  24791. var (
  24792. err error
  24793. once sync.Once
  24794. value *SopTask
  24795. )
  24796. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  24797. once.Do(func() {
  24798. if m.done {
  24799. err = errors.New("querying old values post mutation is not allowed")
  24800. } else {
  24801. value, err = m.Client().SopTask.Get(ctx, id)
  24802. }
  24803. })
  24804. return value, err
  24805. }
  24806. m.id = &id
  24807. }
  24808. }
  24809. // withSopTask sets the old SopTask of the mutation.
  24810. func withSopTask(node *SopTask) soptaskOption {
  24811. return func(m *SopTaskMutation) {
  24812. m.oldValue = func(context.Context) (*SopTask, error) {
  24813. return node, nil
  24814. }
  24815. m.id = &node.ID
  24816. }
  24817. }
  24818. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24819. // executed in a transaction (ent.Tx), a transactional client is returned.
  24820. func (m SopTaskMutation) Client() *Client {
  24821. client := &Client{config: m.config}
  24822. client.init()
  24823. return client
  24824. }
  24825. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24826. // it returns an error otherwise.
  24827. func (m SopTaskMutation) Tx() (*Tx, error) {
  24828. if _, ok := m.driver.(*txDriver); !ok {
  24829. return nil, errors.New("ent: mutation is not running in a transaction")
  24830. }
  24831. tx := &Tx{config: m.config}
  24832. tx.init()
  24833. return tx, nil
  24834. }
  24835. // SetID sets the value of the id field. Note that this
  24836. // operation is only accepted on creation of SopTask entities.
  24837. func (m *SopTaskMutation) SetID(id uint64) {
  24838. m.id = &id
  24839. }
  24840. // ID returns the ID value in the mutation. Note that the ID is only available
  24841. // if it was provided to the builder or after it was returned from the database.
  24842. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  24843. if m.id == nil {
  24844. return
  24845. }
  24846. return *m.id, true
  24847. }
  24848. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24849. // That means, if the mutation is applied within a transaction with an isolation level such
  24850. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24851. // or updated by the mutation.
  24852. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  24853. switch {
  24854. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24855. id, exists := m.ID()
  24856. if exists {
  24857. return []uint64{id}, nil
  24858. }
  24859. fallthrough
  24860. case m.op.Is(OpUpdate | OpDelete):
  24861. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  24862. default:
  24863. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24864. }
  24865. }
  24866. // SetCreatedAt sets the "created_at" field.
  24867. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  24868. m.created_at = &t
  24869. }
  24870. // CreatedAt returns the value of the "created_at" field in the mutation.
  24871. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  24872. v := m.created_at
  24873. if v == nil {
  24874. return
  24875. }
  24876. return *v, true
  24877. }
  24878. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  24879. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24880. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24881. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24882. if !m.op.Is(OpUpdateOne) {
  24883. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24884. }
  24885. if m.id == nil || m.oldValue == nil {
  24886. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24887. }
  24888. oldValue, err := m.oldValue(ctx)
  24889. if err != nil {
  24890. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24891. }
  24892. return oldValue.CreatedAt, nil
  24893. }
  24894. // ResetCreatedAt resets all changes to the "created_at" field.
  24895. func (m *SopTaskMutation) ResetCreatedAt() {
  24896. m.created_at = nil
  24897. }
  24898. // SetUpdatedAt sets the "updated_at" field.
  24899. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  24900. m.updated_at = &t
  24901. }
  24902. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24903. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  24904. v := m.updated_at
  24905. if v == nil {
  24906. return
  24907. }
  24908. return *v, true
  24909. }
  24910. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  24911. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24912. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24913. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24914. if !m.op.Is(OpUpdateOne) {
  24915. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24916. }
  24917. if m.id == nil || m.oldValue == nil {
  24918. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24919. }
  24920. oldValue, err := m.oldValue(ctx)
  24921. if err != nil {
  24922. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24923. }
  24924. return oldValue.UpdatedAt, nil
  24925. }
  24926. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24927. func (m *SopTaskMutation) ResetUpdatedAt() {
  24928. m.updated_at = nil
  24929. }
  24930. // SetStatus sets the "status" field.
  24931. func (m *SopTaskMutation) SetStatus(u uint8) {
  24932. m.status = &u
  24933. m.addstatus = nil
  24934. }
  24935. // Status returns the value of the "status" field in the mutation.
  24936. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  24937. v := m.status
  24938. if v == nil {
  24939. return
  24940. }
  24941. return *v, true
  24942. }
  24943. // OldStatus returns the old "status" field's value of the SopTask entity.
  24944. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24945. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24946. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  24947. if !m.op.Is(OpUpdateOne) {
  24948. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  24949. }
  24950. if m.id == nil || m.oldValue == nil {
  24951. return v, errors.New("OldStatus requires an ID field in the mutation")
  24952. }
  24953. oldValue, err := m.oldValue(ctx)
  24954. if err != nil {
  24955. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  24956. }
  24957. return oldValue.Status, nil
  24958. }
  24959. // AddStatus adds u to the "status" field.
  24960. func (m *SopTaskMutation) AddStatus(u int8) {
  24961. if m.addstatus != nil {
  24962. *m.addstatus += u
  24963. } else {
  24964. m.addstatus = &u
  24965. }
  24966. }
  24967. // AddedStatus returns the value that was added to the "status" field in this mutation.
  24968. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  24969. v := m.addstatus
  24970. if v == nil {
  24971. return
  24972. }
  24973. return *v, true
  24974. }
  24975. // ClearStatus clears the value of the "status" field.
  24976. func (m *SopTaskMutation) ClearStatus() {
  24977. m.status = nil
  24978. m.addstatus = nil
  24979. m.clearedFields[soptask.FieldStatus] = struct{}{}
  24980. }
  24981. // StatusCleared returns if the "status" field was cleared in this mutation.
  24982. func (m *SopTaskMutation) StatusCleared() bool {
  24983. _, ok := m.clearedFields[soptask.FieldStatus]
  24984. return ok
  24985. }
  24986. // ResetStatus resets all changes to the "status" field.
  24987. func (m *SopTaskMutation) ResetStatus() {
  24988. m.status = nil
  24989. m.addstatus = nil
  24990. delete(m.clearedFields, soptask.FieldStatus)
  24991. }
  24992. // SetDeletedAt sets the "deleted_at" field.
  24993. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  24994. m.deleted_at = &t
  24995. }
  24996. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  24997. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  24998. v := m.deleted_at
  24999. if v == nil {
  25000. return
  25001. }
  25002. return *v, true
  25003. }
  25004. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  25005. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25006. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25007. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25008. if !m.op.Is(OpUpdateOne) {
  25009. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25010. }
  25011. if m.id == nil || m.oldValue == nil {
  25012. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25013. }
  25014. oldValue, err := m.oldValue(ctx)
  25015. if err != nil {
  25016. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25017. }
  25018. return oldValue.DeletedAt, nil
  25019. }
  25020. // ClearDeletedAt clears the value of the "deleted_at" field.
  25021. func (m *SopTaskMutation) ClearDeletedAt() {
  25022. m.deleted_at = nil
  25023. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  25024. }
  25025. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25026. func (m *SopTaskMutation) DeletedAtCleared() bool {
  25027. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  25028. return ok
  25029. }
  25030. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25031. func (m *SopTaskMutation) ResetDeletedAt() {
  25032. m.deleted_at = nil
  25033. delete(m.clearedFields, soptask.FieldDeletedAt)
  25034. }
  25035. // SetName sets the "name" field.
  25036. func (m *SopTaskMutation) SetName(s string) {
  25037. m.name = &s
  25038. }
  25039. // Name returns the value of the "name" field in the mutation.
  25040. func (m *SopTaskMutation) Name() (r string, exists bool) {
  25041. v := m.name
  25042. if v == nil {
  25043. return
  25044. }
  25045. return *v, true
  25046. }
  25047. // OldName returns the old "name" field's value of the SopTask entity.
  25048. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25049. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25050. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  25051. if !m.op.Is(OpUpdateOne) {
  25052. return v, errors.New("OldName is only allowed on UpdateOne operations")
  25053. }
  25054. if m.id == nil || m.oldValue == nil {
  25055. return v, errors.New("OldName requires an ID field in the mutation")
  25056. }
  25057. oldValue, err := m.oldValue(ctx)
  25058. if err != nil {
  25059. return v, fmt.Errorf("querying old value for OldName: %w", err)
  25060. }
  25061. return oldValue.Name, nil
  25062. }
  25063. // ResetName resets all changes to the "name" field.
  25064. func (m *SopTaskMutation) ResetName() {
  25065. m.name = nil
  25066. }
  25067. // SetBotWxidList sets the "bot_wxid_list" field.
  25068. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  25069. m.bot_wxid_list = &s
  25070. m.appendbot_wxid_list = nil
  25071. }
  25072. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  25073. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  25074. v := m.bot_wxid_list
  25075. if v == nil {
  25076. return
  25077. }
  25078. return *v, true
  25079. }
  25080. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  25081. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25082. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25083. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  25084. if !m.op.Is(OpUpdateOne) {
  25085. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  25086. }
  25087. if m.id == nil || m.oldValue == nil {
  25088. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  25089. }
  25090. oldValue, err := m.oldValue(ctx)
  25091. if err != nil {
  25092. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  25093. }
  25094. return oldValue.BotWxidList, nil
  25095. }
  25096. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  25097. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  25098. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  25099. }
  25100. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  25101. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  25102. if len(m.appendbot_wxid_list) == 0 {
  25103. return nil, false
  25104. }
  25105. return m.appendbot_wxid_list, true
  25106. }
  25107. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  25108. func (m *SopTaskMutation) ClearBotWxidList() {
  25109. m.bot_wxid_list = nil
  25110. m.appendbot_wxid_list = nil
  25111. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  25112. }
  25113. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  25114. func (m *SopTaskMutation) BotWxidListCleared() bool {
  25115. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  25116. return ok
  25117. }
  25118. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  25119. func (m *SopTaskMutation) ResetBotWxidList() {
  25120. m.bot_wxid_list = nil
  25121. m.appendbot_wxid_list = nil
  25122. delete(m.clearedFields, soptask.FieldBotWxidList)
  25123. }
  25124. // SetType sets the "type" field.
  25125. func (m *SopTaskMutation) SetType(i int) {
  25126. m._type = &i
  25127. m.add_type = nil
  25128. }
  25129. // GetType returns the value of the "type" field in the mutation.
  25130. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  25131. v := m._type
  25132. if v == nil {
  25133. return
  25134. }
  25135. return *v, true
  25136. }
  25137. // OldType returns the old "type" field's value of the SopTask entity.
  25138. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25139. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25140. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  25141. if !m.op.Is(OpUpdateOne) {
  25142. return v, errors.New("OldType is only allowed on UpdateOne operations")
  25143. }
  25144. if m.id == nil || m.oldValue == nil {
  25145. return v, errors.New("OldType requires an ID field in the mutation")
  25146. }
  25147. oldValue, err := m.oldValue(ctx)
  25148. if err != nil {
  25149. return v, fmt.Errorf("querying old value for OldType: %w", err)
  25150. }
  25151. return oldValue.Type, nil
  25152. }
  25153. // AddType adds i to the "type" field.
  25154. func (m *SopTaskMutation) AddType(i int) {
  25155. if m.add_type != nil {
  25156. *m.add_type += i
  25157. } else {
  25158. m.add_type = &i
  25159. }
  25160. }
  25161. // AddedType returns the value that was added to the "type" field in this mutation.
  25162. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  25163. v := m.add_type
  25164. if v == nil {
  25165. return
  25166. }
  25167. return *v, true
  25168. }
  25169. // ResetType resets all changes to the "type" field.
  25170. func (m *SopTaskMutation) ResetType() {
  25171. m._type = nil
  25172. m.add_type = nil
  25173. }
  25174. // SetPlanStartTime sets the "plan_start_time" field.
  25175. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  25176. m.plan_start_time = &t
  25177. }
  25178. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  25179. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  25180. v := m.plan_start_time
  25181. if v == nil {
  25182. return
  25183. }
  25184. return *v, true
  25185. }
  25186. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  25187. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25189. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  25190. if !m.op.Is(OpUpdateOne) {
  25191. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  25192. }
  25193. if m.id == nil || m.oldValue == nil {
  25194. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  25195. }
  25196. oldValue, err := m.oldValue(ctx)
  25197. if err != nil {
  25198. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  25199. }
  25200. return oldValue.PlanStartTime, nil
  25201. }
  25202. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  25203. func (m *SopTaskMutation) ClearPlanStartTime() {
  25204. m.plan_start_time = nil
  25205. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  25206. }
  25207. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  25208. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  25209. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  25210. return ok
  25211. }
  25212. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  25213. func (m *SopTaskMutation) ResetPlanStartTime() {
  25214. m.plan_start_time = nil
  25215. delete(m.clearedFields, soptask.FieldPlanStartTime)
  25216. }
  25217. // SetPlanEndTime sets the "plan_end_time" field.
  25218. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  25219. m.plan_end_time = &t
  25220. }
  25221. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  25222. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  25223. v := m.plan_end_time
  25224. if v == nil {
  25225. return
  25226. }
  25227. return *v, true
  25228. }
  25229. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  25230. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25231. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25232. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  25233. if !m.op.Is(OpUpdateOne) {
  25234. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  25235. }
  25236. if m.id == nil || m.oldValue == nil {
  25237. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  25238. }
  25239. oldValue, err := m.oldValue(ctx)
  25240. if err != nil {
  25241. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  25242. }
  25243. return oldValue.PlanEndTime, nil
  25244. }
  25245. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  25246. func (m *SopTaskMutation) ClearPlanEndTime() {
  25247. m.plan_end_time = nil
  25248. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  25249. }
  25250. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  25251. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  25252. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  25253. return ok
  25254. }
  25255. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  25256. func (m *SopTaskMutation) ResetPlanEndTime() {
  25257. m.plan_end_time = nil
  25258. delete(m.clearedFields, soptask.FieldPlanEndTime)
  25259. }
  25260. // SetCreatorID sets the "creator_id" field.
  25261. func (m *SopTaskMutation) SetCreatorID(s string) {
  25262. m.creator_id = &s
  25263. }
  25264. // CreatorID returns the value of the "creator_id" field in the mutation.
  25265. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  25266. v := m.creator_id
  25267. if v == nil {
  25268. return
  25269. }
  25270. return *v, true
  25271. }
  25272. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  25273. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25274. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25275. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  25276. if !m.op.Is(OpUpdateOne) {
  25277. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  25278. }
  25279. if m.id == nil || m.oldValue == nil {
  25280. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  25281. }
  25282. oldValue, err := m.oldValue(ctx)
  25283. if err != nil {
  25284. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  25285. }
  25286. return oldValue.CreatorID, nil
  25287. }
  25288. // ClearCreatorID clears the value of the "creator_id" field.
  25289. func (m *SopTaskMutation) ClearCreatorID() {
  25290. m.creator_id = nil
  25291. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  25292. }
  25293. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  25294. func (m *SopTaskMutation) CreatorIDCleared() bool {
  25295. _, ok := m.clearedFields[soptask.FieldCreatorID]
  25296. return ok
  25297. }
  25298. // ResetCreatorID resets all changes to the "creator_id" field.
  25299. func (m *SopTaskMutation) ResetCreatorID() {
  25300. m.creator_id = nil
  25301. delete(m.clearedFields, soptask.FieldCreatorID)
  25302. }
  25303. // SetOrganizationID sets the "organization_id" field.
  25304. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  25305. m.organization_id = &u
  25306. m.addorganization_id = nil
  25307. }
  25308. // OrganizationID returns the value of the "organization_id" field in the mutation.
  25309. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  25310. v := m.organization_id
  25311. if v == nil {
  25312. return
  25313. }
  25314. return *v, true
  25315. }
  25316. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  25317. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25319. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  25320. if !m.op.Is(OpUpdateOne) {
  25321. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  25322. }
  25323. if m.id == nil || m.oldValue == nil {
  25324. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  25325. }
  25326. oldValue, err := m.oldValue(ctx)
  25327. if err != nil {
  25328. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  25329. }
  25330. return oldValue.OrganizationID, nil
  25331. }
  25332. // AddOrganizationID adds u to the "organization_id" field.
  25333. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  25334. if m.addorganization_id != nil {
  25335. *m.addorganization_id += u
  25336. } else {
  25337. m.addorganization_id = &u
  25338. }
  25339. }
  25340. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  25341. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  25342. v := m.addorganization_id
  25343. if v == nil {
  25344. return
  25345. }
  25346. return *v, true
  25347. }
  25348. // ClearOrganizationID clears the value of the "organization_id" field.
  25349. func (m *SopTaskMutation) ClearOrganizationID() {
  25350. m.organization_id = nil
  25351. m.addorganization_id = nil
  25352. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  25353. }
  25354. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  25355. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  25356. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  25357. return ok
  25358. }
  25359. // ResetOrganizationID resets all changes to the "organization_id" field.
  25360. func (m *SopTaskMutation) ResetOrganizationID() {
  25361. m.organization_id = nil
  25362. m.addorganization_id = nil
  25363. delete(m.clearedFields, soptask.FieldOrganizationID)
  25364. }
  25365. // SetToken sets the "token" field.
  25366. func (m *SopTaskMutation) SetToken(s []string) {
  25367. m.token = &s
  25368. m.appendtoken = nil
  25369. }
  25370. // Token returns the value of the "token" field in the mutation.
  25371. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  25372. v := m.token
  25373. if v == nil {
  25374. return
  25375. }
  25376. return *v, true
  25377. }
  25378. // OldToken returns the old "token" field's value of the SopTask entity.
  25379. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25380. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25381. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  25382. if !m.op.Is(OpUpdateOne) {
  25383. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  25384. }
  25385. if m.id == nil || m.oldValue == nil {
  25386. return v, errors.New("OldToken requires an ID field in the mutation")
  25387. }
  25388. oldValue, err := m.oldValue(ctx)
  25389. if err != nil {
  25390. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  25391. }
  25392. return oldValue.Token, nil
  25393. }
  25394. // AppendToken adds s to the "token" field.
  25395. func (m *SopTaskMutation) AppendToken(s []string) {
  25396. m.appendtoken = append(m.appendtoken, s...)
  25397. }
  25398. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  25399. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  25400. if len(m.appendtoken) == 0 {
  25401. return nil, false
  25402. }
  25403. return m.appendtoken, true
  25404. }
  25405. // ClearToken clears the value of the "token" field.
  25406. func (m *SopTaskMutation) ClearToken() {
  25407. m.token = nil
  25408. m.appendtoken = nil
  25409. m.clearedFields[soptask.FieldToken] = struct{}{}
  25410. }
  25411. // TokenCleared returns if the "token" field was cleared in this mutation.
  25412. func (m *SopTaskMutation) TokenCleared() bool {
  25413. _, ok := m.clearedFields[soptask.FieldToken]
  25414. return ok
  25415. }
  25416. // ResetToken resets all changes to the "token" field.
  25417. func (m *SopTaskMutation) ResetToken() {
  25418. m.token = nil
  25419. m.appendtoken = nil
  25420. delete(m.clearedFields, soptask.FieldToken)
  25421. }
  25422. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  25423. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  25424. if m.task_stages == nil {
  25425. m.task_stages = make(map[uint64]struct{})
  25426. }
  25427. for i := range ids {
  25428. m.task_stages[ids[i]] = struct{}{}
  25429. }
  25430. }
  25431. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  25432. func (m *SopTaskMutation) ClearTaskStages() {
  25433. m.clearedtask_stages = true
  25434. }
  25435. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  25436. func (m *SopTaskMutation) TaskStagesCleared() bool {
  25437. return m.clearedtask_stages
  25438. }
  25439. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  25440. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  25441. if m.removedtask_stages == nil {
  25442. m.removedtask_stages = make(map[uint64]struct{})
  25443. }
  25444. for i := range ids {
  25445. delete(m.task_stages, ids[i])
  25446. m.removedtask_stages[ids[i]] = struct{}{}
  25447. }
  25448. }
  25449. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  25450. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  25451. for id := range m.removedtask_stages {
  25452. ids = append(ids, id)
  25453. }
  25454. return
  25455. }
  25456. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  25457. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  25458. for id := range m.task_stages {
  25459. ids = append(ids, id)
  25460. }
  25461. return
  25462. }
  25463. // ResetTaskStages resets all changes to the "task_stages" edge.
  25464. func (m *SopTaskMutation) ResetTaskStages() {
  25465. m.task_stages = nil
  25466. m.clearedtask_stages = false
  25467. m.removedtask_stages = nil
  25468. }
  25469. // Where appends a list predicates to the SopTaskMutation builder.
  25470. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  25471. m.predicates = append(m.predicates, ps...)
  25472. }
  25473. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  25474. // users can use type-assertion to append predicates that do not depend on any generated package.
  25475. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  25476. p := make([]predicate.SopTask, len(ps))
  25477. for i := range ps {
  25478. p[i] = ps[i]
  25479. }
  25480. m.Where(p...)
  25481. }
  25482. // Op returns the operation name.
  25483. func (m *SopTaskMutation) Op() Op {
  25484. return m.op
  25485. }
  25486. // SetOp allows setting the mutation operation.
  25487. func (m *SopTaskMutation) SetOp(op Op) {
  25488. m.op = op
  25489. }
  25490. // Type returns the node type of this mutation (SopTask).
  25491. func (m *SopTaskMutation) Type() string {
  25492. return m.typ
  25493. }
  25494. // Fields returns all fields that were changed during this mutation. Note that in
  25495. // order to get all numeric fields that were incremented/decremented, call
  25496. // AddedFields().
  25497. func (m *SopTaskMutation) Fields() []string {
  25498. fields := make([]string, 0, 12)
  25499. if m.created_at != nil {
  25500. fields = append(fields, soptask.FieldCreatedAt)
  25501. }
  25502. if m.updated_at != nil {
  25503. fields = append(fields, soptask.FieldUpdatedAt)
  25504. }
  25505. if m.status != nil {
  25506. fields = append(fields, soptask.FieldStatus)
  25507. }
  25508. if m.deleted_at != nil {
  25509. fields = append(fields, soptask.FieldDeletedAt)
  25510. }
  25511. if m.name != nil {
  25512. fields = append(fields, soptask.FieldName)
  25513. }
  25514. if m.bot_wxid_list != nil {
  25515. fields = append(fields, soptask.FieldBotWxidList)
  25516. }
  25517. if m._type != nil {
  25518. fields = append(fields, soptask.FieldType)
  25519. }
  25520. if m.plan_start_time != nil {
  25521. fields = append(fields, soptask.FieldPlanStartTime)
  25522. }
  25523. if m.plan_end_time != nil {
  25524. fields = append(fields, soptask.FieldPlanEndTime)
  25525. }
  25526. if m.creator_id != nil {
  25527. fields = append(fields, soptask.FieldCreatorID)
  25528. }
  25529. if m.organization_id != nil {
  25530. fields = append(fields, soptask.FieldOrganizationID)
  25531. }
  25532. if m.token != nil {
  25533. fields = append(fields, soptask.FieldToken)
  25534. }
  25535. return fields
  25536. }
  25537. // Field returns the value of a field with the given name. The second boolean
  25538. // return value indicates that this field was not set, or was not defined in the
  25539. // schema.
  25540. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  25541. switch name {
  25542. case soptask.FieldCreatedAt:
  25543. return m.CreatedAt()
  25544. case soptask.FieldUpdatedAt:
  25545. return m.UpdatedAt()
  25546. case soptask.FieldStatus:
  25547. return m.Status()
  25548. case soptask.FieldDeletedAt:
  25549. return m.DeletedAt()
  25550. case soptask.FieldName:
  25551. return m.Name()
  25552. case soptask.FieldBotWxidList:
  25553. return m.BotWxidList()
  25554. case soptask.FieldType:
  25555. return m.GetType()
  25556. case soptask.FieldPlanStartTime:
  25557. return m.PlanStartTime()
  25558. case soptask.FieldPlanEndTime:
  25559. return m.PlanEndTime()
  25560. case soptask.FieldCreatorID:
  25561. return m.CreatorID()
  25562. case soptask.FieldOrganizationID:
  25563. return m.OrganizationID()
  25564. case soptask.FieldToken:
  25565. return m.Token()
  25566. }
  25567. return nil, false
  25568. }
  25569. // OldField returns the old value of the field from the database. An error is
  25570. // returned if the mutation operation is not UpdateOne, or the query to the
  25571. // database failed.
  25572. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25573. switch name {
  25574. case soptask.FieldCreatedAt:
  25575. return m.OldCreatedAt(ctx)
  25576. case soptask.FieldUpdatedAt:
  25577. return m.OldUpdatedAt(ctx)
  25578. case soptask.FieldStatus:
  25579. return m.OldStatus(ctx)
  25580. case soptask.FieldDeletedAt:
  25581. return m.OldDeletedAt(ctx)
  25582. case soptask.FieldName:
  25583. return m.OldName(ctx)
  25584. case soptask.FieldBotWxidList:
  25585. return m.OldBotWxidList(ctx)
  25586. case soptask.FieldType:
  25587. return m.OldType(ctx)
  25588. case soptask.FieldPlanStartTime:
  25589. return m.OldPlanStartTime(ctx)
  25590. case soptask.FieldPlanEndTime:
  25591. return m.OldPlanEndTime(ctx)
  25592. case soptask.FieldCreatorID:
  25593. return m.OldCreatorID(ctx)
  25594. case soptask.FieldOrganizationID:
  25595. return m.OldOrganizationID(ctx)
  25596. case soptask.FieldToken:
  25597. return m.OldToken(ctx)
  25598. }
  25599. return nil, fmt.Errorf("unknown SopTask field %s", name)
  25600. }
  25601. // SetField sets the value of a field with the given name. It returns an error if
  25602. // the field is not defined in the schema, or if the type mismatched the field
  25603. // type.
  25604. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  25605. switch name {
  25606. case soptask.FieldCreatedAt:
  25607. v, ok := value.(time.Time)
  25608. if !ok {
  25609. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25610. }
  25611. m.SetCreatedAt(v)
  25612. return nil
  25613. case soptask.FieldUpdatedAt:
  25614. v, ok := value.(time.Time)
  25615. if !ok {
  25616. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25617. }
  25618. m.SetUpdatedAt(v)
  25619. return nil
  25620. case soptask.FieldStatus:
  25621. v, ok := value.(uint8)
  25622. if !ok {
  25623. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25624. }
  25625. m.SetStatus(v)
  25626. return nil
  25627. case soptask.FieldDeletedAt:
  25628. v, ok := value.(time.Time)
  25629. if !ok {
  25630. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25631. }
  25632. m.SetDeletedAt(v)
  25633. return nil
  25634. case soptask.FieldName:
  25635. v, ok := value.(string)
  25636. if !ok {
  25637. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25638. }
  25639. m.SetName(v)
  25640. return nil
  25641. case soptask.FieldBotWxidList:
  25642. v, ok := value.([]string)
  25643. if !ok {
  25644. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25645. }
  25646. m.SetBotWxidList(v)
  25647. return nil
  25648. case soptask.FieldType:
  25649. v, ok := value.(int)
  25650. if !ok {
  25651. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25652. }
  25653. m.SetType(v)
  25654. return nil
  25655. case soptask.FieldPlanStartTime:
  25656. v, ok := value.(time.Time)
  25657. if !ok {
  25658. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25659. }
  25660. m.SetPlanStartTime(v)
  25661. return nil
  25662. case soptask.FieldPlanEndTime:
  25663. v, ok := value.(time.Time)
  25664. if !ok {
  25665. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25666. }
  25667. m.SetPlanEndTime(v)
  25668. return nil
  25669. case soptask.FieldCreatorID:
  25670. v, ok := value.(string)
  25671. if !ok {
  25672. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25673. }
  25674. m.SetCreatorID(v)
  25675. return nil
  25676. case soptask.FieldOrganizationID:
  25677. v, ok := value.(uint64)
  25678. if !ok {
  25679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25680. }
  25681. m.SetOrganizationID(v)
  25682. return nil
  25683. case soptask.FieldToken:
  25684. v, ok := value.([]string)
  25685. if !ok {
  25686. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25687. }
  25688. m.SetToken(v)
  25689. return nil
  25690. }
  25691. return fmt.Errorf("unknown SopTask field %s", name)
  25692. }
  25693. // AddedFields returns all numeric fields that were incremented/decremented during
  25694. // this mutation.
  25695. func (m *SopTaskMutation) AddedFields() []string {
  25696. var fields []string
  25697. if m.addstatus != nil {
  25698. fields = append(fields, soptask.FieldStatus)
  25699. }
  25700. if m.add_type != nil {
  25701. fields = append(fields, soptask.FieldType)
  25702. }
  25703. if m.addorganization_id != nil {
  25704. fields = append(fields, soptask.FieldOrganizationID)
  25705. }
  25706. return fields
  25707. }
  25708. // AddedField returns the numeric value that was incremented/decremented on a field
  25709. // with the given name. The second boolean return value indicates that this field
  25710. // was not set, or was not defined in the schema.
  25711. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  25712. switch name {
  25713. case soptask.FieldStatus:
  25714. return m.AddedStatus()
  25715. case soptask.FieldType:
  25716. return m.AddedType()
  25717. case soptask.FieldOrganizationID:
  25718. return m.AddedOrganizationID()
  25719. }
  25720. return nil, false
  25721. }
  25722. // AddField adds the value to the field with the given name. It returns an error if
  25723. // the field is not defined in the schema, or if the type mismatched the field
  25724. // type.
  25725. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  25726. switch name {
  25727. case soptask.FieldStatus:
  25728. v, ok := value.(int8)
  25729. if !ok {
  25730. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25731. }
  25732. m.AddStatus(v)
  25733. return nil
  25734. case soptask.FieldType:
  25735. v, ok := value.(int)
  25736. if !ok {
  25737. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25738. }
  25739. m.AddType(v)
  25740. return nil
  25741. case soptask.FieldOrganizationID:
  25742. v, ok := value.(int64)
  25743. if !ok {
  25744. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25745. }
  25746. m.AddOrganizationID(v)
  25747. return nil
  25748. }
  25749. return fmt.Errorf("unknown SopTask numeric field %s", name)
  25750. }
  25751. // ClearedFields returns all nullable fields that were cleared during this
  25752. // mutation.
  25753. func (m *SopTaskMutation) ClearedFields() []string {
  25754. var fields []string
  25755. if m.FieldCleared(soptask.FieldStatus) {
  25756. fields = append(fields, soptask.FieldStatus)
  25757. }
  25758. if m.FieldCleared(soptask.FieldDeletedAt) {
  25759. fields = append(fields, soptask.FieldDeletedAt)
  25760. }
  25761. if m.FieldCleared(soptask.FieldBotWxidList) {
  25762. fields = append(fields, soptask.FieldBotWxidList)
  25763. }
  25764. if m.FieldCleared(soptask.FieldPlanStartTime) {
  25765. fields = append(fields, soptask.FieldPlanStartTime)
  25766. }
  25767. if m.FieldCleared(soptask.FieldPlanEndTime) {
  25768. fields = append(fields, soptask.FieldPlanEndTime)
  25769. }
  25770. if m.FieldCleared(soptask.FieldCreatorID) {
  25771. fields = append(fields, soptask.FieldCreatorID)
  25772. }
  25773. if m.FieldCleared(soptask.FieldOrganizationID) {
  25774. fields = append(fields, soptask.FieldOrganizationID)
  25775. }
  25776. if m.FieldCleared(soptask.FieldToken) {
  25777. fields = append(fields, soptask.FieldToken)
  25778. }
  25779. return fields
  25780. }
  25781. // FieldCleared returns a boolean indicating if a field with the given name was
  25782. // cleared in this mutation.
  25783. func (m *SopTaskMutation) FieldCleared(name string) bool {
  25784. _, ok := m.clearedFields[name]
  25785. return ok
  25786. }
  25787. // ClearField clears the value of the field with the given name. It returns an
  25788. // error if the field is not defined in the schema.
  25789. func (m *SopTaskMutation) ClearField(name string) error {
  25790. switch name {
  25791. case soptask.FieldStatus:
  25792. m.ClearStatus()
  25793. return nil
  25794. case soptask.FieldDeletedAt:
  25795. m.ClearDeletedAt()
  25796. return nil
  25797. case soptask.FieldBotWxidList:
  25798. m.ClearBotWxidList()
  25799. return nil
  25800. case soptask.FieldPlanStartTime:
  25801. m.ClearPlanStartTime()
  25802. return nil
  25803. case soptask.FieldPlanEndTime:
  25804. m.ClearPlanEndTime()
  25805. return nil
  25806. case soptask.FieldCreatorID:
  25807. m.ClearCreatorID()
  25808. return nil
  25809. case soptask.FieldOrganizationID:
  25810. m.ClearOrganizationID()
  25811. return nil
  25812. case soptask.FieldToken:
  25813. m.ClearToken()
  25814. return nil
  25815. }
  25816. return fmt.Errorf("unknown SopTask nullable field %s", name)
  25817. }
  25818. // ResetField resets all changes in the mutation for the field with the given name.
  25819. // It returns an error if the field is not defined in the schema.
  25820. func (m *SopTaskMutation) ResetField(name string) error {
  25821. switch name {
  25822. case soptask.FieldCreatedAt:
  25823. m.ResetCreatedAt()
  25824. return nil
  25825. case soptask.FieldUpdatedAt:
  25826. m.ResetUpdatedAt()
  25827. return nil
  25828. case soptask.FieldStatus:
  25829. m.ResetStatus()
  25830. return nil
  25831. case soptask.FieldDeletedAt:
  25832. m.ResetDeletedAt()
  25833. return nil
  25834. case soptask.FieldName:
  25835. m.ResetName()
  25836. return nil
  25837. case soptask.FieldBotWxidList:
  25838. m.ResetBotWxidList()
  25839. return nil
  25840. case soptask.FieldType:
  25841. m.ResetType()
  25842. return nil
  25843. case soptask.FieldPlanStartTime:
  25844. m.ResetPlanStartTime()
  25845. return nil
  25846. case soptask.FieldPlanEndTime:
  25847. m.ResetPlanEndTime()
  25848. return nil
  25849. case soptask.FieldCreatorID:
  25850. m.ResetCreatorID()
  25851. return nil
  25852. case soptask.FieldOrganizationID:
  25853. m.ResetOrganizationID()
  25854. return nil
  25855. case soptask.FieldToken:
  25856. m.ResetToken()
  25857. return nil
  25858. }
  25859. return fmt.Errorf("unknown SopTask field %s", name)
  25860. }
  25861. // AddedEdges returns all edge names that were set/added in this mutation.
  25862. func (m *SopTaskMutation) AddedEdges() []string {
  25863. edges := make([]string, 0, 1)
  25864. if m.task_stages != nil {
  25865. edges = append(edges, soptask.EdgeTaskStages)
  25866. }
  25867. return edges
  25868. }
  25869. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25870. // name in this mutation.
  25871. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  25872. switch name {
  25873. case soptask.EdgeTaskStages:
  25874. ids := make([]ent.Value, 0, len(m.task_stages))
  25875. for id := range m.task_stages {
  25876. ids = append(ids, id)
  25877. }
  25878. return ids
  25879. }
  25880. return nil
  25881. }
  25882. // RemovedEdges returns all edge names that were removed in this mutation.
  25883. func (m *SopTaskMutation) RemovedEdges() []string {
  25884. edges := make([]string, 0, 1)
  25885. if m.removedtask_stages != nil {
  25886. edges = append(edges, soptask.EdgeTaskStages)
  25887. }
  25888. return edges
  25889. }
  25890. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25891. // the given name in this mutation.
  25892. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  25893. switch name {
  25894. case soptask.EdgeTaskStages:
  25895. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  25896. for id := range m.removedtask_stages {
  25897. ids = append(ids, id)
  25898. }
  25899. return ids
  25900. }
  25901. return nil
  25902. }
  25903. // ClearedEdges returns all edge names that were cleared in this mutation.
  25904. func (m *SopTaskMutation) ClearedEdges() []string {
  25905. edges := make([]string, 0, 1)
  25906. if m.clearedtask_stages {
  25907. edges = append(edges, soptask.EdgeTaskStages)
  25908. }
  25909. return edges
  25910. }
  25911. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25912. // was cleared in this mutation.
  25913. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  25914. switch name {
  25915. case soptask.EdgeTaskStages:
  25916. return m.clearedtask_stages
  25917. }
  25918. return false
  25919. }
  25920. // ClearEdge clears the value of the edge with the given name. It returns an error
  25921. // if that edge is not defined in the schema.
  25922. func (m *SopTaskMutation) ClearEdge(name string) error {
  25923. switch name {
  25924. }
  25925. return fmt.Errorf("unknown SopTask unique edge %s", name)
  25926. }
  25927. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25928. // It returns an error if the edge is not defined in the schema.
  25929. func (m *SopTaskMutation) ResetEdge(name string) error {
  25930. switch name {
  25931. case soptask.EdgeTaskStages:
  25932. m.ResetTaskStages()
  25933. return nil
  25934. }
  25935. return fmt.Errorf("unknown SopTask edge %s", name)
  25936. }
  25937. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  25938. type TokenMutation struct {
  25939. config
  25940. op Op
  25941. typ string
  25942. id *uint64
  25943. created_at *time.Time
  25944. updated_at *time.Time
  25945. deleted_at *time.Time
  25946. expire_at *time.Time
  25947. token *string
  25948. mac *string
  25949. organization_id *uint64
  25950. addorganization_id *int64
  25951. custom_agent_base *string
  25952. custom_agent_key *string
  25953. openai_base *string
  25954. openai_key *string
  25955. clearedFields map[string]struct{}
  25956. agent *uint64
  25957. clearedagent bool
  25958. done bool
  25959. oldValue func(context.Context) (*Token, error)
  25960. predicates []predicate.Token
  25961. }
  25962. var _ ent.Mutation = (*TokenMutation)(nil)
  25963. // tokenOption allows management of the mutation configuration using functional options.
  25964. type tokenOption func(*TokenMutation)
  25965. // newTokenMutation creates new mutation for the Token entity.
  25966. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  25967. m := &TokenMutation{
  25968. config: c,
  25969. op: op,
  25970. typ: TypeToken,
  25971. clearedFields: make(map[string]struct{}),
  25972. }
  25973. for _, opt := range opts {
  25974. opt(m)
  25975. }
  25976. return m
  25977. }
  25978. // withTokenID sets the ID field of the mutation.
  25979. func withTokenID(id uint64) tokenOption {
  25980. return func(m *TokenMutation) {
  25981. var (
  25982. err error
  25983. once sync.Once
  25984. value *Token
  25985. )
  25986. m.oldValue = func(ctx context.Context) (*Token, error) {
  25987. once.Do(func() {
  25988. if m.done {
  25989. err = errors.New("querying old values post mutation is not allowed")
  25990. } else {
  25991. value, err = m.Client().Token.Get(ctx, id)
  25992. }
  25993. })
  25994. return value, err
  25995. }
  25996. m.id = &id
  25997. }
  25998. }
  25999. // withToken sets the old Token of the mutation.
  26000. func withToken(node *Token) tokenOption {
  26001. return func(m *TokenMutation) {
  26002. m.oldValue = func(context.Context) (*Token, error) {
  26003. return node, nil
  26004. }
  26005. m.id = &node.ID
  26006. }
  26007. }
  26008. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26009. // executed in a transaction (ent.Tx), a transactional client is returned.
  26010. func (m TokenMutation) Client() *Client {
  26011. client := &Client{config: m.config}
  26012. client.init()
  26013. return client
  26014. }
  26015. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26016. // it returns an error otherwise.
  26017. func (m TokenMutation) Tx() (*Tx, error) {
  26018. if _, ok := m.driver.(*txDriver); !ok {
  26019. return nil, errors.New("ent: mutation is not running in a transaction")
  26020. }
  26021. tx := &Tx{config: m.config}
  26022. tx.init()
  26023. return tx, nil
  26024. }
  26025. // SetID sets the value of the id field. Note that this
  26026. // operation is only accepted on creation of Token entities.
  26027. func (m *TokenMutation) SetID(id uint64) {
  26028. m.id = &id
  26029. }
  26030. // ID returns the ID value in the mutation. Note that the ID is only available
  26031. // if it was provided to the builder or after it was returned from the database.
  26032. func (m *TokenMutation) ID() (id uint64, exists bool) {
  26033. if m.id == nil {
  26034. return
  26035. }
  26036. return *m.id, true
  26037. }
  26038. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26039. // That means, if the mutation is applied within a transaction with an isolation level such
  26040. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26041. // or updated by the mutation.
  26042. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  26043. switch {
  26044. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26045. id, exists := m.ID()
  26046. if exists {
  26047. return []uint64{id}, nil
  26048. }
  26049. fallthrough
  26050. case m.op.Is(OpUpdate | OpDelete):
  26051. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  26052. default:
  26053. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26054. }
  26055. }
  26056. // SetCreatedAt sets the "created_at" field.
  26057. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  26058. m.created_at = &t
  26059. }
  26060. // CreatedAt returns the value of the "created_at" field in the mutation.
  26061. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  26062. v := m.created_at
  26063. if v == nil {
  26064. return
  26065. }
  26066. return *v, true
  26067. }
  26068. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  26069. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26070. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26071. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26072. if !m.op.Is(OpUpdateOne) {
  26073. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26074. }
  26075. if m.id == nil || m.oldValue == nil {
  26076. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26077. }
  26078. oldValue, err := m.oldValue(ctx)
  26079. if err != nil {
  26080. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26081. }
  26082. return oldValue.CreatedAt, nil
  26083. }
  26084. // ResetCreatedAt resets all changes to the "created_at" field.
  26085. func (m *TokenMutation) ResetCreatedAt() {
  26086. m.created_at = nil
  26087. }
  26088. // SetUpdatedAt sets the "updated_at" field.
  26089. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  26090. m.updated_at = &t
  26091. }
  26092. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26093. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  26094. v := m.updated_at
  26095. if v == nil {
  26096. return
  26097. }
  26098. return *v, true
  26099. }
  26100. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  26101. // If the Token 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 *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26104. if !m.op.Is(OpUpdateOne) {
  26105. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26106. }
  26107. if m.id == nil || m.oldValue == nil {
  26108. return v, errors.New("OldUpdatedAt 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 OldUpdatedAt: %w", err)
  26113. }
  26114. return oldValue.UpdatedAt, nil
  26115. }
  26116. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26117. func (m *TokenMutation) ResetUpdatedAt() {
  26118. m.updated_at = nil
  26119. }
  26120. // SetDeletedAt sets the "deleted_at" field.
  26121. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  26122. m.deleted_at = &t
  26123. }
  26124. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26125. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  26126. v := m.deleted_at
  26127. if v == nil {
  26128. return
  26129. }
  26130. return *v, true
  26131. }
  26132. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  26133. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26134. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26135. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26136. if !m.op.Is(OpUpdateOne) {
  26137. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26138. }
  26139. if m.id == nil || m.oldValue == nil {
  26140. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26141. }
  26142. oldValue, err := m.oldValue(ctx)
  26143. if err != nil {
  26144. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26145. }
  26146. return oldValue.DeletedAt, nil
  26147. }
  26148. // ClearDeletedAt clears the value of the "deleted_at" field.
  26149. func (m *TokenMutation) ClearDeletedAt() {
  26150. m.deleted_at = nil
  26151. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  26152. }
  26153. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26154. func (m *TokenMutation) DeletedAtCleared() bool {
  26155. _, ok := m.clearedFields[token.FieldDeletedAt]
  26156. return ok
  26157. }
  26158. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26159. func (m *TokenMutation) ResetDeletedAt() {
  26160. m.deleted_at = nil
  26161. delete(m.clearedFields, token.FieldDeletedAt)
  26162. }
  26163. // SetExpireAt sets the "expire_at" field.
  26164. func (m *TokenMutation) SetExpireAt(t time.Time) {
  26165. m.expire_at = &t
  26166. }
  26167. // ExpireAt returns the value of the "expire_at" field in the mutation.
  26168. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  26169. v := m.expire_at
  26170. if v == nil {
  26171. return
  26172. }
  26173. return *v, true
  26174. }
  26175. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  26176. // If the Token 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 *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  26179. if !m.op.Is(OpUpdateOne) {
  26180. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  26181. }
  26182. if m.id == nil || m.oldValue == nil {
  26183. return v, errors.New("OldExpireAt 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 OldExpireAt: %w", err)
  26188. }
  26189. return oldValue.ExpireAt, nil
  26190. }
  26191. // ClearExpireAt clears the value of the "expire_at" field.
  26192. func (m *TokenMutation) ClearExpireAt() {
  26193. m.expire_at = nil
  26194. m.clearedFields[token.FieldExpireAt] = struct{}{}
  26195. }
  26196. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  26197. func (m *TokenMutation) ExpireAtCleared() bool {
  26198. _, ok := m.clearedFields[token.FieldExpireAt]
  26199. return ok
  26200. }
  26201. // ResetExpireAt resets all changes to the "expire_at" field.
  26202. func (m *TokenMutation) ResetExpireAt() {
  26203. m.expire_at = nil
  26204. delete(m.clearedFields, token.FieldExpireAt)
  26205. }
  26206. // SetToken sets the "token" field.
  26207. func (m *TokenMutation) SetToken(s string) {
  26208. m.token = &s
  26209. }
  26210. // Token returns the value of the "token" field in the mutation.
  26211. func (m *TokenMutation) Token() (r string, exists bool) {
  26212. v := m.token
  26213. if v == nil {
  26214. return
  26215. }
  26216. return *v, true
  26217. }
  26218. // OldToken returns the old "token" field's value of the Token entity.
  26219. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26220. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26221. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  26222. if !m.op.Is(OpUpdateOne) {
  26223. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  26224. }
  26225. if m.id == nil || m.oldValue == nil {
  26226. return v, errors.New("OldToken requires an ID field in the mutation")
  26227. }
  26228. oldValue, err := m.oldValue(ctx)
  26229. if err != nil {
  26230. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  26231. }
  26232. return oldValue.Token, nil
  26233. }
  26234. // ClearToken clears the value of the "token" field.
  26235. func (m *TokenMutation) ClearToken() {
  26236. m.token = nil
  26237. m.clearedFields[token.FieldToken] = struct{}{}
  26238. }
  26239. // TokenCleared returns if the "token" field was cleared in this mutation.
  26240. func (m *TokenMutation) TokenCleared() bool {
  26241. _, ok := m.clearedFields[token.FieldToken]
  26242. return ok
  26243. }
  26244. // ResetToken resets all changes to the "token" field.
  26245. func (m *TokenMutation) ResetToken() {
  26246. m.token = nil
  26247. delete(m.clearedFields, token.FieldToken)
  26248. }
  26249. // SetMAC sets the "mac" field.
  26250. func (m *TokenMutation) SetMAC(s string) {
  26251. m.mac = &s
  26252. }
  26253. // MAC returns the value of the "mac" field in the mutation.
  26254. func (m *TokenMutation) MAC() (r string, exists bool) {
  26255. v := m.mac
  26256. if v == nil {
  26257. return
  26258. }
  26259. return *v, true
  26260. }
  26261. // OldMAC returns the old "mac" field's value of the Token entity.
  26262. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26263. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26264. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  26265. if !m.op.Is(OpUpdateOne) {
  26266. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  26267. }
  26268. if m.id == nil || m.oldValue == nil {
  26269. return v, errors.New("OldMAC requires an ID field in the mutation")
  26270. }
  26271. oldValue, err := m.oldValue(ctx)
  26272. if err != nil {
  26273. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  26274. }
  26275. return oldValue.MAC, nil
  26276. }
  26277. // ClearMAC clears the value of the "mac" field.
  26278. func (m *TokenMutation) ClearMAC() {
  26279. m.mac = nil
  26280. m.clearedFields[token.FieldMAC] = struct{}{}
  26281. }
  26282. // MACCleared returns if the "mac" field was cleared in this mutation.
  26283. func (m *TokenMutation) MACCleared() bool {
  26284. _, ok := m.clearedFields[token.FieldMAC]
  26285. return ok
  26286. }
  26287. // ResetMAC resets all changes to the "mac" field.
  26288. func (m *TokenMutation) ResetMAC() {
  26289. m.mac = nil
  26290. delete(m.clearedFields, token.FieldMAC)
  26291. }
  26292. // SetOrganizationID sets the "organization_id" field.
  26293. func (m *TokenMutation) SetOrganizationID(u uint64) {
  26294. m.organization_id = &u
  26295. m.addorganization_id = nil
  26296. }
  26297. // OrganizationID returns the value of the "organization_id" field in the mutation.
  26298. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  26299. v := m.organization_id
  26300. if v == nil {
  26301. return
  26302. }
  26303. return *v, true
  26304. }
  26305. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  26306. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26307. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26308. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  26309. if !m.op.Is(OpUpdateOne) {
  26310. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  26311. }
  26312. if m.id == nil || m.oldValue == nil {
  26313. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  26314. }
  26315. oldValue, err := m.oldValue(ctx)
  26316. if err != nil {
  26317. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  26318. }
  26319. return oldValue.OrganizationID, nil
  26320. }
  26321. // AddOrganizationID adds u to the "organization_id" field.
  26322. func (m *TokenMutation) AddOrganizationID(u int64) {
  26323. if m.addorganization_id != nil {
  26324. *m.addorganization_id += u
  26325. } else {
  26326. m.addorganization_id = &u
  26327. }
  26328. }
  26329. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  26330. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  26331. v := m.addorganization_id
  26332. if v == nil {
  26333. return
  26334. }
  26335. return *v, true
  26336. }
  26337. // ResetOrganizationID resets all changes to the "organization_id" field.
  26338. func (m *TokenMutation) ResetOrganizationID() {
  26339. m.organization_id = nil
  26340. m.addorganization_id = nil
  26341. }
  26342. // SetAgentID sets the "agent_id" field.
  26343. func (m *TokenMutation) SetAgentID(u uint64) {
  26344. m.agent = &u
  26345. }
  26346. // AgentID returns the value of the "agent_id" field in the mutation.
  26347. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  26348. v := m.agent
  26349. if v == nil {
  26350. return
  26351. }
  26352. return *v, true
  26353. }
  26354. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  26355. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26357. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  26358. if !m.op.Is(OpUpdateOne) {
  26359. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  26360. }
  26361. if m.id == nil || m.oldValue == nil {
  26362. return v, errors.New("OldAgentID requires an ID field in the mutation")
  26363. }
  26364. oldValue, err := m.oldValue(ctx)
  26365. if err != nil {
  26366. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  26367. }
  26368. return oldValue.AgentID, nil
  26369. }
  26370. // ResetAgentID resets all changes to the "agent_id" field.
  26371. func (m *TokenMutation) ResetAgentID() {
  26372. m.agent = nil
  26373. }
  26374. // SetCustomAgentBase sets the "custom_agent_base" field.
  26375. func (m *TokenMutation) SetCustomAgentBase(s string) {
  26376. m.custom_agent_base = &s
  26377. }
  26378. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  26379. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  26380. v := m.custom_agent_base
  26381. if v == nil {
  26382. return
  26383. }
  26384. return *v, true
  26385. }
  26386. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  26387. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26388. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26389. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  26390. if !m.op.Is(OpUpdateOne) {
  26391. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  26392. }
  26393. if m.id == nil || m.oldValue == nil {
  26394. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  26395. }
  26396. oldValue, err := m.oldValue(ctx)
  26397. if err != nil {
  26398. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  26399. }
  26400. return oldValue.CustomAgentBase, nil
  26401. }
  26402. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  26403. func (m *TokenMutation) ClearCustomAgentBase() {
  26404. m.custom_agent_base = nil
  26405. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  26406. }
  26407. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  26408. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  26409. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  26410. return ok
  26411. }
  26412. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  26413. func (m *TokenMutation) ResetCustomAgentBase() {
  26414. m.custom_agent_base = nil
  26415. delete(m.clearedFields, token.FieldCustomAgentBase)
  26416. }
  26417. // SetCustomAgentKey sets the "custom_agent_key" field.
  26418. func (m *TokenMutation) SetCustomAgentKey(s string) {
  26419. m.custom_agent_key = &s
  26420. }
  26421. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  26422. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  26423. v := m.custom_agent_key
  26424. if v == nil {
  26425. return
  26426. }
  26427. return *v, true
  26428. }
  26429. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  26430. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26432. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  26433. if !m.op.Is(OpUpdateOne) {
  26434. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  26435. }
  26436. if m.id == nil || m.oldValue == nil {
  26437. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  26438. }
  26439. oldValue, err := m.oldValue(ctx)
  26440. if err != nil {
  26441. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  26442. }
  26443. return oldValue.CustomAgentKey, nil
  26444. }
  26445. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  26446. func (m *TokenMutation) ClearCustomAgentKey() {
  26447. m.custom_agent_key = nil
  26448. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  26449. }
  26450. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  26451. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  26452. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  26453. return ok
  26454. }
  26455. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  26456. func (m *TokenMutation) ResetCustomAgentKey() {
  26457. m.custom_agent_key = nil
  26458. delete(m.clearedFields, token.FieldCustomAgentKey)
  26459. }
  26460. // SetOpenaiBase sets the "openai_base" field.
  26461. func (m *TokenMutation) SetOpenaiBase(s string) {
  26462. m.openai_base = &s
  26463. }
  26464. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  26465. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  26466. v := m.openai_base
  26467. if v == nil {
  26468. return
  26469. }
  26470. return *v, true
  26471. }
  26472. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  26473. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26474. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26475. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  26476. if !m.op.Is(OpUpdateOne) {
  26477. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  26478. }
  26479. if m.id == nil || m.oldValue == nil {
  26480. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  26481. }
  26482. oldValue, err := m.oldValue(ctx)
  26483. if err != nil {
  26484. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  26485. }
  26486. return oldValue.OpenaiBase, nil
  26487. }
  26488. // ClearOpenaiBase clears the value of the "openai_base" field.
  26489. func (m *TokenMutation) ClearOpenaiBase() {
  26490. m.openai_base = nil
  26491. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  26492. }
  26493. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  26494. func (m *TokenMutation) OpenaiBaseCleared() bool {
  26495. _, ok := m.clearedFields[token.FieldOpenaiBase]
  26496. return ok
  26497. }
  26498. // ResetOpenaiBase resets all changes to the "openai_base" field.
  26499. func (m *TokenMutation) ResetOpenaiBase() {
  26500. m.openai_base = nil
  26501. delete(m.clearedFields, token.FieldOpenaiBase)
  26502. }
  26503. // SetOpenaiKey sets the "openai_key" field.
  26504. func (m *TokenMutation) SetOpenaiKey(s string) {
  26505. m.openai_key = &s
  26506. }
  26507. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  26508. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  26509. v := m.openai_key
  26510. if v == nil {
  26511. return
  26512. }
  26513. return *v, true
  26514. }
  26515. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  26516. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26517. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26518. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  26519. if !m.op.Is(OpUpdateOne) {
  26520. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  26521. }
  26522. if m.id == nil || m.oldValue == nil {
  26523. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  26524. }
  26525. oldValue, err := m.oldValue(ctx)
  26526. if err != nil {
  26527. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  26528. }
  26529. return oldValue.OpenaiKey, nil
  26530. }
  26531. // ClearOpenaiKey clears the value of the "openai_key" field.
  26532. func (m *TokenMutation) ClearOpenaiKey() {
  26533. m.openai_key = nil
  26534. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  26535. }
  26536. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  26537. func (m *TokenMutation) OpenaiKeyCleared() bool {
  26538. _, ok := m.clearedFields[token.FieldOpenaiKey]
  26539. return ok
  26540. }
  26541. // ResetOpenaiKey resets all changes to the "openai_key" field.
  26542. func (m *TokenMutation) ResetOpenaiKey() {
  26543. m.openai_key = nil
  26544. delete(m.clearedFields, token.FieldOpenaiKey)
  26545. }
  26546. // ClearAgent clears the "agent" edge to the Agent entity.
  26547. func (m *TokenMutation) ClearAgent() {
  26548. m.clearedagent = true
  26549. m.clearedFields[token.FieldAgentID] = struct{}{}
  26550. }
  26551. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  26552. func (m *TokenMutation) AgentCleared() bool {
  26553. return m.clearedagent
  26554. }
  26555. // AgentIDs returns the "agent" edge IDs in the mutation.
  26556. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  26557. // AgentID instead. It exists only for internal usage by the builders.
  26558. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  26559. if id := m.agent; id != nil {
  26560. ids = append(ids, *id)
  26561. }
  26562. return
  26563. }
  26564. // ResetAgent resets all changes to the "agent" edge.
  26565. func (m *TokenMutation) ResetAgent() {
  26566. m.agent = nil
  26567. m.clearedagent = false
  26568. }
  26569. // Where appends a list predicates to the TokenMutation builder.
  26570. func (m *TokenMutation) Where(ps ...predicate.Token) {
  26571. m.predicates = append(m.predicates, ps...)
  26572. }
  26573. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  26574. // users can use type-assertion to append predicates that do not depend on any generated package.
  26575. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  26576. p := make([]predicate.Token, len(ps))
  26577. for i := range ps {
  26578. p[i] = ps[i]
  26579. }
  26580. m.Where(p...)
  26581. }
  26582. // Op returns the operation name.
  26583. func (m *TokenMutation) Op() Op {
  26584. return m.op
  26585. }
  26586. // SetOp allows setting the mutation operation.
  26587. func (m *TokenMutation) SetOp(op Op) {
  26588. m.op = op
  26589. }
  26590. // Type returns the node type of this mutation (Token).
  26591. func (m *TokenMutation) Type() string {
  26592. return m.typ
  26593. }
  26594. // Fields returns all fields that were changed during this mutation. Note that in
  26595. // order to get all numeric fields that were incremented/decremented, call
  26596. // AddedFields().
  26597. func (m *TokenMutation) Fields() []string {
  26598. fields := make([]string, 0, 12)
  26599. if m.created_at != nil {
  26600. fields = append(fields, token.FieldCreatedAt)
  26601. }
  26602. if m.updated_at != nil {
  26603. fields = append(fields, token.FieldUpdatedAt)
  26604. }
  26605. if m.deleted_at != nil {
  26606. fields = append(fields, token.FieldDeletedAt)
  26607. }
  26608. if m.expire_at != nil {
  26609. fields = append(fields, token.FieldExpireAt)
  26610. }
  26611. if m.token != nil {
  26612. fields = append(fields, token.FieldToken)
  26613. }
  26614. if m.mac != nil {
  26615. fields = append(fields, token.FieldMAC)
  26616. }
  26617. if m.organization_id != nil {
  26618. fields = append(fields, token.FieldOrganizationID)
  26619. }
  26620. if m.agent != nil {
  26621. fields = append(fields, token.FieldAgentID)
  26622. }
  26623. if m.custom_agent_base != nil {
  26624. fields = append(fields, token.FieldCustomAgentBase)
  26625. }
  26626. if m.custom_agent_key != nil {
  26627. fields = append(fields, token.FieldCustomAgentKey)
  26628. }
  26629. if m.openai_base != nil {
  26630. fields = append(fields, token.FieldOpenaiBase)
  26631. }
  26632. if m.openai_key != nil {
  26633. fields = append(fields, token.FieldOpenaiKey)
  26634. }
  26635. return fields
  26636. }
  26637. // Field returns the value of a field with the given name. The second boolean
  26638. // return value indicates that this field was not set, or was not defined in the
  26639. // schema.
  26640. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  26641. switch name {
  26642. case token.FieldCreatedAt:
  26643. return m.CreatedAt()
  26644. case token.FieldUpdatedAt:
  26645. return m.UpdatedAt()
  26646. case token.FieldDeletedAt:
  26647. return m.DeletedAt()
  26648. case token.FieldExpireAt:
  26649. return m.ExpireAt()
  26650. case token.FieldToken:
  26651. return m.Token()
  26652. case token.FieldMAC:
  26653. return m.MAC()
  26654. case token.FieldOrganizationID:
  26655. return m.OrganizationID()
  26656. case token.FieldAgentID:
  26657. return m.AgentID()
  26658. case token.FieldCustomAgentBase:
  26659. return m.CustomAgentBase()
  26660. case token.FieldCustomAgentKey:
  26661. return m.CustomAgentKey()
  26662. case token.FieldOpenaiBase:
  26663. return m.OpenaiBase()
  26664. case token.FieldOpenaiKey:
  26665. return m.OpenaiKey()
  26666. }
  26667. return nil, false
  26668. }
  26669. // OldField returns the old value of the field from the database. An error is
  26670. // returned if the mutation operation is not UpdateOne, or the query to the
  26671. // database failed.
  26672. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26673. switch name {
  26674. case token.FieldCreatedAt:
  26675. return m.OldCreatedAt(ctx)
  26676. case token.FieldUpdatedAt:
  26677. return m.OldUpdatedAt(ctx)
  26678. case token.FieldDeletedAt:
  26679. return m.OldDeletedAt(ctx)
  26680. case token.FieldExpireAt:
  26681. return m.OldExpireAt(ctx)
  26682. case token.FieldToken:
  26683. return m.OldToken(ctx)
  26684. case token.FieldMAC:
  26685. return m.OldMAC(ctx)
  26686. case token.FieldOrganizationID:
  26687. return m.OldOrganizationID(ctx)
  26688. case token.FieldAgentID:
  26689. return m.OldAgentID(ctx)
  26690. case token.FieldCustomAgentBase:
  26691. return m.OldCustomAgentBase(ctx)
  26692. case token.FieldCustomAgentKey:
  26693. return m.OldCustomAgentKey(ctx)
  26694. case token.FieldOpenaiBase:
  26695. return m.OldOpenaiBase(ctx)
  26696. case token.FieldOpenaiKey:
  26697. return m.OldOpenaiKey(ctx)
  26698. }
  26699. return nil, fmt.Errorf("unknown Token field %s", name)
  26700. }
  26701. // SetField sets the value of a field with the given name. It returns an error if
  26702. // the field is not defined in the schema, or if the type mismatched the field
  26703. // type.
  26704. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  26705. switch name {
  26706. case token.FieldCreatedAt:
  26707. v, ok := value.(time.Time)
  26708. if !ok {
  26709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26710. }
  26711. m.SetCreatedAt(v)
  26712. return nil
  26713. case token.FieldUpdatedAt:
  26714. v, ok := value.(time.Time)
  26715. if !ok {
  26716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26717. }
  26718. m.SetUpdatedAt(v)
  26719. return nil
  26720. case token.FieldDeletedAt:
  26721. v, ok := value.(time.Time)
  26722. if !ok {
  26723. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26724. }
  26725. m.SetDeletedAt(v)
  26726. return nil
  26727. case token.FieldExpireAt:
  26728. v, ok := value.(time.Time)
  26729. if !ok {
  26730. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26731. }
  26732. m.SetExpireAt(v)
  26733. return nil
  26734. case token.FieldToken:
  26735. v, ok := value.(string)
  26736. if !ok {
  26737. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26738. }
  26739. m.SetToken(v)
  26740. return nil
  26741. case token.FieldMAC:
  26742. v, ok := value.(string)
  26743. if !ok {
  26744. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26745. }
  26746. m.SetMAC(v)
  26747. return nil
  26748. case token.FieldOrganizationID:
  26749. v, ok := value.(uint64)
  26750. if !ok {
  26751. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26752. }
  26753. m.SetOrganizationID(v)
  26754. return nil
  26755. case token.FieldAgentID:
  26756. v, ok := value.(uint64)
  26757. if !ok {
  26758. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26759. }
  26760. m.SetAgentID(v)
  26761. return nil
  26762. case token.FieldCustomAgentBase:
  26763. v, ok := value.(string)
  26764. if !ok {
  26765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26766. }
  26767. m.SetCustomAgentBase(v)
  26768. return nil
  26769. case token.FieldCustomAgentKey:
  26770. v, ok := value.(string)
  26771. if !ok {
  26772. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26773. }
  26774. m.SetCustomAgentKey(v)
  26775. return nil
  26776. case token.FieldOpenaiBase:
  26777. v, ok := value.(string)
  26778. if !ok {
  26779. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26780. }
  26781. m.SetOpenaiBase(v)
  26782. return nil
  26783. case token.FieldOpenaiKey:
  26784. v, ok := value.(string)
  26785. if !ok {
  26786. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26787. }
  26788. m.SetOpenaiKey(v)
  26789. return nil
  26790. }
  26791. return fmt.Errorf("unknown Token field %s", name)
  26792. }
  26793. // AddedFields returns all numeric fields that were incremented/decremented during
  26794. // this mutation.
  26795. func (m *TokenMutation) AddedFields() []string {
  26796. var fields []string
  26797. if m.addorganization_id != nil {
  26798. fields = append(fields, token.FieldOrganizationID)
  26799. }
  26800. return fields
  26801. }
  26802. // AddedField returns the numeric value that was incremented/decremented on a field
  26803. // with the given name. The second boolean return value indicates that this field
  26804. // was not set, or was not defined in the schema.
  26805. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  26806. switch name {
  26807. case token.FieldOrganizationID:
  26808. return m.AddedOrganizationID()
  26809. }
  26810. return nil, false
  26811. }
  26812. // AddField adds the value to the field with the given name. It returns an error if
  26813. // the field is not defined in the schema, or if the type mismatched the field
  26814. // type.
  26815. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  26816. switch name {
  26817. case token.FieldOrganizationID:
  26818. v, ok := value.(int64)
  26819. if !ok {
  26820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26821. }
  26822. m.AddOrganizationID(v)
  26823. return nil
  26824. }
  26825. return fmt.Errorf("unknown Token numeric field %s", name)
  26826. }
  26827. // ClearedFields returns all nullable fields that were cleared during this
  26828. // mutation.
  26829. func (m *TokenMutation) ClearedFields() []string {
  26830. var fields []string
  26831. if m.FieldCleared(token.FieldDeletedAt) {
  26832. fields = append(fields, token.FieldDeletedAt)
  26833. }
  26834. if m.FieldCleared(token.FieldExpireAt) {
  26835. fields = append(fields, token.FieldExpireAt)
  26836. }
  26837. if m.FieldCleared(token.FieldToken) {
  26838. fields = append(fields, token.FieldToken)
  26839. }
  26840. if m.FieldCleared(token.FieldMAC) {
  26841. fields = append(fields, token.FieldMAC)
  26842. }
  26843. if m.FieldCleared(token.FieldCustomAgentBase) {
  26844. fields = append(fields, token.FieldCustomAgentBase)
  26845. }
  26846. if m.FieldCleared(token.FieldCustomAgentKey) {
  26847. fields = append(fields, token.FieldCustomAgentKey)
  26848. }
  26849. if m.FieldCleared(token.FieldOpenaiBase) {
  26850. fields = append(fields, token.FieldOpenaiBase)
  26851. }
  26852. if m.FieldCleared(token.FieldOpenaiKey) {
  26853. fields = append(fields, token.FieldOpenaiKey)
  26854. }
  26855. return fields
  26856. }
  26857. // FieldCleared returns a boolean indicating if a field with the given name was
  26858. // cleared in this mutation.
  26859. func (m *TokenMutation) FieldCleared(name string) bool {
  26860. _, ok := m.clearedFields[name]
  26861. return ok
  26862. }
  26863. // ClearField clears the value of the field with the given name. It returns an
  26864. // error if the field is not defined in the schema.
  26865. func (m *TokenMutation) ClearField(name string) error {
  26866. switch name {
  26867. case token.FieldDeletedAt:
  26868. m.ClearDeletedAt()
  26869. return nil
  26870. case token.FieldExpireAt:
  26871. m.ClearExpireAt()
  26872. return nil
  26873. case token.FieldToken:
  26874. m.ClearToken()
  26875. return nil
  26876. case token.FieldMAC:
  26877. m.ClearMAC()
  26878. return nil
  26879. case token.FieldCustomAgentBase:
  26880. m.ClearCustomAgentBase()
  26881. return nil
  26882. case token.FieldCustomAgentKey:
  26883. m.ClearCustomAgentKey()
  26884. return nil
  26885. case token.FieldOpenaiBase:
  26886. m.ClearOpenaiBase()
  26887. return nil
  26888. case token.FieldOpenaiKey:
  26889. m.ClearOpenaiKey()
  26890. return nil
  26891. }
  26892. return fmt.Errorf("unknown Token nullable field %s", name)
  26893. }
  26894. // ResetField resets all changes in the mutation for the field with the given name.
  26895. // It returns an error if the field is not defined in the schema.
  26896. func (m *TokenMutation) ResetField(name string) error {
  26897. switch name {
  26898. case token.FieldCreatedAt:
  26899. m.ResetCreatedAt()
  26900. return nil
  26901. case token.FieldUpdatedAt:
  26902. m.ResetUpdatedAt()
  26903. return nil
  26904. case token.FieldDeletedAt:
  26905. m.ResetDeletedAt()
  26906. return nil
  26907. case token.FieldExpireAt:
  26908. m.ResetExpireAt()
  26909. return nil
  26910. case token.FieldToken:
  26911. m.ResetToken()
  26912. return nil
  26913. case token.FieldMAC:
  26914. m.ResetMAC()
  26915. return nil
  26916. case token.FieldOrganizationID:
  26917. m.ResetOrganizationID()
  26918. return nil
  26919. case token.FieldAgentID:
  26920. m.ResetAgentID()
  26921. return nil
  26922. case token.FieldCustomAgentBase:
  26923. m.ResetCustomAgentBase()
  26924. return nil
  26925. case token.FieldCustomAgentKey:
  26926. m.ResetCustomAgentKey()
  26927. return nil
  26928. case token.FieldOpenaiBase:
  26929. m.ResetOpenaiBase()
  26930. return nil
  26931. case token.FieldOpenaiKey:
  26932. m.ResetOpenaiKey()
  26933. return nil
  26934. }
  26935. return fmt.Errorf("unknown Token field %s", name)
  26936. }
  26937. // AddedEdges returns all edge names that were set/added in this mutation.
  26938. func (m *TokenMutation) AddedEdges() []string {
  26939. edges := make([]string, 0, 1)
  26940. if m.agent != nil {
  26941. edges = append(edges, token.EdgeAgent)
  26942. }
  26943. return edges
  26944. }
  26945. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26946. // name in this mutation.
  26947. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  26948. switch name {
  26949. case token.EdgeAgent:
  26950. if id := m.agent; id != nil {
  26951. return []ent.Value{*id}
  26952. }
  26953. }
  26954. return nil
  26955. }
  26956. // RemovedEdges returns all edge names that were removed in this mutation.
  26957. func (m *TokenMutation) RemovedEdges() []string {
  26958. edges := make([]string, 0, 1)
  26959. return edges
  26960. }
  26961. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26962. // the given name in this mutation.
  26963. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  26964. return nil
  26965. }
  26966. // ClearedEdges returns all edge names that were cleared in this mutation.
  26967. func (m *TokenMutation) ClearedEdges() []string {
  26968. edges := make([]string, 0, 1)
  26969. if m.clearedagent {
  26970. edges = append(edges, token.EdgeAgent)
  26971. }
  26972. return edges
  26973. }
  26974. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26975. // was cleared in this mutation.
  26976. func (m *TokenMutation) EdgeCleared(name string) bool {
  26977. switch name {
  26978. case token.EdgeAgent:
  26979. return m.clearedagent
  26980. }
  26981. return false
  26982. }
  26983. // ClearEdge clears the value of the edge with the given name. It returns an error
  26984. // if that edge is not defined in the schema.
  26985. func (m *TokenMutation) ClearEdge(name string) error {
  26986. switch name {
  26987. case token.EdgeAgent:
  26988. m.ClearAgent()
  26989. return nil
  26990. }
  26991. return fmt.Errorf("unknown Token unique edge %s", name)
  26992. }
  26993. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26994. // It returns an error if the edge is not defined in the schema.
  26995. func (m *TokenMutation) ResetEdge(name string) error {
  26996. switch name {
  26997. case token.EdgeAgent:
  26998. m.ResetAgent()
  26999. return nil
  27000. }
  27001. return fmt.Errorf("unknown Token edge %s", name)
  27002. }
  27003. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  27004. type TutorialMutation struct {
  27005. config
  27006. op Op
  27007. typ string
  27008. id *uint64
  27009. created_at *time.Time
  27010. updated_at *time.Time
  27011. deleted_at *time.Time
  27012. index *int
  27013. addindex *int
  27014. title *string
  27015. content *string
  27016. organization_id *uint64
  27017. addorganization_id *int64
  27018. clearedFields map[string]struct{}
  27019. employee *uint64
  27020. clearedemployee bool
  27021. done bool
  27022. oldValue func(context.Context) (*Tutorial, error)
  27023. predicates []predicate.Tutorial
  27024. }
  27025. var _ ent.Mutation = (*TutorialMutation)(nil)
  27026. // tutorialOption allows management of the mutation configuration using functional options.
  27027. type tutorialOption func(*TutorialMutation)
  27028. // newTutorialMutation creates new mutation for the Tutorial entity.
  27029. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  27030. m := &TutorialMutation{
  27031. config: c,
  27032. op: op,
  27033. typ: TypeTutorial,
  27034. clearedFields: make(map[string]struct{}),
  27035. }
  27036. for _, opt := range opts {
  27037. opt(m)
  27038. }
  27039. return m
  27040. }
  27041. // withTutorialID sets the ID field of the mutation.
  27042. func withTutorialID(id uint64) tutorialOption {
  27043. return func(m *TutorialMutation) {
  27044. var (
  27045. err error
  27046. once sync.Once
  27047. value *Tutorial
  27048. )
  27049. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  27050. once.Do(func() {
  27051. if m.done {
  27052. err = errors.New("querying old values post mutation is not allowed")
  27053. } else {
  27054. value, err = m.Client().Tutorial.Get(ctx, id)
  27055. }
  27056. })
  27057. return value, err
  27058. }
  27059. m.id = &id
  27060. }
  27061. }
  27062. // withTutorial sets the old Tutorial of the mutation.
  27063. func withTutorial(node *Tutorial) tutorialOption {
  27064. return func(m *TutorialMutation) {
  27065. m.oldValue = func(context.Context) (*Tutorial, error) {
  27066. return node, nil
  27067. }
  27068. m.id = &node.ID
  27069. }
  27070. }
  27071. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27072. // executed in a transaction (ent.Tx), a transactional client is returned.
  27073. func (m TutorialMutation) Client() *Client {
  27074. client := &Client{config: m.config}
  27075. client.init()
  27076. return client
  27077. }
  27078. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27079. // it returns an error otherwise.
  27080. func (m TutorialMutation) Tx() (*Tx, error) {
  27081. if _, ok := m.driver.(*txDriver); !ok {
  27082. return nil, errors.New("ent: mutation is not running in a transaction")
  27083. }
  27084. tx := &Tx{config: m.config}
  27085. tx.init()
  27086. return tx, nil
  27087. }
  27088. // SetID sets the value of the id field. Note that this
  27089. // operation is only accepted on creation of Tutorial entities.
  27090. func (m *TutorialMutation) SetID(id uint64) {
  27091. m.id = &id
  27092. }
  27093. // ID returns the ID value in the mutation. Note that the ID is only available
  27094. // if it was provided to the builder or after it was returned from the database.
  27095. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  27096. if m.id == nil {
  27097. return
  27098. }
  27099. return *m.id, true
  27100. }
  27101. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27102. // That means, if the mutation is applied within a transaction with an isolation level such
  27103. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27104. // or updated by the mutation.
  27105. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  27106. switch {
  27107. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27108. id, exists := m.ID()
  27109. if exists {
  27110. return []uint64{id}, nil
  27111. }
  27112. fallthrough
  27113. case m.op.Is(OpUpdate | OpDelete):
  27114. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  27115. default:
  27116. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27117. }
  27118. }
  27119. // SetCreatedAt sets the "created_at" field.
  27120. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  27121. m.created_at = &t
  27122. }
  27123. // CreatedAt returns the value of the "created_at" field in the mutation.
  27124. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  27125. v := m.created_at
  27126. if v == nil {
  27127. return
  27128. }
  27129. return *v, true
  27130. }
  27131. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  27132. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27133. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27134. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27135. if !m.op.Is(OpUpdateOne) {
  27136. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27137. }
  27138. if m.id == nil || m.oldValue == nil {
  27139. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27140. }
  27141. oldValue, err := m.oldValue(ctx)
  27142. if err != nil {
  27143. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27144. }
  27145. return oldValue.CreatedAt, nil
  27146. }
  27147. // ResetCreatedAt resets all changes to the "created_at" field.
  27148. func (m *TutorialMutation) ResetCreatedAt() {
  27149. m.created_at = nil
  27150. }
  27151. // SetUpdatedAt sets the "updated_at" field.
  27152. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  27153. m.updated_at = &t
  27154. }
  27155. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27156. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  27157. v := m.updated_at
  27158. if v == nil {
  27159. return
  27160. }
  27161. return *v, true
  27162. }
  27163. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  27164. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27165. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27166. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27167. if !m.op.Is(OpUpdateOne) {
  27168. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27169. }
  27170. if m.id == nil || m.oldValue == nil {
  27171. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27172. }
  27173. oldValue, err := m.oldValue(ctx)
  27174. if err != nil {
  27175. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27176. }
  27177. return oldValue.UpdatedAt, nil
  27178. }
  27179. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27180. func (m *TutorialMutation) ResetUpdatedAt() {
  27181. m.updated_at = nil
  27182. }
  27183. // SetDeletedAt sets the "deleted_at" field.
  27184. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  27185. m.deleted_at = &t
  27186. }
  27187. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  27188. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  27189. v := m.deleted_at
  27190. if v == nil {
  27191. return
  27192. }
  27193. return *v, true
  27194. }
  27195. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  27196. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27197. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27198. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  27199. if !m.op.Is(OpUpdateOne) {
  27200. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  27201. }
  27202. if m.id == nil || m.oldValue == nil {
  27203. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  27204. }
  27205. oldValue, err := m.oldValue(ctx)
  27206. if err != nil {
  27207. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  27208. }
  27209. return oldValue.DeletedAt, nil
  27210. }
  27211. // ClearDeletedAt clears the value of the "deleted_at" field.
  27212. func (m *TutorialMutation) ClearDeletedAt() {
  27213. m.deleted_at = nil
  27214. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  27215. }
  27216. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  27217. func (m *TutorialMutation) DeletedAtCleared() bool {
  27218. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  27219. return ok
  27220. }
  27221. // ResetDeletedAt resets all changes to the "deleted_at" field.
  27222. func (m *TutorialMutation) ResetDeletedAt() {
  27223. m.deleted_at = nil
  27224. delete(m.clearedFields, tutorial.FieldDeletedAt)
  27225. }
  27226. // SetEmployeeID sets the "employee_id" field.
  27227. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  27228. m.employee = &u
  27229. }
  27230. // EmployeeID returns the value of the "employee_id" field in the mutation.
  27231. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  27232. v := m.employee
  27233. if v == nil {
  27234. return
  27235. }
  27236. return *v, true
  27237. }
  27238. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  27239. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27240. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27241. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  27242. if !m.op.Is(OpUpdateOne) {
  27243. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  27244. }
  27245. if m.id == nil || m.oldValue == nil {
  27246. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  27247. }
  27248. oldValue, err := m.oldValue(ctx)
  27249. if err != nil {
  27250. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  27251. }
  27252. return oldValue.EmployeeID, nil
  27253. }
  27254. // ResetEmployeeID resets all changes to the "employee_id" field.
  27255. func (m *TutorialMutation) ResetEmployeeID() {
  27256. m.employee = nil
  27257. }
  27258. // SetIndex sets the "index" field.
  27259. func (m *TutorialMutation) SetIndex(i int) {
  27260. m.index = &i
  27261. m.addindex = nil
  27262. }
  27263. // Index returns the value of the "index" field in the mutation.
  27264. func (m *TutorialMutation) Index() (r int, exists bool) {
  27265. v := m.index
  27266. if v == nil {
  27267. return
  27268. }
  27269. return *v, true
  27270. }
  27271. // OldIndex returns the old "index" field's value of the Tutorial entity.
  27272. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27273. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27274. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  27275. if !m.op.Is(OpUpdateOne) {
  27276. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  27277. }
  27278. if m.id == nil || m.oldValue == nil {
  27279. return v, errors.New("OldIndex requires an ID field in the mutation")
  27280. }
  27281. oldValue, err := m.oldValue(ctx)
  27282. if err != nil {
  27283. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  27284. }
  27285. return oldValue.Index, nil
  27286. }
  27287. // AddIndex adds i to the "index" field.
  27288. func (m *TutorialMutation) AddIndex(i int) {
  27289. if m.addindex != nil {
  27290. *m.addindex += i
  27291. } else {
  27292. m.addindex = &i
  27293. }
  27294. }
  27295. // AddedIndex returns the value that was added to the "index" field in this mutation.
  27296. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  27297. v := m.addindex
  27298. if v == nil {
  27299. return
  27300. }
  27301. return *v, true
  27302. }
  27303. // ResetIndex resets all changes to the "index" field.
  27304. func (m *TutorialMutation) ResetIndex() {
  27305. m.index = nil
  27306. m.addindex = nil
  27307. }
  27308. // SetTitle sets the "title" field.
  27309. func (m *TutorialMutation) SetTitle(s string) {
  27310. m.title = &s
  27311. }
  27312. // Title returns the value of the "title" field in the mutation.
  27313. func (m *TutorialMutation) Title() (r string, exists bool) {
  27314. v := m.title
  27315. if v == nil {
  27316. return
  27317. }
  27318. return *v, true
  27319. }
  27320. // OldTitle returns the old "title" field's value of the Tutorial entity.
  27321. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27322. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27323. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  27324. if !m.op.Is(OpUpdateOne) {
  27325. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  27326. }
  27327. if m.id == nil || m.oldValue == nil {
  27328. return v, errors.New("OldTitle requires an ID field in the mutation")
  27329. }
  27330. oldValue, err := m.oldValue(ctx)
  27331. if err != nil {
  27332. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  27333. }
  27334. return oldValue.Title, nil
  27335. }
  27336. // ResetTitle resets all changes to the "title" field.
  27337. func (m *TutorialMutation) ResetTitle() {
  27338. m.title = nil
  27339. }
  27340. // SetContent sets the "content" field.
  27341. func (m *TutorialMutation) SetContent(s string) {
  27342. m.content = &s
  27343. }
  27344. // Content returns the value of the "content" field in the mutation.
  27345. func (m *TutorialMutation) Content() (r string, exists bool) {
  27346. v := m.content
  27347. if v == nil {
  27348. return
  27349. }
  27350. return *v, true
  27351. }
  27352. // OldContent returns the old "content" field's value of the Tutorial entity.
  27353. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27354. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27355. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  27356. if !m.op.Is(OpUpdateOne) {
  27357. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  27358. }
  27359. if m.id == nil || m.oldValue == nil {
  27360. return v, errors.New("OldContent requires an ID field in the mutation")
  27361. }
  27362. oldValue, err := m.oldValue(ctx)
  27363. if err != nil {
  27364. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  27365. }
  27366. return oldValue.Content, nil
  27367. }
  27368. // ResetContent resets all changes to the "content" field.
  27369. func (m *TutorialMutation) ResetContent() {
  27370. m.content = nil
  27371. }
  27372. // SetOrganizationID sets the "organization_id" field.
  27373. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  27374. m.organization_id = &u
  27375. m.addorganization_id = nil
  27376. }
  27377. // OrganizationID returns the value of the "organization_id" field in the mutation.
  27378. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  27379. v := m.organization_id
  27380. if v == nil {
  27381. return
  27382. }
  27383. return *v, true
  27384. }
  27385. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  27386. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27387. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27388. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  27389. if !m.op.Is(OpUpdateOne) {
  27390. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  27391. }
  27392. if m.id == nil || m.oldValue == nil {
  27393. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  27394. }
  27395. oldValue, err := m.oldValue(ctx)
  27396. if err != nil {
  27397. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  27398. }
  27399. return oldValue.OrganizationID, nil
  27400. }
  27401. // AddOrganizationID adds u to the "organization_id" field.
  27402. func (m *TutorialMutation) AddOrganizationID(u int64) {
  27403. if m.addorganization_id != nil {
  27404. *m.addorganization_id += u
  27405. } else {
  27406. m.addorganization_id = &u
  27407. }
  27408. }
  27409. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  27410. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  27411. v := m.addorganization_id
  27412. if v == nil {
  27413. return
  27414. }
  27415. return *v, true
  27416. }
  27417. // ResetOrganizationID resets all changes to the "organization_id" field.
  27418. func (m *TutorialMutation) ResetOrganizationID() {
  27419. m.organization_id = nil
  27420. m.addorganization_id = nil
  27421. }
  27422. // ClearEmployee clears the "employee" edge to the Employee entity.
  27423. func (m *TutorialMutation) ClearEmployee() {
  27424. m.clearedemployee = true
  27425. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  27426. }
  27427. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  27428. func (m *TutorialMutation) EmployeeCleared() bool {
  27429. return m.clearedemployee
  27430. }
  27431. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  27432. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  27433. // EmployeeID instead. It exists only for internal usage by the builders.
  27434. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  27435. if id := m.employee; id != nil {
  27436. ids = append(ids, *id)
  27437. }
  27438. return
  27439. }
  27440. // ResetEmployee resets all changes to the "employee" edge.
  27441. func (m *TutorialMutation) ResetEmployee() {
  27442. m.employee = nil
  27443. m.clearedemployee = false
  27444. }
  27445. // Where appends a list predicates to the TutorialMutation builder.
  27446. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  27447. m.predicates = append(m.predicates, ps...)
  27448. }
  27449. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  27450. // users can use type-assertion to append predicates that do not depend on any generated package.
  27451. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  27452. p := make([]predicate.Tutorial, len(ps))
  27453. for i := range ps {
  27454. p[i] = ps[i]
  27455. }
  27456. m.Where(p...)
  27457. }
  27458. // Op returns the operation name.
  27459. func (m *TutorialMutation) Op() Op {
  27460. return m.op
  27461. }
  27462. // SetOp allows setting the mutation operation.
  27463. func (m *TutorialMutation) SetOp(op Op) {
  27464. m.op = op
  27465. }
  27466. // Type returns the node type of this mutation (Tutorial).
  27467. func (m *TutorialMutation) Type() string {
  27468. return m.typ
  27469. }
  27470. // Fields returns all fields that were changed during this mutation. Note that in
  27471. // order to get all numeric fields that were incremented/decremented, call
  27472. // AddedFields().
  27473. func (m *TutorialMutation) Fields() []string {
  27474. fields := make([]string, 0, 8)
  27475. if m.created_at != nil {
  27476. fields = append(fields, tutorial.FieldCreatedAt)
  27477. }
  27478. if m.updated_at != nil {
  27479. fields = append(fields, tutorial.FieldUpdatedAt)
  27480. }
  27481. if m.deleted_at != nil {
  27482. fields = append(fields, tutorial.FieldDeletedAt)
  27483. }
  27484. if m.employee != nil {
  27485. fields = append(fields, tutorial.FieldEmployeeID)
  27486. }
  27487. if m.index != nil {
  27488. fields = append(fields, tutorial.FieldIndex)
  27489. }
  27490. if m.title != nil {
  27491. fields = append(fields, tutorial.FieldTitle)
  27492. }
  27493. if m.content != nil {
  27494. fields = append(fields, tutorial.FieldContent)
  27495. }
  27496. if m.organization_id != nil {
  27497. fields = append(fields, tutorial.FieldOrganizationID)
  27498. }
  27499. return fields
  27500. }
  27501. // Field returns the value of a field with the given name. The second boolean
  27502. // return value indicates that this field was not set, or was not defined in the
  27503. // schema.
  27504. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  27505. switch name {
  27506. case tutorial.FieldCreatedAt:
  27507. return m.CreatedAt()
  27508. case tutorial.FieldUpdatedAt:
  27509. return m.UpdatedAt()
  27510. case tutorial.FieldDeletedAt:
  27511. return m.DeletedAt()
  27512. case tutorial.FieldEmployeeID:
  27513. return m.EmployeeID()
  27514. case tutorial.FieldIndex:
  27515. return m.Index()
  27516. case tutorial.FieldTitle:
  27517. return m.Title()
  27518. case tutorial.FieldContent:
  27519. return m.Content()
  27520. case tutorial.FieldOrganizationID:
  27521. return m.OrganizationID()
  27522. }
  27523. return nil, false
  27524. }
  27525. // OldField returns the old value of the field from the database. An error is
  27526. // returned if the mutation operation is not UpdateOne, or the query to the
  27527. // database failed.
  27528. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27529. switch name {
  27530. case tutorial.FieldCreatedAt:
  27531. return m.OldCreatedAt(ctx)
  27532. case tutorial.FieldUpdatedAt:
  27533. return m.OldUpdatedAt(ctx)
  27534. case tutorial.FieldDeletedAt:
  27535. return m.OldDeletedAt(ctx)
  27536. case tutorial.FieldEmployeeID:
  27537. return m.OldEmployeeID(ctx)
  27538. case tutorial.FieldIndex:
  27539. return m.OldIndex(ctx)
  27540. case tutorial.FieldTitle:
  27541. return m.OldTitle(ctx)
  27542. case tutorial.FieldContent:
  27543. return m.OldContent(ctx)
  27544. case tutorial.FieldOrganizationID:
  27545. return m.OldOrganizationID(ctx)
  27546. }
  27547. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  27548. }
  27549. // SetField sets the value of a field with the given name. It returns an error if
  27550. // the field is not defined in the schema, or if the type mismatched the field
  27551. // type.
  27552. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  27553. switch name {
  27554. case tutorial.FieldCreatedAt:
  27555. v, ok := value.(time.Time)
  27556. if !ok {
  27557. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27558. }
  27559. m.SetCreatedAt(v)
  27560. return nil
  27561. case tutorial.FieldUpdatedAt:
  27562. v, ok := value.(time.Time)
  27563. if !ok {
  27564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27565. }
  27566. m.SetUpdatedAt(v)
  27567. return nil
  27568. case tutorial.FieldDeletedAt:
  27569. v, ok := value.(time.Time)
  27570. if !ok {
  27571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27572. }
  27573. m.SetDeletedAt(v)
  27574. return nil
  27575. case tutorial.FieldEmployeeID:
  27576. v, ok := value.(uint64)
  27577. if !ok {
  27578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27579. }
  27580. m.SetEmployeeID(v)
  27581. return nil
  27582. case tutorial.FieldIndex:
  27583. v, ok := value.(int)
  27584. if !ok {
  27585. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27586. }
  27587. m.SetIndex(v)
  27588. return nil
  27589. case tutorial.FieldTitle:
  27590. v, ok := value.(string)
  27591. if !ok {
  27592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27593. }
  27594. m.SetTitle(v)
  27595. return nil
  27596. case tutorial.FieldContent:
  27597. v, ok := value.(string)
  27598. if !ok {
  27599. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27600. }
  27601. m.SetContent(v)
  27602. return nil
  27603. case tutorial.FieldOrganizationID:
  27604. v, ok := value.(uint64)
  27605. if !ok {
  27606. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27607. }
  27608. m.SetOrganizationID(v)
  27609. return nil
  27610. }
  27611. return fmt.Errorf("unknown Tutorial field %s", name)
  27612. }
  27613. // AddedFields returns all numeric fields that were incremented/decremented during
  27614. // this mutation.
  27615. func (m *TutorialMutation) AddedFields() []string {
  27616. var fields []string
  27617. if m.addindex != nil {
  27618. fields = append(fields, tutorial.FieldIndex)
  27619. }
  27620. if m.addorganization_id != nil {
  27621. fields = append(fields, tutorial.FieldOrganizationID)
  27622. }
  27623. return fields
  27624. }
  27625. // AddedField returns the numeric value that was incremented/decremented on a field
  27626. // with the given name. The second boolean return value indicates that this field
  27627. // was not set, or was not defined in the schema.
  27628. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  27629. switch name {
  27630. case tutorial.FieldIndex:
  27631. return m.AddedIndex()
  27632. case tutorial.FieldOrganizationID:
  27633. return m.AddedOrganizationID()
  27634. }
  27635. return nil, false
  27636. }
  27637. // AddField adds the value to the field with the given name. It returns an error if
  27638. // the field is not defined in the schema, or if the type mismatched the field
  27639. // type.
  27640. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  27641. switch name {
  27642. case tutorial.FieldIndex:
  27643. v, ok := value.(int)
  27644. if !ok {
  27645. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27646. }
  27647. m.AddIndex(v)
  27648. return nil
  27649. case tutorial.FieldOrganizationID:
  27650. v, ok := value.(int64)
  27651. if !ok {
  27652. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27653. }
  27654. m.AddOrganizationID(v)
  27655. return nil
  27656. }
  27657. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  27658. }
  27659. // ClearedFields returns all nullable fields that were cleared during this
  27660. // mutation.
  27661. func (m *TutorialMutation) ClearedFields() []string {
  27662. var fields []string
  27663. if m.FieldCleared(tutorial.FieldDeletedAt) {
  27664. fields = append(fields, tutorial.FieldDeletedAt)
  27665. }
  27666. return fields
  27667. }
  27668. // FieldCleared returns a boolean indicating if a field with the given name was
  27669. // cleared in this mutation.
  27670. func (m *TutorialMutation) FieldCleared(name string) bool {
  27671. _, ok := m.clearedFields[name]
  27672. return ok
  27673. }
  27674. // ClearField clears the value of the field with the given name. It returns an
  27675. // error if the field is not defined in the schema.
  27676. func (m *TutorialMutation) ClearField(name string) error {
  27677. switch name {
  27678. case tutorial.FieldDeletedAt:
  27679. m.ClearDeletedAt()
  27680. return nil
  27681. }
  27682. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  27683. }
  27684. // ResetField resets all changes in the mutation for the field with the given name.
  27685. // It returns an error if the field is not defined in the schema.
  27686. func (m *TutorialMutation) ResetField(name string) error {
  27687. switch name {
  27688. case tutorial.FieldCreatedAt:
  27689. m.ResetCreatedAt()
  27690. return nil
  27691. case tutorial.FieldUpdatedAt:
  27692. m.ResetUpdatedAt()
  27693. return nil
  27694. case tutorial.FieldDeletedAt:
  27695. m.ResetDeletedAt()
  27696. return nil
  27697. case tutorial.FieldEmployeeID:
  27698. m.ResetEmployeeID()
  27699. return nil
  27700. case tutorial.FieldIndex:
  27701. m.ResetIndex()
  27702. return nil
  27703. case tutorial.FieldTitle:
  27704. m.ResetTitle()
  27705. return nil
  27706. case tutorial.FieldContent:
  27707. m.ResetContent()
  27708. return nil
  27709. case tutorial.FieldOrganizationID:
  27710. m.ResetOrganizationID()
  27711. return nil
  27712. }
  27713. return fmt.Errorf("unknown Tutorial field %s", name)
  27714. }
  27715. // AddedEdges returns all edge names that were set/added in this mutation.
  27716. func (m *TutorialMutation) AddedEdges() []string {
  27717. edges := make([]string, 0, 1)
  27718. if m.employee != nil {
  27719. edges = append(edges, tutorial.EdgeEmployee)
  27720. }
  27721. return edges
  27722. }
  27723. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27724. // name in this mutation.
  27725. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  27726. switch name {
  27727. case tutorial.EdgeEmployee:
  27728. if id := m.employee; id != nil {
  27729. return []ent.Value{*id}
  27730. }
  27731. }
  27732. return nil
  27733. }
  27734. // RemovedEdges returns all edge names that were removed in this mutation.
  27735. func (m *TutorialMutation) RemovedEdges() []string {
  27736. edges := make([]string, 0, 1)
  27737. return edges
  27738. }
  27739. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27740. // the given name in this mutation.
  27741. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  27742. return nil
  27743. }
  27744. // ClearedEdges returns all edge names that were cleared in this mutation.
  27745. func (m *TutorialMutation) ClearedEdges() []string {
  27746. edges := make([]string, 0, 1)
  27747. if m.clearedemployee {
  27748. edges = append(edges, tutorial.EdgeEmployee)
  27749. }
  27750. return edges
  27751. }
  27752. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27753. // was cleared in this mutation.
  27754. func (m *TutorialMutation) EdgeCleared(name string) bool {
  27755. switch name {
  27756. case tutorial.EdgeEmployee:
  27757. return m.clearedemployee
  27758. }
  27759. return false
  27760. }
  27761. // ClearEdge clears the value of the edge with the given name. It returns an error
  27762. // if that edge is not defined in the schema.
  27763. func (m *TutorialMutation) ClearEdge(name string) error {
  27764. switch name {
  27765. case tutorial.EdgeEmployee:
  27766. m.ClearEmployee()
  27767. return nil
  27768. }
  27769. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  27770. }
  27771. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27772. // It returns an error if the edge is not defined in the schema.
  27773. func (m *TutorialMutation) ResetEdge(name string) error {
  27774. switch name {
  27775. case tutorial.EdgeEmployee:
  27776. m.ResetEmployee()
  27777. return nil
  27778. }
  27779. return fmt.Errorf("unknown Tutorial edge %s", name)
  27780. }
  27781. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  27782. type UsageDetailMutation struct {
  27783. config
  27784. op Op
  27785. typ string
  27786. id *uint64
  27787. created_at *time.Time
  27788. updated_at *time.Time
  27789. status *uint8
  27790. addstatus *int8
  27791. _type *int
  27792. add_type *int
  27793. bot_id *string
  27794. receiver_id *string
  27795. app *int
  27796. addapp *int
  27797. session_id *uint64
  27798. addsession_id *int64
  27799. request *string
  27800. response *string
  27801. original_data *custom_types.OriginalData
  27802. total_tokens *uint64
  27803. addtotal_tokens *int64
  27804. prompt_tokens *uint64
  27805. addprompt_tokens *int64
  27806. completion_tokens *uint64
  27807. addcompletion_tokens *int64
  27808. organization_id *uint64
  27809. addorganization_id *int64
  27810. clearedFields map[string]struct{}
  27811. done bool
  27812. oldValue func(context.Context) (*UsageDetail, error)
  27813. predicates []predicate.UsageDetail
  27814. }
  27815. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  27816. // usagedetailOption allows management of the mutation configuration using functional options.
  27817. type usagedetailOption func(*UsageDetailMutation)
  27818. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  27819. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  27820. m := &UsageDetailMutation{
  27821. config: c,
  27822. op: op,
  27823. typ: TypeUsageDetail,
  27824. clearedFields: make(map[string]struct{}),
  27825. }
  27826. for _, opt := range opts {
  27827. opt(m)
  27828. }
  27829. return m
  27830. }
  27831. // withUsageDetailID sets the ID field of the mutation.
  27832. func withUsageDetailID(id uint64) usagedetailOption {
  27833. return func(m *UsageDetailMutation) {
  27834. var (
  27835. err error
  27836. once sync.Once
  27837. value *UsageDetail
  27838. )
  27839. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  27840. once.Do(func() {
  27841. if m.done {
  27842. err = errors.New("querying old values post mutation is not allowed")
  27843. } else {
  27844. value, err = m.Client().UsageDetail.Get(ctx, id)
  27845. }
  27846. })
  27847. return value, err
  27848. }
  27849. m.id = &id
  27850. }
  27851. }
  27852. // withUsageDetail sets the old UsageDetail of the mutation.
  27853. func withUsageDetail(node *UsageDetail) usagedetailOption {
  27854. return func(m *UsageDetailMutation) {
  27855. m.oldValue = func(context.Context) (*UsageDetail, error) {
  27856. return node, nil
  27857. }
  27858. m.id = &node.ID
  27859. }
  27860. }
  27861. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27862. // executed in a transaction (ent.Tx), a transactional client is returned.
  27863. func (m UsageDetailMutation) Client() *Client {
  27864. client := &Client{config: m.config}
  27865. client.init()
  27866. return client
  27867. }
  27868. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27869. // it returns an error otherwise.
  27870. func (m UsageDetailMutation) Tx() (*Tx, error) {
  27871. if _, ok := m.driver.(*txDriver); !ok {
  27872. return nil, errors.New("ent: mutation is not running in a transaction")
  27873. }
  27874. tx := &Tx{config: m.config}
  27875. tx.init()
  27876. return tx, nil
  27877. }
  27878. // SetID sets the value of the id field. Note that this
  27879. // operation is only accepted on creation of UsageDetail entities.
  27880. func (m *UsageDetailMutation) SetID(id uint64) {
  27881. m.id = &id
  27882. }
  27883. // ID returns the ID value in the mutation. Note that the ID is only available
  27884. // if it was provided to the builder or after it was returned from the database.
  27885. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  27886. if m.id == nil {
  27887. return
  27888. }
  27889. return *m.id, true
  27890. }
  27891. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27892. // That means, if the mutation is applied within a transaction with an isolation level such
  27893. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27894. // or updated by the mutation.
  27895. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  27896. switch {
  27897. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27898. id, exists := m.ID()
  27899. if exists {
  27900. return []uint64{id}, nil
  27901. }
  27902. fallthrough
  27903. case m.op.Is(OpUpdate | OpDelete):
  27904. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  27905. default:
  27906. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27907. }
  27908. }
  27909. // SetCreatedAt sets the "created_at" field.
  27910. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  27911. m.created_at = &t
  27912. }
  27913. // CreatedAt returns the value of the "created_at" field in the mutation.
  27914. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  27915. v := m.created_at
  27916. if v == nil {
  27917. return
  27918. }
  27919. return *v, true
  27920. }
  27921. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  27922. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27923. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27924. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27925. if !m.op.Is(OpUpdateOne) {
  27926. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27927. }
  27928. if m.id == nil || m.oldValue == nil {
  27929. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27930. }
  27931. oldValue, err := m.oldValue(ctx)
  27932. if err != nil {
  27933. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27934. }
  27935. return oldValue.CreatedAt, nil
  27936. }
  27937. // ResetCreatedAt resets all changes to the "created_at" field.
  27938. func (m *UsageDetailMutation) ResetCreatedAt() {
  27939. m.created_at = nil
  27940. }
  27941. // SetUpdatedAt sets the "updated_at" field.
  27942. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  27943. m.updated_at = &t
  27944. }
  27945. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27946. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  27947. v := m.updated_at
  27948. if v == nil {
  27949. return
  27950. }
  27951. return *v, true
  27952. }
  27953. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  27954. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27955. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27956. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27957. if !m.op.Is(OpUpdateOne) {
  27958. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27959. }
  27960. if m.id == nil || m.oldValue == nil {
  27961. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27962. }
  27963. oldValue, err := m.oldValue(ctx)
  27964. if err != nil {
  27965. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27966. }
  27967. return oldValue.UpdatedAt, nil
  27968. }
  27969. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27970. func (m *UsageDetailMutation) ResetUpdatedAt() {
  27971. m.updated_at = nil
  27972. }
  27973. // SetStatus sets the "status" field.
  27974. func (m *UsageDetailMutation) SetStatus(u uint8) {
  27975. m.status = &u
  27976. m.addstatus = nil
  27977. }
  27978. // Status returns the value of the "status" field in the mutation.
  27979. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  27980. v := m.status
  27981. if v == nil {
  27982. return
  27983. }
  27984. return *v, true
  27985. }
  27986. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  27987. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27988. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27989. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  27990. if !m.op.Is(OpUpdateOne) {
  27991. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  27992. }
  27993. if m.id == nil || m.oldValue == nil {
  27994. return v, errors.New("OldStatus requires an ID field in the mutation")
  27995. }
  27996. oldValue, err := m.oldValue(ctx)
  27997. if err != nil {
  27998. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  27999. }
  28000. return oldValue.Status, nil
  28001. }
  28002. // AddStatus adds u to the "status" field.
  28003. func (m *UsageDetailMutation) AddStatus(u int8) {
  28004. if m.addstatus != nil {
  28005. *m.addstatus += u
  28006. } else {
  28007. m.addstatus = &u
  28008. }
  28009. }
  28010. // AddedStatus returns the value that was added to the "status" field in this mutation.
  28011. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  28012. v := m.addstatus
  28013. if v == nil {
  28014. return
  28015. }
  28016. return *v, true
  28017. }
  28018. // ClearStatus clears the value of the "status" field.
  28019. func (m *UsageDetailMutation) ClearStatus() {
  28020. m.status = nil
  28021. m.addstatus = nil
  28022. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  28023. }
  28024. // StatusCleared returns if the "status" field was cleared in this mutation.
  28025. func (m *UsageDetailMutation) StatusCleared() bool {
  28026. _, ok := m.clearedFields[usagedetail.FieldStatus]
  28027. return ok
  28028. }
  28029. // ResetStatus resets all changes to the "status" field.
  28030. func (m *UsageDetailMutation) ResetStatus() {
  28031. m.status = nil
  28032. m.addstatus = nil
  28033. delete(m.clearedFields, usagedetail.FieldStatus)
  28034. }
  28035. // SetType sets the "type" field.
  28036. func (m *UsageDetailMutation) SetType(i int) {
  28037. m._type = &i
  28038. m.add_type = nil
  28039. }
  28040. // GetType returns the value of the "type" field in the mutation.
  28041. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  28042. v := m._type
  28043. if v == nil {
  28044. return
  28045. }
  28046. return *v, true
  28047. }
  28048. // OldType returns the old "type" field's value of the UsageDetail entity.
  28049. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28050. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28051. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  28052. if !m.op.Is(OpUpdateOne) {
  28053. return v, errors.New("OldType is only allowed on UpdateOne operations")
  28054. }
  28055. if m.id == nil || m.oldValue == nil {
  28056. return v, errors.New("OldType requires an ID field in the mutation")
  28057. }
  28058. oldValue, err := m.oldValue(ctx)
  28059. if err != nil {
  28060. return v, fmt.Errorf("querying old value for OldType: %w", err)
  28061. }
  28062. return oldValue.Type, nil
  28063. }
  28064. // AddType adds i to the "type" field.
  28065. func (m *UsageDetailMutation) AddType(i int) {
  28066. if m.add_type != nil {
  28067. *m.add_type += i
  28068. } else {
  28069. m.add_type = &i
  28070. }
  28071. }
  28072. // AddedType returns the value that was added to the "type" field in this mutation.
  28073. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  28074. v := m.add_type
  28075. if v == nil {
  28076. return
  28077. }
  28078. return *v, true
  28079. }
  28080. // ClearType clears the value of the "type" field.
  28081. func (m *UsageDetailMutation) ClearType() {
  28082. m._type = nil
  28083. m.add_type = nil
  28084. m.clearedFields[usagedetail.FieldType] = struct{}{}
  28085. }
  28086. // TypeCleared returns if the "type" field was cleared in this mutation.
  28087. func (m *UsageDetailMutation) TypeCleared() bool {
  28088. _, ok := m.clearedFields[usagedetail.FieldType]
  28089. return ok
  28090. }
  28091. // ResetType resets all changes to the "type" field.
  28092. func (m *UsageDetailMutation) ResetType() {
  28093. m._type = nil
  28094. m.add_type = nil
  28095. delete(m.clearedFields, usagedetail.FieldType)
  28096. }
  28097. // SetBotID sets the "bot_id" field.
  28098. func (m *UsageDetailMutation) SetBotID(s string) {
  28099. m.bot_id = &s
  28100. }
  28101. // BotID returns the value of the "bot_id" field in the mutation.
  28102. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  28103. v := m.bot_id
  28104. if v == nil {
  28105. return
  28106. }
  28107. return *v, true
  28108. }
  28109. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  28110. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28111. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28112. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  28113. if !m.op.Is(OpUpdateOne) {
  28114. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  28115. }
  28116. if m.id == nil || m.oldValue == nil {
  28117. return v, errors.New("OldBotID requires an ID field in the mutation")
  28118. }
  28119. oldValue, err := m.oldValue(ctx)
  28120. if err != nil {
  28121. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  28122. }
  28123. return oldValue.BotID, nil
  28124. }
  28125. // ResetBotID resets all changes to the "bot_id" field.
  28126. func (m *UsageDetailMutation) ResetBotID() {
  28127. m.bot_id = nil
  28128. }
  28129. // SetReceiverID sets the "receiver_id" field.
  28130. func (m *UsageDetailMutation) SetReceiverID(s string) {
  28131. m.receiver_id = &s
  28132. }
  28133. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  28134. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  28135. v := m.receiver_id
  28136. if v == nil {
  28137. return
  28138. }
  28139. return *v, true
  28140. }
  28141. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  28142. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28143. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28144. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  28145. if !m.op.Is(OpUpdateOne) {
  28146. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  28147. }
  28148. if m.id == nil || m.oldValue == nil {
  28149. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  28150. }
  28151. oldValue, err := m.oldValue(ctx)
  28152. if err != nil {
  28153. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  28154. }
  28155. return oldValue.ReceiverID, nil
  28156. }
  28157. // ResetReceiverID resets all changes to the "receiver_id" field.
  28158. func (m *UsageDetailMutation) ResetReceiverID() {
  28159. m.receiver_id = nil
  28160. }
  28161. // SetApp sets the "app" field.
  28162. func (m *UsageDetailMutation) SetApp(i int) {
  28163. m.app = &i
  28164. m.addapp = nil
  28165. }
  28166. // App returns the value of the "app" field in the mutation.
  28167. func (m *UsageDetailMutation) App() (r int, exists bool) {
  28168. v := m.app
  28169. if v == nil {
  28170. return
  28171. }
  28172. return *v, true
  28173. }
  28174. // OldApp returns the old "app" field's value of the UsageDetail entity.
  28175. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28176. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28177. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  28178. if !m.op.Is(OpUpdateOne) {
  28179. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  28180. }
  28181. if m.id == nil || m.oldValue == nil {
  28182. return v, errors.New("OldApp requires an ID field in the mutation")
  28183. }
  28184. oldValue, err := m.oldValue(ctx)
  28185. if err != nil {
  28186. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  28187. }
  28188. return oldValue.App, nil
  28189. }
  28190. // AddApp adds i to the "app" field.
  28191. func (m *UsageDetailMutation) AddApp(i int) {
  28192. if m.addapp != nil {
  28193. *m.addapp += i
  28194. } else {
  28195. m.addapp = &i
  28196. }
  28197. }
  28198. // AddedApp returns the value that was added to the "app" field in this mutation.
  28199. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  28200. v := m.addapp
  28201. if v == nil {
  28202. return
  28203. }
  28204. return *v, true
  28205. }
  28206. // ClearApp clears the value of the "app" field.
  28207. func (m *UsageDetailMutation) ClearApp() {
  28208. m.app = nil
  28209. m.addapp = nil
  28210. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  28211. }
  28212. // AppCleared returns if the "app" field was cleared in this mutation.
  28213. func (m *UsageDetailMutation) AppCleared() bool {
  28214. _, ok := m.clearedFields[usagedetail.FieldApp]
  28215. return ok
  28216. }
  28217. // ResetApp resets all changes to the "app" field.
  28218. func (m *UsageDetailMutation) ResetApp() {
  28219. m.app = nil
  28220. m.addapp = nil
  28221. delete(m.clearedFields, usagedetail.FieldApp)
  28222. }
  28223. // SetSessionID sets the "session_id" field.
  28224. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  28225. m.session_id = &u
  28226. m.addsession_id = nil
  28227. }
  28228. // SessionID returns the value of the "session_id" field in the mutation.
  28229. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  28230. v := m.session_id
  28231. if v == nil {
  28232. return
  28233. }
  28234. return *v, true
  28235. }
  28236. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  28237. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28238. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28239. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  28240. if !m.op.Is(OpUpdateOne) {
  28241. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  28242. }
  28243. if m.id == nil || m.oldValue == nil {
  28244. return v, errors.New("OldSessionID requires an ID field in the mutation")
  28245. }
  28246. oldValue, err := m.oldValue(ctx)
  28247. if err != nil {
  28248. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  28249. }
  28250. return oldValue.SessionID, nil
  28251. }
  28252. // AddSessionID adds u to the "session_id" field.
  28253. func (m *UsageDetailMutation) AddSessionID(u int64) {
  28254. if m.addsession_id != nil {
  28255. *m.addsession_id += u
  28256. } else {
  28257. m.addsession_id = &u
  28258. }
  28259. }
  28260. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  28261. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  28262. v := m.addsession_id
  28263. if v == nil {
  28264. return
  28265. }
  28266. return *v, true
  28267. }
  28268. // ClearSessionID clears the value of the "session_id" field.
  28269. func (m *UsageDetailMutation) ClearSessionID() {
  28270. m.session_id = nil
  28271. m.addsession_id = nil
  28272. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  28273. }
  28274. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  28275. func (m *UsageDetailMutation) SessionIDCleared() bool {
  28276. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  28277. return ok
  28278. }
  28279. // ResetSessionID resets all changes to the "session_id" field.
  28280. func (m *UsageDetailMutation) ResetSessionID() {
  28281. m.session_id = nil
  28282. m.addsession_id = nil
  28283. delete(m.clearedFields, usagedetail.FieldSessionID)
  28284. }
  28285. // SetRequest sets the "request" field.
  28286. func (m *UsageDetailMutation) SetRequest(s string) {
  28287. m.request = &s
  28288. }
  28289. // Request returns the value of the "request" field in the mutation.
  28290. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  28291. v := m.request
  28292. if v == nil {
  28293. return
  28294. }
  28295. return *v, true
  28296. }
  28297. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  28298. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28299. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28300. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  28301. if !m.op.Is(OpUpdateOne) {
  28302. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  28303. }
  28304. if m.id == nil || m.oldValue == nil {
  28305. return v, errors.New("OldRequest requires an ID field in the mutation")
  28306. }
  28307. oldValue, err := m.oldValue(ctx)
  28308. if err != nil {
  28309. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  28310. }
  28311. return oldValue.Request, nil
  28312. }
  28313. // ResetRequest resets all changes to the "request" field.
  28314. func (m *UsageDetailMutation) ResetRequest() {
  28315. m.request = nil
  28316. }
  28317. // SetResponse sets the "response" field.
  28318. func (m *UsageDetailMutation) SetResponse(s string) {
  28319. m.response = &s
  28320. }
  28321. // Response returns the value of the "response" field in the mutation.
  28322. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  28323. v := m.response
  28324. if v == nil {
  28325. return
  28326. }
  28327. return *v, true
  28328. }
  28329. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  28330. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28331. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28332. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  28333. if !m.op.Is(OpUpdateOne) {
  28334. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  28335. }
  28336. if m.id == nil || m.oldValue == nil {
  28337. return v, errors.New("OldResponse requires an ID field in the mutation")
  28338. }
  28339. oldValue, err := m.oldValue(ctx)
  28340. if err != nil {
  28341. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  28342. }
  28343. return oldValue.Response, nil
  28344. }
  28345. // ResetResponse resets all changes to the "response" field.
  28346. func (m *UsageDetailMutation) ResetResponse() {
  28347. m.response = nil
  28348. }
  28349. // SetOriginalData sets the "original_data" field.
  28350. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  28351. m.original_data = &ctd
  28352. }
  28353. // OriginalData returns the value of the "original_data" field in the mutation.
  28354. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  28355. v := m.original_data
  28356. if v == nil {
  28357. return
  28358. }
  28359. return *v, true
  28360. }
  28361. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  28362. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28363. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28364. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  28365. if !m.op.Is(OpUpdateOne) {
  28366. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  28367. }
  28368. if m.id == nil || m.oldValue == nil {
  28369. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  28370. }
  28371. oldValue, err := m.oldValue(ctx)
  28372. if err != nil {
  28373. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  28374. }
  28375. return oldValue.OriginalData, nil
  28376. }
  28377. // ResetOriginalData resets all changes to the "original_data" field.
  28378. func (m *UsageDetailMutation) ResetOriginalData() {
  28379. m.original_data = nil
  28380. }
  28381. // SetTotalTokens sets the "total_tokens" field.
  28382. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  28383. m.total_tokens = &u
  28384. m.addtotal_tokens = nil
  28385. }
  28386. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  28387. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  28388. v := m.total_tokens
  28389. if v == nil {
  28390. return
  28391. }
  28392. return *v, true
  28393. }
  28394. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  28395. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28396. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28397. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  28398. if !m.op.Is(OpUpdateOne) {
  28399. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  28400. }
  28401. if m.id == nil || m.oldValue == nil {
  28402. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  28403. }
  28404. oldValue, err := m.oldValue(ctx)
  28405. if err != nil {
  28406. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  28407. }
  28408. return oldValue.TotalTokens, nil
  28409. }
  28410. // AddTotalTokens adds u to the "total_tokens" field.
  28411. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  28412. if m.addtotal_tokens != nil {
  28413. *m.addtotal_tokens += u
  28414. } else {
  28415. m.addtotal_tokens = &u
  28416. }
  28417. }
  28418. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  28419. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  28420. v := m.addtotal_tokens
  28421. if v == nil {
  28422. return
  28423. }
  28424. return *v, true
  28425. }
  28426. // ClearTotalTokens clears the value of the "total_tokens" field.
  28427. func (m *UsageDetailMutation) ClearTotalTokens() {
  28428. m.total_tokens = nil
  28429. m.addtotal_tokens = nil
  28430. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  28431. }
  28432. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  28433. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  28434. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  28435. return ok
  28436. }
  28437. // ResetTotalTokens resets all changes to the "total_tokens" field.
  28438. func (m *UsageDetailMutation) ResetTotalTokens() {
  28439. m.total_tokens = nil
  28440. m.addtotal_tokens = nil
  28441. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  28442. }
  28443. // SetPromptTokens sets the "prompt_tokens" field.
  28444. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  28445. m.prompt_tokens = &u
  28446. m.addprompt_tokens = nil
  28447. }
  28448. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  28449. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  28450. v := m.prompt_tokens
  28451. if v == nil {
  28452. return
  28453. }
  28454. return *v, true
  28455. }
  28456. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  28457. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28458. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28459. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  28460. if !m.op.Is(OpUpdateOne) {
  28461. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  28462. }
  28463. if m.id == nil || m.oldValue == nil {
  28464. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  28465. }
  28466. oldValue, err := m.oldValue(ctx)
  28467. if err != nil {
  28468. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  28469. }
  28470. return oldValue.PromptTokens, nil
  28471. }
  28472. // AddPromptTokens adds u to the "prompt_tokens" field.
  28473. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  28474. if m.addprompt_tokens != nil {
  28475. *m.addprompt_tokens += u
  28476. } else {
  28477. m.addprompt_tokens = &u
  28478. }
  28479. }
  28480. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  28481. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  28482. v := m.addprompt_tokens
  28483. if v == nil {
  28484. return
  28485. }
  28486. return *v, true
  28487. }
  28488. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  28489. func (m *UsageDetailMutation) ClearPromptTokens() {
  28490. m.prompt_tokens = nil
  28491. m.addprompt_tokens = nil
  28492. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  28493. }
  28494. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  28495. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  28496. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  28497. return ok
  28498. }
  28499. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  28500. func (m *UsageDetailMutation) ResetPromptTokens() {
  28501. m.prompt_tokens = nil
  28502. m.addprompt_tokens = nil
  28503. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  28504. }
  28505. // SetCompletionTokens sets the "completion_tokens" field.
  28506. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  28507. m.completion_tokens = &u
  28508. m.addcompletion_tokens = nil
  28509. }
  28510. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  28511. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  28512. v := m.completion_tokens
  28513. if v == nil {
  28514. return
  28515. }
  28516. return *v, true
  28517. }
  28518. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  28519. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28520. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28521. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  28522. if !m.op.Is(OpUpdateOne) {
  28523. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  28524. }
  28525. if m.id == nil || m.oldValue == nil {
  28526. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  28527. }
  28528. oldValue, err := m.oldValue(ctx)
  28529. if err != nil {
  28530. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  28531. }
  28532. return oldValue.CompletionTokens, nil
  28533. }
  28534. // AddCompletionTokens adds u to the "completion_tokens" field.
  28535. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  28536. if m.addcompletion_tokens != nil {
  28537. *m.addcompletion_tokens += u
  28538. } else {
  28539. m.addcompletion_tokens = &u
  28540. }
  28541. }
  28542. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  28543. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  28544. v := m.addcompletion_tokens
  28545. if v == nil {
  28546. return
  28547. }
  28548. return *v, true
  28549. }
  28550. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  28551. func (m *UsageDetailMutation) ClearCompletionTokens() {
  28552. m.completion_tokens = nil
  28553. m.addcompletion_tokens = nil
  28554. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  28555. }
  28556. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  28557. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  28558. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  28559. return ok
  28560. }
  28561. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  28562. func (m *UsageDetailMutation) ResetCompletionTokens() {
  28563. m.completion_tokens = nil
  28564. m.addcompletion_tokens = nil
  28565. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  28566. }
  28567. // SetOrganizationID sets the "organization_id" field.
  28568. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  28569. m.organization_id = &u
  28570. m.addorganization_id = nil
  28571. }
  28572. // OrganizationID returns the value of the "organization_id" field in the mutation.
  28573. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  28574. v := m.organization_id
  28575. if v == nil {
  28576. return
  28577. }
  28578. return *v, true
  28579. }
  28580. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  28581. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28582. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28583. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  28584. if !m.op.Is(OpUpdateOne) {
  28585. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  28586. }
  28587. if m.id == nil || m.oldValue == nil {
  28588. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  28589. }
  28590. oldValue, err := m.oldValue(ctx)
  28591. if err != nil {
  28592. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  28593. }
  28594. return oldValue.OrganizationID, nil
  28595. }
  28596. // AddOrganizationID adds u to the "organization_id" field.
  28597. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  28598. if m.addorganization_id != nil {
  28599. *m.addorganization_id += u
  28600. } else {
  28601. m.addorganization_id = &u
  28602. }
  28603. }
  28604. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  28605. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  28606. v := m.addorganization_id
  28607. if v == nil {
  28608. return
  28609. }
  28610. return *v, true
  28611. }
  28612. // ClearOrganizationID clears the value of the "organization_id" field.
  28613. func (m *UsageDetailMutation) ClearOrganizationID() {
  28614. m.organization_id = nil
  28615. m.addorganization_id = nil
  28616. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  28617. }
  28618. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  28619. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  28620. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  28621. return ok
  28622. }
  28623. // ResetOrganizationID resets all changes to the "organization_id" field.
  28624. func (m *UsageDetailMutation) ResetOrganizationID() {
  28625. m.organization_id = nil
  28626. m.addorganization_id = nil
  28627. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  28628. }
  28629. // Where appends a list predicates to the UsageDetailMutation builder.
  28630. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  28631. m.predicates = append(m.predicates, ps...)
  28632. }
  28633. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  28634. // users can use type-assertion to append predicates that do not depend on any generated package.
  28635. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  28636. p := make([]predicate.UsageDetail, len(ps))
  28637. for i := range ps {
  28638. p[i] = ps[i]
  28639. }
  28640. m.Where(p...)
  28641. }
  28642. // Op returns the operation name.
  28643. func (m *UsageDetailMutation) Op() Op {
  28644. return m.op
  28645. }
  28646. // SetOp allows setting the mutation operation.
  28647. func (m *UsageDetailMutation) SetOp(op Op) {
  28648. m.op = op
  28649. }
  28650. // Type returns the node type of this mutation (UsageDetail).
  28651. func (m *UsageDetailMutation) Type() string {
  28652. return m.typ
  28653. }
  28654. // Fields returns all fields that were changed during this mutation. Note that in
  28655. // order to get all numeric fields that were incremented/decremented, call
  28656. // AddedFields().
  28657. func (m *UsageDetailMutation) Fields() []string {
  28658. fields := make([]string, 0, 15)
  28659. if m.created_at != nil {
  28660. fields = append(fields, usagedetail.FieldCreatedAt)
  28661. }
  28662. if m.updated_at != nil {
  28663. fields = append(fields, usagedetail.FieldUpdatedAt)
  28664. }
  28665. if m.status != nil {
  28666. fields = append(fields, usagedetail.FieldStatus)
  28667. }
  28668. if m._type != nil {
  28669. fields = append(fields, usagedetail.FieldType)
  28670. }
  28671. if m.bot_id != nil {
  28672. fields = append(fields, usagedetail.FieldBotID)
  28673. }
  28674. if m.receiver_id != nil {
  28675. fields = append(fields, usagedetail.FieldReceiverID)
  28676. }
  28677. if m.app != nil {
  28678. fields = append(fields, usagedetail.FieldApp)
  28679. }
  28680. if m.session_id != nil {
  28681. fields = append(fields, usagedetail.FieldSessionID)
  28682. }
  28683. if m.request != nil {
  28684. fields = append(fields, usagedetail.FieldRequest)
  28685. }
  28686. if m.response != nil {
  28687. fields = append(fields, usagedetail.FieldResponse)
  28688. }
  28689. if m.original_data != nil {
  28690. fields = append(fields, usagedetail.FieldOriginalData)
  28691. }
  28692. if m.total_tokens != nil {
  28693. fields = append(fields, usagedetail.FieldTotalTokens)
  28694. }
  28695. if m.prompt_tokens != nil {
  28696. fields = append(fields, usagedetail.FieldPromptTokens)
  28697. }
  28698. if m.completion_tokens != nil {
  28699. fields = append(fields, usagedetail.FieldCompletionTokens)
  28700. }
  28701. if m.organization_id != nil {
  28702. fields = append(fields, usagedetail.FieldOrganizationID)
  28703. }
  28704. return fields
  28705. }
  28706. // Field returns the value of a field with the given name. The second boolean
  28707. // return value indicates that this field was not set, or was not defined in the
  28708. // schema.
  28709. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  28710. switch name {
  28711. case usagedetail.FieldCreatedAt:
  28712. return m.CreatedAt()
  28713. case usagedetail.FieldUpdatedAt:
  28714. return m.UpdatedAt()
  28715. case usagedetail.FieldStatus:
  28716. return m.Status()
  28717. case usagedetail.FieldType:
  28718. return m.GetType()
  28719. case usagedetail.FieldBotID:
  28720. return m.BotID()
  28721. case usagedetail.FieldReceiverID:
  28722. return m.ReceiverID()
  28723. case usagedetail.FieldApp:
  28724. return m.App()
  28725. case usagedetail.FieldSessionID:
  28726. return m.SessionID()
  28727. case usagedetail.FieldRequest:
  28728. return m.Request()
  28729. case usagedetail.FieldResponse:
  28730. return m.Response()
  28731. case usagedetail.FieldOriginalData:
  28732. return m.OriginalData()
  28733. case usagedetail.FieldTotalTokens:
  28734. return m.TotalTokens()
  28735. case usagedetail.FieldPromptTokens:
  28736. return m.PromptTokens()
  28737. case usagedetail.FieldCompletionTokens:
  28738. return m.CompletionTokens()
  28739. case usagedetail.FieldOrganizationID:
  28740. return m.OrganizationID()
  28741. }
  28742. return nil, false
  28743. }
  28744. // OldField returns the old value of the field from the database. An error is
  28745. // returned if the mutation operation is not UpdateOne, or the query to the
  28746. // database failed.
  28747. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  28748. switch name {
  28749. case usagedetail.FieldCreatedAt:
  28750. return m.OldCreatedAt(ctx)
  28751. case usagedetail.FieldUpdatedAt:
  28752. return m.OldUpdatedAt(ctx)
  28753. case usagedetail.FieldStatus:
  28754. return m.OldStatus(ctx)
  28755. case usagedetail.FieldType:
  28756. return m.OldType(ctx)
  28757. case usagedetail.FieldBotID:
  28758. return m.OldBotID(ctx)
  28759. case usagedetail.FieldReceiverID:
  28760. return m.OldReceiverID(ctx)
  28761. case usagedetail.FieldApp:
  28762. return m.OldApp(ctx)
  28763. case usagedetail.FieldSessionID:
  28764. return m.OldSessionID(ctx)
  28765. case usagedetail.FieldRequest:
  28766. return m.OldRequest(ctx)
  28767. case usagedetail.FieldResponse:
  28768. return m.OldResponse(ctx)
  28769. case usagedetail.FieldOriginalData:
  28770. return m.OldOriginalData(ctx)
  28771. case usagedetail.FieldTotalTokens:
  28772. return m.OldTotalTokens(ctx)
  28773. case usagedetail.FieldPromptTokens:
  28774. return m.OldPromptTokens(ctx)
  28775. case usagedetail.FieldCompletionTokens:
  28776. return m.OldCompletionTokens(ctx)
  28777. case usagedetail.FieldOrganizationID:
  28778. return m.OldOrganizationID(ctx)
  28779. }
  28780. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  28781. }
  28782. // SetField sets the value of a field with the given name. It returns an error if
  28783. // the field is not defined in the schema, or if the type mismatched the field
  28784. // type.
  28785. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  28786. switch name {
  28787. case usagedetail.FieldCreatedAt:
  28788. v, ok := value.(time.Time)
  28789. if !ok {
  28790. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28791. }
  28792. m.SetCreatedAt(v)
  28793. return nil
  28794. case usagedetail.FieldUpdatedAt:
  28795. v, ok := value.(time.Time)
  28796. if !ok {
  28797. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28798. }
  28799. m.SetUpdatedAt(v)
  28800. return nil
  28801. case usagedetail.FieldStatus:
  28802. v, ok := value.(uint8)
  28803. if !ok {
  28804. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28805. }
  28806. m.SetStatus(v)
  28807. return nil
  28808. case usagedetail.FieldType:
  28809. v, ok := value.(int)
  28810. if !ok {
  28811. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28812. }
  28813. m.SetType(v)
  28814. return nil
  28815. case usagedetail.FieldBotID:
  28816. v, ok := value.(string)
  28817. if !ok {
  28818. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28819. }
  28820. m.SetBotID(v)
  28821. return nil
  28822. case usagedetail.FieldReceiverID:
  28823. v, ok := value.(string)
  28824. if !ok {
  28825. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28826. }
  28827. m.SetReceiverID(v)
  28828. return nil
  28829. case usagedetail.FieldApp:
  28830. v, ok := value.(int)
  28831. if !ok {
  28832. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28833. }
  28834. m.SetApp(v)
  28835. return nil
  28836. case usagedetail.FieldSessionID:
  28837. v, ok := value.(uint64)
  28838. if !ok {
  28839. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28840. }
  28841. m.SetSessionID(v)
  28842. return nil
  28843. case usagedetail.FieldRequest:
  28844. v, ok := value.(string)
  28845. if !ok {
  28846. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28847. }
  28848. m.SetRequest(v)
  28849. return nil
  28850. case usagedetail.FieldResponse:
  28851. v, ok := value.(string)
  28852. if !ok {
  28853. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28854. }
  28855. m.SetResponse(v)
  28856. return nil
  28857. case usagedetail.FieldOriginalData:
  28858. v, ok := value.(custom_types.OriginalData)
  28859. if !ok {
  28860. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28861. }
  28862. m.SetOriginalData(v)
  28863. return nil
  28864. case usagedetail.FieldTotalTokens:
  28865. v, ok := value.(uint64)
  28866. if !ok {
  28867. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28868. }
  28869. m.SetTotalTokens(v)
  28870. return nil
  28871. case usagedetail.FieldPromptTokens:
  28872. v, ok := value.(uint64)
  28873. if !ok {
  28874. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28875. }
  28876. m.SetPromptTokens(v)
  28877. return nil
  28878. case usagedetail.FieldCompletionTokens:
  28879. v, ok := value.(uint64)
  28880. if !ok {
  28881. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28882. }
  28883. m.SetCompletionTokens(v)
  28884. return nil
  28885. case usagedetail.FieldOrganizationID:
  28886. v, ok := value.(uint64)
  28887. if !ok {
  28888. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28889. }
  28890. m.SetOrganizationID(v)
  28891. return nil
  28892. }
  28893. return fmt.Errorf("unknown UsageDetail field %s", name)
  28894. }
  28895. // AddedFields returns all numeric fields that were incremented/decremented during
  28896. // this mutation.
  28897. func (m *UsageDetailMutation) AddedFields() []string {
  28898. var fields []string
  28899. if m.addstatus != nil {
  28900. fields = append(fields, usagedetail.FieldStatus)
  28901. }
  28902. if m.add_type != nil {
  28903. fields = append(fields, usagedetail.FieldType)
  28904. }
  28905. if m.addapp != nil {
  28906. fields = append(fields, usagedetail.FieldApp)
  28907. }
  28908. if m.addsession_id != nil {
  28909. fields = append(fields, usagedetail.FieldSessionID)
  28910. }
  28911. if m.addtotal_tokens != nil {
  28912. fields = append(fields, usagedetail.FieldTotalTokens)
  28913. }
  28914. if m.addprompt_tokens != nil {
  28915. fields = append(fields, usagedetail.FieldPromptTokens)
  28916. }
  28917. if m.addcompletion_tokens != nil {
  28918. fields = append(fields, usagedetail.FieldCompletionTokens)
  28919. }
  28920. if m.addorganization_id != nil {
  28921. fields = append(fields, usagedetail.FieldOrganizationID)
  28922. }
  28923. return fields
  28924. }
  28925. // AddedField returns the numeric value that was incremented/decremented on a field
  28926. // with the given name. The second boolean return value indicates that this field
  28927. // was not set, or was not defined in the schema.
  28928. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  28929. switch name {
  28930. case usagedetail.FieldStatus:
  28931. return m.AddedStatus()
  28932. case usagedetail.FieldType:
  28933. return m.AddedType()
  28934. case usagedetail.FieldApp:
  28935. return m.AddedApp()
  28936. case usagedetail.FieldSessionID:
  28937. return m.AddedSessionID()
  28938. case usagedetail.FieldTotalTokens:
  28939. return m.AddedTotalTokens()
  28940. case usagedetail.FieldPromptTokens:
  28941. return m.AddedPromptTokens()
  28942. case usagedetail.FieldCompletionTokens:
  28943. return m.AddedCompletionTokens()
  28944. case usagedetail.FieldOrganizationID:
  28945. return m.AddedOrganizationID()
  28946. }
  28947. return nil, false
  28948. }
  28949. // AddField adds the value to the field with the given name. It returns an error if
  28950. // the field is not defined in the schema, or if the type mismatched the field
  28951. // type.
  28952. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  28953. switch name {
  28954. case usagedetail.FieldStatus:
  28955. v, ok := value.(int8)
  28956. if !ok {
  28957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28958. }
  28959. m.AddStatus(v)
  28960. return nil
  28961. case usagedetail.FieldType:
  28962. v, ok := value.(int)
  28963. if !ok {
  28964. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28965. }
  28966. m.AddType(v)
  28967. return nil
  28968. case usagedetail.FieldApp:
  28969. v, ok := value.(int)
  28970. if !ok {
  28971. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28972. }
  28973. m.AddApp(v)
  28974. return nil
  28975. case usagedetail.FieldSessionID:
  28976. v, ok := value.(int64)
  28977. if !ok {
  28978. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28979. }
  28980. m.AddSessionID(v)
  28981. return nil
  28982. case usagedetail.FieldTotalTokens:
  28983. v, ok := value.(int64)
  28984. if !ok {
  28985. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28986. }
  28987. m.AddTotalTokens(v)
  28988. return nil
  28989. case usagedetail.FieldPromptTokens:
  28990. v, ok := value.(int64)
  28991. if !ok {
  28992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28993. }
  28994. m.AddPromptTokens(v)
  28995. return nil
  28996. case usagedetail.FieldCompletionTokens:
  28997. v, ok := value.(int64)
  28998. if !ok {
  28999. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29000. }
  29001. m.AddCompletionTokens(v)
  29002. return nil
  29003. case usagedetail.FieldOrganizationID:
  29004. v, ok := value.(int64)
  29005. if !ok {
  29006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29007. }
  29008. m.AddOrganizationID(v)
  29009. return nil
  29010. }
  29011. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  29012. }
  29013. // ClearedFields returns all nullable fields that were cleared during this
  29014. // mutation.
  29015. func (m *UsageDetailMutation) ClearedFields() []string {
  29016. var fields []string
  29017. if m.FieldCleared(usagedetail.FieldStatus) {
  29018. fields = append(fields, usagedetail.FieldStatus)
  29019. }
  29020. if m.FieldCleared(usagedetail.FieldType) {
  29021. fields = append(fields, usagedetail.FieldType)
  29022. }
  29023. if m.FieldCleared(usagedetail.FieldApp) {
  29024. fields = append(fields, usagedetail.FieldApp)
  29025. }
  29026. if m.FieldCleared(usagedetail.FieldSessionID) {
  29027. fields = append(fields, usagedetail.FieldSessionID)
  29028. }
  29029. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  29030. fields = append(fields, usagedetail.FieldTotalTokens)
  29031. }
  29032. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  29033. fields = append(fields, usagedetail.FieldPromptTokens)
  29034. }
  29035. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  29036. fields = append(fields, usagedetail.FieldCompletionTokens)
  29037. }
  29038. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  29039. fields = append(fields, usagedetail.FieldOrganizationID)
  29040. }
  29041. return fields
  29042. }
  29043. // FieldCleared returns a boolean indicating if a field with the given name was
  29044. // cleared in this mutation.
  29045. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  29046. _, ok := m.clearedFields[name]
  29047. return ok
  29048. }
  29049. // ClearField clears the value of the field with the given name. It returns an
  29050. // error if the field is not defined in the schema.
  29051. func (m *UsageDetailMutation) ClearField(name string) error {
  29052. switch name {
  29053. case usagedetail.FieldStatus:
  29054. m.ClearStatus()
  29055. return nil
  29056. case usagedetail.FieldType:
  29057. m.ClearType()
  29058. return nil
  29059. case usagedetail.FieldApp:
  29060. m.ClearApp()
  29061. return nil
  29062. case usagedetail.FieldSessionID:
  29063. m.ClearSessionID()
  29064. return nil
  29065. case usagedetail.FieldTotalTokens:
  29066. m.ClearTotalTokens()
  29067. return nil
  29068. case usagedetail.FieldPromptTokens:
  29069. m.ClearPromptTokens()
  29070. return nil
  29071. case usagedetail.FieldCompletionTokens:
  29072. m.ClearCompletionTokens()
  29073. return nil
  29074. case usagedetail.FieldOrganizationID:
  29075. m.ClearOrganizationID()
  29076. return nil
  29077. }
  29078. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  29079. }
  29080. // ResetField resets all changes in the mutation for the field with the given name.
  29081. // It returns an error if the field is not defined in the schema.
  29082. func (m *UsageDetailMutation) ResetField(name string) error {
  29083. switch name {
  29084. case usagedetail.FieldCreatedAt:
  29085. m.ResetCreatedAt()
  29086. return nil
  29087. case usagedetail.FieldUpdatedAt:
  29088. m.ResetUpdatedAt()
  29089. return nil
  29090. case usagedetail.FieldStatus:
  29091. m.ResetStatus()
  29092. return nil
  29093. case usagedetail.FieldType:
  29094. m.ResetType()
  29095. return nil
  29096. case usagedetail.FieldBotID:
  29097. m.ResetBotID()
  29098. return nil
  29099. case usagedetail.FieldReceiverID:
  29100. m.ResetReceiverID()
  29101. return nil
  29102. case usagedetail.FieldApp:
  29103. m.ResetApp()
  29104. return nil
  29105. case usagedetail.FieldSessionID:
  29106. m.ResetSessionID()
  29107. return nil
  29108. case usagedetail.FieldRequest:
  29109. m.ResetRequest()
  29110. return nil
  29111. case usagedetail.FieldResponse:
  29112. m.ResetResponse()
  29113. return nil
  29114. case usagedetail.FieldOriginalData:
  29115. m.ResetOriginalData()
  29116. return nil
  29117. case usagedetail.FieldTotalTokens:
  29118. m.ResetTotalTokens()
  29119. return nil
  29120. case usagedetail.FieldPromptTokens:
  29121. m.ResetPromptTokens()
  29122. return nil
  29123. case usagedetail.FieldCompletionTokens:
  29124. m.ResetCompletionTokens()
  29125. return nil
  29126. case usagedetail.FieldOrganizationID:
  29127. m.ResetOrganizationID()
  29128. return nil
  29129. }
  29130. return fmt.Errorf("unknown UsageDetail field %s", name)
  29131. }
  29132. // AddedEdges returns all edge names that were set/added in this mutation.
  29133. func (m *UsageDetailMutation) AddedEdges() []string {
  29134. edges := make([]string, 0, 0)
  29135. return edges
  29136. }
  29137. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29138. // name in this mutation.
  29139. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  29140. return nil
  29141. }
  29142. // RemovedEdges returns all edge names that were removed in this mutation.
  29143. func (m *UsageDetailMutation) RemovedEdges() []string {
  29144. edges := make([]string, 0, 0)
  29145. return edges
  29146. }
  29147. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29148. // the given name in this mutation.
  29149. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  29150. return nil
  29151. }
  29152. // ClearedEdges returns all edge names that were cleared in this mutation.
  29153. func (m *UsageDetailMutation) ClearedEdges() []string {
  29154. edges := make([]string, 0, 0)
  29155. return edges
  29156. }
  29157. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29158. // was cleared in this mutation.
  29159. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  29160. return false
  29161. }
  29162. // ClearEdge clears the value of the edge with the given name. It returns an error
  29163. // if that edge is not defined in the schema.
  29164. func (m *UsageDetailMutation) ClearEdge(name string) error {
  29165. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  29166. }
  29167. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29168. // It returns an error if the edge is not defined in the schema.
  29169. func (m *UsageDetailMutation) ResetEdge(name string) error {
  29170. return fmt.Errorf("unknown UsageDetail edge %s", name)
  29171. }
  29172. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  29173. type UsageStatisticDayMutation struct {
  29174. config
  29175. op Op
  29176. typ string
  29177. id *uint64
  29178. created_at *time.Time
  29179. updated_at *time.Time
  29180. status *uint8
  29181. addstatus *int8
  29182. deleted_at *time.Time
  29183. addtime *uint64
  29184. addaddtime *int64
  29185. _type *int
  29186. add_type *int
  29187. bot_id *string
  29188. organization_id *uint64
  29189. addorganization_id *int64
  29190. ai_response *uint64
  29191. addai_response *int64
  29192. sop_run *uint64
  29193. addsop_run *int64
  29194. total_friend *uint64
  29195. addtotal_friend *int64
  29196. total_group *uint64
  29197. addtotal_group *int64
  29198. account_balance *uint64
  29199. addaccount_balance *int64
  29200. consume_token *uint64
  29201. addconsume_token *int64
  29202. active_user *uint64
  29203. addactive_user *int64
  29204. new_user *int64
  29205. addnew_user *int64
  29206. label_dist *[]custom_types.LabelDist
  29207. appendlabel_dist []custom_types.LabelDist
  29208. clearedFields map[string]struct{}
  29209. done bool
  29210. oldValue func(context.Context) (*UsageStatisticDay, error)
  29211. predicates []predicate.UsageStatisticDay
  29212. }
  29213. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  29214. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  29215. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  29216. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  29217. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  29218. m := &UsageStatisticDayMutation{
  29219. config: c,
  29220. op: op,
  29221. typ: TypeUsageStatisticDay,
  29222. clearedFields: make(map[string]struct{}),
  29223. }
  29224. for _, opt := range opts {
  29225. opt(m)
  29226. }
  29227. return m
  29228. }
  29229. // withUsageStatisticDayID sets the ID field of the mutation.
  29230. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  29231. return func(m *UsageStatisticDayMutation) {
  29232. var (
  29233. err error
  29234. once sync.Once
  29235. value *UsageStatisticDay
  29236. )
  29237. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  29238. once.Do(func() {
  29239. if m.done {
  29240. err = errors.New("querying old values post mutation is not allowed")
  29241. } else {
  29242. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  29243. }
  29244. })
  29245. return value, err
  29246. }
  29247. m.id = &id
  29248. }
  29249. }
  29250. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  29251. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  29252. return func(m *UsageStatisticDayMutation) {
  29253. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  29254. return node, nil
  29255. }
  29256. m.id = &node.ID
  29257. }
  29258. }
  29259. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29260. // executed in a transaction (ent.Tx), a transactional client is returned.
  29261. func (m UsageStatisticDayMutation) Client() *Client {
  29262. client := &Client{config: m.config}
  29263. client.init()
  29264. return client
  29265. }
  29266. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29267. // it returns an error otherwise.
  29268. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  29269. if _, ok := m.driver.(*txDriver); !ok {
  29270. return nil, errors.New("ent: mutation is not running in a transaction")
  29271. }
  29272. tx := &Tx{config: m.config}
  29273. tx.init()
  29274. return tx, nil
  29275. }
  29276. // SetID sets the value of the id field. Note that this
  29277. // operation is only accepted on creation of UsageStatisticDay entities.
  29278. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  29279. m.id = &id
  29280. }
  29281. // ID returns the ID value in the mutation. Note that the ID is only available
  29282. // if it was provided to the builder or after it was returned from the database.
  29283. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  29284. if m.id == nil {
  29285. return
  29286. }
  29287. return *m.id, true
  29288. }
  29289. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29290. // That means, if the mutation is applied within a transaction with an isolation level such
  29291. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29292. // or updated by the mutation.
  29293. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  29294. switch {
  29295. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29296. id, exists := m.ID()
  29297. if exists {
  29298. return []uint64{id}, nil
  29299. }
  29300. fallthrough
  29301. case m.op.Is(OpUpdate | OpDelete):
  29302. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  29303. default:
  29304. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29305. }
  29306. }
  29307. // SetCreatedAt sets the "created_at" field.
  29308. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  29309. m.created_at = &t
  29310. }
  29311. // CreatedAt returns the value of the "created_at" field in the mutation.
  29312. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  29313. v := m.created_at
  29314. if v == nil {
  29315. return
  29316. }
  29317. return *v, true
  29318. }
  29319. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  29320. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29321. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29322. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29323. if !m.op.Is(OpUpdateOne) {
  29324. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29325. }
  29326. if m.id == nil || m.oldValue == nil {
  29327. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29328. }
  29329. oldValue, err := m.oldValue(ctx)
  29330. if err != nil {
  29331. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29332. }
  29333. return oldValue.CreatedAt, nil
  29334. }
  29335. // ResetCreatedAt resets all changes to the "created_at" field.
  29336. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  29337. m.created_at = nil
  29338. }
  29339. // SetUpdatedAt sets the "updated_at" field.
  29340. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  29341. m.updated_at = &t
  29342. }
  29343. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29344. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  29345. v := m.updated_at
  29346. if v == nil {
  29347. return
  29348. }
  29349. return *v, true
  29350. }
  29351. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  29352. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29353. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29354. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29355. if !m.op.Is(OpUpdateOne) {
  29356. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29357. }
  29358. if m.id == nil || m.oldValue == nil {
  29359. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29360. }
  29361. oldValue, err := m.oldValue(ctx)
  29362. if err != nil {
  29363. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29364. }
  29365. return oldValue.UpdatedAt, nil
  29366. }
  29367. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29368. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  29369. m.updated_at = nil
  29370. }
  29371. // SetStatus sets the "status" field.
  29372. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  29373. m.status = &u
  29374. m.addstatus = nil
  29375. }
  29376. // Status returns the value of the "status" field in the mutation.
  29377. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  29378. v := m.status
  29379. if v == nil {
  29380. return
  29381. }
  29382. return *v, true
  29383. }
  29384. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  29385. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29386. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29387. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  29388. if !m.op.Is(OpUpdateOne) {
  29389. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  29390. }
  29391. if m.id == nil || m.oldValue == nil {
  29392. return v, errors.New("OldStatus requires an ID field in the mutation")
  29393. }
  29394. oldValue, err := m.oldValue(ctx)
  29395. if err != nil {
  29396. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  29397. }
  29398. return oldValue.Status, nil
  29399. }
  29400. // AddStatus adds u to the "status" field.
  29401. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  29402. if m.addstatus != nil {
  29403. *m.addstatus += u
  29404. } else {
  29405. m.addstatus = &u
  29406. }
  29407. }
  29408. // AddedStatus returns the value that was added to the "status" field in this mutation.
  29409. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  29410. v := m.addstatus
  29411. if v == nil {
  29412. return
  29413. }
  29414. return *v, true
  29415. }
  29416. // ClearStatus clears the value of the "status" field.
  29417. func (m *UsageStatisticDayMutation) ClearStatus() {
  29418. m.status = nil
  29419. m.addstatus = nil
  29420. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  29421. }
  29422. // StatusCleared returns if the "status" field was cleared in this mutation.
  29423. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  29424. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  29425. return ok
  29426. }
  29427. // ResetStatus resets all changes to the "status" field.
  29428. func (m *UsageStatisticDayMutation) ResetStatus() {
  29429. m.status = nil
  29430. m.addstatus = nil
  29431. delete(m.clearedFields, usagestatisticday.FieldStatus)
  29432. }
  29433. // SetDeletedAt sets the "deleted_at" field.
  29434. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  29435. m.deleted_at = &t
  29436. }
  29437. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  29438. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  29439. v := m.deleted_at
  29440. if v == nil {
  29441. return
  29442. }
  29443. return *v, true
  29444. }
  29445. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  29446. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29447. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29448. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  29449. if !m.op.Is(OpUpdateOne) {
  29450. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  29451. }
  29452. if m.id == nil || m.oldValue == nil {
  29453. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  29454. }
  29455. oldValue, err := m.oldValue(ctx)
  29456. if err != nil {
  29457. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  29458. }
  29459. return oldValue.DeletedAt, nil
  29460. }
  29461. // ClearDeletedAt clears the value of the "deleted_at" field.
  29462. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  29463. m.deleted_at = nil
  29464. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  29465. }
  29466. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  29467. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  29468. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  29469. return ok
  29470. }
  29471. // ResetDeletedAt resets all changes to the "deleted_at" field.
  29472. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  29473. m.deleted_at = nil
  29474. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  29475. }
  29476. // SetAddtime sets the "addtime" field.
  29477. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  29478. m.addtime = &u
  29479. m.addaddtime = nil
  29480. }
  29481. // Addtime returns the value of the "addtime" field in the mutation.
  29482. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  29483. v := m.addtime
  29484. if v == nil {
  29485. return
  29486. }
  29487. return *v, true
  29488. }
  29489. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  29490. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29491. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29492. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  29493. if !m.op.Is(OpUpdateOne) {
  29494. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  29495. }
  29496. if m.id == nil || m.oldValue == nil {
  29497. return v, errors.New("OldAddtime requires an ID field in the mutation")
  29498. }
  29499. oldValue, err := m.oldValue(ctx)
  29500. if err != nil {
  29501. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  29502. }
  29503. return oldValue.Addtime, nil
  29504. }
  29505. // AddAddtime adds u to the "addtime" field.
  29506. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  29507. if m.addaddtime != nil {
  29508. *m.addaddtime += u
  29509. } else {
  29510. m.addaddtime = &u
  29511. }
  29512. }
  29513. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  29514. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  29515. v := m.addaddtime
  29516. if v == nil {
  29517. return
  29518. }
  29519. return *v, true
  29520. }
  29521. // ResetAddtime resets all changes to the "addtime" field.
  29522. func (m *UsageStatisticDayMutation) ResetAddtime() {
  29523. m.addtime = nil
  29524. m.addaddtime = nil
  29525. }
  29526. // SetType sets the "type" field.
  29527. func (m *UsageStatisticDayMutation) SetType(i int) {
  29528. m._type = &i
  29529. m.add_type = nil
  29530. }
  29531. // GetType returns the value of the "type" field in the mutation.
  29532. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  29533. v := m._type
  29534. if v == nil {
  29535. return
  29536. }
  29537. return *v, true
  29538. }
  29539. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  29540. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29541. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29542. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  29543. if !m.op.Is(OpUpdateOne) {
  29544. return v, errors.New("OldType is only allowed on UpdateOne operations")
  29545. }
  29546. if m.id == nil || m.oldValue == nil {
  29547. return v, errors.New("OldType requires an ID field in the mutation")
  29548. }
  29549. oldValue, err := m.oldValue(ctx)
  29550. if err != nil {
  29551. return v, fmt.Errorf("querying old value for OldType: %w", err)
  29552. }
  29553. return oldValue.Type, nil
  29554. }
  29555. // AddType adds i to the "type" field.
  29556. func (m *UsageStatisticDayMutation) AddType(i int) {
  29557. if m.add_type != nil {
  29558. *m.add_type += i
  29559. } else {
  29560. m.add_type = &i
  29561. }
  29562. }
  29563. // AddedType returns the value that was added to the "type" field in this mutation.
  29564. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  29565. v := m.add_type
  29566. if v == nil {
  29567. return
  29568. }
  29569. return *v, true
  29570. }
  29571. // ResetType resets all changes to the "type" field.
  29572. func (m *UsageStatisticDayMutation) ResetType() {
  29573. m._type = nil
  29574. m.add_type = nil
  29575. }
  29576. // SetBotID sets the "bot_id" field.
  29577. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  29578. m.bot_id = &s
  29579. }
  29580. // BotID returns the value of the "bot_id" field in the mutation.
  29581. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  29582. v := m.bot_id
  29583. if v == nil {
  29584. return
  29585. }
  29586. return *v, true
  29587. }
  29588. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  29589. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29590. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29591. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  29592. if !m.op.Is(OpUpdateOne) {
  29593. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  29594. }
  29595. if m.id == nil || m.oldValue == nil {
  29596. return v, errors.New("OldBotID requires an ID field in the mutation")
  29597. }
  29598. oldValue, err := m.oldValue(ctx)
  29599. if err != nil {
  29600. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  29601. }
  29602. return oldValue.BotID, nil
  29603. }
  29604. // ClearBotID clears the value of the "bot_id" field.
  29605. func (m *UsageStatisticDayMutation) ClearBotID() {
  29606. m.bot_id = nil
  29607. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  29608. }
  29609. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  29610. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  29611. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  29612. return ok
  29613. }
  29614. // ResetBotID resets all changes to the "bot_id" field.
  29615. func (m *UsageStatisticDayMutation) ResetBotID() {
  29616. m.bot_id = nil
  29617. delete(m.clearedFields, usagestatisticday.FieldBotID)
  29618. }
  29619. // SetOrganizationID sets the "organization_id" field.
  29620. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  29621. m.organization_id = &u
  29622. m.addorganization_id = nil
  29623. }
  29624. // OrganizationID returns the value of the "organization_id" field in the mutation.
  29625. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  29626. v := m.organization_id
  29627. if v == nil {
  29628. return
  29629. }
  29630. return *v, true
  29631. }
  29632. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  29633. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29634. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29635. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  29636. if !m.op.Is(OpUpdateOne) {
  29637. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  29638. }
  29639. if m.id == nil || m.oldValue == nil {
  29640. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  29641. }
  29642. oldValue, err := m.oldValue(ctx)
  29643. if err != nil {
  29644. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  29645. }
  29646. return oldValue.OrganizationID, nil
  29647. }
  29648. // AddOrganizationID adds u to the "organization_id" field.
  29649. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  29650. if m.addorganization_id != nil {
  29651. *m.addorganization_id += u
  29652. } else {
  29653. m.addorganization_id = &u
  29654. }
  29655. }
  29656. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  29657. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  29658. v := m.addorganization_id
  29659. if v == nil {
  29660. return
  29661. }
  29662. return *v, true
  29663. }
  29664. // ClearOrganizationID clears the value of the "organization_id" field.
  29665. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  29666. m.organization_id = nil
  29667. m.addorganization_id = nil
  29668. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  29669. }
  29670. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  29671. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  29672. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  29673. return ok
  29674. }
  29675. // ResetOrganizationID resets all changes to the "organization_id" field.
  29676. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  29677. m.organization_id = nil
  29678. m.addorganization_id = nil
  29679. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  29680. }
  29681. // SetAiResponse sets the "ai_response" field.
  29682. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  29683. m.ai_response = &u
  29684. m.addai_response = nil
  29685. }
  29686. // AiResponse returns the value of the "ai_response" field in the mutation.
  29687. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  29688. v := m.ai_response
  29689. if v == nil {
  29690. return
  29691. }
  29692. return *v, true
  29693. }
  29694. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  29695. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29696. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29697. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  29698. if !m.op.Is(OpUpdateOne) {
  29699. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  29700. }
  29701. if m.id == nil || m.oldValue == nil {
  29702. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  29703. }
  29704. oldValue, err := m.oldValue(ctx)
  29705. if err != nil {
  29706. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  29707. }
  29708. return oldValue.AiResponse, nil
  29709. }
  29710. // AddAiResponse adds u to the "ai_response" field.
  29711. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  29712. if m.addai_response != nil {
  29713. *m.addai_response += u
  29714. } else {
  29715. m.addai_response = &u
  29716. }
  29717. }
  29718. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  29719. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  29720. v := m.addai_response
  29721. if v == nil {
  29722. return
  29723. }
  29724. return *v, true
  29725. }
  29726. // ResetAiResponse resets all changes to the "ai_response" field.
  29727. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  29728. m.ai_response = nil
  29729. m.addai_response = nil
  29730. }
  29731. // SetSopRun sets the "sop_run" field.
  29732. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  29733. m.sop_run = &u
  29734. m.addsop_run = nil
  29735. }
  29736. // SopRun returns the value of the "sop_run" field in the mutation.
  29737. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  29738. v := m.sop_run
  29739. if v == nil {
  29740. return
  29741. }
  29742. return *v, true
  29743. }
  29744. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  29745. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29746. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29747. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  29748. if !m.op.Is(OpUpdateOne) {
  29749. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  29750. }
  29751. if m.id == nil || m.oldValue == nil {
  29752. return v, errors.New("OldSopRun requires an ID field in the mutation")
  29753. }
  29754. oldValue, err := m.oldValue(ctx)
  29755. if err != nil {
  29756. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  29757. }
  29758. return oldValue.SopRun, nil
  29759. }
  29760. // AddSopRun adds u to the "sop_run" field.
  29761. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  29762. if m.addsop_run != nil {
  29763. *m.addsop_run += u
  29764. } else {
  29765. m.addsop_run = &u
  29766. }
  29767. }
  29768. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  29769. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  29770. v := m.addsop_run
  29771. if v == nil {
  29772. return
  29773. }
  29774. return *v, true
  29775. }
  29776. // ResetSopRun resets all changes to the "sop_run" field.
  29777. func (m *UsageStatisticDayMutation) ResetSopRun() {
  29778. m.sop_run = nil
  29779. m.addsop_run = nil
  29780. }
  29781. // SetTotalFriend sets the "total_friend" field.
  29782. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  29783. m.total_friend = &u
  29784. m.addtotal_friend = nil
  29785. }
  29786. // TotalFriend returns the value of the "total_friend" field in the mutation.
  29787. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  29788. v := m.total_friend
  29789. if v == nil {
  29790. return
  29791. }
  29792. return *v, true
  29793. }
  29794. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  29795. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29796. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29797. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  29798. if !m.op.Is(OpUpdateOne) {
  29799. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  29800. }
  29801. if m.id == nil || m.oldValue == nil {
  29802. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  29803. }
  29804. oldValue, err := m.oldValue(ctx)
  29805. if err != nil {
  29806. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  29807. }
  29808. return oldValue.TotalFriend, nil
  29809. }
  29810. // AddTotalFriend adds u to the "total_friend" field.
  29811. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  29812. if m.addtotal_friend != nil {
  29813. *m.addtotal_friend += u
  29814. } else {
  29815. m.addtotal_friend = &u
  29816. }
  29817. }
  29818. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  29819. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  29820. v := m.addtotal_friend
  29821. if v == nil {
  29822. return
  29823. }
  29824. return *v, true
  29825. }
  29826. // ResetTotalFriend resets all changes to the "total_friend" field.
  29827. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  29828. m.total_friend = nil
  29829. m.addtotal_friend = nil
  29830. }
  29831. // SetTotalGroup sets the "total_group" field.
  29832. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  29833. m.total_group = &u
  29834. m.addtotal_group = nil
  29835. }
  29836. // TotalGroup returns the value of the "total_group" field in the mutation.
  29837. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  29838. v := m.total_group
  29839. if v == nil {
  29840. return
  29841. }
  29842. return *v, true
  29843. }
  29844. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  29845. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29846. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29847. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  29848. if !m.op.Is(OpUpdateOne) {
  29849. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  29850. }
  29851. if m.id == nil || m.oldValue == nil {
  29852. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  29853. }
  29854. oldValue, err := m.oldValue(ctx)
  29855. if err != nil {
  29856. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  29857. }
  29858. return oldValue.TotalGroup, nil
  29859. }
  29860. // AddTotalGroup adds u to the "total_group" field.
  29861. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  29862. if m.addtotal_group != nil {
  29863. *m.addtotal_group += u
  29864. } else {
  29865. m.addtotal_group = &u
  29866. }
  29867. }
  29868. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  29869. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  29870. v := m.addtotal_group
  29871. if v == nil {
  29872. return
  29873. }
  29874. return *v, true
  29875. }
  29876. // ResetTotalGroup resets all changes to the "total_group" field.
  29877. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  29878. m.total_group = nil
  29879. m.addtotal_group = nil
  29880. }
  29881. // SetAccountBalance sets the "account_balance" field.
  29882. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  29883. m.account_balance = &u
  29884. m.addaccount_balance = nil
  29885. }
  29886. // AccountBalance returns the value of the "account_balance" field in the mutation.
  29887. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  29888. v := m.account_balance
  29889. if v == nil {
  29890. return
  29891. }
  29892. return *v, true
  29893. }
  29894. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  29895. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29896. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29897. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  29898. if !m.op.Is(OpUpdateOne) {
  29899. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  29900. }
  29901. if m.id == nil || m.oldValue == nil {
  29902. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  29903. }
  29904. oldValue, err := m.oldValue(ctx)
  29905. if err != nil {
  29906. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  29907. }
  29908. return oldValue.AccountBalance, nil
  29909. }
  29910. // AddAccountBalance adds u to the "account_balance" field.
  29911. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  29912. if m.addaccount_balance != nil {
  29913. *m.addaccount_balance += u
  29914. } else {
  29915. m.addaccount_balance = &u
  29916. }
  29917. }
  29918. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  29919. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  29920. v := m.addaccount_balance
  29921. if v == nil {
  29922. return
  29923. }
  29924. return *v, true
  29925. }
  29926. // ResetAccountBalance resets all changes to the "account_balance" field.
  29927. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  29928. m.account_balance = nil
  29929. m.addaccount_balance = nil
  29930. }
  29931. // SetConsumeToken sets the "consume_token" field.
  29932. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  29933. m.consume_token = &u
  29934. m.addconsume_token = nil
  29935. }
  29936. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  29937. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  29938. v := m.consume_token
  29939. if v == nil {
  29940. return
  29941. }
  29942. return *v, true
  29943. }
  29944. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  29945. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29946. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29947. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  29948. if !m.op.Is(OpUpdateOne) {
  29949. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  29950. }
  29951. if m.id == nil || m.oldValue == nil {
  29952. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  29953. }
  29954. oldValue, err := m.oldValue(ctx)
  29955. if err != nil {
  29956. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  29957. }
  29958. return oldValue.ConsumeToken, nil
  29959. }
  29960. // AddConsumeToken adds u to the "consume_token" field.
  29961. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  29962. if m.addconsume_token != nil {
  29963. *m.addconsume_token += u
  29964. } else {
  29965. m.addconsume_token = &u
  29966. }
  29967. }
  29968. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  29969. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  29970. v := m.addconsume_token
  29971. if v == nil {
  29972. return
  29973. }
  29974. return *v, true
  29975. }
  29976. // ResetConsumeToken resets all changes to the "consume_token" field.
  29977. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  29978. m.consume_token = nil
  29979. m.addconsume_token = nil
  29980. }
  29981. // SetActiveUser sets the "active_user" field.
  29982. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  29983. m.active_user = &u
  29984. m.addactive_user = nil
  29985. }
  29986. // ActiveUser returns the value of the "active_user" field in the mutation.
  29987. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  29988. v := m.active_user
  29989. if v == nil {
  29990. return
  29991. }
  29992. return *v, true
  29993. }
  29994. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  29995. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29996. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29997. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  29998. if !m.op.Is(OpUpdateOne) {
  29999. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  30000. }
  30001. if m.id == nil || m.oldValue == nil {
  30002. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  30003. }
  30004. oldValue, err := m.oldValue(ctx)
  30005. if err != nil {
  30006. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  30007. }
  30008. return oldValue.ActiveUser, nil
  30009. }
  30010. // AddActiveUser adds u to the "active_user" field.
  30011. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  30012. if m.addactive_user != nil {
  30013. *m.addactive_user += u
  30014. } else {
  30015. m.addactive_user = &u
  30016. }
  30017. }
  30018. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  30019. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  30020. v := m.addactive_user
  30021. if v == nil {
  30022. return
  30023. }
  30024. return *v, true
  30025. }
  30026. // ResetActiveUser resets all changes to the "active_user" field.
  30027. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  30028. m.active_user = nil
  30029. m.addactive_user = nil
  30030. }
  30031. // SetNewUser sets the "new_user" field.
  30032. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  30033. m.new_user = &i
  30034. m.addnew_user = nil
  30035. }
  30036. // NewUser returns the value of the "new_user" field in the mutation.
  30037. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  30038. v := m.new_user
  30039. if v == nil {
  30040. return
  30041. }
  30042. return *v, true
  30043. }
  30044. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  30045. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30046. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30047. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  30048. if !m.op.Is(OpUpdateOne) {
  30049. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  30050. }
  30051. if m.id == nil || m.oldValue == nil {
  30052. return v, errors.New("OldNewUser requires an ID field in the mutation")
  30053. }
  30054. oldValue, err := m.oldValue(ctx)
  30055. if err != nil {
  30056. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  30057. }
  30058. return oldValue.NewUser, nil
  30059. }
  30060. // AddNewUser adds i to the "new_user" field.
  30061. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  30062. if m.addnew_user != nil {
  30063. *m.addnew_user += i
  30064. } else {
  30065. m.addnew_user = &i
  30066. }
  30067. }
  30068. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  30069. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  30070. v := m.addnew_user
  30071. if v == nil {
  30072. return
  30073. }
  30074. return *v, true
  30075. }
  30076. // ResetNewUser resets all changes to the "new_user" field.
  30077. func (m *UsageStatisticDayMutation) ResetNewUser() {
  30078. m.new_user = nil
  30079. m.addnew_user = nil
  30080. }
  30081. // SetLabelDist sets the "label_dist" field.
  30082. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  30083. m.label_dist = &ctd
  30084. m.appendlabel_dist = nil
  30085. }
  30086. // LabelDist returns the value of the "label_dist" field in the mutation.
  30087. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  30088. v := m.label_dist
  30089. if v == nil {
  30090. return
  30091. }
  30092. return *v, true
  30093. }
  30094. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  30095. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30096. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30097. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  30098. if !m.op.Is(OpUpdateOne) {
  30099. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  30100. }
  30101. if m.id == nil || m.oldValue == nil {
  30102. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  30103. }
  30104. oldValue, err := m.oldValue(ctx)
  30105. if err != nil {
  30106. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  30107. }
  30108. return oldValue.LabelDist, nil
  30109. }
  30110. // AppendLabelDist adds ctd to the "label_dist" field.
  30111. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  30112. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  30113. }
  30114. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  30115. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  30116. if len(m.appendlabel_dist) == 0 {
  30117. return nil, false
  30118. }
  30119. return m.appendlabel_dist, true
  30120. }
  30121. // ResetLabelDist resets all changes to the "label_dist" field.
  30122. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  30123. m.label_dist = nil
  30124. m.appendlabel_dist = nil
  30125. }
  30126. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  30127. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  30128. m.predicates = append(m.predicates, ps...)
  30129. }
  30130. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  30131. // users can use type-assertion to append predicates that do not depend on any generated package.
  30132. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  30133. p := make([]predicate.UsageStatisticDay, len(ps))
  30134. for i := range ps {
  30135. p[i] = ps[i]
  30136. }
  30137. m.Where(p...)
  30138. }
  30139. // Op returns the operation name.
  30140. func (m *UsageStatisticDayMutation) Op() Op {
  30141. return m.op
  30142. }
  30143. // SetOp allows setting the mutation operation.
  30144. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  30145. m.op = op
  30146. }
  30147. // Type returns the node type of this mutation (UsageStatisticDay).
  30148. func (m *UsageStatisticDayMutation) Type() string {
  30149. return m.typ
  30150. }
  30151. // Fields returns all fields that were changed during this mutation. Note that in
  30152. // order to get all numeric fields that were incremented/decremented, call
  30153. // AddedFields().
  30154. func (m *UsageStatisticDayMutation) Fields() []string {
  30155. fields := make([]string, 0, 17)
  30156. if m.created_at != nil {
  30157. fields = append(fields, usagestatisticday.FieldCreatedAt)
  30158. }
  30159. if m.updated_at != nil {
  30160. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  30161. }
  30162. if m.status != nil {
  30163. fields = append(fields, usagestatisticday.FieldStatus)
  30164. }
  30165. if m.deleted_at != nil {
  30166. fields = append(fields, usagestatisticday.FieldDeletedAt)
  30167. }
  30168. if m.addtime != nil {
  30169. fields = append(fields, usagestatisticday.FieldAddtime)
  30170. }
  30171. if m._type != nil {
  30172. fields = append(fields, usagestatisticday.FieldType)
  30173. }
  30174. if m.bot_id != nil {
  30175. fields = append(fields, usagestatisticday.FieldBotID)
  30176. }
  30177. if m.organization_id != nil {
  30178. fields = append(fields, usagestatisticday.FieldOrganizationID)
  30179. }
  30180. if m.ai_response != nil {
  30181. fields = append(fields, usagestatisticday.FieldAiResponse)
  30182. }
  30183. if m.sop_run != nil {
  30184. fields = append(fields, usagestatisticday.FieldSopRun)
  30185. }
  30186. if m.total_friend != nil {
  30187. fields = append(fields, usagestatisticday.FieldTotalFriend)
  30188. }
  30189. if m.total_group != nil {
  30190. fields = append(fields, usagestatisticday.FieldTotalGroup)
  30191. }
  30192. if m.account_balance != nil {
  30193. fields = append(fields, usagestatisticday.FieldAccountBalance)
  30194. }
  30195. if m.consume_token != nil {
  30196. fields = append(fields, usagestatisticday.FieldConsumeToken)
  30197. }
  30198. if m.active_user != nil {
  30199. fields = append(fields, usagestatisticday.FieldActiveUser)
  30200. }
  30201. if m.new_user != nil {
  30202. fields = append(fields, usagestatisticday.FieldNewUser)
  30203. }
  30204. if m.label_dist != nil {
  30205. fields = append(fields, usagestatisticday.FieldLabelDist)
  30206. }
  30207. return fields
  30208. }
  30209. // Field returns the value of a field with the given name. The second boolean
  30210. // return value indicates that this field was not set, or was not defined in the
  30211. // schema.
  30212. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  30213. switch name {
  30214. case usagestatisticday.FieldCreatedAt:
  30215. return m.CreatedAt()
  30216. case usagestatisticday.FieldUpdatedAt:
  30217. return m.UpdatedAt()
  30218. case usagestatisticday.FieldStatus:
  30219. return m.Status()
  30220. case usagestatisticday.FieldDeletedAt:
  30221. return m.DeletedAt()
  30222. case usagestatisticday.FieldAddtime:
  30223. return m.Addtime()
  30224. case usagestatisticday.FieldType:
  30225. return m.GetType()
  30226. case usagestatisticday.FieldBotID:
  30227. return m.BotID()
  30228. case usagestatisticday.FieldOrganizationID:
  30229. return m.OrganizationID()
  30230. case usagestatisticday.FieldAiResponse:
  30231. return m.AiResponse()
  30232. case usagestatisticday.FieldSopRun:
  30233. return m.SopRun()
  30234. case usagestatisticday.FieldTotalFriend:
  30235. return m.TotalFriend()
  30236. case usagestatisticday.FieldTotalGroup:
  30237. return m.TotalGroup()
  30238. case usagestatisticday.FieldAccountBalance:
  30239. return m.AccountBalance()
  30240. case usagestatisticday.FieldConsumeToken:
  30241. return m.ConsumeToken()
  30242. case usagestatisticday.FieldActiveUser:
  30243. return m.ActiveUser()
  30244. case usagestatisticday.FieldNewUser:
  30245. return m.NewUser()
  30246. case usagestatisticday.FieldLabelDist:
  30247. return m.LabelDist()
  30248. }
  30249. return nil, false
  30250. }
  30251. // OldField returns the old value of the field from the database. An error is
  30252. // returned if the mutation operation is not UpdateOne, or the query to the
  30253. // database failed.
  30254. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30255. switch name {
  30256. case usagestatisticday.FieldCreatedAt:
  30257. return m.OldCreatedAt(ctx)
  30258. case usagestatisticday.FieldUpdatedAt:
  30259. return m.OldUpdatedAt(ctx)
  30260. case usagestatisticday.FieldStatus:
  30261. return m.OldStatus(ctx)
  30262. case usagestatisticday.FieldDeletedAt:
  30263. return m.OldDeletedAt(ctx)
  30264. case usagestatisticday.FieldAddtime:
  30265. return m.OldAddtime(ctx)
  30266. case usagestatisticday.FieldType:
  30267. return m.OldType(ctx)
  30268. case usagestatisticday.FieldBotID:
  30269. return m.OldBotID(ctx)
  30270. case usagestatisticday.FieldOrganizationID:
  30271. return m.OldOrganizationID(ctx)
  30272. case usagestatisticday.FieldAiResponse:
  30273. return m.OldAiResponse(ctx)
  30274. case usagestatisticday.FieldSopRun:
  30275. return m.OldSopRun(ctx)
  30276. case usagestatisticday.FieldTotalFriend:
  30277. return m.OldTotalFriend(ctx)
  30278. case usagestatisticday.FieldTotalGroup:
  30279. return m.OldTotalGroup(ctx)
  30280. case usagestatisticday.FieldAccountBalance:
  30281. return m.OldAccountBalance(ctx)
  30282. case usagestatisticday.FieldConsumeToken:
  30283. return m.OldConsumeToken(ctx)
  30284. case usagestatisticday.FieldActiveUser:
  30285. return m.OldActiveUser(ctx)
  30286. case usagestatisticday.FieldNewUser:
  30287. return m.OldNewUser(ctx)
  30288. case usagestatisticday.FieldLabelDist:
  30289. return m.OldLabelDist(ctx)
  30290. }
  30291. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  30292. }
  30293. // SetField sets the value of a field with the given name. It returns an error if
  30294. // the field is not defined in the schema, or if the type mismatched the field
  30295. // type.
  30296. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  30297. switch name {
  30298. case usagestatisticday.FieldCreatedAt:
  30299. v, ok := value.(time.Time)
  30300. if !ok {
  30301. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30302. }
  30303. m.SetCreatedAt(v)
  30304. return nil
  30305. case usagestatisticday.FieldUpdatedAt:
  30306. v, ok := value.(time.Time)
  30307. if !ok {
  30308. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30309. }
  30310. m.SetUpdatedAt(v)
  30311. return nil
  30312. case usagestatisticday.FieldStatus:
  30313. v, ok := value.(uint8)
  30314. if !ok {
  30315. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30316. }
  30317. m.SetStatus(v)
  30318. return nil
  30319. case usagestatisticday.FieldDeletedAt:
  30320. v, ok := value.(time.Time)
  30321. if !ok {
  30322. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30323. }
  30324. m.SetDeletedAt(v)
  30325. return nil
  30326. case usagestatisticday.FieldAddtime:
  30327. v, ok := value.(uint64)
  30328. if !ok {
  30329. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30330. }
  30331. m.SetAddtime(v)
  30332. return nil
  30333. case usagestatisticday.FieldType:
  30334. v, ok := value.(int)
  30335. if !ok {
  30336. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30337. }
  30338. m.SetType(v)
  30339. return nil
  30340. case usagestatisticday.FieldBotID:
  30341. v, ok := value.(string)
  30342. if !ok {
  30343. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30344. }
  30345. m.SetBotID(v)
  30346. return nil
  30347. case usagestatisticday.FieldOrganizationID:
  30348. v, ok := value.(uint64)
  30349. if !ok {
  30350. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30351. }
  30352. m.SetOrganizationID(v)
  30353. return nil
  30354. case usagestatisticday.FieldAiResponse:
  30355. v, ok := value.(uint64)
  30356. if !ok {
  30357. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30358. }
  30359. m.SetAiResponse(v)
  30360. return nil
  30361. case usagestatisticday.FieldSopRun:
  30362. v, ok := value.(uint64)
  30363. if !ok {
  30364. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30365. }
  30366. m.SetSopRun(v)
  30367. return nil
  30368. case usagestatisticday.FieldTotalFriend:
  30369. v, ok := value.(uint64)
  30370. if !ok {
  30371. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30372. }
  30373. m.SetTotalFriend(v)
  30374. return nil
  30375. case usagestatisticday.FieldTotalGroup:
  30376. v, ok := value.(uint64)
  30377. if !ok {
  30378. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30379. }
  30380. m.SetTotalGroup(v)
  30381. return nil
  30382. case usagestatisticday.FieldAccountBalance:
  30383. v, ok := value.(uint64)
  30384. if !ok {
  30385. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30386. }
  30387. m.SetAccountBalance(v)
  30388. return nil
  30389. case usagestatisticday.FieldConsumeToken:
  30390. v, ok := value.(uint64)
  30391. if !ok {
  30392. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30393. }
  30394. m.SetConsumeToken(v)
  30395. return nil
  30396. case usagestatisticday.FieldActiveUser:
  30397. v, ok := value.(uint64)
  30398. if !ok {
  30399. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30400. }
  30401. m.SetActiveUser(v)
  30402. return nil
  30403. case usagestatisticday.FieldNewUser:
  30404. v, ok := value.(int64)
  30405. if !ok {
  30406. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30407. }
  30408. m.SetNewUser(v)
  30409. return nil
  30410. case usagestatisticday.FieldLabelDist:
  30411. v, ok := value.([]custom_types.LabelDist)
  30412. if !ok {
  30413. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30414. }
  30415. m.SetLabelDist(v)
  30416. return nil
  30417. }
  30418. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  30419. }
  30420. // AddedFields returns all numeric fields that were incremented/decremented during
  30421. // this mutation.
  30422. func (m *UsageStatisticDayMutation) AddedFields() []string {
  30423. var fields []string
  30424. if m.addstatus != nil {
  30425. fields = append(fields, usagestatisticday.FieldStatus)
  30426. }
  30427. if m.addaddtime != nil {
  30428. fields = append(fields, usagestatisticday.FieldAddtime)
  30429. }
  30430. if m.add_type != nil {
  30431. fields = append(fields, usagestatisticday.FieldType)
  30432. }
  30433. if m.addorganization_id != nil {
  30434. fields = append(fields, usagestatisticday.FieldOrganizationID)
  30435. }
  30436. if m.addai_response != nil {
  30437. fields = append(fields, usagestatisticday.FieldAiResponse)
  30438. }
  30439. if m.addsop_run != nil {
  30440. fields = append(fields, usagestatisticday.FieldSopRun)
  30441. }
  30442. if m.addtotal_friend != nil {
  30443. fields = append(fields, usagestatisticday.FieldTotalFriend)
  30444. }
  30445. if m.addtotal_group != nil {
  30446. fields = append(fields, usagestatisticday.FieldTotalGroup)
  30447. }
  30448. if m.addaccount_balance != nil {
  30449. fields = append(fields, usagestatisticday.FieldAccountBalance)
  30450. }
  30451. if m.addconsume_token != nil {
  30452. fields = append(fields, usagestatisticday.FieldConsumeToken)
  30453. }
  30454. if m.addactive_user != nil {
  30455. fields = append(fields, usagestatisticday.FieldActiveUser)
  30456. }
  30457. if m.addnew_user != nil {
  30458. fields = append(fields, usagestatisticday.FieldNewUser)
  30459. }
  30460. return fields
  30461. }
  30462. // AddedField returns the numeric value that was incremented/decremented on a field
  30463. // with the given name. The second boolean return value indicates that this field
  30464. // was not set, or was not defined in the schema.
  30465. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  30466. switch name {
  30467. case usagestatisticday.FieldStatus:
  30468. return m.AddedStatus()
  30469. case usagestatisticday.FieldAddtime:
  30470. return m.AddedAddtime()
  30471. case usagestatisticday.FieldType:
  30472. return m.AddedType()
  30473. case usagestatisticday.FieldOrganizationID:
  30474. return m.AddedOrganizationID()
  30475. case usagestatisticday.FieldAiResponse:
  30476. return m.AddedAiResponse()
  30477. case usagestatisticday.FieldSopRun:
  30478. return m.AddedSopRun()
  30479. case usagestatisticday.FieldTotalFriend:
  30480. return m.AddedTotalFriend()
  30481. case usagestatisticday.FieldTotalGroup:
  30482. return m.AddedTotalGroup()
  30483. case usagestatisticday.FieldAccountBalance:
  30484. return m.AddedAccountBalance()
  30485. case usagestatisticday.FieldConsumeToken:
  30486. return m.AddedConsumeToken()
  30487. case usagestatisticday.FieldActiveUser:
  30488. return m.AddedActiveUser()
  30489. case usagestatisticday.FieldNewUser:
  30490. return m.AddedNewUser()
  30491. }
  30492. return nil, false
  30493. }
  30494. // AddField adds the value to the field with the given name. It returns an error if
  30495. // the field is not defined in the schema, or if the type mismatched the field
  30496. // type.
  30497. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  30498. switch name {
  30499. case usagestatisticday.FieldStatus:
  30500. v, ok := value.(int8)
  30501. if !ok {
  30502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30503. }
  30504. m.AddStatus(v)
  30505. return nil
  30506. case usagestatisticday.FieldAddtime:
  30507. v, ok := value.(int64)
  30508. if !ok {
  30509. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30510. }
  30511. m.AddAddtime(v)
  30512. return nil
  30513. case usagestatisticday.FieldType:
  30514. v, ok := value.(int)
  30515. if !ok {
  30516. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30517. }
  30518. m.AddType(v)
  30519. return nil
  30520. case usagestatisticday.FieldOrganizationID:
  30521. v, ok := value.(int64)
  30522. if !ok {
  30523. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30524. }
  30525. m.AddOrganizationID(v)
  30526. return nil
  30527. case usagestatisticday.FieldAiResponse:
  30528. v, ok := value.(int64)
  30529. if !ok {
  30530. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30531. }
  30532. m.AddAiResponse(v)
  30533. return nil
  30534. case usagestatisticday.FieldSopRun:
  30535. v, ok := value.(int64)
  30536. if !ok {
  30537. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30538. }
  30539. m.AddSopRun(v)
  30540. return nil
  30541. case usagestatisticday.FieldTotalFriend:
  30542. v, ok := value.(int64)
  30543. if !ok {
  30544. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30545. }
  30546. m.AddTotalFriend(v)
  30547. return nil
  30548. case usagestatisticday.FieldTotalGroup:
  30549. v, ok := value.(int64)
  30550. if !ok {
  30551. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30552. }
  30553. m.AddTotalGroup(v)
  30554. return nil
  30555. case usagestatisticday.FieldAccountBalance:
  30556. v, ok := value.(int64)
  30557. if !ok {
  30558. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30559. }
  30560. m.AddAccountBalance(v)
  30561. return nil
  30562. case usagestatisticday.FieldConsumeToken:
  30563. v, ok := value.(int64)
  30564. if !ok {
  30565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30566. }
  30567. m.AddConsumeToken(v)
  30568. return nil
  30569. case usagestatisticday.FieldActiveUser:
  30570. v, ok := value.(int64)
  30571. if !ok {
  30572. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30573. }
  30574. m.AddActiveUser(v)
  30575. return nil
  30576. case usagestatisticday.FieldNewUser:
  30577. v, ok := value.(int64)
  30578. if !ok {
  30579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30580. }
  30581. m.AddNewUser(v)
  30582. return nil
  30583. }
  30584. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  30585. }
  30586. // ClearedFields returns all nullable fields that were cleared during this
  30587. // mutation.
  30588. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  30589. var fields []string
  30590. if m.FieldCleared(usagestatisticday.FieldStatus) {
  30591. fields = append(fields, usagestatisticday.FieldStatus)
  30592. }
  30593. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  30594. fields = append(fields, usagestatisticday.FieldDeletedAt)
  30595. }
  30596. if m.FieldCleared(usagestatisticday.FieldBotID) {
  30597. fields = append(fields, usagestatisticday.FieldBotID)
  30598. }
  30599. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  30600. fields = append(fields, usagestatisticday.FieldOrganizationID)
  30601. }
  30602. return fields
  30603. }
  30604. // FieldCleared returns a boolean indicating if a field with the given name was
  30605. // cleared in this mutation.
  30606. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  30607. _, ok := m.clearedFields[name]
  30608. return ok
  30609. }
  30610. // ClearField clears the value of the field with the given name. It returns an
  30611. // error if the field is not defined in the schema.
  30612. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  30613. switch name {
  30614. case usagestatisticday.FieldStatus:
  30615. m.ClearStatus()
  30616. return nil
  30617. case usagestatisticday.FieldDeletedAt:
  30618. m.ClearDeletedAt()
  30619. return nil
  30620. case usagestatisticday.FieldBotID:
  30621. m.ClearBotID()
  30622. return nil
  30623. case usagestatisticday.FieldOrganizationID:
  30624. m.ClearOrganizationID()
  30625. return nil
  30626. }
  30627. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  30628. }
  30629. // ResetField resets all changes in the mutation for the field with the given name.
  30630. // It returns an error if the field is not defined in the schema.
  30631. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  30632. switch name {
  30633. case usagestatisticday.FieldCreatedAt:
  30634. m.ResetCreatedAt()
  30635. return nil
  30636. case usagestatisticday.FieldUpdatedAt:
  30637. m.ResetUpdatedAt()
  30638. return nil
  30639. case usagestatisticday.FieldStatus:
  30640. m.ResetStatus()
  30641. return nil
  30642. case usagestatisticday.FieldDeletedAt:
  30643. m.ResetDeletedAt()
  30644. return nil
  30645. case usagestatisticday.FieldAddtime:
  30646. m.ResetAddtime()
  30647. return nil
  30648. case usagestatisticday.FieldType:
  30649. m.ResetType()
  30650. return nil
  30651. case usagestatisticday.FieldBotID:
  30652. m.ResetBotID()
  30653. return nil
  30654. case usagestatisticday.FieldOrganizationID:
  30655. m.ResetOrganizationID()
  30656. return nil
  30657. case usagestatisticday.FieldAiResponse:
  30658. m.ResetAiResponse()
  30659. return nil
  30660. case usagestatisticday.FieldSopRun:
  30661. m.ResetSopRun()
  30662. return nil
  30663. case usagestatisticday.FieldTotalFriend:
  30664. m.ResetTotalFriend()
  30665. return nil
  30666. case usagestatisticday.FieldTotalGroup:
  30667. m.ResetTotalGroup()
  30668. return nil
  30669. case usagestatisticday.FieldAccountBalance:
  30670. m.ResetAccountBalance()
  30671. return nil
  30672. case usagestatisticday.FieldConsumeToken:
  30673. m.ResetConsumeToken()
  30674. return nil
  30675. case usagestatisticday.FieldActiveUser:
  30676. m.ResetActiveUser()
  30677. return nil
  30678. case usagestatisticday.FieldNewUser:
  30679. m.ResetNewUser()
  30680. return nil
  30681. case usagestatisticday.FieldLabelDist:
  30682. m.ResetLabelDist()
  30683. return nil
  30684. }
  30685. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  30686. }
  30687. // AddedEdges returns all edge names that were set/added in this mutation.
  30688. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  30689. edges := make([]string, 0, 0)
  30690. return edges
  30691. }
  30692. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  30693. // name in this mutation.
  30694. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  30695. return nil
  30696. }
  30697. // RemovedEdges returns all edge names that were removed in this mutation.
  30698. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  30699. edges := make([]string, 0, 0)
  30700. return edges
  30701. }
  30702. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  30703. // the given name in this mutation.
  30704. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  30705. return nil
  30706. }
  30707. // ClearedEdges returns all edge names that were cleared in this mutation.
  30708. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  30709. edges := make([]string, 0, 0)
  30710. return edges
  30711. }
  30712. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30713. // was cleared in this mutation.
  30714. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  30715. return false
  30716. }
  30717. // ClearEdge clears the value of the edge with the given name. It returns an error
  30718. // if that edge is not defined in the schema.
  30719. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  30720. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  30721. }
  30722. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30723. // It returns an error if the edge is not defined in the schema.
  30724. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  30725. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  30726. }
  30727. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  30728. type UsageStatisticHourMutation struct {
  30729. config
  30730. op Op
  30731. typ string
  30732. id *uint64
  30733. created_at *time.Time
  30734. updated_at *time.Time
  30735. status *uint8
  30736. addstatus *int8
  30737. deleted_at *time.Time
  30738. addtime *uint64
  30739. addaddtime *int64
  30740. _type *int
  30741. add_type *int
  30742. bot_id *string
  30743. organization_id *uint64
  30744. addorganization_id *int64
  30745. ai_response *uint64
  30746. addai_response *int64
  30747. sop_run *uint64
  30748. addsop_run *int64
  30749. total_friend *uint64
  30750. addtotal_friend *int64
  30751. total_group *uint64
  30752. addtotal_group *int64
  30753. account_balance *uint64
  30754. addaccount_balance *int64
  30755. consume_token *uint64
  30756. addconsume_token *int64
  30757. active_user *uint64
  30758. addactive_user *int64
  30759. new_user *int64
  30760. addnew_user *int64
  30761. label_dist *[]custom_types.LabelDist
  30762. appendlabel_dist []custom_types.LabelDist
  30763. clearedFields map[string]struct{}
  30764. done bool
  30765. oldValue func(context.Context) (*UsageStatisticHour, error)
  30766. predicates []predicate.UsageStatisticHour
  30767. }
  30768. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  30769. // usagestatistichourOption allows management of the mutation configuration using functional options.
  30770. type usagestatistichourOption func(*UsageStatisticHourMutation)
  30771. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  30772. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  30773. m := &UsageStatisticHourMutation{
  30774. config: c,
  30775. op: op,
  30776. typ: TypeUsageStatisticHour,
  30777. clearedFields: make(map[string]struct{}),
  30778. }
  30779. for _, opt := range opts {
  30780. opt(m)
  30781. }
  30782. return m
  30783. }
  30784. // withUsageStatisticHourID sets the ID field of the mutation.
  30785. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  30786. return func(m *UsageStatisticHourMutation) {
  30787. var (
  30788. err error
  30789. once sync.Once
  30790. value *UsageStatisticHour
  30791. )
  30792. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  30793. once.Do(func() {
  30794. if m.done {
  30795. err = errors.New("querying old values post mutation is not allowed")
  30796. } else {
  30797. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  30798. }
  30799. })
  30800. return value, err
  30801. }
  30802. m.id = &id
  30803. }
  30804. }
  30805. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  30806. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  30807. return func(m *UsageStatisticHourMutation) {
  30808. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  30809. return node, nil
  30810. }
  30811. m.id = &node.ID
  30812. }
  30813. }
  30814. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30815. // executed in a transaction (ent.Tx), a transactional client is returned.
  30816. func (m UsageStatisticHourMutation) Client() *Client {
  30817. client := &Client{config: m.config}
  30818. client.init()
  30819. return client
  30820. }
  30821. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30822. // it returns an error otherwise.
  30823. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  30824. if _, ok := m.driver.(*txDriver); !ok {
  30825. return nil, errors.New("ent: mutation is not running in a transaction")
  30826. }
  30827. tx := &Tx{config: m.config}
  30828. tx.init()
  30829. return tx, nil
  30830. }
  30831. // SetID sets the value of the id field. Note that this
  30832. // operation is only accepted on creation of UsageStatisticHour entities.
  30833. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  30834. m.id = &id
  30835. }
  30836. // ID returns the ID value in the mutation. Note that the ID is only available
  30837. // if it was provided to the builder or after it was returned from the database.
  30838. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  30839. if m.id == nil {
  30840. return
  30841. }
  30842. return *m.id, true
  30843. }
  30844. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30845. // That means, if the mutation is applied within a transaction with an isolation level such
  30846. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30847. // or updated by the mutation.
  30848. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  30849. switch {
  30850. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30851. id, exists := m.ID()
  30852. if exists {
  30853. return []uint64{id}, nil
  30854. }
  30855. fallthrough
  30856. case m.op.Is(OpUpdate | OpDelete):
  30857. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  30858. default:
  30859. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30860. }
  30861. }
  30862. // SetCreatedAt sets the "created_at" field.
  30863. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  30864. m.created_at = &t
  30865. }
  30866. // CreatedAt returns the value of the "created_at" field in the mutation.
  30867. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  30868. v := m.created_at
  30869. if v == nil {
  30870. return
  30871. }
  30872. return *v, true
  30873. }
  30874. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  30875. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30876. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30877. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  30878. if !m.op.Is(OpUpdateOne) {
  30879. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  30880. }
  30881. if m.id == nil || m.oldValue == nil {
  30882. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  30883. }
  30884. oldValue, err := m.oldValue(ctx)
  30885. if err != nil {
  30886. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  30887. }
  30888. return oldValue.CreatedAt, nil
  30889. }
  30890. // ResetCreatedAt resets all changes to the "created_at" field.
  30891. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  30892. m.created_at = nil
  30893. }
  30894. // SetUpdatedAt sets the "updated_at" field.
  30895. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  30896. m.updated_at = &t
  30897. }
  30898. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  30899. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  30900. v := m.updated_at
  30901. if v == nil {
  30902. return
  30903. }
  30904. return *v, true
  30905. }
  30906. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  30907. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30908. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30909. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  30910. if !m.op.Is(OpUpdateOne) {
  30911. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  30912. }
  30913. if m.id == nil || m.oldValue == nil {
  30914. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  30915. }
  30916. oldValue, err := m.oldValue(ctx)
  30917. if err != nil {
  30918. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  30919. }
  30920. return oldValue.UpdatedAt, nil
  30921. }
  30922. // ResetUpdatedAt resets all changes to the "updated_at" field.
  30923. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  30924. m.updated_at = nil
  30925. }
  30926. // SetStatus sets the "status" field.
  30927. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  30928. m.status = &u
  30929. m.addstatus = nil
  30930. }
  30931. // Status returns the value of the "status" field in the mutation.
  30932. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  30933. v := m.status
  30934. if v == nil {
  30935. return
  30936. }
  30937. return *v, true
  30938. }
  30939. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  30940. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30941. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30942. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  30943. if !m.op.Is(OpUpdateOne) {
  30944. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  30945. }
  30946. if m.id == nil || m.oldValue == nil {
  30947. return v, errors.New("OldStatus requires an ID field in the mutation")
  30948. }
  30949. oldValue, err := m.oldValue(ctx)
  30950. if err != nil {
  30951. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  30952. }
  30953. return oldValue.Status, nil
  30954. }
  30955. // AddStatus adds u to the "status" field.
  30956. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  30957. if m.addstatus != nil {
  30958. *m.addstatus += u
  30959. } else {
  30960. m.addstatus = &u
  30961. }
  30962. }
  30963. // AddedStatus returns the value that was added to the "status" field in this mutation.
  30964. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  30965. v := m.addstatus
  30966. if v == nil {
  30967. return
  30968. }
  30969. return *v, true
  30970. }
  30971. // ClearStatus clears the value of the "status" field.
  30972. func (m *UsageStatisticHourMutation) ClearStatus() {
  30973. m.status = nil
  30974. m.addstatus = nil
  30975. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  30976. }
  30977. // StatusCleared returns if the "status" field was cleared in this mutation.
  30978. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  30979. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  30980. return ok
  30981. }
  30982. // ResetStatus resets all changes to the "status" field.
  30983. func (m *UsageStatisticHourMutation) ResetStatus() {
  30984. m.status = nil
  30985. m.addstatus = nil
  30986. delete(m.clearedFields, usagestatistichour.FieldStatus)
  30987. }
  30988. // SetDeletedAt sets the "deleted_at" field.
  30989. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  30990. m.deleted_at = &t
  30991. }
  30992. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  30993. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  30994. v := m.deleted_at
  30995. if v == nil {
  30996. return
  30997. }
  30998. return *v, true
  30999. }
  31000. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  31001. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31002. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31003. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  31004. if !m.op.Is(OpUpdateOne) {
  31005. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  31006. }
  31007. if m.id == nil || m.oldValue == nil {
  31008. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  31009. }
  31010. oldValue, err := m.oldValue(ctx)
  31011. if err != nil {
  31012. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  31013. }
  31014. return oldValue.DeletedAt, nil
  31015. }
  31016. // ClearDeletedAt clears the value of the "deleted_at" field.
  31017. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  31018. m.deleted_at = nil
  31019. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  31020. }
  31021. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  31022. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  31023. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  31024. return ok
  31025. }
  31026. // ResetDeletedAt resets all changes to the "deleted_at" field.
  31027. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  31028. m.deleted_at = nil
  31029. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  31030. }
  31031. // SetAddtime sets the "addtime" field.
  31032. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  31033. m.addtime = &u
  31034. m.addaddtime = nil
  31035. }
  31036. // Addtime returns the value of the "addtime" field in the mutation.
  31037. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  31038. v := m.addtime
  31039. if v == nil {
  31040. return
  31041. }
  31042. return *v, true
  31043. }
  31044. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  31045. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31046. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31047. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  31048. if !m.op.Is(OpUpdateOne) {
  31049. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  31050. }
  31051. if m.id == nil || m.oldValue == nil {
  31052. return v, errors.New("OldAddtime requires an ID field in the mutation")
  31053. }
  31054. oldValue, err := m.oldValue(ctx)
  31055. if err != nil {
  31056. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  31057. }
  31058. return oldValue.Addtime, nil
  31059. }
  31060. // AddAddtime adds u to the "addtime" field.
  31061. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  31062. if m.addaddtime != nil {
  31063. *m.addaddtime += u
  31064. } else {
  31065. m.addaddtime = &u
  31066. }
  31067. }
  31068. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  31069. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  31070. v := m.addaddtime
  31071. if v == nil {
  31072. return
  31073. }
  31074. return *v, true
  31075. }
  31076. // ResetAddtime resets all changes to the "addtime" field.
  31077. func (m *UsageStatisticHourMutation) ResetAddtime() {
  31078. m.addtime = nil
  31079. m.addaddtime = nil
  31080. }
  31081. // SetType sets the "type" field.
  31082. func (m *UsageStatisticHourMutation) SetType(i int) {
  31083. m._type = &i
  31084. m.add_type = nil
  31085. }
  31086. // GetType returns the value of the "type" field in the mutation.
  31087. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  31088. v := m._type
  31089. if v == nil {
  31090. return
  31091. }
  31092. return *v, true
  31093. }
  31094. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  31095. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31096. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31097. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  31098. if !m.op.Is(OpUpdateOne) {
  31099. return v, errors.New("OldType is only allowed on UpdateOne operations")
  31100. }
  31101. if m.id == nil || m.oldValue == nil {
  31102. return v, errors.New("OldType requires an ID field in the mutation")
  31103. }
  31104. oldValue, err := m.oldValue(ctx)
  31105. if err != nil {
  31106. return v, fmt.Errorf("querying old value for OldType: %w", err)
  31107. }
  31108. return oldValue.Type, nil
  31109. }
  31110. // AddType adds i to the "type" field.
  31111. func (m *UsageStatisticHourMutation) AddType(i int) {
  31112. if m.add_type != nil {
  31113. *m.add_type += i
  31114. } else {
  31115. m.add_type = &i
  31116. }
  31117. }
  31118. // AddedType returns the value that was added to the "type" field in this mutation.
  31119. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  31120. v := m.add_type
  31121. if v == nil {
  31122. return
  31123. }
  31124. return *v, true
  31125. }
  31126. // ResetType resets all changes to the "type" field.
  31127. func (m *UsageStatisticHourMutation) ResetType() {
  31128. m._type = nil
  31129. m.add_type = nil
  31130. }
  31131. // SetBotID sets the "bot_id" field.
  31132. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  31133. m.bot_id = &s
  31134. }
  31135. // BotID returns the value of the "bot_id" field in the mutation.
  31136. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  31137. v := m.bot_id
  31138. if v == nil {
  31139. return
  31140. }
  31141. return *v, true
  31142. }
  31143. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  31144. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31145. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31146. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  31147. if !m.op.Is(OpUpdateOne) {
  31148. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  31149. }
  31150. if m.id == nil || m.oldValue == nil {
  31151. return v, errors.New("OldBotID requires an ID field in the mutation")
  31152. }
  31153. oldValue, err := m.oldValue(ctx)
  31154. if err != nil {
  31155. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  31156. }
  31157. return oldValue.BotID, nil
  31158. }
  31159. // ClearBotID clears the value of the "bot_id" field.
  31160. func (m *UsageStatisticHourMutation) ClearBotID() {
  31161. m.bot_id = nil
  31162. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  31163. }
  31164. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  31165. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  31166. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  31167. return ok
  31168. }
  31169. // ResetBotID resets all changes to the "bot_id" field.
  31170. func (m *UsageStatisticHourMutation) ResetBotID() {
  31171. m.bot_id = nil
  31172. delete(m.clearedFields, usagestatistichour.FieldBotID)
  31173. }
  31174. // SetOrganizationID sets the "organization_id" field.
  31175. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  31176. m.organization_id = &u
  31177. m.addorganization_id = nil
  31178. }
  31179. // OrganizationID returns the value of the "organization_id" field in the mutation.
  31180. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  31181. v := m.organization_id
  31182. if v == nil {
  31183. return
  31184. }
  31185. return *v, true
  31186. }
  31187. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  31188. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31189. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31190. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  31191. if !m.op.Is(OpUpdateOne) {
  31192. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  31193. }
  31194. if m.id == nil || m.oldValue == nil {
  31195. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  31196. }
  31197. oldValue, err := m.oldValue(ctx)
  31198. if err != nil {
  31199. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  31200. }
  31201. return oldValue.OrganizationID, nil
  31202. }
  31203. // AddOrganizationID adds u to the "organization_id" field.
  31204. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  31205. if m.addorganization_id != nil {
  31206. *m.addorganization_id += u
  31207. } else {
  31208. m.addorganization_id = &u
  31209. }
  31210. }
  31211. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  31212. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  31213. v := m.addorganization_id
  31214. if v == nil {
  31215. return
  31216. }
  31217. return *v, true
  31218. }
  31219. // ClearOrganizationID clears the value of the "organization_id" field.
  31220. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  31221. m.organization_id = nil
  31222. m.addorganization_id = nil
  31223. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  31224. }
  31225. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  31226. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  31227. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  31228. return ok
  31229. }
  31230. // ResetOrganizationID resets all changes to the "organization_id" field.
  31231. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  31232. m.organization_id = nil
  31233. m.addorganization_id = nil
  31234. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  31235. }
  31236. // SetAiResponse sets the "ai_response" field.
  31237. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  31238. m.ai_response = &u
  31239. m.addai_response = nil
  31240. }
  31241. // AiResponse returns the value of the "ai_response" field in the mutation.
  31242. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  31243. v := m.ai_response
  31244. if v == nil {
  31245. return
  31246. }
  31247. return *v, true
  31248. }
  31249. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  31250. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31251. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31252. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  31253. if !m.op.Is(OpUpdateOne) {
  31254. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  31255. }
  31256. if m.id == nil || m.oldValue == nil {
  31257. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  31258. }
  31259. oldValue, err := m.oldValue(ctx)
  31260. if err != nil {
  31261. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  31262. }
  31263. return oldValue.AiResponse, nil
  31264. }
  31265. // AddAiResponse adds u to the "ai_response" field.
  31266. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  31267. if m.addai_response != nil {
  31268. *m.addai_response += u
  31269. } else {
  31270. m.addai_response = &u
  31271. }
  31272. }
  31273. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  31274. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  31275. v := m.addai_response
  31276. if v == nil {
  31277. return
  31278. }
  31279. return *v, true
  31280. }
  31281. // ResetAiResponse resets all changes to the "ai_response" field.
  31282. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  31283. m.ai_response = nil
  31284. m.addai_response = nil
  31285. }
  31286. // SetSopRun sets the "sop_run" field.
  31287. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  31288. m.sop_run = &u
  31289. m.addsop_run = nil
  31290. }
  31291. // SopRun returns the value of the "sop_run" field in the mutation.
  31292. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  31293. v := m.sop_run
  31294. if v == nil {
  31295. return
  31296. }
  31297. return *v, true
  31298. }
  31299. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  31300. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31301. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31302. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  31303. if !m.op.Is(OpUpdateOne) {
  31304. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  31305. }
  31306. if m.id == nil || m.oldValue == nil {
  31307. return v, errors.New("OldSopRun requires an ID field in the mutation")
  31308. }
  31309. oldValue, err := m.oldValue(ctx)
  31310. if err != nil {
  31311. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  31312. }
  31313. return oldValue.SopRun, nil
  31314. }
  31315. // AddSopRun adds u to the "sop_run" field.
  31316. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  31317. if m.addsop_run != nil {
  31318. *m.addsop_run += u
  31319. } else {
  31320. m.addsop_run = &u
  31321. }
  31322. }
  31323. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  31324. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  31325. v := m.addsop_run
  31326. if v == nil {
  31327. return
  31328. }
  31329. return *v, true
  31330. }
  31331. // ResetSopRun resets all changes to the "sop_run" field.
  31332. func (m *UsageStatisticHourMutation) ResetSopRun() {
  31333. m.sop_run = nil
  31334. m.addsop_run = nil
  31335. }
  31336. // SetTotalFriend sets the "total_friend" field.
  31337. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  31338. m.total_friend = &u
  31339. m.addtotal_friend = nil
  31340. }
  31341. // TotalFriend returns the value of the "total_friend" field in the mutation.
  31342. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  31343. v := m.total_friend
  31344. if v == nil {
  31345. return
  31346. }
  31347. return *v, true
  31348. }
  31349. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  31350. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31351. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31352. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  31353. if !m.op.Is(OpUpdateOne) {
  31354. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  31355. }
  31356. if m.id == nil || m.oldValue == nil {
  31357. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  31358. }
  31359. oldValue, err := m.oldValue(ctx)
  31360. if err != nil {
  31361. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  31362. }
  31363. return oldValue.TotalFriend, nil
  31364. }
  31365. // AddTotalFriend adds u to the "total_friend" field.
  31366. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  31367. if m.addtotal_friend != nil {
  31368. *m.addtotal_friend += u
  31369. } else {
  31370. m.addtotal_friend = &u
  31371. }
  31372. }
  31373. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  31374. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  31375. v := m.addtotal_friend
  31376. if v == nil {
  31377. return
  31378. }
  31379. return *v, true
  31380. }
  31381. // ResetTotalFriend resets all changes to the "total_friend" field.
  31382. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  31383. m.total_friend = nil
  31384. m.addtotal_friend = nil
  31385. }
  31386. // SetTotalGroup sets the "total_group" field.
  31387. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  31388. m.total_group = &u
  31389. m.addtotal_group = nil
  31390. }
  31391. // TotalGroup returns the value of the "total_group" field in the mutation.
  31392. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  31393. v := m.total_group
  31394. if v == nil {
  31395. return
  31396. }
  31397. return *v, true
  31398. }
  31399. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  31400. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31402. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  31403. if !m.op.Is(OpUpdateOne) {
  31404. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  31405. }
  31406. if m.id == nil || m.oldValue == nil {
  31407. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  31408. }
  31409. oldValue, err := m.oldValue(ctx)
  31410. if err != nil {
  31411. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  31412. }
  31413. return oldValue.TotalGroup, nil
  31414. }
  31415. // AddTotalGroup adds u to the "total_group" field.
  31416. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  31417. if m.addtotal_group != nil {
  31418. *m.addtotal_group += u
  31419. } else {
  31420. m.addtotal_group = &u
  31421. }
  31422. }
  31423. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  31424. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  31425. v := m.addtotal_group
  31426. if v == nil {
  31427. return
  31428. }
  31429. return *v, true
  31430. }
  31431. // ResetTotalGroup resets all changes to the "total_group" field.
  31432. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  31433. m.total_group = nil
  31434. m.addtotal_group = nil
  31435. }
  31436. // SetAccountBalance sets the "account_balance" field.
  31437. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  31438. m.account_balance = &u
  31439. m.addaccount_balance = nil
  31440. }
  31441. // AccountBalance returns the value of the "account_balance" field in the mutation.
  31442. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  31443. v := m.account_balance
  31444. if v == nil {
  31445. return
  31446. }
  31447. return *v, true
  31448. }
  31449. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  31450. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31451. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31452. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  31453. if !m.op.Is(OpUpdateOne) {
  31454. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  31455. }
  31456. if m.id == nil || m.oldValue == nil {
  31457. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  31458. }
  31459. oldValue, err := m.oldValue(ctx)
  31460. if err != nil {
  31461. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  31462. }
  31463. return oldValue.AccountBalance, nil
  31464. }
  31465. // AddAccountBalance adds u to the "account_balance" field.
  31466. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  31467. if m.addaccount_balance != nil {
  31468. *m.addaccount_balance += u
  31469. } else {
  31470. m.addaccount_balance = &u
  31471. }
  31472. }
  31473. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  31474. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  31475. v := m.addaccount_balance
  31476. if v == nil {
  31477. return
  31478. }
  31479. return *v, true
  31480. }
  31481. // ResetAccountBalance resets all changes to the "account_balance" field.
  31482. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  31483. m.account_balance = nil
  31484. m.addaccount_balance = nil
  31485. }
  31486. // SetConsumeToken sets the "consume_token" field.
  31487. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  31488. m.consume_token = &u
  31489. m.addconsume_token = nil
  31490. }
  31491. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  31492. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  31493. v := m.consume_token
  31494. if v == nil {
  31495. return
  31496. }
  31497. return *v, true
  31498. }
  31499. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  31500. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31501. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31502. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  31503. if !m.op.Is(OpUpdateOne) {
  31504. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  31505. }
  31506. if m.id == nil || m.oldValue == nil {
  31507. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  31508. }
  31509. oldValue, err := m.oldValue(ctx)
  31510. if err != nil {
  31511. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  31512. }
  31513. return oldValue.ConsumeToken, nil
  31514. }
  31515. // AddConsumeToken adds u to the "consume_token" field.
  31516. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  31517. if m.addconsume_token != nil {
  31518. *m.addconsume_token += u
  31519. } else {
  31520. m.addconsume_token = &u
  31521. }
  31522. }
  31523. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  31524. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  31525. v := m.addconsume_token
  31526. if v == nil {
  31527. return
  31528. }
  31529. return *v, true
  31530. }
  31531. // ResetConsumeToken resets all changes to the "consume_token" field.
  31532. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  31533. m.consume_token = nil
  31534. m.addconsume_token = nil
  31535. }
  31536. // SetActiveUser sets the "active_user" field.
  31537. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  31538. m.active_user = &u
  31539. m.addactive_user = nil
  31540. }
  31541. // ActiveUser returns the value of the "active_user" field in the mutation.
  31542. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  31543. v := m.active_user
  31544. if v == nil {
  31545. return
  31546. }
  31547. return *v, true
  31548. }
  31549. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  31550. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31551. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31552. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  31553. if !m.op.Is(OpUpdateOne) {
  31554. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  31555. }
  31556. if m.id == nil || m.oldValue == nil {
  31557. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  31558. }
  31559. oldValue, err := m.oldValue(ctx)
  31560. if err != nil {
  31561. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  31562. }
  31563. return oldValue.ActiveUser, nil
  31564. }
  31565. // AddActiveUser adds u to the "active_user" field.
  31566. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  31567. if m.addactive_user != nil {
  31568. *m.addactive_user += u
  31569. } else {
  31570. m.addactive_user = &u
  31571. }
  31572. }
  31573. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  31574. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  31575. v := m.addactive_user
  31576. if v == nil {
  31577. return
  31578. }
  31579. return *v, true
  31580. }
  31581. // ResetActiveUser resets all changes to the "active_user" field.
  31582. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  31583. m.active_user = nil
  31584. m.addactive_user = nil
  31585. }
  31586. // SetNewUser sets the "new_user" field.
  31587. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  31588. m.new_user = &i
  31589. m.addnew_user = nil
  31590. }
  31591. // NewUser returns the value of the "new_user" field in the mutation.
  31592. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  31593. v := m.new_user
  31594. if v == nil {
  31595. return
  31596. }
  31597. return *v, true
  31598. }
  31599. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  31600. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31601. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31602. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  31603. if !m.op.Is(OpUpdateOne) {
  31604. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  31605. }
  31606. if m.id == nil || m.oldValue == nil {
  31607. return v, errors.New("OldNewUser requires an ID field in the mutation")
  31608. }
  31609. oldValue, err := m.oldValue(ctx)
  31610. if err != nil {
  31611. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  31612. }
  31613. return oldValue.NewUser, nil
  31614. }
  31615. // AddNewUser adds i to the "new_user" field.
  31616. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  31617. if m.addnew_user != nil {
  31618. *m.addnew_user += i
  31619. } else {
  31620. m.addnew_user = &i
  31621. }
  31622. }
  31623. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  31624. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  31625. v := m.addnew_user
  31626. if v == nil {
  31627. return
  31628. }
  31629. return *v, true
  31630. }
  31631. // ResetNewUser resets all changes to the "new_user" field.
  31632. func (m *UsageStatisticHourMutation) ResetNewUser() {
  31633. m.new_user = nil
  31634. m.addnew_user = nil
  31635. }
  31636. // SetLabelDist sets the "label_dist" field.
  31637. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  31638. m.label_dist = &ctd
  31639. m.appendlabel_dist = nil
  31640. }
  31641. // LabelDist returns the value of the "label_dist" field in the mutation.
  31642. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  31643. v := m.label_dist
  31644. if v == nil {
  31645. return
  31646. }
  31647. return *v, true
  31648. }
  31649. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  31650. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31652. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  31653. if !m.op.Is(OpUpdateOne) {
  31654. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  31655. }
  31656. if m.id == nil || m.oldValue == nil {
  31657. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  31658. }
  31659. oldValue, err := m.oldValue(ctx)
  31660. if err != nil {
  31661. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  31662. }
  31663. return oldValue.LabelDist, nil
  31664. }
  31665. // AppendLabelDist adds ctd to the "label_dist" field.
  31666. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  31667. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  31668. }
  31669. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  31670. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  31671. if len(m.appendlabel_dist) == 0 {
  31672. return nil, false
  31673. }
  31674. return m.appendlabel_dist, true
  31675. }
  31676. // ResetLabelDist resets all changes to the "label_dist" field.
  31677. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  31678. m.label_dist = nil
  31679. m.appendlabel_dist = nil
  31680. }
  31681. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  31682. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  31683. m.predicates = append(m.predicates, ps...)
  31684. }
  31685. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  31686. // users can use type-assertion to append predicates that do not depend on any generated package.
  31687. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  31688. p := make([]predicate.UsageStatisticHour, len(ps))
  31689. for i := range ps {
  31690. p[i] = ps[i]
  31691. }
  31692. m.Where(p...)
  31693. }
  31694. // Op returns the operation name.
  31695. func (m *UsageStatisticHourMutation) Op() Op {
  31696. return m.op
  31697. }
  31698. // SetOp allows setting the mutation operation.
  31699. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  31700. m.op = op
  31701. }
  31702. // Type returns the node type of this mutation (UsageStatisticHour).
  31703. func (m *UsageStatisticHourMutation) Type() string {
  31704. return m.typ
  31705. }
  31706. // Fields returns all fields that were changed during this mutation. Note that in
  31707. // order to get all numeric fields that were incremented/decremented, call
  31708. // AddedFields().
  31709. func (m *UsageStatisticHourMutation) Fields() []string {
  31710. fields := make([]string, 0, 17)
  31711. if m.created_at != nil {
  31712. fields = append(fields, usagestatistichour.FieldCreatedAt)
  31713. }
  31714. if m.updated_at != nil {
  31715. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  31716. }
  31717. if m.status != nil {
  31718. fields = append(fields, usagestatistichour.FieldStatus)
  31719. }
  31720. if m.deleted_at != nil {
  31721. fields = append(fields, usagestatistichour.FieldDeletedAt)
  31722. }
  31723. if m.addtime != nil {
  31724. fields = append(fields, usagestatistichour.FieldAddtime)
  31725. }
  31726. if m._type != nil {
  31727. fields = append(fields, usagestatistichour.FieldType)
  31728. }
  31729. if m.bot_id != nil {
  31730. fields = append(fields, usagestatistichour.FieldBotID)
  31731. }
  31732. if m.organization_id != nil {
  31733. fields = append(fields, usagestatistichour.FieldOrganizationID)
  31734. }
  31735. if m.ai_response != nil {
  31736. fields = append(fields, usagestatistichour.FieldAiResponse)
  31737. }
  31738. if m.sop_run != nil {
  31739. fields = append(fields, usagestatistichour.FieldSopRun)
  31740. }
  31741. if m.total_friend != nil {
  31742. fields = append(fields, usagestatistichour.FieldTotalFriend)
  31743. }
  31744. if m.total_group != nil {
  31745. fields = append(fields, usagestatistichour.FieldTotalGroup)
  31746. }
  31747. if m.account_balance != nil {
  31748. fields = append(fields, usagestatistichour.FieldAccountBalance)
  31749. }
  31750. if m.consume_token != nil {
  31751. fields = append(fields, usagestatistichour.FieldConsumeToken)
  31752. }
  31753. if m.active_user != nil {
  31754. fields = append(fields, usagestatistichour.FieldActiveUser)
  31755. }
  31756. if m.new_user != nil {
  31757. fields = append(fields, usagestatistichour.FieldNewUser)
  31758. }
  31759. if m.label_dist != nil {
  31760. fields = append(fields, usagestatistichour.FieldLabelDist)
  31761. }
  31762. return fields
  31763. }
  31764. // Field returns the value of a field with the given name. The second boolean
  31765. // return value indicates that this field was not set, or was not defined in the
  31766. // schema.
  31767. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  31768. switch name {
  31769. case usagestatistichour.FieldCreatedAt:
  31770. return m.CreatedAt()
  31771. case usagestatistichour.FieldUpdatedAt:
  31772. return m.UpdatedAt()
  31773. case usagestatistichour.FieldStatus:
  31774. return m.Status()
  31775. case usagestatistichour.FieldDeletedAt:
  31776. return m.DeletedAt()
  31777. case usagestatistichour.FieldAddtime:
  31778. return m.Addtime()
  31779. case usagestatistichour.FieldType:
  31780. return m.GetType()
  31781. case usagestatistichour.FieldBotID:
  31782. return m.BotID()
  31783. case usagestatistichour.FieldOrganizationID:
  31784. return m.OrganizationID()
  31785. case usagestatistichour.FieldAiResponse:
  31786. return m.AiResponse()
  31787. case usagestatistichour.FieldSopRun:
  31788. return m.SopRun()
  31789. case usagestatistichour.FieldTotalFriend:
  31790. return m.TotalFriend()
  31791. case usagestatistichour.FieldTotalGroup:
  31792. return m.TotalGroup()
  31793. case usagestatistichour.FieldAccountBalance:
  31794. return m.AccountBalance()
  31795. case usagestatistichour.FieldConsumeToken:
  31796. return m.ConsumeToken()
  31797. case usagestatistichour.FieldActiveUser:
  31798. return m.ActiveUser()
  31799. case usagestatistichour.FieldNewUser:
  31800. return m.NewUser()
  31801. case usagestatistichour.FieldLabelDist:
  31802. return m.LabelDist()
  31803. }
  31804. return nil, false
  31805. }
  31806. // OldField returns the old value of the field from the database. An error is
  31807. // returned if the mutation operation is not UpdateOne, or the query to the
  31808. // database failed.
  31809. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  31810. switch name {
  31811. case usagestatistichour.FieldCreatedAt:
  31812. return m.OldCreatedAt(ctx)
  31813. case usagestatistichour.FieldUpdatedAt:
  31814. return m.OldUpdatedAt(ctx)
  31815. case usagestatistichour.FieldStatus:
  31816. return m.OldStatus(ctx)
  31817. case usagestatistichour.FieldDeletedAt:
  31818. return m.OldDeletedAt(ctx)
  31819. case usagestatistichour.FieldAddtime:
  31820. return m.OldAddtime(ctx)
  31821. case usagestatistichour.FieldType:
  31822. return m.OldType(ctx)
  31823. case usagestatistichour.FieldBotID:
  31824. return m.OldBotID(ctx)
  31825. case usagestatistichour.FieldOrganizationID:
  31826. return m.OldOrganizationID(ctx)
  31827. case usagestatistichour.FieldAiResponse:
  31828. return m.OldAiResponse(ctx)
  31829. case usagestatistichour.FieldSopRun:
  31830. return m.OldSopRun(ctx)
  31831. case usagestatistichour.FieldTotalFriend:
  31832. return m.OldTotalFriend(ctx)
  31833. case usagestatistichour.FieldTotalGroup:
  31834. return m.OldTotalGroup(ctx)
  31835. case usagestatistichour.FieldAccountBalance:
  31836. return m.OldAccountBalance(ctx)
  31837. case usagestatistichour.FieldConsumeToken:
  31838. return m.OldConsumeToken(ctx)
  31839. case usagestatistichour.FieldActiveUser:
  31840. return m.OldActiveUser(ctx)
  31841. case usagestatistichour.FieldNewUser:
  31842. return m.OldNewUser(ctx)
  31843. case usagestatistichour.FieldLabelDist:
  31844. return m.OldLabelDist(ctx)
  31845. }
  31846. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  31847. }
  31848. // SetField sets the value of a field with the given name. It returns an error if
  31849. // the field is not defined in the schema, or if the type mismatched the field
  31850. // type.
  31851. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  31852. switch name {
  31853. case usagestatistichour.FieldCreatedAt:
  31854. v, ok := value.(time.Time)
  31855. if !ok {
  31856. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31857. }
  31858. m.SetCreatedAt(v)
  31859. return nil
  31860. case usagestatistichour.FieldUpdatedAt:
  31861. v, ok := value.(time.Time)
  31862. if !ok {
  31863. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31864. }
  31865. m.SetUpdatedAt(v)
  31866. return nil
  31867. case usagestatistichour.FieldStatus:
  31868. v, ok := value.(uint8)
  31869. if !ok {
  31870. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31871. }
  31872. m.SetStatus(v)
  31873. return nil
  31874. case usagestatistichour.FieldDeletedAt:
  31875. v, ok := value.(time.Time)
  31876. if !ok {
  31877. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31878. }
  31879. m.SetDeletedAt(v)
  31880. return nil
  31881. case usagestatistichour.FieldAddtime:
  31882. v, ok := value.(uint64)
  31883. if !ok {
  31884. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31885. }
  31886. m.SetAddtime(v)
  31887. return nil
  31888. case usagestatistichour.FieldType:
  31889. v, ok := value.(int)
  31890. if !ok {
  31891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31892. }
  31893. m.SetType(v)
  31894. return nil
  31895. case usagestatistichour.FieldBotID:
  31896. v, ok := value.(string)
  31897. if !ok {
  31898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31899. }
  31900. m.SetBotID(v)
  31901. return nil
  31902. case usagestatistichour.FieldOrganizationID:
  31903. v, ok := value.(uint64)
  31904. if !ok {
  31905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31906. }
  31907. m.SetOrganizationID(v)
  31908. return nil
  31909. case usagestatistichour.FieldAiResponse:
  31910. v, ok := value.(uint64)
  31911. if !ok {
  31912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31913. }
  31914. m.SetAiResponse(v)
  31915. return nil
  31916. case usagestatistichour.FieldSopRun:
  31917. v, ok := value.(uint64)
  31918. if !ok {
  31919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31920. }
  31921. m.SetSopRun(v)
  31922. return nil
  31923. case usagestatistichour.FieldTotalFriend:
  31924. v, ok := value.(uint64)
  31925. if !ok {
  31926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31927. }
  31928. m.SetTotalFriend(v)
  31929. return nil
  31930. case usagestatistichour.FieldTotalGroup:
  31931. v, ok := value.(uint64)
  31932. if !ok {
  31933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31934. }
  31935. m.SetTotalGroup(v)
  31936. return nil
  31937. case usagestatistichour.FieldAccountBalance:
  31938. v, ok := value.(uint64)
  31939. if !ok {
  31940. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31941. }
  31942. m.SetAccountBalance(v)
  31943. return nil
  31944. case usagestatistichour.FieldConsumeToken:
  31945. v, ok := value.(uint64)
  31946. if !ok {
  31947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31948. }
  31949. m.SetConsumeToken(v)
  31950. return nil
  31951. case usagestatistichour.FieldActiveUser:
  31952. v, ok := value.(uint64)
  31953. if !ok {
  31954. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31955. }
  31956. m.SetActiveUser(v)
  31957. return nil
  31958. case usagestatistichour.FieldNewUser:
  31959. v, ok := value.(int64)
  31960. if !ok {
  31961. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31962. }
  31963. m.SetNewUser(v)
  31964. return nil
  31965. case usagestatistichour.FieldLabelDist:
  31966. v, ok := value.([]custom_types.LabelDist)
  31967. if !ok {
  31968. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31969. }
  31970. m.SetLabelDist(v)
  31971. return nil
  31972. }
  31973. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  31974. }
  31975. // AddedFields returns all numeric fields that were incremented/decremented during
  31976. // this mutation.
  31977. func (m *UsageStatisticHourMutation) AddedFields() []string {
  31978. var fields []string
  31979. if m.addstatus != nil {
  31980. fields = append(fields, usagestatistichour.FieldStatus)
  31981. }
  31982. if m.addaddtime != nil {
  31983. fields = append(fields, usagestatistichour.FieldAddtime)
  31984. }
  31985. if m.add_type != nil {
  31986. fields = append(fields, usagestatistichour.FieldType)
  31987. }
  31988. if m.addorganization_id != nil {
  31989. fields = append(fields, usagestatistichour.FieldOrganizationID)
  31990. }
  31991. if m.addai_response != nil {
  31992. fields = append(fields, usagestatistichour.FieldAiResponse)
  31993. }
  31994. if m.addsop_run != nil {
  31995. fields = append(fields, usagestatistichour.FieldSopRun)
  31996. }
  31997. if m.addtotal_friend != nil {
  31998. fields = append(fields, usagestatistichour.FieldTotalFriend)
  31999. }
  32000. if m.addtotal_group != nil {
  32001. fields = append(fields, usagestatistichour.FieldTotalGroup)
  32002. }
  32003. if m.addaccount_balance != nil {
  32004. fields = append(fields, usagestatistichour.FieldAccountBalance)
  32005. }
  32006. if m.addconsume_token != nil {
  32007. fields = append(fields, usagestatistichour.FieldConsumeToken)
  32008. }
  32009. if m.addactive_user != nil {
  32010. fields = append(fields, usagestatistichour.FieldActiveUser)
  32011. }
  32012. if m.addnew_user != nil {
  32013. fields = append(fields, usagestatistichour.FieldNewUser)
  32014. }
  32015. return fields
  32016. }
  32017. // AddedField returns the numeric value that was incremented/decremented on a field
  32018. // with the given name. The second boolean return value indicates that this field
  32019. // was not set, or was not defined in the schema.
  32020. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  32021. switch name {
  32022. case usagestatistichour.FieldStatus:
  32023. return m.AddedStatus()
  32024. case usagestatistichour.FieldAddtime:
  32025. return m.AddedAddtime()
  32026. case usagestatistichour.FieldType:
  32027. return m.AddedType()
  32028. case usagestatistichour.FieldOrganizationID:
  32029. return m.AddedOrganizationID()
  32030. case usagestatistichour.FieldAiResponse:
  32031. return m.AddedAiResponse()
  32032. case usagestatistichour.FieldSopRun:
  32033. return m.AddedSopRun()
  32034. case usagestatistichour.FieldTotalFriend:
  32035. return m.AddedTotalFriend()
  32036. case usagestatistichour.FieldTotalGroup:
  32037. return m.AddedTotalGroup()
  32038. case usagestatistichour.FieldAccountBalance:
  32039. return m.AddedAccountBalance()
  32040. case usagestatistichour.FieldConsumeToken:
  32041. return m.AddedConsumeToken()
  32042. case usagestatistichour.FieldActiveUser:
  32043. return m.AddedActiveUser()
  32044. case usagestatistichour.FieldNewUser:
  32045. return m.AddedNewUser()
  32046. }
  32047. return nil, false
  32048. }
  32049. // AddField adds the value to the field with the given name. It returns an error if
  32050. // the field is not defined in the schema, or if the type mismatched the field
  32051. // type.
  32052. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  32053. switch name {
  32054. case usagestatistichour.FieldStatus:
  32055. v, ok := value.(int8)
  32056. if !ok {
  32057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32058. }
  32059. m.AddStatus(v)
  32060. return nil
  32061. case usagestatistichour.FieldAddtime:
  32062. v, ok := value.(int64)
  32063. if !ok {
  32064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32065. }
  32066. m.AddAddtime(v)
  32067. return nil
  32068. case usagestatistichour.FieldType:
  32069. v, ok := value.(int)
  32070. if !ok {
  32071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32072. }
  32073. m.AddType(v)
  32074. return nil
  32075. case usagestatistichour.FieldOrganizationID:
  32076. v, ok := value.(int64)
  32077. if !ok {
  32078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32079. }
  32080. m.AddOrganizationID(v)
  32081. return nil
  32082. case usagestatistichour.FieldAiResponse:
  32083. v, ok := value.(int64)
  32084. if !ok {
  32085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32086. }
  32087. m.AddAiResponse(v)
  32088. return nil
  32089. case usagestatistichour.FieldSopRun:
  32090. v, ok := value.(int64)
  32091. if !ok {
  32092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32093. }
  32094. m.AddSopRun(v)
  32095. return nil
  32096. case usagestatistichour.FieldTotalFriend:
  32097. v, ok := value.(int64)
  32098. if !ok {
  32099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32100. }
  32101. m.AddTotalFriend(v)
  32102. return nil
  32103. case usagestatistichour.FieldTotalGroup:
  32104. v, ok := value.(int64)
  32105. if !ok {
  32106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32107. }
  32108. m.AddTotalGroup(v)
  32109. return nil
  32110. case usagestatistichour.FieldAccountBalance:
  32111. v, ok := value.(int64)
  32112. if !ok {
  32113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32114. }
  32115. m.AddAccountBalance(v)
  32116. return nil
  32117. case usagestatistichour.FieldConsumeToken:
  32118. v, ok := value.(int64)
  32119. if !ok {
  32120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32121. }
  32122. m.AddConsumeToken(v)
  32123. return nil
  32124. case usagestatistichour.FieldActiveUser:
  32125. v, ok := value.(int64)
  32126. if !ok {
  32127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32128. }
  32129. m.AddActiveUser(v)
  32130. return nil
  32131. case usagestatistichour.FieldNewUser:
  32132. v, ok := value.(int64)
  32133. if !ok {
  32134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32135. }
  32136. m.AddNewUser(v)
  32137. return nil
  32138. }
  32139. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  32140. }
  32141. // ClearedFields returns all nullable fields that were cleared during this
  32142. // mutation.
  32143. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  32144. var fields []string
  32145. if m.FieldCleared(usagestatistichour.FieldStatus) {
  32146. fields = append(fields, usagestatistichour.FieldStatus)
  32147. }
  32148. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  32149. fields = append(fields, usagestatistichour.FieldDeletedAt)
  32150. }
  32151. if m.FieldCleared(usagestatistichour.FieldBotID) {
  32152. fields = append(fields, usagestatistichour.FieldBotID)
  32153. }
  32154. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  32155. fields = append(fields, usagestatistichour.FieldOrganizationID)
  32156. }
  32157. return fields
  32158. }
  32159. // FieldCleared returns a boolean indicating if a field with the given name was
  32160. // cleared in this mutation.
  32161. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  32162. _, ok := m.clearedFields[name]
  32163. return ok
  32164. }
  32165. // ClearField clears the value of the field with the given name. It returns an
  32166. // error if the field is not defined in the schema.
  32167. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  32168. switch name {
  32169. case usagestatistichour.FieldStatus:
  32170. m.ClearStatus()
  32171. return nil
  32172. case usagestatistichour.FieldDeletedAt:
  32173. m.ClearDeletedAt()
  32174. return nil
  32175. case usagestatistichour.FieldBotID:
  32176. m.ClearBotID()
  32177. return nil
  32178. case usagestatistichour.FieldOrganizationID:
  32179. m.ClearOrganizationID()
  32180. return nil
  32181. }
  32182. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  32183. }
  32184. // ResetField resets all changes in the mutation for the field with the given name.
  32185. // It returns an error if the field is not defined in the schema.
  32186. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  32187. switch name {
  32188. case usagestatistichour.FieldCreatedAt:
  32189. m.ResetCreatedAt()
  32190. return nil
  32191. case usagestatistichour.FieldUpdatedAt:
  32192. m.ResetUpdatedAt()
  32193. return nil
  32194. case usagestatistichour.FieldStatus:
  32195. m.ResetStatus()
  32196. return nil
  32197. case usagestatistichour.FieldDeletedAt:
  32198. m.ResetDeletedAt()
  32199. return nil
  32200. case usagestatistichour.FieldAddtime:
  32201. m.ResetAddtime()
  32202. return nil
  32203. case usagestatistichour.FieldType:
  32204. m.ResetType()
  32205. return nil
  32206. case usagestatistichour.FieldBotID:
  32207. m.ResetBotID()
  32208. return nil
  32209. case usagestatistichour.FieldOrganizationID:
  32210. m.ResetOrganizationID()
  32211. return nil
  32212. case usagestatistichour.FieldAiResponse:
  32213. m.ResetAiResponse()
  32214. return nil
  32215. case usagestatistichour.FieldSopRun:
  32216. m.ResetSopRun()
  32217. return nil
  32218. case usagestatistichour.FieldTotalFriend:
  32219. m.ResetTotalFriend()
  32220. return nil
  32221. case usagestatistichour.FieldTotalGroup:
  32222. m.ResetTotalGroup()
  32223. return nil
  32224. case usagestatistichour.FieldAccountBalance:
  32225. m.ResetAccountBalance()
  32226. return nil
  32227. case usagestatistichour.FieldConsumeToken:
  32228. m.ResetConsumeToken()
  32229. return nil
  32230. case usagestatistichour.FieldActiveUser:
  32231. m.ResetActiveUser()
  32232. return nil
  32233. case usagestatistichour.FieldNewUser:
  32234. m.ResetNewUser()
  32235. return nil
  32236. case usagestatistichour.FieldLabelDist:
  32237. m.ResetLabelDist()
  32238. return nil
  32239. }
  32240. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  32241. }
  32242. // AddedEdges returns all edge names that were set/added in this mutation.
  32243. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  32244. edges := make([]string, 0, 0)
  32245. return edges
  32246. }
  32247. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32248. // name in this mutation.
  32249. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  32250. return nil
  32251. }
  32252. // RemovedEdges returns all edge names that were removed in this mutation.
  32253. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  32254. edges := make([]string, 0, 0)
  32255. return edges
  32256. }
  32257. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32258. // the given name in this mutation.
  32259. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  32260. return nil
  32261. }
  32262. // ClearedEdges returns all edge names that were cleared in this mutation.
  32263. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  32264. edges := make([]string, 0, 0)
  32265. return edges
  32266. }
  32267. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32268. // was cleared in this mutation.
  32269. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  32270. return false
  32271. }
  32272. // ClearEdge clears the value of the edge with the given name. It returns an error
  32273. // if that edge is not defined in the schema.
  32274. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  32275. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  32276. }
  32277. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32278. // It returns an error if the edge is not defined in the schema.
  32279. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  32280. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  32281. }
  32282. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  32283. type UsageStatisticMonthMutation struct {
  32284. config
  32285. op Op
  32286. typ string
  32287. id *uint64
  32288. created_at *time.Time
  32289. updated_at *time.Time
  32290. status *uint8
  32291. addstatus *int8
  32292. deleted_at *time.Time
  32293. addtime *uint64
  32294. addaddtime *int64
  32295. _type *int
  32296. add_type *int
  32297. bot_id *string
  32298. organization_id *uint64
  32299. addorganization_id *int64
  32300. ai_response *uint64
  32301. addai_response *int64
  32302. sop_run *uint64
  32303. addsop_run *int64
  32304. total_friend *uint64
  32305. addtotal_friend *int64
  32306. total_group *uint64
  32307. addtotal_group *int64
  32308. account_balance *uint64
  32309. addaccount_balance *int64
  32310. consume_token *uint64
  32311. addconsume_token *int64
  32312. active_user *uint64
  32313. addactive_user *int64
  32314. new_user *int64
  32315. addnew_user *int64
  32316. label_dist *[]custom_types.LabelDist
  32317. appendlabel_dist []custom_types.LabelDist
  32318. clearedFields map[string]struct{}
  32319. done bool
  32320. oldValue func(context.Context) (*UsageStatisticMonth, error)
  32321. predicates []predicate.UsageStatisticMonth
  32322. }
  32323. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  32324. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  32325. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  32326. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  32327. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  32328. m := &UsageStatisticMonthMutation{
  32329. config: c,
  32330. op: op,
  32331. typ: TypeUsageStatisticMonth,
  32332. clearedFields: make(map[string]struct{}),
  32333. }
  32334. for _, opt := range opts {
  32335. opt(m)
  32336. }
  32337. return m
  32338. }
  32339. // withUsageStatisticMonthID sets the ID field of the mutation.
  32340. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  32341. return func(m *UsageStatisticMonthMutation) {
  32342. var (
  32343. err error
  32344. once sync.Once
  32345. value *UsageStatisticMonth
  32346. )
  32347. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  32348. once.Do(func() {
  32349. if m.done {
  32350. err = errors.New("querying old values post mutation is not allowed")
  32351. } else {
  32352. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  32353. }
  32354. })
  32355. return value, err
  32356. }
  32357. m.id = &id
  32358. }
  32359. }
  32360. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  32361. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  32362. return func(m *UsageStatisticMonthMutation) {
  32363. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  32364. return node, nil
  32365. }
  32366. m.id = &node.ID
  32367. }
  32368. }
  32369. // Client returns a new `ent.Client` from the mutation. If the mutation was
  32370. // executed in a transaction (ent.Tx), a transactional client is returned.
  32371. func (m UsageStatisticMonthMutation) Client() *Client {
  32372. client := &Client{config: m.config}
  32373. client.init()
  32374. return client
  32375. }
  32376. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  32377. // it returns an error otherwise.
  32378. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  32379. if _, ok := m.driver.(*txDriver); !ok {
  32380. return nil, errors.New("ent: mutation is not running in a transaction")
  32381. }
  32382. tx := &Tx{config: m.config}
  32383. tx.init()
  32384. return tx, nil
  32385. }
  32386. // SetID sets the value of the id field. Note that this
  32387. // operation is only accepted on creation of UsageStatisticMonth entities.
  32388. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  32389. m.id = &id
  32390. }
  32391. // ID returns the ID value in the mutation. Note that the ID is only available
  32392. // if it was provided to the builder or after it was returned from the database.
  32393. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  32394. if m.id == nil {
  32395. return
  32396. }
  32397. return *m.id, true
  32398. }
  32399. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32400. // That means, if the mutation is applied within a transaction with an isolation level such
  32401. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32402. // or updated by the mutation.
  32403. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  32404. switch {
  32405. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32406. id, exists := m.ID()
  32407. if exists {
  32408. return []uint64{id}, nil
  32409. }
  32410. fallthrough
  32411. case m.op.Is(OpUpdate | OpDelete):
  32412. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  32413. default:
  32414. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32415. }
  32416. }
  32417. // SetCreatedAt sets the "created_at" field.
  32418. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  32419. m.created_at = &t
  32420. }
  32421. // CreatedAt returns the value of the "created_at" field in the mutation.
  32422. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  32423. v := m.created_at
  32424. if v == nil {
  32425. return
  32426. }
  32427. return *v, true
  32428. }
  32429. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  32430. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32432. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32433. if !m.op.Is(OpUpdateOne) {
  32434. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32435. }
  32436. if m.id == nil || m.oldValue == nil {
  32437. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32438. }
  32439. oldValue, err := m.oldValue(ctx)
  32440. if err != nil {
  32441. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32442. }
  32443. return oldValue.CreatedAt, nil
  32444. }
  32445. // ResetCreatedAt resets all changes to the "created_at" field.
  32446. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  32447. m.created_at = nil
  32448. }
  32449. // SetUpdatedAt sets the "updated_at" field.
  32450. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  32451. m.updated_at = &t
  32452. }
  32453. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32454. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  32455. v := m.updated_at
  32456. if v == nil {
  32457. return
  32458. }
  32459. return *v, true
  32460. }
  32461. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  32462. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32463. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32464. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32465. if !m.op.Is(OpUpdateOne) {
  32466. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32467. }
  32468. if m.id == nil || m.oldValue == nil {
  32469. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32470. }
  32471. oldValue, err := m.oldValue(ctx)
  32472. if err != nil {
  32473. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32474. }
  32475. return oldValue.UpdatedAt, nil
  32476. }
  32477. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32478. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  32479. m.updated_at = nil
  32480. }
  32481. // SetStatus sets the "status" field.
  32482. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  32483. m.status = &u
  32484. m.addstatus = nil
  32485. }
  32486. // Status returns the value of the "status" field in the mutation.
  32487. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  32488. v := m.status
  32489. if v == nil {
  32490. return
  32491. }
  32492. return *v, true
  32493. }
  32494. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  32495. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32496. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32497. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  32498. if !m.op.Is(OpUpdateOne) {
  32499. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  32500. }
  32501. if m.id == nil || m.oldValue == nil {
  32502. return v, errors.New("OldStatus requires an ID field in the mutation")
  32503. }
  32504. oldValue, err := m.oldValue(ctx)
  32505. if err != nil {
  32506. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  32507. }
  32508. return oldValue.Status, nil
  32509. }
  32510. // AddStatus adds u to the "status" field.
  32511. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  32512. if m.addstatus != nil {
  32513. *m.addstatus += u
  32514. } else {
  32515. m.addstatus = &u
  32516. }
  32517. }
  32518. // AddedStatus returns the value that was added to the "status" field in this mutation.
  32519. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  32520. v := m.addstatus
  32521. if v == nil {
  32522. return
  32523. }
  32524. return *v, true
  32525. }
  32526. // ClearStatus clears the value of the "status" field.
  32527. func (m *UsageStatisticMonthMutation) ClearStatus() {
  32528. m.status = nil
  32529. m.addstatus = nil
  32530. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  32531. }
  32532. // StatusCleared returns if the "status" field was cleared in this mutation.
  32533. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  32534. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  32535. return ok
  32536. }
  32537. // ResetStatus resets all changes to the "status" field.
  32538. func (m *UsageStatisticMonthMutation) ResetStatus() {
  32539. m.status = nil
  32540. m.addstatus = nil
  32541. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  32542. }
  32543. // SetDeletedAt sets the "deleted_at" field.
  32544. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  32545. m.deleted_at = &t
  32546. }
  32547. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  32548. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  32549. v := m.deleted_at
  32550. if v == nil {
  32551. return
  32552. }
  32553. return *v, true
  32554. }
  32555. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  32556. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32557. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32558. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  32559. if !m.op.Is(OpUpdateOne) {
  32560. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  32561. }
  32562. if m.id == nil || m.oldValue == nil {
  32563. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  32564. }
  32565. oldValue, err := m.oldValue(ctx)
  32566. if err != nil {
  32567. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  32568. }
  32569. return oldValue.DeletedAt, nil
  32570. }
  32571. // ClearDeletedAt clears the value of the "deleted_at" field.
  32572. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  32573. m.deleted_at = nil
  32574. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  32575. }
  32576. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  32577. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  32578. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  32579. return ok
  32580. }
  32581. // ResetDeletedAt resets all changes to the "deleted_at" field.
  32582. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  32583. m.deleted_at = nil
  32584. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  32585. }
  32586. // SetAddtime sets the "addtime" field.
  32587. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  32588. m.addtime = &u
  32589. m.addaddtime = nil
  32590. }
  32591. // Addtime returns the value of the "addtime" field in the mutation.
  32592. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  32593. v := m.addtime
  32594. if v == nil {
  32595. return
  32596. }
  32597. return *v, true
  32598. }
  32599. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  32600. // If the UsageStatisticMonth 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 *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  32603. if !m.op.Is(OpUpdateOne) {
  32604. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  32605. }
  32606. if m.id == nil || m.oldValue == nil {
  32607. return v, errors.New("OldAddtime 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 OldAddtime: %w", err)
  32612. }
  32613. return oldValue.Addtime, nil
  32614. }
  32615. // AddAddtime adds u to the "addtime" field.
  32616. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  32617. if m.addaddtime != nil {
  32618. *m.addaddtime += u
  32619. } else {
  32620. m.addaddtime = &u
  32621. }
  32622. }
  32623. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  32624. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  32625. v := m.addaddtime
  32626. if v == nil {
  32627. return
  32628. }
  32629. return *v, true
  32630. }
  32631. // ResetAddtime resets all changes to the "addtime" field.
  32632. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  32633. m.addtime = nil
  32634. m.addaddtime = nil
  32635. }
  32636. // SetType sets the "type" field.
  32637. func (m *UsageStatisticMonthMutation) SetType(i int) {
  32638. m._type = &i
  32639. m.add_type = nil
  32640. }
  32641. // GetType returns the value of the "type" field in the mutation.
  32642. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  32643. v := m._type
  32644. if v == nil {
  32645. return
  32646. }
  32647. return *v, true
  32648. }
  32649. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  32650. // If the UsageStatisticMonth 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 *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  32653. if !m.op.Is(OpUpdateOne) {
  32654. return v, errors.New("OldType is only allowed on UpdateOne operations")
  32655. }
  32656. if m.id == nil || m.oldValue == nil {
  32657. return v, errors.New("OldType 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 OldType: %w", err)
  32662. }
  32663. return oldValue.Type, nil
  32664. }
  32665. // AddType adds i to the "type" field.
  32666. func (m *UsageStatisticMonthMutation) AddType(i int) {
  32667. if m.add_type != nil {
  32668. *m.add_type += i
  32669. } else {
  32670. m.add_type = &i
  32671. }
  32672. }
  32673. // AddedType returns the value that was added to the "type" field in this mutation.
  32674. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  32675. v := m.add_type
  32676. if v == nil {
  32677. return
  32678. }
  32679. return *v, true
  32680. }
  32681. // ResetType resets all changes to the "type" field.
  32682. func (m *UsageStatisticMonthMutation) ResetType() {
  32683. m._type = nil
  32684. m.add_type = nil
  32685. }
  32686. // SetBotID sets the "bot_id" field.
  32687. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  32688. m.bot_id = &s
  32689. }
  32690. // BotID returns the value of the "bot_id" field in the mutation.
  32691. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  32692. v := m.bot_id
  32693. if v == nil {
  32694. return
  32695. }
  32696. return *v, true
  32697. }
  32698. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  32699. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32700. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32701. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  32702. if !m.op.Is(OpUpdateOne) {
  32703. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  32704. }
  32705. if m.id == nil || m.oldValue == nil {
  32706. return v, errors.New("OldBotID requires an ID field in the mutation")
  32707. }
  32708. oldValue, err := m.oldValue(ctx)
  32709. if err != nil {
  32710. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  32711. }
  32712. return oldValue.BotID, nil
  32713. }
  32714. // ClearBotID clears the value of the "bot_id" field.
  32715. func (m *UsageStatisticMonthMutation) ClearBotID() {
  32716. m.bot_id = nil
  32717. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  32718. }
  32719. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  32720. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  32721. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  32722. return ok
  32723. }
  32724. // ResetBotID resets all changes to the "bot_id" field.
  32725. func (m *UsageStatisticMonthMutation) ResetBotID() {
  32726. m.bot_id = nil
  32727. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  32728. }
  32729. // SetOrganizationID sets the "organization_id" field.
  32730. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  32731. m.organization_id = &u
  32732. m.addorganization_id = nil
  32733. }
  32734. // OrganizationID returns the value of the "organization_id" field in the mutation.
  32735. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  32736. v := m.organization_id
  32737. if v == nil {
  32738. return
  32739. }
  32740. return *v, true
  32741. }
  32742. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  32743. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32744. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32745. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  32746. if !m.op.Is(OpUpdateOne) {
  32747. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  32748. }
  32749. if m.id == nil || m.oldValue == nil {
  32750. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  32751. }
  32752. oldValue, err := m.oldValue(ctx)
  32753. if err != nil {
  32754. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  32755. }
  32756. return oldValue.OrganizationID, nil
  32757. }
  32758. // AddOrganizationID adds u to the "organization_id" field.
  32759. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  32760. if m.addorganization_id != nil {
  32761. *m.addorganization_id += u
  32762. } else {
  32763. m.addorganization_id = &u
  32764. }
  32765. }
  32766. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  32767. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  32768. v := m.addorganization_id
  32769. if v == nil {
  32770. return
  32771. }
  32772. return *v, true
  32773. }
  32774. // ClearOrganizationID clears the value of the "organization_id" field.
  32775. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  32776. m.organization_id = nil
  32777. m.addorganization_id = nil
  32778. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  32779. }
  32780. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  32781. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  32782. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  32783. return ok
  32784. }
  32785. // ResetOrganizationID resets all changes to the "organization_id" field.
  32786. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  32787. m.organization_id = nil
  32788. m.addorganization_id = nil
  32789. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  32790. }
  32791. // SetAiResponse sets the "ai_response" field.
  32792. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  32793. m.ai_response = &u
  32794. m.addai_response = nil
  32795. }
  32796. // AiResponse returns the value of the "ai_response" field in the mutation.
  32797. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  32798. v := m.ai_response
  32799. if v == nil {
  32800. return
  32801. }
  32802. return *v, true
  32803. }
  32804. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  32805. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32807. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  32808. if !m.op.Is(OpUpdateOne) {
  32809. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  32810. }
  32811. if m.id == nil || m.oldValue == nil {
  32812. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  32813. }
  32814. oldValue, err := m.oldValue(ctx)
  32815. if err != nil {
  32816. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  32817. }
  32818. return oldValue.AiResponse, nil
  32819. }
  32820. // AddAiResponse adds u to the "ai_response" field.
  32821. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  32822. if m.addai_response != nil {
  32823. *m.addai_response += u
  32824. } else {
  32825. m.addai_response = &u
  32826. }
  32827. }
  32828. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  32829. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  32830. v := m.addai_response
  32831. if v == nil {
  32832. return
  32833. }
  32834. return *v, true
  32835. }
  32836. // ResetAiResponse resets all changes to the "ai_response" field.
  32837. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  32838. m.ai_response = nil
  32839. m.addai_response = nil
  32840. }
  32841. // SetSopRun sets the "sop_run" field.
  32842. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  32843. m.sop_run = &u
  32844. m.addsop_run = nil
  32845. }
  32846. // SopRun returns the value of the "sop_run" field in the mutation.
  32847. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  32848. v := m.sop_run
  32849. if v == nil {
  32850. return
  32851. }
  32852. return *v, true
  32853. }
  32854. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  32855. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32856. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32857. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  32858. if !m.op.Is(OpUpdateOne) {
  32859. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  32860. }
  32861. if m.id == nil || m.oldValue == nil {
  32862. return v, errors.New("OldSopRun requires an ID field in the mutation")
  32863. }
  32864. oldValue, err := m.oldValue(ctx)
  32865. if err != nil {
  32866. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  32867. }
  32868. return oldValue.SopRun, nil
  32869. }
  32870. // AddSopRun adds u to the "sop_run" field.
  32871. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  32872. if m.addsop_run != nil {
  32873. *m.addsop_run += u
  32874. } else {
  32875. m.addsop_run = &u
  32876. }
  32877. }
  32878. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  32879. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  32880. v := m.addsop_run
  32881. if v == nil {
  32882. return
  32883. }
  32884. return *v, true
  32885. }
  32886. // ResetSopRun resets all changes to the "sop_run" field.
  32887. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  32888. m.sop_run = nil
  32889. m.addsop_run = nil
  32890. }
  32891. // SetTotalFriend sets the "total_friend" field.
  32892. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  32893. m.total_friend = &u
  32894. m.addtotal_friend = nil
  32895. }
  32896. // TotalFriend returns the value of the "total_friend" field in the mutation.
  32897. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  32898. v := m.total_friend
  32899. if v == nil {
  32900. return
  32901. }
  32902. return *v, true
  32903. }
  32904. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  32905. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32907. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  32908. if !m.op.Is(OpUpdateOne) {
  32909. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  32910. }
  32911. if m.id == nil || m.oldValue == nil {
  32912. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  32913. }
  32914. oldValue, err := m.oldValue(ctx)
  32915. if err != nil {
  32916. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  32917. }
  32918. return oldValue.TotalFriend, nil
  32919. }
  32920. // AddTotalFriend adds u to the "total_friend" field.
  32921. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  32922. if m.addtotal_friend != nil {
  32923. *m.addtotal_friend += u
  32924. } else {
  32925. m.addtotal_friend = &u
  32926. }
  32927. }
  32928. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  32929. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  32930. v := m.addtotal_friend
  32931. if v == nil {
  32932. return
  32933. }
  32934. return *v, true
  32935. }
  32936. // ResetTotalFriend resets all changes to the "total_friend" field.
  32937. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  32938. m.total_friend = nil
  32939. m.addtotal_friend = nil
  32940. }
  32941. // SetTotalGroup sets the "total_group" field.
  32942. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  32943. m.total_group = &u
  32944. m.addtotal_group = nil
  32945. }
  32946. // TotalGroup returns the value of the "total_group" field in the mutation.
  32947. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  32948. v := m.total_group
  32949. if v == nil {
  32950. return
  32951. }
  32952. return *v, true
  32953. }
  32954. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  32955. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32956. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32957. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  32958. if !m.op.Is(OpUpdateOne) {
  32959. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  32960. }
  32961. if m.id == nil || m.oldValue == nil {
  32962. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  32963. }
  32964. oldValue, err := m.oldValue(ctx)
  32965. if err != nil {
  32966. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  32967. }
  32968. return oldValue.TotalGroup, nil
  32969. }
  32970. // AddTotalGroup adds u to the "total_group" field.
  32971. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  32972. if m.addtotal_group != nil {
  32973. *m.addtotal_group += u
  32974. } else {
  32975. m.addtotal_group = &u
  32976. }
  32977. }
  32978. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  32979. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  32980. v := m.addtotal_group
  32981. if v == nil {
  32982. return
  32983. }
  32984. return *v, true
  32985. }
  32986. // ResetTotalGroup resets all changes to the "total_group" field.
  32987. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  32988. m.total_group = nil
  32989. m.addtotal_group = nil
  32990. }
  32991. // SetAccountBalance sets the "account_balance" field.
  32992. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  32993. m.account_balance = &u
  32994. m.addaccount_balance = nil
  32995. }
  32996. // AccountBalance returns the value of the "account_balance" field in the mutation.
  32997. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  32998. v := m.account_balance
  32999. if v == nil {
  33000. return
  33001. }
  33002. return *v, true
  33003. }
  33004. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  33005. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33006. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33007. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  33008. if !m.op.Is(OpUpdateOne) {
  33009. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  33010. }
  33011. if m.id == nil || m.oldValue == nil {
  33012. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  33013. }
  33014. oldValue, err := m.oldValue(ctx)
  33015. if err != nil {
  33016. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  33017. }
  33018. return oldValue.AccountBalance, nil
  33019. }
  33020. // AddAccountBalance adds u to the "account_balance" field.
  33021. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  33022. if m.addaccount_balance != nil {
  33023. *m.addaccount_balance += u
  33024. } else {
  33025. m.addaccount_balance = &u
  33026. }
  33027. }
  33028. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  33029. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  33030. v := m.addaccount_balance
  33031. if v == nil {
  33032. return
  33033. }
  33034. return *v, true
  33035. }
  33036. // ResetAccountBalance resets all changes to the "account_balance" field.
  33037. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  33038. m.account_balance = nil
  33039. m.addaccount_balance = nil
  33040. }
  33041. // SetConsumeToken sets the "consume_token" field.
  33042. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  33043. m.consume_token = &u
  33044. m.addconsume_token = nil
  33045. }
  33046. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  33047. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  33048. v := m.consume_token
  33049. if v == nil {
  33050. return
  33051. }
  33052. return *v, true
  33053. }
  33054. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  33055. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33056. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33057. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  33058. if !m.op.Is(OpUpdateOne) {
  33059. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  33060. }
  33061. if m.id == nil || m.oldValue == nil {
  33062. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  33063. }
  33064. oldValue, err := m.oldValue(ctx)
  33065. if err != nil {
  33066. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  33067. }
  33068. return oldValue.ConsumeToken, nil
  33069. }
  33070. // AddConsumeToken adds u to the "consume_token" field.
  33071. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  33072. if m.addconsume_token != nil {
  33073. *m.addconsume_token += u
  33074. } else {
  33075. m.addconsume_token = &u
  33076. }
  33077. }
  33078. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  33079. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  33080. v := m.addconsume_token
  33081. if v == nil {
  33082. return
  33083. }
  33084. return *v, true
  33085. }
  33086. // ResetConsumeToken resets all changes to the "consume_token" field.
  33087. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  33088. m.consume_token = nil
  33089. m.addconsume_token = nil
  33090. }
  33091. // SetActiveUser sets the "active_user" field.
  33092. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  33093. m.active_user = &u
  33094. m.addactive_user = nil
  33095. }
  33096. // ActiveUser returns the value of the "active_user" field in the mutation.
  33097. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  33098. v := m.active_user
  33099. if v == nil {
  33100. return
  33101. }
  33102. return *v, true
  33103. }
  33104. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  33105. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33106. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33107. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  33108. if !m.op.Is(OpUpdateOne) {
  33109. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  33110. }
  33111. if m.id == nil || m.oldValue == nil {
  33112. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  33113. }
  33114. oldValue, err := m.oldValue(ctx)
  33115. if err != nil {
  33116. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  33117. }
  33118. return oldValue.ActiveUser, nil
  33119. }
  33120. // AddActiveUser adds u to the "active_user" field.
  33121. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  33122. if m.addactive_user != nil {
  33123. *m.addactive_user += u
  33124. } else {
  33125. m.addactive_user = &u
  33126. }
  33127. }
  33128. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  33129. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  33130. v := m.addactive_user
  33131. if v == nil {
  33132. return
  33133. }
  33134. return *v, true
  33135. }
  33136. // ResetActiveUser resets all changes to the "active_user" field.
  33137. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  33138. m.active_user = nil
  33139. m.addactive_user = nil
  33140. }
  33141. // SetNewUser sets the "new_user" field.
  33142. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  33143. m.new_user = &i
  33144. m.addnew_user = nil
  33145. }
  33146. // NewUser returns the value of the "new_user" field in the mutation.
  33147. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  33148. v := m.new_user
  33149. if v == nil {
  33150. return
  33151. }
  33152. return *v, true
  33153. }
  33154. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  33155. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33156. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33157. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  33158. if !m.op.Is(OpUpdateOne) {
  33159. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  33160. }
  33161. if m.id == nil || m.oldValue == nil {
  33162. return v, errors.New("OldNewUser requires an ID field in the mutation")
  33163. }
  33164. oldValue, err := m.oldValue(ctx)
  33165. if err != nil {
  33166. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  33167. }
  33168. return oldValue.NewUser, nil
  33169. }
  33170. // AddNewUser adds i to the "new_user" field.
  33171. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  33172. if m.addnew_user != nil {
  33173. *m.addnew_user += i
  33174. } else {
  33175. m.addnew_user = &i
  33176. }
  33177. }
  33178. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  33179. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  33180. v := m.addnew_user
  33181. if v == nil {
  33182. return
  33183. }
  33184. return *v, true
  33185. }
  33186. // ResetNewUser resets all changes to the "new_user" field.
  33187. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  33188. m.new_user = nil
  33189. m.addnew_user = nil
  33190. }
  33191. // SetLabelDist sets the "label_dist" field.
  33192. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  33193. m.label_dist = &ctd
  33194. m.appendlabel_dist = nil
  33195. }
  33196. // LabelDist returns the value of the "label_dist" field in the mutation.
  33197. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  33198. v := m.label_dist
  33199. if v == nil {
  33200. return
  33201. }
  33202. return *v, true
  33203. }
  33204. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  33205. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33206. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33207. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  33208. if !m.op.Is(OpUpdateOne) {
  33209. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  33210. }
  33211. if m.id == nil || m.oldValue == nil {
  33212. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  33213. }
  33214. oldValue, err := m.oldValue(ctx)
  33215. if err != nil {
  33216. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  33217. }
  33218. return oldValue.LabelDist, nil
  33219. }
  33220. // AppendLabelDist adds ctd to the "label_dist" field.
  33221. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  33222. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  33223. }
  33224. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  33225. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  33226. if len(m.appendlabel_dist) == 0 {
  33227. return nil, false
  33228. }
  33229. return m.appendlabel_dist, true
  33230. }
  33231. // ResetLabelDist resets all changes to the "label_dist" field.
  33232. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  33233. m.label_dist = nil
  33234. m.appendlabel_dist = nil
  33235. }
  33236. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  33237. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  33238. m.predicates = append(m.predicates, ps...)
  33239. }
  33240. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  33241. // users can use type-assertion to append predicates that do not depend on any generated package.
  33242. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  33243. p := make([]predicate.UsageStatisticMonth, len(ps))
  33244. for i := range ps {
  33245. p[i] = ps[i]
  33246. }
  33247. m.Where(p...)
  33248. }
  33249. // Op returns the operation name.
  33250. func (m *UsageStatisticMonthMutation) Op() Op {
  33251. return m.op
  33252. }
  33253. // SetOp allows setting the mutation operation.
  33254. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  33255. m.op = op
  33256. }
  33257. // Type returns the node type of this mutation (UsageStatisticMonth).
  33258. func (m *UsageStatisticMonthMutation) Type() string {
  33259. return m.typ
  33260. }
  33261. // Fields returns all fields that were changed during this mutation. Note that in
  33262. // order to get all numeric fields that were incremented/decremented, call
  33263. // AddedFields().
  33264. func (m *UsageStatisticMonthMutation) Fields() []string {
  33265. fields := make([]string, 0, 17)
  33266. if m.created_at != nil {
  33267. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  33268. }
  33269. if m.updated_at != nil {
  33270. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  33271. }
  33272. if m.status != nil {
  33273. fields = append(fields, usagestatisticmonth.FieldStatus)
  33274. }
  33275. if m.deleted_at != nil {
  33276. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  33277. }
  33278. if m.addtime != nil {
  33279. fields = append(fields, usagestatisticmonth.FieldAddtime)
  33280. }
  33281. if m._type != nil {
  33282. fields = append(fields, usagestatisticmonth.FieldType)
  33283. }
  33284. if m.bot_id != nil {
  33285. fields = append(fields, usagestatisticmonth.FieldBotID)
  33286. }
  33287. if m.organization_id != nil {
  33288. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  33289. }
  33290. if m.ai_response != nil {
  33291. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  33292. }
  33293. if m.sop_run != nil {
  33294. fields = append(fields, usagestatisticmonth.FieldSopRun)
  33295. }
  33296. if m.total_friend != nil {
  33297. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  33298. }
  33299. if m.total_group != nil {
  33300. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  33301. }
  33302. if m.account_balance != nil {
  33303. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  33304. }
  33305. if m.consume_token != nil {
  33306. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  33307. }
  33308. if m.active_user != nil {
  33309. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  33310. }
  33311. if m.new_user != nil {
  33312. fields = append(fields, usagestatisticmonth.FieldNewUser)
  33313. }
  33314. if m.label_dist != nil {
  33315. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  33316. }
  33317. return fields
  33318. }
  33319. // Field returns the value of a field with the given name. The second boolean
  33320. // return value indicates that this field was not set, or was not defined in the
  33321. // schema.
  33322. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  33323. switch name {
  33324. case usagestatisticmonth.FieldCreatedAt:
  33325. return m.CreatedAt()
  33326. case usagestatisticmonth.FieldUpdatedAt:
  33327. return m.UpdatedAt()
  33328. case usagestatisticmonth.FieldStatus:
  33329. return m.Status()
  33330. case usagestatisticmonth.FieldDeletedAt:
  33331. return m.DeletedAt()
  33332. case usagestatisticmonth.FieldAddtime:
  33333. return m.Addtime()
  33334. case usagestatisticmonth.FieldType:
  33335. return m.GetType()
  33336. case usagestatisticmonth.FieldBotID:
  33337. return m.BotID()
  33338. case usagestatisticmonth.FieldOrganizationID:
  33339. return m.OrganizationID()
  33340. case usagestatisticmonth.FieldAiResponse:
  33341. return m.AiResponse()
  33342. case usagestatisticmonth.FieldSopRun:
  33343. return m.SopRun()
  33344. case usagestatisticmonth.FieldTotalFriend:
  33345. return m.TotalFriend()
  33346. case usagestatisticmonth.FieldTotalGroup:
  33347. return m.TotalGroup()
  33348. case usagestatisticmonth.FieldAccountBalance:
  33349. return m.AccountBalance()
  33350. case usagestatisticmonth.FieldConsumeToken:
  33351. return m.ConsumeToken()
  33352. case usagestatisticmonth.FieldActiveUser:
  33353. return m.ActiveUser()
  33354. case usagestatisticmonth.FieldNewUser:
  33355. return m.NewUser()
  33356. case usagestatisticmonth.FieldLabelDist:
  33357. return m.LabelDist()
  33358. }
  33359. return nil, false
  33360. }
  33361. // OldField returns the old value of the field from the database. An error is
  33362. // returned if the mutation operation is not UpdateOne, or the query to the
  33363. // database failed.
  33364. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  33365. switch name {
  33366. case usagestatisticmonth.FieldCreatedAt:
  33367. return m.OldCreatedAt(ctx)
  33368. case usagestatisticmonth.FieldUpdatedAt:
  33369. return m.OldUpdatedAt(ctx)
  33370. case usagestatisticmonth.FieldStatus:
  33371. return m.OldStatus(ctx)
  33372. case usagestatisticmonth.FieldDeletedAt:
  33373. return m.OldDeletedAt(ctx)
  33374. case usagestatisticmonth.FieldAddtime:
  33375. return m.OldAddtime(ctx)
  33376. case usagestatisticmonth.FieldType:
  33377. return m.OldType(ctx)
  33378. case usagestatisticmonth.FieldBotID:
  33379. return m.OldBotID(ctx)
  33380. case usagestatisticmonth.FieldOrganizationID:
  33381. return m.OldOrganizationID(ctx)
  33382. case usagestatisticmonth.FieldAiResponse:
  33383. return m.OldAiResponse(ctx)
  33384. case usagestatisticmonth.FieldSopRun:
  33385. return m.OldSopRun(ctx)
  33386. case usagestatisticmonth.FieldTotalFriend:
  33387. return m.OldTotalFriend(ctx)
  33388. case usagestatisticmonth.FieldTotalGroup:
  33389. return m.OldTotalGroup(ctx)
  33390. case usagestatisticmonth.FieldAccountBalance:
  33391. return m.OldAccountBalance(ctx)
  33392. case usagestatisticmonth.FieldConsumeToken:
  33393. return m.OldConsumeToken(ctx)
  33394. case usagestatisticmonth.FieldActiveUser:
  33395. return m.OldActiveUser(ctx)
  33396. case usagestatisticmonth.FieldNewUser:
  33397. return m.OldNewUser(ctx)
  33398. case usagestatisticmonth.FieldLabelDist:
  33399. return m.OldLabelDist(ctx)
  33400. }
  33401. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  33402. }
  33403. // SetField sets the value of a field with the given name. It returns an error if
  33404. // the field is not defined in the schema, or if the type mismatched the field
  33405. // type.
  33406. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  33407. switch name {
  33408. case usagestatisticmonth.FieldCreatedAt:
  33409. v, ok := value.(time.Time)
  33410. if !ok {
  33411. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33412. }
  33413. m.SetCreatedAt(v)
  33414. return nil
  33415. case usagestatisticmonth.FieldUpdatedAt:
  33416. v, ok := value.(time.Time)
  33417. if !ok {
  33418. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33419. }
  33420. m.SetUpdatedAt(v)
  33421. return nil
  33422. case usagestatisticmonth.FieldStatus:
  33423. v, ok := value.(uint8)
  33424. if !ok {
  33425. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33426. }
  33427. m.SetStatus(v)
  33428. return nil
  33429. case usagestatisticmonth.FieldDeletedAt:
  33430. v, ok := value.(time.Time)
  33431. if !ok {
  33432. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33433. }
  33434. m.SetDeletedAt(v)
  33435. return nil
  33436. case usagestatisticmonth.FieldAddtime:
  33437. v, ok := value.(uint64)
  33438. if !ok {
  33439. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33440. }
  33441. m.SetAddtime(v)
  33442. return nil
  33443. case usagestatisticmonth.FieldType:
  33444. v, ok := value.(int)
  33445. if !ok {
  33446. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33447. }
  33448. m.SetType(v)
  33449. return nil
  33450. case usagestatisticmonth.FieldBotID:
  33451. v, ok := value.(string)
  33452. if !ok {
  33453. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33454. }
  33455. m.SetBotID(v)
  33456. return nil
  33457. case usagestatisticmonth.FieldOrganizationID:
  33458. v, ok := value.(uint64)
  33459. if !ok {
  33460. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33461. }
  33462. m.SetOrganizationID(v)
  33463. return nil
  33464. case usagestatisticmonth.FieldAiResponse:
  33465. v, ok := value.(uint64)
  33466. if !ok {
  33467. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33468. }
  33469. m.SetAiResponse(v)
  33470. return nil
  33471. case usagestatisticmonth.FieldSopRun:
  33472. v, ok := value.(uint64)
  33473. if !ok {
  33474. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33475. }
  33476. m.SetSopRun(v)
  33477. return nil
  33478. case usagestatisticmonth.FieldTotalFriend:
  33479. v, ok := value.(uint64)
  33480. if !ok {
  33481. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33482. }
  33483. m.SetTotalFriend(v)
  33484. return nil
  33485. case usagestatisticmonth.FieldTotalGroup:
  33486. v, ok := value.(uint64)
  33487. if !ok {
  33488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33489. }
  33490. m.SetTotalGroup(v)
  33491. return nil
  33492. case usagestatisticmonth.FieldAccountBalance:
  33493. v, ok := value.(uint64)
  33494. if !ok {
  33495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33496. }
  33497. m.SetAccountBalance(v)
  33498. return nil
  33499. case usagestatisticmonth.FieldConsumeToken:
  33500. v, ok := value.(uint64)
  33501. if !ok {
  33502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33503. }
  33504. m.SetConsumeToken(v)
  33505. return nil
  33506. case usagestatisticmonth.FieldActiveUser:
  33507. v, ok := value.(uint64)
  33508. if !ok {
  33509. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33510. }
  33511. m.SetActiveUser(v)
  33512. return nil
  33513. case usagestatisticmonth.FieldNewUser:
  33514. v, ok := value.(int64)
  33515. if !ok {
  33516. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33517. }
  33518. m.SetNewUser(v)
  33519. return nil
  33520. case usagestatisticmonth.FieldLabelDist:
  33521. v, ok := value.([]custom_types.LabelDist)
  33522. if !ok {
  33523. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33524. }
  33525. m.SetLabelDist(v)
  33526. return nil
  33527. }
  33528. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  33529. }
  33530. // AddedFields returns all numeric fields that were incremented/decremented during
  33531. // this mutation.
  33532. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  33533. var fields []string
  33534. if m.addstatus != nil {
  33535. fields = append(fields, usagestatisticmonth.FieldStatus)
  33536. }
  33537. if m.addaddtime != nil {
  33538. fields = append(fields, usagestatisticmonth.FieldAddtime)
  33539. }
  33540. if m.add_type != nil {
  33541. fields = append(fields, usagestatisticmonth.FieldType)
  33542. }
  33543. if m.addorganization_id != nil {
  33544. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  33545. }
  33546. if m.addai_response != nil {
  33547. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  33548. }
  33549. if m.addsop_run != nil {
  33550. fields = append(fields, usagestatisticmonth.FieldSopRun)
  33551. }
  33552. if m.addtotal_friend != nil {
  33553. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  33554. }
  33555. if m.addtotal_group != nil {
  33556. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  33557. }
  33558. if m.addaccount_balance != nil {
  33559. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  33560. }
  33561. if m.addconsume_token != nil {
  33562. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  33563. }
  33564. if m.addactive_user != nil {
  33565. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  33566. }
  33567. if m.addnew_user != nil {
  33568. fields = append(fields, usagestatisticmonth.FieldNewUser)
  33569. }
  33570. return fields
  33571. }
  33572. // AddedField returns the numeric value that was incremented/decremented on a field
  33573. // with the given name. The second boolean return value indicates that this field
  33574. // was not set, or was not defined in the schema.
  33575. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  33576. switch name {
  33577. case usagestatisticmonth.FieldStatus:
  33578. return m.AddedStatus()
  33579. case usagestatisticmonth.FieldAddtime:
  33580. return m.AddedAddtime()
  33581. case usagestatisticmonth.FieldType:
  33582. return m.AddedType()
  33583. case usagestatisticmonth.FieldOrganizationID:
  33584. return m.AddedOrganizationID()
  33585. case usagestatisticmonth.FieldAiResponse:
  33586. return m.AddedAiResponse()
  33587. case usagestatisticmonth.FieldSopRun:
  33588. return m.AddedSopRun()
  33589. case usagestatisticmonth.FieldTotalFriend:
  33590. return m.AddedTotalFriend()
  33591. case usagestatisticmonth.FieldTotalGroup:
  33592. return m.AddedTotalGroup()
  33593. case usagestatisticmonth.FieldAccountBalance:
  33594. return m.AddedAccountBalance()
  33595. case usagestatisticmonth.FieldConsumeToken:
  33596. return m.AddedConsumeToken()
  33597. case usagestatisticmonth.FieldActiveUser:
  33598. return m.AddedActiveUser()
  33599. case usagestatisticmonth.FieldNewUser:
  33600. return m.AddedNewUser()
  33601. }
  33602. return nil, false
  33603. }
  33604. // AddField adds the value to the field with the given name. It returns an error if
  33605. // the field is not defined in the schema, or if the type mismatched the field
  33606. // type.
  33607. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  33608. switch name {
  33609. case usagestatisticmonth.FieldStatus:
  33610. v, ok := value.(int8)
  33611. if !ok {
  33612. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33613. }
  33614. m.AddStatus(v)
  33615. return nil
  33616. case usagestatisticmonth.FieldAddtime:
  33617. v, ok := value.(int64)
  33618. if !ok {
  33619. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33620. }
  33621. m.AddAddtime(v)
  33622. return nil
  33623. case usagestatisticmonth.FieldType:
  33624. v, ok := value.(int)
  33625. if !ok {
  33626. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33627. }
  33628. m.AddType(v)
  33629. return nil
  33630. case usagestatisticmonth.FieldOrganizationID:
  33631. v, ok := value.(int64)
  33632. if !ok {
  33633. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33634. }
  33635. m.AddOrganizationID(v)
  33636. return nil
  33637. case usagestatisticmonth.FieldAiResponse:
  33638. v, ok := value.(int64)
  33639. if !ok {
  33640. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33641. }
  33642. m.AddAiResponse(v)
  33643. return nil
  33644. case usagestatisticmonth.FieldSopRun:
  33645. v, ok := value.(int64)
  33646. if !ok {
  33647. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33648. }
  33649. m.AddSopRun(v)
  33650. return nil
  33651. case usagestatisticmonth.FieldTotalFriend:
  33652. v, ok := value.(int64)
  33653. if !ok {
  33654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33655. }
  33656. m.AddTotalFriend(v)
  33657. return nil
  33658. case usagestatisticmonth.FieldTotalGroup:
  33659. v, ok := value.(int64)
  33660. if !ok {
  33661. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33662. }
  33663. m.AddTotalGroup(v)
  33664. return nil
  33665. case usagestatisticmonth.FieldAccountBalance:
  33666. v, ok := value.(int64)
  33667. if !ok {
  33668. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33669. }
  33670. m.AddAccountBalance(v)
  33671. return nil
  33672. case usagestatisticmonth.FieldConsumeToken:
  33673. v, ok := value.(int64)
  33674. if !ok {
  33675. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33676. }
  33677. m.AddConsumeToken(v)
  33678. return nil
  33679. case usagestatisticmonth.FieldActiveUser:
  33680. v, ok := value.(int64)
  33681. if !ok {
  33682. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33683. }
  33684. m.AddActiveUser(v)
  33685. return nil
  33686. case usagestatisticmonth.FieldNewUser:
  33687. v, ok := value.(int64)
  33688. if !ok {
  33689. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33690. }
  33691. m.AddNewUser(v)
  33692. return nil
  33693. }
  33694. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  33695. }
  33696. // ClearedFields returns all nullable fields that were cleared during this
  33697. // mutation.
  33698. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  33699. var fields []string
  33700. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  33701. fields = append(fields, usagestatisticmonth.FieldStatus)
  33702. }
  33703. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  33704. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  33705. }
  33706. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  33707. fields = append(fields, usagestatisticmonth.FieldBotID)
  33708. }
  33709. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  33710. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  33711. }
  33712. return fields
  33713. }
  33714. // FieldCleared returns a boolean indicating if a field with the given name was
  33715. // cleared in this mutation.
  33716. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  33717. _, ok := m.clearedFields[name]
  33718. return ok
  33719. }
  33720. // ClearField clears the value of the field with the given name. It returns an
  33721. // error if the field is not defined in the schema.
  33722. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  33723. switch name {
  33724. case usagestatisticmonth.FieldStatus:
  33725. m.ClearStatus()
  33726. return nil
  33727. case usagestatisticmonth.FieldDeletedAt:
  33728. m.ClearDeletedAt()
  33729. return nil
  33730. case usagestatisticmonth.FieldBotID:
  33731. m.ClearBotID()
  33732. return nil
  33733. case usagestatisticmonth.FieldOrganizationID:
  33734. m.ClearOrganizationID()
  33735. return nil
  33736. }
  33737. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  33738. }
  33739. // ResetField resets all changes in the mutation for the field with the given name.
  33740. // It returns an error if the field is not defined in the schema.
  33741. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  33742. switch name {
  33743. case usagestatisticmonth.FieldCreatedAt:
  33744. m.ResetCreatedAt()
  33745. return nil
  33746. case usagestatisticmonth.FieldUpdatedAt:
  33747. m.ResetUpdatedAt()
  33748. return nil
  33749. case usagestatisticmonth.FieldStatus:
  33750. m.ResetStatus()
  33751. return nil
  33752. case usagestatisticmonth.FieldDeletedAt:
  33753. m.ResetDeletedAt()
  33754. return nil
  33755. case usagestatisticmonth.FieldAddtime:
  33756. m.ResetAddtime()
  33757. return nil
  33758. case usagestatisticmonth.FieldType:
  33759. m.ResetType()
  33760. return nil
  33761. case usagestatisticmonth.FieldBotID:
  33762. m.ResetBotID()
  33763. return nil
  33764. case usagestatisticmonth.FieldOrganizationID:
  33765. m.ResetOrganizationID()
  33766. return nil
  33767. case usagestatisticmonth.FieldAiResponse:
  33768. m.ResetAiResponse()
  33769. return nil
  33770. case usagestatisticmonth.FieldSopRun:
  33771. m.ResetSopRun()
  33772. return nil
  33773. case usagestatisticmonth.FieldTotalFriend:
  33774. m.ResetTotalFriend()
  33775. return nil
  33776. case usagestatisticmonth.FieldTotalGroup:
  33777. m.ResetTotalGroup()
  33778. return nil
  33779. case usagestatisticmonth.FieldAccountBalance:
  33780. m.ResetAccountBalance()
  33781. return nil
  33782. case usagestatisticmonth.FieldConsumeToken:
  33783. m.ResetConsumeToken()
  33784. return nil
  33785. case usagestatisticmonth.FieldActiveUser:
  33786. m.ResetActiveUser()
  33787. return nil
  33788. case usagestatisticmonth.FieldNewUser:
  33789. m.ResetNewUser()
  33790. return nil
  33791. case usagestatisticmonth.FieldLabelDist:
  33792. m.ResetLabelDist()
  33793. return nil
  33794. }
  33795. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  33796. }
  33797. // AddedEdges returns all edge names that were set/added in this mutation.
  33798. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  33799. edges := make([]string, 0, 0)
  33800. return edges
  33801. }
  33802. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33803. // name in this mutation.
  33804. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  33805. return nil
  33806. }
  33807. // RemovedEdges returns all edge names that were removed in this mutation.
  33808. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  33809. edges := make([]string, 0, 0)
  33810. return edges
  33811. }
  33812. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33813. // the given name in this mutation.
  33814. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  33815. return nil
  33816. }
  33817. // ClearedEdges returns all edge names that were cleared in this mutation.
  33818. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  33819. edges := make([]string, 0, 0)
  33820. return edges
  33821. }
  33822. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33823. // was cleared in this mutation.
  33824. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  33825. return false
  33826. }
  33827. // ClearEdge clears the value of the edge with the given name. It returns an error
  33828. // if that edge is not defined in the schema.
  33829. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  33830. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  33831. }
  33832. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33833. // It returns an error if the edge is not defined in the schema.
  33834. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  33835. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  33836. }
  33837. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  33838. type UsageTotalMutation struct {
  33839. config
  33840. op Op
  33841. typ string
  33842. id *uint64
  33843. created_at *time.Time
  33844. updated_at *time.Time
  33845. status *uint8
  33846. addstatus *int8
  33847. _type *int
  33848. add_type *int
  33849. bot_id *string
  33850. total_tokens *uint64
  33851. addtotal_tokens *int64
  33852. start_index *uint64
  33853. addstart_index *int64
  33854. end_index *uint64
  33855. addend_index *int64
  33856. organization_id *uint64
  33857. addorganization_id *int64
  33858. clearedFields map[string]struct{}
  33859. done bool
  33860. oldValue func(context.Context) (*UsageTotal, error)
  33861. predicates []predicate.UsageTotal
  33862. }
  33863. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  33864. // usagetotalOption allows management of the mutation configuration using functional options.
  33865. type usagetotalOption func(*UsageTotalMutation)
  33866. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  33867. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  33868. m := &UsageTotalMutation{
  33869. config: c,
  33870. op: op,
  33871. typ: TypeUsageTotal,
  33872. clearedFields: make(map[string]struct{}),
  33873. }
  33874. for _, opt := range opts {
  33875. opt(m)
  33876. }
  33877. return m
  33878. }
  33879. // withUsageTotalID sets the ID field of the mutation.
  33880. func withUsageTotalID(id uint64) usagetotalOption {
  33881. return func(m *UsageTotalMutation) {
  33882. var (
  33883. err error
  33884. once sync.Once
  33885. value *UsageTotal
  33886. )
  33887. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  33888. once.Do(func() {
  33889. if m.done {
  33890. err = errors.New("querying old values post mutation is not allowed")
  33891. } else {
  33892. value, err = m.Client().UsageTotal.Get(ctx, id)
  33893. }
  33894. })
  33895. return value, err
  33896. }
  33897. m.id = &id
  33898. }
  33899. }
  33900. // withUsageTotal sets the old UsageTotal of the mutation.
  33901. func withUsageTotal(node *UsageTotal) usagetotalOption {
  33902. return func(m *UsageTotalMutation) {
  33903. m.oldValue = func(context.Context) (*UsageTotal, error) {
  33904. return node, nil
  33905. }
  33906. m.id = &node.ID
  33907. }
  33908. }
  33909. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33910. // executed in a transaction (ent.Tx), a transactional client is returned.
  33911. func (m UsageTotalMutation) Client() *Client {
  33912. client := &Client{config: m.config}
  33913. client.init()
  33914. return client
  33915. }
  33916. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33917. // it returns an error otherwise.
  33918. func (m UsageTotalMutation) Tx() (*Tx, error) {
  33919. if _, ok := m.driver.(*txDriver); !ok {
  33920. return nil, errors.New("ent: mutation is not running in a transaction")
  33921. }
  33922. tx := &Tx{config: m.config}
  33923. tx.init()
  33924. return tx, nil
  33925. }
  33926. // SetID sets the value of the id field. Note that this
  33927. // operation is only accepted on creation of UsageTotal entities.
  33928. func (m *UsageTotalMutation) SetID(id uint64) {
  33929. m.id = &id
  33930. }
  33931. // ID returns the ID value in the mutation. Note that the ID is only available
  33932. // if it was provided to the builder or after it was returned from the database.
  33933. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  33934. if m.id == nil {
  33935. return
  33936. }
  33937. return *m.id, true
  33938. }
  33939. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33940. // That means, if the mutation is applied within a transaction with an isolation level such
  33941. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33942. // or updated by the mutation.
  33943. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  33944. switch {
  33945. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33946. id, exists := m.ID()
  33947. if exists {
  33948. return []uint64{id}, nil
  33949. }
  33950. fallthrough
  33951. case m.op.Is(OpUpdate | OpDelete):
  33952. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  33953. default:
  33954. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  33955. }
  33956. }
  33957. // SetCreatedAt sets the "created_at" field.
  33958. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  33959. m.created_at = &t
  33960. }
  33961. // CreatedAt returns the value of the "created_at" field in the mutation.
  33962. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  33963. v := m.created_at
  33964. if v == nil {
  33965. return
  33966. }
  33967. return *v, true
  33968. }
  33969. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  33970. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33971. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33972. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  33973. if !m.op.Is(OpUpdateOne) {
  33974. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  33975. }
  33976. if m.id == nil || m.oldValue == nil {
  33977. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  33978. }
  33979. oldValue, err := m.oldValue(ctx)
  33980. if err != nil {
  33981. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  33982. }
  33983. return oldValue.CreatedAt, nil
  33984. }
  33985. // ResetCreatedAt resets all changes to the "created_at" field.
  33986. func (m *UsageTotalMutation) ResetCreatedAt() {
  33987. m.created_at = nil
  33988. }
  33989. // SetUpdatedAt sets the "updated_at" field.
  33990. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  33991. m.updated_at = &t
  33992. }
  33993. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  33994. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  33995. v := m.updated_at
  33996. if v == nil {
  33997. return
  33998. }
  33999. return *v, true
  34000. }
  34001. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  34002. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34003. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34004. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  34005. if !m.op.Is(OpUpdateOne) {
  34006. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  34007. }
  34008. if m.id == nil || m.oldValue == nil {
  34009. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  34010. }
  34011. oldValue, err := m.oldValue(ctx)
  34012. if err != nil {
  34013. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  34014. }
  34015. return oldValue.UpdatedAt, nil
  34016. }
  34017. // ResetUpdatedAt resets all changes to the "updated_at" field.
  34018. func (m *UsageTotalMutation) ResetUpdatedAt() {
  34019. m.updated_at = nil
  34020. }
  34021. // SetStatus sets the "status" field.
  34022. func (m *UsageTotalMutation) SetStatus(u uint8) {
  34023. m.status = &u
  34024. m.addstatus = nil
  34025. }
  34026. // Status returns the value of the "status" field in the mutation.
  34027. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  34028. v := m.status
  34029. if v == nil {
  34030. return
  34031. }
  34032. return *v, true
  34033. }
  34034. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  34035. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34036. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34037. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  34038. if !m.op.Is(OpUpdateOne) {
  34039. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  34040. }
  34041. if m.id == nil || m.oldValue == nil {
  34042. return v, errors.New("OldStatus requires an ID field in the mutation")
  34043. }
  34044. oldValue, err := m.oldValue(ctx)
  34045. if err != nil {
  34046. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  34047. }
  34048. return oldValue.Status, nil
  34049. }
  34050. // AddStatus adds u to the "status" field.
  34051. func (m *UsageTotalMutation) AddStatus(u int8) {
  34052. if m.addstatus != nil {
  34053. *m.addstatus += u
  34054. } else {
  34055. m.addstatus = &u
  34056. }
  34057. }
  34058. // AddedStatus returns the value that was added to the "status" field in this mutation.
  34059. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  34060. v := m.addstatus
  34061. if v == nil {
  34062. return
  34063. }
  34064. return *v, true
  34065. }
  34066. // ClearStatus clears the value of the "status" field.
  34067. func (m *UsageTotalMutation) ClearStatus() {
  34068. m.status = nil
  34069. m.addstatus = nil
  34070. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  34071. }
  34072. // StatusCleared returns if the "status" field was cleared in this mutation.
  34073. func (m *UsageTotalMutation) StatusCleared() bool {
  34074. _, ok := m.clearedFields[usagetotal.FieldStatus]
  34075. return ok
  34076. }
  34077. // ResetStatus resets all changes to the "status" field.
  34078. func (m *UsageTotalMutation) ResetStatus() {
  34079. m.status = nil
  34080. m.addstatus = nil
  34081. delete(m.clearedFields, usagetotal.FieldStatus)
  34082. }
  34083. // SetType sets the "type" field.
  34084. func (m *UsageTotalMutation) SetType(i int) {
  34085. m._type = &i
  34086. m.add_type = nil
  34087. }
  34088. // GetType returns the value of the "type" field in the mutation.
  34089. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  34090. v := m._type
  34091. if v == nil {
  34092. return
  34093. }
  34094. return *v, true
  34095. }
  34096. // OldType returns the old "type" field's value of the UsageTotal entity.
  34097. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34098. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34099. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  34100. if !m.op.Is(OpUpdateOne) {
  34101. return v, errors.New("OldType is only allowed on UpdateOne operations")
  34102. }
  34103. if m.id == nil || m.oldValue == nil {
  34104. return v, errors.New("OldType requires an ID field in the mutation")
  34105. }
  34106. oldValue, err := m.oldValue(ctx)
  34107. if err != nil {
  34108. return v, fmt.Errorf("querying old value for OldType: %w", err)
  34109. }
  34110. return oldValue.Type, nil
  34111. }
  34112. // AddType adds i to the "type" field.
  34113. func (m *UsageTotalMutation) AddType(i int) {
  34114. if m.add_type != nil {
  34115. *m.add_type += i
  34116. } else {
  34117. m.add_type = &i
  34118. }
  34119. }
  34120. // AddedType returns the value that was added to the "type" field in this mutation.
  34121. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  34122. v := m.add_type
  34123. if v == nil {
  34124. return
  34125. }
  34126. return *v, true
  34127. }
  34128. // ClearType clears the value of the "type" field.
  34129. func (m *UsageTotalMutation) ClearType() {
  34130. m._type = nil
  34131. m.add_type = nil
  34132. m.clearedFields[usagetotal.FieldType] = struct{}{}
  34133. }
  34134. // TypeCleared returns if the "type" field was cleared in this mutation.
  34135. func (m *UsageTotalMutation) TypeCleared() bool {
  34136. _, ok := m.clearedFields[usagetotal.FieldType]
  34137. return ok
  34138. }
  34139. // ResetType resets all changes to the "type" field.
  34140. func (m *UsageTotalMutation) ResetType() {
  34141. m._type = nil
  34142. m.add_type = nil
  34143. delete(m.clearedFields, usagetotal.FieldType)
  34144. }
  34145. // SetBotID sets the "bot_id" field.
  34146. func (m *UsageTotalMutation) SetBotID(s string) {
  34147. m.bot_id = &s
  34148. }
  34149. // BotID returns the value of the "bot_id" field in the mutation.
  34150. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  34151. v := m.bot_id
  34152. if v == nil {
  34153. return
  34154. }
  34155. return *v, true
  34156. }
  34157. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  34158. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34159. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34160. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  34161. if !m.op.Is(OpUpdateOne) {
  34162. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  34163. }
  34164. if m.id == nil || m.oldValue == nil {
  34165. return v, errors.New("OldBotID requires an ID field in the mutation")
  34166. }
  34167. oldValue, err := m.oldValue(ctx)
  34168. if err != nil {
  34169. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  34170. }
  34171. return oldValue.BotID, nil
  34172. }
  34173. // ResetBotID resets all changes to the "bot_id" field.
  34174. func (m *UsageTotalMutation) ResetBotID() {
  34175. m.bot_id = nil
  34176. }
  34177. // SetTotalTokens sets the "total_tokens" field.
  34178. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  34179. m.total_tokens = &u
  34180. m.addtotal_tokens = nil
  34181. }
  34182. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  34183. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  34184. v := m.total_tokens
  34185. if v == nil {
  34186. return
  34187. }
  34188. return *v, true
  34189. }
  34190. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  34191. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34192. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34193. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  34194. if !m.op.Is(OpUpdateOne) {
  34195. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  34196. }
  34197. if m.id == nil || m.oldValue == nil {
  34198. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  34199. }
  34200. oldValue, err := m.oldValue(ctx)
  34201. if err != nil {
  34202. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  34203. }
  34204. return oldValue.TotalTokens, nil
  34205. }
  34206. // AddTotalTokens adds u to the "total_tokens" field.
  34207. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  34208. if m.addtotal_tokens != nil {
  34209. *m.addtotal_tokens += u
  34210. } else {
  34211. m.addtotal_tokens = &u
  34212. }
  34213. }
  34214. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  34215. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  34216. v := m.addtotal_tokens
  34217. if v == nil {
  34218. return
  34219. }
  34220. return *v, true
  34221. }
  34222. // ClearTotalTokens clears the value of the "total_tokens" field.
  34223. func (m *UsageTotalMutation) ClearTotalTokens() {
  34224. m.total_tokens = nil
  34225. m.addtotal_tokens = nil
  34226. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  34227. }
  34228. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  34229. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  34230. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  34231. return ok
  34232. }
  34233. // ResetTotalTokens resets all changes to the "total_tokens" field.
  34234. func (m *UsageTotalMutation) ResetTotalTokens() {
  34235. m.total_tokens = nil
  34236. m.addtotal_tokens = nil
  34237. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  34238. }
  34239. // SetStartIndex sets the "start_index" field.
  34240. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  34241. m.start_index = &u
  34242. m.addstart_index = nil
  34243. }
  34244. // StartIndex returns the value of the "start_index" field in the mutation.
  34245. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  34246. v := m.start_index
  34247. if v == nil {
  34248. return
  34249. }
  34250. return *v, true
  34251. }
  34252. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  34253. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34255. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  34256. if !m.op.Is(OpUpdateOne) {
  34257. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  34258. }
  34259. if m.id == nil || m.oldValue == nil {
  34260. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  34261. }
  34262. oldValue, err := m.oldValue(ctx)
  34263. if err != nil {
  34264. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  34265. }
  34266. return oldValue.StartIndex, nil
  34267. }
  34268. // AddStartIndex adds u to the "start_index" field.
  34269. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  34270. if m.addstart_index != nil {
  34271. *m.addstart_index += u
  34272. } else {
  34273. m.addstart_index = &u
  34274. }
  34275. }
  34276. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  34277. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  34278. v := m.addstart_index
  34279. if v == nil {
  34280. return
  34281. }
  34282. return *v, true
  34283. }
  34284. // ClearStartIndex clears the value of the "start_index" field.
  34285. func (m *UsageTotalMutation) ClearStartIndex() {
  34286. m.start_index = nil
  34287. m.addstart_index = nil
  34288. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  34289. }
  34290. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  34291. func (m *UsageTotalMutation) StartIndexCleared() bool {
  34292. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  34293. return ok
  34294. }
  34295. // ResetStartIndex resets all changes to the "start_index" field.
  34296. func (m *UsageTotalMutation) ResetStartIndex() {
  34297. m.start_index = nil
  34298. m.addstart_index = nil
  34299. delete(m.clearedFields, usagetotal.FieldStartIndex)
  34300. }
  34301. // SetEndIndex sets the "end_index" field.
  34302. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  34303. m.end_index = &u
  34304. m.addend_index = nil
  34305. }
  34306. // EndIndex returns the value of the "end_index" field in the mutation.
  34307. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  34308. v := m.end_index
  34309. if v == nil {
  34310. return
  34311. }
  34312. return *v, true
  34313. }
  34314. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  34315. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34316. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34317. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  34318. if !m.op.Is(OpUpdateOne) {
  34319. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  34320. }
  34321. if m.id == nil || m.oldValue == nil {
  34322. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  34323. }
  34324. oldValue, err := m.oldValue(ctx)
  34325. if err != nil {
  34326. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  34327. }
  34328. return oldValue.EndIndex, nil
  34329. }
  34330. // AddEndIndex adds u to the "end_index" field.
  34331. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  34332. if m.addend_index != nil {
  34333. *m.addend_index += u
  34334. } else {
  34335. m.addend_index = &u
  34336. }
  34337. }
  34338. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  34339. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  34340. v := m.addend_index
  34341. if v == nil {
  34342. return
  34343. }
  34344. return *v, true
  34345. }
  34346. // ClearEndIndex clears the value of the "end_index" field.
  34347. func (m *UsageTotalMutation) ClearEndIndex() {
  34348. m.end_index = nil
  34349. m.addend_index = nil
  34350. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  34351. }
  34352. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  34353. func (m *UsageTotalMutation) EndIndexCleared() bool {
  34354. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  34355. return ok
  34356. }
  34357. // ResetEndIndex resets all changes to the "end_index" field.
  34358. func (m *UsageTotalMutation) ResetEndIndex() {
  34359. m.end_index = nil
  34360. m.addend_index = nil
  34361. delete(m.clearedFields, usagetotal.FieldEndIndex)
  34362. }
  34363. // SetOrganizationID sets the "organization_id" field.
  34364. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  34365. m.organization_id = &u
  34366. m.addorganization_id = nil
  34367. }
  34368. // OrganizationID returns the value of the "organization_id" field in the mutation.
  34369. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  34370. v := m.organization_id
  34371. if v == nil {
  34372. return
  34373. }
  34374. return *v, true
  34375. }
  34376. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  34377. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34378. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34379. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  34380. if !m.op.Is(OpUpdateOne) {
  34381. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  34382. }
  34383. if m.id == nil || m.oldValue == nil {
  34384. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  34385. }
  34386. oldValue, err := m.oldValue(ctx)
  34387. if err != nil {
  34388. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  34389. }
  34390. return oldValue.OrganizationID, nil
  34391. }
  34392. // AddOrganizationID adds u to the "organization_id" field.
  34393. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  34394. if m.addorganization_id != nil {
  34395. *m.addorganization_id += u
  34396. } else {
  34397. m.addorganization_id = &u
  34398. }
  34399. }
  34400. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  34401. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  34402. v := m.addorganization_id
  34403. if v == nil {
  34404. return
  34405. }
  34406. return *v, true
  34407. }
  34408. // ClearOrganizationID clears the value of the "organization_id" field.
  34409. func (m *UsageTotalMutation) ClearOrganizationID() {
  34410. m.organization_id = nil
  34411. m.addorganization_id = nil
  34412. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  34413. }
  34414. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  34415. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  34416. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  34417. return ok
  34418. }
  34419. // ResetOrganizationID resets all changes to the "organization_id" field.
  34420. func (m *UsageTotalMutation) ResetOrganizationID() {
  34421. m.organization_id = nil
  34422. m.addorganization_id = nil
  34423. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  34424. }
  34425. // Where appends a list predicates to the UsageTotalMutation builder.
  34426. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  34427. m.predicates = append(m.predicates, ps...)
  34428. }
  34429. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  34430. // users can use type-assertion to append predicates that do not depend on any generated package.
  34431. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  34432. p := make([]predicate.UsageTotal, len(ps))
  34433. for i := range ps {
  34434. p[i] = ps[i]
  34435. }
  34436. m.Where(p...)
  34437. }
  34438. // Op returns the operation name.
  34439. func (m *UsageTotalMutation) Op() Op {
  34440. return m.op
  34441. }
  34442. // SetOp allows setting the mutation operation.
  34443. func (m *UsageTotalMutation) SetOp(op Op) {
  34444. m.op = op
  34445. }
  34446. // Type returns the node type of this mutation (UsageTotal).
  34447. func (m *UsageTotalMutation) Type() string {
  34448. return m.typ
  34449. }
  34450. // Fields returns all fields that were changed during this mutation. Note that in
  34451. // order to get all numeric fields that were incremented/decremented, call
  34452. // AddedFields().
  34453. func (m *UsageTotalMutation) Fields() []string {
  34454. fields := make([]string, 0, 9)
  34455. if m.created_at != nil {
  34456. fields = append(fields, usagetotal.FieldCreatedAt)
  34457. }
  34458. if m.updated_at != nil {
  34459. fields = append(fields, usagetotal.FieldUpdatedAt)
  34460. }
  34461. if m.status != nil {
  34462. fields = append(fields, usagetotal.FieldStatus)
  34463. }
  34464. if m._type != nil {
  34465. fields = append(fields, usagetotal.FieldType)
  34466. }
  34467. if m.bot_id != nil {
  34468. fields = append(fields, usagetotal.FieldBotID)
  34469. }
  34470. if m.total_tokens != nil {
  34471. fields = append(fields, usagetotal.FieldTotalTokens)
  34472. }
  34473. if m.start_index != nil {
  34474. fields = append(fields, usagetotal.FieldStartIndex)
  34475. }
  34476. if m.end_index != nil {
  34477. fields = append(fields, usagetotal.FieldEndIndex)
  34478. }
  34479. if m.organization_id != nil {
  34480. fields = append(fields, usagetotal.FieldOrganizationID)
  34481. }
  34482. return fields
  34483. }
  34484. // Field returns the value of a field with the given name. The second boolean
  34485. // return value indicates that this field was not set, or was not defined in the
  34486. // schema.
  34487. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  34488. switch name {
  34489. case usagetotal.FieldCreatedAt:
  34490. return m.CreatedAt()
  34491. case usagetotal.FieldUpdatedAt:
  34492. return m.UpdatedAt()
  34493. case usagetotal.FieldStatus:
  34494. return m.Status()
  34495. case usagetotal.FieldType:
  34496. return m.GetType()
  34497. case usagetotal.FieldBotID:
  34498. return m.BotID()
  34499. case usagetotal.FieldTotalTokens:
  34500. return m.TotalTokens()
  34501. case usagetotal.FieldStartIndex:
  34502. return m.StartIndex()
  34503. case usagetotal.FieldEndIndex:
  34504. return m.EndIndex()
  34505. case usagetotal.FieldOrganizationID:
  34506. return m.OrganizationID()
  34507. }
  34508. return nil, false
  34509. }
  34510. // OldField returns the old value of the field from the database. An error is
  34511. // returned if the mutation operation is not UpdateOne, or the query to the
  34512. // database failed.
  34513. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34514. switch name {
  34515. case usagetotal.FieldCreatedAt:
  34516. return m.OldCreatedAt(ctx)
  34517. case usagetotal.FieldUpdatedAt:
  34518. return m.OldUpdatedAt(ctx)
  34519. case usagetotal.FieldStatus:
  34520. return m.OldStatus(ctx)
  34521. case usagetotal.FieldType:
  34522. return m.OldType(ctx)
  34523. case usagetotal.FieldBotID:
  34524. return m.OldBotID(ctx)
  34525. case usagetotal.FieldTotalTokens:
  34526. return m.OldTotalTokens(ctx)
  34527. case usagetotal.FieldStartIndex:
  34528. return m.OldStartIndex(ctx)
  34529. case usagetotal.FieldEndIndex:
  34530. return m.OldEndIndex(ctx)
  34531. case usagetotal.FieldOrganizationID:
  34532. return m.OldOrganizationID(ctx)
  34533. }
  34534. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  34535. }
  34536. // SetField sets the value of a field with the given name. It returns an error if
  34537. // the field is not defined in the schema, or if the type mismatched the field
  34538. // type.
  34539. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  34540. switch name {
  34541. case usagetotal.FieldCreatedAt:
  34542. v, ok := value.(time.Time)
  34543. if !ok {
  34544. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34545. }
  34546. m.SetCreatedAt(v)
  34547. return nil
  34548. case usagetotal.FieldUpdatedAt:
  34549. v, ok := value.(time.Time)
  34550. if !ok {
  34551. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34552. }
  34553. m.SetUpdatedAt(v)
  34554. return nil
  34555. case usagetotal.FieldStatus:
  34556. v, ok := value.(uint8)
  34557. if !ok {
  34558. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34559. }
  34560. m.SetStatus(v)
  34561. return nil
  34562. case usagetotal.FieldType:
  34563. v, ok := value.(int)
  34564. if !ok {
  34565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34566. }
  34567. m.SetType(v)
  34568. return nil
  34569. case usagetotal.FieldBotID:
  34570. v, ok := value.(string)
  34571. if !ok {
  34572. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34573. }
  34574. m.SetBotID(v)
  34575. return nil
  34576. case usagetotal.FieldTotalTokens:
  34577. v, ok := value.(uint64)
  34578. if !ok {
  34579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34580. }
  34581. m.SetTotalTokens(v)
  34582. return nil
  34583. case usagetotal.FieldStartIndex:
  34584. v, ok := value.(uint64)
  34585. if !ok {
  34586. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34587. }
  34588. m.SetStartIndex(v)
  34589. return nil
  34590. case usagetotal.FieldEndIndex:
  34591. v, ok := value.(uint64)
  34592. if !ok {
  34593. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34594. }
  34595. m.SetEndIndex(v)
  34596. return nil
  34597. case usagetotal.FieldOrganizationID:
  34598. v, ok := value.(uint64)
  34599. if !ok {
  34600. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34601. }
  34602. m.SetOrganizationID(v)
  34603. return nil
  34604. }
  34605. return fmt.Errorf("unknown UsageTotal field %s", name)
  34606. }
  34607. // AddedFields returns all numeric fields that were incremented/decremented during
  34608. // this mutation.
  34609. func (m *UsageTotalMutation) AddedFields() []string {
  34610. var fields []string
  34611. if m.addstatus != nil {
  34612. fields = append(fields, usagetotal.FieldStatus)
  34613. }
  34614. if m.add_type != nil {
  34615. fields = append(fields, usagetotal.FieldType)
  34616. }
  34617. if m.addtotal_tokens != nil {
  34618. fields = append(fields, usagetotal.FieldTotalTokens)
  34619. }
  34620. if m.addstart_index != nil {
  34621. fields = append(fields, usagetotal.FieldStartIndex)
  34622. }
  34623. if m.addend_index != nil {
  34624. fields = append(fields, usagetotal.FieldEndIndex)
  34625. }
  34626. if m.addorganization_id != nil {
  34627. fields = append(fields, usagetotal.FieldOrganizationID)
  34628. }
  34629. return fields
  34630. }
  34631. // AddedField returns the numeric value that was incremented/decremented on a field
  34632. // with the given name. The second boolean return value indicates that this field
  34633. // was not set, or was not defined in the schema.
  34634. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  34635. switch name {
  34636. case usagetotal.FieldStatus:
  34637. return m.AddedStatus()
  34638. case usagetotal.FieldType:
  34639. return m.AddedType()
  34640. case usagetotal.FieldTotalTokens:
  34641. return m.AddedTotalTokens()
  34642. case usagetotal.FieldStartIndex:
  34643. return m.AddedStartIndex()
  34644. case usagetotal.FieldEndIndex:
  34645. return m.AddedEndIndex()
  34646. case usagetotal.FieldOrganizationID:
  34647. return m.AddedOrganizationID()
  34648. }
  34649. return nil, false
  34650. }
  34651. // AddField adds the value to the field with the given name. It returns an error if
  34652. // the field is not defined in the schema, or if the type mismatched the field
  34653. // type.
  34654. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  34655. switch name {
  34656. case usagetotal.FieldStatus:
  34657. v, ok := value.(int8)
  34658. if !ok {
  34659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34660. }
  34661. m.AddStatus(v)
  34662. return nil
  34663. case usagetotal.FieldType:
  34664. v, ok := value.(int)
  34665. if !ok {
  34666. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34667. }
  34668. m.AddType(v)
  34669. return nil
  34670. case usagetotal.FieldTotalTokens:
  34671. v, ok := value.(int64)
  34672. if !ok {
  34673. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34674. }
  34675. m.AddTotalTokens(v)
  34676. return nil
  34677. case usagetotal.FieldStartIndex:
  34678. v, ok := value.(int64)
  34679. if !ok {
  34680. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34681. }
  34682. m.AddStartIndex(v)
  34683. return nil
  34684. case usagetotal.FieldEndIndex:
  34685. v, ok := value.(int64)
  34686. if !ok {
  34687. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34688. }
  34689. m.AddEndIndex(v)
  34690. return nil
  34691. case usagetotal.FieldOrganizationID:
  34692. v, ok := value.(int64)
  34693. if !ok {
  34694. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34695. }
  34696. m.AddOrganizationID(v)
  34697. return nil
  34698. }
  34699. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  34700. }
  34701. // ClearedFields returns all nullable fields that were cleared during this
  34702. // mutation.
  34703. func (m *UsageTotalMutation) ClearedFields() []string {
  34704. var fields []string
  34705. if m.FieldCleared(usagetotal.FieldStatus) {
  34706. fields = append(fields, usagetotal.FieldStatus)
  34707. }
  34708. if m.FieldCleared(usagetotal.FieldType) {
  34709. fields = append(fields, usagetotal.FieldType)
  34710. }
  34711. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  34712. fields = append(fields, usagetotal.FieldTotalTokens)
  34713. }
  34714. if m.FieldCleared(usagetotal.FieldStartIndex) {
  34715. fields = append(fields, usagetotal.FieldStartIndex)
  34716. }
  34717. if m.FieldCleared(usagetotal.FieldEndIndex) {
  34718. fields = append(fields, usagetotal.FieldEndIndex)
  34719. }
  34720. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  34721. fields = append(fields, usagetotal.FieldOrganizationID)
  34722. }
  34723. return fields
  34724. }
  34725. // FieldCleared returns a boolean indicating if a field with the given name was
  34726. // cleared in this mutation.
  34727. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  34728. _, ok := m.clearedFields[name]
  34729. return ok
  34730. }
  34731. // ClearField clears the value of the field with the given name. It returns an
  34732. // error if the field is not defined in the schema.
  34733. func (m *UsageTotalMutation) ClearField(name string) error {
  34734. switch name {
  34735. case usagetotal.FieldStatus:
  34736. m.ClearStatus()
  34737. return nil
  34738. case usagetotal.FieldType:
  34739. m.ClearType()
  34740. return nil
  34741. case usagetotal.FieldTotalTokens:
  34742. m.ClearTotalTokens()
  34743. return nil
  34744. case usagetotal.FieldStartIndex:
  34745. m.ClearStartIndex()
  34746. return nil
  34747. case usagetotal.FieldEndIndex:
  34748. m.ClearEndIndex()
  34749. return nil
  34750. case usagetotal.FieldOrganizationID:
  34751. m.ClearOrganizationID()
  34752. return nil
  34753. }
  34754. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  34755. }
  34756. // ResetField resets all changes in the mutation for the field with the given name.
  34757. // It returns an error if the field is not defined in the schema.
  34758. func (m *UsageTotalMutation) ResetField(name string) error {
  34759. switch name {
  34760. case usagetotal.FieldCreatedAt:
  34761. m.ResetCreatedAt()
  34762. return nil
  34763. case usagetotal.FieldUpdatedAt:
  34764. m.ResetUpdatedAt()
  34765. return nil
  34766. case usagetotal.FieldStatus:
  34767. m.ResetStatus()
  34768. return nil
  34769. case usagetotal.FieldType:
  34770. m.ResetType()
  34771. return nil
  34772. case usagetotal.FieldBotID:
  34773. m.ResetBotID()
  34774. return nil
  34775. case usagetotal.FieldTotalTokens:
  34776. m.ResetTotalTokens()
  34777. return nil
  34778. case usagetotal.FieldStartIndex:
  34779. m.ResetStartIndex()
  34780. return nil
  34781. case usagetotal.FieldEndIndex:
  34782. m.ResetEndIndex()
  34783. return nil
  34784. case usagetotal.FieldOrganizationID:
  34785. m.ResetOrganizationID()
  34786. return nil
  34787. }
  34788. return fmt.Errorf("unknown UsageTotal field %s", name)
  34789. }
  34790. // AddedEdges returns all edge names that were set/added in this mutation.
  34791. func (m *UsageTotalMutation) AddedEdges() []string {
  34792. edges := make([]string, 0, 0)
  34793. return edges
  34794. }
  34795. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  34796. // name in this mutation.
  34797. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  34798. return nil
  34799. }
  34800. // RemovedEdges returns all edge names that were removed in this mutation.
  34801. func (m *UsageTotalMutation) RemovedEdges() []string {
  34802. edges := make([]string, 0, 0)
  34803. return edges
  34804. }
  34805. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  34806. // the given name in this mutation.
  34807. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  34808. return nil
  34809. }
  34810. // ClearedEdges returns all edge names that were cleared in this mutation.
  34811. func (m *UsageTotalMutation) ClearedEdges() []string {
  34812. edges := make([]string, 0, 0)
  34813. return edges
  34814. }
  34815. // EdgeCleared returns a boolean which indicates if the edge with the given name
  34816. // was cleared in this mutation.
  34817. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  34818. return false
  34819. }
  34820. // ClearEdge clears the value of the edge with the given name. It returns an error
  34821. // if that edge is not defined in the schema.
  34822. func (m *UsageTotalMutation) ClearEdge(name string) error {
  34823. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  34824. }
  34825. // ResetEdge resets all changes to the edge with the given name in this mutation.
  34826. // It returns an error if the edge is not defined in the schema.
  34827. func (m *UsageTotalMutation) ResetEdge(name string) error {
  34828. return fmt.Errorf("unknown UsageTotal edge %s", name)
  34829. }
  34830. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  34831. type WhatsappMutation struct {
  34832. config
  34833. op Op
  34834. typ string
  34835. id *uint64
  34836. created_at *time.Time
  34837. updated_at *time.Time
  34838. status *uint8
  34839. addstatus *int8
  34840. deleted_at *time.Time
  34841. wa_id *string
  34842. wa_name *string
  34843. callback *string
  34844. account *string
  34845. cc *string
  34846. phone *string
  34847. cc_phone *string
  34848. phone_name *string
  34849. phone_status *int8
  34850. addphone_status *int8
  34851. organization_id *uint64
  34852. addorganization_id *int64
  34853. api_base *string
  34854. api_key *string
  34855. allow_list *[]string
  34856. appendallow_list []string
  34857. group_allow_list *[]string
  34858. appendgroup_allow_list []string
  34859. block_list *[]string
  34860. appendblock_list []string
  34861. group_block_list *[]string
  34862. appendgroup_block_list []string
  34863. clearedFields map[string]struct{}
  34864. agent *uint64
  34865. clearedagent bool
  34866. done bool
  34867. oldValue func(context.Context) (*Whatsapp, error)
  34868. predicates []predicate.Whatsapp
  34869. }
  34870. var _ ent.Mutation = (*WhatsappMutation)(nil)
  34871. // whatsappOption allows management of the mutation configuration using functional options.
  34872. type whatsappOption func(*WhatsappMutation)
  34873. // newWhatsappMutation creates new mutation for the Whatsapp entity.
  34874. func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
  34875. m := &WhatsappMutation{
  34876. config: c,
  34877. op: op,
  34878. typ: TypeWhatsapp,
  34879. clearedFields: make(map[string]struct{}),
  34880. }
  34881. for _, opt := range opts {
  34882. opt(m)
  34883. }
  34884. return m
  34885. }
  34886. // withWhatsappID sets the ID field of the mutation.
  34887. func withWhatsappID(id uint64) whatsappOption {
  34888. return func(m *WhatsappMutation) {
  34889. var (
  34890. err error
  34891. once sync.Once
  34892. value *Whatsapp
  34893. )
  34894. m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
  34895. once.Do(func() {
  34896. if m.done {
  34897. err = errors.New("querying old values post mutation is not allowed")
  34898. } else {
  34899. value, err = m.Client().Whatsapp.Get(ctx, id)
  34900. }
  34901. })
  34902. return value, err
  34903. }
  34904. m.id = &id
  34905. }
  34906. }
  34907. // withWhatsapp sets the old Whatsapp of the mutation.
  34908. func withWhatsapp(node *Whatsapp) whatsappOption {
  34909. return func(m *WhatsappMutation) {
  34910. m.oldValue = func(context.Context) (*Whatsapp, error) {
  34911. return node, nil
  34912. }
  34913. m.id = &node.ID
  34914. }
  34915. }
  34916. // Client returns a new `ent.Client` from the mutation. If the mutation was
  34917. // executed in a transaction (ent.Tx), a transactional client is returned.
  34918. func (m WhatsappMutation) Client() *Client {
  34919. client := &Client{config: m.config}
  34920. client.init()
  34921. return client
  34922. }
  34923. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  34924. // it returns an error otherwise.
  34925. func (m WhatsappMutation) Tx() (*Tx, error) {
  34926. if _, ok := m.driver.(*txDriver); !ok {
  34927. return nil, errors.New("ent: mutation is not running in a transaction")
  34928. }
  34929. tx := &Tx{config: m.config}
  34930. tx.init()
  34931. return tx, nil
  34932. }
  34933. // SetID sets the value of the id field. Note that this
  34934. // operation is only accepted on creation of Whatsapp entities.
  34935. func (m *WhatsappMutation) SetID(id uint64) {
  34936. m.id = &id
  34937. }
  34938. // ID returns the ID value in the mutation. Note that the ID is only available
  34939. // if it was provided to the builder or after it was returned from the database.
  34940. func (m *WhatsappMutation) ID() (id uint64, exists bool) {
  34941. if m.id == nil {
  34942. return
  34943. }
  34944. return *m.id, true
  34945. }
  34946. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  34947. // That means, if the mutation is applied within a transaction with an isolation level such
  34948. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  34949. // or updated by the mutation.
  34950. func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
  34951. switch {
  34952. case m.op.Is(OpUpdateOne | OpDeleteOne):
  34953. id, exists := m.ID()
  34954. if exists {
  34955. return []uint64{id}, nil
  34956. }
  34957. fallthrough
  34958. case m.op.Is(OpUpdate | OpDelete):
  34959. return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
  34960. default:
  34961. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  34962. }
  34963. }
  34964. // SetCreatedAt sets the "created_at" field.
  34965. func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
  34966. m.created_at = &t
  34967. }
  34968. // CreatedAt returns the value of the "created_at" field in the mutation.
  34969. func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
  34970. v := m.created_at
  34971. if v == nil {
  34972. return
  34973. }
  34974. return *v, true
  34975. }
  34976. // OldCreatedAt returns the old "created_at" field's value of the Whatsapp entity.
  34977. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34978. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34979. func (m *WhatsappMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  34980. if !m.op.Is(OpUpdateOne) {
  34981. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  34982. }
  34983. if m.id == nil || m.oldValue == nil {
  34984. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  34985. }
  34986. oldValue, err := m.oldValue(ctx)
  34987. if err != nil {
  34988. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  34989. }
  34990. return oldValue.CreatedAt, nil
  34991. }
  34992. // ResetCreatedAt resets all changes to the "created_at" field.
  34993. func (m *WhatsappMutation) ResetCreatedAt() {
  34994. m.created_at = nil
  34995. }
  34996. // SetUpdatedAt sets the "updated_at" field.
  34997. func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
  34998. m.updated_at = &t
  34999. }
  35000. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  35001. func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
  35002. v := m.updated_at
  35003. if v == nil {
  35004. return
  35005. }
  35006. return *v, true
  35007. }
  35008. // OldUpdatedAt returns the old "updated_at" field's value of the Whatsapp entity.
  35009. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35010. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35011. func (m *WhatsappMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35012. if !m.op.Is(OpUpdateOne) {
  35013. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35014. }
  35015. if m.id == nil || m.oldValue == nil {
  35016. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35017. }
  35018. oldValue, err := m.oldValue(ctx)
  35019. if err != nil {
  35020. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35021. }
  35022. return oldValue.UpdatedAt, nil
  35023. }
  35024. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35025. func (m *WhatsappMutation) ResetUpdatedAt() {
  35026. m.updated_at = nil
  35027. }
  35028. // SetStatus sets the "status" field.
  35029. func (m *WhatsappMutation) SetStatus(u uint8) {
  35030. m.status = &u
  35031. m.addstatus = nil
  35032. }
  35033. // Status returns the value of the "status" field in the mutation.
  35034. func (m *WhatsappMutation) Status() (r uint8, exists bool) {
  35035. v := m.status
  35036. if v == nil {
  35037. return
  35038. }
  35039. return *v, true
  35040. }
  35041. // OldStatus returns the old "status" field's value of the Whatsapp entity.
  35042. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35043. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35044. func (m *WhatsappMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  35045. if !m.op.Is(OpUpdateOne) {
  35046. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  35047. }
  35048. if m.id == nil || m.oldValue == nil {
  35049. return v, errors.New("OldStatus requires an ID field in the mutation")
  35050. }
  35051. oldValue, err := m.oldValue(ctx)
  35052. if err != nil {
  35053. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  35054. }
  35055. return oldValue.Status, nil
  35056. }
  35057. // AddStatus adds u to the "status" field.
  35058. func (m *WhatsappMutation) AddStatus(u int8) {
  35059. if m.addstatus != nil {
  35060. *m.addstatus += u
  35061. } else {
  35062. m.addstatus = &u
  35063. }
  35064. }
  35065. // AddedStatus returns the value that was added to the "status" field in this mutation.
  35066. func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
  35067. v := m.addstatus
  35068. if v == nil {
  35069. return
  35070. }
  35071. return *v, true
  35072. }
  35073. // ClearStatus clears the value of the "status" field.
  35074. func (m *WhatsappMutation) ClearStatus() {
  35075. m.status = nil
  35076. m.addstatus = nil
  35077. m.clearedFields[whatsapp.FieldStatus] = struct{}{}
  35078. }
  35079. // StatusCleared returns if the "status" field was cleared in this mutation.
  35080. func (m *WhatsappMutation) StatusCleared() bool {
  35081. _, ok := m.clearedFields[whatsapp.FieldStatus]
  35082. return ok
  35083. }
  35084. // ResetStatus resets all changes to the "status" field.
  35085. func (m *WhatsappMutation) ResetStatus() {
  35086. m.status = nil
  35087. m.addstatus = nil
  35088. delete(m.clearedFields, whatsapp.FieldStatus)
  35089. }
  35090. // SetDeletedAt sets the "deleted_at" field.
  35091. func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
  35092. m.deleted_at = &t
  35093. }
  35094. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  35095. func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
  35096. v := m.deleted_at
  35097. if v == nil {
  35098. return
  35099. }
  35100. return *v, true
  35101. }
  35102. // OldDeletedAt returns the old "deleted_at" field's value of the Whatsapp entity.
  35103. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35104. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35105. func (m *WhatsappMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  35106. if !m.op.Is(OpUpdateOne) {
  35107. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  35108. }
  35109. if m.id == nil || m.oldValue == nil {
  35110. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  35111. }
  35112. oldValue, err := m.oldValue(ctx)
  35113. if err != nil {
  35114. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  35115. }
  35116. return oldValue.DeletedAt, nil
  35117. }
  35118. // ClearDeletedAt clears the value of the "deleted_at" field.
  35119. func (m *WhatsappMutation) ClearDeletedAt() {
  35120. m.deleted_at = nil
  35121. m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
  35122. }
  35123. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  35124. func (m *WhatsappMutation) DeletedAtCleared() bool {
  35125. _, ok := m.clearedFields[whatsapp.FieldDeletedAt]
  35126. return ok
  35127. }
  35128. // ResetDeletedAt resets all changes to the "deleted_at" field.
  35129. func (m *WhatsappMutation) ResetDeletedAt() {
  35130. m.deleted_at = nil
  35131. delete(m.clearedFields, whatsapp.FieldDeletedAt)
  35132. }
  35133. // SetWaID sets the "wa_id" field.
  35134. func (m *WhatsappMutation) SetWaID(s string) {
  35135. m.wa_id = &s
  35136. }
  35137. // WaID returns the value of the "wa_id" field in the mutation.
  35138. func (m *WhatsappMutation) WaID() (r string, exists bool) {
  35139. v := m.wa_id
  35140. if v == nil {
  35141. return
  35142. }
  35143. return *v, true
  35144. }
  35145. // OldWaID returns the old "wa_id" field's value of the Whatsapp entity.
  35146. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35147. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35148. func (m *WhatsappMutation) OldWaID(ctx context.Context) (v string, err error) {
  35149. if !m.op.Is(OpUpdateOne) {
  35150. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  35151. }
  35152. if m.id == nil || m.oldValue == nil {
  35153. return v, errors.New("OldWaID requires an ID field in the mutation")
  35154. }
  35155. oldValue, err := m.oldValue(ctx)
  35156. if err != nil {
  35157. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  35158. }
  35159. return oldValue.WaID, nil
  35160. }
  35161. // ClearWaID clears the value of the "wa_id" field.
  35162. func (m *WhatsappMutation) ClearWaID() {
  35163. m.wa_id = nil
  35164. m.clearedFields[whatsapp.FieldWaID] = struct{}{}
  35165. }
  35166. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  35167. func (m *WhatsappMutation) WaIDCleared() bool {
  35168. _, ok := m.clearedFields[whatsapp.FieldWaID]
  35169. return ok
  35170. }
  35171. // ResetWaID resets all changes to the "wa_id" field.
  35172. func (m *WhatsappMutation) ResetWaID() {
  35173. m.wa_id = nil
  35174. delete(m.clearedFields, whatsapp.FieldWaID)
  35175. }
  35176. // SetWaName sets the "wa_name" field.
  35177. func (m *WhatsappMutation) SetWaName(s string) {
  35178. m.wa_name = &s
  35179. }
  35180. // WaName returns the value of the "wa_name" field in the mutation.
  35181. func (m *WhatsappMutation) WaName() (r string, exists bool) {
  35182. v := m.wa_name
  35183. if v == nil {
  35184. return
  35185. }
  35186. return *v, true
  35187. }
  35188. // OldWaName returns the old "wa_name" field's value of the Whatsapp entity.
  35189. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35190. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35191. func (m *WhatsappMutation) OldWaName(ctx context.Context) (v string, err error) {
  35192. if !m.op.Is(OpUpdateOne) {
  35193. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  35194. }
  35195. if m.id == nil || m.oldValue == nil {
  35196. return v, errors.New("OldWaName requires an ID field in the mutation")
  35197. }
  35198. oldValue, err := m.oldValue(ctx)
  35199. if err != nil {
  35200. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  35201. }
  35202. return oldValue.WaName, nil
  35203. }
  35204. // ClearWaName clears the value of the "wa_name" field.
  35205. func (m *WhatsappMutation) ClearWaName() {
  35206. m.wa_name = nil
  35207. m.clearedFields[whatsapp.FieldWaName] = struct{}{}
  35208. }
  35209. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  35210. func (m *WhatsappMutation) WaNameCleared() bool {
  35211. _, ok := m.clearedFields[whatsapp.FieldWaName]
  35212. return ok
  35213. }
  35214. // ResetWaName resets all changes to the "wa_name" field.
  35215. func (m *WhatsappMutation) ResetWaName() {
  35216. m.wa_name = nil
  35217. delete(m.clearedFields, whatsapp.FieldWaName)
  35218. }
  35219. // SetCallback sets the "callback" field.
  35220. func (m *WhatsappMutation) SetCallback(s string) {
  35221. m.callback = &s
  35222. }
  35223. // Callback returns the value of the "callback" field in the mutation.
  35224. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  35225. v := m.callback
  35226. if v == nil {
  35227. return
  35228. }
  35229. return *v, true
  35230. }
  35231. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  35232. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35233. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35234. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  35235. if !m.op.Is(OpUpdateOne) {
  35236. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  35237. }
  35238. if m.id == nil || m.oldValue == nil {
  35239. return v, errors.New("OldCallback requires an ID field in the mutation")
  35240. }
  35241. oldValue, err := m.oldValue(ctx)
  35242. if err != nil {
  35243. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  35244. }
  35245. return oldValue.Callback, nil
  35246. }
  35247. // ClearCallback clears the value of the "callback" field.
  35248. func (m *WhatsappMutation) ClearCallback() {
  35249. m.callback = nil
  35250. m.clearedFields[whatsapp.FieldCallback] = struct{}{}
  35251. }
  35252. // CallbackCleared returns if the "callback" field was cleared in this mutation.
  35253. func (m *WhatsappMutation) CallbackCleared() bool {
  35254. _, ok := m.clearedFields[whatsapp.FieldCallback]
  35255. return ok
  35256. }
  35257. // ResetCallback resets all changes to the "callback" field.
  35258. func (m *WhatsappMutation) ResetCallback() {
  35259. m.callback = nil
  35260. delete(m.clearedFields, whatsapp.FieldCallback)
  35261. }
  35262. // SetAgentID sets the "agent_id" field.
  35263. func (m *WhatsappMutation) SetAgentID(u uint64) {
  35264. m.agent = &u
  35265. }
  35266. // AgentID returns the value of the "agent_id" field in the mutation.
  35267. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  35268. v := m.agent
  35269. if v == nil {
  35270. return
  35271. }
  35272. return *v, true
  35273. }
  35274. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  35275. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35276. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35277. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  35278. if !m.op.Is(OpUpdateOne) {
  35279. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  35280. }
  35281. if m.id == nil || m.oldValue == nil {
  35282. return v, errors.New("OldAgentID requires an ID field in the mutation")
  35283. }
  35284. oldValue, err := m.oldValue(ctx)
  35285. if err != nil {
  35286. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  35287. }
  35288. return oldValue.AgentID, nil
  35289. }
  35290. // ResetAgentID resets all changes to the "agent_id" field.
  35291. func (m *WhatsappMutation) ResetAgentID() {
  35292. m.agent = nil
  35293. }
  35294. // SetAccount sets the "account" field.
  35295. func (m *WhatsappMutation) SetAccount(s string) {
  35296. m.account = &s
  35297. }
  35298. // Account returns the value of the "account" field in the mutation.
  35299. func (m *WhatsappMutation) Account() (r string, exists bool) {
  35300. v := m.account
  35301. if v == nil {
  35302. return
  35303. }
  35304. return *v, true
  35305. }
  35306. // OldAccount returns the old "account" field's value of the Whatsapp entity.
  35307. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35308. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35309. func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error) {
  35310. if !m.op.Is(OpUpdateOne) {
  35311. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  35312. }
  35313. if m.id == nil || m.oldValue == nil {
  35314. return v, errors.New("OldAccount requires an ID field in the mutation")
  35315. }
  35316. oldValue, err := m.oldValue(ctx)
  35317. if err != nil {
  35318. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  35319. }
  35320. return oldValue.Account, nil
  35321. }
  35322. // ClearAccount clears the value of the "account" field.
  35323. func (m *WhatsappMutation) ClearAccount() {
  35324. m.account = nil
  35325. m.clearedFields[whatsapp.FieldAccount] = struct{}{}
  35326. }
  35327. // AccountCleared returns if the "account" field was cleared in this mutation.
  35328. func (m *WhatsappMutation) AccountCleared() bool {
  35329. _, ok := m.clearedFields[whatsapp.FieldAccount]
  35330. return ok
  35331. }
  35332. // ResetAccount resets all changes to the "account" field.
  35333. func (m *WhatsappMutation) ResetAccount() {
  35334. m.account = nil
  35335. delete(m.clearedFields, whatsapp.FieldAccount)
  35336. }
  35337. // SetCc sets the "cc" field.
  35338. func (m *WhatsappMutation) SetCc(s string) {
  35339. m.cc = &s
  35340. }
  35341. // Cc returns the value of the "cc" field in the mutation.
  35342. func (m *WhatsappMutation) Cc() (r string, exists bool) {
  35343. v := m.cc
  35344. if v == nil {
  35345. return
  35346. }
  35347. return *v, true
  35348. }
  35349. // OldCc returns the old "cc" field's value of the Whatsapp entity.
  35350. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35351. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35352. func (m *WhatsappMutation) OldCc(ctx context.Context) (v string, err error) {
  35353. if !m.op.Is(OpUpdateOne) {
  35354. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  35355. }
  35356. if m.id == nil || m.oldValue == nil {
  35357. return v, errors.New("OldCc requires an ID field in the mutation")
  35358. }
  35359. oldValue, err := m.oldValue(ctx)
  35360. if err != nil {
  35361. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  35362. }
  35363. return oldValue.Cc, nil
  35364. }
  35365. // ResetCc resets all changes to the "cc" field.
  35366. func (m *WhatsappMutation) ResetCc() {
  35367. m.cc = nil
  35368. }
  35369. // SetPhone sets the "phone" field.
  35370. func (m *WhatsappMutation) SetPhone(s string) {
  35371. m.phone = &s
  35372. }
  35373. // Phone returns the value of the "phone" field in the mutation.
  35374. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  35375. v := m.phone
  35376. if v == nil {
  35377. return
  35378. }
  35379. return *v, true
  35380. }
  35381. // OldPhone returns the old "phone" field's value of the Whatsapp entity.
  35382. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35383. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35384. func (m *WhatsappMutation) OldPhone(ctx context.Context) (v string, err error) {
  35385. if !m.op.Is(OpUpdateOne) {
  35386. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  35387. }
  35388. if m.id == nil || m.oldValue == nil {
  35389. return v, errors.New("OldPhone requires an ID field in the mutation")
  35390. }
  35391. oldValue, err := m.oldValue(ctx)
  35392. if err != nil {
  35393. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  35394. }
  35395. return oldValue.Phone, nil
  35396. }
  35397. // ResetPhone resets all changes to the "phone" field.
  35398. func (m *WhatsappMutation) ResetPhone() {
  35399. m.phone = nil
  35400. }
  35401. // SetCcPhone sets the "cc_phone" field.
  35402. func (m *WhatsappMutation) SetCcPhone(s string) {
  35403. m.cc_phone = &s
  35404. }
  35405. // CcPhone returns the value of the "cc_phone" field in the mutation.
  35406. func (m *WhatsappMutation) CcPhone() (r string, exists bool) {
  35407. v := m.cc_phone
  35408. if v == nil {
  35409. return
  35410. }
  35411. return *v, true
  35412. }
  35413. // OldCcPhone returns the old "cc_phone" field's value of the Whatsapp entity.
  35414. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35415. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35416. func (m *WhatsappMutation) OldCcPhone(ctx context.Context) (v string, err error) {
  35417. if !m.op.Is(OpUpdateOne) {
  35418. return v, errors.New("OldCcPhone is only allowed on UpdateOne operations")
  35419. }
  35420. if m.id == nil || m.oldValue == nil {
  35421. return v, errors.New("OldCcPhone requires an ID field in the mutation")
  35422. }
  35423. oldValue, err := m.oldValue(ctx)
  35424. if err != nil {
  35425. return v, fmt.Errorf("querying old value for OldCcPhone: %w", err)
  35426. }
  35427. return oldValue.CcPhone, nil
  35428. }
  35429. // ResetCcPhone resets all changes to the "cc_phone" field.
  35430. func (m *WhatsappMutation) ResetCcPhone() {
  35431. m.cc_phone = nil
  35432. }
  35433. // SetPhoneName sets the "phone_name" field.
  35434. func (m *WhatsappMutation) SetPhoneName(s string) {
  35435. m.phone_name = &s
  35436. }
  35437. // PhoneName returns the value of the "phone_name" field in the mutation.
  35438. func (m *WhatsappMutation) PhoneName() (r string, exists bool) {
  35439. v := m.phone_name
  35440. if v == nil {
  35441. return
  35442. }
  35443. return *v, true
  35444. }
  35445. // OldPhoneName returns the old "phone_name" field's value of the Whatsapp entity.
  35446. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35447. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35448. func (m *WhatsappMutation) OldPhoneName(ctx context.Context) (v string, err error) {
  35449. if !m.op.Is(OpUpdateOne) {
  35450. return v, errors.New("OldPhoneName is only allowed on UpdateOne operations")
  35451. }
  35452. if m.id == nil || m.oldValue == nil {
  35453. return v, errors.New("OldPhoneName requires an ID field in the mutation")
  35454. }
  35455. oldValue, err := m.oldValue(ctx)
  35456. if err != nil {
  35457. return v, fmt.Errorf("querying old value for OldPhoneName: %w", err)
  35458. }
  35459. return oldValue.PhoneName, nil
  35460. }
  35461. // ResetPhoneName resets all changes to the "phone_name" field.
  35462. func (m *WhatsappMutation) ResetPhoneName() {
  35463. m.phone_name = nil
  35464. }
  35465. // SetPhoneStatus sets the "phone_status" field.
  35466. func (m *WhatsappMutation) SetPhoneStatus(i int8) {
  35467. m.phone_status = &i
  35468. m.addphone_status = nil
  35469. }
  35470. // PhoneStatus returns the value of the "phone_status" field in the mutation.
  35471. func (m *WhatsappMutation) PhoneStatus() (r int8, exists bool) {
  35472. v := m.phone_status
  35473. if v == nil {
  35474. return
  35475. }
  35476. return *v, true
  35477. }
  35478. // OldPhoneStatus returns the old "phone_status" field's value of the Whatsapp entity.
  35479. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35480. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35481. func (m *WhatsappMutation) OldPhoneStatus(ctx context.Context) (v int8, err error) {
  35482. if !m.op.Is(OpUpdateOne) {
  35483. return v, errors.New("OldPhoneStatus is only allowed on UpdateOne operations")
  35484. }
  35485. if m.id == nil || m.oldValue == nil {
  35486. return v, errors.New("OldPhoneStatus requires an ID field in the mutation")
  35487. }
  35488. oldValue, err := m.oldValue(ctx)
  35489. if err != nil {
  35490. return v, fmt.Errorf("querying old value for OldPhoneStatus: %w", err)
  35491. }
  35492. return oldValue.PhoneStatus, nil
  35493. }
  35494. // AddPhoneStatus adds i to the "phone_status" field.
  35495. func (m *WhatsappMutation) AddPhoneStatus(i int8) {
  35496. if m.addphone_status != nil {
  35497. *m.addphone_status += i
  35498. } else {
  35499. m.addphone_status = &i
  35500. }
  35501. }
  35502. // AddedPhoneStatus returns the value that was added to the "phone_status" field in this mutation.
  35503. func (m *WhatsappMutation) AddedPhoneStatus() (r int8, exists bool) {
  35504. v := m.addphone_status
  35505. if v == nil {
  35506. return
  35507. }
  35508. return *v, true
  35509. }
  35510. // ResetPhoneStatus resets all changes to the "phone_status" field.
  35511. func (m *WhatsappMutation) ResetPhoneStatus() {
  35512. m.phone_status = nil
  35513. m.addphone_status = nil
  35514. }
  35515. // SetOrganizationID sets the "organization_id" field.
  35516. func (m *WhatsappMutation) SetOrganizationID(u uint64) {
  35517. m.organization_id = &u
  35518. m.addorganization_id = nil
  35519. }
  35520. // OrganizationID returns the value of the "organization_id" field in the mutation.
  35521. func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
  35522. v := m.organization_id
  35523. if v == nil {
  35524. return
  35525. }
  35526. return *v, true
  35527. }
  35528. // OldOrganizationID returns the old "organization_id" field's value of the Whatsapp entity.
  35529. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35530. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35531. func (m *WhatsappMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  35532. if !m.op.Is(OpUpdateOne) {
  35533. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  35534. }
  35535. if m.id == nil || m.oldValue == nil {
  35536. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  35537. }
  35538. oldValue, err := m.oldValue(ctx)
  35539. if err != nil {
  35540. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  35541. }
  35542. return oldValue.OrganizationID, nil
  35543. }
  35544. // AddOrganizationID adds u to the "organization_id" field.
  35545. func (m *WhatsappMutation) AddOrganizationID(u int64) {
  35546. if m.addorganization_id != nil {
  35547. *m.addorganization_id += u
  35548. } else {
  35549. m.addorganization_id = &u
  35550. }
  35551. }
  35552. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  35553. func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
  35554. v := m.addorganization_id
  35555. if v == nil {
  35556. return
  35557. }
  35558. return *v, true
  35559. }
  35560. // ClearOrganizationID clears the value of the "organization_id" field.
  35561. func (m *WhatsappMutation) ClearOrganizationID() {
  35562. m.organization_id = nil
  35563. m.addorganization_id = nil
  35564. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  35565. }
  35566. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  35567. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  35568. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  35569. return ok
  35570. }
  35571. // ResetOrganizationID resets all changes to the "organization_id" field.
  35572. func (m *WhatsappMutation) ResetOrganizationID() {
  35573. m.organization_id = nil
  35574. m.addorganization_id = nil
  35575. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  35576. }
  35577. // SetAPIBase sets the "api_base" field.
  35578. func (m *WhatsappMutation) SetAPIBase(s string) {
  35579. m.api_base = &s
  35580. }
  35581. // APIBase returns the value of the "api_base" field in the mutation.
  35582. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  35583. v := m.api_base
  35584. if v == nil {
  35585. return
  35586. }
  35587. return *v, true
  35588. }
  35589. // OldAPIBase returns the old "api_base" field's value of the Whatsapp entity.
  35590. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35591. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35592. func (m *WhatsappMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  35593. if !m.op.Is(OpUpdateOne) {
  35594. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  35595. }
  35596. if m.id == nil || m.oldValue == nil {
  35597. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  35598. }
  35599. oldValue, err := m.oldValue(ctx)
  35600. if err != nil {
  35601. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  35602. }
  35603. return oldValue.APIBase, nil
  35604. }
  35605. // ClearAPIBase clears the value of the "api_base" field.
  35606. func (m *WhatsappMutation) ClearAPIBase() {
  35607. m.api_base = nil
  35608. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  35609. }
  35610. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  35611. func (m *WhatsappMutation) APIBaseCleared() bool {
  35612. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  35613. return ok
  35614. }
  35615. // ResetAPIBase resets all changes to the "api_base" field.
  35616. func (m *WhatsappMutation) ResetAPIBase() {
  35617. m.api_base = nil
  35618. delete(m.clearedFields, whatsapp.FieldAPIBase)
  35619. }
  35620. // SetAPIKey sets the "api_key" field.
  35621. func (m *WhatsappMutation) SetAPIKey(s string) {
  35622. m.api_key = &s
  35623. }
  35624. // APIKey returns the value of the "api_key" field in the mutation.
  35625. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  35626. v := m.api_key
  35627. if v == nil {
  35628. return
  35629. }
  35630. return *v, true
  35631. }
  35632. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  35633. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35634. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35635. func (m *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  35636. if !m.op.Is(OpUpdateOne) {
  35637. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  35638. }
  35639. if m.id == nil || m.oldValue == nil {
  35640. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  35641. }
  35642. oldValue, err := m.oldValue(ctx)
  35643. if err != nil {
  35644. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  35645. }
  35646. return oldValue.APIKey, nil
  35647. }
  35648. // ClearAPIKey clears the value of the "api_key" field.
  35649. func (m *WhatsappMutation) ClearAPIKey() {
  35650. m.api_key = nil
  35651. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  35652. }
  35653. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  35654. func (m *WhatsappMutation) APIKeyCleared() bool {
  35655. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  35656. return ok
  35657. }
  35658. // ResetAPIKey resets all changes to the "api_key" field.
  35659. func (m *WhatsappMutation) ResetAPIKey() {
  35660. m.api_key = nil
  35661. delete(m.clearedFields, whatsapp.FieldAPIKey)
  35662. }
  35663. // SetAllowList sets the "allow_list" field.
  35664. func (m *WhatsappMutation) SetAllowList(s []string) {
  35665. m.allow_list = &s
  35666. m.appendallow_list = nil
  35667. }
  35668. // AllowList returns the value of the "allow_list" field in the mutation.
  35669. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  35670. v := m.allow_list
  35671. if v == nil {
  35672. return
  35673. }
  35674. return *v, true
  35675. }
  35676. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  35677. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35678. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35679. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  35680. if !m.op.Is(OpUpdateOne) {
  35681. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  35682. }
  35683. if m.id == nil || m.oldValue == nil {
  35684. return v, errors.New("OldAllowList requires an ID field in the mutation")
  35685. }
  35686. oldValue, err := m.oldValue(ctx)
  35687. if err != nil {
  35688. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  35689. }
  35690. return oldValue.AllowList, nil
  35691. }
  35692. // AppendAllowList adds s to the "allow_list" field.
  35693. func (m *WhatsappMutation) AppendAllowList(s []string) {
  35694. m.appendallow_list = append(m.appendallow_list, s...)
  35695. }
  35696. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  35697. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  35698. if len(m.appendallow_list) == 0 {
  35699. return nil, false
  35700. }
  35701. return m.appendallow_list, true
  35702. }
  35703. // ClearAllowList clears the value of the "allow_list" field.
  35704. func (m *WhatsappMutation) ClearAllowList() {
  35705. m.allow_list = nil
  35706. m.appendallow_list = nil
  35707. m.clearedFields[whatsapp.FieldAllowList] = struct{}{}
  35708. }
  35709. // AllowListCleared returns if the "allow_list" field was cleared in this mutation.
  35710. func (m *WhatsappMutation) AllowListCleared() bool {
  35711. _, ok := m.clearedFields[whatsapp.FieldAllowList]
  35712. return ok
  35713. }
  35714. // ResetAllowList resets all changes to the "allow_list" field.
  35715. func (m *WhatsappMutation) ResetAllowList() {
  35716. m.allow_list = nil
  35717. m.appendallow_list = nil
  35718. delete(m.clearedFields, whatsapp.FieldAllowList)
  35719. }
  35720. // SetGroupAllowList sets the "group_allow_list" field.
  35721. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  35722. m.group_allow_list = &s
  35723. m.appendgroup_allow_list = nil
  35724. }
  35725. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  35726. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  35727. v := m.group_allow_list
  35728. if v == nil {
  35729. return
  35730. }
  35731. return *v, true
  35732. }
  35733. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  35734. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35735. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35736. func (m *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  35737. if !m.op.Is(OpUpdateOne) {
  35738. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  35739. }
  35740. if m.id == nil || m.oldValue == nil {
  35741. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  35742. }
  35743. oldValue, err := m.oldValue(ctx)
  35744. if err != nil {
  35745. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  35746. }
  35747. return oldValue.GroupAllowList, nil
  35748. }
  35749. // AppendGroupAllowList adds s to the "group_allow_list" field.
  35750. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  35751. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  35752. }
  35753. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  35754. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  35755. if len(m.appendgroup_allow_list) == 0 {
  35756. return nil, false
  35757. }
  35758. return m.appendgroup_allow_list, true
  35759. }
  35760. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  35761. func (m *WhatsappMutation) ClearGroupAllowList() {
  35762. m.group_allow_list = nil
  35763. m.appendgroup_allow_list = nil
  35764. m.clearedFields[whatsapp.FieldGroupAllowList] = struct{}{}
  35765. }
  35766. // GroupAllowListCleared returns if the "group_allow_list" field was cleared in this mutation.
  35767. func (m *WhatsappMutation) GroupAllowListCleared() bool {
  35768. _, ok := m.clearedFields[whatsapp.FieldGroupAllowList]
  35769. return ok
  35770. }
  35771. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  35772. func (m *WhatsappMutation) ResetGroupAllowList() {
  35773. m.group_allow_list = nil
  35774. m.appendgroup_allow_list = nil
  35775. delete(m.clearedFields, whatsapp.FieldGroupAllowList)
  35776. }
  35777. // SetBlockList sets the "block_list" field.
  35778. func (m *WhatsappMutation) SetBlockList(s []string) {
  35779. m.block_list = &s
  35780. m.appendblock_list = nil
  35781. }
  35782. // BlockList returns the value of the "block_list" field in the mutation.
  35783. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  35784. v := m.block_list
  35785. if v == nil {
  35786. return
  35787. }
  35788. return *v, true
  35789. }
  35790. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  35791. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35792. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35793. func (m *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  35794. if !m.op.Is(OpUpdateOne) {
  35795. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  35796. }
  35797. if m.id == nil || m.oldValue == nil {
  35798. return v, errors.New("OldBlockList requires an ID field in the mutation")
  35799. }
  35800. oldValue, err := m.oldValue(ctx)
  35801. if err != nil {
  35802. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  35803. }
  35804. return oldValue.BlockList, nil
  35805. }
  35806. // AppendBlockList adds s to the "block_list" field.
  35807. func (m *WhatsappMutation) AppendBlockList(s []string) {
  35808. m.appendblock_list = append(m.appendblock_list, s...)
  35809. }
  35810. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  35811. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  35812. if len(m.appendblock_list) == 0 {
  35813. return nil, false
  35814. }
  35815. return m.appendblock_list, true
  35816. }
  35817. // ClearBlockList clears the value of the "block_list" field.
  35818. func (m *WhatsappMutation) ClearBlockList() {
  35819. m.block_list = nil
  35820. m.appendblock_list = nil
  35821. m.clearedFields[whatsapp.FieldBlockList] = struct{}{}
  35822. }
  35823. // BlockListCleared returns if the "block_list" field was cleared in this mutation.
  35824. func (m *WhatsappMutation) BlockListCleared() bool {
  35825. _, ok := m.clearedFields[whatsapp.FieldBlockList]
  35826. return ok
  35827. }
  35828. // ResetBlockList resets all changes to the "block_list" field.
  35829. func (m *WhatsappMutation) ResetBlockList() {
  35830. m.block_list = nil
  35831. m.appendblock_list = nil
  35832. delete(m.clearedFields, whatsapp.FieldBlockList)
  35833. }
  35834. // SetGroupBlockList sets the "group_block_list" field.
  35835. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  35836. m.group_block_list = &s
  35837. m.appendgroup_block_list = nil
  35838. }
  35839. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  35840. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  35841. v := m.group_block_list
  35842. if v == nil {
  35843. return
  35844. }
  35845. return *v, true
  35846. }
  35847. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  35848. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35849. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35850. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  35851. if !m.op.Is(OpUpdateOne) {
  35852. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  35853. }
  35854. if m.id == nil || m.oldValue == nil {
  35855. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  35856. }
  35857. oldValue, err := m.oldValue(ctx)
  35858. if err != nil {
  35859. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  35860. }
  35861. return oldValue.GroupBlockList, nil
  35862. }
  35863. // AppendGroupBlockList adds s to the "group_block_list" field.
  35864. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  35865. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  35866. }
  35867. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  35868. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  35869. if len(m.appendgroup_block_list) == 0 {
  35870. return nil, false
  35871. }
  35872. return m.appendgroup_block_list, true
  35873. }
  35874. // ClearGroupBlockList clears the value of the "group_block_list" field.
  35875. func (m *WhatsappMutation) ClearGroupBlockList() {
  35876. m.group_block_list = nil
  35877. m.appendgroup_block_list = nil
  35878. m.clearedFields[whatsapp.FieldGroupBlockList] = struct{}{}
  35879. }
  35880. // GroupBlockListCleared returns if the "group_block_list" field was cleared in this mutation.
  35881. func (m *WhatsappMutation) GroupBlockListCleared() bool {
  35882. _, ok := m.clearedFields[whatsapp.FieldGroupBlockList]
  35883. return ok
  35884. }
  35885. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  35886. func (m *WhatsappMutation) ResetGroupBlockList() {
  35887. m.group_block_list = nil
  35888. m.appendgroup_block_list = nil
  35889. delete(m.clearedFields, whatsapp.FieldGroupBlockList)
  35890. }
  35891. // ClearAgent clears the "agent" edge to the Agent entity.
  35892. func (m *WhatsappMutation) ClearAgent() {
  35893. m.clearedagent = true
  35894. m.clearedFields[whatsapp.FieldAgentID] = struct{}{}
  35895. }
  35896. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  35897. func (m *WhatsappMutation) AgentCleared() bool {
  35898. return m.clearedagent
  35899. }
  35900. // AgentIDs returns the "agent" edge IDs in the mutation.
  35901. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  35902. // AgentID instead. It exists only for internal usage by the builders.
  35903. func (m *WhatsappMutation) AgentIDs() (ids []uint64) {
  35904. if id := m.agent; id != nil {
  35905. ids = append(ids, *id)
  35906. }
  35907. return
  35908. }
  35909. // ResetAgent resets all changes to the "agent" edge.
  35910. func (m *WhatsappMutation) ResetAgent() {
  35911. m.agent = nil
  35912. m.clearedagent = false
  35913. }
  35914. // Where appends a list predicates to the WhatsappMutation builder.
  35915. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  35916. m.predicates = append(m.predicates, ps...)
  35917. }
  35918. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  35919. // users can use type-assertion to append predicates that do not depend on any generated package.
  35920. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  35921. p := make([]predicate.Whatsapp, len(ps))
  35922. for i := range ps {
  35923. p[i] = ps[i]
  35924. }
  35925. m.Where(p...)
  35926. }
  35927. // Op returns the operation name.
  35928. func (m *WhatsappMutation) Op() Op {
  35929. return m.op
  35930. }
  35931. // SetOp allows setting the mutation operation.
  35932. func (m *WhatsappMutation) SetOp(op Op) {
  35933. m.op = op
  35934. }
  35935. // Type returns the node type of this mutation (Whatsapp).
  35936. func (m *WhatsappMutation) Type() string {
  35937. return m.typ
  35938. }
  35939. // Fields returns all fields that were changed during this mutation. Note that in
  35940. // order to get all numeric fields that were incremented/decremented, call
  35941. // AddedFields().
  35942. func (m *WhatsappMutation) Fields() []string {
  35943. fields := make([]string, 0, 21)
  35944. if m.created_at != nil {
  35945. fields = append(fields, whatsapp.FieldCreatedAt)
  35946. }
  35947. if m.updated_at != nil {
  35948. fields = append(fields, whatsapp.FieldUpdatedAt)
  35949. }
  35950. if m.status != nil {
  35951. fields = append(fields, whatsapp.FieldStatus)
  35952. }
  35953. if m.deleted_at != nil {
  35954. fields = append(fields, whatsapp.FieldDeletedAt)
  35955. }
  35956. if m.wa_id != nil {
  35957. fields = append(fields, whatsapp.FieldWaID)
  35958. }
  35959. if m.wa_name != nil {
  35960. fields = append(fields, whatsapp.FieldWaName)
  35961. }
  35962. if m.callback != nil {
  35963. fields = append(fields, whatsapp.FieldCallback)
  35964. }
  35965. if m.agent != nil {
  35966. fields = append(fields, whatsapp.FieldAgentID)
  35967. }
  35968. if m.account != nil {
  35969. fields = append(fields, whatsapp.FieldAccount)
  35970. }
  35971. if m.cc != nil {
  35972. fields = append(fields, whatsapp.FieldCc)
  35973. }
  35974. if m.phone != nil {
  35975. fields = append(fields, whatsapp.FieldPhone)
  35976. }
  35977. if m.cc_phone != nil {
  35978. fields = append(fields, whatsapp.FieldCcPhone)
  35979. }
  35980. if m.phone_name != nil {
  35981. fields = append(fields, whatsapp.FieldPhoneName)
  35982. }
  35983. if m.phone_status != nil {
  35984. fields = append(fields, whatsapp.FieldPhoneStatus)
  35985. }
  35986. if m.organization_id != nil {
  35987. fields = append(fields, whatsapp.FieldOrganizationID)
  35988. }
  35989. if m.api_base != nil {
  35990. fields = append(fields, whatsapp.FieldAPIBase)
  35991. }
  35992. if m.api_key != nil {
  35993. fields = append(fields, whatsapp.FieldAPIKey)
  35994. }
  35995. if m.allow_list != nil {
  35996. fields = append(fields, whatsapp.FieldAllowList)
  35997. }
  35998. if m.group_allow_list != nil {
  35999. fields = append(fields, whatsapp.FieldGroupAllowList)
  36000. }
  36001. if m.block_list != nil {
  36002. fields = append(fields, whatsapp.FieldBlockList)
  36003. }
  36004. if m.group_block_list != nil {
  36005. fields = append(fields, whatsapp.FieldGroupBlockList)
  36006. }
  36007. return fields
  36008. }
  36009. // Field returns the value of a field with the given name. The second boolean
  36010. // return value indicates that this field was not set, or was not defined in the
  36011. // schema.
  36012. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  36013. switch name {
  36014. case whatsapp.FieldCreatedAt:
  36015. return m.CreatedAt()
  36016. case whatsapp.FieldUpdatedAt:
  36017. return m.UpdatedAt()
  36018. case whatsapp.FieldStatus:
  36019. return m.Status()
  36020. case whatsapp.FieldDeletedAt:
  36021. return m.DeletedAt()
  36022. case whatsapp.FieldWaID:
  36023. return m.WaID()
  36024. case whatsapp.FieldWaName:
  36025. return m.WaName()
  36026. case whatsapp.FieldCallback:
  36027. return m.Callback()
  36028. case whatsapp.FieldAgentID:
  36029. return m.AgentID()
  36030. case whatsapp.FieldAccount:
  36031. return m.Account()
  36032. case whatsapp.FieldCc:
  36033. return m.Cc()
  36034. case whatsapp.FieldPhone:
  36035. return m.Phone()
  36036. case whatsapp.FieldCcPhone:
  36037. return m.CcPhone()
  36038. case whatsapp.FieldPhoneName:
  36039. return m.PhoneName()
  36040. case whatsapp.FieldPhoneStatus:
  36041. return m.PhoneStatus()
  36042. case whatsapp.FieldOrganizationID:
  36043. return m.OrganizationID()
  36044. case whatsapp.FieldAPIBase:
  36045. return m.APIBase()
  36046. case whatsapp.FieldAPIKey:
  36047. return m.APIKey()
  36048. case whatsapp.FieldAllowList:
  36049. return m.AllowList()
  36050. case whatsapp.FieldGroupAllowList:
  36051. return m.GroupAllowList()
  36052. case whatsapp.FieldBlockList:
  36053. return m.BlockList()
  36054. case whatsapp.FieldGroupBlockList:
  36055. return m.GroupBlockList()
  36056. }
  36057. return nil, false
  36058. }
  36059. // OldField returns the old value of the field from the database. An error is
  36060. // returned if the mutation operation is not UpdateOne, or the query to the
  36061. // database failed.
  36062. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  36063. switch name {
  36064. case whatsapp.FieldCreatedAt:
  36065. return m.OldCreatedAt(ctx)
  36066. case whatsapp.FieldUpdatedAt:
  36067. return m.OldUpdatedAt(ctx)
  36068. case whatsapp.FieldStatus:
  36069. return m.OldStatus(ctx)
  36070. case whatsapp.FieldDeletedAt:
  36071. return m.OldDeletedAt(ctx)
  36072. case whatsapp.FieldWaID:
  36073. return m.OldWaID(ctx)
  36074. case whatsapp.FieldWaName:
  36075. return m.OldWaName(ctx)
  36076. case whatsapp.FieldCallback:
  36077. return m.OldCallback(ctx)
  36078. case whatsapp.FieldAgentID:
  36079. return m.OldAgentID(ctx)
  36080. case whatsapp.FieldAccount:
  36081. return m.OldAccount(ctx)
  36082. case whatsapp.FieldCc:
  36083. return m.OldCc(ctx)
  36084. case whatsapp.FieldPhone:
  36085. return m.OldPhone(ctx)
  36086. case whatsapp.FieldCcPhone:
  36087. return m.OldCcPhone(ctx)
  36088. case whatsapp.FieldPhoneName:
  36089. return m.OldPhoneName(ctx)
  36090. case whatsapp.FieldPhoneStatus:
  36091. return m.OldPhoneStatus(ctx)
  36092. case whatsapp.FieldOrganizationID:
  36093. return m.OldOrganizationID(ctx)
  36094. case whatsapp.FieldAPIBase:
  36095. return m.OldAPIBase(ctx)
  36096. case whatsapp.FieldAPIKey:
  36097. return m.OldAPIKey(ctx)
  36098. case whatsapp.FieldAllowList:
  36099. return m.OldAllowList(ctx)
  36100. case whatsapp.FieldGroupAllowList:
  36101. return m.OldGroupAllowList(ctx)
  36102. case whatsapp.FieldBlockList:
  36103. return m.OldBlockList(ctx)
  36104. case whatsapp.FieldGroupBlockList:
  36105. return m.OldGroupBlockList(ctx)
  36106. }
  36107. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  36108. }
  36109. // SetField sets the value of a field with the given name. It returns an error if
  36110. // the field is not defined in the schema, or if the type mismatched the field
  36111. // type.
  36112. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  36113. switch name {
  36114. case whatsapp.FieldCreatedAt:
  36115. v, ok := value.(time.Time)
  36116. if !ok {
  36117. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36118. }
  36119. m.SetCreatedAt(v)
  36120. return nil
  36121. case whatsapp.FieldUpdatedAt:
  36122. v, ok := value.(time.Time)
  36123. if !ok {
  36124. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36125. }
  36126. m.SetUpdatedAt(v)
  36127. return nil
  36128. case whatsapp.FieldStatus:
  36129. v, ok := value.(uint8)
  36130. if !ok {
  36131. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36132. }
  36133. m.SetStatus(v)
  36134. return nil
  36135. case whatsapp.FieldDeletedAt:
  36136. v, ok := value.(time.Time)
  36137. if !ok {
  36138. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36139. }
  36140. m.SetDeletedAt(v)
  36141. return nil
  36142. case whatsapp.FieldWaID:
  36143. v, ok := value.(string)
  36144. if !ok {
  36145. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36146. }
  36147. m.SetWaID(v)
  36148. return nil
  36149. case whatsapp.FieldWaName:
  36150. v, ok := value.(string)
  36151. if !ok {
  36152. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36153. }
  36154. m.SetWaName(v)
  36155. return nil
  36156. case whatsapp.FieldCallback:
  36157. v, ok := value.(string)
  36158. if !ok {
  36159. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36160. }
  36161. m.SetCallback(v)
  36162. return nil
  36163. case whatsapp.FieldAgentID:
  36164. v, ok := value.(uint64)
  36165. if !ok {
  36166. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36167. }
  36168. m.SetAgentID(v)
  36169. return nil
  36170. case whatsapp.FieldAccount:
  36171. v, ok := value.(string)
  36172. if !ok {
  36173. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36174. }
  36175. m.SetAccount(v)
  36176. return nil
  36177. case whatsapp.FieldCc:
  36178. v, ok := value.(string)
  36179. if !ok {
  36180. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36181. }
  36182. m.SetCc(v)
  36183. return nil
  36184. case whatsapp.FieldPhone:
  36185. v, ok := value.(string)
  36186. if !ok {
  36187. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36188. }
  36189. m.SetPhone(v)
  36190. return nil
  36191. case whatsapp.FieldCcPhone:
  36192. v, ok := value.(string)
  36193. if !ok {
  36194. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36195. }
  36196. m.SetCcPhone(v)
  36197. return nil
  36198. case whatsapp.FieldPhoneName:
  36199. v, ok := value.(string)
  36200. if !ok {
  36201. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36202. }
  36203. m.SetPhoneName(v)
  36204. return nil
  36205. case whatsapp.FieldPhoneStatus:
  36206. v, ok := value.(int8)
  36207. if !ok {
  36208. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36209. }
  36210. m.SetPhoneStatus(v)
  36211. return nil
  36212. case whatsapp.FieldOrganizationID:
  36213. v, ok := value.(uint64)
  36214. if !ok {
  36215. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36216. }
  36217. m.SetOrganizationID(v)
  36218. return nil
  36219. case whatsapp.FieldAPIBase:
  36220. v, ok := value.(string)
  36221. if !ok {
  36222. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36223. }
  36224. m.SetAPIBase(v)
  36225. return nil
  36226. case whatsapp.FieldAPIKey:
  36227. v, ok := value.(string)
  36228. if !ok {
  36229. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36230. }
  36231. m.SetAPIKey(v)
  36232. return nil
  36233. case whatsapp.FieldAllowList:
  36234. v, ok := value.([]string)
  36235. if !ok {
  36236. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36237. }
  36238. m.SetAllowList(v)
  36239. return nil
  36240. case whatsapp.FieldGroupAllowList:
  36241. v, ok := value.([]string)
  36242. if !ok {
  36243. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36244. }
  36245. m.SetGroupAllowList(v)
  36246. return nil
  36247. case whatsapp.FieldBlockList:
  36248. v, ok := value.([]string)
  36249. if !ok {
  36250. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36251. }
  36252. m.SetBlockList(v)
  36253. return nil
  36254. case whatsapp.FieldGroupBlockList:
  36255. v, ok := value.([]string)
  36256. if !ok {
  36257. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36258. }
  36259. m.SetGroupBlockList(v)
  36260. return nil
  36261. }
  36262. return fmt.Errorf("unknown Whatsapp field %s", name)
  36263. }
  36264. // AddedFields returns all numeric fields that were incremented/decremented during
  36265. // this mutation.
  36266. func (m *WhatsappMutation) AddedFields() []string {
  36267. var fields []string
  36268. if m.addstatus != nil {
  36269. fields = append(fields, whatsapp.FieldStatus)
  36270. }
  36271. if m.addphone_status != nil {
  36272. fields = append(fields, whatsapp.FieldPhoneStatus)
  36273. }
  36274. if m.addorganization_id != nil {
  36275. fields = append(fields, whatsapp.FieldOrganizationID)
  36276. }
  36277. return fields
  36278. }
  36279. // AddedField returns the numeric value that was incremented/decremented on a field
  36280. // with the given name. The second boolean return value indicates that this field
  36281. // was not set, or was not defined in the schema.
  36282. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  36283. switch name {
  36284. case whatsapp.FieldStatus:
  36285. return m.AddedStatus()
  36286. case whatsapp.FieldPhoneStatus:
  36287. return m.AddedPhoneStatus()
  36288. case whatsapp.FieldOrganizationID:
  36289. return m.AddedOrganizationID()
  36290. }
  36291. return nil, false
  36292. }
  36293. // AddField adds the value to the field with the given name. It returns an error if
  36294. // the field is not defined in the schema, or if the type mismatched the field
  36295. // type.
  36296. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  36297. switch name {
  36298. case whatsapp.FieldStatus:
  36299. v, ok := value.(int8)
  36300. if !ok {
  36301. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36302. }
  36303. m.AddStatus(v)
  36304. return nil
  36305. case whatsapp.FieldPhoneStatus:
  36306. v, ok := value.(int8)
  36307. if !ok {
  36308. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36309. }
  36310. m.AddPhoneStatus(v)
  36311. return nil
  36312. case whatsapp.FieldOrganizationID:
  36313. v, ok := value.(int64)
  36314. if !ok {
  36315. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36316. }
  36317. m.AddOrganizationID(v)
  36318. return nil
  36319. }
  36320. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  36321. }
  36322. // ClearedFields returns all nullable fields that were cleared during this
  36323. // mutation.
  36324. func (m *WhatsappMutation) ClearedFields() []string {
  36325. var fields []string
  36326. if m.FieldCleared(whatsapp.FieldStatus) {
  36327. fields = append(fields, whatsapp.FieldStatus)
  36328. }
  36329. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  36330. fields = append(fields, whatsapp.FieldDeletedAt)
  36331. }
  36332. if m.FieldCleared(whatsapp.FieldWaID) {
  36333. fields = append(fields, whatsapp.FieldWaID)
  36334. }
  36335. if m.FieldCleared(whatsapp.FieldWaName) {
  36336. fields = append(fields, whatsapp.FieldWaName)
  36337. }
  36338. if m.FieldCleared(whatsapp.FieldCallback) {
  36339. fields = append(fields, whatsapp.FieldCallback)
  36340. }
  36341. if m.FieldCleared(whatsapp.FieldAccount) {
  36342. fields = append(fields, whatsapp.FieldAccount)
  36343. }
  36344. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  36345. fields = append(fields, whatsapp.FieldOrganizationID)
  36346. }
  36347. if m.FieldCleared(whatsapp.FieldAPIBase) {
  36348. fields = append(fields, whatsapp.FieldAPIBase)
  36349. }
  36350. if m.FieldCleared(whatsapp.FieldAPIKey) {
  36351. fields = append(fields, whatsapp.FieldAPIKey)
  36352. }
  36353. if m.FieldCleared(whatsapp.FieldAllowList) {
  36354. fields = append(fields, whatsapp.FieldAllowList)
  36355. }
  36356. if m.FieldCleared(whatsapp.FieldGroupAllowList) {
  36357. fields = append(fields, whatsapp.FieldGroupAllowList)
  36358. }
  36359. if m.FieldCleared(whatsapp.FieldBlockList) {
  36360. fields = append(fields, whatsapp.FieldBlockList)
  36361. }
  36362. if m.FieldCleared(whatsapp.FieldGroupBlockList) {
  36363. fields = append(fields, whatsapp.FieldGroupBlockList)
  36364. }
  36365. return fields
  36366. }
  36367. // FieldCleared returns a boolean indicating if a field with the given name was
  36368. // cleared in this mutation.
  36369. func (m *WhatsappMutation) FieldCleared(name string) bool {
  36370. _, ok := m.clearedFields[name]
  36371. return ok
  36372. }
  36373. // ClearField clears the value of the field with the given name. It returns an
  36374. // error if the field is not defined in the schema.
  36375. func (m *WhatsappMutation) ClearField(name string) error {
  36376. switch name {
  36377. case whatsapp.FieldStatus:
  36378. m.ClearStatus()
  36379. return nil
  36380. case whatsapp.FieldDeletedAt:
  36381. m.ClearDeletedAt()
  36382. return nil
  36383. case whatsapp.FieldWaID:
  36384. m.ClearWaID()
  36385. return nil
  36386. case whatsapp.FieldWaName:
  36387. m.ClearWaName()
  36388. return nil
  36389. case whatsapp.FieldCallback:
  36390. m.ClearCallback()
  36391. return nil
  36392. case whatsapp.FieldAccount:
  36393. m.ClearAccount()
  36394. return nil
  36395. case whatsapp.FieldOrganizationID:
  36396. m.ClearOrganizationID()
  36397. return nil
  36398. case whatsapp.FieldAPIBase:
  36399. m.ClearAPIBase()
  36400. return nil
  36401. case whatsapp.FieldAPIKey:
  36402. m.ClearAPIKey()
  36403. return nil
  36404. case whatsapp.FieldAllowList:
  36405. m.ClearAllowList()
  36406. return nil
  36407. case whatsapp.FieldGroupAllowList:
  36408. m.ClearGroupAllowList()
  36409. return nil
  36410. case whatsapp.FieldBlockList:
  36411. m.ClearBlockList()
  36412. return nil
  36413. case whatsapp.FieldGroupBlockList:
  36414. m.ClearGroupBlockList()
  36415. return nil
  36416. }
  36417. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  36418. }
  36419. // ResetField resets all changes in the mutation for the field with the given name.
  36420. // It returns an error if the field is not defined in the schema.
  36421. func (m *WhatsappMutation) ResetField(name string) error {
  36422. switch name {
  36423. case whatsapp.FieldCreatedAt:
  36424. m.ResetCreatedAt()
  36425. return nil
  36426. case whatsapp.FieldUpdatedAt:
  36427. m.ResetUpdatedAt()
  36428. return nil
  36429. case whatsapp.FieldStatus:
  36430. m.ResetStatus()
  36431. return nil
  36432. case whatsapp.FieldDeletedAt:
  36433. m.ResetDeletedAt()
  36434. return nil
  36435. case whatsapp.FieldWaID:
  36436. m.ResetWaID()
  36437. return nil
  36438. case whatsapp.FieldWaName:
  36439. m.ResetWaName()
  36440. return nil
  36441. case whatsapp.FieldCallback:
  36442. m.ResetCallback()
  36443. return nil
  36444. case whatsapp.FieldAgentID:
  36445. m.ResetAgentID()
  36446. return nil
  36447. case whatsapp.FieldAccount:
  36448. m.ResetAccount()
  36449. return nil
  36450. case whatsapp.FieldCc:
  36451. m.ResetCc()
  36452. return nil
  36453. case whatsapp.FieldPhone:
  36454. m.ResetPhone()
  36455. return nil
  36456. case whatsapp.FieldCcPhone:
  36457. m.ResetCcPhone()
  36458. return nil
  36459. case whatsapp.FieldPhoneName:
  36460. m.ResetPhoneName()
  36461. return nil
  36462. case whatsapp.FieldPhoneStatus:
  36463. m.ResetPhoneStatus()
  36464. return nil
  36465. case whatsapp.FieldOrganizationID:
  36466. m.ResetOrganizationID()
  36467. return nil
  36468. case whatsapp.FieldAPIBase:
  36469. m.ResetAPIBase()
  36470. return nil
  36471. case whatsapp.FieldAPIKey:
  36472. m.ResetAPIKey()
  36473. return nil
  36474. case whatsapp.FieldAllowList:
  36475. m.ResetAllowList()
  36476. return nil
  36477. case whatsapp.FieldGroupAllowList:
  36478. m.ResetGroupAllowList()
  36479. return nil
  36480. case whatsapp.FieldBlockList:
  36481. m.ResetBlockList()
  36482. return nil
  36483. case whatsapp.FieldGroupBlockList:
  36484. m.ResetGroupBlockList()
  36485. return nil
  36486. }
  36487. return fmt.Errorf("unknown Whatsapp field %s", name)
  36488. }
  36489. // AddedEdges returns all edge names that were set/added in this mutation.
  36490. func (m *WhatsappMutation) AddedEdges() []string {
  36491. edges := make([]string, 0, 1)
  36492. if m.agent != nil {
  36493. edges = append(edges, whatsapp.EdgeAgent)
  36494. }
  36495. return edges
  36496. }
  36497. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  36498. // name in this mutation.
  36499. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  36500. switch name {
  36501. case whatsapp.EdgeAgent:
  36502. if id := m.agent; id != nil {
  36503. return []ent.Value{*id}
  36504. }
  36505. }
  36506. return nil
  36507. }
  36508. // RemovedEdges returns all edge names that were removed in this mutation.
  36509. func (m *WhatsappMutation) RemovedEdges() []string {
  36510. edges := make([]string, 0, 1)
  36511. return edges
  36512. }
  36513. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  36514. // the given name in this mutation.
  36515. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  36516. return nil
  36517. }
  36518. // ClearedEdges returns all edge names that were cleared in this mutation.
  36519. func (m *WhatsappMutation) ClearedEdges() []string {
  36520. edges := make([]string, 0, 1)
  36521. if m.clearedagent {
  36522. edges = append(edges, whatsapp.EdgeAgent)
  36523. }
  36524. return edges
  36525. }
  36526. // EdgeCleared returns a boolean which indicates if the edge with the given name
  36527. // was cleared in this mutation.
  36528. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  36529. switch name {
  36530. case whatsapp.EdgeAgent:
  36531. return m.clearedagent
  36532. }
  36533. return false
  36534. }
  36535. // ClearEdge clears the value of the edge with the given name. It returns an error
  36536. // if that edge is not defined in the schema.
  36537. func (m *WhatsappMutation) ClearEdge(name string) error {
  36538. switch name {
  36539. case whatsapp.EdgeAgent:
  36540. m.ClearAgent()
  36541. return nil
  36542. }
  36543. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  36544. }
  36545. // ResetEdge resets all changes to the edge with the given name in this mutation.
  36546. // It returns an error if the edge is not defined in the schema.
  36547. func (m *WhatsappMutation) ResetEdge(name string) error {
  36548. switch name {
  36549. case whatsapp.EdgeAgent:
  36550. m.ResetAgent()
  36551. return nil
  36552. }
  36553. return fmt.Errorf("unknown Whatsapp edge %s", name)
  36554. }
  36555. // WhatsappChannelMutation represents an operation that mutates the WhatsappChannel nodes in the graph.
  36556. type WhatsappChannelMutation struct {
  36557. config
  36558. op Op
  36559. typ string
  36560. id *uint64
  36561. created_at *time.Time
  36562. updated_at *time.Time
  36563. status *uint8
  36564. addstatus *int8
  36565. deleted_at *time.Time
  36566. ak *string
  36567. sk *string
  36568. wa_id *string
  36569. wa_name *string
  36570. waba_id *uint64
  36571. addwaba_id *int64
  36572. business_id *uint64
  36573. addbusiness_id *int64
  36574. organization_id *uint64
  36575. addorganization_id *int64
  36576. verify_account *string
  36577. clearedFields map[string]struct{}
  36578. done bool
  36579. oldValue func(context.Context) (*WhatsappChannel, error)
  36580. predicates []predicate.WhatsappChannel
  36581. }
  36582. var _ ent.Mutation = (*WhatsappChannelMutation)(nil)
  36583. // whatsappchannelOption allows management of the mutation configuration using functional options.
  36584. type whatsappchannelOption func(*WhatsappChannelMutation)
  36585. // newWhatsappChannelMutation creates new mutation for the WhatsappChannel entity.
  36586. func newWhatsappChannelMutation(c config, op Op, opts ...whatsappchannelOption) *WhatsappChannelMutation {
  36587. m := &WhatsappChannelMutation{
  36588. config: c,
  36589. op: op,
  36590. typ: TypeWhatsappChannel,
  36591. clearedFields: make(map[string]struct{}),
  36592. }
  36593. for _, opt := range opts {
  36594. opt(m)
  36595. }
  36596. return m
  36597. }
  36598. // withWhatsappChannelID sets the ID field of the mutation.
  36599. func withWhatsappChannelID(id uint64) whatsappchannelOption {
  36600. return func(m *WhatsappChannelMutation) {
  36601. var (
  36602. err error
  36603. once sync.Once
  36604. value *WhatsappChannel
  36605. )
  36606. m.oldValue = func(ctx context.Context) (*WhatsappChannel, error) {
  36607. once.Do(func() {
  36608. if m.done {
  36609. err = errors.New("querying old values post mutation is not allowed")
  36610. } else {
  36611. value, err = m.Client().WhatsappChannel.Get(ctx, id)
  36612. }
  36613. })
  36614. return value, err
  36615. }
  36616. m.id = &id
  36617. }
  36618. }
  36619. // withWhatsappChannel sets the old WhatsappChannel of the mutation.
  36620. func withWhatsappChannel(node *WhatsappChannel) whatsappchannelOption {
  36621. return func(m *WhatsappChannelMutation) {
  36622. m.oldValue = func(context.Context) (*WhatsappChannel, error) {
  36623. return node, nil
  36624. }
  36625. m.id = &node.ID
  36626. }
  36627. }
  36628. // Client returns a new `ent.Client` from the mutation. If the mutation was
  36629. // executed in a transaction (ent.Tx), a transactional client is returned.
  36630. func (m WhatsappChannelMutation) Client() *Client {
  36631. client := &Client{config: m.config}
  36632. client.init()
  36633. return client
  36634. }
  36635. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  36636. // it returns an error otherwise.
  36637. func (m WhatsappChannelMutation) Tx() (*Tx, error) {
  36638. if _, ok := m.driver.(*txDriver); !ok {
  36639. return nil, errors.New("ent: mutation is not running in a transaction")
  36640. }
  36641. tx := &Tx{config: m.config}
  36642. tx.init()
  36643. return tx, nil
  36644. }
  36645. // SetID sets the value of the id field. Note that this
  36646. // operation is only accepted on creation of WhatsappChannel entities.
  36647. func (m *WhatsappChannelMutation) SetID(id uint64) {
  36648. m.id = &id
  36649. }
  36650. // ID returns the ID value in the mutation. Note that the ID is only available
  36651. // if it was provided to the builder or after it was returned from the database.
  36652. func (m *WhatsappChannelMutation) ID() (id uint64, exists bool) {
  36653. if m.id == nil {
  36654. return
  36655. }
  36656. return *m.id, true
  36657. }
  36658. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36659. // That means, if the mutation is applied within a transaction with an isolation level such
  36660. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36661. // or updated by the mutation.
  36662. func (m *WhatsappChannelMutation) IDs(ctx context.Context) ([]uint64, error) {
  36663. switch {
  36664. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36665. id, exists := m.ID()
  36666. if exists {
  36667. return []uint64{id}, nil
  36668. }
  36669. fallthrough
  36670. case m.op.Is(OpUpdate | OpDelete):
  36671. return m.Client().WhatsappChannel.Query().Where(m.predicates...).IDs(ctx)
  36672. default:
  36673. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36674. }
  36675. }
  36676. // SetCreatedAt sets the "created_at" field.
  36677. func (m *WhatsappChannelMutation) SetCreatedAt(t time.Time) {
  36678. m.created_at = &t
  36679. }
  36680. // CreatedAt returns the value of the "created_at" field in the mutation.
  36681. func (m *WhatsappChannelMutation) CreatedAt() (r time.Time, exists bool) {
  36682. v := m.created_at
  36683. if v == nil {
  36684. return
  36685. }
  36686. return *v, true
  36687. }
  36688. // OldCreatedAt returns the old "created_at" field's value of the WhatsappChannel entity.
  36689. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36690. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36691. func (m *WhatsappChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36692. if !m.op.Is(OpUpdateOne) {
  36693. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36694. }
  36695. if m.id == nil || m.oldValue == nil {
  36696. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36697. }
  36698. oldValue, err := m.oldValue(ctx)
  36699. if err != nil {
  36700. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36701. }
  36702. return oldValue.CreatedAt, nil
  36703. }
  36704. // ResetCreatedAt resets all changes to the "created_at" field.
  36705. func (m *WhatsappChannelMutation) ResetCreatedAt() {
  36706. m.created_at = nil
  36707. }
  36708. // SetUpdatedAt sets the "updated_at" field.
  36709. func (m *WhatsappChannelMutation) SetUpdatedAt(t time.Time) {
  36710. m.updated_at = &t
  36711. }
  36712. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36713. func (m *WhatsappChannelMutation) UpdatedAt() (r time.Time, exists bool) {
  36714. v := m.updated_at
  36715. if v == nil {
  36716. return
  36717. }
  36718. return *v, true
  36719. }
  36720. // OldUpdatedAt returns the old "updated_at" field's value of the WhatsappChannel entity.
  36721. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36722. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36723. func (m *WhatsappChannelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36724. if !m.op.Is(OpUpdateOne) {
  36725. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36726. }
  36727. if m.id == nil || m.oldValue == nil {
  36728. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36729. }
  36730. oldValue, err := m.oldValue(ctx)
  36731. if err != nil {
  36732. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36733. }
  36734. return oldValue.UpdatedAt, nil
  36735. }
  36736. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36737. func (m *WhatsappChannelMutation) ResetUpdatedAt() {
  36738. m.updated_at = nil
  36739. }
  36740. // SetStatus sets the "status" field.
  36741. func (m *WhatsappChannelMutation) SetStatus(u uint8) {
  36742. m.status = &u
  36743. m.addstatus = nil
  36744. }
  36745. // Status returns the value of the "status" field in the mutation.
  36746. func (m *WhatsappChannelMutation) Status() (r uint8, exists bool) {
  36747. v := m.status
  36748. if v == nil {
  36749. return
  36750. }
  36751. return *v, true
  36752. }
  36753. // OldStatus returns the old "status" field's value of the WhatsappChannel entity.
  36754. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36755. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36756. func (m *WhatsappChannelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  36757. if !m.op.Is(OpUpdateOne) {
  36758. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  36759. }
  36760. if m.id == nil || m.oldValue == nil {
  36761. return v, errors.New("OldStatus requires an ID field in the mutation")
  36762. }
  36763. oldValue, err := m.oldValue(ctx)
  36764. if err != nil {
  36765. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  36766. }
  36767. return oldValue.Status, nil
  36768. }
  36769. // AddStatus adds u to the "status" field.
  36770. func (m *WhatsappChannelMutation) AddStatus(u int8) {
  36771. if m.addstatus != nil {
  36772. *m.addstatus += u
  36773. } else {
  36774. m.addstatus = &u
  36775. }
  36776. }
  36777. // AddedStatus returns the value that was added to the "status" field in this mutation.
  36778. func (m *WhatsappChannelMutation) AddedStatus() (r int8, exists bool) {
  36779. v := m.addstatus
  36780. if v == nil {
  36781. return
  36782. }
  36783. return *v, true
  36784. }
  36785. // ClearStatus clears the value of the "status" field.
  36786. func (m *WhatsappChannelMutation) ClearStatus() {
  36787. m.status = nil
  36788. m.addstatus = nil
  36789. m.clearedFields[whatsappchannel.FieldStatus] = struct{}{}
  36790. }
  36791. // StatusCleared returns if the "status" field was cleared in this mutation.
  36792. func (m *WhatsappChannelMutation) StatusCleared() bool {
  36793. _, ok := m.clearedFields[whatsappchannel.FieldStatus]
  36794. return ok
  36795. }
  36796. // ResetStatus resets all changes to the "status" field.
  36797. func (m *WhatsappChannelMutation) ResetStatus() {
  36798. m.status = nil
  36799. m.addstatus = nil
  36800. delete(m.clearedFields, whatsappchannel.FieldStatus)
  36801. }
  36802. // SetDeletedAt sets the "deleted_at" field.
  36803. func (m *WhatsappChannelMutation) SetDeletedAt(t time.Time) {
  36804. m.deleted_at = &t
  36805. }
  36806. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  36807. func (m *WhatsappChannelMutation) DeletedAt() (r time.Time, exists bool) {
  36808. v := m.deleted_at
  36809. if v == nil {
  36810. return
  36811. }
  36812. return *v, true
  36813. }
  36814. // OldDeletedAt returns the old "deleted_at" field's value of the WhatsappChannel entity.
  36815. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36816. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36817. func (m *WhatsappChannelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  36818. if !m.op.Is(OpUpdateOne) {
  36819. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  36820. }
  36821. if m.id == nil || m.oldValue == nil {
  36822. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  36823. }
  36824. oldValue, err := m.oldValue(ctx)
  36825. if err != nil {
  36826. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  36827. }
  36828. return oldValue.DeletedAt, nil
  36829. }
  36830. // ClearDeletedAt clears the value of the "deleted_at" field.
  36831. func (m *WhatsappChannelMutation) ClearDeletedAt() {
  36832. m.deleted_at = nil
  36833. m.clearedFields[whatsappchannel.FieldDeletedAt] = struct{}{}
  36834. }
  36835. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  36836. func (m *WhatsappChannelMutation) DeletedAtCleared() bool {
  36837. _, ok := m.clearedFields[whatsappchannel.FieldDeletedAt]
  36838. return ok
  36839. }
  36840. // ResetDeletedAt resets all changes to the "deleted_at" field.
  36841. func (m *WhatsappChannelMutation) ResetDeletedAt() {
  36842. m.deleted_at = nil
  36843. delete(m.clearedFields, whatsappchannel.FieldDeletedAt)
  36844. }
  36845. // SetAk sets the "ak" field.
  36846. func (m *WhatsappChannelMutation) SetAk(s string) {
  36847. m.ak = &s
  36848. }
  36849. // Ak returns the value of the "ak" field in the mutation.
  36850. func (m *WhatsappChannelMutation) Ak() (r string, exists bool) {
  36851. v := m.ak
  36852. if v == nil {
  36853. return
  36854. }
  36855. return *v, true
  36856. }
  36857. // OldAk returns the old "ak" field's value of the WhatsappChannel entity.
  36858. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36859. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36860. func (m *WhatsappChannelMutation) OldAk(ctx context.Context) (v string, err error) {
  36861. if !m.op.Is(OpUpdateOne) {
  36862. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  36863. }
  36864. if m.id == nil || m.oldValue == nil {
  36865. return v, errors.New("OldAk requires an ID field in the mutation")
  36866. }
  36867. oldValue, err := m.oldValue(ctx)
  36868. if err != nil {
  36869. return v, fmt.Errorf("querying old value for OldAk: %w", err)
  36870. }
  36871. return oldValue.Ak, nil
  36872. }
  36873. // ClearAk clears the value of the "ak" field.
  36874. func (m *WhatsappChannelMutation) ClearAk() {
  36875. m.ak = nil
  36876. m.clearedFields[whatsappchannel.FieldAk] = struct{}{}
  36877. }
  36878. // AkCleared returns if the "ak" field was cleared in this mutation.
  36879. func (m *WhatsappChannelMutation) AkCleared() bool {
  36880. _, ok := m.clearedFields[whatsappchannel.FieldAk]
  36881. return ok
  36882. }
  36883. // ResetAk resets all changes to the "ak" field.
  36884. func (m *WhatsappChannelMutation) ResetAk() {
  36885. m.ak = nil
  36886. delete(m.clearedFields, whatsappchannel.FieldAk)
  36887. }
  36888. // SetSk sets the "sk" field.
  36889. func (m *WhatsappChannelMutation) SetSk(s string) {
  36890. m.sk = &s
  36891. }
  36892. // Sk returns the value of the "sk" field in the mutation.
  36893. func (m *WhatsappChannelMutation) Sk() (r string, exists bool) {
  36894. v := m.sk
  36895. if v == nil {
  36896. return
  36897. }
  36898. return *v, true
  36899. }
  36900. // OldSk returns the old "sk" field's value of the WhatsappChannel entity.
  36901. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36902. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36903. func (m *WhatsappChannelMutation) OldSk(ctx context.Context) (v string, err error) {
  36904. if !m.op.Is(OpUpdateOne) {
  36905. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  36906. }
  36907. if m.id == nil || m.oldValue == nil {
  36908. return v, errors.New("OldSk requires an ID field in the mutation")
  36909. }
  36910. oldValue, err := m.oldValue(ctx)
  36911. if err != nil {
  36912. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  36913. }
  36914. return oldValue.Sk, nil
  36915. }
  36916. // ResetSk resets all changes to the "sk" field.
  36917. func (m *WhatsappChannelMutation) ResetSk() {
  36918. m.sk = nil
  36919. }
  36920. // SetWaID sets the "wa_id" field.
  36921. func (m *WhatsappChannelMutation) SetWaID(s string) {
  36922. m.wa_id = &s
  36923. }
  36924. // WaID returns the value of the "wa_id" field in the mutation.
  36925. func (m *WhatsappChannelMutation) WaID() (r string, exists bool) {
  36926. v := m.wa_id
  36927. if v == nil {
  36928. return
  36929. }
  36930. return *v, true
  36931. }
  36932. // OldWaID returns the old "wa_id" field's value of the WhatsappChannel entity.
  36933. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36934. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36935. func (m *WhatsappChannelMutation) OldWaID(ctx context.Context) (v string, err error) {
  36936. if !m.op.Is(OpUpdateOne) {
  36937. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  36938. }
  36939. if m.id == nil || m.oldValue == nil {
  36940. return v, errors.New("OldWaID requires an ID field in the mutation")
  36941. }
  36942. oldValue, err := m.oldValue(ctx)
  36943. if err != nil {
  36944. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  36945. }
  36946. return oldValue.WaID, nil
  36947. }
  36948. // ClearWaID clears the value of the "wa_id" field.
  36949. func (m *WhatsappChannelMutation) ClearWaID() {
  36950. m.wa_id = nil
  36951. m.clearedFields[whatsappchannel.FieldWaID] = struct{}{}
  36952. }
  36953. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  36954. func (m *WhatsappChannelMutation) WaIDCleared() bool {
  36955. _, ok := m.clearedFields[whatsappchannel.FieldWaID]
  36956. return ok
  36957. }
  36958. // ResetWaID resets all changes to the "wa_id" field.
  36959. func (m *WhatsappChannelMutation) ResetWaID() {
  36960. m.wa_id = nil
  36961. delete(m.clearedFields, whatsappchannel.FieldWaID)
  36962. }
  36963. // SetWaName sets the "wa_name" field.
  36964. func (m *WhatsappChannelMutation) SetWaName(s string) {
  36965. m.wa_name = &s
  36966. }
  36967. // WaName returns the value of the "wa_name" field in the mutation.
  36968. func (m *WhatsappChannelMutation) WaName() (r string, exists bool) {
  36969. v := m.wa_name
  36970. if v == nil {
  36971. return
  36972. }
  36973. return *v, true
  36974. }
  36975. // OldWaName returns the old "wa_name" field's value of the WhatsappChannel entity.
  36976. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36977. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36978. func (m *WhatsappChannelMutation) OldWaName(ctx context.Context) (v string, err error) {
  36979. if !m.op.Is(OpUpdateOne) {
  36980. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  36981. }
  36982. if m.id == nil || m.oldValue == nil {
  36983. return v, errors.New("OldWaName requires an ID field in the mutation")
  36984. }
  36985. oldValue, err := m.oldValue(ctx)
  36986. if err != nil {
  36987. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  36988. }
  36989. return oldValue.WaName, nil
  36990. }
  36991. // ClearWaName clears the value of the "wa_name" field.
  36992. func (m *WhatsappChannelMutation) ClearWaName() {
  36993. m.wa_name = nil
  36994. m.clearedFields[whatsappchannel.FieldWaName] = struct{}{}
  36995. }
  36996. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  36997. func (m *WhatsappChannelMutation) WaNameCleared() bool {
  36998. _, ok := m.clearedFields[whatsappchannel.FieldWaName]
  36999. return ok
  37000. }
  37001. // ResetWaName resets all changes to the "wa_name" field.
  37002. func (m *WhatsappChannelMutation) ResetWaName() {
  37003. m.wa_name = nil
  37004. delete(m.clearedFields, whatsappchannel.FieldWaName)
  37005. }
  37006. // SetWabaID sets the "waba_id" field.
  37007. func (m *WhatsappChannelMutation) SetWabaID(u uint64) {
  37008. m.waba_id = &u
  37009. m.addwaba_id = nil
  37010. }
  37011. // WabaID returns the value of the "waba_id" field in the mutation.
  37012. func (m *WhatsappChannelMutation) WabaID() (r uint64, exists bool) {
  37013. v := m.waba_id
  37014. if v == nil {
  37015. return
  37016. }
  37017. return *v, true
  37018. }
  37019. // OldWabaID returns the old "waba_id" field's value of the WhatsappChannel entity.
  37020. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37021. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37022. func (m *WhatsappChannelMutation) OldWabaID(ctx context.Context) (v uint64, err error) {
  37023. if !m.op.Is(OpUpdateOne) {
  37024. return v, errors.New("OldWabaID is only allowed on UpdateOne operations")
  37025. }
  37026. if m.id == nil || m.oldValue == nil {
  37027. return v, errors.New("OldWabaID requires an ID field in the mutation")
  37028. }
  37029. oldValue, err := m.oldValue(ctx)
  37030. if err != nil {
  37031. return v, fmt.Errorf("querying old value for OldWabaID: %w", err)
  37032. }
  37033. return oldValue.WabaID, nil
  37034. }
  37035. // AddWabaID adds u to the "waba_id" field.
  37036. func (m *WhatsappChannelMutation) AddWabaID(u int64) {
  37037. if m.addwaba_id != nil {
  37038. *m.addwaba_id += u
  37039. } else {
  37040. m.addwaba_id = &u
  37041. }
  37042. }
  37043. // AddedWabaID returns the value that was added to the "waba_id" field in this mutation.
  37044. func (m *WhatsappChannelMutation) AddedWabaID() (r int64, exists bool) {
  37045. v := m.addwaba_id
  37046. if v == nil {
  37047. return
  37048. }
  37049. return *v, true
  37050. }
  37051. // ResetWabaID resets all changes to the "waba_id" field.
  37052. func (m *WhatsappChannelMutation) ResetWabaID() {
  37053. m.waba_id = nil
  37054. m.addwaba_id = nil
  37055. }
  37056. // SetBusinessID sets the "business_id" field.
  37057. func (m *WhatsappChannelMutation) SetBusinessID(u uint64) {
  37058. m.business_id = &u
  37059. m.addbusiness_id = nil
  37060. }
  37061. // BusinessID returns the value of the "business_id" field in the mutation.
  37062. func (m *WhatsappChannelMutation) BusinessID() (r uint64, exists bool) {
  37063. v := m.business_id
  37064. if v == nil {
  37065. return
  37066. }
  37067. return *v, true
  37068. }
  37069. // OldBusinessID returns the old "business_id" field's value of the WhatsappChannel entity.
  37070. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37071. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37072. func (m *WhatsappChannelMutation) OldBusinessID(ctx context.Context) (v uint64, err error) {
  37073. if !m.op.Is(OpUpdateOne) {
  37074. return v, errors.New("OldBusinessID is only allowed on UpdateOne operations")
  37075. }
  37076. if m.id == nil || m.oldValue == nil {
  37077. return v, errors.New("OldBusinessID requires an ID field in the mutation")
  37078. }
  37079. oldValue, err := m.oldValue(ctx)
  37080. if err != nil {
  37081. return v, fmt.Errorf("querying old value for OldBusinessID: %w", err)
  37082. }
  37083. return oldValue.BusinessID, nil
  37084. }
  37085. // AddBusinessID adds u to the "business_id" field.
  37086. func (m *WhatsappChannelMutation) AddBusinessID(u int64) {
  37087. if m.addbusiness_id != nil {
  37088. *m.addbusiness_id += u
  37089. } else {
  37090. m.addbusiness_id = &u
  37091. }
  37092. }
  37093. // AddedBusinessID returns the value that was added to the "business_id" field in this mutation.
  37094. func (m *WhatsappChannelMutation) AddedBusinessID() (r int64, exists bool) {
  37095. v := m.addbusiness_id
  37096. if v == nil {
  37097. return
  37098. }
  37099. return *v, true
  37100. }
  37101. // ResetBusinessID resets all changes to the "business_id" field.
  37102. func (m *WhatsappChannelMutation) ResetBusinessID() {
  37103. m.business_id = nil
  37104. m.addbusiness_id = nil
  37105. }
  37106. // SetOrganizationID sets the "organization_id" field.
  37107. func (m *WhatsappChannelMutation) SetOrganizationID(u uint64) {
  37108. m.organization_id = &u
  37109. m.addorganization_id = nil
  37110. }
  37111. // OrganizationID returns the value of the "organization_id" field in the mutation.
  37112. func (m *WhatsappChannelMutation) OrganizationID() (r uint64, exists bool) {
  37113. v := m.organization_id
  37114. if v == nil {
  37115. return
  37116. }
  37117. return *v, true
  37118. }
  37119. // OldOrganizationID returns the old "organization_id" field's value of the WhatsappChannel entity.
  37120. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37121. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37122. func (m *WhatsappChannelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  37123. if !m.op.Is(OpUpdateOne) {
  37124. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  37125. }
  37126. if m.id == nil || m.oldValue == nil {
  37127. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  37128. }
  37129. oldValue, err := m.oldValue(ctx)
  37130. if err != nil {
  37131. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  37132. }
  37133. return oldValue.OrganizationID, nil
  37134. }
  37135. // AddOrganizationID adds u to the "organization_id" field.
  37136. func (m *WhatsappChannelMutation) AddOrganizationID(u int64) {
  37137. if m.addorganization_id != nil {
  37138. *m.addorganization_id += u
  37139. } else {
  37140. m.addorganization_id = &u
  37141. }
  37142. }
  37143. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  37144. func (m *WhatsappChannelMutation) AddedOrganizationID() (r int64, exists bool) {
  37145. v := m.addorganization_id
  37146. if v == nil {
  37147. return
  37148. }
  37149. return *v, true
  37150. }
  37151. // ClearOrganizationID clears the value of the "organization_id" field.
  37152. func (m *WhatsappChannelMutation) ClearOrganizationID() {
  37153. m.organization_id = nil
  37154. m.addorganization_id = nil
  37155. m.clearedFields[whatsappchannel.FieldOrganizationID] = struct{}{}
  37156. }
  37157. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  37158. func (m *WhatsappChannelMutation) OrganizationIDCleared() bool {
  37159. _, ok := m.clearedFields[whatsappchannel.FieldOrganizationID]
  37160. return ok
  37161. }
  37162. // ResetOrganizationID resets all changes to the "organization_id" field.
  37163. func (m *WhatsappChannelMutation) ResetOrganizationID() {
  37164. m.organization_id = nil
  37165. m.addorganization_id = nil
  37166. delete(m.clearedFields, whatsappchannel.FieldOrganizationID)
  37167. }
  37168. // SetVerifyAccount sets the "verify_account" field.
  37169. func (m *WhatsappChannelMutation) SetVerifyAccount(s string) {
  37170. m.verify_account = &s
  37171. }
  37172. // VerifyAccount returns the value of the "verify_account" field in the mutation.
  37173. func (m *WhatsappChannelMutation) VerifyAccount() (r string, exists bool) {
  37174. v := m.verify_account
  37175. if v == nil {
  37176. return
  37177. }
  37178. return *v, true
  37179. }
  37180. // OldVerifyAccount returns the old "verify_account" field's value of the WhatsappChannel entity.
  37181. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37182. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37183. func (m *WhatsappChannelMutation) OldVerifyAccount(ctx context.Context) (v string, err error) {
  37184. if !m.op.Is(OpUpdateOne) {
  37185. return v, errors.New("OldVerifyAccount is only allowed on UpdateOne operations")
  37186. }
  37187. if m.id == nil || m.oldValue == nil {
  37188. return v, errors.New("OldVerifyAccount requires an ID field in the mutation")
  37189. }
  37190. oldValue, err := m.oldValue(ctx)
  37191. if err != nil {
  37192. return v, fmt.Errorf("querying old value for OldVerifyAccount: %w", err)
  37193. }
  37194. return oldValue.VerifyAccount, nil
  37195. }
  37196. // ResetVerifyAccount resets all changes to the "verify_account" field.
  37197. func (m *WhatsappChannelMutation) ResetVerifyAccount() {
  37198. m.verify_account = nil
  37199. }
  37200. // Where appends a list predicates to the WhatsappChannelMutation builder.
  37201. func (m *WhatsappChannelMutation) Where(ps ...predicate.WhatsappChannel) {
  37202. m.predicates = append(m.predicates, ps...)
  37203. }
  37204. // WhereP appends storage-level predicates to the WhatsappChannelMutation builder. Using this method,
  37205. // users can use type-assertion to append predicates that do not depend on any generated package.
  37206. func (m *WhatsappChannelMutation) WhereP(ps ...func(*sql.Selector)) {
  37207. p := make([]predicate.WhatsappChannel, len(ps))
  37208. for i := range ps {
  37209. p[i] = ps[i]
  37210. }
  37211. m.Where(p...)
  37212. }
  37213. // Op returns the operation name.
  37214. func (m *WhatsappChannelMutation) Op() Op {
  37215. return m.op
  37216. }
  37217. // SetOp allows setting the mutation operation.
  37218. func (m *WhatsappChannelMutation) SetOp(op Op) {
  37219. m.op = op
  37220. }
  37221. // Type returns the node type of this mutation (WhatsappChannel).
  37222. func (m *WhatsappChannelMutation) Type() string {
  37223. return m.typ
  37224. }
  37225. // Fields returns all fields that were changed during this mutation. Note that in
  37226. // order to get all numeric fields that were incremented/decremented, call
  37227. // AddedFields().
  37228. func (m *WhatsappChannelMutation) Fields() []string {
  37229. fields := make([]string, 0, 12)
  37230. if m.created_at != nil {
  37231. fields = append(fields, whatsappchannel.FieldCreatedAt)
  37232. }
  37233. if m.updated_at != nil {
  37234. fields = append(fields, whatsappchannel.FieldUpdatedAt)
  37235. }
  37236. if m.status != nil {
  37237. fields = append(fields, whatsappchannel.FieldStatus)
  37238. }
  37239. if m.deleted_at != nil {
  37240. fields = append(fields, whatsappchannel.FieldDeletedAt)
  37241. }
  37242. if m.ak != nil {
  37243. fields = append(fields, whatsappchannel.FieldAk)
  37244. }
  37245. if m.sk != nil {
  37246. fields = append(fields, whatsappchannel.FieldSk)
  37247. }
  37248. if m.wa_id != nil {
  37249. fields = append(fields, whatsappchannel.FieldWaID)
  37250. }
  37251. if m.wa_name != nil {
  37252. fields = append(fields, whatsappchannel.FieldWaName)
  37253. }
  37254. if m.waba_id != nil {
  37255. fields = append(fields, whatsappchannel.FieldWabaID)
  37256. }
  37257. if m.business_id != nil {
  37258. fields = append(fields, whatsappchannel.FieldBusinessID)
  37259. }
  37260. if m.organization_id != nil {
  37261. fields = append(fields, whatsappchannel.FieldOrganizationID)
  37262. }
  37263. if m.verify_account != nil {
  37264. fields = append(fields, whatsappchannel.FieldVerifyAccount)
  37265. }
  37266. return fields
  37267. }
  37268. // Field returns the value of a field with the given name. The second boolean
  37269. // return value indicates that this field was not set, or was not defined in the
  37270. // schema.
  37271. func (m *WhatsappChannelMutation) Field(name string) (ent.Value, bool) {
  37272. switch name {
  37273. case whatsappchannel.FieldCreatedAt:
  37274. return m.CreatedAt()
  37275. case whatsappchannel.FieldUpdatedAt:
  37276. return m.UpdatedAt()
  37277. case whatsappchannel.FieldStatus:
  37278. return m.Status()
  37279. case whatsappchannel.FieldDeletedAt:
  37280. return m.DeletedAt()
  37281. case whatsappchannel.FieldAk:
  37282. return m.Ak()
  37283. case whatsappchannel.FieldSk:
  37284. return m.Sk()
  37285. case whatsappchannel.FieldWaID:
  37286. return m.WaID()
  37287. case whatsappchannel.FieldWaName:
  37288. return m.WaName()
  37289. case whatsappchannel.FieldWabaID:
  37290. return m.WabaID()
  37291. case whatsappchannel.FieldBusinessID:
  37292. return m.BusinessID()
  37293. case whatsappchannel.FieldOrganizationID:
  37294. return m.OrganizationID()
  37295. case whatsappchannel.FieldVerifyAccount:
  37296. return m.VerifyAccount()
  37297. }
  37298. return nil, false
  37299. }
  37300. // OldField returns the old value of the field from the database. An error is
  37301. // returned if the mutation operation is not UpdateOne, or the query to the
  37302. // database failed.
  37303. func (m *WhatsappChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37304. switch name {
  37305. case whatsappchannel.FieldCreatedAt:
  37306. return m.OldCreatedAt(ctx)
  37307. case whatsappchannel.FieldUpdatedAt:
  37308. return m.OldUpdatedAt(ctx)
  37309. case whatsappchannel.FieldStatus:
  37310. return m.OldStatus(ctx)
  37311. case whatsappchannel.FieldDeletedAt:
  37312. return m.OldDeletedAt(ctx)
  37313. case whatsappchannel.FieldAk:
  37314. return m.OldAk(ctx)
  37315. case whatsappchannel.FieldSk:
  37316. return m.OldSk(ctx)
  37317. case whatsappchannel.FieldWaID:
  37318. return m.OldWaID(ctx)
  37319. case whatsappchannel.FieldWaName:
  37320. return m.OldWaName(ctx)
  37321. case whatsappchannel.FieldWabaID:
  37322. return m.OldWabaID(ctx)
  37323. case whatsappchannel.FieldBusinessID:
  37324. return m.OldBusinessID(ctx)
  37325. case whatsappchannel.FieldOrganizationID:
  37326. return m.OldOrganizationID(ctx)
  37327. case whatsappchannel.FieldVerifyAccount:
  37328. return m.OldVerifyAccount(ctx)
  37329. }
  37330. return nil, fmt.Errorf("unknown WhatsappChannel field %s", name)
  37331. }
  37332. // SetField sets the value of a field with the given name. It returns an error if
  37333. // the field is not defined in the schema, or if the type mismatched the field
  37334. // type.
  37335. func (m *WhatsappChannelMutation) SetField(name string, value ent.Value) error {
  37336. switch name {
  37337. case whatsappchannel.FieldCreatedAt:
  37338. v, ok := value.(time.Time)
  37339. if !ok {
  37340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37341. }
  37342. m.SetCreatedAt(v)
  37343. return nil
  37344. case whatsappchannel.FieldUpdatedAt:
  37345. v, ok := value.(time.Time)
  37346. if !ok {
  37347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37348. }
  37349. m.SetUpdatedAt(v)
  37350. return nil
  37351. case whatsappchannel.FieldStatus:
  37352. v, ok := value.(uint8)
  37353. if !ok {
  37354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37355. }
  37356. m.SetStatus(v)
  37357. return nil
  37358. case whatsappchannel.FieldDeletedAt:
  37359. v, ok := value.(time.Time)
  37360. if !ok {
  37361. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37362. }
  37363. m.SetDeletedAt(v)
  37364. return nil
  37365. case whatsappchannel.FieldAk:
  37366. v, ok := value.(string)
  37367. if !ok {
  37368. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37369. }
  37370. m.SetAk(v)
  37371. return nil
  37372. case whatsappchannel.FieldSk:
  37373. v, ok := value.(string)
  37374. if !ok {
  37375. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37376. }
  37377. m.SetSk(v)
  37378. return nil
  37379. case whatsappchannel.FieldWaID:
  37380. v, ok := value.(string)
  37381. if !ok {
  37382. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37383. }
  37384. m.SetWaID(v)
  37385. return nil
  37386. case whatsappchannel.FieldWaName:
  37387. v, ok := value.(string)
  37388. if !ok {
  37389. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37390. }
  37391. m.SetWaName(v)
  37392. return nil
  37393. case whatsappchannel.FieldWabaID:
  37394. v, ok := value.(uint64)
  37395. if !ok {
  37396. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37397. }
  37398. m.SetWabaID(v)
  37399. return nil
  37400. case whatsappchannel.FieldBusinessID:
  37401. v, ok := value.(uint64)
  37402. if !ok {
  37403. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37404. }
  37405. m.SetBusinessID(v)
  37406. return nil
  37407. case whatsappchannel.FieldOrganizationID:
  37408. v, ok := value.(uint64)
  37409. if !ok {
  37410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37411. }
  37412. m.SetOrganizationID(v)
  37413. return nil
  37414. case whatsappchannel.FieldVerifyAccount:
  37415. v, ok := value.(string)
  37416. if !ok {
  37417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37418. }
  37419. m.SetVerifyAccount(v)
  37420. return nil
  37421. }
  37422. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  37423. }
  37424. // AddedFields returns all numeric fields that were incremented/decremented during
  37425. // this mutation.
  37426. func (m *WhatsappChannelMutation) AddedFields() []string {
  37427. var fields []string
  37428. if m.addstatus != nil {
  37429. fields = append(fields, whatsappchannel.FieldStatus)
  37430. }
  37431. if m.addwaba_id != nil {
  37432. fields = append(fields, whatsappchannel.FieldWabaID)
  37433. }
  37434. if m.addbusiness_id != nil {
  37435. fields = append(fields, whatsappchannel.FieldBusinessID)
  37436. }
  37437. if m.addorganization_id != nil {
  37438. fields = append(fields, whatsappchannel.FieldOrganizationID)
  37439. }
  37440. return fields
  37441. }
  37442. // AddedField returns the numeric value that was incremented/decremented on a field
  37443. // with the given name. The second boolean return value indicates that this field
  37444. // was not set, or was not defined in the schema.
  37445. func (m *WhatsappChannelMutation) AddedField(name string) (ent.Value, bool) {
  37446. switch name {
  37447. case whatsappchannel.FieldStatus:
  37448. return m.AddedStatus()
  37449. case whatsappchannel.FieldWabaID:
  37450. return m.AddedWabaID()
  37451. case whatsappchannel.FieldBusinessID:
  37452. return m.AddedBusinessID()
  37453. case whatsappchannel.FieldOrganizationID:
  37454. return m.AddedOrganizationID()
  37455. }
  37456. return nil, false
  37457. }
  37458. // AddField adds the value to the field with the given name. It returns an error if
  37459. // the field is not defined in the schema, or if the type mismatched the field
  37460. // type.
  37461. func (m *WhatsappChannelMutation) AddField(name string, value ent.Value) error {
  37462. switch name {
  37463. case whatsappchannel.FieldStatus:
  37464. v, ok := value.(int8)
  37465. if !ok {
  37466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37467. }
  37468. m.AddStatus(v)
  37469. return nil
  37470. case whatsappchannel.FieldWabaID:
  37471. v, ok := value.(int64)
  37472. if !ok {
  37473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37474. }
  37475. m.AddWabaID(v)
  37476. return nil
  37477. case whatsappchannel.FieldBusinessID:
  37478. v, ok := value.(int64)
  37479. if !ok {
  37480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37481. }
  37482. m.AddBusinessID(v)
  37483. return nil
  37484. case whatsappchannel.FieldOrganizationID:
  37485. v, ok := value.(int64)
  37486. if !ok {
  37487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37488. }
  37489. m.AddOrganizationID(v)
  37490. return nil
  37491. }
  37492. return fmt.Errorf("unknown WhatsappChannel numeric field %s", name)
  37493. }
  37494. // ClearedFields returns all nullable fields that were cleared during this
  37495. // mutation.
  37496. func (m *WhatsappChannelMutation) ClearedFields() []string {
  37497. var fields []string
  37498. if m.FieldCleared(whatsappchannel.FieldStatus) {
  37499. fields = append(fields, whatsappchannel.FieldStatus)
  37500. }
  37501. if m.FieldCleared(whatsappchannel.FieldDeletedAt) {
  37502. fields = append(fields, whatsappchannel.FieldDeletedAt)
  37503. }
  37504. if m.FieldCleared(whatsappchannel.FieldAk) {
  37505. fields = append(fields, whatsappchannel.FieldAk)
  37506. }
  37507. if m.FieldCleared(whatsappchannel.FieldWaID) {
  37508. fields = append(fields, whatsappchannel.FieldWaID)
  37509. }
  37510. if m.FieldCleared(whatsappchannel.FieldWaName) {
  37511. fields = append(fields, whatsappchannel.FieldWaName)
  37512. }
  37513. if m.FieldCleared(whatsappchannel.FieldOrganizationID) {
  37514. fields = append(fields, whatsappchannel.FieldOrganizationID)
  37515. }
  37516. return fields
  37517. }
  37518. // FieldCleared returns a boolean indicating if a field with the given name was
  37519. // cleared in this mutation.
  37520. func (m *WhatsappChannelMutation) FieldCleared(name string) bool {
  37521. _, ok := m.clearedFields[name]
  37522. return ok
  37523. }
  37524. // ClearField clears the value of the field with the given name. It returns an
  37525. // error if the field is not defined in the schema.
  37526. func (m *WhatsappChannelMutation) ClearField(name string) error {
  37527. switch name {
  37528. case whatsappchannel.FieldStatus:
  37529. m.ClearStatus()
  37530. return nil
  37531. case whatsappchannel.FieldDeletedAt:
  37532. m.ClearDeletedAt()
  37533. return nil
  37534. case whatsappchannel.FieldAk:
  37535. m.ClearAk()
  37536. return nil
  37537. case whatsappchannel.FieldWaID:
  37538. m.ClearWaID()
  37539. return nil
  37540. case whatsappchannel.FieldWaName:
  37541. m.ClearWaName()
  37542. return nil
  37543. case whatsappchannel.FieldOrganizationID:
  37544. m.ClearOrganizationID()
  37545. return nil
  37546. }
  37547. return fmt.Errorf("unknown WhatsappChannel nullable field %s", name)
  37548. }
  37549. // ResetField resets all changes in the mutation for the field with the given name.
  37550. // It returns an error if the field is not defined in the schema.
  37551. func (m *WhatsappChannelMutation) ResetField(name string) error {
  37552. switch name {
  37553. case whatsappchannel.FieldCreatedAt:
  37554. m.ResetCreatedAt()
  37555. return nil
  37556. case whatsappchannel.FieldUpdatedAt:
  37557. m.ResetUpdatedAt()
  37558. return nil
  37559. case whatsappchannel.FieldStatus:
  37560. m.ResetStatus()
  37561. return nil
  37562. case whatsappchannel.FieldDeletedAt:
  37563. m.ResetDeletedAt()
  37564. return nil
  37565. case whatsappchannel.FieldAk:
  37566. m.ResetAk()
  37567. return nil
  37568. case whatsappchannel.FieldSk:
  37569. m.ResetSk()
  37570. return nil
  37571. case whatsappchannel.FieldWaID:
  37572. m.ResetWaID()
  37573. return nil
  37574. case whatsappchannel.FieldWaName:
  37575. m.ResetWaName()
  37576. return nil
  37577. case whatsappchannel.FieldWabaID:
  37578. m.ResetWabaID()
  37579. return nil
  37580. case whatsappchannel.FieldBusinessID:
  37581. m.ResetBusinessID()
  37582. return nil
  37583. case whatsappchannel.FieldOrganizationID:
  37584. m.ResetOrganizationID()
  37585. return nil
  37586. case whatsappchannel.FieldVerifyAccount:
  37587. m.ResetVerifyAccount()
  37588. return nil
  37589. }
  37590. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  37591. }
  37592. // AddedEdges returns all edge names that were set/added in this mutation.
  37593. func (m *WhatsappChannelMutation) AddedEdges() []string {
  37594. edges := make([]string, 0, 0)
  37595. return edges
  37596. }
  37597. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37598. // name in this mutation.
  37599. func (m *WhatsappChannelMutation) AddedIDs(name string) []ent.Value {
  37600. return nil
  37601. }
  37602. // RemovedEdges returns all edge names that were removed in this mutation.
  37603. func (m *WhatsappChannelMutation) RemovedEdges() []string {
  37604. edges := make([]string, 0, 0)
  37605. return edges
  37606. }
  37607. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37608. // the given name in this mutation.
  37609. func (m *WhatsappChannelMutation) RemovedIDs(name string) []ent.Value {
  37610. return nil
  37611. }
  37612. // ClearedEdges returns all edge names that were cleared in this mutation.
  37613. func (m *WhatsappChannelMutation) ClearedEdges() []string {
  37614. edges := make([]string, 0, 0)
  37615. return edges
  37616. }
  37617. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37618. // was cleared in this mutation.
  37619. func (m *WhatsappChannelMutation) EdgeCleared(name string) bool {
  37620. return false
  37621. }
  37622. // ClearEdge clears the value of the edge with the given name. It returns an error
  37623. // if that edge is not defined in the schema.
  37624. func (m *WhatsappChannelMutation) ClearEdge(name string) error {
  37625. return fmt.Errorf("unknown WhatsappChannel unique edge %s", name)
  37626. }
  37627. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37628. // It returns an error if the edge is not defined in the schema.
  37629. func (m *WhatsappChannelMutation) ResetEdge(name string) error {
  37630. return fmt.Errorf("unknown WhatsappChannel edge %s", name)
  37631. }
  37632. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  37633. type WorkExperienceMutation struct {
  37634. config
  37635. op Op
  37636. typ string
  37637. id *uint64
  37638. created_at *time.Time
  37639. updated_at *time.Time
  37640. deleted_at *time.Time
  37641. start_date *time.Time
  37642. end_date *time.Time
  37643. company *string
  37644. experience *string
  37645. organization_id *uint64
  37646. addorganization_id *int64
  37647. clearedFields map[string]struct{}
  37648. employee *uint64
  37649. clearedemployee bool
  37650. done bool
  37651. oldValue func(context.Context) (*WorkExperience, error)
  37652. predicates []predicate.WorkExperience
  37653. }
  37654. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  37655. // workexperienceOption allows management of the mutation configuration using functional options.
  37656. type workexperienceOption func(*WorkExperienceMutation)
  37657. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  37658. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  37659. m := &WorkExperienceMutation{
  37660. config: c,
  37661. op: op,
  37662. typ: TypeWorkExperience,
  37663. clearedFields: make(map[string]struct{}),
  37664. }
  37665. for _, opt := range opts {
  37666. opt(m)
  37667. }
  37668. return m
  37669. }
  37670. // withWorkExperienceID sets the ID field of the mutation.
  37671. func withWorkExperienceID(id uint64) workexperienceOption {
  37672. return func(m *WorkExperienceMutation) {
  37673. var (
  37674. err error
  37675. once sync.Once
  37676. value *WorkExperience
  37677. )
  37678. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  37679. once.Do(func() {
  37680. if m.done {
  37681. err = errors.New("querying old values post mutation is not allowed")
  37682. } else {
  37683. value, err = m.Client().WorkExperience.Get(ctx, id)
  37684. }
  37685. })
  37686. return value, err
  37687. }
  37688. m.id = &id
  37689. }
  37690. }
  37691. // withWorkExperience sets the old WorkExperience of the mutation.
  37692. func withWorkExperience(node *WorkExperience) workexperienceOption {
  37693. return func(m *WorkExperienceMutation) {
  37694. m.oldValue = func(context.Context) (*WorkExperience, error) {
  37695. return node, nil
  37696. }
  37697. m.id = &node.ID
  37698. }
  37699. }
  37700. // Client returns a new `ent.Client` from the mutation. If the mutation was
  37701. // executed in a transaction (ent.Tx), a transactional client is returned.
  37702. func (m WorkExperienceMutation) Client() *Client {
  37703. client := &Client{config: m.config}
  37704. client.init()
  37705. return client
  37706. }
  37707. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  37708. // it returns an error otherwise.
  37709. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  37710. if _, ok := m.driver.(*txDriver); !ok {
  37711. return nil, errors.New("ent: mutation is not running in a transaction")
  37712. }
  37713. tx := &Tx{config: m.config}
  37714. tx.init()
  37715. return tx, nil
  37716. }
  37717. // SetID sets the value of the id field. Note that this
  37718. // operation is only accepted on creation of WorkExperience entities.
  37719. func (m *WorkExperienceMutation) SetID(id uint64) {
  37720. m.id = &id
  37721. }
  37722. // ID returns the ID value in the mutation. Note that the ID is only available
  37723. // if it was provided to the builder or after it was returned from the database.
  37724. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  37725. if m.id == nil {
  37726. return
  37727. }
  37728. return *m.id, true
  37729. }
  37730. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  37731. // That means, if the mutation is applied within a transaction with an isolation level such
  37732. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  37733. // or updated by the mutation.
  37734. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  37735. switch {
  37736. case m.op.Is(OpUpdateOne | OpDeleteOne):
  37737. id, exists := m.ID()
  37738. if exists {
  37739. return []uint64{id}, nil
  37740. }
  37741. fallthrough
  37742. case m.op.Is(OpUpdate | OpDelete):
  37743. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  37744. default:
  37745. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  37746. }
  37747. }
  37748. // SetCreatedAt sets the "created_at" field.
  37749. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  37750. m.created_at = &t
  37751. }
  37752. // CreatedAt returns the value of the "created_at" field in the mutation.
  37753. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  37754. v := m.created_at
  37755. if v == nil {
  37756. return
  37757. }
  37758. return *v, true
  37759. }
  37760. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  37761. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37762. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37763. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  37764. if !m.op.Is(OpUpdateOne) {
  37765. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  37766. }
  37767. if m.id == nil || m.oldValue == nil {
  37768. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  37769. }
  37770. oldValue, err := m.oldValue(ctx)
  37771. if err != nil {
  37772. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  37773. }
  37774. return oldValue.CreatedAt, nil
  37775. }
  37776. // ResetCreatedAt resets all changes to the "created_at" field.
  37777. func (m *WorkExperienceMutation) ResetCreatedAt() {
  37778. m.created_at = nil
  37779. }
  37780. // SetUpdatedAt sets the "updated_at" field.
  37781. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  37782. m.updated_at = &t
  37783. }
  37784. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  37785. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  37786. v := m.updated_at
  37787. if v == nil {
  37788. return
  37789. }
  37790. return *v, true
  37791. }
  37792. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  37793. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37794. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37795. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  37796. if !m.op.Is(OpUpdateOne) {
  37797. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  37798. }
  37799. if m.id == nil || m.oldValue == nil {
  37800. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  37801. }
  37802. oldValue, err := m.oldValue(ctx)
  37803. if err != nil {
  37804. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  37805. }
  37806. return oldValue.UpdatedAt, nil
  37807. }
  37808. // ResetUpdatedAt resets all changes to the "updated_at" field.
  37809. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  37810. m.updated_at = nil
  37811. }
  37812. // SetDeletedAt sets the "deleted_at" field.
  37813. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  37814. m.deleted_at = &t
  37815. }
  37816. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  37817. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  37818. v := m.deleted_at
  37819. if v == nil {
  37820. return
  37821. }
  37822. return *v, true
  37823. }
  37824. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  37825. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37826. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37827. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  37828. if !m.op.Is(OpUpdateOne) {
  37829. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  37830. }
  37831. if m.id == nil || m.oldValue == nil {
  37832. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  37833. }
  37834. oldValue, err := m.oldValue(ctx)
  37835. if err != nil {
  37836. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  37837. }
  37838. return oldValue.DeletedAt, nil
  37839. }
  37840. // ClearDeletedAt clears the value of the "deleted_at" field.
  37841. func (m *WorkExperienceMutation) ClearDeletedAt() {
  37842. m.deleted_at = nil
  37843. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  37844. }
  37845. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  37846. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  37847. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  37848. return ok
  37849. }
  37850. // ResetDeletedAt resets all changes to the "deleted_at" field.
  37851. func (m *WorkExperienceMutation) ResetDeletedAt() {
  37852. m.deleted_at = nil
  37853. delete(m.clearedFields, workexperience.FieldDeletedAt)
  37854. }
  37855. // SetEmployeeID sets the "employee_id" field.
  37856. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  37857. m.employee = &u
  37858. }
  37859. // EmployeeID returns the value of the "employee_id" field in the mutation.
  37860. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  37861. v := m.employee
  37862. if v == nil {
  37863. return
  37864. }
  37865. return *v, true
  37866. }
  37867. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  37868. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37869. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37870. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  37871. if !m.op.Is(OpUpdateOne) {
  37872. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  37873. }
  37874. if m.id == nil || m.oldValue == nil {
  37875. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  37876. }
  37877. oldValue, err := m.oldValue(ctx)
  37878. if err != nil {
  37879. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  37880. }
  37881. return oldValue.EmployeeID, nil
  37882. }
  37883. // ResetEmployeeID resets all changes to the "employee_id" field.
  37884. func (m *WorkExperienceMutation) ResetEmployeeID() {
  37885. m.employee = nil
  37886. }
  37887. // SetStartDate sets the "start_date" field.
  37888. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  37889. m.start_date = &t
  37890. }
  37891. // StartDate returns the value of the "start_date" field in the mutation.
  37892. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  37893. v := m.start_date
  37894. if v == nil {
  37895. return
  37896. }
  37897. return *v, true
  37898. }
  37899. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  37900. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37901. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37902. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  37903. if !m.op.Is(OpUpdateOne) {
  37904. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  37905. }
  37906. if m.id == nil || m.oldValue == nil {
  37907. return v, errors.New("OldStartDate requires an ID field in the mutation")
  37908. }
  37909. oldValue, err := m.oldValue(ctx)
  37910. if err != nil {
  37911. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  37912. }
  37913. return oldValue.StartDate, nil
  37914. }
  37915. // ResetStartDate resets all changes to the "start_date" field.
  37916. func (m *WorkExperienceMutation) ResetStartDate() {
  37917. m.start_date = nil
  37918. }
  37919. // SetEndDate sets the "end_date" field.
  37920. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  37921. m.end_date = &t
  37922. }
  37923. // EndDate returns the value of the "end_date" field in the mutation.
  37924. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  37925. v := m.end_date
  37926. if v == nil {
  37927. return
  37928. }
  37929. return *v, true
  37930. }
  37931. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  37932. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37933. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37934. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  37935. if !m.op.Is(OpUpdateOne) {
  37936. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  37937. }
  37938. if m.id == nil || m.oldValue == nil {
  37939. return v, errors.New("OldEndDate requires an ID field in the mutation")
  37940. }
  37941. oldValue, err := m.oldValue(ctx)
  37942. if err != nil {
  37943. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  37944. }
  37945. return oldValue.EndDate, nil
  37946. }
  37947. // ResetEndDate resets all changes to the "end_date" field.
  37948. func (m *WorkExperienceMutation) ResetEndDate() {
  37949. m.end_date = nil
  37950. }
  37951. // SetCompany sets the "company" field.
  37952. func (m *WorkExperienceMutation) SetCompany(s string) {
  37953. m.company = &s
  37954. }
  37955. // Company returns the value of the "company" field in the mutation.
  37956. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  37957. v := m.company
  37958. if v == nil {
  37959. return
  37960. }
  37961. return *v, true
  37962. }
  37963. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  37964. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37965. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37966. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  37967. if !m.op.Is(OpUpdateOne) {
  37968. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  37969. }
  37970. if m.id == nil || m.oldValue == nil {
  37971. return v, errors.New("OldCompany requires an ID field in the mutation")
  37972. }
  37973. oldValue, err := m.oldValue(ctx)
  37974. if err != nil {
  37975. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  37976. }
  37977. return oldValue.Company, nil
  37978. }
  37979. // ResetCompany resets all changes to the "company" field.
  37980. func (m *WorkExperienceMutation) ResetCompany() {
  37981. m.company = nil
  37982. }
  37983. // SetExperience sets the "experience" field.
  37984. func (m *WorkExperienceMutation) SetExperience(s string) {
  37985. m.experience = &s
  37986. }
  37987. // Experience returns the value of the "experience" field in the mutation.
  37988. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  37989. v := m.experience
  37990. if v == nil {
  37991. return
  37992. }
  37993. return *v, true
  37994. }
  37995. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  37996. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37997. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37998. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  37999. if !m.op.Is(OpUpdateOne) {
  38000. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  38001. }
  38002. if m.id == nil || m.oldValue == nil {
  38003. return v, errors.New("OldExperience requires an ID field in the mutation")
  38004. }
  38005. oldValue, err := m.oldValue(ctx)
  38006. if err != nil {
  38007. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  38008. }
  38009. return oldValue.Experience, nil
  38010. }
  38011. // ResetExperience resets all changes to the "experience" field.
  38012. func (m *WorkExperienceMutation) ResetExperience() {
  38013. m.experience = nil
  38014. }
  38015. // SetOrganizationID sets the "organization_id" field.
  38016. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  38017. m.organization_id = &u
  38018. m.addorganization_id = nil
  38019. }
  38020. // OrganizationID returns the value of the "organization_id" field in the mutation.
  38021. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  38022. v := m.organization_id
  38023. if v == nil {
  38024. return
  38025. }
  38026. return *v, true
  38027. }
  38028. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  38029. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  38030. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38031. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  38032. if !m.op.Is(OpUpdateOne) {
  38033. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  38034. }
  38035. if m.id == nil || m.oldValue == nil {
  38036. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  38037. }
  38038. oldValue, err := m.oldValue(ctx)
  38039. if err != nil {
  38040. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  38041. }
  38042. return oldValue.OrganizationID, nil
  38043. }
  38044. // AddOrganizationID adds u to the "organization_id" field.
  38045. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  38046. if m.addorganization_id != nil {
  38047. *m.addorganization_id += u
  38048. } else {
  38049. m.addorganization_id = &u
  38050. }
  38051. }
  38052. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  38053. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  38054. v := m.addorganization_id
  38055. if v == nil {
  38056. return
  38057. }
  38058. return *v, true
  38059. }
  38060. // ResetOrganizationID resets all changes to the "organization_id" field.
  38061. func (m *WorkExperienceMutation) ResetOrganizationID() {
  38062. m.organization_id = nil
  38063. m.addorganization_id = nil
  38064. }
  38065. // ClearEmployee clears the "employee" edge to the Employee entity.
  38066. func (m *WorkExperienceMutation) ClearEmployee() {
  38067. m.clearedemployee = true
  38068. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  38069. }
  38070. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  38071. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  38072. return m.clearedemployee
  38073. }
  38074. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  38075. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  38076. // EmployeeID instead. It exists only for internal usage by the builders.
  38077. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  38078. if id := m.employee; id != nil {
  38079. ids = append(ids, *id)
  38080. }
  38081. return
  38082. }
  38083. // ResetEmployee resets all changes to the "employee" edge.
  38084. func (m *WorkExperienceMutation) ResetEmployee() {
  38085. m.employee = nil
  38086. m.clearedemployee = false
  38087. }
  38088. // Where appends a list predicates to the WorkExperienceMutation builder.
  38089. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  38090. m.predicates = append(m.predicates, ps...)
  38091. }
  38092. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  38093. // users can use type-assertion to append predicates that do not depend on any generated package.
  38094. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  38095. p := make([]predicate.WorkExperience, len(ps))
  38096. for i := range ps {
  38097. p[i] = ps[i]
  38098. }
  38099. m.Where(p...)
  38100. }
  38101. // Op returns the operation name.
  38102. func (m *WorkExperienceMutation) Op() Op {
  38103. return m.op
  38104. }
  38105. // SetOp allows setting the mutation operation.
  38106. func (m *WorkExperienceMutation) SetOp(op Op) {
  38107. m.op = op
  38108. }
  38109. // Type returns the node type of this mutation (WorkExperience).
  38110. func (m *WorkExperienceMutation) Type() string {
  38111. return m.typ
  38112. }
  38113. // Fields returns all fields that were changed during this mutation. Note that in
  38114. // order to get all numeric fields that were incremented/decremented, call
  38115. // AddedFields().
  38116. func (m *WorkExperienceMutation) Fields() []string {
  38117. fields := make([]string, 0, 9)
  38118. if m.created_at != nil {
  38119. fields = append(fields, workexperience.FieldCreatedAt)
  38120. }
  38121. if m.updated_at != nil {
  38122. fields = append(fields, workexperience.FieldUpdatedAt)
  38123. }
  38124. if m.deleted_at != nil {
  38125. fields = append(fields, workexperience.FieldDeletedAt)
  38126. }
  38127. if m.employee != nil {
  38128. fields = append(fields, workexperience.FieldEmployeeID)
  38129. }
  38130. if m.start_date != nil {
  38131. fields = append(fields, workexperience.FieldStartDate)
  38132. }
  38133. if m.end_date != nil {
  38134. fields = append(fields, workexperience.FieldEndDate)
  38135. }
  38136. if m.company != nil {
  38137. fields = append(fields, workexperience.FieldCompany)
  38138. }
  38139. if m.experience != nil {
  38140. fields = append(fields, workexperience.FieldExperience)
  38141. }
  38142. if m.organization_id != nil {
  38143. fields = append(fields, workexperience.FieldOrganizationID)
  38144. }
  38145. return fields
  38146. }
  38147. // Field returns the value of a field with the given name. The second boolean
  38148. // return value indicates that this field was not set, or was not defined in the
  38149. // schema.
  38150. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  38151. switch name {
  38152. case workexperience.FieldCreatedAt:
  38153. return m.CreatedAt()
  38154. case workexperience.FieldUpdatedAt:
  38155. return m.UpdatedAt()
  38156. case workexperience.FieldDeletedAt:
  38157. return m.DeletedAt()
  38158. case workexperience.FieldEmployeeID:
  38159. return m.EmployeeID()
  38160. case workexperience.FieldStartDate:
  38161. return m.StartDate()
  38162. case workexperience.FieldEndDate:
  38163. return m.EndDate()
  38164. case workexperience.FieldCompany:
  38165. return m.Company()
  38166. case workexperience.FieldExperience:
  38167. return m.Experience()
  38168. case workexperience.FieldOrganizationID:
  38169. return m.OrganizationID()
  38170. }
  38171. return nil, false
  38172. }
  38173. // OldField returns the old value of the field from the database. An error is
  38174. // returned if the mutation operation is not UpdateOne, or the query to the
  38175. // database failed.
  38176. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  38177. switch name {
  38178. case workexperience.FieldCreatedAt:
  38179. return m.OldCreatedAt(ctx)
  38180. case workexperience.FieldUpdatedAt:
  38181. return m.OldUpdatedAt(ctx)
  38182. case workexperience.FieldDeletedAt:
  38183. return m.OldDeletedAt(ctx)
  38184. case workexperience.FieldEmployeeID:
  38185. return m.OldEmployeeID(ctx)
  38186. case workexperience.FieldStartDate:
  38187. return m.OldStartDate(ctx)
  38188. case workexperience.FieldEndDate:
  38189. return m.OldEndDate(ctx)
  38190. case workexperience.FieldCompany:
  38191. return m.OldCompany(ctx)
  38192. case workexperience.FieldExperience:
  38193. return m.OldExperience(ctx)
  38194. case workexperience.FieldOrganizationID:
  38195. return m.OldOrganizationID(ctx)
  38196. }
  38197. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  38198. }
  38199. // SetField sets the value of a field with the given name. It returns an error if
  38200. // the field is not defined in the schema, or if the type mismatched the field
  38201. // type.
  38202. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  38203. switch name {
  38204. case workexperience.FieldCreatedAt:
  38205. v, ok := value.(time.Time)
  38206. if !ok {
  38207. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38208. }
  38209. m.SetCreatedAt(v)
  38210. return nil
  38211. case workexperience.FieldUpdatedAt:
  38212. v, ok := value.(time.Time)
  38213. if !ok {
  38214. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38215. }
  38216. m.SetUpdatedAt(v)
  38217. return nil
  38218. case workexperience.FieldDeletedAt:
  38219. v, ok := value.(time.Time)
  38220. if !ok {
  38221. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38222. }
  38223. m.SetDeletedAt(v)
  38224. return nil
  38225. case workexperience.FieldEmployeeID:
  38226. v, ok := value.(uint64)
  38227. if !ok {
  38228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38229. }
  38230. m.SetEmployeeID(v)
  38231. return nil
  38232. case workexperience.FieldStartDate:
  38233. v, ok := value.(time.Time)
  38234. if !ok {
  38235. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38236. }
  38237. m.SetStartDate(v)
  38238. return nil
  38239. case workexperience.FieldEndDate:
  38240. v, ok := value.(time.Time)
  38241. if !ok {
  38242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38243. }
  38244. m.SetEndDate(v)
  38245. return nil
  38246. case workexperience.FieldCompany:
  38247. v, ok := value.(string)
  38248. if !ok {
  38249. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38250. }
  38251. m.SetCompany(v)
  38252. return nil
  38253. case workexperience.FieldExperience:
  38254. v, ok := value.(string)
  38255. if !ok {
  38256. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38257. }
  38258. m.SetExperience(v)
  38259. return nil
  38260. case workexperience.FieldOrganizationID:
  38261. v, ok := value.(uint64)
  38262. if !ok {
  38263. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38264. }
  38265. m.SetOrganizationID(v)
  38266. return nil
  38267. }
  38268. return fmt.Errorf("unknown WorkExperience field %s", name)
  38269. }
  38270. // AddedFields returns all numeric fields that were incremented/decremented during
  38271. // this mutation.
  38272. func (m *WorkExperienceMutation) AddedFields() []string {
  38273. var fields []string
  38274. if m.addorganization_id != nil {
  38275. fields = append(fields, workexperience.FieldOrganizationID)
  38276. }
  38277. return fields
  38278. }
  38279. // AddedField returns the numeric value that was incremented/decremented on a field
  38280. // with the given name. The second boolean return value indicates that this field
  38281. // was not set, or was not defined in the schema.
  38282. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  38283. switch name {
  38284. case workexperience.FieldOrganizationID:
  38285. return m.AddedOrganizationID()
  38286. }
  38287. return nil, false
  38288. }
  38289. // AddField adds the value to the field with the given name. It returns an error if
  38290. // the field is not defined in the schema, or if the type mismatched the field
  38291. // type.
  38292. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  38293. switch name {
  38294. case workexperience.FieldOrganizationID:
  38295. v, ok := value.(int64)
  38296. if !ok {
  38297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38298. }
  38299. m.AddOrganizationID(v)
  38300. return nil
  38301. }
  38302. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  38303. }
  38304. // ClearedFields returns all nullable fields that were cleared during this
  38305. // mutation.
  38306. func (m *WorkExperienceMutation) ClearedFields() []string {
  38307. var fields []string
  38308. if m.FieldCleared(workexperience.FieldDeletedAt) {
  38309. fields = append(fields, workexperience.FieldDeletedAt)
  38310. }
  38311. return fields
  38312. }
  38313. // FieldCleared returns a boolean indicating if a field with the given name was
  38314. // cleared in this mutation.
  38315. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  38316. _, ok := m.clearedFields[name]
  38317. return ok
  38318. }
  38319. // ClearField clears the value of the field with the given name. It returns an
  38320. // error if the field is not defined in the schema.
  38321. func (m *WorkExperienceMutation) ClearField(name string) error {
  38322. switch name {
  38323. case workexperience.FieldDeletedAt:
  38324. m.ClearDeletedAt()
  38325. return nil
  38326. }
  38327. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  38328. }
  38329. // ResetField resets all changes in the mutation for the field with the given name.
  38330. // It returns an error if the field is not defined in the schema.
  38331. func (m *WorkExperienceMutation) ResetField(name string) error {
  38332. switch name {
  38333. case workexperience.FieldCreatedAt:
  38334. m.ResetCreatedAt()
  38335. return nil
  38336. case workexperience.FieldUpdatedAt:
  38337. m.ResetUpdatedAt()
  38338. return nil
  38339. case workexperience.FieldDeletedAt:
  38340. m.ResetDeletedAt()
  38341. return nil
  38342. case workexperience.FieldEmployeeID:
  38343. m.ResetEmployeeID()
  38344. return nil
  38345. case workexperience.FieldStartDate:
  38346. m.ResetStartDate()
  38347. return nil
  38348. case workexperience.FieldEndDate:
  38349. m.ResetEndDate()
  38350. return nil
  38351. case workexperience.FieldCompany:
  38352. m.ResetCompany()
  38353. return nil
  38354. case workexperience.FieldExperience:
  38355. m.ResetExperience()
  38356. return nil
  38357. case workexperience.FieldOrganizationID:
  38358. m.ResetOrganizationID()
  38359. return nil
  38360. }
  38361. return fmt.Errorf("unknown WorkExperience field %s", name)
  38362. }
  38363. // AddedEdges returns all edge names that were set/added in this mutation.
  38364. func (m *WorkExperienceMutation) AddedEdges() []string {
  38365. edges := make([]string, 0, 1)
  38366. if m.employee != nil {
  38367. edges = append(edges, workexperience.EdgeEmployee)
  38368. }
  38369. return edges
  38370. }
  38371. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  38372. // name in this mutation.
  38373. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  38374. switch name {
  38375. case workexperience.EdgeEmployee:
  38376. if id := m.employee; id != nil {
  38377. return []ent.Value{*id}
  38378. }
  38379. }
  38380. return nil
  38381. }
  38382. // RemovedEdges returns all edge names that were removed in this mutation.
  38383. func (m *WorkExperienceMutation) RemovedEdges() []string {
  38384. edges := make([]string, 0, 1)
  38385. return edges
  38386. }
  38387. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  38388. // the given name in this mutation.
  38389. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  38390. return nil
  38391. }
  38392. // ClearedEdges returns all edge names that were cleared in this mutation.
  38393. func (m *WorkExperienceMutation) ClearedEdges() []string {
  38394. edges := make([]string, 0, 1)
  38395. if m.clearedemployee {
  38396. edges = append(edges, workexperience.EdgeEmployee)
  38397. }
  38398. return edges
  38399. }
  38400. // EdgeCleared returns a boolean which indicates if the edge with the given name
  38401. // was cleared in this mutation.
  38402. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  38403. switch name {
  38404. case workexperience.EdgeEmployee:
  38405. return m.clearedemployee
  38406. }
  38407. return false
  38408. }
  38409. // ClearEdge clears the value of the edge with the given name. It returns an error
  38410. // if that edge is not defined in the schema.
  38411. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  38412. switch name {
  38413. case workexperience.EdgeEmployee:
  38414. m.ClearEmployee()
  38415. return nil
  38416. }
  38417. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  38418. }
  38419. // ResetEdge resets all changes to the edge with the given name in this mutation.
  38420. // It returns an error if the edge is not defined in the schema.
  38421. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  38422. switch name {
  38423. case workexperience.EdgeEmployee:
  38424. m.ResetEmployee()
  38425. return nil
  38426. }
  38427. return fmt.Errorf("unknown WorkExperience edge %s", name)
  38428. }
  38429. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  38430. type WpChatroomMutation struct {
  38431. config
  38432. op Op
  38433. typ string
  38434. id *uint64
  38435. created_at *time.Time
  38436. updated_at *time.Time
  38437. status *uint8
  38438. addstatus *int8
  38439. wx_wxid *string
  38440. chatroom_id *string
  38441. nickname *string
  38442. owner *string
  38443. avatar *string
  38444. member_list *[]string
  38445. appendmember_list []string
  38446. clearedFields map[string]struct{}
  38447. done bool
  38448. oldValue func(context.Context) (*WpChatroom, error)
  38449. predicates []predicate.WpChatroom
  38450. }
  38451. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  38452. // wpchatroomOption allows management of the mutation configuration using functional options.
  38453. type wpchatroomOption func(*WpChatroomMutation)
  38454. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  38455. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  38456. m := &WpChatroomMutation{
  38457. config: c,
  38458. op: op,
  38459. typ: TypeWpChatroom,
  38460. clearedFields: make(map[string]struct{}),
  38461. }
  38462. for _, opt := range opts {
  38463. opt(m)
  38464. }
  38465. return m
  38466. }
  38467. // withWpChatroomID sets the ID field of the mutation.
  38468. func withWpChatroomID(id uint64) wpchatroomOption {
  38469. return func(m *WpChatroomMutation) {
  38470. var (
  38471. err error
  38472. once sync.Once
  38473. value *WpChatroom
  38474. )
  38475. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  38476. once.Do(func() {
  38477. if m.done {
  38478. err = errors.New("querying old values post mutation is not allowed")
  38479. } else {
  38480. value, err = m.Client().WpChatroom.Get(ctx, id)
  38481. }
  38482. })
  38483. return value, err
  38484. }
  38485. m.id = &id
  38486. }
  38487. }
  38488. // withWpChatroom sets the old WpChatroom of the mutation.
  38489. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  38490. return func(m *WpChatroomMutation) {
  38491. m.oldValue = func(context.Context) (*WpChatroom, error) {
  38492. return node, nil
  38493. }
  38494. m.id = &node.ID
  38495. }
  38496. }
  38497. // Client returns a new `ent.Client` from the mutation. If the mutation was
  38498. // executed in a transaction (ent.Tx), a transactional client is returned.
  38499. func (m WpChatroomMutation) Client() *Client {
  38500. client := &Client{config: m.config}
  38501. client.init()
  38502. return client
  38503. }
  38504. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  38505. // it returns an error otherwise.
  38506. func (m WpChatroomMutation) Tx() (*Tx, error) {
  38507. if _, ok := m.driver.(*txDriver); !ok {
  38508. return nil, errors.New("ent: mutation is not running in a transaction")
  38509. }
  38510. tx := &Tx{config: m.config}
  38511. tx.init()
  38512. return tx, nil
  38513. }
  38514. // SetID sets the value of the id field. Note that this
  38515. // operation is only accepted on creation of WpChatroom entities.
  38516. func (m *WpChatroomMutation) SetID(id uint64) {
  38517. m.id = &id
  38518. }
  38519. // ID returns the ID value in the mutation. Note that the ID is only available
  38520. // if it was provided to the builder or after it was returned from the database.
  38521. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  38522. if m.id == nil {
  38523. return
  38524. }
  38525. return *m.id, true
  38526. }
  38527. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  38528. // That means, if the mutation is applied within a transaction with an isolation level such
  38529. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  38530. // or updated by the mutation.
  38531. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  38532. switch {
  38533. case m.op.Is(OpUpdateOne | OpDeleteOne):
  38534. id, exists := m.ID()
  38535. if exists {
  38536. return []uint64{id}, nil
  38537. }
  38538. fallthrough
  38539. case m.op.Is(OpUpdate | OpDelete):
  38540. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  38541. default:
  38542. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  38543. }
  38544. }
  38545. // SetCreatedAt sets the "created_at" field.
  38546. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  38547. m.created_at = &t
  38548. }
  38549. // CreatedAt returns the value of the "created_at" field in the mutation.
  38550. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  38551. v := m.created_at
  38552. if v == nil {
  38553. return
  38554. }
  38555. return *v, true
  38556. }
  38557. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  38558. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38559. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38560. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  38561. if !m.op.Is(OpUpdateOne) {
  38562. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  38563. }
  38564. if m.id == nil || m.oldValue == nil {
  38565. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  38566. }
  38567. oldValue, err := m.oldValue(ctx)
  38568. if err != nil {
  38569. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  38570. }
  38571. return oldValue.CreatedAt, nil
  38572. }
  38573. // ResetCreatedAt resets all changes to the "created_at" field.
  38574. func (m *WpChatroomMutation) ResetCreatedAt() {
  38575. m.created_at = nil
  38576. }
  38577. // SetUpdatedAt sets the "updated_at" field.
  38578. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  38579. m.updated_at = &t
  38580. }
  38581. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  38582. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  38583. v := m.updated_at
  38584. if v == nil {
  38585. return
  38586. }
  38587. return *v, true
  38588. }
  38589. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  38590. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38591. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38592. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  38593. if !m.op.Is(OpUpdateOne) {
  38594. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  38595. }
  38596. if m.id == nil || m.oldValue == nil {
  38597. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  38598. }
  38599. oldValue, err := m.oldValue(ctx)
  38600. if err != nil {
  38601. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  38602. }
  38603. return oldValue.UpdatedAt, nil
  38604. }
  38605. // ResetUpdatedAt resets all changes to the "updated_at" field.
  38606. func (m *WpChatroomMutation) ResetUpdatedAt() {
  38607. m.updated_at = nil
  38608. }
  38609. // SetStatus sets the "status" field.
  38610. func (m *WpChatroomMutation) SetStatus(u uint8) {
  38611. m.status = &u
  38612. m.addstatus = nil
  38613. }
  38614. // Status returns the value of the "status" field in the mutation.
  38615. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  38616. v := m.status
  38617. if v == nil {
  38618. return
  38619. }
  38620. return *v, true
  38621. }
  38622. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  38623. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38624. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38625. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  38626. if !m.op.Is(OpUpdateOne) {
  38627. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  38628. }
  38629. if m.id == nil || m.oldValue == nil {
  38630. return v, errors.New("OldStatus requires an ID field in the mutation")
  38631. }
  38632. oldValue, err := m.oldValue(ctx)
  38633. if err != nil {
  38634. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  38635. }
  38636. return oldValue.Status, nil
  38637. }
  38638. // AddStatus adds u to the "status" field.
  38639. func (m *WpChatroomMutation) AddStatus(u int8) {
  38640. if m.addstatus != nil {
  38641. *m.addstatus += u
  38642. } else {
  38643. m.addstatus = &u
  38644. }
  38645. }
  38646. // AddedStatus returns the value that was added to the "status" field in this mutation.
  38647. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  38648. v := m.addstatus
  38649. if v == nil {
  38650. return
  38651. }
  38652. return *v, true
  38653. }
  38654. // ClearStatus clears the value of the "status" field.
  38655. func (m *WpChatroomMutation) ClearStatus() {
  38656. m.status = nil
  38657. m.addstatus = nil
  38658. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  38659. }
  38660. // StatusCleared returns if the "status" field was cleared in this mutation.
  38661. func (m *WpChatroomMutation) StatusCleared() bool {
  38662. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  38663. return ok
  38664. }
  38665. // ResetStatus resets all changes to the "status" field.
  38666. func (m *WpChatroomMutation) ResetStatus() {
  38667. m.status = nil
  38668. m.addstatus = nil
  38669. delete(m.clearedFields, wpchatroom.FieldStatus)
  38670. }
  38671. // SetWxWxid sets the "wx_wxid" field.
  38672. func (m *WpChatroomMutation) SetWxWxid(s string) {
  38673. m.wx_wxid = &s
  38674. }
  38675. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  38676. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  38677. v := m.wx_wxid
  38678. if v == nil {
  38679. return
  38680. }
  38681. return *v, true
  38682. }
  38683. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  38684. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38685. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38686. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  38687. if !m.op.Is(OpUpdateOne) {
  38688. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  38689. }
  38690. if m.id == nil || m.oldValue == nil {
  38691. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  38692. }
  38693. oldValue, err := m.oldValue(ctx)
  38694. if err != nil {
  38695. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  38696. }
  38697. return oldValue.WxWxid, nil
  38698. }
  38699. // ResetWxWxid resets all changes to the "wx_wxid" field.
  38700. func (m *WpChatroomMutation) ResetWxWxid() {
  38701. m.wx_wxid = nil
  38702. }
  38703. // SetChatroomID sets the "chatroom_id" field.
  38704. func (m *WpChatroomMutation) SetChatroomID(s string) {
  38705. m.chatroom_id = &s
  38706. }
  38707. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  38708. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  38709. v := m.chatroom_id
  38710. if v == nil {
  38711. return
  38712. }
  38713. return *v, true
  38714. }
  38715. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  38716. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38717. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38718. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  38719. if !m.op.Is(OpUpdateOne) {
  38720. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  38721. }
  38722. if m.id == nil || m.oldValue == nil {
  38723. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  38724. }
  38725. oldValue, err := m.oldValue(ctx)
  38726. if err != nil {
  38727. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  38728. }
  38729. return oldValue.ChatroomID, nil
  38730. }
  38731. // ResetChatroomID resets all changes to the "chatroom_id" field.
  38732. func (m *WpChatroomMutation) ResetChatroomID() {
  38733. m.chatroom_id = nil
  38734. }
  38735. // SetNickname sets the "nickname" field.
  38736. func (m *WpChatroomMutation) SetNickname(s string) {
  38737. m.nickname = &s
  38738. }
  38739. // Nickname returns the value of the "nickname" field in the mutation.
  38740. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  38741. v := m.nickname
  38742. if v == nil {
  38743. return
  38744. }
  38745. return *v, true
  38746. }
  38747. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  38748. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38749. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38750. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  38751. if !m.op.Is(OpUpdateOne) {
  38752. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  38753. }
  38754. if m.id == nil || m.oldValue == nil {
  38755. return v, errors.New("OldNickname requires an ID field in the mutation")
  38756. }
  38757. oldValue, err := m.oldValue(ctx)
  38758. if err != nil {
  38759. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  38760. }
  38761. return oldValue.Nickname, nil
  38762. }
  38763. // ResetNickname resets all changes to the "nickname" field.
  38764. func (m *WpChatroomMutation) ResetNickname() {
  38765. m.nickname = nil
  38766. }
  38767. // SetOwner sets the "owner" field.
  38768. func (m *WpChatroomMutation) SetOwner(s string) {
  38769. m.owner = &s
  38770. }
  38771. // Owner returns the value of the "owner" field in the mutation.
  38772. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  38773. v := m.owner
  38774. if v == nil {
  38775. return
  38776. }
  38777. return *v, true
  38778. }
  38779. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  38780. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38781. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38782. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  38783. if !m.op.Is(OpUpdateOne) {
  38784. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  38785. }
  38786. if m.id == nil || m.oldValue == nil {
  38787. return v, errors.New("OldOwner requires an ID field in the mutation")
  38788. }
  38789. oldValue, err := m.oldValue(ctx)
  38790. if err != nil {
  38791. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  38792. }
  38793. return oldValue.Owner, nil
  38794. }
  38795. // ResetOwner resets all changes to the "owner" field.
  38796. func (m *WpChatroomMutation) ResetOwner() {
  38797. m.owner = nil
  38798. }
  38799. // SetAvatar sets the "avatar" field.
  38800. func (m *WpChatroomMutation) SetAvatar(s string) {
  38801. m.avatar = &s
  38802. }
  38803. // Avatar returns the value of the "avatar" field in the mutation.
  38804. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  38805. v := m.avatar
  38806. if v == nil {
  38807. return
  38808. }
  38809. return *v, true
  38810. }
  38811. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  38812. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38814. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  38815. if !m.op.Is(OpUpdateOne) {
  38816. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  38817. }
  38818. if m.id == nil || m.oldValue == nil {
  38819. return v, errors.New("OldAvatar requires an ID field in the mutation")
  38820. }
  38821. oldValue, err := m.oldValue(ctx)
  38822. if err != nil {
  38823. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  38824. }
  38825. return oldValue.Avatar, nil
  38826. }
  38827. // ResetAvatar resets all changes to the "avatar" field.
  38828. func (m *WpChatroomMutation) ResetAvatar() {
  38829. m.avatar = nil
  38830. }
  38831. // SetMemberList sets the "member_list" field.
  38832. func (m *WpChatroomMutation) SetMemberList(s []string) {
  38833. m.member_list = &s
  38834. m.appendmember_list = nil
  38835. }
  38836. // MemberList returns the value of the "member_list" field in the mutation.
  38837. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  38838. v := m.member_list
  38839. if v == nil {
  38840. return
  38841. }
  38842. return *v, true
  38843. }
  38844. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  38845. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38846. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38847. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  38848. if !m.op.Is(OpUpdateOne) {
  38849. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  38850. }
  38851. if m.id == nil || m.oldValue == nil {
  38852. return v, errors.New("OldMemberList requires an ID field in the mutation")
  38853. }
  38854. oldValue, err := m.oldValue(ctx)
  38855. if err != nil {
  38856. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  38857. }
  38858. return oldValue.MemberList, nil
  38859. }
  38860. // AppendMemberList adds s to the "member_list" field.
  38861. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  38862. m.appendmember_list = append(m.appendmember_list, s...)
  38863. }
  38864. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  38865. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  38866. if len(m.appendmember_list) == 0 {
  38867. return nil, false
  38868. }
  38869. return m.appendmember_list, true
  38870. }
  38871. // ResetMemberList resets all changes to the "member_list" field.
  38872. func (m *WpChatroomMutation) ResetMemberList() {
  38873. m.member_list = nil
  38874. m.appendmember_list = nil
  38875. }
  38876. // Where appends a list predicates to the WpChatroomMutation builder.
  38877. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  38878. m.predicates = append(m.predicates, ps...)
  38879. }
  38880. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  38881. // users can use type-assertion to append predicates that do not depend on any generated package.
  38882. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  38883. p := make([]predicate.WpChatroom, len(ps))
  38884. for i := range ps {
  38885. p[i] = ps[i]
  38886. }
  38887. m.Where(p...)
  38888. }
  38889. // Op returns the operation name.
  38890. func (m *WpChatroomMutation) Op() Op {
  38891. return m.op
  38892. }
  38893. // SetOp allows setting the mutation operation.
  38894. func (m *WpChatroomMutation) SetOp(op Op) {
  38895. m.op = op
  38896. }
  38897. // Type returns the node type of this mutation (WpChatroom).
  38898. func (m *WpChatroomMutation) Type() string {
  38899. return m.typ
  38900. }
  38901. // Fields returns all fields that were changed during this mutation. Note that in
  38902. // order to get all numeric fields that were incremented/decremented, call
  38903. // AddedFields().
  38904. func (m *WpChatroomMutation) Fields() []string {
  38905. fields := make([]string, 0, 9)
  38906. if m.created_at != nil {
  38907. fields = append(fields, wpchatroom.FieldCreatedAt)
  38908. }
  38909. if m.updated_at != nil {
  38910. fields = append(fields, wpchatroom.FieldUpdatedAt)
  38911. }
  38912. if m.status != nil {
  38913. fields = append(fields, wpchatroom.FieldStatus)
  38914. }
  38915. if m.wx_wxid != nil {
  38916. fields = append(fields, wpchatroom.FieldWxWxid)
  38917. }
  38918. if m.chatroom_id != nil {
  38919. fields = append(fields, wpchatroom.FieldChatroomID)
  38920. }
  38921. if m.nickname != nil {
  38922. fields = append(fields, wpchatroom.FieldNickname)
  38923. }
  38924. if m.owner != nil {
  38925. fields = append(fields, wpchatroom.FieldOwner)
  38926. }
  38927. if m.avatar != nil {
  38928. fields = append(fields, wpchatroom.FieldAvatar)
  38929. }
  38930. if m.member_list != nil {
  38931. fields = append(fields, wpchatroom.FieldMemberList)
  38932. }
  38933. return fields
  38934. }
  38935. // Field returns the value of a field with the given name. The second boolean
  38936. // return value indicates that this field was not set, or was not defined in the
  38937. // schema.
  38938. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  38939. switch name {
  38940. case wpchatroom.FieldCreatedAt:
  38941. return m.CreatedAt()
  38942. case wpchatroom.FieldUpdatedAt:
  38943. return m.UpdatedAt()
  38944. case wpchatroom.FieldStatus:
  38945. return m.Status()
  38946. case wpchatroom.FieldWxWxid:
  38947. return m.WxWxid()
  38948. case wpchatroom.FieldChatroomID:
  38949. return m.ChatroomID()
  38950. case wpchatroom.FieldNickname:
  38951. return m.Nickname()
  38952. case wpchatroom.FieldOwner:
  38953. return m.Owner()
  38954. case wpchatroom.FieldAvatar:
  38955. return m.Avatar()
  38956. case wpchatroom.FieldMemberList:
  38957. return m.MemberList()
  38958. }
  38959. return nil, false
  38960. }
  38961. // OldField returns the old value of the field from the database. An error is
  38962. // returned if the mutation operation is not UpdateOne, or the query to the
  38963. // database failed.
  38964. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  38965. switch name {
  38966. case wpchatroom.FieldCreatedAt:
  38967. return m.OldCreatedAt(ctx)
  38968. case wpchatroom.FieldUpdatedAt:
  38969. return m.OldUpdatedAt(ctx)
  38970. case wpchatroom.FieldStatus:
  38971. return m.OldStatus(ctx)
  38972. case wpchatroom.FieldWxWxid:
  38973. return m.OldWxWxid(ctx)
  38974. case wpchatroom.FieldChatroomID:
  38975. return m.OldChatroomID(ctx)
  38976. case wpchatroom.FieldNickname:
  38977. return m.OldNickname(ctx)
  38978. case wpchatroom.FieldOwner:
  38979. return m.OldOwner(ctx)
  38980. case wpchatroom.FieldAvatar:
  38981. return m.OldAvatar(ctx)
  38982. case wpchatroom.FieldMemberList:
  38983. return m.OldMemberList(ctx)
  38984. }
  38985. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  38986. }
  38987. // SetField sets the value of a field with the given name. It returns an error if
  38988. // the field is not defined in the schema, or if the type mismatched the field
  38989. // type.
  38990. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  38991. switch name {
  38992. case wpchatroom.FieldCreatedAt:
  38993. v, ok := value.(time.Time)
  38994. if !ok {
  38995. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38996. }
  38997. m.SetCreatedAt(v)
  38998. return nil
  38999. case wpchatroom.FieldUpdatedAt:
  39000. v, ok := value.(time.Time)
  39001. if !ok {
  39002. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39003. }
  39004. m.SetUpdatedAt(v)
  39005. return nil
  39006. case wpchatroom.FieldStatus:
  39007. v, ok := value.(uint8)
  39008. if !ok {
  39009. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39010. }
  39011. m.SetStatus(v)
  39012. return nil
  39013. case wpchatroom.FieldWxWxid:
  39014. v, ok := value.(string)
  39015. if !ok {
  39016. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39017. }
  39018. m.SetWxWxid(v)
  39019. return nil
  39020. case wpchatroom.FieldChatroomID:
  39021. v, ok := value.(string)
  39022. if !ok {
  39023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39024. }
  39025. m.SetChatroomID(v)
  39026. return nil
  39027. case wpchatroom.FieldNickname:
  39028. v, ok := value.(string)
  39029. if !ok {
  39030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39031. }
  39032. m.SetNickname(v)
  39033. return nil
  39034. case wpchatroom.FieldOwner:
  39035. v, ok := value.(string)
  39036. if !ok {
  39037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39038. }
  39039. m.SetOwner(v)
  39040. return nil
  39041. case wpchatroom.FieldAvatar:
  39042. v, ok := value.(string)
  39043. if !ok {
  39044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39045. }
  39046. m.SetAvatar(v)
  39047. return nil
  39048. case wpchatroom.FieldMemberList:
  39049. v, ok := value.([]string)
  39050. if !ok {
  39051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39052. }
  39053. m.SetMemberList(v)
  39054. return nil
  39055. }
  39056. return fmt.Errorf("unknown WpChatroom field %s", name)
  39057. }
  39058. // AddedFields returns all numeric fields that were incremented/decremented during
  39059. // this mutation.
  39060. func (m *WpChatroomMutation) AddedFields() []string {
  39061. var fields []string
  39062. if m.addstatus != nil {
  39063. fields = append(fields, wpchatroom.FieldStatus)
  39064. }
  39065. return fields
  39066. }
  39067. // AddedField returns the numeric value that was incremented/decremented on a field
  39068. // with the given name. The second boolean return value indicates that this field
  39069. // was not set, or was not defined in the schema.
  39070. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  39071. switch name {
  39072. case wpchatroom.FieldStatus:
  39073. return m.AddedStatus()
  39074. }
  39075. return nil, false
  39076. }
  39077. // AddField adds the value to the field with the given name. It returns an error if
  39078. // the field is not defined in the schema, or if the type mismatched the field
  39079. // type.
  39080. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  39081. switch name {
  39082. case wpchatroom.FieldStatus:
  39083. v, ok := value.(int8)
  39084. if !ok {
  39085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39086. }
  39087. m.AddStatus(v)
  39088. return nil
  39089. }
  39090. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  39091. }
  39092. // ClearedFields returns all nullable fields that were cleared during this
  39093. // mutation.
  39094. func (m *WpChatroomMutation) ClearedFields() []string {
  39095. var fields []string
  39096. if m.FieldCleared(wpchatroom.FieldStatus) {
  39097. fields = append(fields, wpchatroom.FieldStatus)
  39098. }
  39099. return fields
  39100. }
  39101. // FieldCleared returns a boolean indicating if a field with the given name was
  39102. // cleared in this mutation.
  39103. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  39104. _, ok := m.clearedFields[name]
  39105. return ok
  39106. }
  39107. // ClearField clears the value of the field with the given name. It returns an
  39108. // error if the field is not defined in the schema.
  39109. func (m *WpChatroomMutation) ClearField(name string) error {
  39110. switch name {
  39111. case wpchatroom.FieldStatus:
  39112. m.ClearStatus()
  39113. return nil
  39114. }
  39115. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  39116. }
  39117. // ResetField resets all changes in the mutation for the field with the given name.
  39118. // It returns an error if the field is not defined in the schema.
  39119. func (m *WpChatroomMutation) ResetField(name string) error {
  39120. switch name {
  39121. case wpchatroom.FieldCreatedAt:
  39122. m.ResetCreatedAt()
  39123. return nil
  39124. case wpchatroom.FieldUpdatedAt:
  39125. m.ResetUpdatedAt()
  39126. return nil
  39127. case wpchatroom.FieldStatus:
  39128. m.ResetStatus()
  39129. return nil
  39130. case wpchatroom.FieldWxWxid:
  39131. m.ResetWxWxid()
  39132. return nil
  39133. case wpchatroom.FieldChatroomID:
  39134. m.ResetChatroomID()
  39135. return nil
  39136. case wpchatroom.FieldNickname:
  39137. m.ResetNickname()
  39138. return nil
  39139. case wpchatroom.FieldOwner:
  39140. m.ResetOwner()
  39141. return nil
  39142. case wpchatroom.FieldAvatar:
  39143. m.ResetAvatar()
  39144. return nil
  39145. case wpchatroom.FieldMemberList:
  39146. m.ResetMemberList()
  39147. return nil
  39148. }
  39149. return fmt.Errorf("unknown WpChatroom field %s", name)
  39150. }
  39151. // AddedEdges returns all edge names that were set/added in this mutation.
  39152. func (m *WpChatroomMutation) AddedEdges() []string {
  39153. edges := make([]string, 0, 0)
  39154. return edges
  39155. }
  39156. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  39157. // name in this mutation.
  39158. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  39159. return nil
  39160. }
  39161. // RemovedEdges returns all edge names that were removed in this mutation.
  39162. func (m *WpChatroomMutation) RemovedEdges() []string {
  39163. edges := make([]string, 0, 0)
  39164. return edges
  39165. }
  39166. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39167. // the given name in this mutation.
  39168. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  39169. return nil
  39170. }
  39171. // ClearedEdges returns all edge names that were cleared in this mutation.
  39172. func (m *WpChatroomMutation) ClearedEdges() []string {
  39173. edges := make([]string, 0, 0)
  39174. return edges
  39175. }
  39176. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39177. // was cleared in this mutation.
  39178. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  39179. return false
  39180. }
  39181. // ClearEdge clears the value of the edge with the given name. It returns an error
  39182. // if that edge is not defined in the schema.
  39183. func (m *WpChatroomMutation) ClearEdge(name string) error {
  39184. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  39185. }
  39186. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39187. // It returns an error if the edge is not defined in the schema.
  39188. func (m *WpChatroomMutation) ResetEdge(name string) error {
  39189. return fmt.Errorf("unknown WpChatroom edge %s", name)
  39190. }
  39191. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  39192. type WpChatroomMemberMutation struct {
  39193. config
  39194. op Op
  39195. typ string
  39196. id *uint64
  39197. created_at *time.Time
  39198. updated_at *time.Time
  39199. status *uint8
  39200. addstatus *int8
  39201. wx_wxid *string
  39202. wxid *string
  39203. nickname *string
  39204. avatar *string
  39205. clearedFields map[string]struct{}
  39206. done bool
  39207. oldValue func(context.Context) (*WpChatroomMember, error)
  39208. predicates []predicate.WpChatroomMember
  39209. }
  39210. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  39211. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  39212. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  39213. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  39214. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  39215. m := &WpChatroomMemberMutation{
  39216. config: c,
  39217. op: op,
  39218. typ: TypeWpChatroomMember,
  39219. clearedFields: make(map[string]struct{}),
  39220. }
  39221. for _, opt := range opts {
  39222. opt(m)
  39223. }
  39224. return m
  39225. }
  39226. // withWpChatroomMemberID sets the ID field of the mutation.
  39227. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  39228. return func(m *WpChatroomMemberMutation) {
  39229. var (
  39230. err error
  39231. once sync.Once
  39232. value *WpChatroomMember
  39233. )
  39234. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  39235. once.Do(func() {
  39236. if m.done {
  39237. err = errors.New("querying old values post mutation is not allowed")
  39238. } else {
  39239. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  39240. }
  39241. })
  39242. return value, err
  39243. }
  39244. m.id = &id
  39245. }
  39246. }
  39247. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  39248. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  39249. return func(m *WpChatroomMemberMutation) {
  39250. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  39251. return node, nil
  39252. }
  39253. m.id = &node.ID
  39254. }
  39255. }
  39256. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39257. // executed in a transaction (ent.Tx), a transactional client is returned.
  39258. func (m WpChatroomMemberMutation) Client() *Client {
  39259. client := &Client{config: m.config}
  39260. client.init()
  39261. return client
  39262. }
  39263. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39264. // it returns an error otherwise.
  39265. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  39266. if _, ok := m.driver.(*txDriver); !ok {
  39267. return nil, errors.New("ent: mutation is not running in a transaction")
  39268. }
  39269. tx := &Tx{config: m.config}
  39270. tx.init()
  39271. return tx, nil
  39272. }
  39273. // SetID sets the value of the id field. Note that this
  39274. // operation is only accepted on creation of WpChatroomMember entities.
  39275. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  39276. m.id = &id
  39277. }
  39278. // ID returns the ID value in the mutation. Note that the ID is only available
  39279. // if it was provided to the builder or after it was returned from the database.
  39280. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  39281. if m.id == nil {
  39282. return
  39283. }
  39284. return *m.id, true
  39285. }
  39286. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39287. // That means, if the mutation is applied within a transaction with an isolation level such
  39288. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39289. // or updated by the mutation.
  39290. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  39291. switch {
  39292. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39293. id, exists := m.ID()
  39294. if exists {
  39295. return []uint64{id}, nil
  39296. }
  39297. fallthrough
  39298. case m.op.Is(OpUpdate | OpDelete):
  39299. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  39300. default:
  39301. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39302. }
  39303. }
  39304. // SetCreatedAt sets the "created_at" field.
  39305. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  39306. m.created_at = &t
  39307. }
  39308. // CreatedAt returns the value of the "created_at" field in the mutation.
  39309. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  39310. v := m.created_at
  39311. if v == nil {
  39312. return
  39313. }
  39314. return *v, true
  39315. }
  39316. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  39317. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39319. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39320. if !m.op.Is(OpUpdateOne) {
  39321. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39322. }
  39323. if m.id == nil || m.oldValue == nil {
  39324. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39325. }
  39326. oldValue, err := m.oldValue(ctx)
  39327. if err != nil {
  39328. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39329. }
  39330. return oldValue.CreatedAt, nil
  39331. }
  39332. // ResetCreatedAt resets all changes to the "created_at" field.
  39333. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  39334. m.created_at = nil
  39335. }
  39336. // SetUpdatedAt sets the "updated_at" field.
  39337. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  39338. m.updated_at = &t
  39339. }
  39340. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  39341. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  39342. v := m.updated_at
  39343. if v == nil {
  39344. return
  39345. }
  39346. return *v, true
  39347. }
  39348. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  39349. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39350. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39351. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  39352. if !m.op.Is(OpUpdateOne) {
  39353. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  39354. }
  39355. if m.id == nil || m.oldValue == nil {
  39356. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  39357. }
  39358. oldValue, err := m.oldValue(ctx)
  39359. if err != nil {
  39360. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  39361. }
  39362. return oldValue.UpdatedAt, nil
  39363. }
  39364. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39365. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  39366. m.updated_at = nil
  39367. }
  39368. // SetStatus sets the "status" field.
  39369. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  39370. m.status = &u
  39371. m.addstatus = nil
  39372. }
  39373. // Status returns the value of the "status" field in the mutation.
  39374. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  39375. v := m.status
  39376. if v == nil {
  39377. return
  39378. }
  39379. return *v, true
  39380. }
  39381. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  39382. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39383. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39384. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  39385. if !m.op.Is(OpUpdateOne) {
  39386. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  39387. }
  39388. if m.id == nil || m.oldValue == nil {
  39389. return v, errors.New("OldStatus requires an ID field in the mutation")
  39390. }
  39391. oldValue, err := m.oldValue(ctx)
  39392. if err != nil {
  39393. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  39394. }
  39395. return oldValue.Status, nil
  39396. }
  39397. // AddStatus adds u to the "status" field.
  39398. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  39399. if m.addstatus != nil {
  39400. *m.addstatus += u
  39401. } else {
  39402. m.addstatus = &u
  39403. }
  39404. }
  39405. // AddedStatus returns the value that was added to the "status" field in this mutation.
  39406. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  39407. v := m.addstatus
  39408. if v == nil {
  39409. return
  39410. }
  39411. return *v, true
  39412. }
  39413. // ClearStatus clears the value of the "status" field.
  39414. func (m *WpChatroomMemberMutation) ClearStatus() {
  39415. m.status = nil
  39416. m.addstatus = nil
  39417. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  39418. }
  39419. // StatusCleared returns if the "status" field was cleared in this mutation.
  39420. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  39421. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  39422. return ok
  39423. }
  39424. // ResetStatus resets all changes to the "status" field.
  39425. func (m *WpChatroomMemberMutation) ResetStatus() {
  39426. m.status = nil
  39427. m.addstatus = nil
  39428. delete(m.clearedFields, wpchatroommember.FieldStatus)
  39429. }
  39430. // SetWxWxid sets the "wx_wxid" field.
  39431. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  39432. m.wx_wxid = &s
  39433. }
  39434. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  39435. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  39436. v := m.wx_wxid
  39437. if v == nil {
  39438. return
  39439. }
  39440. return *v, true
  39441. }
  39442. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  39443. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39444. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39445. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  39446. if !m.op.Is(OpUpdateOne) {
  39447. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  39448. }
  39449. if m.id == nil || m.oldValue == nil {
  39450. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  39451. }
  39452. oldValue, err := m.oldValue(ctx)
  39453. if err != nil {
  39454. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  39455. }
  39456. return oldValue.WxWxid, nil
  39457. }
  39458. // ResetWxWxid resets all changes to the "wx_wxid" field.
  39459. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  39460. m.wx_wxid = nil
  39461. }
  39462. // SetWxid sets the "wxid" field.
  39463. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  39464. m.wxid = &s
  39465. }
  39466. // Wxid returns the value of the "wxid" field in the mutation.
  39467. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  39468. v := m.wxid
  39469. if v == nil {
  39470. return
  39471. }
  39472. return *v, true
  39473. }
  39474. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  39475. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39476. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39477. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  39478. if !m.op.Is(OpUpdateOne) {
  39479. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  39480. }
  39481. if m.id == nil || m.oldValue == nil {
  39482. return v, errors.New("OldWxid requires an ID field in the mutation")
  39483. }
  39484. oldValue, err := m.oldValue(ctx)
  39485. if err != nil {
  39486. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  39487. }
  39488. return oldValue.Wxid, nil
  39489. }
  39490. // ResetWxid resets all changes to the "wxid" field.
  39491. func (m *WpChatroomMemberMutation) ResetWxid() {
  39492. m.wxid = nil
  39493. }
  39494. // SetNickname sets the "nickname" field.
  39495. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  39496. m.nickname = &s
  39497. }
  39498. // Nickname returns the value of the "nickname" field in the mutation.
  39499. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  39500. v := m.nickname
  39501. if v == nil {
  39502. return
  39503. }
  39504. return *v, true
  39505. }
  39506. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  39507. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39508. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39509. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  39510. if !m.op.Is(OpUpdateOne) {
  39511. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  39512. }
  39513. if m.id == nil || m.oldValue == nil {
  39514. return v, errors.New("OldNickname requires an ID field in the mutation")
  39515. }
  39516. oldValue, err := m.oldValue(ctx)
  39517. if err != nil {
  39518. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  39519. }
  39520. return oldValue.Nickname, nil
  39521. }
  39522. // ResetNickname resets all changes to the "nickname" field.
  39523. func (m *WpChatroomMemberMutation) ResetNickname() {
  39524. m.nickname = nil
  39525. }
  39526. // SetAvatar sets the "avatar" field.
  39527. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  39528. m.avatar = &s
  39529. }
  39530. // Avatar returns the value of the "avatar" field in the mutation.
  39531. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  39532. v := m.avatar
  39533. if v == nil {
  39534. return
  39535. }
  39536. return *v, true
  39537. }
  39538. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  39539. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39540. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39541. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  39542. if !m.op.Is(OpUpdateOne) {
  39543. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  39544. }
  39545. if m.id == nil || m.oldValue == nil {
  39546. return v, errors.New("OldAvatar requires an ID field in the mutation")
  39547. }
  39548. oldValue, err := m.oldValue(ctx)
  39549. if err != nil {
  39550. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  39551. }
  39552. return oldValue.Avatar, nil
  39553. }
  39554. // ResetAvatar resets all changes to the "avatar" field.
  39555. func (m *WpChatroomMemberMutation) ResetAvatar() {
  39556. m.avatar = nil
  39557. }
  39558. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  39559. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  39560. m.predicates = append(m.predicates, ps...)
  39561. }
  39562. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  39563. // users can use type-assertion to append predicates that do not depend on any generated package.
  39564. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  39565. p := make([]predicate.WpChatroomMember, len(ps))
  39566. for i := range ps {
  39567. p[i] = ps[i]
  39568. }
  39569. m.Where(p...)
  39570. }
  39571. // Op returns the operation name.
  39572. func (m *WpChatroomMemberMutation) Op() Op {
  39573. return m.op
  39574. }
  39575. // SetOp allows setting the mutation operation.
  39576. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  39577. m.op = op
  39578. }
  39579. // Type returns the node type of this mutation (WpChatroomMember).
  39580. func (m *WpChatroomMemberMutation) Type() string {
  39581. return m.typ
  39582. }
  39583. // Fields returns all fields that were changed during this mutation. Note that in
  39584. // order to get all numeric fields that were incremented/decremented, call
  39585. // AddedFields().
  39586. func (m *WpChatroomMemberMutation) Fields() []string {
  39587. fields := make([]string, 0, 7)
  39588. if m.created_at != nil {
  39589. fields = append(fields, wpchatroommember.FieldCreatedAt)
  39590. }
  39591. if m.updated_at != nil {
  39592. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  39593. }
  39594. if m.status != nil {
  39595. fields = append(fields, wpchatroommember.FieldStatus)
  39596. }
  39597. if m.wx_wxid != nil {
  39598. fields = append(fields, wpchatroommember.FieldWxWxid)
  39599. }
  39600. if m.wxid != nil {
  39601. fields = append(fields, wpchatroommember.FieldWxid)
  39602. }
  39603. if m.nickname != nil {
  39604. fields = append(fields, wpchatroommember.FieldNickname)
  39605. }
  39606. if m.avatar != nil {
  39607. fields = append(fields, wpchatroommember.FieldAvatar)
  39608. }
  39609. return fields
  39610. }
  39611. // Field returns the value of a field with the given name. The second boolean
  39612. // return value indicates that this field was not set, or was not defined in the
  39613. // schema.
  39614. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  39615. switch name {
  39616. case wpchatroommember.FieldCreatedAt:
  39617. return m.CreatedAt()
  39618. case wpchatroommember.FieldUpdatedAt:
  39619. return m.UpdatedAt()
  39620. case wpchatroommember.FieldStatus:
  39621. return m.Status()
  39622. case wpchatroommember.FieldWxWxid:
  39623. return m.WxWxid()
  39624. case wpchatroommember.FieldWxid:
  39625. return m.Wxid()
  39626. case wpchatroommember.FieldNickname:
  39627. return m.Nickname()
  39628. case wpchatroommember.FieldAvatar:
  39629. return m.Avatar()
  39630. }
  39631. return nil, false
  39632. }
  39633. // OldField returns the old value of the field from the database. An error is
  39634. // returned if the mutation operation is not UpdateOne, or the query to the
  39635. // database failed.
  39636. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  39637. switch name {
  39638. case wpchatroommember.FieldCreatedAt:
  39639. return m.OldCreatedAt(ctx)
  39640. case wpchatroommember.FieldUpdatedAt:
  39641. return m.OldUpdatedAt(ctx)
  39642. case wpchatroommember.FieldStatus:
  39643. return m.OldStatus(ctx)
  39644. case wpchatroommember.FieldWxWxid:
  39645. return m.OldWxWxid(ctx)
  39646. case wpchatroommember.FieldWxid:
  39647. return m.OldWxid(ctx)
  39648. case wpchatroommember.FieldNickname:
  39649. return m.OldNickname(ctx)
  39650. case wpchatroommember.FieldAvatar:
  39651. return m.OldAvatar(ctx)
  39652. }
  39653. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  39654. }
  39655. // SetField sets the value of a field with the given name. It returns an error if
  39656. // the field is not defined in the schema, or if the type mismatched the field
  39657. // type.
  39658. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  39659. switch name {
  39660. case wpchatroommember.FieldCreatedAt:
  39661. v, ok := value.(time.Time)
  39662. if !ok {
  39663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39664. }
  39665. m.SetCreatedAt(v)
  39666. return nil
  39667. case wpchatroommember.FieldUpdatedAt:
  39668. v, ok := value.(time.Time)
  39669. if !ok {
  39670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39671. }
  39672. m.SetUpdatedAt(v)
  39673. return nil
  39674. case wpchatroommember.FieldStatus:
  39675. v, ok := value.(uint8)
  39676. if !ok {
  39677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39678. }
  39679. m.SetStatus(v)
  39680. return nil
  39681. case wpchatroommember.FieldWxWxid:
  39682. v, ok := value.(string)
  39683. if !ok {
  39684. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39685. }
  39686. m.SetWxWxid(v)
  39687. return nil
  39688. case wpchatroommember.FieldWxid:
  39689. v, ok := value.(string)
  39690. if !ok {
  39691. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39692. }
  39693. m.SetWxid(v)
  39694. return nil
  39695. case wpchatroommember.FieldNickname:
  39696. v, ok := value.(string)
  39697. if !ok {
  39698. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39699. }
  39700. m.SetNickname(v)
  39701. return nil
  39702. case wpchatroommember.FieldAvatar:
  39703. v, ok := value.(string)
  39704. if !ok {
  39705. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39706. }
  39707. m.SetAvatar(v)
  39708. return nil
  39709. }
  39710. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  39711. }
  39712. // AddedFields returns all numeric fields that were incremented/decremented during
  39713. // this mutation.
  39714. func (m *WpChatroomMemberMutation) AddedFields() []string {
  39715. var fields []string
  39716. if m.addstatus != nil {
  39717. fields = append(fields, wpchatroommember.FieldStatus)
  39718. }
  39719. return fields
  39720. }
  39721. // AddedField returns the numeric value that was incremented/decremented on a field
  39722. // with the given name. The second boolean return value indicates that this field
  39723. // was not set, or was not defined in the schema.
  39724. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  39725. switch name {
  39726. case wpchatroommember.FieldStatus:
  39727. return m.AddedStatus()
  39728. }
  39729. return nil, false
  39730. }
  39731. // AddField adds the value to the field with the given name. It returns an error if
  39732. // the field is not defined in the schema, or if the type mismatched the field
  39733. // type.
  39734. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  39735. switch name {
  39736. case wpchatroommember.FieldStatus:
  39737. v, ok := value.(int8)
  39738. if !ok {
  39739. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39740. }
  39741. m.AddStatus(v)
  39742. return nil
  39743. }
  39744. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  39745. }
  39746. // ClearedFields returns all nullable fields that were cleared during this
  39747. // mutation.
  39748. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  39749. var fields []string
  39750. if m.FieldCleared(wpchatroommember.FieldStatus) {
  39751. fields = append(fields, wpchatroommember.FieldStatus)
  39752. }
  39753. return fields
  39754. }
  39755. // FieldCleared returns a boolean indicating if a field with the given name was
  39756. // cleared in this mutation.
  39757. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  39758. _, ok := m.clearedFields[name]
  39759. return ok
  39760. }
  39761. // ClearField clears the value of the field with the given name. It returns an
  39762. // error if the field is not defined in the schema.
  39763. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  39764. switch name {
  39765. case wpchatroommember.FieldStatus:
  39766. m.ClearStatus()
  39767. return nil
  39768. }
  39769. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  39770. }
  39771. // ResetField resets all changes in the mutation for the field with the given name.
  39772. // It returns an error if the field is not defined in the schema.
  39773. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  39774. switch name {
  39775. case wpchatroommember.FieldCreatedAt:
  39776. m.ResetCreatedAt()
  39777. return nil
  39778. case wpchatroommember.FieldUpdatedAt:
  39779. m.ResetUpdatedAt()
  39780. return nil
  39781. case wpchatroommember.FieldStatus:
  39782. m.ResetStatus()
  39783. return nil
  39784. case wpchatroommember.FieldWxWxid:
  39785. m.ResetWxWxid()
  39786. return nil
  39787. case wpchatroommember.FieldWxid:
  39788. m.ResetWxid()
  39789. return nil
  39790. case wpchatroommember.FieldNickname:
  39791. m.ResetNickname()
  39792. return nil
  39793. case wpchatroommember.FieldAvatar:
  39794. m.ResetAvatar()
  39795. return nil
  39796. }
  39797. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  39798. }
  39799. // AddedEdges returns all edge names that were set/added in this mutation.
  39800. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  39801. edges := make([]string, 0, 0)
  39802. return edges
  39803. }
  39804. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  39805. // name in this mutation.
  39806. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  39807. return nil
  39808. }
  39809. // RemovedEdges returns all edge names that were removed in this mutation.
  39810. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  39811. edges := make([]string, 0, 0)
  39812. return edges
  39813. }
  39814. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39815. // the given name in this mutation.
  39816. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  39817. return nil
  39818. }
  39819. // ClearedEdges returns all edge names that were cleared in this mutation.
  39820. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  39821. edges := make([]string, 0, 0)
  39822. return edges
  39823. }
  39824. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39825. // was cleared in this mutation.
  39826. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  39827. return false
  39828. }
  39829. // ClearEdge clears the value of the edge with the given name. It returns an error
  39830. // if that edge is not defined in the schema.
  39831. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  39832. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  39833. }
  39834. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39835. // It returns an error if the edge is not defined in the schema.
  39836. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  39837. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  39838. }
  39839. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  39840. type WxMutation struct {
  39841. config
  39842. op Op
  39843. typ string
  39844. id *uint64
  39845. created_at *time.Time
  39846. updated_at *time.Time
  39847. status *uint8
  39848. addstatus *int8
  39849. deleted_at *time.Time
  39850. port *string
  39851. process_id *string
  39852. callback *string
  39853. wxid *string
  39854. account *string
  39855. nickname *string
  39856. tel *string
  39857. head_big *string
  39858. organization_id *uint64
  39859. addorganization_id *int64
  39860. api_base *string
  39861. api_key *string
  39862. allow_list *[]string
  39863. appendallow_list []string
  39864. group_allow_list *[]string
  39865. appendgroup_allow_list []string
  39866. block_list *[]string
  39867. appendblock_list []string
  39868. group_block_list *[]string
  39869. appendgroup_block_list []string
  39870. ctype *uint64
  39871. addctype *int64
  39872. clearedFields map[string]struct{}
  39873. server *uint64
  39874. clearedserver bool
  39875. agent *uint64
  39876. clearedagent bool
  39877. done bool
  39878. oldValue func(context.Context) (*Wx, error)
  39879. predicates []predicate.Wx
  39880. }
  39881. var _ ent.Mutation = (*WxMutation)(nil)
  39882. // wxOption allows management of the mutation configuration using functional options.
  39883. type wxOption func(*WxMutation)
  39884. // newWxMutation creates new mutation for the Wx entity.
  39885. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  39886. m := &WxMutation{
  39887. config: c,
  39888. op: op,
  39889. typ: TypeWx,
  39890. clearedFields: make(map[string]struct{}),
  39891. }
  39892. for _, opt := range opts {
  39893. opt(m)
  39894. }
  39895. return m
  39896. }
  39897. // withWxID sets the ID field of the mutation.
  39898. func withWxID(id uint64) wxOption {
  39899. return func(m *WxMutation) {
  39900. var (
  39901. err error
  39902. once sync.Once
  39903. value *Wx
  39904. )
  39905. m.oldValue = func(ctx context.Context) (*Wx, error) {
  39906. once.Do(func() {
  39907. if m.done {
  39908. err = errors.New("querying old values post mutation is not allowed")
  39909. } else {
  39910. value, err = m.Client().Wx.Get(ctx, id)
  39911. }
  39912. })
  39913. return value, err
  39914. }
  39915. m.id = &id
  39916. }
  39917. }
  39918. // withWx sets the old Wx of the mutation.
  39919. func withWx(node *Wx) wxOption {
  39920. return func(m *WxMutation) {
  39921. m.oldValue = func(context.Context) (*Wx, error) {
  39922. return node, nil
  39923. }
  39924. m.id = &node.ID
  39925. }
  39926. }
  39927. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39928. // executed in a transaction (ent.Tx), a transactional client is returned.
  39929. func (m WxMutation) Client() *Client {
  39930. client := &Client{config: m.config}
  39931. client.init()
  39932. return client
  39933. }
  39934. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39935. // it returns an error otherwise.
  39936. func (m WxMutation) Tx() (*Tx, error) {
  39937. if _, ok := m.driver.(*txDriver); !ok {
  39938. return nil, errors.New("ent: mutation is not running in a transaction")
  39939. }
  39940. tx := &Tx{config: m.config}
  39941. tx.init()
  39942. return tx, nil
  39943. }
  39944. // SetID sets the value of the id field. Note that this
  39945. // operation is only accepted on creation of Wx entities.
  39946. func (m *WxMutation) SetID(id uint64) {
  39947. m.id = &id
  39948. }
  39949. // ID returns the ID value in the mutation. Note that the ID is only available
  39950. // if it was provided to the builder or after it was returned from the database.
  39951. func (m *WxMutation) ID() (id uint64, exists bool) {
  39952. if m.id == nil {
  39953. return
  39954. }
  39955. return *m.id, true
  39956. }
  39957. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39958. // That means, if the mutation is applied within a transaction with an isolation level such
  39959. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39960. // or updated by the mutation.
  39961. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  39962. switch {
  39963. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39964. id, exists := m.ID()
  39965. if exists {
  39966. return []uint64{id}, nil
  39967. }
  39968. fallthrough
  39969. case m.op.Is(OpUpdate | OpDelete):
  39970. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  39971. default:
  39972. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39973. }
  39974. }
  39975. // SetCreatedAt sets the "created_at" field.
  39976. func (m *WxMutation) SetCreatedAt(t time.Time) {
  39977. m.created_at = &t
  39978. }
  39979. // CreatedAt returns the value of the "created_at" field in the mutation.
  39980. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  39981. v := m.created_at
  39982. if v == nil {
  39983. return
  39984. }
  39985. return *v, true
  39986. }
  39987. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  39988. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39989. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39990. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39991. if !m.op.Is(OpUpdateOne) {
  39992. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39993. }
  39994. if m.id == nil || m.oldValue == nil {
  39995. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39996. }
  39997. oldValue, err := m.oldValue(ctx)
  39998. if err != nil {
  39999. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  40000. }
  40001. return oldValue.CreatedAt, nil
  40002. }
  40003. // ResetCreatedAt resets all changes to the "created_at" field.
  40004. func (m *WxMutation) ResetCreatedAt() {
  40005. m.created_at = nil
  40006. }
  40007. // SetUpdatedAt sets the "updated_at" field.
  40008. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  40009. m.updated_at = &t
  40010. }
  40011. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  40012. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  40013. v := m.updated_at
  40014. if v == nil {
  40015. return
  40016. }
  40017. return *v, true
  40018. }
  40019. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  40020. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40021. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40022. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  40023. if !m.op.Is(OpUpdateOne) {
  40024. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  40025. }
  40026. if m.id == nil || m.oldValue == nil {
  40027. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  40028. }
  40029. oldValue, err := m.oldValue(ctx)
  40030. if err != nil {
  40031. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  40032. }
  40033. return oldValue.UpdatedAt, nil
  40034. }
  40035. // ResetUpdatedAt resets all changes to the "updated_at" field.
  40036. func (m *WxMutation) ResetUpdatedAt() {
  40037. m.updated_at = nil
  40038. }
  40039. // SetStatus sets the "status" field.
  40040. func (m *WxMutation) SetStatus(u uint8) {
  40041. m.status = &u
  40042. m.addstatus = nil
  40043. }
  40044. // Status returns the value of the "status" field in the mutation.
  40045. func (m *WxMutation) Status() (r uint8, exists bool) {
  40046. v := m.status
  40047. if v == nil {
  40048. return
  40049. }
  40050. return *v, true
  40051. }
  40052. // OldStatus returns the old "status" field's value of the Wx entity.
  40053. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40054. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40055. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  40056. if !m.op.Is(OpUpdateOne) {
  40057. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  40058. }
  40059. if m.id == nil || m.oldValue == nil {
  40060. return v, errors.New("OldStatus requires an ID field in the mutation")
  40061. }
  40062. oldValue, err := m.oldValue(ctx)
  40063. if err != nil {
  40064. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  40065. }
  40066. return oldValue.Status, nil
  40067. }
  40068. // AddStatus adds u to the "status" field.
  40069. func (m *WxMutation) AddStatus(u int8) {
  40070. if m.addstatus != nil {
  40071. *m.addstatus += u
  40072. } else {
  40073. m.addstatus = &u
  40074. }
  40075. }
  40076. // AddedStatus returns the value that was added to the "status" field in this mutation.
  40077. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  40078. v := m.addstatus
  40079. if v == nil {
  40080. return
  40081. }
  40082. return *v, true
  40083. }
  40084. // ClearStatus clears the value of the "status" field.
  40085. func (m *WxMutation) ClearStatus() {
  40086. m.status = nil
  40087. m.addstatus = nil
  40088. m.clearedFields[wx.FieldStatus] = struct{}{}
  40089. }
  40090. // StatusCleared returns if the "status" field was cleared in this mutation.
  40091. func (m *WxMutation) StatusCleared() bool {
  40092. _, ok := m.clearedFields[wx.FieldStatus]
  40093. return ok
  40094. }
  40095. // ResetStatus resets all changes to the "status" field.
  40096. func (m *WxMutation) ResetStatus() {
  40097. m.status = nil
  40098. m.addstatus = nil
  40099. delete(m.clearedFields, wx.FieldStatus)
  40100. }
  40101. // SetDeletedAt sets the "deleted_at" field.
  40102. func (m *WxMutation) SetDeletedAt(t time.Time) {
  40103. m.deleted_at = &t
  40104. }
  40105. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  40106. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  40107. v := m.deleted_at
  40108. if v == nil {
  40109. return
  40110. }
  40111. return *v, true
  40112. }
  40113. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  40114. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40115. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40116. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  40117. if !m.op.Is(OpUpdateOne) {
  40118. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  40119. }
  40120. if m.id == nil || m.oldValue == nil {
  40121. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  40122. }
  40123. oldValue, err := m.oldValue(ctx)
  40124. if err != nil {
  40125. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  40126. }
  40127. return oldValue.DeletedAt, nil
  40128. }
  40129. // ClearDeletedAt clears the value of the "deleted_at" field.
  40130. func (m *WxMutation) ClearDeletedAt() {
  40131. m.deleted_at = nil
  40132. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  40133. }
  40134. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  40135. func (m *WxMutation) DeletedAtCleared() bool {
  40136. _, ok := m.clearedFields[wx.FieldDeletedAt]
  40137. return ok
  40138. }
  40139. // ResetDeletedAt resets all changes to the "deleted_at" field.
  40140. func (m *WxMutation) ResetDeletedAt() {
  40141. m.deleted_at = nil
  40142. delete(m.clearedFields, wx.FieldDeletedAt)
  40143. }
  40144. // SetServerID sets the "server_id" field.
  40145. func (m *WxMutation) SetServerID(u uint64) {
  40146. m.server = &u
  40147. }
  40148. // ServerID returns the value of the "server_id" field in the mutation.
  40149. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  40150. v := m.server
  40151. if v == nil {
  40152. return
  40153. }
  40154. return *v, true
  40155. }
  40156. // OldServerID returns the old "server_id" field's value of the Wx entity.
  40157. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40158. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40159. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  40160. if !m.op.Is(OpUpdateOne) {
  40161. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  40162. }
  40163. if m.id == nil || m.oldValue == nil {
  40164. return v, errors.New("OldServerID requires an ID field in the mutation")
  40165. }
  40166. oldValue, err := m.oldValue(ctx)
  40167. if err != nil {
  40168. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  40169. }
  40170. return oldValue.ServerID, nil
  40171. }
  40172. // ClearServerID clears the value of the "server_id" field.
  40173. func (m *WxMutation) ClearServerID() {
  40174. m.server = nil
  40175. m.clearedFields[wx.FieldServerID] = struct{}{}
  40176. }
  40177. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  40178. func (m *WxMutation) ServerIDCleared() bool {
  40179. _, ok := m.clearedFields[wx.FieldServerID]
  40180. return ok
  40181. }
  40182. // ResetServerID resets all changes to the "server_id" field.
  40183. func (m *WxMutation) ResetServerID() {
  40184. m.server = nil
  40185. delete(m.clearedFields, wx.FieldServerID)
  40186. }
  40187. // SetPort sets the "port" field.
  40188. func (m *WxMutation) SetPort(s string) {
  40189. m.port = &s
  40190. }
  40191. // Port returns the value of the "port" field in the mutation.
  40192. func (m *WxMutation) Port() (r string, exists bool) {
  40193. v := m.port
  40194. if v == nil {
  40195. return
  40196. }
  40197. return *v, true
  40198. }
  40199. // OldPort returns the old "port" field's value of the Wx entity.
  40200. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40201. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40202. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  40203. if !m.op.Is(OpUpdateOne) {
  40204. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  40205. }
  40206. if m.id == nil || m.oldValue == nil {
  40207. return v, errors.New("OldPort requires an ID field in the mutation")
  40208. }
  40209. oldValue, err := m.oldValue(ctx)
  40210. if err != nil {
  40211. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  40212. }
  40213. return oldValue.Port, nil
  40214. }
  40215. // ResetPort resets all changes to the "port" field.
  40216. func (m *WxMutation) ResetPort() {
  40217. m.port = nil
  40218. }
  40219. // SetProcessID sets the "process_id" field.
  40220. func (m *WxMutation) SetProcessID(s string) {
  40221. m.process_id = &s
  40222. }
  40223. // ProcessID returns the value of the "process_id" field in the mutation.
  40224. func (m *WxMutation) ProcessID() (r string, exists bool) {
  40225. v := m.process_id
  40226. if v == nil {
  40227. return
  40228. }
  40229. return *v, true
  40230. }
  40231. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  40232. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40233. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40234. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  40235. if !m.op.Is(OpUpdateOne) {
  40236. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  40237. }
  40238. if m.id == nil || m.oldValue == nil {
  40239. return v, errors.New("OldProcessID requires an ID field in the mutation")
  40240. }
  40241. oldValue, err := m.oldValue(ctx)
  40242. if err != nil {
  40243. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  40244. }
  40245. return oldValue.ProcessID, nil
  40246. }
  40247. // ResetProcessID resets all changes to the "process_id" field.
  40248. func (m *WxMutation) ResetProcessID() {
  40249. m.process_id = nil
  40250. }
  40251. // SetCallback sets the "callback" field.
  40252. func (m *WxMutation) SetCallback(s string) {
  40253. m.callback = &s
  40254. }
  40255. // Callback returns the value of the "callback" field in the mutation.
  40256. func (m *WxMutation) Callback() (r string, exists bool) {
  40257. v := m.callback
  40258. if v == nil {
  40259. return
  40260. }
  40261. return *v, true
  40262. }
  40263. // OldCallback returns the old "callback" field's value of the Wx entity.
  40264. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40266. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  40267. if !m.op.Is(OpUpdateOne) {
  40268. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  40269. }
  40270. if m.id == nil || m.oldValue == nil {
  40271. return v, errors.New("OldCallback requires an ID field in the mutation")
  40272. }
  40273. oldValue, err := m.oldValue(ctx)
  40274. if err != nil {
  40275. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  40276. }
  40277. return oldValue.Callback, nil
  40278. }
  40279. // ResetCallback resets all changes to the "callback" field.
  40280. func (m *WxMutation) ResetCallback() {
  40281. m.callback = nil
  40282. }
  40283. // SetWxid sets the "wxid" field.
  40284. func (m *WxMutation) SetWxid(s string) {
  40285. m.wxid = &s
  40286. }
  40287. // Wxid returns the value of the "wxid" field in the mutation.
  40288. func (m *WxMutation) Wxid() (r string, exists bool) {
  40289. v := m.wxid
  40290. if v == nil {
  40291. return
  40292. }
  40293. return *v, true
  40294. }
  40295. // OldWxid returns the old "wxid" field's value of the Wx entity.
  40296. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40298. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  40299. if !m.op.Is(OpUpdateOne) {
  40300. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  40301. }
  40302. if m.id == nil || m.oldValue == nil {
  40303. return v, errors.New("OldWxid requires an ID field in the mutation")
  40304. }
  40305. oldValue, err := m.oldValue(ctx)
  40306. if err != nil {
  40307. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  40308. }
  40309. return oldValue.Wxid, nil
  40310. }
  40311. // ResetWxid resets all changes to the "wxid" field.
  40312. func (m *WxMutation) ResetWxid() {
  40313. m.wxid = nil
  40314. }
  40315. // SetAccount sets the "account" field.
  40316. func (m *WxMutation) SetAccount(s string) {
  40317. m.account = &s
  40318. }
  40319. // Account returns the value of the "account" field in the mutation.
  40320. func (m *WxMutation) Account() (r string, exists bool) {
  40321. v := m.account
  40322. if v == nil {
  40323. return
  40324. }
  40325. return *v, true
  40326. }
  40327. // OldAccount returns the old "account" field's value of the Wx entity.
  40328. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40329. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40330. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  40331. if !m.op.Is(OpUpdateOne) {
  40332. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  40333. }
  40334. if m.id == nil || m.oldValue == nil {
  40335. return v, errors.New("OldAccount requires an ID field in the mutation")
  40336. }
  40337. oldValue, err := m.oldValue(ctx)
  40338. if err != nil {
  40339. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  40340. }
  40341. return oldValue.Account, nil
  40342. }
  40343. // ResetAccount resets all changes to the "account" field.
  40344. func (m *WxMutation) ResetAccount() {
  40345. m.account = nil
  40346. }
  40347. // SetNickname sets the "nickname" field.
  40348. func (m *WxMutation) SetNickname(s string) {
  40349. m.nickname = &s
  40350. }
  40351. // Nickname returns the value of the "nickname" field in the mutation.
  40352. func (m *WxMutation) Nickname() (r string, exists bool) {
  40353. v := m.nickname
  40354. if v == nil {
  40355. return
  40356. }
  40357. return *v, true
  40358. }
  40359. // OldNickname returns the old "nickname" field's value of the Wx entity.
  40360. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40362. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  40363. if !m.op.Is(OpUpdateOne) {
  40364. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  40365. }
  40366. if m.id == nil || m.oldValue == nil {
  40367. return v, errors.New("OldNickname requires an ID field in the mutation")
  40368. }
  40369. oldValue, err := m.oldValue(ctx)
  40370. if err != nil {
  40371. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  40372. }
  40373. return oldValue.Nickname, nil
  40374. }
  40375. // ResetNickname resets all changes to the "nickname" field.
  40376. func (m *WxMutation) ResetNickname() {
  40377. m.nickname = nil
  40378. }
  40379. // SetTel sets the "tel" field.
  40380. func (m *WxMutation) SetTel(s string) {
  40381. m.tel = &s
  40382. }
  40383. // Tel returns the value of the "tel" field in the mutation.
  40384. func (m *WxMutation) Tel() (r string, exists bool) {
  40385. v := m.tel
  40386. if v == nil {
  40387. return
  40388. }
  40389. return *v, true
  40390. }
  40391. // OldTel returns the old "tel" field's value of the Wx entity.
  40392. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40393. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40394. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  40395. if !m.op.Is(OpUpdateOne) {
  40396. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  40397. }
  40398. if m.id == nil || m.oldValue == nil {
  40399. return v, errors.New("OldTel requires an ID field in the mutation")
  40400. }
  40401. oldValue, err := m.oldValue(ctx)
  40402. if err != nil {
  40403. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  40404. }
  40405. return oldValue.Tel, nil
  40406. }
  40407. // ResetTel resets all changes to the "tel" field.
  40408. func (m *WxMutation) ResetTel() {
  40409. m.tel = nil
  40410. }
  40411. // SetHeadBig sets the "head_big" field.
  40412. func (m *WxMutation) SetHeadBig(s string) {
  40413. m.head_big = &s
  40414. }
  40415. // HeadBig returns the value of the "head_big" field in the mutation.
  40416. func (m *WxMutation) HeadBig() (r string, exists bool) {
  40417. v := m.head_big
  40418. if v == nil {
  40419. return
  40420. }
  40421. return *v, true
  40422. }
  40423. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  40424. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40425. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40426. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  40427. if !m.op.Is(OpUpdateOne) {
  40428. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  40429. }
  40430. if m.id == nil || m.oldValue == nil {
  40431. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  40432. }
  40433. oldValue, err := m.oldValue(ctx)
  40434. if err != nil {
  40435. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  40436. }
  40437. return oldValue.HeadBig, nil
  40438. }
  40439. // ResetHeadBig resets all changes to the "head_big" field.
  40440. func (m *WxMutation) ResetHeadBig() {
  40441. m.head_big = nil
  40442. }
  40443. // SetOrganizationID sets the "organization_id" field.
  40444. func (m *WxMutation) SetOrganizationID(u uint64) {
  40445. m.organization_id = &u
  40446. m.addorganization_id = nil
  40447. }
  40448. // OrganizationID returns the value of the "organization_id" field in the mutation.
  40449. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  40450. v := m.organization_id
  40451. if v == nil {
  40452. return
  40453. }
  40454. return *v, true
  40455. }
  40456. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  40457. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40458. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40459. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  40460. if !m.op.Is(OpUpdateOne) {
  40461. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  40462. }
  40463. if m.id == nil || m.oldValue == nil {
  40464. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  40465. }
  40466. oldValue, err := m.oldValue(ctx)
  40467. if err != nil {
  40468. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  40469. }
  40470. return oldValue.OrganizationID, nil
  40471. }
  40472. // AddOrganizationID adds u to the "organization_id" field.
  40473. func (m *WxMutation) AddOrganizationID(u int64) {
  40474. if m.addorganization_id != nil {
  40475. *m.addorganization_id += u
  40476. } else {
  40477. m.addorganization_id = &u
  40478. }
  40479. }
  40480. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  40481. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  40482. v := m.addorganization_id
  40483. if v == nil {
  40484. return
  40485. }
  40486. return *v, true
  40487. }
  40488. // ClearOrganizationID clears the value of the "organization_id" field.
  40489. func (m *WxMutation) ClearOrganizationID() {
  40490. m.organization_id = nil
  40491. m.addorganization_id = nil
  40492. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  40493. }
  40494. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  40495. func (m *WxMutation) OrganizationIDCleared() bool {
  40496. _, ok := m.clearedFields[wx.FieldOrganizationID]
  40497. return ok
  40498. }
  40499. // ResetOrganizationID resets all changes to the "organization_id" field.
  40500. func (m *WxMutation) ResetOrganizationID() {
  40501. m.organization_id = nil
  40502. m.addorganization_id = nil
  40503. delete(m.clearedFields, wx.FieldOrganizationID)
  40504. }
  40505. // SetAgentID sets the "agent_id" field.
  40506. func (m *WxMutation) SetAgentID(u uint64) {
  40507. m.agent = &u
  40508. }
  40509. // AgentID returns the value of the "agent_id" field in the mutation.
  40510. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  40511. v := m.agent
  40512. if v == nil {
  40513. return
  40514. }
  40515. return *v, true
  40516. }
  40517. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  40518. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40519. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40520. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  40521. if !m.op.Is(OpUpdateOne) {
  40522. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  40523. }
  40524. if m.id == nil || m.oldValue == nil {
  40525. return v, errors.New("OldAgentID requires an ID field in the mutation")
  40526. }
  40527. oldValue, err := m.oldValue(ctx)
  40528. if err != nil {
  40529. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  40530. }
  40531. return oldValue.AgentID, nil
  40532. }
  40533. // ResetAgentID resets all changes to the "agent_id" field.
  40534. func (m *WxMutation) ResetAgentID() {
  40535. m.agent = nil
  40536. }
  40537. // SetAPIBase sets the "api_base" field.
  40538. func (m *WxMutation) SetAPIBase(s string) {
  40539. m.api_base = &s
  40540. }
  40541. // APIBase returns the value of the "api_base" field in the mutation.
  40542. func (m *WxMutation) APIBase() (r string, exists bool) {
  40543. v := m.api_base
  40544. if v == nil {
  40545. return
  40546. }
  40547. return *v, true
  40548. }
  40549. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  40550. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40551. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40552. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  40553. if !m.op.Is(OpUpdateOne) {
  40554. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  40555. }
  40556. if m.id == nil || m.oldValue == nil {
  40557. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  40558. }
  40559. oldValue, err := m.oldValue(ctx)
  40560. if err != nil {
  40561. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  40562. }
  40563. return oldValue.APIBase, nil
  40564. }
  40565. // ClearAPIBase clears the value of the "api_base" field.
  40566. func (m *WxMutation) ClearAPIBase() {
  40567. m.api_base = nil
  40568. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  40569. }
  40570. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  40571. func (m *WxMutation) APIBaseCleared() bool {
  40572. _, ok := m.clearedFields[wx.FieldAPIBase]
  40573. return ok
  40574. }
  40575. // ResetAPIBase resets all changes to the "api_base" field.
  40576. func (m *WxMutation) ResetAPIBase() {
  40577. m.api_base = nil
  40578. delete(m.clearedFields, wx.FieldAPIBase)
  40579. }
  40580. // SetAPIKey sets the "api_key" field.
  40581. func (m *WxMutation) SetAPIKey(s string) {
  40582. m.api_key = &s
  40583. }
  40584. // APIKey returns the value of the "api_key" field in the mutation.
  40585. func (m *WxMutation) APIKey() (r string, exists bool) {
  40586. v := m.api_key
  40587. if v == nil {
  40588. return
  40589. }
  40590. return *v, true
  40591. }
  40592. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  40593. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40594. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40595. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  40596. if !m.op.Is(OpUpdateOne) {
  40597. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  40598. }
  40599. if m.id == nil || m.oldValue == nil {
  40600. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  40601. }
  40602. oldValue, err := m.oldValue(ctx)
  40603. if err != nil {
  40604. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  40605. }
  40606. return oldValue.APIKey, nil
  40607. }
  40608. // ClearAPIKey clears the value of the "api_key" field.
  40609. func (m *WxMutation) ClearAPIKey() {
  40610. m.api_key = nil
  40611. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  40612. }
  40613. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  40614. func (m *WxMutation) APIKeyCleared() bool {
  40615. _, ok := m.clearedFields[wx.FieldAPIKey]
  40616. return ok
  40617. }
  40618. // ResetAPIKey resets all changes to the "api_key" field.
  40619. func (m *WxMutation) ResetAPIKey() {
  40620. m.api_key = nil
  40621. delete(m.clearedFields, wx.FieldAPIKey)
  40622. }
  40623. // SetAllowList sets the "allow_list" field.
  40624. func (m *WxMutation) SetAllowList(s []string) {
  40625. m.allow_list = &s
  40626. m.appendallow_list = nil
  40627. }
  40628. // AllowList returns the value of the "allow_list" field in the mutation.
  40629. func (m *WxMutation) AllowList() (r []string, exists bool) {
  40630. v := m.allow_list
  40631. if v == nil {
  40632. return
  40633. }
  40634. return *v, true
  40635. }
  40636. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  40637. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40638. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40639. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  40640. if !m.op.Is(OpUpdateOne) {
  40641. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  40642. }
  40643. if m.id == nil || m.oldValue == nil {
  40644. return v, errors.New("OldAllowList requires an ID field in the mutation")
  40645. }
  40646. oldValue, err := m.oldValue(ctx)
  40647. if err != nil {
  40648. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  40649. }
  40650. return oldValue.AllowList, nil
  40651. }
  40652. // AppendAllowList adds s to the "allow_list" field.
  40653. func (m *WxMutation) AppendAllowList(s []string) {
  40654. m.appendallow_list = append(m.appendallow_list, s...)
  40655. }
  40656. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  40657. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  40658. if len(m.appendallow_list) == 0 {
  40659. return nil, false
  40660. }
  40661. return m.appendallow_list, true
  40662. }
  40663. // ResetAllowList resets all changes to the "allow_list" field.
  40664. func (m *WxMutation) ResetAllowList() {
  40665. m.allow_list = nil
  40666. m.appendallow_list = nil
  40667. }
  40668. // SetGroupAllowList sets the "group_allow_list" field.
  40669. func (m *WxMutation) SetGroupAllowList(s []string) {
  40670. m.group_allow_list = &s
  40671. m.appendgroup_allow_list = nil
  40672. }
  40673. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  40674. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  40675. v := m.group_allow_list
  40676. if v == nil {
  40677. return
  40678. }
  40679. return *v, true
  40680. }
  40681. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  40682. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40683. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40684. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  40685. if !m.op.Is(OpUpdateOne) {
  40686. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  40687. }
  40688. if m.id == nil || m.oldValue == nil {
  40689. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  40690. }
  40691. oldValue, err := m.oldValue(ctx)
  40692. if err != nil {
  40693. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  40694. }
  40695. return oldValue.GroupAllowList, nil
  40696. }
  40697. // AppendGroupAllowList adds s to the "group_allow_list" field.
  40698. func (m *WxMutation) AppendGroupAllowList(s []string) {
  40699. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  40700. }
  40701. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  40702. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  40703. if len(m.appendgroup_allow_list) == 0 {
  40704. return nil, false
  40705. }
  40706. return m.appendgroup_allow_list, true
  40707. }
  40708. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  40709. func (m *WxMutation) ResetGroupAllowList() {
  40710. m.group_allow_list = nil
  40711. m.appendgroup_allow_list = nil
  40712. }
  40713. // SetBlockList sets the "block_list" field.
  40714. func (m *WxMutation) SetBlockList(s []string) {
  40715. m.block_list = &s
  40716. m.appendblock_list = nil
  40717. }
  40718. // BlockList returns the value of the "block_list" field in the mutation.
  40719. func (m *WxMutation) BlockList() (r []string, exists bool) {
  40720. v := m.block_list
  40721. if v == nil {
  40722. return
  40723. }
  40724. return *v, true
  40725. }
  40726. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  40727. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40728. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40729. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  40730. if !m.op.Is(OpUpdateOne) {
  40731. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  40732. }
  40733. if m.id == nil || m.oldValue == nil {
  40734. return v, errors.New("OldBlockList requires an ID field in the mutation")
  40735. }
  40736. oldValue, err := m.oldValue(ctx)
  40737. if err != nil {
  40738. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  40739. }
  40740. return oldValue.BlockList, nil
  40741. }
  40742. // AppendBlockList adds s to the "block_list" field.
  40743. func (m *WxMutation) AppendBlockList(s []string) {
  40744. m.appendblock_list = append(m.appendblock_list, s...)
  40745. }
  40746. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  40747. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  40748. if len(m.appendblock_list) == 0 {
  40749. return nil, false
  40750. }
  40751. return m.appendblock_list, true
  40752. }
  40753. // ResetBlockList resets all changes to the "block_list" field.
  40754. func (m *WxMutation) ResetBlockList() {
  40755. m.block_list = nil
  40756. m.appendblock_list = nil
  40757. }
  40758. // SetGroupBlockList sets the "group_block_list" field.
  40759. func (m *WxMutation) SetGroupBlockList(s []string) {
  40760. m.group_block_list = &s
  40761. m.appendgroup_block_list = nil
  40762. }
  40763. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  40764. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  40765. v := m.group_block_list
  40766. if v == nil {
  40767. return
  40768. }
  40769. return *v, true
  40770. }
  40771. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  40772. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40773. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40774. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  40775. if !m.op.Is(OpUpdateOne) {
  40776. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  40777. }
  40778. if m.id == nil || m.oldValue == nil {
  40779. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  40780. }
  40781. oldValue, err := m.oldValue(ctx)
  40782. if err != nil {
  40783. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  40784. }
  40785. return oldValue.GroupBlockList, nil
  40786. }
  40787. // AppendGroupBlockList adds s to the "group_block_list" field.
  40788. func (m *WxMutation) AppendGroupBlockList(s []string) {
  40789. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  40790. }
  40791. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  40792. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  40793. if len(m.appendgroup_block_list) == 0 {
  40794. return nil, false
  40795. }
  40796. return m.appendgroup_block_list, true
  40797. }
  40798. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  40799. func (m *WxMutation) ResetGroupBlockList() {
  40800. m.group_block_list = nil
  40801. m.appendgroup_block_list = nil
  40802. }
  40803. // SetCtype sets the "ctype" field.
  40804. func (m *WxMutation) SetCtype(u uint64) {
  40805. m.ctype = &u
  40806. m.addctype = nil
  40807. }
  40808. // Ctype returns the value of the "ctype" field in the mutation.
  40809. func (m *WxMutation) Ctype() (r uint64, exists bool) {
  40810. v := m.ctype
  40811. if v == nil {
  40812. return
  40813. }
  40814. return *v, true
  40815. }
  40816. // OldCtype returns the old "ctype" field's value of the Wx entity.
  40817. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40818. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40819. func (m *WxMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  40820. if !m.op.Is(OpUpdateOne) {
  40821. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  40822. }
  40823. if m.id == nil || m.oldValue == nil {
  40824. return v, errors.New("OldCtype requires an ID field in the mutation")
  40825. }
  40826. oldValue, err := m.oldValue(ctx)
  40827. if err != nil {
  40828. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  40829. }
  40830. return oldValue.Ctype, nil
  40831. }
  40832. // AddCtype adds u to the "ctype" field.
  40833. func (m *WxMutation) AddCtype(u int64) {
  40834. if m.addctype != nil {
  40835. *m.addctype += u
  40836. } else {
  40837. m.addctype = &u
  40838. }
  40839. }
  40840. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  40841. func (m *WxMutation) AddedCtype() (r int64, exists bool) {
  40842. v := m.addctype
  40843. if v == nil {
  40844. return
  40845. }
  40846. return *v, true
  40847. }
  40848. // ClearCtype clears the value of the "ctype" field.
  40849. func (m *WxMutation) ClearCtype() {
  40850. m.ctype = nil
  40851. m.addctype = nil
  40852. m.clearedFields[wx.FieldCtype] = struct{}{}
  40853. }
  40854. // CtypeCleared returns if the "ctype" field was cleared in this mutation.
  40855. func (m *WxMutation) CtypeCleared() bool {
  40856. _, ok := m.clearedFields[wx.FieldCtype]
  40857. return ok
  40858. }
  40859. // ResetCtype resets all changes to the "ctype" field.
  40860. func (m *WxMutation) ResetCtype() {
  40861. m.ctype = nil
  40862. m.addctype = nil
  40863. delete(m.clearedFields, wx.FieldCtype)
  40864. }
  40865. // ClearServer clears the "server" edge to the Server entity.
  40866. func (m *WxMutation) ClearServer() {
  40867. m.clearedserver = true
  40868. m.clearedFields[wx.FieldServerID] = struct{}{}
  40869. }
  40870. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  40871. func (m *WxMutation) ServerCleared() bool {
  40872. return m.ServerIDCleared() || m.clearedserver
  40873. }
  40874. // ServerIDs returns the "server" edge IDs in the mutation.
  40875. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  40876. // ServerID instead. It exists only for internal usage by the builders.
  40877. func (m *WxMutation) ServerIDs() (ids []uint64) {
  40878. if id := m.server; id != nil {
  40879. ids = append(ids, *id)
  40880. }
  40881. return
  40882. }
  40883. // ResetServer resets all changes to the "server" edge.
  40884. func (m *WxMutation) ResetServer() {
  40885. m.server = nil
  40886. m.clearedserver = false
  40887. }
  40888. // ClearAgent clears the "agent" edge to the Agent entity.
  40889. func (m *WxMutation) ClearAgent() {
  40890. m.clearedagent = true
  40891. m.clearedFields[wx.FieldAgentID] = struct{}{}
  40892. }
  40893. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  40894. func (m *WxMutation) AgentCleared() bool {
  40895. return m.clearedagent
  40896. }
  40897. // AgentIDs returns the "agent" edge IDs in the mutation.
  40898. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  40899. // AgentID instead. It exists only for internal usage by the builders.
  40900. func (m *WxMutation) AgentIDs() (ids []uint64) {
  40901. if id := m.agent; id != nil {
  40902. ids = append(ids, *id)
  40903. }
  40904. return
  40905. }
  40906. // ResetAgent resets all changes to the "agent" edge.
  40907. func (m *WxMutation) ResetAgent() {
  40908. m.agent = nil
  40909. m.clearedagent = false
  40910. }
  40911. // Where appends a list predicates to the WxMutation builder.
  40912. func (m *WxMutation) Where(ps ...predicate.Wx) {
  40913. m.predicates = append(m.predicates, ps...)
  40914. }
  40915. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  40916. // users can use type-assertion to append predicates that do not depend on any generated package.
  40917. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  40918. p := make([]predicate.Wx, len(ps))
  40919. for i := range ps {
  40920. p[i] = ps[i]
  40921. }
  40922. m.Where(p...)
  40923. }
  40924. // Op returns the operation name.
  40925. func (m *WxMutation) Op() Op {
  40926. return m.op
  40927. }
  40928. // SetOp allows setting the mutation operation.
  40929. func (m *WxMutation) SetOp(op Op) {
  40930. m.op = op
  40931. }
  40932. // Type returns the node type of this mutation (Wx).
  40933. func (m *WxMutation) Type() string {
  40934. return m.typ
  40935. }
  40936. // Fields returns all fields that were changed during this mutation. Note that in
  40937. // order to get all numeric fields that were incremented/decremented, call
  40938. // AddedFields().
  40939. func (m *WxMutation) Fields() []string {
  40940. fields := make([]string, 0, 22)
  40941. if m.created_at != nil {
  40942. fields = append(fields, wx.FieldCreatedAt)
  40943. }
  40944. if m.updated_at != nil {
  40945. fields = append(fields, wx.FieldUpdatedAt)
  40946. }
  40947. if m.status != nil {
  40948. fields = append(fields, wx.FieldStatus)
  40949. }
  40950. if m.deleted_at != nil {
  40951. fields = append(fields, wx.FieldDeletedAt)
  40952. }
  40953. if m.server != nil {
  40954. fields = append(fields, wx.FieldServerID)
  40955. }
  40956. if m.port != nil {
  40957. fields = append(fields, wx.FieldPort)
  40958. }
  40959. if m.process_id != nil {
  40960. fields = append(fields, wx.FieldProcessID)
  40961. }
  40962. if m.callback != nil {
  40963. fields = append(fields, wx.FieldCallback)
  40964. }
  40965. if m.wxid != nil {
  40966. fields = append(fields, wx.FieldWxid)
  40967. }
  40968. if m.account != nil {
  40969. fields = append(fields, wx.FieldAccount)
  40970. }
  40971. if m.nickname != nil {
  40972. fields = append(fields, wx.FieldNickname)
  40973. }
  40974. if m.tel != nil {
  40975. fields = append(fields, wx.FieldTel)
  40976. }
  40977. if m.head_big != nil {
  40978. fields = append(fields, wx.FieldHeadBig)
  40979. }
  40980. if m.organization_id != nil {
  40981. fields = append(fields, wx.FieldOrganizationID)
  40982. }
  40983. if m.agent != nil {
  40984. fields = append(fields, wx.FieldAgentID)
  40985. }
  40986. if m.api_base != nil {
  40987. fields = append(fields, wx.FieldAPIBase)
  40988. }
  40989. if m.api_key != nil {
  40990. fields = append(fields, wx.FieldAPIKey)
  40991. }
  40992. if m.allow_list != nil {
  40993. fields = append(fields, wx.FieldAllowList)
  40994. }
  40995. if m.group_allow_list != nil {
  40996. fields = append(fields, wx.FieldGroupAllowList)
  40997. }
  40998. if m.block_list != nil {
  40999. fields = append(fields, wx.FieldBlockList)
  41000. }
  41001. if m.group_block_list != nil {
  41002. fields = append(fields, wx.FieldGroupBlockList)
  41003. }
  41004. if m.ctype != nil {
  41005. fields = append(fields, wx.FieldCtype)
  41006. }
  41007. return fields
  41008. }
  41009. // Field returns the value of a field with the given name. The second boolean
  41010. // return value indicates that this field was not set, or was not defined in the
  41011. // schema.
  41012. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  41013. switch name {
  41014. case wx.FieldCreatedAt:
  41015. return m.CreatedAt()
  41016. case wx.FieldUpdatedAt:
  41017. return m.UpdatedAt()
  41018. case wx.FieldStatus:
  41019. return m.Status()
  41020. case wx.FieldDeletedAt:
  41021. return m.DeletedAt()
  41022. case wx.FieldServerID:
  41023. return m.ServerID()
  41024. case wx.FieldPort:
  41025. return m.Port()
  41026. case wx.FieldProcessID:
  41027. return m.ProcessID()
  41028. case wx.FieldCallback:
  41029. return m.Callback()
  41030. case wx.FieldWxid:
  41031. return m.Wxid()
  41032. case wx.FieldAccount:
  41033. return m.Account()
  41034. case wx.FieldNickname:
  41035. return m.Nickname()
  41036. case wx.FieldTel:
  41037. return m.Tel()
  41038. case wx.FieldHeadBig:
  41039. return m.HeadBig()
  41040. case wx.FieldOrganizationID:
  41041. return m.OrganizationID()
  41042. case wx.FieldAgentID:
  41043. return m.AgentID()
  41044. case wx.FieldAPIBase:
  41045. return m.APIBase()
  41046. case wx.FieldAPIKey:
  41047. return m.APIKey()
  41048. case wx.FieldAllowList:
  41049. return m.AllowList()
  41050. case wx.FieldGroupAllowList:
  41051. return m.GroupAllowList()
  41052. case wx.FieldBlockList:
  41053. return m.BlockList()
  41054. case wx.FieldGroupBlockList:
  41055. return m.GroupBlockList()
  41056. case wx.FieldCtype:
  41057. return m.Ctype()
  41058. }
  41059. return nil, false
  41060. }
  41061. // OldField returns the old value of the field from the database. An error is
  41062. // returned if the mutation operation is not UpdateOne, or the query to the
  41063. // database failed.
  41064. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  41065. switch name {
  41066. case wx.FieldCreatedAt:
  41067. return m.OldCreatedAt(ctx)
  41068. case wx.FieldUpdatedAt:
  41069. return m.OldUpdatedAt(ctx)
  41070. case wx.FieldStatus:
  41071. return m.OldStatus(ctx)
  41072. case wx.FieldDeletedAt:
  41073. return m.OldDeletedAt(ctx)
  41074. case wx.FieldServerID:
  41075. return m.OldServerID(ctx)
  41076. case wx.FieldPort:
  41077. return m.OldPort(ctx)
  41078. case wx.FieldProcessID:
  41079. return m.OldProcessID(ctx)
  41080. case wx.FieldCallback:
  41081. return m.OldCallback(ctx)
  41082. case wx.FieldWxid:
  41083. return m.OldWxid(ctx)
  41084. case wx.FieldAccount:
  41085. return m.OldAccount(ctx)
  41086. case wx.FieldNickname:
  41087. return m.OldNickname(ctx)
  41088. case wx.FieldTel:
  41089. return m.OldTel(ctx)
  41090. case wx.FieldHeadBig:
  41091. return m.OldHeadBig(ctx)
  41092. case wx.FieldOrganizationID:
  41093. return m.OldOrganizationID(ctx)
  41094. case wx.FieldAgentID:
  41095. return m.OldAgentID(ctx)
  41096. case wx.FieldAPIBase:
  41097. return m.OldAPIBase(ctx)
  41098. case wx.FieldAPIKey:
  41099. return m.OldAPIKey(ctx)
  41100. case wx.FieldAllowList:
  41101. return m.OldAllowList(ctx)
  41102. case wx.FieldGroupAllowList:
  41103. return m.OldGroupAllowList(ctx)
  41104. case wx.FieldBlockList:
  41105. return m.OldBlockList(ctx)
  41106. case wx.FieldGroupBlockList:
  41107. return m.OldGroupBlockList(ctx)
  41108. case wx.FieldCtype:
  41109. return m.OldCtype(ctx)
  41110. }
  41111. return nil, fmt.Errorf("unknown Wx field %s", name)
  41112. }
  41113. // SetField sets the value of a field with the given name. It returns an error if
  41114. // the field is not defined in the schema, or if the type mismatched the field
  41115. // type.
  41116. func (m *WxMutation) SetField(name string, value ent.Value) error {
  41117. switch name {
  41118. case wx.FieldCreatedAt:
  41119. v, ok := value.(time.Time)
  41120. if !ok {
  41121. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41122. }
  41123. m.SetCreatedAt(v)
  41124. return nil
  41125. case wx.FieldUpdatedAt:
  41126. v, ok := value.(time.Time)
  41127. if !ok {
  41128. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41129. }
  41130. m.SetUpdatedAt(v)
  41131. return nil
  41132. case wx.FieldStatus:
  41133. v, ok := value.(uint8)
  41134. if !ok {
  41135. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41136. }
  41137. m.SetStatus(v)
  41138. return nil
  41139. case wx.FieldDeletedAt:
  41140. v, ok := value.(time.Time)
  41141. if !ok {
  41142. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41143. }
  41144. m.SetDeletedAt(v)
  41145. return nil
  41146. case wx.FieldServerID:
  41147. v, ok := value.(uint64)
  41148. if !ok {
  41149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41150. }
  41151. m.SetServerID(v)
  41152. return nil
  41153. case wx.FieldPort:
  41154. v, ok := value.(string)
  41155. if !ok {
  41156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41157. }
  41158. m.SetPort(v)
  41159. return nil
  41160. case wx.FieldProcessID:
  41161. v, ok := value.(string)
  41162. if !ok {
  41163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41164. }
  41165. m.SetProcessID(v)
  41166. return nil
  41167. case wx.FieldCallback:
  41168. v, ok := value.(string)
  41169. if !ok {
  41170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41171. }
  41172. m.SetCallback(v)
  41173. return nil
  41174. case wx.FieldWxid:
  41175. v, ok := value.(string)
  41176. if !ok {
  41177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41178. }
  41179. m.SetWxid(v)
  41180. return nil
  41181. case wx.FieldAccount:
  41182. v, ok := value.(string)
  41183. if !ok {
  41184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41185. }
  41186. m.SetAccount(v)
  41187. return nil
  41188. case wx.FieldNickname:
  41189. v, ok := value.(string)
  41190. if !ok {
  41191. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41192. }
  41193. m.SetNickname(v)
  41194. return nil
  41195. case wx.FieldTel:
  41196. v, ok := value.(string)
  41197. if !ok {
  41198. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41199. }
  41200. m.SetTel(v)
  41201. return nil
  41202. case wx.FieldHeadBig:
  41203. v, ok := value.(string)
  41204. if !ok {
  41205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41206. }
  41207. m.SetHeadBig(v)
  41208. return nil
  41209. case wx.FieldOrganizationID:
  41210. v, ok := value.(uint64)
  41211. if !ok {
  41212. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41213. }
  41214. m.SetOrganizationID(v)
  41215. return nil
  41216. case wx.FieldAgentID:
  41217. v, ok := value.(uint64)
  41218. if !ok {
  41219. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41220. }
  41221. m.SetAgentID(v)
  41222. return nil
  41223. case wx.FieldAPIBase:
  41224. v, ok := value.(string)
  41225. if !ok {
  41226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41227. }
  41228. m.SetAPIBase(v)
  41229. return nil
  41230. case wx.FieldAPIKey:
  41231. v, ok := value.(string)
  41232. if !ok {
  41233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41234. }
  41235. m.SetAPIKey(v)
  41236. return nil
  41237. case wx.FieldAllowList:
  41238. v, ok := value.([]string)
  41239. if !ok {
  41240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41241. }
  41242. m.SetAllowList(v)
  41243. return nil
  41244. case wx.FieldGroupAllowList:
  41245. v, ok := value.([]string)
  41246. if !ok {
  41247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41248. }
  41249. m.SetGroupAllowList(v)
  41250. return nil
  41251. case wx.FieldBlockList:
  41252. v, ok := value.([]string)
  41253. if !ok {
  41254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41255. }
  41256. m.SetBlockList(v)
  41257. return nil
  41258. case wx.FieldGroupBlockList:
  41259. v, ok := value.([]string)
  41260. if !ok {
  41261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41262. }
  41263. m.SetGroupBlockList(v)
  41264. return nil
  41265. case wx.FieldCtype:
  41266. v, ok := value.(uint64)
  41267. if !ok {
  41268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41269. }
  41270. m.SetCtype(v)
  41271. return nil
  41272. }
  41273. return fmt.Errorf("unknown Wx field %s", name)
  41274. }
  41275. // AddedFields returns all numeric fields that were incremented/decremented during
  41276. // this mutation.
  41277. func (m *WxMutation) AddedFields() []string {
  41278. var fields []string
  41279. if m.addstatus != nil {
  41280. fields = append(fields, wx.FieldStatus)
  41281. }
  41282. if m.addorganization_id != nil {
  41283. fields = append(fields, wx.FieldOrganizationID)
  41284. }
  41285. if m.addctype != nil {
  41286. fields = append(fields, wx.FieldCtype)
  41287. }
  41288. return fields
  41289. }
  41290. // AddedField returns the numeric value that was incremented/decremented on a field
  41291. // with the given name. The second boolean return value indicates that this field
  41292. // was not set, or was not defined in the schema.
  41293. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  41294. switch name {
  41295. case wx.FieldStatus:
  41296. return m.AddedStatus()
  41297. case wx.FieldOrganizationID:
  41298. return m.AddedOrganizationID()
  41299. case wx.FieldCtype:
  41300. return m.AddedCtype()
  41301. }
  41302. return nil, false
  41303. }
  41304. // AddField adds the value to the field with the given name. It returns an error if
  41305. // the field is not defined in the schema, or if the type mismatched the field
  41306. // type.
  41307. func (m *WxMutation) AddField(name string, value ent.Value) error {
  41308. switch name {
  41309. case wx.FieldStatus:
  41310. v, ok := value.(int8)
  41311. if !ok {
  41312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41313. }
  41314. m.AddStatus(v)
  41315. return nil
  41316. case wx.FieldOrganizationID:
  41317. v, ok := value.(int64)
  41318. if !ok {
  41319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41320. }
  41321. m.AddOrganizationID(v)
  41322. return nil
  41323. case wx.FieldCtype:
  41324. v, ok := value.(int64)
  41325. if !ok {
  41326. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41327. }
  41328. m.AddCtype(v)
  41329. return nil
  41330. }
  41331. return fmt.Errorf("unknown Wx numeric field %s", name)
  41332. }
  41333. // ClearedFields returns all nullable fields that were cleared during this
  41334. // mutation.
  41335. func (m *WxMutation) ClearedFields() []string {
  41336. var fields []string
  41337. if m.FieldCleared(wx.FieldStatus) {
  41338. fields = append(fields, wx.FieldStatus)
  41339. }
  41340. if m.FieldCleared(wx.FieldDeletedAt) {
  41341. fields = append(fields, wx.FieldDeletedAt)
  41342. }
  41343. if m.FieldCleared(wx.FieldServerID) {
  41344. fields = append(fields, wx.FieldServerID)
  41345. }
  41346. if m.FieldCleared(wx.FieldOrganizationID) {
  41347. fields = append(fields, wx.FieldOrganizationID)
  41348. }
  41349. if m.FieldCleared(wx.FieldAPIBase) {
  41350. fields = append(fields, wx.FieldAPIBase)
  41351. }
  41352. if m.FieldCleared(wx.FieldAPIKey) {
  41353. fields = append(fields, wx.FieldAPIKey)
  41354. }
  41355. if m.FieldCleared(wx.FieldCtype) {
  41356. fields = append(fields, wx.FieldCtype)
  41357. }
  41358. return fields
  41359. }
  41360. // FieldCleared returns a boolean indicating if a field with the given name was
  41361. // cleared in this mutation.
  41362. func (m *WxMutation) FieldCleared(name string) bool {
  41363. _, ok := m.clearedFields[name]
  41364. return ok
  41365. }
  41366. // ClearField clears the value of the field with the given name. It returns an
  41367. // error if the field is not defined in the schema.
  41368. func (m *WxMutation) ClearField(name string) error {
  41369. switch name {
  41370. case wx.FieldStatus:
  41371. m.ClearStatus()
  41372. return nil
  41373. case wx.FieldDeletedAt:
  41374. m.ClearDeletedAt()
  41375. return nil
  41376. case wx.FieldServerID:
  41377. m.ClearServerID()
  41378. return nil
  41379. case wx.FieldOrganizationID:
  41380. m.ClearOrganizationID()
  41381. return nil
  41382. case wx.FieldAPIBase:
  41383. m.ClearAPIBase()
  41384. return nil
  41385. case wx.FieldAPIKey:
  41386. m.ClearAPIKey()
  41387. return nil
  41388. case wx.FieldCtype:
  41389. m.ClearCtype()
  41390. return nil
  41391. }
  41392. return fmt.Errorf("unknown Wx nullable field %s", name)
  41393. }
  41394. // ResetField resets all changes in the mutation for the field with the given name.
  41395. // It returns an error if the field is not defined in the schema.
  41396. func (m *WxMutation) ResetField(name string) error {
  41397. switch name {
  41398. case wx.FieldCreatedAt:
  41399. m.ResetCreatedAt()
  41400. return nil
  41401. case wx.FieldUpdatedAt:
  41402. m.ResetUpdatedAt()
  41403. return nil
  41404. case wx.FieldStatus:
  41405. m.ResetStatus()
  41406. return nil
  41407. case wx.FieldDeletedAt:
  41408. m.ResetDeletedAt()
  41409. return nil
  41410. case wx.FieldServerID:
  41411. m.ResetServerID()
  41412. return nil
  41413. case wx.FieldPort:
  41414. m.ResetPort()
  41415. return nil
  41416. case wx.FieldProcessID:
  41417. m.ResetProcessID()
  41418. return nil
  41419. case wx.FieldCallback:
  41420. m.ResetCallback()
  41421. return nil
  41422. case wx.FieldWxid:
  41423. m.ResetWxid()
  41424. return nil
  41425. case wx.FieldAccount:
  41426. m.ResetAccount()
  41427. return nil
  41428. case wx.FieldNickname:
  41429. m.ResetNickname()
  41430. return nil
  41431. case wx.FieldTel:
  41432. m.ResetTel()
  41433. return nil
  41434. case wx.FieldHeadBig:
  41435. m.ResetHeadBig()
  41436. return nil
  41437. case wx.FieldOrganizationID:
  41438. m.ResetOrganizationID()
  41439. return nil
  41440. case wx.FieldAgentID:
  41441. m.ResetAgentID()
  41442. return nil
  41443. case wx.FieldAPIBase:
  41444. m.ResetAPIBase()
  41445. return nil
  41446. case wx.FieldAPIKey:
  41447. m.ResetAPIKey()
  41448. return nil
  41449. case wx.FieldAllowList:
  41450. m.ResetAllowList()
  41451. return nil
  41452. case wx.FieldGroupAllowList:
  41453. m.ResetGroupAllowList()
  41454. return nil
  41455. case wx.FieldBlockList:
  41456. m.ResetBlockList()
  41457. return nil
  41458. case wx.FieldGroupBlockList:
  41459. m.ResetGroupBlockList()
  41460. return nil
  41461. case wx.FieldCtype:
  41462. m.ResetCtype()
  41463. return nil
  41464. }
  41465. return fmt.Errorf("unknown Wx field %s", name)
  41466. }
  41467. // AddedEdges returns all edge names that were set/added in this mutation.
  41468. func (m *WxMutation) AddedEdges() []string {
  41469. edges := make([]string, 0, 2)
  41470. if m.server != nil {
  41471. edges = append(edges, wx.EdgeServer)
  41472. }
  41473. if m.agent != nil {
  41474. edges = append(edges, wx.EdgeAgent)
  41475. }
  41476. return edges
  41477. }
  41478. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  41479. // name in this mutation.
  41480. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  41481. switch name {
  41482. case wx.EdgeServer:
  41483. if id := m.server; id != nil {
  41484. return []ent.Value{*id}
  41485. }
  41486. case wx.EdgeAgent:
  41487. if id := m.agent; id != nil {
  41488. return []ent.Value{*id}
  41489. }
  41490. }
  41491. return nil
  41492. }
  41493. // RemovedEdges returns all edge names that were removed in this mutation.
  41494. func (m *WxMutation) RemovedEdges() []string {
  41495. edges := make([]string, 0, 2)
  41496. return edges
  41497. }
  41498. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  41499. // the given name in this mutation.
  41500. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  41501. return nil
  41502. }
  41503. // ClearedEdges returns all edge names that were cleared in this mutation.
  41504. func (m *WxMutation) ClearedEdges() []string {
  41505. edges := make([]string, 0, 2)
  41506. if m.clearedserver {
  41507. edges = append(edges, wx.EdgeServer)
  41508. }
  41509. if m.clearedagent {
  41510. edges = append(edges, wx.EdgeAgent)
  41511. }
  41512. return edges
  41513. }
  41514. // EdgeCleared returns a boolean which indicates if the edge with the given name
  41515. // was cleared in this mutation.
  41516. func (m *WxMutation) EdgeCleared(name string) bool {
  41517. switch name {
  41518. case wx.EdgeServer:
  41519. return m.clearedserver
  41520. case wx.EdgeAgent:
  41521. return m.clearedagent
  41522. }
  41523. return false
  41524. }
  41525. // ClearEdge clears the value of the edge with the given name. It returns an error
  41526. // if that edge is not defined in the schema.
  41527. func (m *WxMutation) ClearEdge(name string) error {
  41528. switch name {
  41529. case wx.EdgeServer:
  41530. m.ClearServer()
  41531. return nil
  41532. case wx.EdgeAgent:
  41533. m.ClearAgent()
  41534. return nil
  41535. }
  41536. return fmt.Errorf("unknown Wx unique edge %s", name)
  41537. }
  41538. // ResetEdge resets all changes to the edge with the given name in this mutation.
  41539. // It returns an error if the edge is not defined in the schema.
  41540. func (m *WxMutation) ResetEdge(name string) error {
  41541. switch name {
  41542. case wx.EdgeServer:
  41543. m.ResetServer()
  41544. return nil
  41545. case wx.EdgeAgent:
  41546. m.ResetAgent()
  41547. return nil
  41548. }
  41549. return fmt.Errorf("unknown Wx edge %s", name)
  41550. }
  41551. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  41552. type WxCardMutation struct {
  41553. config
  41554. op Op
  41555. typ string
  41556. id *uint64
  41557. created_at *time.Time
  41558. updated_at *time.Time
  41559. deleted_at *time.Time
  41560. user_id *uint64
  41561. adduser_id *int64
  41562. wx_user_id *uint64
  41563. addwx_user_id *int64
  41564. avatar *string
  41565. logo *string
  41566. name *string
  41567. company *string
  41568. address *string
  41569. phone *string
  41570. official_account *string
  41571. wechat_account *string
  41572. email *string
  41573. api_base *string
  41574. api_key *string
  41575. ai_info *string
  41576. intro *string
  41577. clearedFields map[string]struct{}
  41578. done bool
  41579. oldValue func(context.Context) (*WxCard, error)
  41580. predicates []predicate.WxCard
  41581. }
  41582. var _ ent.Mutation = (*WxCardMutation)(nil)
  41583. // wxcardOption allows management of the mutation configuration using functional options.
  41584. type wxcardOption func(*WxCardMutation)
  41585. // newWxCardMutation creates new mutation for the WxCard entity.
  41586. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  41587. m := &WxCardMutation{
  41588. config: c,
  41589. op: op,
  41590. typ: TypeWxCard,
  41591. clearedFields: make(map[string]struct{}),
  41592. }
  41593. for _, opt := range opts {
  41594. opt(m)
  41595. }
  41596. return m
  41597. }
  41598. // withWxCardID sets the ID field of the mutation.
  41599. func withWxCardID(id uint64) wxcardOption {
  41600. return func(m *WxCardMutation) {
  41601. var (
  41602. err error
  41603. once sync.Once
  41604. value *WxCard
  41605. )
  41606. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  41607. once.Do(func() {
  41608. if m.done {
  41609. err = errors.New("querying old values post mutation is not allowed")
  41610. } else {
  41611. value, err = m.Client().WxCard.Get(ctx, id)
  41612. }
  41613. })
  41614. return value, err
  41615. }
  41616. m.id = &id
  41617. }
  41618. }
  41619. // withWxCard sets the old WxCard of the mutation.
  41620. func withWxCard(node *WxCard) wxcardOption {
  41621. return func(m *WxCardMutation) {
  41622. m.oldValue = func(context.Context) (*WxCard, error) {
  41623. return node, nil
  41624. }
  41625. m.id = &node.ID
  41626. }
  41627. }
  41628. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41629. // executed in a transaction (ent.Tx), a transactional client is returned.
  41630. func (m WxCardMutation) Client() *Client {
  41631. client := &Client{config: m.config}
  41632. client.init()
  41633. return client
  41634. }
  41635. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41636. // it returns an error otherwise.
  41637. func (m WxCardMutation) Tx() (*Tx, error) {
  41638. if _, ok := m.driver.(*txDriver); !ok {
  41639. return nil, errors.New("ent: mutation is not running in a transaction")
  41640. }
  41641. tx := &Tx{config: m.config}
  41642. tx.init()
  41643. return tx, nil
  41644. }
  41645. // SetID sets the value of the id field. Note that this
  41646. // operation is only accepted on creation of WxCard entities.
  41647. func (m *WxCardMutation) SetID(id uint64) {
  41648. m.id = &id
  41649. }
  41650. // ID returns the ID value in the mutation. Note that the ID is only available
  41651. // if it was provided to the builder or after it was returned from the database.
  41652. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  41653. if m.id == nil {
  41654. return
  41655. }
  41656. return *m.id, true
  41657. }
  41658. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41659. // That means, if the mutation is applied within a transaction with an isolation level such
  41660. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41661. // or updated by the mutation.
  41662. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  41663. switch {
  41664. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41665. id, exists := m.ID()
  41666. if exists {
  41667. return []uint64{id}, nil
  41668. }
  41669. fallthrough
  41670. case m.op.Is(OpUpdate | OpDelete):
  41671. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  41672. default:
  41673. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41674. }
  41675. }
  41676. // SetCreatedAt sets the "created_at" field.
  41677. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  41678. m.created_at = &t
  41679. }
  41680. // CreatedAt returns the value of the "created_at" field in the mutation.
  41681. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  41682. v := m.created_at
  41683. if v == nil {
  41684. return
  41685. }
  41686. return *v, true
  41687. }
  41688. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  41689. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41690. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41691. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  41692. if !m.op.Is(OpUpdateOne) {
  41693. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  41694. }
  41695. if m.id == nil || m.oldValue == nil {
  41696. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  41697. }
  41698. oldValue, err := m.oldValue(ctx)
  41699. if err != nil {
  41700. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  41701. }
  41702. return oldValue.CreatedAt, nil
  41703. }
  41704. // ResetCreatedAt resets all changes to the "created_at" field.
  41705. func (m *WxCardMutation) ResetCreatedAt() {
  41706. m.created_at = nil
  41707. }
  41708. // SetUpdatedAt sets the "updated_at" field.
  41709. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  41710. m.updated_at = &t
  41711. }
  41712. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  41713. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  41714. v := m.updated_at
  41715. if v == nil {
  41716. return
  41717. }
  41718. return *v, true
  41719. }
  41720. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  41721. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41722. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41723. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  41724. if !m.op.Is(OpUpdateOne) {
  41725. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  41726. }
  41727. if m.id == nil || m.oldValue == nil {
  41728. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  41729. }
  41730. oldValue, err := m.oldValue(ctx)
  41731. if err != nil {
  41732. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  41733. }
  41734. return oldValue.UpdatedAt, nil
  41735. }
  41736. // ResetUpdatedAt resets all changes to the "updated_at" field.
  41737. func (m *WxCardMutation) ResetUpdatedAt() {
  41738. m.updated_at = nil
  41739. }
  41740. // SetDeletedAt sets the "deleted_at" field.
  41741. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  41742. m.deleted_at = &t
  41743. }
  41744. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  41745. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  41746. v := m.deleted_at
  41747. if v == nil {
  41748. return
  41749. }
  41750. return *v, true
  41751. }
  41752. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  41753. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41754. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41755. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  41756. if !m.op.Is(OpUpdateOne) {
  41757. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  41758. }
  41759. if m.id == nil || m.oldValue == nil {
  41760. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  41761. }
  41762. oldValue, err := m.oldValue(ctx)
  41763. if err != nil {
  41764. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  41765. }
  41766. return oldValue.DeletedAt, nil
  41767. }
  41768. // ClearDeletedAt clears the value of the "deleted_at" field.
  41769. func (m *WxCardMutation) ClearDeletedAt() {
  41770. m.deleted_at = nil
  41771. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  41772. }
  41773. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  41774. func (m *WxCardMutation) DeletedAtCleared() bool {
  41775. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  41776. return ok
  41777. }
  41778. // ResetDeletedAt resets all changes to the "deleted_at" field.
  41779. func (m *WxCardMutation) ResetDeletedAt() {
  41780. m.deleted_at = nil
  41781. delete(m.clearedFields, wxcard.FieldDeletedAt)
  41782. }
  41783. // SetUserID sets the "user_id" field.
  41784. func (m *WxCardMutation) SetUserID(u uint64) {
  41785. m.user_id = &u
  41786. m.adduser_id = nil
  41787. }
  41788. // UserID returns the value of the "user_id" field in the mutation.
  41789. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  41790. v := m.user_id
  41791. if v == nil {
  41792. return
  41793. }
  41794. return *v, true
  41795. }
  41796. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  41797. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41798. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41799. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  41800. if !m.op.Is(OpUpdateOne) {
  41801. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  41802. }
  41803. if m.id == nil || m.oldValue == nil {
  41804. return v, errors.New("OldUserID requires an ID field in the mutation")
  41805. }
  41806. oldValue, err := m.oldValue(ctx)
  41807. if err != nil {
  41808. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  41809. }
  41810. return oldValue.UserID, nil
  41811. }
  41812. // AddUserID adds u to the "user_id" field.
  41813. func (m *WxCardMutation) AddUserID(u int64) {
  41814. if m.adduser_id != nil {
  41815. *m.adduser_id += u
  41816. } else {
  41817. m.adduser_id = &u
  41818. }
  41819. }
  41820. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  41821. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  41822. v := m.adduser_id
  41823. if v == nil {
  41824. return
  41825. }
  41826. return *v, true
  41827. }
  41828. // ClearUserID clears the value of the "user_id" field.
  41829. func (m *WxCardMutation) ClearUserID() {
  41830. m.user_id = nil
  41831. m.adduser_id = nil
  41832. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  41833. }
  41834. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  41835. func (m *WxCardMutation) UserIDCleared() bool {
  41836. _, ok := m.clearedFields[wxcard.FieldUserID]
  41837. return ok
  41838. }
  41839. // ResetUserID resets all changes to the "user_id" field.
  41840. func (m *WxCardMutation) ResetUserID() {
  41841. m.user_id = nil
  41842. m.adduser_id = nil
  41843. delete(m.clearedFields, wxcard.FieldUserID)
  41844. }
  41845. // SetWxUserID sets the "wx_user_id" field.
  41846. func (m *WxCardMutation) SetWxUserID(u uint64) {
  41847. m.wx_user_id = &u
  41848. m.addwx_user_id = nil
  41849. }
  41850. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  41851. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  41852. v := m.wx_user_id
  41853. if v == nil {
  41854. return
  41855. }
  41856. return *v, true
  41857. }
  41858. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  41859. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41860. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41861. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  41862. if !m.op.Is(OpUpdateOne) {
  41863. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  41864. }
  41865. if m.id == nil || m.oldValue == nil {
  41866. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  41867. }
  41868. oldValue, err := m.oldValue(ctx)
  41869. if err != nil {
  41870. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  41871. }
  41872. return oldValue.WxUserID, nil
  41873. }
  41874. // AddWxUserID adds u to the "wx_user_id" field.
  41875. func (m *WxCardMutation) AddWxUserID(u int64) {
  41876. if m.addwx_user_id != nil {
  41877. *m.addwx_user_id += u
  41878. } else {
  41879. m.addwx_user_id = &u
  41880. }
  41881. }
  41882. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  41883. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  41884. v := m.addwx_user_id
  41885. if v == nil {
  41886. return
  41887. }
  41888. return *v, true
  41889. }
  41890. // ClearWxUserID clears the value of the "wx_user_id" field.
  41891. func (m *WxCardMutation) ClearWxUserID() {
  41892. m.wx_user_id = nil
  41893. m.addwx_user_id = nil
  41894. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  41895. }
  41896. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  41897. func (m *WxCardMutation) WxUserIDCleared() bool {
  41898. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  41899. return ok
  41900. }
  41901. // ResetWxUserID resets all changes to the "wx_user_id" field.
  41902. func (m *WxCardMutation) ResetWxUserID() {
  41903. m.wx_user_id = nil
  41904. m.addwx_user_id = nil
  41905. delete(m.clearedFields, wxcard.FieldWxUserID)
  41906. }
  41907. // SetAvatar sets the "avatar" field.
  41908. func (m *WxCardMutation) SetAvatar(s string) {
  41909. m.avatar = &s
  41910. }
  41911. // Avatar returns the value of the "avatar" field in the mutation.
  41912. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  41913. v := m.avatar
  41914. if v == nil {
  41915. return
  41916. }
  41917. return *v, true
  41918. }
  41919. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  41920. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41921. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41922. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  41923. if !m.op.Is(OpUpdateOne) {
  41924. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  41925. }
  41926. if m.id == nil || m.oldValue == nil {
  41927. return v, errors.New("OldAvatar requires an ID field in the mutation")
  41928. }
  41929. oldValue, err := m.oldValue(ctx)
  41930. if err != nil {
  41931. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  41932. }
  41933. return oldValue.Avatar, nil
  41934. }
  41935. // ResetAvatar resets all changes to the "avatar" field.
  41936. func (m *WxCardMutation) ResetAvatar() {
  41937. m.avatar = nil
  41938. }
  41939. // SetLogo sets the "logo" field.
  41940. func (m *WxCardMutation) SetLogo(s string) {
  41941. m.logo = &s
  41942. }
  41943. // Logo returns the value of the "logo" field in the mutation.
  41944. func (m *WxCardMutation) Logo() (r string, exists bool) {
  41945. v := m.logo
  41946. if v == nil {
  41947. return
  41948. }
  41949. return *v, true
  41950. }
  41951. // OldLogo returns the old "logo" field's value of the WxCard entity.
  41952. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41953. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41954. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  41955. if !m.op.Is(OpUpdateOne) {
  41956. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  41957. }
  41958. if m.id == nil || m.oldValue == nil {
  41959. return v, errors.New("OldLogo requires an ID field in the mutation")
  41960. }
  41961. oldValue, err := m.oldValue(ctx)
  41962. if err != nil {
  41963. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  41964. }
  41965. return oldValue.Logo, nil
  41966. }
  41967. // ResetLogo resets all changes to the "logo" field.
  41968. func (m *WxCardMutation) ResetLogo() {
  41969. m.logo = nil
  41970. }
  41971. // SetName sets the "name" field.
  41972. func (m *WxCardMutation) SetName(s string) {
  41973. m.name = &s
  41974. }
  41975. // Name returns the value of the "name" field in the mutation.
  41976. func (m *WxCardMutation) Name() (r string, exists bool) {
  41977. v := m.name
  41978. if v == nil {
  41979. return
  41980. }
  41981. return *v, true
  41982. }
  41983. // OldName returns the old "name" field's value of the WxCard entity.
  41984. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41985. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41986. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  41987. if !m.op.Is(OpUpdateOne) {
  41988. return v, errors.New("OldName is only allowed on UpdateOne operations")
  41989. }
  41990. if m.id == nil || m.oldValue == nil {
  41991. return v, errors.New("OldName requires an ID field in the mutation")
  41992. }
  41993. oldValue, err := m.oldValue(ctx)
  41994. if err != nil {
  41995. return v, fmt.Errorf("querying old value for OldName: %w", err)
  41996. }
  41997. return oldValue.Name, nil
  41998. }
  41999. // ResetName resets all changes to the "name" field.
  42000. func (m *WxCardMutation) ResetName() {
  42001. m.name = nil
  42002. }
  42003. // SetCompany sets the "company" field.
  42004. func (m *WxCardMutation) SetCompany(s string) {
  42005. m.company = &s
  42006. }
  42007. // Company returns the value of the "company" field in the mutation.
  42008. func (m *WxCardMutation) Company() (r string, exists bool) {
  42009. v := m.company
  42010. if v == nil {
  42011. return
  42012. }
  42013. return *v, true
  42014. }
  42015. // OldCompany returns the old "company" field's value of the WxCard entity.
  42016. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42017. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42018. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  42019. if !m.op.Is(OpUpdateOne) {
  42020. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  42021. }
  42022. if m.id == nil || m.oldValue == nil {
  42023. return v, errors.New("OldCompany requires an ID field in the mutation")
  42024. }
  42025. oldValue, err := m.oldValue(ctx)
  42026. if err != nil {
  42027. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  42028. }
  42029. return oldValue.Company, nil
  42030. }
  42031. // ResetCompany resets all changes to the "company" field.
  42032. func (m *WxCardMutation) ResetCompany() {
  42033. m.company = nil
  42034. }
  42035. // SetAddress sets the "address" field.
  42036. func (m *WxCardMutation) SetAddress(s string) {
  42037. m.address = &s
  42038. }
  42039. // Address returns the value of the "address" field in the mutation.
  42040. func (m *WxCardMutation) Address() (r string, exists bool) {
  42041. v := m.address
  42042. if v == nil {
  42043. return
  42044. }
  42045. return *v, true
  42046. }
  42047. // OldAddress returns the old "address" field's value of the WxCard entity.
  42048. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42049. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42050. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  42051. if !m.op.Is(OpUpdateOne) {
  42052. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  42053. }
  42054. if m.id == nil || m.oldValue == nil {
  42055. return v, errors.New("OldAddress requires an ID field in the mutation")
  42056. }
  42057. oldValue, err := m.oldValue(ctx)
  42058. if err != nil {
  42059. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  42060. }
  42061. return oldValue.Address, nil
  42062. }
  42063. // ResetAddress resets all changes to the "address" field.
  42064. func (m *WxCardMutation) ResetAddress() {
  42065. m.address = nil
  42066. }
  42067. // SetPhone sets the "phone" field.
  42068. func (m *WxCardMutation) SetPhone(s string) {
  42069. m.phone = &s
  42070. }
  42071. // Phone returns the value of the "phone" field in the mutation.
  42072. func (m *WxCardMutation) Phone() (r string, exists bool) {
  42073. v := m.phone
  42074. if v == nil {
  42075. return
  42076. }
  42077. return *v, true
  42078. }
  42079. // OldPhone returns the old "phone" field's value of the WxCard entity.
  42080. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42081. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42082. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  42083. if !m.op.Is(OpUpdateOne) {
  42084. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  42085. }
  42086. if m.id == nil || m.oldValue == nil {
  42087. return v, errors.New("OldPhone requires an ID field in the mutation")
  42088. }
  42089. oldValue, err := m.oldValue(ctx)
  42090. if err != nil {
  42091. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  42092. }
  42093. return oldValue.Phone, nil
  42094. }
  42095. // ResetPhone resets all changes to the "phone" field.
  42096. func (m *WxCardMutation) ResetPhone() {
  42097. m.phone = nil
  42098. }
  42099. // SetOfficialAccount sets the "official_account" field.
  42100. func (m *WxCardMutation) SetOfficialAccount(s string) {
  42101. m.official_account = &s
  42102. }
  42103. // OfficialAccount returns the value of the "official_account" field in the mutation.
  42104. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  42105. v := m.official_account
  42106. if v == nil {
  42107. return
  42108. }
  42109. return *v, true
  42110. }
  42111. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  42112. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42113. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42114. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  42115. if !m.op.Is(OpUpdateOne) {
  42116. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  42117. }
  42118. if m.id == nil || m.oldValue == nil {
  42119. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  42120. }
  42121. oldValue, err := m.oldValue(ctx)
  42122. if err != nil {
  42123. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  42124. }
  42125. return oldValue.OfficialAccount, nil
  42126. }
  42127. // ResetOfficialAccount resets all changes to the "official_account" field.
  42128. func (m *WxCardMutation) ResetOfficialAccount() {
  42129. m.official_account = nil
  42130. }
  42131. // SetWechatAccount sets the "wechat_account" field.
  42132. func (m *WxCardMutation) SetWechatAccount(s string) {
  42133. m.wechat_account = &s
  42134. }
  42135. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  42136. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  42137. v := m.wechat_account
  42138. if v == nil {
  42139. return
  42140. }
  42141. return *v, true
  42142. }
  42143. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  42144. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42145. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42146. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  42147. if !m.op.Is(OpUpdateOne) {
  42148. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  42149. }
  42150. if m.id == nil || m.oldValue == nil {
  42151. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  42152. }
  42153. oldValue, err := m.oldValue(ctx)
  42154. if err != nil {
  42155. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  42156. }
  42157. return oldValue.WechatAccount, nil
  42158. }
  42159. // ResetWechatAccount resets all changes to the "wechat_account" field.
  42160. func (m *WxCardMutation) ResetWechatAccount() {
  42161. m.wechat_account = nil
  42162. }
  42163. // SetEmail sets the "email" field.
  42164. func (m *WxCardMutation) SetEmail(s string) {
  42165. m.email = &s
  42166. }
  42167. // Email returns the value of the "email" field in the mutation.
  42168. func (m *WxCardMutation) Email() (r string, exists bool) {
  42169. v := m.email
  42170. if v == nil {
  42171. return
  42172. }
  42173. return *v, true
  42174. }
  42175. // OldEmail returns the old "email" field's value of the WxCard entity.
  42176. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42177. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42178. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  42179. if !m.op.Is(OpUpdateOne) {
  42180. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  42181. }
  42182. if m.id == nil || m.oldValue == nil {
  42183. return v, errors.New("OldEmail requires an ID field in the mutation")
  42184. }
  42185. oldValue, err := m.oldValue(ctx)
  42186. if err != nil {
  42187. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  42188. }
  42189. return oldValue.Email, nil
  42190. }
  42191. // ClearEmail clears the value of the "email" field.
  42192. func (m *WxCardMutation) ClearEmail() {
  42193. m.email = nil
  42194. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  42195. }
  42196. // EmailCleared returns if the "email" field was cleared in this mutation.
  42197. func (m *WxCardMutation) EmailCleared() bool {
  42198. _, ok := m.clearedFields[wxcard.FieldEmail]
  42199. return ok
  42200. }
  42201. // ResetEmail resets all changes to the "email" field.
  42202. func (m *WxCardMutation) ResetEmail() {
  42203. m.email = nil
  42204. delete(m.clearedFields, wxcard.FieldEmail)
  42205. }
  42206. // SetAPIBase sets the "api_base" field.
  42207. func (m *WxCardMutation) SetAPIBase(s string) {
  42208. m.api_base = &s
  42209. }
  42210. // APIBase returns the value of the "api_base" field in the mutation.
  42211. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  42212. v := m.api_base
  42213. if v == nil {
  42214. return
  42215. }
  42216. return *v, true
  42217. }
  42218. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  42219. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42220. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42221. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  42222. if !m.op.Is(OpUpdateOne) {
  42223. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  42224. }
  42225. if m.id == nil || m.oldValue == nil {
  42226. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  42227. }
  42228. oldValue, err := m.oldValue(ctx)
  42229. if err != nil {
  42230. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  42231. }
  42232. return oldValue.APIBase, nil
  42233. }
  42234. // ClearAPIBase clears the value of the "api_base" field.
  42235. func (m *WxCardMutation) ClearAPIBase() {
  42236. m.api_base = nil
  42237. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  42238. }
  42239. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  42240. func (m *WxCardMutation) APIBaseCleared() bool {
  42241. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  42242. return ok
  42243. }
  42244. // ResetAPIBase resets all changes to the "api_base" field.
  42245. func (m *WxCardMutation) ResetAPIBase() {
  42246. m.api_base = nil
  42247. delete(m.clearedFields, wxcard.FieldAPIBase)
  42248. }
  42249. // SetAPIKey sets the "api_key" field.
  42250. func (m *WxCardMutation) SetAPIKey(s string) {
  42251. m.api_key = &s
  42252. }
  42253. // APIKey returns the value of the "api_key" field in the mutation.
  42254. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  42255. v := m.api_key
  42256. if v == nil {
  42257. return
  42258. }
  42259. return *v, true
  42260. }
  42261. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  42262. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42263. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42264. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  42265. if !m.op.Is(OpUpdateOne) {
  42266. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  42267. }
  42268. if m.id == nil || m.oldValue == nil {
  42269. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  42270. }
  42271. oldValue, err := m.oldValue(ctx)
  42272. if err != nil {
  42273. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  42274. }
  42275. return oldValue.APIKey, nil
  42276. }
  42277. // ClearAPIKey clears the value of the "api_key" field.
  42278. func (m *WxCardMutation) ClearAPIKey() {
  42279. m.api_key = nil
  42280. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  42281. }
  42282. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  42283. func (m *WxCardMutation) APIKeyCleared() bool {
  42284. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  42285. return ok
  42286. }
  42287. // ResetAPIKey resets all changes to the "api_key" field.
  42288. func (m *WxCardMutation) ResetAPIKey() {
  42289. m.api_key = nil
  42290. delete(m.clearedFields, wxcard.FieldAPIKey)
  42291. }
  42292. // SetAiInfo sets the "ai_info" field.
  42293. func (m *WxCardMutation) SetAiInfo(s string) {
  42294. m.ai_info = &s
  42295. }
  42296. // AiInfo returns the value of the "ai_info" field in the mutation.
  42297. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  42298. v := m.ai_info
  42299. if v == nil {
  42300. return
  42301. }
  42302. return *v, true
  42303. }
  42304. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  42305. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42306. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42307. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  42308. if !m.op.Is(OpUpdateOne) {
  42309. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  42310. }
  42311. if m.id == nil || m.oldValue == nil {
  42312. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  42313. }
  42314. oldValue, err := m.oldValue(ctx)
  42315. if err != nil {
  42316. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  42317. }
  42318. return oldValue.AiInfo, nil
  42319. }
  42320. // ClearAiInfo clears the value of the "ai_info" field.
  42321. func (m *WxCardMutation) ClearAiInfo() {
  42322. m.ai_info = nil
  42323. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  42324. }
  42325. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  42326. func (m *WxCardMutation) AiInfoCleared() bool {
  42327. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  42328. return ok
  42329. }
  42330. // ResetAiInfo resets all changes to the "ai_info" field.
  42331. func (m *WxCardMutation) ResetAiInfo() {
  42332. m.ai_info = nil
  42333. delete(m.clearedFields, wxcard.FieldAiInfo)
  42334. }
  42335. // SetIntro sets the "intro" field.
  42336. func (m *WxCardMutation) SetIntro(s string) {
  42337. m.intro = &s
  42338. }
  42339. // Intro returns the value of the "intro" field in the mutation.
  42340. func (m *WxCardMutation) Intro() (r string, exists bool) {
  42341. v := m.intro
  42342. if v == nil {
  42343. return
  42344. }
  42345. return *v, true
  42346. }
  42347. // OldIntro returns the old "intro" field's value of the WxCard entity.
  42348. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42349. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42350. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  42351. if !m.op.Is(OpUpdateOne) {
  42352. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  42353. }
  42354. if m.id == nil || m.oldValue == nil {
  42355. return v, errors.New("OldIntro requires an ID field in the mutation")
  42356. }
  42357. oldValue, err := m.oldValue(ctx)
  42358. if err != nil {
  42359. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  42360. }
  42361. return oldValue.Intro, nil
  42362. }
  42363. // ClearIntro clears the value of the "intro" field.
  42364. func (m *WxCardMutation) ClearIntro() {
  42365. m.intro = nil
  42366. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  42367. }
  42368. // IntroCleared returns if the "intro" field was cleared in this mutation.
  42369. func (m *WxCardMutation) IntroCleared() bool {
  42370. _, ok := m.clearedFields[wxcard.FieldIntro]
  42371. return ok
  42372. }
  42373. // ResetIntro resets all changes to the "intro" field.
  42374. func (m *WxCardMutation) ResetIntro() {
  42375. m.intro = nil
  42376. delete(m.clearedFields, wxcard.FieldIntro)
  42377. }
  42378. // Where appends a list predicates to the WxCardMutation builder.
  42379. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  42380. m.predicates = append(m.predicates, ps...)
  42381. }
  42382. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  42383. // users can use type-assertion to append predicates that do not depend on any generated package.
  42384. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  42385. p := make([]predicate.WxCard, len(ps))
  42386. for i := range ps {
  42387. p[i] = ps[i]
  42388. }
  42389. m.Where(p...)
  42390. }
  42391. // Op returns the operation name.
  42392. func (m *WxCardMutation) Op() Op {
  42393. return m.op
  42394. }
  42395. // SetOp allows setting the mutation operation.
  42396. func (m *WxCardMutation) SetOp(op Op) {
  42397. m.op = op
  42398. }
  42399. // Type returns the node type of this mutation (WxCard).
  42400. func (m *WxCardMutation) Type() string {
  42401. return m.typ
  42402. }
  42403. // Fields returns all fields that were changed during this mutation. Note that in
  42404. // order to get all numeric fields that were incremented/decremented, call
  42405. // AddedFields().
  42406. func (m *WxCardMutation) Fields() []string {
  42407. fields := make([]string, 0, 18)
  42408. if m.created_at != nil {
  42409. fields = append(fields, wxcard.FieldCreatedAt)
  42410. }
  42411. if m.updated_at != nil {
  42412. fields = append(fields, wxcard.FieldUpdatedAt)
  42413. }
  42414. if m.deleted_at != nil {
  42415. fields = append(fields, wxcard.FieldDeletedAt)
  42416. }
  42417. if m.user_id != nil {
  42418. fields = append(fields, wxcard.FieldUserID)
  42419. }
  42420. if m.wx_user_id != nil {
  42421. fields = append(fields, wxcard.FieldWxUserID)
  42422. }
  42423. if m.avatar != nil {
  42424. fields = append(fields, wxcard.FieldAvatar)
  42425. }
  42426. if m.logo != nil {
  42427. fields = append(fields, wxcard.FieldLogo)
  42428. }
  42429. if m.name != nil {
  42430. fields = append(fields, wxcard.FieldName)
  42431. }
  42432. if m.company != nil {
  42433. fields = append(fields, wxcard.FieldCompany)
  42434. }
  42435. if m.address != nil {
  42436. fields = append(fields, wxcard.FieldAddress)
  42437. }
  42438. if m.phone != nil {
  42439. fields = append(fields, wxcard.FieldPhone)
  42440. }
  42441. if m.official_account != nil {
  42442. fields = append(fields, wxcard.FieldOfficialAccount)
  42443. }
  42444. if m.wechat_account != nil {
  42445. fields = append(fields, wxcard.FieldWechatAccount)
  42446. }
  42447. if m.email != nil {
  42448. fields = append(fields, wxcard.FieldEmail)
  42449. }
  42450. if m.api_base != nil {
  42451. fields = append(fields, wxcard.FieldAPIBase)
  42452. }
  42453. if m.api_key != nil {
  42454. fields = append(fields, wxcard.FieldAPIKey)
  42455. }
  42456. if m.ai_info != nil {
  42457. fields = append(fields, wxcard.FieldAiInfo)
  42458. }
  42459. if m.intro != nil {
  42460. fields = append(fields, wxcard.FieldIntro)
  42461. }
  42462. return fields
  42463. }
  42464. // Field returns the value of a field with the given name. The second boolean
  42465. // return value indicates that this field was not set, or was not defined in the
  42466. // schema.
  42467. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  42468. switch name {
  42469. case wxcard.FieldCreatedAt:
  42470. return m.CreatedAt()
  42471. case wxcard.FieldUpdatedAt:
  42472. return m.UpdatedAt()
  42473. case wxcard.FieldDeletedAt:
  42474. return m.DeletedAt()
  42475. case wxcard.FieldUserID:
  42476. return m.UserID()
  42477. case wxcard.FieldWxUserID:
  42478. return m.WxUserID()
  42479. case wxcard.FieldAvatar:
  42480. return m.Avatar()
  42481. case wxcard.FieldLogo:
  42482. return m.Logo()
  42483. case wxcard.FieldName:
  42484. return m.Name()
  42485. case wxcard.FieldCompany:
  42486. return m.Company()
  42487. case wxcard.FieldAddress:
  42488. return m.Address()
  42489. case wxcard.FieldPhone:
  42490. return m.Phone()
  42491. case wxcard.FieldOfficialAccount:
  42492. return m.OfficialAccount()
  42493. case wxcard.FieldWechatAccount:
  42494. return m.WechatAccount()
  42495. case wxcard.FieldEmail:
  42496. return m.Email()
  42497. case wxcard.FieldAPIBase:
  42498. return m.APIBase()
  42499. case wxcard.FieldAPIKey:
  42500. return m.APIKey()
  42501. case wxcard.FieldAiInfo:
  42502. return m.AiInfo()
  42503. case wxcard.FieldIntro:
  42504. return m.Intro()
  42505. }
  42506. return nil, false
  42507. }
  42508. // OldField returns the old value of the field from the database. An error is
  42509. // returned if the mutation operation is not UpdateOne, or the query to the
  42510. // database failed.
  42511. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  42512. switch name {
  42513. case wxcard.FieldCreatedAt:
  42514. return m.OldCreatedAt(ctx)
  42515. case wxcard.FieldUpdatedAt:
  42516. return m.OldUpdatedAt(ctx)
  42517. case wxcard.FieldDeletedAt:
  42518. return m.OldDeletedAt(ctx)
  42519. case wxcard.FieldUserID:
  42520. return m.OldUserID(ctx)
  42521. case wxcard.FieldWxUserID:
  42522. return m.OldWxUserID(ctx)
  42523. case wxcard.FieldAvatar:
  42524. return m.OldAvatar(ctx)
  42525. case wxcard.FieldLogo:
  42526. return m.OldLogo(ctx)
  42527. case wxcard.FieldName:
  42528. return m.OldName(ctx)
  42529. case wxcard.FieldCompany:
  42530. return m.OldCompany(ctx)
  42531. case wxcard.FieldAddress:
  42532. return m.OldAddress(ctx)
  42533. case wxcard.FieldPhone:
  42534. return m.OldPhone(ctx)
  42535. case wxcard.FieldOfficialAccount:
  42536. return m.OldOfficialAccount(ctx)
  42537. case wxcard.FieldWechatAccount:
  42538. return m.OldWechatAccount(ctx)
  42539. case wxcard.FieldEmail:
  42540. return m.OldEmail(ctx)
  42541. case wxcard.FieldAPIBase:
  42542. return m.OldAPIBase(ctx)
  42543. case wxcard.FieldAPIKey:
  42544. return m.OldAPIKey(ctx)
  42545. case wxcard.FieldAiInfo:
  42546. return m.OldAiInfo(ctx)
  42547. case wxcard.FieldIntro:
  42548. return m.OldIntro(ctx)
  42549. }
  42550. return nil, fmt.Errorf("unknown WxCard field %s", name)
  42551. }
  42552. // SetField sets the value of a field with the given name. It returns an error if
  42553. // the field is not defined in the schema, or if the type mismatched the field
  42554. // type.
  42555. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  42556. switch name {
  42557. case wxcard.FieldCreatedAt:
  42558. v, ok := value.(time.Time)
  42559. if !ok {
  42560. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42561. }
  42562. m.SetCreatedAt(v)
  42563. return nil
  42564. case wxcard.FieldUpdatedAt:
  42565. v, ok := value.(time.Time)
  42566. if !ok {
  42567. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42568. }
  42569. m.SetUpdatedAt(v)
  42570. return nil
  42571. case wxcard.FieldDeletedAt:
  42572. v, ok := value.(time.Time)
  42573. if !ok {
  42574. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42575. }
  42576. m.SetDeletedAt(v)
  42577. return nil
  42578. case wxcard.FieldUserID:
  42579. v, ok := value.(uint64)
  42580. if !ok {
  42581. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42582. }
  42583. m.SetUserID(v)
  42584. return nil
  42585. case wxcard.FieldWxUserID:
  42586. v, ok := value.(uint64)
  42587. if !ok {
  42588. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42589. }
  42590. m.SetWxUserID(v)
  42591. return nil
  42592. case wxcard.FieldAvatar:
  42593. v, ok := value.(string)
  42594. if !ok {
  42595. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42596. }
  42597. m.SetAvatar(v)
  42598. return nil
  42599. case wxcard.FieldLogo:
  42600. v, ok := value.(string)
  42601. if !ok {
  42602. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42603. }
  42604. m.SetLogo(v)
  42605. return nil
  42606. case wxcard.FieldName:
  42607. v, ok := value.(string)
  42608. if !ok {
  42609. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42610. }
  42611. m.SetName(v)
  42612. return nil
  42613. case wxcard.FieldCompany:
  42614. v, ok := value.(string)
  42615. if !ok {
  42616. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42617. }
  42618. m.SetCompany(v)
  42619. return nil
  42620. case wxcard.FieldAddress:
  42621. v, ok := value.(string)
  42622. if !ok {
  42623. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42624. }
  42625. m.SetAddress(v)
  42626. return nil
  42627. case wxcard.FieldPhone:
  42628. v, ok := value.(string)
  42629. if !ok {
  42630. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42631. }
  42632. m.SetPhone(v)
  42633. return nil
  42634. case wxcard.FieldOfficialAccount:
  42635. v, ok := value.(string)
  42636. if !ok {
  42637. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42638. }
  42639. m.SetOfficialAccount(v)
  42640. return nil
  42641. case wxcard.FieldWechatAccount:
  42642. v, ok := value.(string)
  42643. if !ok {
  42644. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42645. }
  42646. m.SetWechatAccount(v)
  42647. return nil
  42648. case wxcard.FieldEmail:
  42649. v, ok := value.(string)
  42650. if !ok {
  42651. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42652. }
  42653. m.SetEmail(v)
  42654. return nil
  42655. case wxcard.FieldAPIBase:
  42656. v, ok := value.(string)
  42657. if !ok {
  42658. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42659. }
  42660. m.SetAPIBase(v)
  42661. return nil
  42662. case wxcard.FieldAPIKey:
  42663. v, ok := value.(string)
  42664. if !ok {
  42665. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42666. }
  42667. m.SetAPIKey(v)
  42668. return nil
  42669. case wxcard.FieldAiInfo:
  42670. v, ok := value.(string)
  42671. if !ok {
  42672. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42673. }
  42674. m.SetAiInfo(v)
  42675. return nil
  42676. case wxcard.FieldIntro:
  42677. v, ok := value.(string)
  42678. if !ok {
  42679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42680. }
  42681. m.SetIntro(v)
  42682. return nil
  42683. }
  42684. return fmt.Errorf("unknown WxCard field %s", name)
  42685. }
  42686. // AddedFields returns all numeric fields that were incremented/decremented during
  42687. // this mutation.
  42688. func (m *WxCardMutation) AddedFields() []string {
  42689. var fields []string
  42690. if m.adduser_id != nil {
  42691. fields = append(fields, wxcard.FieldUserID)
  42692. }
  42693. if m.addwx_user_id != nil {
  42694. fields = append(fields, wxcard.FieldWxUserID)
  42695. }
  42696. return fields
  42697. }
  42698. // AddedField returns the numeric value that was incremented/decremented on a field
  42699. // with the given name. The second boolean return value indicates that this field
  42700. // was not set, or was not defined in the schema.
  42701. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  42702. switch name {
  42703. case wxcard.FieldUserID:
  42704. return m.AddedUserID()
  42705. case wxcard.FieldWxUserID:
  42706. return m.AddedWxUserID()
  42707. }
  42708. return nil, false
  42709. }
  42710. // AddField adds the value to the field with the given name. It returns an error if
  42711. // the field is not defined in the schema, or if the type mismatched the field
  42712. // type.
  42713. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  42714. switch name {
  42715. case wxcard.FieldUserID:
  42716. v, ok := value.(int64)
  42717. if !ok {
  42718. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42719. }
  42720. m.AddUserID(v)
  42721. return nil
  42722. case wxcard.FieldWxUserID:
  42723. v, ok := value.(int64)
  42724. if !ok {
  42725. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42726. }
  42727. m.AddWxUserID(v)
  42728. return nil
  42729. }
  42730. return fmt.Errorf("unknown WxCard numeric field %s", name)
  42731. }
  42732. // ClearedFields returns all nullable fields that were cleared during this
  42733. // mutation.
  42734. func (m *WxCardMutation) ClearedFields() []string {
  42735. var fields []string
  42736. if m.FieldCleared(wxcard.FieldDeletedAt) {
  42737. fields = append(fields, wxcard.FieldDeletedAt)
  42738. }
  42739. if m.FieldCleared(wxcard.FieldUserID) {
  42740. fields = append(fields, wxcard.FieldUserID)
  42741. }
  42742. if m.FieldCleared(wxcard.FieldWxUserID) {
  42743. fields = append(fields, wxcard.FieldWxUserID)
  42744. }
  42745. if m.FieldCleared(wxcard.FieldEmail) {
  42746. fields = append(fields, wxcard.FieldEmail)
  42747. }
  42748. if m.FieldCleared(wxcard.FieldAPIBase) {
  42749. fields = append(fields, wxcard.FieldAPIBase)
  42750. }
  42751. if m.FieldCleared(wxcard.FieldAPIKey) {
  42752. fields = append(fields, wxcard.FieldAPIKey)
  42753. }
  42754. if m.FieldCleared(wxcard.FieldAiInfo) {
  42755. fields = append(fields, wxcard.FieldAiInfo)
  42756. }
  42757. if m.FieldCleared(wxcard.FieldIntro) {
  42758. fields = append(fields, wxcard.FieldIntro)
  42759. }
  42760. return fields
  42761. }
  42762. // FieldCleared returns a boolean indicating if a field with the given name was
  42763. // cleared in this mutation.
  42764. func (m *WxCardMutation) FieldCleared(name string) bool {
  42765. _, ok := m.clearedFields[name]
  42766. return ok
  42767. }
  42768. // ClearField clears the value of the field with the given name. It returns an
  42769. // error if the field is not defined in the schema.
  42770. func (m *WxCardMutation) ClearField(name string) error {
  42771. switch name {
  42772. case wxcard.FieldDeletedAt:
  42773. m.ClearDeletedAt()
  42774. return nil
  42775. case wxcard.FieldUserID:
  42776. m.ClearUserID()
  42777. return nil
  42778. case wxcard.FieldWxUserID:
  42779. m.ClearWxUserID()
  42780. return nil
  42781. case wxcard.FieldEmail:
  42782. m.ClearEmail()
  42783. return nil
  42784. case wxcard.FieldAPIBase:
  42785. m.ClearAPIBase()
  42786. return nil
  42787. case wxcard.FieldAPIKey:
  42788. m.ClearAPIKey()
  42789. return nil
  42790. case wxcard.FieldAiInfo:
  42791. m.ClearAiInfo()
  42792. return nil
  42793. case wxcard.FieldIntro:
  42794. m.ClearIntro()
  42795. return nil
  42796. }
  42797. return fmt.Errorf("unknown WxCard nullable field %s", name)
  42798. }
  42799. // ResetField resets all changes in the mutation for the field with the given name.
  42800. // It returns an error if the field is not defined in the schema.
  42801. func (m *WxCardMutation) ResetField(name string) error {
  42802. switch name {
  42803. case wxcard.FieldCreatedAt:
  42804. m.ResetCreatedAt()
  42805. return nil
  42806. case wxcard.FieldUpdatedAt:
  42807. m.ResetUpdatedAt()
  42808. return nil
  42809. case wxcard.FieldDeletedAt:
  42810. m.ResetDeletedAt()
  42811. return nil
  42812. case wxcard.FieldUserID:
  42813. m.ResetUserID()
  42814. return nil
  42815. case wxcard.FieldWxUserID:
  42816. m.ResetWxUserID()
  42817. return nil
  42818. case wxcard.FieldAvatar:
  42819. m.ResetAvatar()
  42820. return nil
  42821. case wxcard.FieldLogo:
  42822. m.ResetLogo()
  42823. return nil
  42824. case wxcard.FieldName:
  42825. m.ResetName()
  42826. return nil
  42827. case wxcard.FieldCompany:
  42828. m.ResetCompany()
  42829. return nil
  42830. case wxcard.FieldAddress:
  42831. m.ResetAddress()
  42832. return nil
  42833. case wxcard.FieldPhone:
  42834. m.ResetPhone()
  42835. return nil
  42836. case wxcard.FieldOfficialAccount:
  42837. m.ResetOfficialAccount()
  42838. return nil
  42839. case wxcard.FieldWechatAccount:
  42840. m.ResetWechatAccount()
  42841. return nil
  42842. case wxcard.FieldEmail:
  42843. m.ResetEmail()
  42844. return nil
  42845. case wxcard.FieldAPIBase:
  42846. m.ResetAPIBase()
  42847. return nil
  42848. case wxcard.FieldAPIKey:
  42849. m.ResetAPIKey()
  42850. return nil
  42851. case wxcard.FieldAiInfo:
  42852. m.ResetAiInfo()
  42853. return nil
  42854. case wxcard.FieldIntro:
  42855. m.ResetIntro()
  42856. return nil
  42857. }
  42858. return fmt.Errorf("unknown WxCard field %s", name)
  42859. }
  42860. // AddedEdges returns all edge names that were set/added in this mutation.
  42861. func (m *WxCardMutation) AddedEdges() []string {
  42862. edges := make([]string, 0, 0)
  42863. return edges
  42864. }
  42865. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  42866. // name in this mutation.
  42867. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  42868. return nil
  42869. }
  42870. // RemovedEdges returns all edge names that were removed in this mutation.
  42871. func (m *WxCardMutation) RemovedEdges() []string {
  42872. edges := make([]string, 0, 0)
  42873. return edges
  42874. }
  42875. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  42876. // the given name in this mutation.
  42877. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  42878. return nil
  42879. }
  42880. // ClearedEdges returns all edge names that were cleared in this mutation.
  42881. func (m *WxCardMutation) ClearedEdges() []string {
  42882. edges := make([]string, 0, 0)
  42883. return edges
  42884. }
  42885. // EdgeCleared returns a boolean which indicates if the edge with the given name
  42886. // was cleared in this mutation.
  42887. func (m *WxCardMutation) EdgeCleared(name string) bool {
  42888. return false
  42889. }
  42890. // ClearEdge clears the value of the edge with the given name. It returns an error
  42891. // if that edge is not defined in the schema.
  42892. func (m *WxCardMutation) ClearEdge(name string) error {
  42893. return fmt.Errorf("unknown WxCard unique edge %s", name)
  42894. }
  42895. // ResetEdge resets all changes to the edge with the given name in this mutation.
  42896. // It returns an error if the edge is not defined in the schema.
  42897. func (m *WxCardMutation) ResetEdge(name string) error {
  42898. return fmt.Errorf("unknown WxCard edge %s", name)
  42899. }
  42900. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  42901. type WxCardUserMutation struct {
  42902. config
  42903. op Op
  42904. typ string
  42905. id *uint64
  42906. created_at *time.Time
  42907. updated_at *time.Time
  42908. deleted_at *time.Time
  42909. wxid *string
  42910. account *string
  42911. avatar *string
  42912. nickname *string
  42913. remark *string
  42914. phone *string
  42915. open_id *string
  42916. union_id *string
  42917. session_key *string
  42918. is_vip *int
  42919. addis_vip *int
  42920. clearedFields map[string]struct{}
  42921. done bool
  42922. oldValue func(context.Context) (*WxCardUser, error)
  42923. predicates []predicate.WxCardUser
  42924. }
  42925. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  42926. // wxcarduserOption allows management of the mutation configuration using functional options.
  42927. type wxcarduserOption func(*WxCardUserMutation)
  42928. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  42929. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  42930. m := &WxCardUserMutation{
  42931. config: c,
  42932. op: op,
  42933. typ: TypeWxCardUser,
  42934. clearedFields: make(map[string]struct{}),
  42935. }
  42936. for _, opt := range opts {
  42937. opt(m)
  42938. }
  42939. return m
  42940. }
  42941. // withWxCardUserID sets the ID field of the mutation.
  42942. func withWxCardUserID(id uint64) wxcarduserOption {
  42943. return func(m *WxCardUserMutation) {
  42944. var (
  42945. err error
  42946. once sync.Once
  42947. value *WxCardUser
  42948. )
  42949. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  42950. once.Do(func() {
  42951. if m.done {
  42952. err = errors.New("querying old values post mutation is not allowed")
  42953. } else {
  42954. value, err = m.Client().WxCardUser.Get(ctx, id)
  42955. }
  42956. })
  42957. return value, err
  42958. }
  42959. m.id = &id
  42960. }
  42961. }
  42962. // withWxCardUser sets the old WxCardUser of the mutation.
  42963. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  42964. return func(m *WxCardUserMutation) {
  42965. m.oldValue = func(context.Context) (*WxCardUser, error) {
  42966. return node, nil
  42967. }
  42968. m.id = &node.ID
  42969. }
  42970. }
  42971. // Client returns a new `ent.Client` from the mutation. If the mutation was
  42972. // executed in a transaction (ent.Tx), a transactional client is returned.
  42973. func (m WxCardUserMutation) Client() *Client {
  42974. client := &Client{config: m.config}
  42975. client.init()
  42976. return client
  42977. }
  42978. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  42979. // it returns an error otherwise.
  42980. func (m WxCardUserMutation) Tx() (*Tx, error) {
  42981. if _, ok := m.driver.(*txDriver); !ok {
  42982. return nil, errors.New("ent: mutation is not running in a transaction")
  42983. }
  42984. tx := &Tx{config: m.config}
  42985. tx.init()
  42986. return tx, nil
  42987. }
  42988. // SetID sets the value of the id field. Note that this
  42989. // operation is only accepted on creation of WxCardUser entities.
  42990. func (m *WxCardUserMutation) SetID(id uint64) {
  42991. m.id = &id
  42992. }
  42993. // ID returns the ID value in the mutation. Note that the ID is only available
  42994. // if it was provided to the builder or after it was returned from the database.
  42995. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  42996. if m.id == nil {
  42997. return
  42998. }
  42999. return *m.id, true
  43000. }
  43001. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  43002. // That means, if the mutation is applied within a transaction with an isolation level such
  43003. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  43004. // or updated by the mutation.
  43005. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  43006. switch {
  43007. case m.op.Is(OpUpdateOne | OpDeleteOne):
  43008. id, exists := m.ID()
  43009. if exists {
  43010. return []uint64{id}, nil
  43011. }
  43012. fallthrough
  43013. case m.op.Is(OpUpdate | OpDelete):
  43014. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  43015. default:
  43016. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  43017. }
  43018. }
  43019. // SetCreatedAt sets the "created_at" field.
  43020. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  43021. m.created_at = &t
  43022. }
  43023. // CreatedAt returns the value of the "created_at" field in the mutation.
  43024. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  43025. v := m.created_at
  43026. if v == nil {
  43027. return
  43028. }
  43029. return *v, true
  43030. }
  43031. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  43032. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43033. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43034. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  43035. if !m.op.Is(OpUpdateOne) {
  43036. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  43037. }
  43038. if m.id == nil || m.oldValue == nil {
  43039. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  43040. }
  43041. oldValue, err := m.oldValue(ctx)
  43042. if err != nil {
  43043. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  43044. }
  43045. return oldValue.CreatedAt, nil
  43046. }
  43047. // ResetCreatedAt resets all changes to the "created_at" field.
  43048. func (m *WxCardUserMutation) ResetCreatedAt() {
  43049. m.created_at = nil
  43050. }
  43051. // SetUpdatedAt sets the "updated_at" field.
  43052. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  43053. m.updated_at = &t
  43054. }
  43055. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  43056. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  43057. v := m.updated_at
  43058. if v == nil {
  43059. return
  43060. }
  43061. return *v, true
  43062. }
  43063. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  43064. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43065. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43066. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  43067. if !m.op.Is(OpUpdateOne) {
  43068. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  43069. }
  43070. if m.id == nil || m.oldValue == nil {
  43071. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  43072. }
  43073. oldValue, err := m.oldValue(ctx)
  43074. if err != nil {
  43075. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  43076. }
  43077. return oldValue.UpdatedAt, nil
  43078. }
  43079. // ResetUpdatedAt resets all changes to the "updated_at" field.
  43080. func (m *WxCardUserMutation) ResetUpdatedAt() {
  43081. m.updated_at = nil
  43082. }
  43083. // SetDeletedAt sets the "deleted_at" field.
  43084. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  43085. m.deleted_at = &t
  43086. }
  43087. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  43088. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  43089. v := m.deleted_at
  43090. if v == nil {
  43091. return
  43092. }
  43093. return *v, true
  43094. }
  43095. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  43096. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43097. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43098. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  43099. if !m.op.Is(OpUpdateOne) {
  43100. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  43101. }
  43102. if m.id == nil || m.oldValue == nil {
  43103. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  43104. }
  43105. oldValue, err := m.oldValue(ctx)
  43106. if err != nil {
  43107. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  43108. }
  43109. return oldValue.DeletedAt, nil
  43110. }
  43111. // ClearDeletedAt clears the value of the "deleted_at" field.
  43112. func (m *WxCardUserMutation) ClearDeletedAt() {
  43113. m.deleted_at = nil
  43114. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  43115. }
  43116. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  43117. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  43118. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  43119. return ok
  43120. }
  43121. // ResetDeletedAt resets all changes to the "deleted_at" field.
  43122. func (m *WxCardUserMutation) ResetDeletedAt() {
  43123. m.deleted_at = nil
  43124. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  43125. }
  43126. // SetWxid sets the "wxid" field.
  43127. func (m *WxCardUserMutation) SetWxid(s string) {
  43128. m.wxid = &s
  43129. }
  43130. // Wxid returns the value of the "wxid" field in the mutation.
  43131. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  43132. v := m.wxid
  43133. if v == nil {
  43134. return
  43135. }
  43136. return *v, true
  43137. }
  43138. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  43139. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43140. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43141. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  43142. if !m.op.Is(OpUpdateOne) {
  43143. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  43144. }
  43145. if m.id == nil || m.oldValue == nil {
  43146. return v, errors.New("OldWxid requires an ID field in the mutation")
  43147. }
  43148. oldValue, err := m.oldValue(ctx)
  43149. if err != nil {
  43150. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  43151. }
  43152. return oldValue.Wxid, nil
  43153. }
  43154. // ResetWxid resets all changes to the "wxid" field.
  43155. func (m *WxCardUserMutation) ResetWxid() {
  43156. m.wxid = nil
  43157. }
  43158. // SetAccount sets the "account" field.
  43159. func (m *WxCardUserMutation) SetAccount(s string) {
  43160. m.account = &s
  43161. }
  43162. // Account returns the value of the "account" field in the mutation.
  43163. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  43164. v := m.account
  43165. if v == nil {
  43166. return
  43167. }
  43168. return *v, true
  43169. }
  43170. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  43171. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43172. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43173. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  43174. if !m.op.Is(OpUpdateOne) {
  43175. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  43176. }
  43177. if m.id == nil || m.oldValue == nil {
  43178. return v, errors.New("OldAccount requires an ID field in the mutation")
  43179. }
  43180. oldValue, err := m.oldValue(ctx)
  43181. if err != nil {
  43182. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  43183. }
  43184. return oldValue.Account, nil
  43185. }
  43186. // ResetAccount resets all changes to the "account" field.
  43187. func (m *WxCardUserMutation) ResetAccount() {
  43188. m.account = nil
  43189. }
  43190. // SetAvatar sets the "avatar" field.
  43191. func (m *WxCardUserMutation) SetAvatar(s string) {
  43192. m.avatar = &s
  43193. }
  43194. // Avatar returns the value of the "avatar" field in the mutation.
  43195. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  43196. v := m.avatar
  43197. if v == nil {
  43198. return
  43199. }
  43200. return *v, true
  43201. }
  43202. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  43203. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43204. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43205. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  43206. if !m.op.Is(OpUpdateOne) {
  43207. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  43208. }
  43209. if m.id == nil || m.oldValue == nil {
  43210. return v, errors.New("OldAvatar requires an ID field in the mutation")
  43211. }
  43212. oldValue, err := m.oldValue(ctx)
  43213. if err != nil {
  43214. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  43215. }
  43216. return oldValue.Avatar, nil
  43217. }
  43218. // ResetAvatar resets all changes to the "avatar" field.
  43219. func (m *WxCardUserMutation) ResetAvatar() {
  43220. m.avatar = nil
  43221. }
  43222. // SetNickname sets the "nickname" field.
  43223. func (m *WxCardUserMutation) SetNickname(s string) {
  43224. m.nickname = &s
  43225. }
  43226. // Nickname returns the value of the "nickname" field in the mutation.
  43227. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  43228. v := m.nickname
  43229. if v == nil {
  43230. return
  43231. }
  43232. return *v, true
  43233. }
  43234. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  43235. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43236. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43237. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  43238. if !m.op.Is(OpUpdateOne) {
  43239. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  43240. }
  43241. if m.id == nil || m.oldValue == nil {
  43242. return v, errors.New("OldNickname requires an ID field in the mutation")
  43243. }
  43244. oldValue, err := m.oldValue(ctx)
  43245. if err != nil {
  43246. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  43247. }
  43248. return oldValue.Nickname, nil
  43249. }
  43250. // ResetNickname resets all changes to the "nickname" field.
  43251. func (m *WxCardUserMutation) ResetNickname() {
  43252. m.nickname = nil
  43253. }
  43254. // SetRemark sets the "remark" field.
  43255. func (m *WxCardUserMutation) SetRemark(s string) {
  43256. m.remark = &s
  43257. }
  43258. // Remark returns the value of the "remark" field in the mutation.
  43259. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  43260. v := m.remark
  43261. if v == nil {
  43262. return
  43263. }
  43264. return *v, true
  43265. }
  43266. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  43267. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43268. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43269. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  43270. if !m.op.Is(OpUpdateOne) {
  43271. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  43272. }
  43273. if m.id == nil || m.oldValue == nil {
  43274. return v, errors.New("OldRemark requires an ID field in the mutation")
  43275. }
  43276. oldValue, err := m.oldValue(ctx)
  43277. if err != nil {
  43278. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  43279. }
  43280. return oldValue.Remark, nil
  43281. }
  43282. // ResetRemark resets all changes to the "remark" field.
  43283. func (m *WxCardUserMutation) ResetRemark() {
  43284. m.remark = nil
  43285. }
  43286. // SetPhone sets the "phone" field.
  43287. func (m *WxCardUserMutation) SetPhone(s string) {
  43288. m.phone = &s
  43289. }
  43290. // Phone returns the value of the "phone" field in the mutation.
  43291. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  43292. v := m.phone
  43293. if v == nil {
  43294. return
  43295. }
  43296. return *v, true
  43297. }
  43298. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  43299. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43300. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43301. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  43302. if !m.op.Is(OpUpdateOne) {
  43303. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  43304. }
  43305. if m.id == nil || m.oldValue == nil {
  43306. return v, errors.New("OldPhone requires an ID field in the mutation")
  43307. }
  43308. oldValue, err := m.oldValue(ctx)
  43309. if err != nil {
  43310. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  43311. }
  43312. return oldValue.Phone, nil
  43313. }
  43314. // ResetPhone resets all changes to the "phone" field.
  43315. func (m *WxCardUserMutation) ResetPhone() {
  43316. m.phone = nil
  43317. }
  43318. // SetOpenID sets the "open_id" field.
  43319. func (m *WxCardUserMutation) SetOpenID(s string) {
  43320. m.open_id = &s
  43321. }
  43322. // OpenID returns the value of the "open_id" field in the mutation.
  43323. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  43324. v := m.open_id
  43325. if v == nil {
  43326. return
  43327. }
  43328. return *v, true
  43329. }
  43330. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  43331. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43332. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43333. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  43334. if !m.op.Is(OpUpdateOne) {
  43335. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  43336. }
  43337. if m.id == nil || m.oldValue == nil {
  43338. return v, errors.New("OldOpenID requires an ID field in the mutation")
  43339. }
  43340. oldValue, err := m.oldValue(ctx)
  43341. if err != nil {
  43342. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  43343. }
  43344. return oldValue.OpenID, nil
  43345. }
  43346. // ResetOpenID resets all changes to the "open_id" field.
  43347. func (m *WxCardUserMutation) ResetOpenID() {
  43348. m.open_id = nil
  43349. }
  43350. // SetUnionID sets the "union_id" field.
  43351. func (m *WxCardUserMutation) SetUnionID(s string) {
  43352. m.union_id = &s
  43353. }
  43354. // UnionID returns the value of the "union_id" field in the mutation.
  43355. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  43356. v := m.union_id
  43357. if v == nil {
  43358. return
  43359. }
  43360. return *v, true
  43361. }
  43362. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  43363. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43364. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43365. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  43366. if !m.op.Is(OpUpdateOne) {
  43367. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  43368. }
  43369. if m.id == nil || m.oldValue == nil {
  43370. return v, errors.New("OldUnionID requires an ID field in the mutation")
  43371. }
  43372. oldValue, err := m.oldValue(ctx)
  43373. if err != nil {
  43374. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  43375. }
  43376. return oldValue.UnionID, nil
  43377. }
  43378. // ResetUnionID resets all changes to the "union_id" field.
  43379. func (m *WxCardUserMutation) ResetUnionID() {
  43380. m.union_id = nil
  43381. }
  43382. // SetSessionKey sets the "session_key" field.
  43383. func (m *WxCardUserMutation) SetSessionKey(s string) {
  43384. m.session_key = &s
  43385. }
  43386. // SessionKey returns the value of the "session_key" field in the mutation.
  43387. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  43388. v := m.session_key
  43389. if v == nil {
  43390. return
  43391. }
  43392. return *v, true
  43393. }
  43394. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  43395. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43396. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43397. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  43398. if !m.op.Is(OpUpdateOne) {
  43399. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  43400. }
  43401. if m.id == nil || m.oldValue == nil {
  43402. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  43403. }
  43404. oldValue, err := m.oldValue(ctx)
  43405. if err != nil {
  43406. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  43407. }
  43408. return oldValue.SessionKey, nil
  43409. }
  43410. // ResetSessionKey resets all changes to the "session_key" field.
  43411. func (m *WxCardUserMutation) ResetSessionKey() {
  43412. m.session_key = nil
  43413. }
  43414. // SetIsVip sets the "is_vip" field.
  43415. func (m *WxCardUserMutation) SetIsVip(i int) {
  43416. m.is_vip = &i
  43417. m.addis_vip = nil
  43418. }
  43419. // IsVip returns the value of the "is_vip" field in the mutation.
  43420. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  43421. v := m.is_vip
  43422. if v == nil {
  43423. return
  43424. }
  43425. return *v, true
  43426. }
  43427. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  43428. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43429. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43430. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  43431. if !m.op.Is(OpUpdateOne) {
  43432. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  43433. }
  43434. if m.id == nil || m.oldValue == nil {
  43435. return v, errors.New("OldIsVip requires an ID field in the mutation")
  43436. }
  43437. oldValue, err := m.oldValue(ctx)
  43438. if err != nil {
  43439. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  43440. }
  43441. return oldValue.IsVip, nil
  43442. }
  43443. // AddIsVip adds i to the "is_vip" field.
  43444. func (m *WxCardUserMutation) AddIsVip(i int) {
  43445. if m.addis_vip != nil {
  43446. *m.addis_vip += i
  43447. } else {
  43448. m.addis_vip = &i
  43449. }
  43450. }
  43451. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  43452. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  43453. v := m.addis_vip
  43454. if v == nil {
  43455. return
  43456. }
  43457. return *v, true
  43458. }
  43459. // ResetIsVip resets all changes to the "is_vip" field.
  43460. func (m *WxCardUserMutation) ResetIsVip() {
  43461. m.is_vip = nil
  43462. m.addis_vip = nil
  43463. }
  43464. // Where appends a list predicates to the WxCardUserMutation builder.
  43465. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  43466. m.predicates = append(m.predicates, ps...)
  43467. }
  43468. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  43469. // users can use type-assertion to append predicates that do not depend on any generated package.
  43470. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  43471. p := make([]predicate.WxCardUser, len(ps))
  43472. for i := range ps {
  43473. p[i] = ps[i]
  43474. }
  43475. m.Where(p...)
  43476. }
  43477. // Op returns the operation name.
  43478. func (m *WxCardUserMutation) Op() Op {
  43479. return m.op
  43480. }
  43481. // SetOp allows setting the mutation operation.
  43482. func (m *WxCardUserMutation) SetOp(op Op) {
  43483. m.op = op
  43484. }
  43485. // Type returns the node type of this mutation (WxCardUser).
  43486. func (m *WxCardUserMutation) Type() string {
  43487. return m.typ
  43488. }
  43489. // Fields returns all fields that were changed during this mutation. Note that in
  43490. // order to get all numeric fields that were incremented/decremented, call
  43491. // AddedFields().
  43492. func (m *WxCardUserMutation) Fields() []string {
  43493. fields := make([]string, 0, 13)
  43494. if m.created_at != nil {
  43495. fields = append(fields, wxcarduser.FieldCreatedAt)
  43496. }
  43497. if m.updated_at != nil {
  43498. fields = append(fields, wxcarduser.FieldUpdatedAt)
  43499. }
  43500. if m.deleted_at != nil {
  43501. fields = append(fields, wxcarduser.FieldDeletedAt)
  43502. }
  43503. if m.wxid != nil {
  43504. fields = append(fields, wxcarduser.FieldWxid)
  43505. }
  43506. if m.account != nil {
  43507. fields = append(fields, wxcarduser.FieldAccount)
  43508. }
  43509. if m.avatar != nil {
  43510. fields = append(fields, wxcarduser.FieldAvatar)
  43511. }
  43512. if m.nickname != nil {
  43513. fields = append(fields, wxcarduser.FieldNickname)
  43514. }
  43515. if m.remark != nil {
  43516. fields = append(fields, wxcarduser.FieldRemark)
  43517. }
  43518. if m.phone != nil {
  43519. fields = append(fields, wxcarduser.FieldPhone)
  43520. }
  43521. if m.open_id != nil {
  43522. fields = append(fields, wxcarduser.FieldOpenID)
  43523. }
  43524. if m.union_id != nil {
  43525. fields = append(fields, wxcarduser.FieldUnionID)
  43526. }
  43527. if m.session_key != nil {
  43528. fields = append(fields, wxcarduser.FieldSessionKey)
  43529. }
  43530. if m.is_vip != nil {
  43531. fields = append(fields, wxcarduser.FieldIsVip)
  43532. }
  43533. return fields
  43534. }
  43535. // Field returns the value of a field with the given name. The second boolean
  43536. // return value indicates that this field was not set, or was not defined in the
  43537. // schema.
  43538. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  43539. switch name {
  43540. case wxcarduser.FieldCreatedAt:
  43541. return m.CreatedAt()
  43542. case wxcarduser.FieldUpdatedAt:
  43543. return m.UpdatedAt()
  43544. case wxcarduser.FieldDeletedAt:
  43545. return m.DeletedAt()
  43546. case wxcarduser.FieldWxid:
  43547. return m.Wxid()
  43548. case wxcarduser.FieldAccount:
  43549. return m.Account()
  43550. case wxcarduser.FieldAvatar:
  43551. return m.Avatar()
  43552. case wxcarduser.FieldNickname:
  43553. return m.Nickname()
  43554. case wxcarduser.FieldRemark:
  43555. return m.Remark()
  43556. case wxcarduser.FieldPhone:
  43557. return m.Phone()
  43558. case wxcarduser.FieldOpenID:
  43559. return m.OpenID()
  43560. case wxcarduser.FieldUnionID:
  43561. return m.UnionID()
  43562. case wxcarduser.FieldSessionKey:
  43563. return m.SessionKey()
  43564. case wxcarduser.FieldIsVip:
  43565. return m.IsVip()
  43566. }
  43567. return nil, false
  43568. }
  43569. // OldField returns the old value of the field from the database. An error is
  43570. // returned if the mutation operation is not UpdateOne, or the query to the
  43571. // database failed.
  43572. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  43573. switch name {
  43574. case wxcarduser.FieldCreatedAt:
  43575. return m.OldCreatedAt(ctx)
  43576. case wxcarduser.FieldUpdatedAt:
  43577. return m.OldUpdatedAt(ctx)
  43578. case wxcarduser.FieldDeletedAt:
  43579. return m.OldDeletedAt(ctx)
  43580. case wxcarduser.FieldWxid:
  43581. return m.OldWxid(ctx)
  43582. case wxcarduser.FieldAccount:
  43583. return m.OldAccount(ctx)
  43584. case wxcarduser.FieldAvatar:
  43585. return m.OldAvatar(ctx)
  43586. case wxcarduser.FieldNickname:
  43587. return m.OldNickname(ctx)
  43588. case wxcarduser.FieldRemark:
  43589. return m.OldRemark(ctx)
  43590. case wxcarduser.FieldPhone:
  43591. return m.OldPhone(ctx)
  43592. case wxcarduser.FieldOpenID:
  43593. return m.OldOpenID(ctx)
  43594. case wxcarduser.FieldUnionID:
  43595. return m.OldUnionID(ctx)
  43596. case wxcarduser.FieldSessionKey:
  43597. return m.OldSessionKey(ctx)
  43598. case wxcarduser.FieldIsVip:
  43599. return m.OldIsVip(ctx)
  43600. }
  43601. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  43602. }
  43603. // SetField sets the value of a field with the given name. It returns an error if
  43604. // the field is not defined in the schema, or if the type mismatched the field
  43605. // type.
  43606. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  43607. switch name {
  43608. case wxcarduser.FieldCreatedAt:
  43609. v, ok := value.(time.Time)
  43610. if !ok {
  43611. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43612. }
  43613. m.SetCreatedAt(v)
  43614. return nil
  43615. case wxcarduser.FieldUpdatedAt:
  43616. v, ok := value.(time.Time)
  43617. if !ok {
  43618. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43619. }
  43620. m.SetUpdatedAt(v)
  43621. return nil
  43622. case wxcarduser.FieldDeletedAt:
  43623. v, ok := value.(time.Time)
  43624. if !ok {
  43625. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43626. }
  43627. m.SetDeletedAt(v)
  43628. return nil
  43629. case wxcarduser.FieldWxid:
  43630. v, ok := value.(string)
  43631. if !ok {
  43632. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43633. }
  43634. m.SetWxid(v)
  43635. return nil
  43636. case wxcarduser.FieldAccount:
  43637. v, ok := value.(string)
  43638. if !ok {
  43639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43640. }
  43641. m.SetAccount(v)
  43642. return nil
  43643. case wxcarduser.FieldAvatar:
  43644. v, ok := value.(string)
  43645. if !ok {
  43646. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43647. }
  43648. m.SetAvatar(v)
  43649. return nil
  43650. case wxcarduser.FieldNickname:
  43651. v, ok := value.(string)
  43652. if !ok {
  43653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43654. }
  43655. m.SetNickname(v)
  43656. return nil
  43657. case wxcarduser.FieldRemark:
  43658. v, ok := value.(string)
  43659. if !ok {
  43660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43661. }
  43662. m.SetRemark(v)
  43663. return nil
  43664. case wxcarduser.FieldPhone:
  43665. v, ok := value.(string)
  43666. if !ok {
  43667. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43668. }
  43669. m.SetPhone(v)
  43670. return nil
  43671. case wxcarduser.FieldOpenID:
  43672. v, ok := value.(string)
  43673. if !ok {
  43674. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43675. }
  43676. m.SetOpenID(v)
  43677. return nil
  43678. case wxcarduser.FieldUnionID:
  43679. v, ok := value.(string)
  43680. if !ok {
  43681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43682. }
  43683. m.SetUnionID(v)
  43684. return nil
  43685. case wxcarduser.FieldSessionKey:
  43686. v, ok := value.(string)
  43687. if !ok {
  43688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43689. }
  43690. m.SetSessionKey(v)
  43691. return nil
  43692. case wxcarduser.FieldIsVip:
  43693. v, ok := value.(int)
  43694. if !ok {
  43695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43696. }
  43697. m.SetIsVip(v)
  43698. return nil
  43699. }
  43700. return fmt.Errorf("unknown WxCardUser field %s", name)
  43701. }
  43702. // AddedFields returns all numeric fields that were incremented/decremented during
  43703. // this mutation.
  43704. func (m *WxCardUserMutation) AddedFields() []string {
  43705. var fields []string
  43706. if m.addis_vip != nil {
  43707. fields = append(fields, wxcarduser.FieldIsVip)
  43708. }
  43709. return fields
  43710. }
  43711. // AddedField returns the numeric value that was incremented/decremented on a field
  43712. // with the given name. The second boolean return value indicates that this field
  43713. // was not set, or was not defined in the schema.
  43714. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  43715. switch name {
  43716. case wxcarduser.FieldIsVip:
  43717. return m.AddedIsVip()
  43718. }
  43719. return nil, false
  43720. }
  43721. // AddField adds the value to the field with the given name. It returns an error if
  43722. // the field is not defined in the schema, or if the type mismatched the field
  43723. // type.
  43724. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  43725. switch name {
  43726. case wxcarduser.FieldIsVip:
  43727. v, ok := value.(int)
  43728. if !ok {
  43729. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43730. }
  43731. m.AddIsVip(v)
  43732. return nil
  43733. }
  43734. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  43735. }
  43736. // ClearedFields returns all nullable fields that were cleared during this
  43737. // mutation.
  43738. func (m *WxCardUserMutation) ClearedFields() []string {
  43739. var fields []string
  43740. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  43741. fields = append(fields, wxcarduser.FieldDeletedAt)
  43742. }
  43743. return fields
  43744. }
  43745. // FieldCleared returns a boolean indicating if a field with the given name was
  43746. // cleared in this mutation.
  43747. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  43748. _, ok := m.clearedFields[name]
  43749. return ok
  43750. }
  43751. // ClearField clears the value of the field with the given name. It returns an
  43752. // error if the field is not defined in the schema.
  43753. func (m *WxCardUserMutation) ClearField(name string) error {
  43754. switch name {
  43755. case wxcarduser.FieldDeletedAt:
  43756. m.ClearDeletedAt()
  43757. return nil
  43758. }
  43759. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  43760. }
  43761. // ResetField resets all changes in the mutation for the field with the given name.
  43762. // It returns an error if the field is not defined in the schema.
  43763. func (m *WxCardUserMutation) ResetField(name string) error {
  43764. switch name {
  43765. case wxcarduser.FieldCreatedAt:
  43766. m.ResetCreatedAt()
  43767. return nil
  43768. case wxcarduser.FieldUpdatedAt:
  43769. m.ResetUpdatedAt()
  43770. return nil
  43771. case wxcarduser.FieldDeletedAt:
  43772. m.ResetDeletedAt()
  43773. return nil
  43774. case wxcarduser.FieldWxid:
  43775. m.ResetWxid()
  43776. return nil
  43777. case wxcarduser.FieldAccount:
  43778. m.ResetAccount()
  43779. return nil
  43780. case wxcarduser.FieldAvatar:
  43781. m.ResetAvatar()
  43782. return nil
  43783. case wxcarduser.FieldNickname:
  43784. m.ResetNickname()
  43785. return nil
  43786. case wxcarduser.FieldRemark:
  43787. m.ResetRemark()
  43788. return nil
  43789. case wxcarduser.FieldPhone:
  43790. m.ResetPhone()
  43791. return nil
  43792. case wxcarduser.FieldOpenID:
  43793. m.ResetOpenID()
  43794. return nil
  43795. case wxcarduser.FieldUnionID:
  43796. m.ResetUnionID()
  43797. return nil
  43798. case wxcarduser.FieldSessionKey:
  43799. m.ResetSessionKey()
  43800. return nil
  43801. case wxcarduser.FieldIsVip:
  43802. m.ResetIsVip()
  43803. return nil
  43804. }
  43805. return fmt.Errorf("unknown WxCardUser field %s", name)
  43806. }
  43807. // AddedEdges returns all edge names that were set/added in this mutation.
  43808. func (m *WxCardUserMutation) AddedEdges() []string {
  43809. edges := make([]string, 0, 0)
  43810. return edges
  43811. }
  43812. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  43813. // name in this mutation.
  43814. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  43815. return nil
  43816. }
  43817. // RemovedEdges returns all edge names that were removed in this mutation.
  43818. func (m *WxCardUserMutation) RemovedEdges() []string {
  43819. edges := make([]string, 0, 0)
  43820. return edges
  43821. }
  43822. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  43823. // the given name in this mutation.
  43824. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  43825. return nil
  43826. }
  43827. // ClearedEdges returns all edge names that were cleared in this mutation.
  43828. func (m *WxCardUserMutation) ClearedEdges() []string {
  43829. edges := make([]string, 0, 0)
  43830. return edges
  43831. }
  43832. // EdgeCleared returns a boolean which indicates if the edge with the given name
  43833. // was cleared in this mutation.
  43834. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  43835. return false
  43836. }
  43837. // ClearEdge clears the value of the edge with the given name. It returns an error
  43838. // if that edge is not defined in the schema.
  43839. func (m *WxCardUserMutation) ClearEdge(name string) error {
  43840. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  43841. }
  43842. // ResetEdge resets all changes to the edge with the given name in this mutation.
  43843. // It returns an error if the edge is not defined in the schema.
  43844. func (m *WxCardUserMutation) ResetEdge(name string) error {
  43845. return fmt.Errorf("unknown WxCardUser edge %s", name)
  43846. }
  43847. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  43848. type WxCardVisitMutation struct {
  43849. config
  43850. op Op
  43851. typ string
  43852. id *uint64
  43853. created_at *time.Time
  43854. updated_at *time.Time
  43855. deleted_at *time.Time
  43856. user_id *uint64
  43857. adduser_id *int64
  43858. bot_id *uint64
  43859. addbot_id *int64
  43860. bot_type *uint8
  43861. addbot_type *int8
  43862. clearedFields map[string]struct{}
  43863. done bool
  43864. oldValue func(context.Context) (*WxCardVisit, error)
  43865. predicates []predicate.WxCardVisit
  43866. }
  43867. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  43868. // wxcardvisitOption allows management of the mutation configuration using functional options.
  43869. type wxcardvisitOption func(*WxCardVisitMutation)
  43870. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  43871. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  43872. m := &WxCardVisitMutation{
  43873. config: c,
  43874. op: op,
  43875. typ: TypeWxCardVisit,
  43876. clearedFields: make(map[string]struct{}),
  43877. }
  43878. for _, opt := range opts {
  43879. opt(m)
  43880. }
  43881. return m
  43882. }
  43883. // withWxCardVisitID sets the ID field of the mutation.
  43884. func withWxCardVisitID(id uint64) wxcardvisitOption {
  43885. return func(m *WxCardVisitMutation) {
  43886. var (
  43887. err error
  43888. once sync.Once
  43889. value *WxCardVisit
  43890. )
  43891. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  43892. once.Do(func() {
  43893. if m.done {
  43894. err = errors.New("querying old values post mutation is not allowed")
  43895. } else {
  43896. value, err = m.Client().WxCardVisit.Get(ctx, id)
  43897. }
  43898. })
  43899. return value, err
  43900. }
  43901. m.id = &id
  43902. }
  43903. }
  43904. // withWxCardVisit sets the old WxCardVisit of the mutation.
  43905. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  43906. return func(m *WxCardVisitMutation) {
  43907. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  43908. return node, nil
  43909. }
  43910. m.id = &node.ID
  43911. }
  43912. }
  43913. // Client returns a new `ent.Client` from the mutation. If the mutation was
  43914. // executed in a transaction (ent.Tx), a transactional client is returned.
  43915. func (m WxCardVisitMutation) Client() *Client {
  43916. client := &Client{config: m.config}
  43917. client.init()
  43918. return client
  43919. }
  43920. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  43921. // it returns an error otherwise.
  43922. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  43923. if _, ok := m.driver.(*txDriver); !ok {
  43924. return nil, errors.New("ent: mutation is not running in a transaction")
  43925. }
  43926. tx := &Tx{config: m.config}
  43927. tx.init()
  43928. return tx, nil
  43929. }
  43930. // SetID sets the value of the id field. Note that this
  43931. // operation is only accepted on creation of WxCardVisit entities.
  43932. func (m *WxCardVisitMutation) SetID(id uint64) {
  43933. m.id = &id
  43934. }
  43935. // ID returns the ID value in the mutation. Note that the ID is only available
  43936. // if it was provided to the builder or after it was returned from the database.
  43937. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  43938. if m.id == nil {
  43939. return
  43940. }
  43941. return *m.id, true
  43942. }
  43943. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  43944. // That means, if the mutation is applied within a transaction with an isolation level such
  43945. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  43946. // or updated by the mutation.
  43947. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  43948. switch {
  43949. case m.op.Is(OpUpdateOne | OpDeleteOne):
  43950. id, exists := m.ID()
  43951. if exists {
  43952. return []uint64{id}, nil
  43953. }
  43954. fallthrough
  43955. case m.op.Is(OpUpdate | OpDelete):
  43956. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  43957. default:
  43958. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  43959. }
  43960. }
  43961. // SetCreatedAt sets the "created_at" field.
  43962. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  43963. m.created_at = &t
  43964. }
  43965. // CreatedAt returns the value of the "created_at" field in the mutation.
  43966. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  43967. v := m.created_at
  43968. if v == nil {
  43969. return
  43970. }
  43971. return *v, true
  43972. }
  43973. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  43974. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  43975. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43976. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  43977. if !m.op.Is(OpUpdateOne) {
  43978. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  43979. }
  43980. if m.id == nil || m.oldValue == nil {
  43981. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  43982. }
  43983. oldValue, err := m.oldValue(ctx)
  43984. if err != nil {
  43985. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  43986. }
  43987. return oldValue.CreatedAt, nil
  43988. }
  43989. // ResetCreatedAt resets all changes to the "created_at" field.
  43990. func (m *WxCardVisitMutation) ResetCreatedAt() {
  43991. m.created_at = nil
  43992. }
  43993. // SetUpdatedAt sets the "updated_at" field.
  43994. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  43995. m.updated_at = &t
  43996. }
  43997. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  43998. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  43999. v := m.updated_at
  44000. if v == nil {
  44001. return
  44002. }
  44003. return *v, true
  44004. }
  44005. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  44006. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  44007. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44008. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  44009. if !m.op.Is(OpUpdateOne) {
  44010. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  44011. }
  44012. if m.id == nil || m.oldValue == nil {
  44013. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  44014. }
  44015. oldValue, err := m.oldValue(ctx)
  44016. if err != nil {
  44017. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  44018. }
  44019. return oldValue.UpdatedAt, nil
  44020. }
  44021. // ResetUpdatedAt resets all changes to the "updated_at" field.
  44022. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  44023. m.updated_at = nil
  44024. }
  44025. // SetDeletedAt sets the "deleted_at" field.
  44026. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  44027. m.deleted_at = &t
  44028. }
  44029. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  44030. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  44031. v := m.deleted_at
  44032. if v == nil {
  44033. return
  44034. }
  44035. return *v, true
  44036. }
  44037. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  44038. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  44039. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44040. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  44041. if !m.op.Is(OpUpdateOne) {
  44042. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  44043. }
  44044. if m.id == nil || m.oldValue == nil {
  44045. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  44046. }
  44047. oldValue, err := m.oldValue(ctx)
  44048. if err != nil {
  44049. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  44050. }
  44051. return oldValue.DeletedAt, nil
  44052. }
  44053. // ClearDeletedAt clears the value of the "deleted_at" field.
  44054. func (m *WxCardVisitMutation) ClearDeletedAt() {
  44055. m.deleted_at = nil
  44056. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  44057. }
  44058. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  44059. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  44060. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  44061. return ok
  44062. }
  44063. // ResetDeletedAt resets all changes to the "deleted_at" field.
  44064. func (m *WxCardVisitMutation) ResetDeletedAt() {
  44065. m.deleted_at = nil
  44066. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  44067. }
  44068. // SetUserID sets the "user_id" field.
  44069. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  44070. m.user_id = &u
  44071. m.adduser_id = nil
  44072. }
  44073. // UserID returns the value of the "user_id" field in the mutation.
  44074. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  44075. v := m.user_id
  44076. if v == nil {
  44077. return
  44078. }
  44079. return *v, true
  44080. }
  44081. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  44082. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  44083. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44084. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  44085. if !m.op.Is(OpUpdateOne) {
  44086. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  44087. }
  44088. if m.id == nil || m.oldValue == nil {
  44089. return v, errors.New("OldUserID requires an ID field in the mutation")
  44090. }
  44091. oldValue, err := m.oldValue(ctx)
  44092. if err != nil {
  44093. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  44094. }
  44095. return oldValue.UserID, nil
  44096. }
  44097. // AddUserID adds u to the "user_id" field.
  44098. func (m *WxCardVisitMutation) AddUserID(u int64) {
  44099. if m.adduser_id != nil {
  44100. *m.adduser_id += u
  44101. } else {
  44102. m.adduser_id = &u
  44103. }
  44104. }
  44105. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  44106. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  44107. v := m.adduser_id
  44108. if v == nil {
  44109. return
  44110. }
  44111. return *v, true
  44112. }
  44113. // ClearUserID clears the value of the "user_id" field.
  44114. func (m *WxCardVisitMutation) ClearUserID() {
  44115. m.user_id = nil
  44116. m.adduser_id = nil
  44117. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  44118. }
  44119. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  44120. func (m *WxCardVisitMutation) UserIDCleared() bool {
  44121. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  44122. return ok
  44123. }
  44124. // ResetUserID resets all changes to the "user_id" field.
  44125. func (m *WxCardVisitMutation) ResetUserID() {
  44126. m.user_id = nil
  44127. m.adduser_id = nil
  44128. delete(m.clearedFields, wxcardvisit.FieldUserID)
  44129. }
  44130. // SetBotID sets the "bot_id" field.
  44131. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  44132. m.bot_id = &u
  44133. m.addbot_id = nil
  44134. }
  44135. // BotID returns the value of the "bot_id" field in the mutation.
  44136. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  44137. v := m.bot_id
  44138. if v == nil {
  44139. return
  44140. }
  44141. return *v, true
  44142. }
  44143. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  44144. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  44145. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44146. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  44147. if !m.op.Is(OpUpdateOne) {
  44148. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  44149. }
  44150. if m.id == nil || m.oldValue == nil {
  44151. return v, errors.New("OldBotID requires an ID field in the mutation")
  44152. }
  44153. oldValue, err := m.oldValue(ctx)
  44154. if err != nil {
  44155. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  44156. }
  44157. return oldValue.BotID, nil
  44158. }
  44159. // AddBotID adds u to the "bot_id" field.
  44160. func (m *WxCardVisitMutation) AddBotID(u int64) {
  44161. if m.addbot_id != nil {
  44162. *m.addbot_id += u
  44163. } else {
  44164. m.addbot_id = &u
  44165. }
  44166. }
  44167. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  44168. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  44169. v := m.addbot_id
  44170. if v == nil {
  44171. return
  44172. }
  44173. return *v, true
  44174. }
  44175. // ResetBotID resets all changes to the "bot_id" field.
  44176. func (m *WxCardVisitMutation) ResetBotID() {
  44177. m.bot_id = nil
  44178. m.addbot_id = nil
  44179. }
  44180. // SetBotType sets the "bot_type" field.
  44181. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  44182. m.bot_type = &u
  44183. m.addbot_type = nil
  44184. }
  44185. // BotType returns the value of the "bot_type" field in the mutation.
  44186. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  44187. v := m.bot_type
  44188. if v == nil {
  44189. return
  44190. }
  44191. return *v, true
  44192. }
  44193. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  44194. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  44195. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44196. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  44197. if !m.op.Is(OpUpdateOne) {
  44198. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  44199. }
  44200. if m.id == nil || m.oldValue == nil {
  44201. return v, errors.New("OldBotType requires an ID field in the mutation")
  44202. }
  44203. oldValue, err := m.oldValue(ctx)
  44204. if err != nil {
  44205. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  44206. }
  44207. return oldValue.BotType, nil
  44208. }
  44209. // AddBotType adds u to the "bot_type" field.
  44210. func (m *WxCardVisitMutation) AddBotType(u int8) {
  44211. if m.addbot_type != nil {
  44212. *m.addbot_type += u
  44213. } else {
  44214. m.addbot_type = &u
  44215. }
  44216. }
  44217. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  44218. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  44219. v := m.addbot_type
  44220. if v == nil {
  44221. return
  44222. }
  44223. return *v, true
  44224. }
  44225. // ResetBotType resets all changes to the "bot_type" field.
  44226. func (m *WxCardVisitMutation) ResetBotType() {
  44227. m.bot_type = nil
  44228. m.addbot_type = nil
  44229. }
  44230. // Where appends a list predicates to the WxCardVisitMutation builder.
  44231. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  44232. m.predicates = append(m.predicates, ps...)
  44233. }
  44234. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  44235. // users can use type-assertion to append predicates that do not depend on any generated package.
  44236. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  44237. p := make([]predicate.WxCardVisit, len(ps))
  44238. for i := range ps {
  44239. p[i] = ps[i]
  44240. }
  44241. m.Where(p...)
  44242. }
  44243. // Op returns the operation name.
  44244. func (m *WxCardVisitMutation) Op() Op {
  44245. return m.op
  44246. }
  44247. // SetOp allows setting the mutation operation.
  44248. func (m *WxCardVisitMutation) SetOp(op Op) {
  44249. m.op = op
  44250. }
  44251. // Type returns the node type of this mutation (WxCardVisit).
  44252. func (m *WxCardVisitMutation) Type() string {
  44253. return m.typ
  44254. }
  44255. // Fields returns all fields that were changed during this mutation. Note that in
  44256. // order to get all numeric fields that were incremented/decremented, call
  44257. // AddedFields().
  44258. func (m *WxCardVisitMutation) Fields() []string {
  44259. fields := make([]string, 0, 6)
  44260. if m.created_at != nil {
  44261. fields = append(fields, wxcardvisit.FieldCreatedAt)
  44262. }
  44263. if m.updated_at != nil {
  44264. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  44265. }
  44266. if m.deleted_at != nil {
  44267. fields = append(fields, wxcardvisit.FieldDeletedAt)
  44268. }
  44269. if m.user_id != nil {
  44270. fields = append(fields, wxcardvisit.FieldUserID)
  44271. }
  44272. if m.bot_id != nil {
  44273. fields = append(fields, wxcardvisit.FieldBotID)
  44274. }
  44275. if m.bot_type != nil {
  44276. fields = append(fields, wxcardvisit.FieldBotType)
  44277. }
  44278. return fields
  44279. }
  44280. // Field returns the value of a field with the given name. The second boolean
  44281. // return value indicates that this field was not set, or was not defined in the
  44282. // schema.
  44283. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  44284. switch name {
  44285. case wxcardvisit.FieldCreatedAt:
  44286. return m.CreatedAt()
  44287. case wxcardvisit.FieldUpdatedAt:
  44288. return m.UpdatedAt()
  44289. case wxcardvisit.FieldDeletedAt:
  44290. return m.DeletedAt()
  44291. case wxcardvisit.FieldUserID:
  44292. return m.UserID()
  44293. case wxcardvisit.FieldBotID:
  44294. return m.BotID()
  44295. case wxcardvisit.FieldBotType:
  44296. return m.BotType()
  44297. }
  44298. return nil, false
  44299. }
  44300. // OldField returns the old value of the field from the database. An error is
  44301. // returned if the mutation operation is not UpdateOne, or the query to the
  44302. // database failed.
  44303. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  44304. switch name {
  44305. case wxcardvisit.FieldCreatedAt:
  44306. return m.OldCreatedAt(ctx)
  44307. case wxcardvisit.FieldUpdatedAt:
  44308. return m.OldUpdatedAt(ctx)
  44309. case wxcardvisit.FieldDeletedAt:
  44310. return m.OldDeletedAt(ctx)
  44311. case wxcardvisit.FieldUserID:
  44312. return m.OldUserID(ctx)
  44313. case wxcardvisit.FieldBotID:
  44314. return m.OldBotID(ctx)
  44315. case wxcardvisit.FieldBotType:
  44316. return m.OldBotType(ctx)
  44317. }
  44318. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  44319. }
  44320. // SetField sets the value of a field with the given name. It returns an error if
  44321. // the field is not defined in the schema, or if the type mismatched the field
  44322. // type.
  44323. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  44324. switch name {
  44325. case wxcardvisit.FieldCreatedAt:
  44326. v, ok := value.(time.Time)
  44327. if !ok {
  44328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44329. }
  44330. m.SetCreatedAt(v)
  44331. return nil
  44332. case wxcardvisit.FieldUpdatedAt:
  44333. v, ok := value.(time.Time)
  44334. if !ok {
  44335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44336. }
  44337. m.SetUpdatedAt(v)
  44338. return nil
  44339. case wxcardvisit.FieldDeletedAt:
  44340. v, ok := value.(time.Time)
  44341. if !ok {
  44342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44343. }
  44344. m.SetDeletedAt(v)
  44345. return nil
  44346. case wxcardvisit.FieldUserID:
  44347. v, ok := value.(uint64)
  44348. if !ok {
  44349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44350. }
  44351. m.SetUserID(v)
  44352. return nil
  44353. case wxcardvisit.FieldBotID:
  44354. v, ok := value.(uint64)
  44355. if !ok {
  44356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44357. }
  44358. m.SetBotID(v)
  44359. return nil
  44360. case wxcardvisit.FieldBotType:
  44361. v, ok := value.(uint8)
  44362. if !ok {
  44363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44364. }
  44365. m.SetBotType(v)
  44366. return nil
  44367. }
  44368. return fmt.Errorf("unknown WxCardVisit field %s", name)
  44369. }
  44370. // AddedFields returns all numeric fields that were incremented/decremented during
  44371. // this mutation.
  44372. func (m *WxCardVisitMutation) AddedFields() []string {
  44373. var fields []string
  44374. if m.adduser_id != nil {
  44375. fields = append(fields, wxcardvisit.FieldUserID)
  44376. }
  44377. if m.addbot_id != nil {
  44378. fields = append(fields, wxcardvisit.FieldBotID)
  44379. }
  44380. if m.addbot_type != nil {
  44381. fields = append(fields, wxcardvisit.FieldBotType)
  44382. }
  44383. return fields
  44384. }
  44385. // AddedField returns the numeric value that was incremented/decremented on a field
  44386. // with the given name. The second boolean return value indicates that this field
  44387. // was not set, or was not defined in the schema.
  44388. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  44389. switch name {
  44390. case wxcardvisit.FieldUserID:
  44391. return m.AddedUserID()
  44392. case wxcardvisit.FieldBotID:
  44393. return m.AddedBotID()
  44394. case wxcardvisit.FieldBotType:
  44395. return m.AddedBotType()
  44396. }
  44397. return nil, false
  44398. }
  44399. // AddField adds the value to the field with the given name. It returns an error if
  44400. // the field is not defined in the schema, or if the type mismatched the field
  44401. // type.
  44402. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  44403. switch name {
  44404. case wxcardvisit.FieldUserID:
  44405. v, ok := value.(int64)
  44406. if !ok {
  44407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44408. }
  44409. m.AddUserID(v)
  44410. return nil
  44411. case wxcardvisit.FieldBotID:
  44412. v, ok := value.(int64)
  44413. if !ok {
  44414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44415. }
  44416. m.AddBotID(v)
  44417. return nil
  44418. case wxcardvisit.FieldBotType:
  44419. v, ok := value.(int8)
  44420. if !ok {
  44421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44422. }
  44423. m.AddBotType(v)
  44424. return nil
  44425. }
  44426. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  44427. }
  44428. // ClearedFields returns all nullable fields that were cleared during this
  44429. // mutation.
  44430. func (m *WxCardVisitMutation) ClearedFields() []string {
  44431. var fields []string
  44432. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  44433. fields = append(fields, wxcardvisit.FieldDeletedAt)
  44434. }
  44435. if m.FieldCleared(wxcardvisit.FieldUserID) {
  44436. fields = append(fields, wxcardvisit.FieldUserID)
  44437. }
  44438. return fields
  44439. }
  44440. // FieldCleared returns a boolean indicating if a field with the given name was
  44441. // cleared in this mutation.
  44442. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  44443. _, ok := m.clearedFields[name]
  44444. return ok
  44445. }
  44446. // ClearField clears the value of the field with the given name. It returns an
  44447. // error if the field is not defined in the schema.
  44448. func (m *WxCardVisitMutation) ClearField(name string) error {
  44449. switch name {
  44450. case wxcardvisit.FieldDeletedAt:
  44451. m.ClearDeletedAt()
  44452. return nil
  44453. case wxcardvisit.FieldUserID:
  44454. m.ClearUserID()
  44455. return nil
  44456. }
  44457. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  44458. }
  44459. // ResetField resets all changes in the mutation for the field with the given name.
  44460. // It returns an error if the field is not defined in the schema.
  44461. func (m *WxCardVisitMutation) ResetField(name string) error {
  44462. switch name {
  44463. case wxcardvisit.FieldCreatedAt:
  44464. m.ResetCreatedAt()
  44465. return nil
  44466. case wxcardvisit.FieldUpdatedAt:
  44467. m.ResetUpdatedAt()
  44468. return nil
  44469. case wxcardvisit.FieldDeletedAt:
  44470. m.ResetDeletedAt()
  44471. return nil
  44472. case wxcardvisit.FieldUserID:
  44473. m.ResetUserID()
  44474. return nil
  44475. case wxcardvisit.FieldBotID:
  44476. m.ResetBotID()
  44477. return nil
  44478. case wxcardvisit.FieldBotType:
  44479. m.ResetBotType()
  44480. return nil
  44481. }
  44482. return fmt.Errorf("unknown WxCardVisit field %s", name)
  44483. }
  44484. // AddedEdges returns all edge names that were set/added in this mutation.
  44485. func (m *WxCardVisitMutation) AddedEdges() []string {
  44486. edges := make([]string, 0, 0)
  44487. return edges
  44488. }
  44489. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  44490. // name in this mutation.
  44491. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  44492. return nil
  44493. }
  44494. // RemovedEdges returns all edge names that were removed in this mutation.
  44495. func (m *WxCardVisitMutation) RemovedEdges() []string {
  44496. edges := make([]string, 0, 0)
  44497. return edges
  44498. }
  44499. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  44500. // the given name in this mutation.
  44501. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  44502. return nil
  44503. }
  44504. // ClearedEdges returns all edge names that were cleared in this mutation.
  44505. func (m *WxCardVisitMutation) ClearedEdges() []string {
  44506. edges := make([]string, 0, 0)
  44507. return edges
  44508. }
  44509. // EdgeCleared returns a boolean which indicates if the edge with the given name
  44510. // was cleared in this mutation.
  44511. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  44512. return false
  44513. }
  44514. // ClearEdge clears the value of the edge with the given name. It returns an error
  44515. // if that edge is not defined in the schema.
  44516. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  44517. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  44518. }
  44519. // ResetEdge resets all changes to the edge with the given name in this mutation.
  44520. // It returns an error if the edge is not defined in the schema.
  44521. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  44522. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  44523. }
  44524. // XunjiMutation represents an operation that mutates the Xunji nodes in the graph.
  44525. type XunjiMutation struct {
  44526. config
  44527. op Op
  44528. typ string
  44529. id *uint64
  44530. created_at *time.Time
  44531. updated_at *time.Time
  44532. status *uint8
  44533. addstatus *int8
  44534. deleted_at *time.Time
  44535. app_key *string
  44536. app_secret *string
  44537. token *string
  44538. encoding_key *string
  44539. agent_id *uint64
  44540. addagent_id *int64
  44541. organization_id *uint64
  44542. addorganization_id *int64
  44543. wxid *string
  44544. api_base *string
  44545. api_key *string
  44546. clearedFields map[string]struct{}
  44547. done bool
  44548. oldValue func(context.Context) (*Xunji, error)
  44549. predicates []predicate.Xunji
  44550. }
  44551. var _ ent.Mutation = (*XunjiMutation)(nil)
  44552. // xunjiOption allows management of the mutation configuration using functional options.
  44553. type xunjiOption func(*XunjiMutation)
  44554. // newXunjiMutation creates new mutation for the Xunji entity.
  44555. func newXunjiMutation(c config, op Op, opts ...xunjiOption) *XunjiMutation {
  44556. m := &XunjiMutation{
  44557. config: c,
  44558. op: op,
  44559. typ: TypeXunji,
  44560. clearedFields: make(map[string]struct{}),
  44561. }
  44562. for _, opt := range opts {
  44563. opt(m)
  44564. }
  44565. return m
  44566. }
  44567. // withXunjiID sets the ID field of the mutation.
  44568. func withXunjiID(id uint64) xunjiOption {
  44569. return func(m *XunjiMutation) {
  44570. var (
  44571. err error
  44572. once sync.Once
  44573. value *Xunji
  44574. )
  44575. m.oldValue = func(ctx context.Context) (*Xunji, error) {
  44576. once.Do(func() {
  44577. if m.done {
  44578. err = errors.New("querying old values post mutation is not allowed")
  44579. } else {
  44580. value, err = m.Client().Xunji.Get(ctx, id)
  44581. }
  44582. })
  44583. return value, err
  44584. }
  44585. m.id = &id
  44586. }
  44587. }
  44588. // withXunji sets the old Xunji of the mutation.
  44589. func withXunji(node *Xunji) xunjiOption {
  44590. return func(m *XunjiMutation) {
  44591. m.oldValue = func(context.Context) (*Xunji, error) {
  44592. return node, nil
  44593. }
  44594. m.id = &node.ID
  44595. }
  44596. }
  44597. // Client returns a new `ent.Client` from the mutation. If the mutation was
  44598. // executed in a transaction (ent.Tx), a transactional client is returned.
  44599. func (m XunjiMutation) Client() *Client {
  44600. client := &Client{config: m.config}
  44601. client.init()
  44602. return client
  44603. }
  44604. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  44605. // it returns an error otherwise.
  44606. func (m XunjiMutation) Tx() (*Tx, error) {
  44607. if _, ok := m.driver.(*txDriver); !ok {
  44608. return nil, errors.New("ent: mutation is not running in a transaction")
  44609. }
  44610. tx := &Tx{config: m.config}
  44611. tx.init()
  44612. return tx, nil
  44613. }
  44614. // SetID sets the value of the id field. Note that this
  44615. // operation is only accepted on creation of Xunji entities.
  44616. func (m *XunjiMutation) SetID(id uint64) {
  44617. m.id = &id
  44618. }
  44619. // ID returns the ID value in the mutation. Note that the ID is only available
  44620. // if it was provided to the builder or after it was returned from the database.
  44621. func (m *XunjiMutation) ID() (id uint64, exists bool) {
  44622. if m.id == nil {
  44623. return
  44624. }
  44625. return *m.id, true
  44626. }
  44627. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  44628. // That means, if the mutation is applied within a transaction with an isolation level such
  44629. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  44630. // or updated by the mutation.
  44631. func (m *XunjiMutation) IDs(ctx context.Context) ([]uint64, error) {
  44632. switch {
  44633. case m.op.Is(OpUpdateOne | OpDeleteOne):
  44634. id, exists := m.ID()
  44635. if exists {
  44636. return []uint64{id}, nil
  44637. }
  44638. fallthrough
  44639. case m.op.Is(OpUpdate | OpDelete):
  44640. return m.Client().Xunji.Query().Where(m.predicates...).IDs(ctx)
  44641. default:
  44642. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  44643. }
  44644. }
  44645. // SetCreatedAt sets the "created_at" field.
  44646. func (m *XunjiMutation) SetCreatedAt(t time.Time) {
  44647. m.created_at = &t
  44648. }
  44649. // CreatedAt returns the value of the "created_at" field in the mutation.
  44650. func (m *XunjiMutation) CreatedAt() (r time.Time, exists bool) {
  44651. v := m.created_at
  44652. if v == nil {
  44653. return
  44654. }
  44655. return *v, true
  44656. }
  44657. // OldCreatedAt returns the old "created_at" field's value of the Xunji entity.
  44658. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  44659. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44660. func (m *XunjiMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  44661. if !m.op.Is(OpUpdateOne) {
  44662. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  44663. }
  44664. if m.id == nil || m.oldValue == nil {
  44665. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  44666. }
  44667. oldValue, err := m.oldValue(ctx)
  44668. if err != nil {
  44669. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  44670. }
  44671. return oldValue.CreatedAt, nil
  44672. }
  44673. // ResetCreatedAt resets all changes to the "created_at" field.
  44674. func (m *XunjiMutation) ResetCreatedAt() {
  44675. m.created_at = nil
  44676. }
  44677. // SetUpdatedAt sets the "updated_at" field.
  44678. func (m *XunjiMutation) SetUpdatedAt(t time.Time) {
  44679. m.updated_at = &t
  44680. }
  44681. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  44682. func (m *XunjiMutation) UpdatedAt() (r time.Time, exists bool) {
  44683. v := m.updated_at
  44684. if v == nil {
  44685. return
  44686. }
  44687. return *v, true
  44688. }
  44689. // OldUpdatedAt returns the old "updated_at" field's value of the Xunji entity.
  44690. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  44691. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44692. func (m *XunjiMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  44693. if !m.op.Is(OpUpdateOne) {
  44694. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  44695. }
  44696. if m.id == nil || m.oldValue == nil {
  44697. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  44698. }
  44699. oldValue, err := m.oldValue(ctx)
  44700. if err != nil {
  44701. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  44702. }
  44703. return oldValue.UpdatedAt, nil
  44704. }
  44705. // ResetUpdatedAt resets all changes to the "updated_at" field.
  44706. func (m *XunjiMutation) ResetUpdatedAt() {
  44707. m.updated_at = nil
  44708. }
  44709. // SetStatus sets the "status" field.
  44710. func (m *XunjiMutation) SetStatus(u uint8) {
  44711. m.status = &u
  44712. m.addstatus = nil
  44713. }
  44714. // Status returns the value of the "status" field in the mutation.
  44715. func (m *XunjiMutation) Status() (r uint8, exists bool) {
  44716. v := m.status
  44717. if v == nil {
  44718. return
  44719. }
  44720. return *v, true
  44721. }
  44722. // OldStatus returns the old "status" field's value of the Xunji entity.
  44723. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  44724. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44725. func (m *XunjiMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  44726. if !m.op.Is(OpUpdateOne) {
  44727. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  44728. }
  44729. if m.id == nil || m.oldValue == nil {
  44730. return v, errors.New("OldStatus requires an ID field in the mutation")
  44731. }
  44732. oldValue, err := m.oldValue(ctx)
  44733. if err != nil {
  44734. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  44735. }
  44736. return oldValue.Status, nil
  44737. }
  44738. // AddStatus adds u to the "status" field.
  44739. func (m *XunjiMutation) AddStatus(u int8) {
  44740. if m.addstatus != nil {
  44741. *m.addstatus += u
  44742. } else {
  44743. m.addstatus = &u
  44744. }
  44745. }
  44746. // AddedStatus returns the value that was added to the "status" field in this mutation.
  44747. func (m *XunjiMutation) AddedStatus() (r int8, exists bool) {
  44748. v := m.addstatus
  44749. if v == nil {
  44750. return
  44751. }
  44752. return *v, true
  44753. }
  44754. // ClearStatus clears the value of the "status" field.
  44755. func (m *XunjiMutation) ClearStatus() {
  44756. m.status = nil
  44757. m.addstatus = nil
  44758. m.clearedFields[xunji.FieldStatus] = struct{}{}
  44759. }
  44760. // StatusCleared returns if the "status" field was cleared in this mutation.
  44761. func (m *XunjiMutation) StatusCleared() bool {
  44762. _, ok := m.clearedFields[xunji.FieldStatus]
  44763. return ok
  44764. }
  44765. // ResetStatus resets all changes to the "status" field.
  44766. func (m *XunjiMutation) ResetStatus() {
  44767. m.status = nil
  44768. m.addstatus = nil
  44769. delete(m.clearedFields, xunji.FieldStatus)
  44770. }
  44771. // SetDeletedAt sets the "deleted_at" field.
  44772. func (m *XunjiMutation) SetDeletedAt(t time.Time) {
  44773. m.deleted_at = &t
  44774. }
  44775. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  44776. func (m *XunjiMutation) DeletedAt() (r time.Time, exists bool) {
  44777. v := m.deleted_at
  44778. if v == nil {
  44779. return
  44780. }
  44781. return *v, true
  44782. }
  44783. // OldDeletedAt returns the old "deleted_at" field's value of the Xunji entity.
  44784. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  44785. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44786. func (m *XunjiMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  44787. if !m.op.Is(OpUpdateOne) {
  44788. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  44789. }
  44790. if m.id == nil || m.oldValue == nil {
  44791. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  44792. }
  44793. oldValue, err := m.oldValue(ctx)
  44794. if err != nil {
  44795. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  44796. }
  44797. return oldValue.DeletedAt, nil
  44798. }
  44799. // ClearDeletedAt clears the value of the "deleted_at" field.
  44800. func (m *XunjiMutation) ClearDeletedAt() {
  44801. m.deleted_at = nil
  44802. m.clearedFields[xunji.FieldDeletedAt] = struct{}{}
  44803. }
  44804. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  44805. func (m *XunjiMutation) DeletedAtCleared() bool {
  44806. _, ok := m.clearedFields[xunji.FieldDeletedAt]
  44807. return ok
  44808. }
  44809. // ResetDeletedAt resets all changes to the "deleted_at" field.
  44810. func (m *XunjiMutation) ResetDeletedAt() {
  44811. m.deleted_at = nil
  44812. delete(m.clearedFields, xunji.FieldDeletedAt)
  44813. }
  44814. // SetAppKey sets the "app_key" field.
  44815. func (m *XunjiMutation) SetAppKey(s string) {
  44816. m.app_key = &s
  44817. }
  44818. // AppKey returns the value of the "app_key" field in the mutation.
  44819. func (m *XunjiMutation) AppKey() (r string, exists bool) {
  44820. v := m.app_key
  44821. if v == nil {
  44822. return
  44823. }
  44824. return *v, true
  44825. }
  44826. // OldAppKey returns the old "app_key" field's value of the Xunji entity.
  44827. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  44828. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44829. func (m *XunjiMutation) OldAppKey(ctx context.Context) (v string, err error) {
  44830. if !m.op.Is(OpUpdateOne) {
  44831. return v, errors.New("OldAppKey is only allowed on UpdateOne operations")
  44832. }
  44833. if m.id == nil || m.oldValue == nil {
  44834. return v, errors.New("OldAppKey requires an ID field in the mutation")
  44835. }
  44836. oldValue, err := m.oldValue(ctx)
  44837. if err != nil {
  44838. return v, fmt.Errorf("querying old value for OldAppKey: %w", err)
  44839. }
  44840. return oldValue.AppKey, nil
  44841. }
  44842. // ResetAppKey resets all changes to the "app_key" field.
  44843. func (m *XunjiMutation) ResetAppKey() {
  44844. m.app_key = nil
  44845. }
  44846. // SetAppSecret sets the "app_secret" field.
  44847. func (m *XunjiMutation) SetAppSecret(s string) {
  44848. m.app_secret = &s
  44849. }
  44850. // AppSecret returns the value of the "app_secret" field in the mutation.
  44851. func (m *XunjiMutation) AppSecret() (r string, exists bool) {
  44852. v := m.app_secret
  44853. if v == nil {
  44854. return
  44855. }
  44856. return *v, true
  44857. }
  44858. // OldAppSecret returns the old "app_secret" field's value of the Xunji entity.
  44859. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  44860. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44861. func (m *XunjiMutation) OldAppSecret(ctx context.Context) (v string, err error) {
  44862. if !m.op.Is(OpUpdateOne) {
  44863. return v, errors.New("OldAppSecret is only allowed on UpdateOne operations")
  44864. }
  44865. if m.id == nil || m.oldValue == nil {
  44866. return v, errors.New("OldAppSecret requires an ID field in the mutation")
  44867. }
  44868. oldValue, err := m.oldValue(ctx)
  44869. if err != nil {
  44870. return v, fmt.Errorf("querying old value for OldAppSecret: %w", err)
  44871. }
  44872. return oldValue.AppSecret, nil
  44873. }
  44874. // ResetAppSecret resets all changes to the "app_secret" field.
  44875. func (m *XunjiMutation) ResetAppSecret() {
  44876. m.app_secret = nil
  44877. }
  44878. // SetToken sets the "token" field.
  44879. func (m *XunjiMutation) SetToken(s string) {
  44880. m.token = &s
  44881. }
  44882. // Token returns the value of the "token" field in the mutation.
  44883. func (m *XunjiMutation) Token() (r string, exists bool) {
  44884. v := m.token
  44885. if v == nil {
  44886. return
  44887. }
  44888. return *v, true
  44889. }
  44890. // OldToken returns the old "token" field's value of the Xunji entity.
  44891. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  44892. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44893. func (m *XunjiMutation) OldToken(ctx context.Context) (v string, err error) {
  44894. if !m.op.Is(OpUpdateOne) {
  44895. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  44896. }
  44897. if m.id == nil || m.oldValue == nil {
  44898. return v, errors.New("OldToken requires an ID field in the mutation")
  44899. }
  44900. oldValue, err := m.oldValue(ctx)
  44901. if err != nil {
  44902. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  44903. }
  44904. return oldValue.Token, nil
  44905. }
  44906. // ResetToken resets all changes to the "token" field.
  44907. func (m *XunjiMutation) ResetToken() {
  44908. m.token = nil
  44909. }
  44910. // SetEncodingKey sets the "encoding_key" field.
  44911. func (m *XunjiMutation) SetEncodingKey(s string) {
  44912. m.encoding_key = &s
  44913. }
  44914. // EncodingKey returns the value of the "encoding_key" field in the mutation.
  44915. func (m *XunjiMutation) EncodingKey() (r string, exists bool) {
  44916. v := m.encoding_key
  44917. if v == nil {
  44918. return
  44919. }
  44920. return *v, true
  44921. }
  44922. // OldEncodingKey returns the old "encoding_key" field's value of the Xunji entity.
  44923. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  44924. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44925. func (m *XunjiMutation) OldEncodingKey(ctx context.Context) (v string, err error) {
  44926. if !m.op.Is(OpUpdateOne) {
  44927. return v, errors.New("OldEncodingKey is only allowed on UpdateOne operations")
  44928. }
  44929. if m.id == nil || m.oldValue == nil {
  44930. return v, errors.New("OldEncodingKey requires an ID field in the mutation")
  44931. }
  44932. oldValue, err := m.oldValue(ctx)
  44933. if err != nil {
  44934. return v, fmt.Errorf("querying old value for OldEncodingKey: %w", err)
  44935. }
  44936. return oldValue.EncodingKey, nil
  44937. }
  44938. // ResetEncodingKey resets all changes to the "encoding_key" field.
  44939. func (m *XunjiMutation) ResetEncodingKey() {
  44940. m.encoding_key = nil
  44941. }
  44942. // SetAgentID sets the "agent_id" field.
  44943. func (m *XunjiMutation) SetAgentID(u uint64) {
  44944. m.agent_id = &u
  44945. m.addagent_id = nil
  44946. }
  44947. // AgentID returns the value of the "agent_id" field in the mutation.
  44948. func (m *XunjiMutation) AgentID() (r uint64, exists bool) {
  44949. v := m.agent_id
  44950. if v == nil {
  44951. return
  44952. }
  44953. return *v, true
  44954. }
  44955. // OldAgentID returns the old "agent_id" field's value of the Xunji entity.
  44956. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  44957. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44958. func (m *XunjiMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  44959. if !m.op.Is(OpUpdateOne) {
  44960. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  44961. }
  44962. if m.id == nil || m.oldValue == nil {
  44963. return v, errors.New("OldAgentID requires an ID field in the mutation")
  44964. }
  44965. oldValue, err := m.oldValue(ctx)
  44966. if err != nil {
  44967. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  44968. }
  44969. return oldValue.AgentID, nil
  44970. }
  44971. // AddAgentID adds u to the "agent_id" field.
  44972. func (m *XunjiMutation) AddAgentID(u int64) {
  44973. if m.addagent_id != nil {
  44974. *m.addagent_id += u
  44975. } else {
  44976. m.addagent_id = &u
  44977. }
  44978. }
  44979. // AddedAgentID returns the value that was added to the "agent_id" field in this mutation.
  44980. func (m *XunjiMutation) AddedAgentID() (r int64, exists bool) {
  44981. v := m.addagent_id
  44982. if v == nil {
  44983. return
  44984. }
  44985. return *v, true
  44986. }
  44987. // ResetAgentID resets all changes to the "agent_id" field.
  44988. func (m *XunjiMutation) ResetAgentID() {
  44989. m.agent_id = nil
  44990. m.addagent_id = nil
  44991. }
  44992. // SetOrganizationID sets the "organization_id" field.
  44993. func (m *XunjiMutation) SetOrganizationID(u uint64) {
  44994. m.organization_id = &u
  44995. m.addorganization_id = nil
  44996. }
  44997. // OrganizationID returns the value of the "organization_id" field in the mutation.
  44998. func (m *XunjiMutation) OrganizationID() (r uint64, exists bool) {
  44999. v := m.organization_id
  45000. if v == nil {
  45001. return
  45002. }
  45003. return *v, true
  45004. }
  45005. // OldOrganizationID returns the old "organization_id" field's value of the Xunji entity.
  45006. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  45007. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45008. func (m *XunjiMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  45009. if !m.op.Is(OpUpdateOne) {
  45010. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  45011. }
  45012. if m.id == nil || m.oldValue == nil {
  45013. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  45014. }
  45015. oldValue, err := m.oldValue(ctx)
  45016. if err != nil {
  45017. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  45018. }
  45019. return oldValue.OrganizationID, nil
  45020. }
  45021. // AddOrganizationID adds u to the "organization_id" field.
  45022. func (m *XunjiMutation) AddOrganizationID(u int64) {
  45023. if m.addorganization_id != nil {
  45024. *m.addorganization_id += u
  45025. } else {
  45026. m.addorganization_id = &u
  45027. }
  45028. }
  45029. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  45030. func (m *XunjiMutation) AddedOrganizationID() (r int64, exists bool) {
  45031. v := m.addorganization_id
  45032. if v == nil {
  45033. return
  45034. }
  45035. return *v, true
  45036. }
  45037. // ResetOrganizationID resets all changes to the "organization_id" field.
  45038. func (m *XunjiMutation) ResetOrganizationID() {
  45039. m.organization_id = nil
  45040. m.addorganization_id = nil
  45041. }
  45042. // SetWxid sets the "wxid" field.
  45043. func (m *XunjiMutation) SetWxid(s string) {
  45044. m.wxid = &s
  45045. }
  45046. // Wxid returns the value of the "wxid" field in the mutation.
  45047. func (m *XunjiMutation) Wxid() (r string, exists bool) {
  45048. v := m.wxid
  45049. if v == nil {
  45050. return
  45051. }
  45052. return *v, true
  45053. }
  45054. // OldWxid returns the old "wxid" field's value of the Xunji entity.
  45055. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  45056. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45057. func (m *XunjiMutation) OldWxid(ctx context.Context) (v string, err error) {
  45058. if !m.op.Is(OpUpdateOne) {
  45059. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  45060. }
  45061. if m.id == nil || m.oldValue == nil {
  45062. return v, errors.New("OldWxid requires an ID field in the mutation")
  45063. }
  45064. oldValue, err := m.oldValue(ctx)
  45065. if err != nil {
  45066. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  45067. }
  45068. return oldValue.Wxid, nil
  45069. }
  45070. // ResetWxid resets all changes to the "wxid" field.
  45071. func (m *XunjiMutation) ResetWxid() {
  45072. m.wxid = nil
  45073. }
  45074. // SetAPIBase sets the "api_base" field.
  45075. func (m *XunjiMutation) SetAPIBase(s string) {
  45076. m.api_base = &s
  45077. }
  45078. // APIBase returns the value of the "api_base" field in the mutation.
  45079. func (m *XunjiMutation) APIBase() (r string, exists bool) {
  45080. v := m.api_base
  45081. if v == nil {
  45082. return
  45083. }
  45084. return *v, true
  45085. }
  45086. // OldAPIBase returns the old "api_base" field's value of the Xunji entity.
  45087. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  45088. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45089. func (m *XunjiMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  45090. if !m.op.Is(OpUpdateOne) {
  45091. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  45092. }
  45093. if m.id == nil || m.oldValue == nil {
  45094. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  45095. }
  45096. oldValue, err := m.oldValue(ctx)
  45097. if err != nil {
  45098. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  45099. }
  45100. return oldValue.APIBase, nil
  45101. }
  45102. // ClearAPIBase clears the value of the "api_base" field.
  45103. func (m *XunjiMutation) ClearAPIBase() {
  45104. m.api_base = nil
  45105. m.clearedFields[xunji.FieldAPIBase] = struct{}{}
  45106. }
  45107. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  45108. func (m *XunjiMutation) APIBaseCleared() bool {
  45109. _, ok := m.clearedFields[xunji.FieldAPIBase]
  45110. return ok
  45111. }
  45112. // ResetAPIBase resets all changes to the "api_base" field.
  45113. func (m *XunjiMutation) ResetAPIBase() {
  45114. m.api_base = nil
  45115. delete(m.clearedFields, xunji.FieldAPIBase)
  45116. }
  45117. // SetAPIKey sets the "api_key" field.
  45118. func (m *XunjiMutation) SetAPIKey(s string) {
  45119. m.api_key = &s
  45120. }
  45121. // APIKey returns the value of the "api_key" field in the mutation.
  45122. func (m *XunjiMutation) APIKey() (r string, exists bool) {
  45123. v := m.api_key
  45124. if v == nil {
  45125. return
  45126. }
  45127. return *v, true
  45128. }
  45129. // OldAPIKey returns the old "api_key" field's value of the Xunji entity.
  45130. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  45131. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45132. func (m *XunjiMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  45133. if !m.op.Is(OpUpdateOne) {
  45134. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  45135. }
  45136. if m.id == nil || m.oldValue == nil {
  45137. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  45138. }
  45139. oldValue, err := m.oldValue(ctx)
  45140. if err != nil {
  45141. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  45142. }
  45143. return oldValue.APIKey, nil
  45144. }
  45145. // ClearAPIKey clears the value of the "api_key" field.
  45146. func (m *XunjiMutation) ClearAPIKey() {
  45147. m.api_key = nil
  45148. m.clearedFields[xunji.FieldAPIKey] = struct{}{}
  45149. }
  45150. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  45151. func (m *XunjiMutation) APIKeyCleared() bool {
  45152. _, ok := m.clearedFields[xunji.FieldAPIKey]
  45153. return ok
  45154. }
  45155. // ResetAPIKey resets all changes to the "api_key" field.
  45156. func (m *XunjiMutation) ResetAPIKey() {
  45157. m.api_key = nil
  45158. delete(m.clearedFields, xunji.FieldAPIKey)
  45159. }
  45160. // Where appends a list predicates to the XunjiMutation builder.
  45161. func (m *XunjiMutation) Where(ps ...predicate.Xunji) {
  45162. m.predicates = append(m.predicates, ps...)
  45163. }
  45164. // WhereP appends storage-level predicates to the XunjiMutation builder. Using this method,
  45165. // users can use type-assertion to append predicates that do not depend on any generated package.
  45166. func (m *XunjiMutation) WhereP(ps ...func(*sql.Selector)) {
  45167. p := make([]predicate.Xunji, len(ps))
  45168. for i := range ps {
  45169. p[i] = ps[i]
  45170. }
  45171. m.Where(p...)
  45172. }
  45173. // Op returns the operation name.
  45174. func (m *XunjiMutation) Op() Op {
  45175. return m.op
  45176. }
  45177. // SetOp allows setting the mutation operation.
  45178. func (m *XunjiMutation) SetOp(op Op) {
  45179. m.op = op
  45180. }
  45181. // Type returns the node type of this mutation (Xunji).
  45182. func (m *XunjiMutation) Type() string {
  45183. return m.typ
  45184. }
  45185. // Fields returns all fields that were changed during this mutation. Note that in
  45186. // order to get all numeric fields that were incremented/decremented, call
  45187. // AddedFields().
  45188. func (m *XunjiMutation) Fields() []string {
  45189. fields := make([]string, 0, 13)
  45190. if m.created_at != nil {
  45191. fields = append(fields, xunji.FieldCreatedAt)
  45192. }
  45193. if m.updated_at != nil {
  45194. fields = append(fields, xunji.FieldUpdatedAt)
  45195. }
  45196. if m.status != nil {
  45197. fields = append(fields, xunji.FieldStatus)
  45198. }
  45199. if m.deleted_at != nil {
  45200. fields = append(fields, xunji.FieldDeletedAt)
  45201. }
  45202. if m.app_key != nil {
  45203. fields = append(fields, xunji.FieldAppKey)
  45204. }
  45205. if m.app_secret != nil {
  45206. fields = append(fields, xunji.FieldAppSecret)
  45207. }
  45208. if m.token != nil {
  45209. fields = append(fields, xunji.FieldToken)
  45210. }
  45211. if m.encoding_key != nil {
  45212. fields = append(fields, xunji.FieldEncodingKey)
  45213. }
  45214. if m.agent_id != nil {
  45215. fields = append(fields, xunji.FieldAgentID)
  45216. }
  45217. if m.organization_id != nil {
  45218. fields = append(fields, xunji.FieldOrganizationID)
  45219. }
  45220. if m.wxid != nil {
  45221. fields = append(fields, xunji.FieldWxid)
  45222. }
  45223. if m.api_base != nil {
  45224. fields = append(fields, xunji.FieldAPIBase)
  45225. }
  45226. if m.api_key != nil {
  45227. fields = append(fields, xunji.FieldAPIKey)
  45228. }
  45229. return fields
  45230. }
  45231. // Field returns the value of a field with the given name. The second boolean
  45232. // return value indicates that this field was not set, or was not defined in the
  45233. // schema.
  45234. func (m *XunjiMutation) Field(name string) (ent.Value, bool) {
  45235. switch name {
  45236. case xunji.FieldCreatedAt:
  45237. return m.CreatedAt()
  45238. case xunji.FieldUpdatedAt:
  45239. return m.UpdatedAt()
  45240. case xunji.FieldStatus:
  45241. return m.Status()
  45242. case xunji.FieldDeletedAt:
  45243. return m.DeletedAt()
  45244. case xunji.FieldAppKey:
  45245. return m.AppKey()
  45246. case xunji.FieldAppSecret:
  45247. return m.AppSecret()
  45248. case xunji.FieldToken:
  45249. return m.Token()
  45250. case xunji.FieldEncodingKey:
  45251. return m.EncodingKey()
  45252. case xunji.FieldAgentID:
  45253. return m.AgentID()
  45254. case xunji.FieldOrganizationID:
  45255. return m.OrganizationID()
  45256. case xunji.FieldWxid:
  45257. return m.Wxid()
  45258. case xunji.FieldAPIBase:
  45259. return m.APIBase()
  45260. case xunji.FieldAPIKey:
  45261. return m.APIKey()
  45262. }
  45263. return nil, false
  45264. }
  45265. // OldField returns the old value of the field from the database. An error is
  45266. // returned if the mutation operation is not UpdateOne, or the query to the
  45267. // database failed.
  45268. func (m *XunjiMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  45269. switch name {
  45270. case xunji.FieldCreatedAt:
  45271. return m.OldCreatedAt(ctx)
  45272. case xunji.FieldUpdatedAt:
  45273. return m.OldUpdatedAt(ctx)
  45274. case xunji.FieldStatus:
  45275. return m.OldStatus(ctx)
  45276. case xunji.FieldDeletedAt:
  45277. return m.OldDeletedAt(ctx)
  45278. case xunji.FieldAppKey:
  45279. return m.OldAppKey(ctx)
  45280. case xunji.FieldAppSecret:
  45281. return m.OldAppSecret(ctx)
  45282. case xunji.FieldToken:
  45283. return m.OldToken(ctx)
  45284. case xunji.FieldEncodingKey:
  45285. return m.OldEncodingKey(ctx)
  45286. case xunji.FieldAgentID:
  45287. return m.OldAgentID(ctx)
  45288. case xunji.FieldOrganizationID:
  45289. return m.OldOrganizationID(ctx)
  45290. case xunji.FieldWxid:
  45291. return m.OldWxid(ctx)
  45292. case xunji.FieldAPIBase:
  45293. return m.OldAPIBase(ctx)
  45294. case xunji.FieldAPIKey:
  45295. return m.OldAPIKey(ctx)
  45296. }
  45297. return nil, fmt.Errorf("unknown Xunji field %s", name)
  45298. }
  45299. // SetField sets the value of a field with the given name. It returns an error if
  45300. // the field is not defined in the schema, or if the type mismatched the field
  45301. // type.
  45302. func (m *XunjiMutation) SetField(name string, value ent.Value) error {
  45303. switch name {
  45304. case xunji.FieldCreatedAt:
  45305. v, ok := value.(time.Time)
  45306. if !ok {
  45307. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45308. }
  45309. m.SetCreatedAt(v)
  45310. return nil
  45311. case xunji.FieldUpdatedAt:
  45312. v, ok := value.(time.Time)
  45313. if !ok {
  45314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45315. }
  45316. m.SetUpdatedAt(v)
  45317. return nil
  45318. case xunji.FieldStatus:
  45319. v, ok := value.(uint8)
  45320. if !ok {
  45321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45322. }
  45323. m.SetStatus(v)
  45324. return nil
  45325. case xunji.FieldDeletedAt:
  45326. v, ok := value.(time.Time)
  45327. if !ok {
  45328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45329. }
  45330. m.SetDeletedAt(v)
  45331. return nil
  45332. case xunji.FieldAppKey:
  45333. v, ok := value.(string)
  45334. if !ok {
  45335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45336. }
  45337. m.SetAppKey(v)
  45338. return nil
  45339. case xunji.FieldAppSecret:
  45340. v, ok := value.(string)
  45341. if !ok {
  45342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45343. }
  45344. m.SetAppSecret(v)
  45345. return nil
  45346. case xunji.FieldToken:
  45347. v, ok := value.(string)
  45348. if !ok {
  45349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45350. }
  45351. m.SetToken(v)
  45352. return nil
  45353. case xunji.FieldEncodingKey:
  45354. v, ok := value.(string)
  45355. if !ok {
  45356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45357. }
  45358. m.SetEncodingKey(v)
  45359. return nil
  45360. case xunji.FieldAgentID:
  45361. v, ok := value.(uint64)
  45362. if !ok {
  45363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45364. }
  45365. m.SetAgentID(v)
  45366. return nil
  45367. case xunji.FieldOrganizationID:
  45368. v, ok := value.(uint64)
  45369. if !ok {
  45370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45371. }
  45372. m.SetOrganizationID(v)
  45373. return nil
  45374. case xunji.FieldWxid:
  45375. v, ok := value.(string)
  45376. if !ok {
  45377. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45378. }
  45379. m.SetWxid(v)
  45380. return nil
  45381. case xunji.FieldAPIBase:
  45382. v, ok := value.(string)
  45383. if !ok {
  45384. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45385. }
  45386. m.SetAPIBase(v)
  45387. return nil
  45388. case xunji.FieldAPIKey:
  45389. v, ok := value.(string)
  45390. if !ok {
  45391. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45392. }
  45393. m.SetAPIKey(v)
  45394. return nil
  45395. }
  45396. return fmt.Errorf("unknown Xunji field %s", name)
  45397. }
  45398. // AddedFields returns all numeric fields that were incremented/decremented during
  45399. // this mutation.
  45400. func (m *XunjiMutation) AddedFields() []string {
  45401. var fields []string
  45402. if m.addstatus != nil {
  45403. fields = append(fields, xunji.FieldStatus)
  45404. }
  45405. if m.addagent_id != nil {
  45406. fields = append(fields, xunji.FieldAgentID)
  45407. }
  45408. if m.addorganization_id != nil {
  45409. fields = append(fields, xunji.FieldOrganizationID)
  45410. }
  45411. return fields
  45412. }
  45413. // AddedField returns the numeric value that was incremented/decremented on a field
  45414. // with the given name. The second boolean return value indicates that this field
  45415. // was not set, or was not defined in the schema.
  45416. func (m *XunjiMutation) AddedField(name string) (ent.Value, bool) {
  45417. switch name {
  45418. case xunji.FieldStatus:
  45419. return m.AddedStatus()
  45420. case xunji.FieldAgentID:
  45421. return m.AddedAgentID()
  45422. case xunji.FieldOrganizationID:
  45423. return m.AddedOrganizationID()
  45424. }
  45425. return nil, false
  45426. }
  45427. // AddField adds the value to the field with the given name. It returns an error if
  45428. // the field is not defined in the schema, or if the type mismatched the field
  45429. // type.
  45430. func (m *XunjiMutation) AddField(name string, value ent.Value) error {
  45431. switch name {
  45432. case xunji.FieldStatus:
  45433. v, ok := value.(int8)
  45434. if !ok {
  45435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45436. }
  45437. m.AddStatus(v)
  45438. return nil
  45439. case xunji.FieldAgentID:
  45440. v, ok := value.(int64)
  45441. if !ok {
  45442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45443. }
  45444. m.AddAgentID(v)
  45445. return nil
  45446. case xunji.FieldOrganizationID:
  45447. v, ok := value.(int64)
  45448. if !ok {
  45449. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45450. }
  45451. m.AddOrganizationID(v)
  45452. return nil
  45453. }
  45454. return fmt.Errorf("unknown Xunji numeric field %s", name)
  45455. }
  45456. // ClearedFields returns all nullable fields that were cleared during this
  45457. // mutation.
  45458. func (m *XunjiMutation) ClearedFields() []string {
  45459. var fields []string
  45460. if m.FieldCleared(xunji.FieldStatus) {
  45461. fields = append(fields, xunji.FieldStatus)
  45462. }
  45463. if m.FieldCleared(xunji.FieldDeletedAt) {
  45464. fields = append(fields, xunji.FieldDeletedAt)
  45465. }
  45466. if m.FieldCleared(xunji.FieldAPIBase) {
  45467. fields = append(fields, xunji.FieldAPIBase)
  45468. }
  45469. if m.FieldCleared(xunji.FieldAPIKey) {
  45470. fields = append(fields, xunji.FieldAPIKey)
  45471. }
  45472. return fields
  45473. }
  45474. // FieldCleared returns a boolean indicating if a field with the given name was
  45475. // cleared in this mutation.
  45476. func (m *XunjiMutation) FieldCleared(name string) bool {
  45477. _, ok := m.clearedFields[name]
  45478. return ok
  45479. }
  45480. // ClearField clears the value of the field with the given name. It returns an
  45481. // error if the field is not defined in the schema.
  45482. func (m *XunjiMutation) ClearField(name string) error {
  45483. switch name {
  45484. case xunji.FieldStatus:
  45485. m.ClearStatus()
  45486. return nil
  45487. case xunji.FieldDeletedAt:
  45488. m.ClearDeletedAt()
  45489. return nil
  45490. case xunji.FieldAPIBase:
  45491. m.ClearAPIBase()
  45492. return nil
  45493. case xunji.FieldAPIKey:
  45494. m.ClearAPIKey()
  45495. return nil
  45496. }
  45497. return fmt.Errorf("unknown Xunji nullable field %s", name)
  45498. }
  45499. // ResetField resets all changes in the mutation for the field with the given name.
  45500. // It returns an error if the field is not defined in the schema.
  45501. func (m *XunjiMutation) ResetField(name string) error {
  45502. switch name {
  45503. case xunji.FieldCreatedAt:
  45504. m.ResetCreatedAt()
  45505. return nil
  45506. case xunji.FieldUpdatedAt:
  45507. m.ResetUpdatedAt()
  45508. return nil
  45509. case xunji.FieldStatus:
  45510. m.ResetStatus()
  45511. return nil
  45512. case xunji.FieldDeletedAt:
  45513. m.ResetDeletedAt()
  45514. return nil
  45515. case xunji.FieldAppKey:
  45516. m.ResetAppKey()
  45517. return nil
  45518. case xunji.FieldAppSecret:
  45519. m.ResetAppSecret()
  45520. return nil
  45521. case xunji.FieldToken:
  45522. m.ResetToken()
  45523. return nil
  45524. case xunji.FieldEncodingKey:
  45525. m.ResetEncodingKey()
  45526. return nil
  45527. case xunji.FieldAgentID:
  45528. m.ResetAgentID()
  45529. return nil
  45530. case xunji.FieldOrganizationID:
  45531. m.ResetOrganizationID()
  45532. return nil
  45533. case xunji.FieldWxid:
  45534. m.ResetWxid()
  45535. return nil
  45536. case xunji.FieldAPIBase:
  45537. m.ResetAPIBase()
  45538. return nil
  45539. case xunji.FieldAPIKey:
  45540. m.ResetAPIKey()
  45541. return nil
  45542. }
  45543. return fmt.Errorf("unknown Xunji field %s", name)
  45544. }
  45545. // AddedEdges returns all edge names that were set/added in this mutation.
  45546. func (m *XunjiMutation) AddedEdges() []string {
  45547. edges := make([]string, 0, 0)
  45548. return edges
  45549. }
  45550. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  45551. // name in this mutation.
  45552. func (m *XunjiMutation) AddedIDs(name string) []ent.Value {
  45553. return nil
  45554. }
  45555. // RemovedEdges returns all edge names that were removed in this mutation.
  45556. func (m *XunjiMutation) RemovedEdges() []string {
  45557. edges := make([]string, 0, 0)
  45558. return edges
  45559. }
  45560. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  45561. // the given name in this mutation.
  45562. func (m *XunjiMutation) RemovedIDs(name string) []ent.Value {
  45563. return nil
  45564. }
  45565. // ClearedEdges returns all edge names that were cleared in this mutation.
  45566. func (m *XunjiMutation) ClearedEdges() []string {
  45567. edges := make([]string, 0, 0)
  45568. return edges
  45569. }
  45570. // EdgeCleared returns a boolean which indicates if the edge with the given name
  45571. // was cleared in this mutation.
  45572. func (m *XunjiMutation) EdgeCleared(name string) bool {
  45573. return false
  45574. }
  45575. // ClearEdge clears the value of the edge with the given name. It returns an error
  45576. // if that edge is not defined in the schema.
  45577. func (m *XunjiMutation) ClearEdge(name string) error {
  45578. return fmt.Errorf("unknown Xunji unique edge %s", name)
  45579. }
  45580. // ResetEdge resets all changes to the edge with the given name in this mutation.
  45581. // It returns an error if the edge is not defined in the schema.
  45582. func (m *XunjiMutation) ResetEdge(name string) error {
  45583. return fmt.Errorf("unknown Xunji edge %s", name)
  45584. }