mutation.go 1.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "sync"
  8. "time"
  9. "wechat-api/ent/agent"
  10. "wechat-api/ent/agentbase"
  11. "wechat-api/ent/aliyunavatar"
  12. "wechat-api/ent/allocagent"
  13. "wechat-api/ent/apikey"
  14. "wechat-api/ent/batchmsg"
  15. "wechat-api/ent/category"
  16. "wechat-api/ent/chatrecords"
  17. "wechat-api/ent/chatsession"
  18. "wechat-api/ent/compapiasynctask"
  19. "wechat-api/ent/contact"
  20. "wechat-api/ent/contactfield"
  21. "wechat-api/ent/contactfieldtemplate"
  22. "wechat-api/ent/creditbalance"
  23. "wechat-api/ent/creditusage"
  24. "wechat-api/ent/custom_types"
  25. "wechat-api/ent/employee"
  26. "wechat-api/ent/employeeconfig"
  27. "wechat-api/ent/label"
  28. "wechat-api/ent/labelrelationship"
  29. "wechat-api/ent/labeltagging"
  30. "wechat-api/ent/message"
  31. "wechat-api/ent/messagerecords"
  32. "wechat-api/ent/msg"
  33. "wechat-api/ent/payrecharge"
  34. "wechat-api/ent/predicate"
  35. "wechat-api/ent/server"
  36. "wechat-api/ent/sopnode"
  37. "wechat-api/ent/sopstage"
  38. "wechat-api/ent/soptask"
  39. "wechat-api/ent/token"
  40. "wechat-api/ent/tutorial"
  41. "wechat-api/ent/usagedetail"
  42. "wechat-api/ent/usagestatisticday"
  43. "wechat-api/ent/usagestatistichour"
  44. "wechat-api/ent/usagestatisticmonth"
  45. "wechat-api/ent/usagetotal"
  46. "wechat-api/ent/whatsapp"
  47. "wechat-api/ent/whatsappchannel"
  48. "wechat-api/ent/workexperience"
  49. "wechat-api/ent/wpchatroom"
  50. "wechat-api/ent/wpchatroommember"
  51. "wechat-api/ent/wx"
  52. "wechat-api/ent/wxcard"
  53. "wechat-api/ent/wxcarduser"
  54. "wechat-api/ent/wxcardvisit"
  55. "wechat-api/ent/xunji"
  56. "wechat-api/ent/xunjiservice"
  57. "entgo.io/ent"
  58. "entgo.io/ent/dialect/sql"
  59. )
  60. const (
  61. // Operation types.
  62. OpCreate = ent.OpCreate
  63. OpDelete = ent.OpDelete
  64. OpDeleteOne = ent.OpDeleteOne
  65. OpUpdate = ent.OpUpdate
  66. OpUpdateOne = ent.OpUpdateOne
  67. // Node types.
  68. TypeAgent = "Agent"
  69. TypeAgentBase = "AgentBase"
  70. TypeAliyunAvatar = "AliyunAvatar"
  71. TypeAllocAgent = "AllocAgent"
  72. TypeApiKey = "ApiKey"
  73. TypeBatchMsg = "BatchMsg"
  74. TypeCategory = "Category"
  75. TypeChatRecords = "ChatRecords"
  76. TypeChatSession = "ChatSession"
  77. TypeCompapiAsynctask = "CompapiAsynctask"
  78. TypeContact = "Contact"
  79. TypeContactField = "ContactField"
  80. TypeContactFieldTemplate = "ContactFieldTemplate"
  81. TypeCreditBalance = "CreditBalance"
  82. TypeCreditUsage = "CreditUsage"
  83. TypeEmployee = "Employee"
  84. TypeEmployeeConfig = "EmployeeConfig"
  85. TypeLabel = "Label"
  86. TypeLabelRelationship = "LabelRelationship"
  87. TypeLabelTagging = "LabelTagging"
  88. TypeMessage = "Message"
  89. TypeMessageRecords = "MessageRecords"
  90. TypeMsg = "Msg"
  91. TypePayRecharge = "PayRecharge"
  92. TypeServer = "Server"
  93. TypeSopNode = "SopNode"
  94. TypeSopStage = "SopStage"
  95. TypeSopTask = "SopTask"
  96. TypeToken = "Token"
  97. TypeTutorial = "Tutorial"
  98. TypeUsageDetail = "UsageDetail"
  99. TypeUsageStatisticDay = "UsageStatisticDay"
  100. TypeUsageStatisticHour = "UsageStatisticHour"
  101. TypeUsageStatisticMonth = "UsageStatisticMonth"
  102. TypeUsageTotal = "UsageTotal"
  103. TypeWhatsapp = "Whatsapp"
  104. TypeWhatsappChannel = "WhatsappChannel"
  105. TypeWorkExperience = "WorkExperience"
  106. TypeWpChatroom = "WpChatroom"
  107. TypeWpChatroomMember = "WpChatroomMember"
  108. TypeWx = "Wx"
  109. TypeWxCard = "WxCard"
  110. TypeWxCardUser = "WxCardUser"
  111. TypeWxCardVisit = "WxCardVisit"
  112. TypeXunji = "Xunji"
  113. TypeXunjiService = "XunjiService"
  114. )
  115. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  116. type AgentMutation struct {
  117. config
  118. op Op
  119. typ string
  120. id *uint64
  121. created_at *time.Time
  122. updated_at *time.Time
  123. deleted_at *time.Time
  124. name *string
  125. role *string
  126. status *int
  127. addstatus *int
  128. background *string
  129. examples *string
  130. organization_id *uint64
  131. addorganization_id *int64
  132. dataset_id *string
  133. collection_id *string
  134. model *string
  135. api_base *string
  136. api_key *string
  137. _type *int
  138. add_type *int
  139. clearedFields map[string]struct{}
  140. wx_agent map[uint64]struct{}
  141. removedwx_agent map[uint64]struct{}
  142. clearedwx_agent bool
  143. token_agent map[uint64]struct{}
  144. removedtoken_agent map[uint64]struct{}
  145. clearedtoken_agent bool
  146. wa_agent map[uint64]struct{}
  147. removedwa_agent map[uint64]struct{}
  148. clearedwa_agent bool
  149. xjs_agent map[uint64]struct{}
  150. removedxjs_agent map[uint64]struct{}
  151. clearedxjs_agent bool
  152. key_agent map[uint64]struct{}
  153. removedkey_agent map[uint64]struct{}
  154. clearedkey_agent bool
  155. done bool
  156. oldValue func(context.Context) (*Agent, error)
  157. predicates []predicate.Agent
  158. }
  159. var _ ent.Mutation = (*AgentMutation)(nil)
  160. // agentOption allows management of the mutation configuration using functional options.
  161. type agentOption func(*AgentMutation)
  162. // newAgentMutation creates new mutation for the Agent entity.
  163. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  164. m := &AgentMutation{
  165. config: c,
  166. op: op,
  167. typ: TypeAgent,
  168. clearedFields: make(map[string]struct{}),
  169. }
  170. for _, opt := range opts {
  171. opt(m)
  172. }
  173. return m
  174. }
  175. // withAgentID sets the ID field of the mutation.
  176. func withAgentID(id uint64) agentOption {
  177. return func(m *AgentMutation) {
  178. var (
  179. err error
  180. once sync.Once
  181. value *Agent
  182. )
  183. m.oldValue = func(ctx context.Context) (*Agent, error) {
  184. once.Do(func() {
  185. if m.done {
  186. err = errors.New("querying old values post mutation is not allowed")
  187. } else {
  188. value, err = m.Client().Agent.Get(ctx, id)
  189. }
  190. })
  191. return value, err
  192. }
  193. m.id = &id
  194. }
  195. }
  196. // withAgent sets the old Agent of the mutation.
  197. func withAgent(node *Agent) agentOption {
  198. return func(m *AgentMutation) {
  199. m.oldValue = func(context.Context) (*Agent, error) {
  200. return node, nil
  201. }
  202. m.id = &node.ID
  203. }
  204. }
  205. // Client returns a new `ent.Client` from the mutation. If the mutation was
  206. // executed in a transaction (ent.Tx), a transactional client is returned.
  207. func (m AgentMutation) Client() *Client {
  208. client := &Client{config: m.config}
  209. client.init()
  210. return client
  211. }
  212. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  213. // it returns an error otherwise.
  214. func (m AgentMutation) Tx() (*Tx, error) {
  215. if _, ok := m.driver.(*txDriver); !ok {
  216. return nil, errors.New("ent: mutation is not running in a transaction")
  217. }
  218. tx := &Tx{config: m.config}
  219. tx.init()
  220. return tx, nil
  221. }
  222. // SetID sets the value of the id field. Note that this
  223. // operation is only accepted on creation of Agent entities.
  224. func (m *AgentMutation) SetID(id uint64) {
  225. m.id = &id
  226. }
  227. // ID returns the ID value in the mutation. Note that the ID is only available
  228. // if it was provided to the builder or after it was returned from the database.
  229. func (m *AgentMutation) ID() (id uint64, exists bool) {
  230. if m.id == nil {
  231. return
  232. }
  233. return *m.id, true
  234. }
  235. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  236. // That means, if the mutation is applied within a transaction with an isolation level such
  237. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  238. // or updated by the mutation.
  239. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  240. switch {
  241. case m.op.Is(OpUpdateOne | OpDeleteOne):
  242. id, exists := m.ID()
  243. if exists {
  244. return []uint64{id}, nil
  245. }
  246. fallthrough
  247. case m.op.Is(OpUpdate | OpDelete):
  248. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  249. default:
  250. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  251. }
  252. }
  253. // SetCreatedAt sets the "created_at" field.
  254. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  255. m.created_at = &t
  256. }
  257. // CreatedAt returns the value of the "created_at" field in the mutation.
  258. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  259. v := m.created_at
  260. if v == nil {
  261. return
  262. }
  263. return *v, true
  264. }
  265. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  266. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  267. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  268. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  269. if !m.op.Is(OpUpdateOne) {
  270. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  271. }
  272. if m.id == nil || m.oldValue == nil {
  273. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  274. }
  275. oldValue, err := m.oldValue(ctx)
  276. if err != nil {
  277. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  278. }
  279. return oldValue.CreatedAt, nil
  280. }
  281. // ResetCreatedAt resets all changes to the "created_at" field.
  282. func (m *AgentMutation) ResetCreatedAt() {
  283. m.created_at = nil
  284. }
  285. // SetUpdatedAt sets the "updated_at" field.
  286. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  287. m.updated_at = &t
  288. }
  289. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  290. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  291. v := m.updated_at
  292. if v == nil {
  293. return
  294. }
  295. return *v, true
  296. }
  297. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  298. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  299. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  300. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  301. if !m.op.Is(OpUpdateOne) {
  302. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  303. }
  304. if m.id == nil || m.oldValue == nil {
  305. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  306. }
  307. oldValue, err := m.oldValue(ctx)
  308. if err != nil {
  309. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  310. }
  311. return oldValue.UpdatedAt, nil
  312. }
  313. // ResetUpdatedAt resets all changes to the "updated_at" field.
  314. func (m *AgentMutation) ResetUpdatedAt() {
  315. m.updated_at = nil
  316. }
  317. // SetDeletedAt sets the "deleted_at" field.
  318. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  319. m.deleted_at = &t
  320. }
  321. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  322. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  323. v := m.deleted_at
  324. if v == nil {
  325. return
  326. }
  327. return *v, true
  328. }
  329. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  330. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  331. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  332. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  333. if !m.op.Is(OpUpdateOne) {
  334. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  335. }
  336. if m.id == nil || m.oldValue == nil {
  337. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  338. }
  339. oldValue, err := m.oldValue(ctx)
  340. if err != nil {
  341. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  342. }
  343. return oldValue.DeletedAt, nil
  344. }
  345. // ClearDeletedAt clears the value of the "deleted_at" field.
  346. func (m *AgentMutation) ClearDeletedAt() {
  347. m.deleted_at = nil
  348. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  349. }
  350. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  351. func (m *AgentMutation) DeletedAtCleared() bool {
  352. _, ok := m.clearedFields[agent.FieldDeletedAt]
  353. return ok
  354. }
  355. // ResetDeletedAt resets all changes to the "deleted_at" field.
  356. func (m *AgentMutation) ResetDeletedAt() {
  357. m.deleted_at = nil
  358. delete(m.clearedFields, agent.FieldDeletedAt)
  359. }
  360. // SetName sets the "name" field.
  361. func (m *AgentMutation) SetName(s string) {
  362. m.name = &s
  363. }
  364. // Name returns the value of the "name" field in the mutation.
  365. func (m *AgentMutation) Name() (r string, exists bool) {
  366. v := m.name
  367. if v == nil {
  368. return
  369. }
  370. return *v, true
  371. }
  372. // OldName returns the old "name" field's value of the Agent entity.
  373. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  374. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  375. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  376. if !m.op.Is(OpUpdateOne) {
  377. return v, errors.New("OldName is only allowed on UpdateOne operations")
  378. }
  379. if m.id == nil || m.oldValue == nil {
  380. return v, errors.New("OldName requires an ID field in the mutation")
  381. }
  382. oldValue, err := m.oldValue(ctx)
  383. if err != nil {
  384. return v, fmt.Errorf("querying old value for OldName: %w", err)
  385. }
  386. return oldValue.Name, nil
  387. }
  388. // ResetName resets all changes to the "name" field.
  389. func (m *AgentMutation) ResetName() {
  390. m.name = nil
  391. }
  392. // SetRole sets the "role" field.
  393. func (m *AgentMutation) SetRole(s string) {
  394. m.role = &s
  395. }
  396. // Role returns the value of the "role" field in the mutation.
  397. func (m *AgentMutation) Role() (r string, exists bool) {
  398. v := m.role
  399. if v == nil {
  400. return
  401. }
  402. return *v, true
  403. }
  404. // OldRole returns the old "role" field's value of the Agent entity.
  405. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  407. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  408. if !m.op.Is(OpUpdateOne) {
  409. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  410. }
  411. if m.id == nil || m.oldValue == nil {
  412. return v, errors.New("OldRole requires an ID field in the mutation")
  413. }
  414. oldValue, err := m.oldValue(ctx)
  415. if err != nil {
  416. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  417. }
  418. return oldValue.Role, nil
  419. }
  420. // ClearRole clears the value of the "role" field.
  421. func (m *AgentMutation) ClearRole() {
  422. m.role = nil
  423. m.clearedFields[agent.FieldRole] = struct{}{}
  424. }
  425. // RoleCleared returns if the "role" field was cleared in this mutation.
  426. func (m *AgentMutation) RoleCleared() bool {
  427. _, ok := m.clearedFields[agent.FieldRole]
  428. return ok
  429. }
  430. // ResetRole resets all changes to the "role" field.
  431. func (m *AgentMutation) ResetRole() {
  432. m.role = nil
  433. delete(m.clearedFields, agent.FieldRole)
  434. }
  435. // SetStatus sets the "status" field.
  436. func (m *AgentMutation) SetStatus(i int) {
  437. m.status = &i
  438. m.addstatus = nil
  439. }
  440. // Status returns the value of the "status" field in the mutation.
  441. func (m *AgentMutation) Status() (r int, exists bool) {
  442. v := m.status
  443. if v == nil {
  444. return
  445. }
  446. return *v, true
  447. }
  448. // OldStatus returns the old "status" field's value of the Agent entity.
  449. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  450. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  451. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  452. if !m.op.Is(OpUpdateOne) {
  453. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  454. }
  455. if m.id == nil || m.oldValue == nil {
  456. return v, errors.New("OldStatus requires an ID field in the mutation")
  457. }
  458. oldValue, err := m.oldValue(ctx)
  459. if err != nil {
  460. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  461. }
  462. return oldValue.Status, nil
  463. }
  464. // AddStatus adds i to the "status" field.
  465. func (m *AgentMutation) AddStatus(i int) {
  466. if m.addstatus != nil {
  467. *m.addstatus += i
  468. } else {
  469. m.addstatus = &i
  470. }
  471. }
  472. // AddedStatus returns the value that was added to the "status" field in this mutation.
  473. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  474. v := m.addstatus
  475. if v == nil {
  476. return
  477. }
  478. return *v, true
  479. }
  480. // ClearStatus clears the value of the "status" field.
  481. func (m *AgentMutation) ClearStatus() {
  482. m.status = nil
  483. m.addstatus = nil
  484. m.clearedFields[agent.FieldStatus] = struct{}{}
  485. }
  486. // StatusCleared returns if the "status" field was cleared in this mutation.
  487. func (m *AgentMutation) StatusCleared() bool {
  488. _, ok := m.clearedFields[agent.FieldStatus]
  489. return ok
  490. }
  491. // ResetStatus resets all changes to the "status" field.
  492. func (m *AgentMutation) ResetStatus() {
  493. m.status = nil
  494. m.addstatus = nil
  495. delete(m.clearedFields, agent.FieldStatus)
  496. }
  497. // SetBackground sets the "background" field.
  498. func (m *AgentMutation) SetBackground(s string) {
  499. m.background = &s
  500. }
  501. // Background returns the value of the "background" field in the mutation.
  502. func (m *AgentMutation) Background() (r string, exists bool) {
  503. v := m.background
  504. if v == nil {
  505. return
  506. }
  507. return *v, true
  508. }
  509. // OldBackground returns the old "background" field's value of the Agent entity.
  510. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  511. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  512. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  513. if !m.op.Is(OpUpdateOne) {
  514. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  515. }
  516. if m.id == nil || m.oldValue == nil {
  517. return v, errors.New("OldBackground requires an ID field in the mutation")
  518. }
  519. oldValue, err := m.oldValue(ctx)
  520. if err != nil {
  521. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  522. }
  523. return oldValue.Background, nil
  524. }
  525. // ClearBackground clears the value of the "background" field.
  526. func (m *AgentMutation) ClearBackground() {
  527. m.background = nil
  528. m.clearedFields[agent.FieldBackground] = struct{}{}
  529. }
  530. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  531. func (m *AgentMutation) BackgroundCleared() bool {
  532. _, ok := m.clearedFields[agent.FieldBackground]
  533. return ok
  534. }
  535. // ResetBackground resets all changes to the "background" field.
  536. func (m *AgentMutation) ResetBackground() {
  537. m.background = nil
  538. delete(m.clearedFields, agent.FieldBackground)
  539. }
  540. // SetExamples sets the "examples" field.
  541. func (m *AgentMutation) SetExamples(s string) {
  542. m.examples = &s
  543. }
  544. // Examples returns the value of the "examples" field in the mutation.
  545. func (m *AgentMutation) Examples() (r string, exists bool) {
  546. v := m.examples
  547. if v == nil {
  548. return
  549. }
  550. return *v, true
  551. }
  552. // OldExamples returns the old "examples" field's value of the Agent entity.
  553. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  554. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  555. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  556. if !m.op.Is(OpUpdateOne) {
  557. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  558. }
  559. if m.id == nil || m.oldValue == nil {
  560. return v, errors.New("OldExamples requires an ID field in the mutation")
  561. }
  562. oldValue, err := m.oldValue(ctx)
  563. if err != nil {
  564. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  565. }
  566. return oldValue.Examples, nil
  567. }
  568. // ClearExamples clears the value of the "examples" field.
  569. func (m *AgentMutation) ClearExamples() {
  570. m.examples = nil
  571. m.clearedFields[agent.FieldExamples] = struct{}{}
  572. }
  573. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  574. func (m *AgentMutation) ExamplesCleared() bool {
  575. _, ok := m.clearedFields[agent.FieldExamples]
  576. return ok
  577. }
  578. // ResetExamples resets all changes to the "examples" field.
  579. func (m *AgentMutation) ResetExamples() {
  580. m.examples = nil
  581. delete(m.clearedFields, agent.FieldExamples)
  582. }
  583. // SetOrganizationID sets the "organization_id" field.
  584. func (m *AgentMutation) SetOrganizationID(u uint64) {
  585. m.organization_id = &u
  586. m.addorganization_id = nil
  587. }
  588. // OrganizationID returns the value of the "organization_id" field in the mutation.
  589. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  590. v := m.organization_id
  591. if v == nil {
  592. return
  593. }
  594. return *v, true
  595. }
  596. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  597. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  598. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  599. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  600. if !m.op.Is(OpUpdateOne) {
  601. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  602. }
  603. if m.id == nil || m.oldValue == nil {
  604. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  605. }
  606. oldValue, err := m.oldValue(ctx)
  607. if err != nil {
  608. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  609. }
  610. return oldValue.OrganizationID, nil
  611. }
  612. // AddOrganizationID adds u to the "organization_id" field.
  613. func (m *AgentMutation) AddOrganizationID(u int64) {
  614. if m.addorganization_id != nil {
  615. *m.addorganization_id += u
  616. } else {
  617. m.addorganization_id = &u
  618. }
  619. }
  620. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  621. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  622. v := m.addorganization_id
  623. if v == nil {
  624. return
  625. }
  626. return *v, true
  627. }
  628. // ResetOrganizationID resets all changes to the "organization_id" field.
  629. func (m *AgentMutation) ResetOrganizationID() {
  630. m.organization_id = nil
  631. m.addorganization_id = nil
  632. }
  633. // SetDatasetID sets the "dataset_id" field.
  634. func (m *AgentMutation) SetDatasetID(s string) {
  635. m.dataset_id = &s
  636. }
  637. // DatasetID returns the value of the "dataset_id" field in the mutation.
  638. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  639. v := m.dataset_id
  640. if v == nil {
  641. return
  642. }
  643. return *v, true
  644. }
  645. // OldDatasetID returns the old "dataset_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) OldDatasetID(ctx context.Context) (v string, err error) {
  649. if !m.op.Is(OpUpdateOne) {
  650. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  651. }
  652. if m.id == nil || m.oldValue == nil {
  653. return v, errors.New("OldDatasetID 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 OldDatasetID: %w", err)
  658. }
  659. return oldValue.DatasetID, nil
  660. }
  661. // ResetDatasetID resets all changes to the "dataset_id" field.
  662. func (m *AgentMutation) ResetDatasetID() {
  663. m.dataset_id = nil
  664. }
  665. // SetCollectionID sets the "collection_id" field.
  666. func (m *AgentMutation) SetCollectionID(s string) {
  667. m.collection_id = &s
  668. }
  669. // CollectionID returns the value of the "collection_id" field in the mutation.
  670. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  671. v := m.collection_id
  672. if v == nil {
  673. return
  674. }
  675. return *v, true
  676. }
  677. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  678. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  680. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  681. if !m.op.Is(OpUpdateOne) {
  682. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  683. }
  684. if m.id == nil || m.oldValue == nil {
  685. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  686. }
  687. oldValue, err := m.oldValue(ctx)
  688. if err != nil {
  689. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  690. }
  691. return oldValue.CollectionID, nil
  692. }
  693. // ResetCollectionID resets all changes to the "collection_id" field.
  694. func (m *AgentMutation) ResetCollectionID() {
  695. m.collection_id = nil
  696. }
  697. // SetModel sets the "model" field.
  698. func (m *AgentMutation) SetModel(s string) {
  699. m.model = &s
  700. }
  701. // Model returns the value of the "model" field in the mutation.
  702. func (m *AgentMutation) Model() (r string, exists bool) {
  703. v := m.model
  704. if v == nil {
  705. return
  706. }
  707. return *v, true
  708. }
  709. // OldModel returns the old "model" field's value of the Agent entity.
  710. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  711. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  712. func (m *AgentMutation) OldModel(ctx context.Context) (v string, err error) {
  713. if !m.op.Is(OpUpdateOne) {
  714. return v, errors.New("OldModel is only allowed on UpdateOne operations")
  715. }
  716. if m.id == nil || m.oldValue == nil {
  717. return v, errors.New("OldModel requires an ID field in the mutation")
  718. }
  719. oldValue, err := m.oldValue(ctx)
  720. if err != nil {
  721. return v, fmt.Errorf("querying old value for OldModel: %w", err)
  722. }
  723. return oldValue.Model, nil
  724. }
  725. // ClearModel clears the value of the "model" field.
  726. func (m *AgentMutation) ClearModel() {
  727. m.model = nil
  728. m.clearedFields[agent.FieldModel] = struct{}{}
  729. }
  730. // ModelCleared returns if the "model" field was cleared in this mutation.
  731. func (m *AgentMutation) ModelCleared() bool {
  732. _, ok := m.clearedFields[agent.FieldModel]
  733. return ok
  734. }
  735. // ResetModel resets all changes to the "model" field.
  736. func (m *AgentMutation) ResetModel() {
  737. m.model = nil
  738. delete(m.clearedFields, agent.FieldModel)
  739. }
  740. // SetAPIBase sets the "api_base" field.
  741. func (m *AgentMutation) SetAPIBase(s string) {
  742. m.api_base = &s
  743. }
  744. // APIBase returns the value of the "api_base" field in the mutation.
  745. func (m *AgentMutation) APIBase() (r string, exists bool) {
  746. v := m.api_base
  747. if v == nil {
  748. return
  749. }
  750. return *v, true
  751. }
  752. // OldAPIBase returns the old "api_base" field's value of the Agent entity.
  753. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  754. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  755. func (m *AgentMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  756. if !m.op.Is(OpUpdateOne) {
  757. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  758. }
  759. if m.id == nil || m.oldValue == nil {
  760. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  761. }
  762. oldValue, err := m.oldValue(ctx)
  763. if err != nil {
  764. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  765. }
  766. return oldValue.APIBase, nil
  767. }
  768. // ClearAPIBase clears the value of the "api_base" field.
  769. func (m *AgentMutation) ClearAPIBase() {
  770. m.api_base = nil
  771. m.clearedFields[agent.FieldAPIBase] = struct{}{}
  772. }
  773. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  774. func (m *AgentMutation) APIBaseCleared() bool {
  775. _, ok := m.clearedFields[agent.FieldAPIBase]
  776. return ok
  777. }
  778. // ResetAPIBase resets all changes to the "api_base" field.
  779. func (m *AgentMutation) ResetAPIBase() {
  780. m.api_base = nil
  781. delete(m.clearedFields, agent.FieldAPIBase)
  782. }
  783. // SetAPIKey sets the "api_key" field.
  784. func (m *AgentMutation) SetAPIKey(s string) {
  785. m.api_key = &s
  786. }
  787. // APIKey returns the value of the "api_key" field in the mutation.
  788. func (m *AgentMutation) APIKey() (r string, exists bool) {
  789. v := m.api_key
  790. if v == nil {
  791. return
  792. }
  793. return *v, true
  794. }
  795. // OldAPIKey returns the old "api_key" field's value of the Agent entity.
  796. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  797. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  798. func (m *AgentMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  799. if !m.op.Is(OpUpdateOne) {
  800. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  801. }
  802. if m.id == nil || m.oldValue == nil {
  803. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  804. }
  805. oldValue, err := m.oldValue(ctx)
  806. if err != nil {
  807. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  808. }
  809. return oldValue.APIKey, nil
  810. }
  811. // ClearAPIKey clears the value of the "api_key" field.
  812. func (m *AgentMutation) ClearAPIKey() {
  813. m.api_key = nil
  814. m.clearedFields[agent.FieldAPIKey] = struct{}{}
  815. }
  816. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  817. func (m *AgentMutation) APIKeyCleared() bool {
  818. _, ok := m.clearedFields[agent.FieldAPIKey]
  819. return ok
  820. }
  821. // ResetAPIKey resets all changes to the "api_key" field.
  822. func (m *AgentMutation) ResetAPIKey() {
  823. m.api_key = nil
  824. delete(m.clearedFields, agent.FieldAPIKey)
  825. }
  826. // SetType sets the "type" field.
  827. func (m *AgentMutation) SetType(i int) {
  828. m._type = &i
  829. m.add_type = nil
  830. }
  831. // GetType returns the value of the "type" field in the mutation.
  832. func (m *AgentMutation) GetType() (r int, exists bool) {
  833. v := m._type
  834. if v == nil {
  835. return
  836. }
  837. return *v, true
  838. }
  839. // OldType returns the old "type" field's value of the Agent entity.
  840. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  841. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  842. func (m *AgentMutation) OldType(ctx context.Context) (v int, err error) {
  843. if !m.op.Is(OpUpdateOne) {
  844. return v, errors.New("OldType is only allowed on UpdateOne operations")
  845. }
  846. if m.id == nil || m.oldValue == nil {
  847. return v, errors.New("OldType requires an ID field in the mutation")
  848. }
  849. oldValue, err := m.oldValue(ctx)
  850. if err != nil {
  851. return v, fmt.Errorf("querying old value for OldType: %w", err)
  852. }
  853. return oldValue.Type, nil
  854. }
  855. // AddType adds i to the "type" field.
  856. func (m *AgentMutation) AddType(i int) {
  857. if m.add_type != nil {
  858. *m.add_type += i
  859. } else {
  860. m.add_type = &i
  861. }
  862. }
  863. // AddedType returns the value that was added to the "type" field in this mutation.
  864. func (m *AgentMutation) AddedType() (r int, exists bool) {
  865. v := m.add_type
  866. if v == nil {
  867. return
  868. }
  869. return *v, true
  870. }
  871. // ClearType clears the value of the "type" field.
  872. func (m *AgentMutation) ClearType() {
  873. m._type = nil
  874. m.add_type = nil
  875. m.clearedFields[agent.FieldType] = struct{}{}
  876. }
  877. // TypeCleared returns if the "type" field was cleared in this mutation.
  878. func (m *AgentMutation) TypeCleared() bool {
  879. _, ok := m.clearedFields[agent.FieldType]
  880. return ok
  881. }
  882. // ResetType resets all changes to the "type" field.
  883. func (m *AgentMutation) ResetType() {
  884. m._type = nil
  885. m.add_type = nil
  886. delete(m.clearedFields, agent.FieldType)
  887. }
  888. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  889. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  890. if m.wx_agent == nil {
  891. m.wx_agent = make(map[uint64]struct{})
  892. }
  893. for i := range ids {
  894. m.wx_agent[ids[i]] = struct{}{}
  895. }
  896. }
  897. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  898. func (m *AgentMutation) ClearWxAgent() {
  899. m.clearedwx_agent = true
  900. }
  901. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  902. func (m *AgentMutation) WxAgentCleared() bool {
  903. return m.clearedwx_agent
  904. }
  905. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  906. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  907. if m.removedwx_agent == nil {
  908. m.removedwx_agent = make(map[uint64]struct{})
  909. }
  910. for i := range ids {
  911. delete(m.wx_agent, ids[i])
  912. m.removedwx_agent[ids[i]] = struct{}{}
  913. }
  914. }
  915. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  916. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  917. for id := range m.removedwx_agent {
  918. ids = append(ids, id)
  919. }
  920. return
  921. }
  922. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  923. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  924. for id := range m.wx_agent {
  925. ids = append(ids, id)
  926. }
  927. return
  928. }
  929. // ResetWxAgent resets all changes to the "wx_agent" edge.
  930. func (m *AgentMutation) ResetWxAgent() {
  931. m.wx_agent = nil
  932. m.clearedwx_agent = false
  933. m.removedwx_agent = nil
  934. }
  935. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  936. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  937. if m.token_agent == nil {
  938. m.token_agent = make(map[uint64]struct{})
  939. }
  940. for i := range ids {
  941. m.token_agent[ids[i]] = struct{}{}
  942. }
  943. }
  944. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  945. func (m *AgentMutation) ClearTokenAgent() {
  946. m.clearedtoken_agent = true
  947. }
  948. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  949. func (m *AgentMutation) TokenAgentCleared() bool {
  950. return m.clearedtoken_agent
  951. }
  952. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  953. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  954. if m.removedtoken_agent == nil {
  955. m.removedtoken_agent = make(map[uint64]struct{})
  956. }
  957. for i := range ids {
  958. delete(m.token_agent, ids[i])
  959. m.removedtoken_agent[ids[i]] = struct{}{}
  960. }
  961. }
  962. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  963. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  964. for id := range m.removedtoken_agent {
  965. ids = append(ids, id)
  966. }
  967. return
  968. }
  969. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  970. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  971. for id := range m.token_agent {
  972. ids = append(ids, id)
  973. }
  974. return
  975. }
  976. // ResetTokenAgent resets all changes to the "token_agent" edge.
  977. func (m *AgentMutation) ResetTokenAgent() {
  978. m.token_agent = nil
  979. m.clearedtoken_agent = false
  980. m.removedtoken_agent = nil
  981. }
  982. // AddWaAgentIDs adds the "wa_agent" edge to the Whatsapp entity by ids.
  983. func (m *AgentMutation) AddWaAgentIDs(ids ...uint64) {
  984. if m.wa_agent == nil {
  985. m.wa_agent = make(map[uint64]struct{})
  986. }
  987. for i := range ids {
  988. m.wa_agent[ids[i]] = struct{}{}
  989. }
  990. }
  991. // ClearWaAgent clears the "wa_agent" edge to the Whatsapp entity.
  992. func (m *AgentMutation) ClearWaAgent() {
  993. m.clearedwa_agent = true
  994. }
  995. // WaAgentCleared reports if the "wa_agent" edge to the Whatsapp entity was cleared.
  996. func (m *AgentMutation) WaAgentCleared() bool {
  997. return m.clearedwa_agent
  998. }
  999. // RemoveWaAgentIDs removes the "wa_agent" edge to the Whatsapp entity by IDs.
  1000. func (m *AgentMutation) RemoveWaAgentIDs(ids ...uint64) {
  1001. if m.removedwa_agent == nil {
  1002. m.removedwa_agent = make(map[uint64]struct{})
  1003. }
  1004. for i := range ids {
  1005. delete(m.wa_agent, ids[i])
  1006. m.removedwa_agent[ids[i]] = struct{}{}
  1007. }
  1008. }
  1009. // RemovedWaAgent returns the removed IDs of the "wa_agent" edge to the Whatsapp entity.
  1010. func (m *AgentMutation) RemovedWaAgentIDs() (ids []uint64) {
  1011. for id := range m.removedwa_agent {
  1012. ids = append(ids, id)
  1013. }
  1014. return
  1015. }
  1016. // WaAgentIDs returns the "wa_agent" edge IDs in the mutation.
  1017. func (m *AgentMutation) WaAgentIDs() (ids []uint64) {
  1018. for id := range m.wa_agent {
  1019. ids = append(ids, id)
  1020. }
  1021. return
  1022. }
  1023. // ResetWaAgent resets all changes to the "wa_agent" edge.
  1024. func (m *AgentMutation) ResetWaAgent() {
  1025. m.wa_agent = nil
  1026. m.clearedwa_agent = false
  1027. m.removedwa_agent = nil
  1028. }
  1029. // AddXjsAgentIDs adds the "xjs_agent" edge to the XunjiService entity by ids.
  1030. func (m *AgentMutation) AddXjsAgentIDs(ids ...uint64) {
  1031. if m.xjs_agent == nil {
  1032. m.xjs_agent = make(map[uint64]struct{})
  1033. }
  1034. for i := range ids {
  1035. m.xjs_agent[ids[i]] = struct{}{}
  1036. }
  1037. }
  1038. // ClearXjsAgent clears the "xjs_agent" edge to the XunjiService entity.
  1039. func (m *AgentMutation) ClearXjsAgent() {
  1040. m.clearedxjs_agent = true
  1041. }
  1042. // XjsAgentCleared reports if the "xjs_agent" edge to the XunjiService entity was cleared.
  1043. func (m *AgentMutation) XjsAgentCleared() bool {
  1044. return m.clearedxjs_agent
  1045. }
  1046. // RemoveXjsAgentIDs removes the "xjs_agent" edge to the XunjiService entity by IDs.
  1047. func (m *AgentMutation) RemoveXjsAgentIDs(ids ...uint64) {
  1048. if m.removedxjs_agent == nil {
  1049. m.removedxjs_agent = make(map[uint64]struct{})
  1050. }
  1051. for i := range ids {
  1052. delete(m.xjs_agent, ids[i])
  1053. m.removedxjs_agent[ids[i]] = struct{}{}
  1054. }
  1055. }
  1056. // RemovedXjsAgent returns the removed IDs of the "xjs_agent" edge to the XunjiService entity.
  1057. func (m *AgentMutation) RemovedXjsAgentIDs() (ids []uint64) {
  1058. for id := range m.removedxjs_agent {
  1059. ids = append(ids, id)
  1060. }
  1061. return
  1062. }
  1063. // XjsAgentIDs returns the "xjs_agent" edge IDs in the mutation.
  1064. func (m *AgentMutation) XjsAgentIDs() (ids []uint64) {
  1065. for id := range m.xjs_agent {
  1066. ids = append(ids, id)
  1067. }
  1068. return
  1069. }
  1070. // ResetXjsAgent resets all changes to the "xjs_agent" edge.
  1071. func (m *AgentMutation) ResetXjsAgent() {
  1072. m.xjs_agent = nil
  1073. m.clearedxjs_agent = false
  1074. m.removedxjs_agent = nil
  1075. }
  1076. // AddKeyAgentIDs adds the "key_agent" edge to the ApiKey entity by ids.
  1077. func (m *AgentMutation) AddKeyAgentIDs(ids ...uint64) {
  1078. if m.key_agent == nil {
  1079. m.key_agent = make(map[uint64]struct{})
  1080. }
  1081. for i := range ids {
  1082. m.key_agent[ids[i]] = struct{}{}
  1083. }
  1084. }
  1085. // ClearKeyAgent clears the "key_agent" edge to the ApiKey entity.
  1086. func (m *AgentMutation) ClearKeyAgent() {
  1087. m.clearedkey_agent = true
  1088. }
  1089. // KeyAgentCleared reports if the "key_agent" edge to the ApiKey entity was cleared.
  1090. func (m *AgentMutation) KeyAgentCleared() bool {
  1091. return m.clearedkey_agent
  1092. }
  1093. // RemoveKeyAgentIDs removes the "key_agent" edge to the ApiKey entity by IDs.
  1094. func (m *AgentMutation) RemoveKeyAgentIDs(ids ...uint64) {
  1095. if m.removedkey_agent == nil {
  1096. m.removedkey_agent = make(map[uint64]struct{})
  1097. }
  1098. for i := range ids {
  1099. delete(m.key_agent, ids[i])
  1100. m.removedkey_agent[ids[i]] = struct{}{}
  1101. }
  1102. }
  1103. // RemovedKeyAgent returns the removed IDs of the "key_agent" edge to the ApiKey entity.
  1104. func (m *AgentMutation) RemovedKeyAgentIDs() (ids []uint64) {
  1105. for id := range m.removedkey_agent {
  1106. ids = append(ids, id)
  1107. }
  1108. return
  1109. }
  1110. // KeyAgentIDs returns the "key_agent" edge IDs in the mutation.
  1111. func (m *AgentMutation) KeyAgentIDs() (ids []uint64) {
  1112. for id := range m.key_agent {
  1113. ids = append(ids, id)
  1114. }
  1115. return
  1116. }
  1117. // ResetKeyAgent resets all changes to the "key_agent" edge.
  1118. func (m *AgentMutation) ResetKeyAgent() {
  1119. m.key_agent = nil
  1120. m.clearedkey_agent = false
  1121. m.removedkey_agent = nil
  1122. }
  1123. // Where appends a list predicates to the AgentMutation builder.
  1124. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  1125. m.predicates = append(m.predicates, ps...)
  1126. }
  1127. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  1128. // users can use type-assertion to append predicates that do not depend on any generated package.
  1129. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  1130. p := make([]predicate.Agent, len(ps))
  1131. for i := range ps {
  1132. p[i] = ps[i]
  1133. }
  1134. m.Where(p...)
  1135. }
  1136. // Op returns the operation name.
  1137. func (m *AgentMutation) Op() Op {
  1138. return m.op
  1139. }
  1140. // SetOp allows setting the mutation operation.
  1141. func (m *AgentMutation) SetOp(op Op) {
  1142. m.op = op
  1143. }
  1144. // Type returns the node type of this mutation (Agent).
  1145. func (m *AgentMutation) Type() string {
  1146. return m.typ
  1147. }
  1148. // Fields returns all fields that were changed during this mutation. Note that in
  1149. // order to get all numeric fields that were incremented/decremented, call
  1150. // AddedFields().
  1151. func (m *AgentMutation) Fields() []string {
  1152. fields := make([]string, 0, 15)
  1153. if m.created_at != nil {
  1154. fields = append(fields, agent.FieldCreatedAt)
  1155. }
  1156. if m.updated_at != nil {
  1157. fields = append(fields, agent.FieldUpdatedAt)
  1158. }
  1159. if m.deleted_at != nil {
  1160. fields = append(fields, agent.FieldDeletedAt)
  1161. }
  1162. if m.name != nil {
  1163. fields = append(fields, agent.FieldName)
  1164. }
  1165. if m.role != nil {
  1166. fields = append(fields, agent.FieldRole)
  1167. }
  1168. if m.status != nil {
  1169. fields = append(fields, agent.FieldStatus)
  1170. }
  1171. if m.background != nil {
  1172. fields = append(fields, agent.FieldBackground)
  1173. }
  1174. if m.examples != nil {
  1175. fields = append(fields, agent.FieldExamples)
  1176. }
  1177. if m.organization_id != nil {
  1178. fields = append(fields, agent.FieldOrganizationID)
  1179. }
  1180. if m.dataset_id != nil {
  1181. fields = append(fields, agent.FieldDatasetID)
  1182. }
  1183. if m.collection_id != nil {
  1184. fields = append(fields, agent.FieldCollectionID)
  1185. }
  1186. if m.model != nil {
  1187. fields = append(fields, agent.FieldModel)
  1188. }
  1189. if m.api_base != nil {
  1190. fields = append(fields, agent.FieldAPIBase)
  1191. }
  1192. if m.api_key != nil {
  1193. fields = append(fields, agent.FieldAPIKey)
  1194. }
  1195. if m._type != nil {
  1196. fields = append(fields, agent.FieldType)
  1197. }
  1198. return fields
  1199. }
  1200. // Field returns the value of a field with the given name. The second boolean
  1201. // return value indicates that this field was not set, or was not defined in the
  1202. // schema.
  1203. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  1204. switch name {
  1205. case agent.FieldCreatedAt:
  1206. return m.CreatedAt()
  1207. case agent.FieldUpdatedAt:
  1208. return m.UpdatedAt()
  1209. case agent.FieldDeletedAt:
  1210. return m.DeletedAt()
  1211. case agent.FieldName:
  1212. return m.Name()
  1213. case agent.FieldRole:
  1214. return m.Role()
  1215. case agent.FieldStatus:
  1216. return m.Status()
  1217. case agent.FieldBackground:
  1218. return m.Background()
  1219. case agent.FieldExamples:
  1220. return m.Examples()
  1221. case agent.FieldOrganizationID:
  1222. return m.OrganizationID()
  1223. case agent.FieldDatasetID:
  1224. return m.DatasetID()
  1225. case agent.FieldCollectionID:
  1226. return m.CollectionID()
  1227. case agent.FieldModel:
  1228. return m.Model()
  1229. case agent.FieldAPIBase:
  1230. return m.APIBase()
  1231. case agent.FieldAPIKey:
  1232. return m.APIKey()
  1233. case agent.FieldType:
  1234. return m.GetType()
  1235. }
  1236. return nil, false
  1237. }
  1238. // OldField returns the old value of the field from the database. An error is
  1239. // returned if the mutation operation is not UpdateOne, or the query to the
  1240. // database failed.
  1241. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1242. switch name {
  1243. case agent.FieldCreatedAt:
  1244. return m.OldCreatedAt(ctx)
  1245. case agent.FieldUpdatedAt:
  1246. return m.OldUpdatedAt(ctx)
  1247. case agent.FieldDeletedAt:
  1248. return m.OldDeletedAt(ctx)
  1249. case agent.FieldName:
  1250. return m.OldName(ctx)
  1251. case agent.FieldRole:
  1252. return m.OldRole(ctx)
  1253. case agent.FieldStatus:
  1254. return m.OldStatus(ctx)
  1255. case agent.FieldBackground:
  1256. return m.OldBackground(ctx)
  1257. case agent.FieldExamples:
  1258. return m.OldExamples(ctx)
  1259. case agent.FieldOrganizationID:
  1260. return m.OldOrganizationID(ctx)
  1261. case agent.FieldDatasetID:
  1262. return m.OldDatasetID(ctx)
  1263. case agent.FieldCollectionID:
  1264. return m.OldCollectionID(ctx)
  1265. case agent.FieldModel:
  1266. return m.OldModel(ctx)
  1267. case agent.FieldAPIBase:
  1268. return m.OldAPIBase(ctx)
  1269. case agent.FieldAPIKey:
  1270. return m.OldAPIKey(ctx)
  1271. case agent.FieldType:
  1272. return m.OldType(ctx)
  1273. }
  1274. return nil, fmt.Errorf("unknown Agent field %s", name)
  1275. }
  1276. // SetField sets the value of a field with the given name. It returns an error if
  1277. // the field is not defined in the schema, or if the type mismatched the field
  1278. // type.
  1279. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  1280. switch name {
  1281. case agent.FieldCreatedAt:
  1282. v, ok := value.(time.Time)
  1283. if !ok {
  1284. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1285. }
  1286. m.SetCreatedAt(v)
  1287. return nil
  1288. case agent.FieldUpdatedAt:
  1289. v, ok := value.(time.Time)
  1290. if !ok {
  1291. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1292. }
  1293. m.SetUpdatedAt(v)
  1294. return nil
  1295. case agent.FieldDeletedAt:
  1296. v, ok := value.(time.Time)
  1297. if !ok {
  1298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1299. }
  1300. m.SetDeletedAt(v)
  1301. return nil
  1302. case agent.FieldName:
  1303. v, ok := value.(string)
  1304. if !ok {
  1305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1306. }
  1307. m.SetName(v)
  1308. return nil
  1309. case agent.FieldRole:
  1310. v, ok := value.(string)
  1311. if !ok {
  1312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1313. }
  1314. m.SetRole(v)
  1315. return nil
  1316. case agent.FieldStatus:
  1317. v, ok := value.(int)
  1318. if !ok {
  1319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1320. }
  1321. m.SetStatus(v)
  1322. return nil
  1323. case agent.FieldBackground:
  1324. v, ok := value.(string)
  1325. if !ok {
  1326. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1327. }
  1328. m.SetBackground(v)
  1329. return nil
  1330. case agent.FieldExamples:
  1331. v, ok := value.(string)
  1332. if !ok {
  1333. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1334. }
  1335. m.SetExamples(v)
  1336. return nil
  1337. case agent.FieldOrganizationID:
  1338. v, ok := value.(uint64)
  1339. if !ok {
  1340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1341. }
  1342. m.SetOrganizationID(v)
  1343. return nil
  1344. case agent.FieldDatasetID:
  1345. v, ok := value.(string)
  1346. if !ok {
  1347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1348. }
  1349. m.SetDatasetID(v)
  1350. return nil
  1351. case agent.FieldCollectionID:
  1352. v, ok := value.(string)
  1353. if !ok {
  1354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1355. }
  1356. m.SetCollectionID(v)
  1357. return nil
  1358. case agent.FieldModel:
  1359. v, ok := value.(string)
  1360. if !ok {
  1361. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1362. }
  1363. m.SetModel(v)
  1364. return nil
  1365. case agent.FieldAPIBase:
  1366. v, ok := value.(string)
  1367. if !ok {
  1368. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1369. }
  1370. m.SetAPIBase(v)
  1371. return nil
  1372. case agent.FieldAPIKey:
  1373. v, ok := value.(string)
  1374. if !ok {
  1375. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1376. }
  1377. m.SetAPIKey(v)
  1378. return nil
  1379. case agent.FieldType:
  1380. v, ok := value.(int)
  1381. if !ok {
  1382. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1383. }
  1384. m.SetType(v)
  1385. return nil
  1386. }
  1387. return fmt.Errorf("unknown Agent field %s", name)
  1388. }
  1389. // AddedFields returns all numeric fields that were incremented/decremented during
  1390. // this mutation.
  1391. func (m *AgentMutation) AddedFields() []string {
  1392. var fields []string
  1393. if m.addstatus != nil {
  1394. fields = append(fields, agent.FieldStatus)
  1395. }
  1396. if m.addorganization_id != nil {
  1397. fields = append(fields, agent.FieldOrganizationID)
  1398. }
  1399. if m.add_type != nil {
  1400. fields = append(fields, agent.FieldType)
  1401. }
  1402. return fields
  1403. }
  1404. // AddedField returns the numeric value that was incremented/decremented on a field
  1405. // with the given name. The second boolean return value indicates that this field
  1406. // was not set, or was not defined in the schema.
  1407. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  1408. switch name {
  1409. case agent.FieldStatus:
  1410. return m.AddedStatus()
  1411. case agent.FieldOrganizationID:
  1412. return m.AddedOrganizationID()
  1413. case agent.FieldType:
  1414. return m.AddedType()
  1415. }
  1416. return nil, false
  1417. }
  1418. // AddField adds the value to the field with the given name. It returns an error if
  1419. // the field is not defined in the schema, or if the type mismatched the field
  1420. // type.
  1421. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  1422. switch name {
  1423. case agent.FieldStatus:
  1424. v, ok := value.(int)
  1425. if !ok {
  1426. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1427. }
  1428. m.AddStatus(v)
  1429. return nil
  1430. case agent.FieldOrganizationID:
  1431. v, ok := value.(int64)
  1432. if !ok {
  1433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1434. }
  1435. m.AddOrganizationID(v)
  1436. return nil
  1437. case agent.FieldType:
  1438. v, ok := value.(int)
  1439. if !ok {
  1440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1441. }
  1442. m.AddType(v)
  1443. return nil
  1444. }
  1445. return fmt.Errorf("unknown Agent numeric field %s", name)
  1446. }
  1447. // ClearedFields returns all nullable fields that were cleared during this
  1448. // mutation.
  1449. func (m *AgentMutation) ClearedFields() []string {
  1450. var fields []string
  1451. if m.FieldCleared(agent.FieldDeletedAt) {
  1452. fields = append(fields, agent.FieldDeletedAt)
  1453. }
  1454. if m.FieldCleared(agent.FieldRole) {
  1455. fields = append(fields, agent.FieldRole)
  1456. }
  1457. if m.FieldCleared(agent.FieldStatus) {
  1458. fields = append(fields, agent.FieldStatus)
  1459. }
  1460. if m.FieldCleared(agent.FieldBackground) {
  1461. fields = append(fields, agent.FieldBackground)
  1462. }
  1463. if m.FieldCleared(agent.FieldExamples) {
  1464. fields = append(fields, agent.FieldExamples)
  1465. }
  1466. if m.FieldCleared(agent.FieldModel) {
  1467. fields = append(fields, agent.FieldModel)
  1468. }
  1469. if m.FieldCleared(agent.FieldAPIBase) {
  1470. fields = append(fields, agent.FieldAPIBase)
  1471. }
  1472. if m.FieldCleared(agent.FieldAPIKey) {
  1473. fields = append(fields, agent.FieldAPIKey)
  1474. }
  1475. if m.FieldCleared(agent.FieldType) {
  1476. fields = append(fields, agent.FieldType)
  1477. }
  1478. return fields
  1479. }
  1480. // FieldCleared returns a boolean indicating if a field with the given name was
  1481. // cleared in this mutation.
  1482. func (m *AgentMutation) FieldCleared(name string) bool {
  1483. _, ok := m.clearedFields[name]
  1484. return ok
  1485. }
  1486. // ClearField clears the value of the field with the given name. It returns an
  1487. // error if the field is not defined in the schema.
  1488. func (m *AgentMutation) ClearField(name string) error {
  1489. switch name {
  1490. case agent.FieldDeletedAt:
  1491. m.ClearDeletedAt()
  1492. return nil
  1493. case agent.FieldRole:
  1494. m.ClearRole()
  1495. return nil
  1496. case agent.FieldStatus:
  1497. m.ClearStatus()
  1498. return nil
  1499. case agent.FieldBackground:
  1500. m.ClearBackground()
  1501. return nil
  1502. case agent.FieldExamples:
  1503. m.ClearExamples()
  1504. return nil
  1505. case agent.FieldModel:
  1506. m.ClearModel()
  1507. return nil
  1508. case agent.FieldAPIBase:
  1509. m.ClearAPIBase()
  1510. return nil
  1511. case agent.FieldAPIKey:
  1512. m.ClearAPIKey()
  1513. return nil
  1514. case agent.FieldType:
  1515. m.ClearType()
  1516. return nil
  1517. }
  1518. return fmt.Errorf("unknown Agent nullable field %s", name)
  1519. }
  1520. // ResetField resets all changes in the mutation for the field with the given name.
  1521. // It returns an error if the field is not defined in the schema.
  1522. func (m *AgentMutation) ResetField(name string) error {
  1523. switch name {
  1524. case agent.FieldCreatedAt:
  1525. m.ResetCreatedAt()
  1526. return nil
  1527. case agent.FieldUpdatedAt:
  1528. m.ResetUpdatedAt()
  1529. return nil
  1530. case agent.FieldDeletedAt:
  1531. m.ResetDeletedAt()
  1532. return nil
  1533. case agent.FieldName:
  1534. m.ResetName()
  1535. return nil
  1536. case agent.FieldRole:
  1537. m.ResetRole()
  1538. return nil
  1539. case agent.FieldStatus:
  1540. m.ResetStatus()
  1541. return nil
  1542. case agent.FieldBackground:
  1543. m.ResetBackground()
  1544. return nil
  1545. case agent.FieldExamples:
  1546. m.ResetExamples()
  1547. return nil
  1548. case agent.FieldOrganizationID:
  1549. m.ResetOrganizationID()
  1550. return nil
  1551. case agent.FieldDatasetID:
  1552. m.ResetDatasetID()
  1553. return nil
  1554. case agent.FieldCollectionID:
  1555. m.ResetCollectionID()
  1556. return nil
  1557. case agent.FieldModel:
  1558. m.ResetModel()
  1559. return nil
  1560. case agent.FieldAPIBase:
  1561. m.ResetAPIBase()
  1562. return nil
  1563. case agent.FieldAPIKey:
  1564. m.ResetAPIKey()
  1565. return nil
  1566. case agent.FieldType:
  1567. m.ResetType()
  1568. return nil
  1569. }
  1570. return fmt.Errorf("unknown Agent field %s", name)
  1571. }
  1572. // AddedEdges returns all edge names that were set/added in this mutation.
  1573. func (m *AgentMutation) AddedEdges() []string {
  1574. edges := make([]string, 0, 5)
  1575. if m.wx_agent != nil {
  1576. edges = append(edges, agent.EdgeWxAgent)
  1577. }
  1578. if m.token_agent != nil {
  1579. edges = append(edges, agent.EdgeTokenAgent)
  1580. }
  1581. if m.wa_agent != nil {
  1582. edges = append(edges, agent.EdgeWaAgent)
  1583. }
  1584. if m.xjs_agent != nil {
  1585. edges = append(edges, agent.EdgeXjsAgent)
  1586. }
  1587. if m.key_agent != nil {
  1588. edges = append(edges, agent.EdgeKeyAgent)
  1589. }
  1590. return edges
  1591. }
  1592. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1593. // name in this mutation.
  1594. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1595. switch name {
  1596. case agent.EdgeWxAgent:
  1597. ids := make([]ent.Value, 0, len(m.wx_agent))
  1598. for id := range m.wx_agent {
  1599. ids = append(ids, id)
  1600. }
  1601. return ids
  1602. case agent.EdgeTokenAgent:
  1603. ids := make([]ent.Value, 0, len(m.token_agent))
  1604. for id := range m.token_agent {
  1605. ids = append(ids, id)
  1606. }
  1607. return ids
  1608. case agent.EdgeWaAgent:
  1609. ids := make([]ent.Value, 0, len(m.wa_agent))
  1610. for id := range m.wa_agent {
  1611. ids = append(ids, id)
  1612. }
  1613. return ids
  1614. case agent.EdgeXjsAgent:
  1615. ids := make([]ent.Value, 0, len(m.xjs_agent))
  1616. for id := range m.xjs_agent {
  1617. ids = append(ids, id)
  1618. }
  1619. return ids
  1620. case agent.EdgeKeyAgent:
  1621. ids := make([]ent.Value, 0, len(m.key_agent))
  1622. for id := range m.key_agent {
  1623. ids = append(ids, id)
  1624. }
  1625. return ids
  1626. }
  1627. return nil
  1628. }
  1629. // RemovedEdges returns all edge names that were removed in this mutation.
  1630. func (m *AgentMutation) RemovedEdges() []string {
  1631. edges := make([]string, 0, 5)
  1632. if m.removedwx_agent != nil {
  1633. edges = append(edges, agent.EdgeWxAgent)
  1634. }
  1635. if m.removedtoken_agent != nil {
  1636. edges = append(edges, agent.EdgeTokenAgent)
  1637. }
  1638. if m.removedwa_agent != nil {
  1639. edges = append(edges, agent.EdgeWaAgent)
  1640. }
  1641. if m.removedxjs_agent != nil {
  1642. edges = append(edges, agent.EdgeXjsAgent)
  1643. }
  1644. if m.removedkey_agent != nil {
  1645. edges = append(edges, agent.EdgeKeyAgent)
  1646. }
  1647. return edges
  1648. }
  1649. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1650. // the given name in this mutation.
  1651. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1652. switch name {
  1653. case agent.EdgeWxAgent:
  1654. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1655. for id := range m.removedwx_agent {
  1656. ids = append(ids, id)
  1657. }
  1658. return ids
  1659. case agent.EdgeTokenAgent:
  1660. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1661. for id := range m.removedtoken_agent {
  1662. ids = append(ids, id)
  1663. }
  1664. return ids
  1665. case agent.EdgeWaAgent:
  1666. ids := make([]ent.Value, 0, len(m.removedwa_agent))
  1667. for id := range m.removedwa_agent {
  1668. ids = append(ids, id)
  1669. }
  1670. return ids
  1671. case agent.EdgeXjsAgent:
  1672. ids := make([]ent.Value, 0, len(m.removedxjs_agent))
  1673. for id := range m.removedxjs_agent {
  1674. ids = append(ids, id)
  1675. }
  1676. return ids
  1677. case agent.EdgeKeyAgent:
  1678. ids := make([]ent.Value, 0, len(m.removedkey_agent))
  1679. for id := range m.removedkey_agent {
  1680. ids = append(ids, id)
  1681. }
  1682. return ids
  1683. }
  1684. return nil
  1685. }
  1686. // ClearedEdges returns all edge names that were cleared in this mutation.
  1687. func (m *AgentMutation) ClearedEdges() []string {
  1688. edges := make([]string, 0, 5)
  1689. if m.clearedwx_agent {
  1690. edges = append(edges, agent.EdgeWxAgent)
  1691. }
  1692. if m.clearedtoken_agent {
  1693. edges = append(edges, agent.EdgeTokenAgent)
  1694. }
  1695. if m.clearedwa_agent {
  1696. edges = append(edges, agent.EdgeWaAgent)
  1697. }
  1698. if m.clearedxjs_agent {
  1699. edges = append(edges, agent.EdgeXjsAgent)
  1700. }
  1701. if m.clearedkey_agent {
  1702. edges = append(edges, agent.EdgeKeyAgent)
  1703. }
  1704. return edges
  1705. }
  1706. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1707. // was cleared in this mutation.
  1708. func (m *AgentMutation) EdgeCleared(name string) bool {
  1709. switch name {
  1710. case agent.EdgeWxAgent:
  1711. return m.clearedwx_agent
  1712. case agent.EdgeTokenAgent:
  1713. return m.clearedtoken_agent
  1714. case agent.EdgeWaAgent:
  1715. return m.clearedwa_agent
  1716. case agent.EdgeXjsAgent:
  1717. return m.clearedxjs_agent
  1718. case agent.EdgeKeyAgent:
  1719. return m.clearedkey_agent
  1720. }
  1721. return false
  1722. }
  1723. // ClearEdge clears the value of the edge with the given name. It returns an error
  1724. // if that edge is not defined in the schema.
  1725. func (m *AgentMutation) ClearEdge(name string) error {
  1726. switch name {
  1727. }
  1728. return fmt.Errorf("unknown Agent unique edge %s", name)
  1729. }
  1730. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1731. // It returns an error if the edge is not defined in the schema.
  1732. func (m *AgentMutation) ResetEdge(name string) error {
  1733. switch name {
  1734. case agent.EdgeWxAgent:
  1735. m.ResetWxAgent()
  1736. return nil
  1737. case agent.EdgeTokenAgent:
  1738. m.ResetTokenAgent()
  1739. return nil
  1740. case agent.EdgeWaAgent:
  1741. m.ResetWaAgent()
  1742. return nil
  1743. case agent.EdgeXjsAgent:
  1744. m.ResetXjsAgent()
  1745. return nil
  1746. case agent.EdgeKeyAgent:
  1747. m.ResetKeyAgent()
  1748. return nil
  1749. }
  1750. return fmt.Errorf("unknown Agent edge %s", name)
  1751. }
  1752. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1753. type AgentBaseMutation struct {
  1754. config
  1755. op Op
  1756. typ string
  1757. id *string
  1758. q *string
  1759. a *string
  1760. chunk_index *uint64
  1761. addchunk_index *int64
  1762. indexes *[]string
  1763. appendindexes []string
  1764. dataset_id *string
  1765. collection_id *string
  1766. source_name *string
  1767. can_write *[]bool
  1768. appendcan_write []bool
  1769. is_owner *[]bool
  1770. appendis_owner []bool
  1771. clearedFields map[string]struct{}
  1772. wx_agent map[uint64]struct{}
  1773. removedwx_agent map[uint64]struct{}
  1774. clearedwx_agent bool
  1775. done bool
  1776. oldValue func(context.Context) (*AgentBase, error)
  1777. predicates []predicate.AgentBase
  1778. }
  1779. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1780. // agentbaseOption allows management of the mutation configuration using functional options.
  1781. type agentbaseOption func(*AgentBaseMutation)
  1782. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1783. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1784. m := &AgentBaseMutation{
  1785. config: c,
  1786. op: op,
  1787. typ: TypeAgentBase,
  1788. clearedFields: make(map[string]struct{}),
  1789. }
  1790. for _, opt := range opts {
  1791. opt(m)
  1792. }
  1793. return m
  1794. }
  1795. // withAgentBaseID sets the ID field of the mutation.
  1796. func withAgentBaseID(id string) agentbaseOption {
  1797. return func(m *AgentBaseMutation) {
  1798. var (
  1799. err error
  1800. once sync.Once
  1801. value *AgentBase
  1802. )
  1803. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1804. once.Do(func() {
  1805. if m.done {
  1806. err = errors.New("querying old values post mutation is not allowed")
  1807. } else {
  1808. value, err = m.Client().AgentBase.Get(ctx, id)
  1809. }
  1810. })
  1811. return value, err
  1812. }
  1813. m.id = &id
  1814. }
  1815. }
  1816. // withAgentBase sets the old AgentBase of the mutation.
  1817. func withAgentBase(node *AgentBase) agentbaseOption {
  1818. return func(m *AgentBaseMutation) {
  1819. m.oldValue = func(context.Context) (*AgentBase, error) {
  1820. return node, nil
  1821. }
  1822. m.id = &node.ID
  1823. }
  1824. }
  1825. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1826. // executed in a transaction (ent.Tx), a transactional client is returned.
  1827. func (m AgentBaseMutation) Client() *Client {
  1828. client := &Client{config: m.config}
  1829. client.init()
  1830. return client
  1831. }
  1832. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1833. // it returns an error otherwise.
  1834. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1835. if _, ok := m.driver.(*txDriver); !ok {
  1836. return nil, errors.New("ent: mutation is not running in a transaction")
  1837. }
  1838. tx := &Tx{config: m.config}
  1839. tx.init()
  1840. return tx, nil
  1841. }
  1842. // SetID sets the value of the id field. Note that this
  1843. // operation is only accepted on creation of AgentBase entities.
  1844. func (m *AgentBaseMutation) SetID(id string) {
  1845. m.id = &id
  1846. }
  1847. // ID returns the ID value in the mutation. Note that the ID is only available
  1848. // if it was provided to the builder or after it was returned from the database.
  1849. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1850. if m.id == nil {
  1851. return
  1852. }
  1853. return *m.id, true
  1854. }
  1855. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1856. // That means, if the mutation is applied within a transaction with an isolation level such
  1857. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1858. // or updated by the mutation.
  1859. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1860. switch {
  1861. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1862. id, exists := m.ID()
  1863. if exists {
  1864. return []string{id}, nil
  1865. }
  1866. fallthrough
  1867. case m.op.Is(OpUpdate | OpDelete):
  1868. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1869. default:
  1870. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1871. }
  1872. }
  1873. // SetQ sets the "q" field.
  1874. func (m *AgentBaseMutation) SetQ(s string) {
  1875. m.q = &s
  1876. }
  1877. // Q returns the value of the "q" field in the mutation.
  1878. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1879. v := m.q
  1880. if v == nil {
  1881. return
  1882. }
  1883. return *v, true
  1884. }
  1885. // OldQ returns the old "q" field's value of the AgentBase entity.
  1886. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1887. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1888. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1889. if !m.op.Is(OpUpdateOne) {
  1890. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1891. }
  1892. if m.id == nil || m.oldValue == nil {
  1893. return v, errors.New("OldQ requires an ID field in the mutation")
  1894. }
  1895. oldValue, err := m.oldValue(ctx)
  1896. if err != nil {
  1897. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1898. }
  1899. return oldValue.Q, nil
  1900. }
  1901. // ClearQ clears the value of the "q" field.
  1902. func (m *AgentBaseMutation) ClearQ() {
  1903. m.q = nil
  1904. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1905. }
  1906. // QCleared returns if the "q" field was cleared in this mutation.
  1907. func (m *AgentBaseMutation) QCleared() bool {
  1908. _, ok := m.clearedFields[agentbase.FieldQ]
  1909. return ok
  1910. }
  1911. // ResetQ resets all changes to the "q" field.
  1912. func (m *AgentBaseMutation) ResetQ() {
  1913. m.q = nil
  1914. delete(m.clearedFields, agentbase.FieldQ)
  1915. }
  1916. // SetA sets the "a" field.
  1917. func (m *AgentBaseMutation) SetA(s string) {
  1918. m.a = &s
  1919. }
  1920. // A returns the value of the "a" field in the mutation.
  1921. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1922. v := m.a
  1923. if v == nil {
  1924. return
  1925. }
  1926. return *v, true
  1927. }
  1928. // OldA returns the old "a" field's value of the AgentBase entity.
  1929. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1930. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1931. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1932. if !m.op.Is(OpUpdateOne) {
  1933. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1934. }
  1935. if m.id == nil || m.oldValue == nil {
  1936. return v, errors.New("OldA requires an ID field in the mutation")
  1937. }
  1938. oldValue, err := m.oldValue(ctx)
  1939. if err != nil {
  1940. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1941. }
  1942. return oldValue.A, nil
  1943. }
  1944. // ClearA clears the value of the "a" field.
  1945. func (m *AgentBaseMutation) ClearA() {
  1946. m.a = nil
  1947. m.clearedFields[agentbase.FieldA] = struct{}{}
  1948. }
  1949. // ACleared returns if the "a" field was cleared in this mutation.
  1950. func (m *AgentBaseMutation) ACleared() bool {
  1951. _, ok := m.clearedFields[agentbase.FieldA]
  1952. return ok
  1953. }
  1954. // ResetA resets all changes to the "a" field.
  1955. func (m *AgentBaseMutation) ResetA() {
  1956. m.a = nil
  1957. delete(m.clearedFields, agentbase.FieldA)
  1958. }
  1959. // SetChunkIndex sets the "chunk_index" field.
  1960. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1961. m.chunk_index = &u
  1962. m.addchunk_index = nil
  1963. }
  1964. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1965. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1966. v := m.chunk_index
  1967. if v == nil {
  1968. return
  1969. }
  1970. return *v, true
  1971. }
  1972. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1973. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1974. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1975. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1976. if !m.op.Is(OpUpdateOne) {
  1977. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1978. }
  1979. if m.id == nil || m.oldValue == nil {
  1980. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1981. }
  1982. oldValue, err := m.oldValue(ctx)
  1983. if err != nil {
  1984. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1985. }
  1986. return oldValue.ChunkIndex, nil
  1987. }
  1988. // AddChunkIndex adds u to the "chunk_index" field.
  1989. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1990. if m.addchunk_index != nil {
  1991. *m.addchunk_index += u
  1992. } else {
  1993. m.addchunk_index = &u
  1994. }
  1995. }
  1996. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1997. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1998. v := m.addchunk_index
  1999. if v == nil {
  2000. return
  2001. }
  2002. return *v, true
  2003. }
  2004. // ResetChunkIndex resets all changes to the "chunk_index" field.
  2005. func (m *AgentBaseMutation) ResetChunkIndex() {
  2006. m.chunk_index = nil
  2007. m.addchunk_index = nil
  2008. }
  2009. // SetIndexes sets the "indexes" field.
  2010. func (m *AgentBaseMutation) SetIndexes(s []string) {
  2011. m.indexes = &s
  2012. m.appendindexes = nil
  2013. }
  2014. // Indexes returns the value of the "indexes" field in the mutation.
  2015. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  2016. v := m.indexes
  2017. if v == nil {
  2018. return
  2019. }
  2020. return *v, true
  2021. }
  2022. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  2023. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2024. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2025. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  2026. if !m.op.Is(OpUpdateOne) {
  2027. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  2028. }
  2029. if m.id == nil || m.oldValue == nil {
  2030. return v, errors.New("OldIndexes requires an ID field in the mutation")
  2031. }
  2032. oldValue, err := m.oldValue(ctx)
  2033. if err != nil {
  2034. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  2035. }
  2036. return oldValue.Indexes, nil
  2037. }
  2038. // AppendIndexes adds s to the "indexes" field.
  2039. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  2040. m.appendindexes = append(m.appendindexes, s...)
  2041. }
  2042. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  2043. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  2044. if len(m.appendindexes) == 0 {
  2045. return nil, false
  2046. }
  2047. return m.appendindexes, true
  2048. }
  2049. // ClearIndexes clears the value of the "indexes" field.
  2050. func (m *AgentBaseMutation) ClearIndexes() {
  2051. m.indexes = nil
  2052. m.appendindexes = nil
  2053. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  2054. }
  2055. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  2056. func (m *AgentBaseMutation) IndexesCleared() bool {
  2057. _, ok := m.clearedFields[agentbase.FieldIndexes]
  2058. return ok
  2059. }
  2060. // ResetIndexes resets all changes to the "indexes" field.
  2061. func (m *AgentBaseMutation) ResetIndexes() {
  2062. m.indexes = nil
  2063. m.appendindexes = nil
  2064. delete(m.clearedFields, agentbase.FieldIndexes)
  2065. }
  2066. // SetDatasetID sets the "dataset_id" field.
  2067. func (m *AgentBaseMutation) SetDatasetID(s string) {
  2068. m.dataset_id = &s
  2069. }
  2070. // DatasetID returns the value of the "dataset_id" field in the mutation.
  2071. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  2072. v := m.dataset_id
  2073. if v == nil {
  2074. return
  2075. }
  2076. return *v, true
  2077. }
  2078. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  2079. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2080. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2081. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  2082. if !m.op.Is(OpUpdateOne) {
  2083. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  2084. }
  2085. if m.id == nil || m.oldValue == nil {
  2086. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  2087. }
  2088. oldValue, err := m.oldValue(ctx)
  2089. if err != nil {
  2090. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  2091. }
  2092. return oldValue.DatasetID, nil
  2093. }
  2094. // ClearDatasetID clears the value of the "dataset_id" field.
  2095. func (m *AgentBaseMutation) ClearDatasetID() {
  2096. m.dataset_id = nil
  2097. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  2098. }
  2099. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  2100. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  2101. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  2102. return ok
  2103. }
  2104. // ResetDatasetID resets all changes to the "dataset_id" field.
  2105. func (m *AgentBaseMutation) ResetDatasetID() {
  2106. m.dataset_id = nil
  2107. delete(m.clearedFields, agentbase.FieldDatasetID)
  2108. }
  2109. // SetCollectionID sets the "collection_id" field.
  2110. func (m *AgentBaseMutation) SetCollectionID(s string) {
  2111. m.collection_id = &s
  2112. }
  2113. // CollectionID returns the value of the "collection_id" field in the mutation.
  2114. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  2115. v := m.collection_id
  2116. if v == nil {
  2117. return
  2118. }
  2119. return *v, true
  2120. }
  2121. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  2122. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2123. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2124. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  2125. if !m.op.Is(OpUpdateOne) {
  2126. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  2127. }
  2128. if m.id == nil || m.oldValue == nil {
  2129. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  2130. }
  2131. oldValue, err := m.oldValue(ctx)
  2132. if err != nil {
  2133. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  2134. }
  2135. return oldValue.CollectionID, nil
  2136. }
  2137. // ClearCollectionID clears the value of the "collection_id" field.
  2138. func (m *AgentBaseMutation) ClearCollectionID() {
  2139. m.collection_id = nil
  2140. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  2141. }
  2142. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  2143. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  2144. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  2145. return ok
  2146. }
  2147. // ResetCollectionID resets all changes to the "collection_id" field.
  2148. func (m *AgentBaseMutation) ResetCollectionID() {
  2149. m.collection_id = nil
  2150. delete(m.clearedFields, agentbase.FieldCollectionID)
  2151. }
  2152. // SetSourceName sets the "source_name" field.
  2153. func (m *AgentBaseMutation) SetSourceName(s string) {
  2154. m.source_name = &s
  2155. }
  2156. // SourceName returns the value of the "source_name" field in the mutation.
  2157. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  2158. v := m.source_name
  2159. if v == nil {
  2160. return
  2161. }
  2162. return *v, true
  2163. }
  2164. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  2165. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2166. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2167. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  2168. if !m.op.Is(OpUpdateOne) {
  2169. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  2170. }
  2171. if m.id == nil || m.oldValue == nil {
  2172. return v, errors.New("OldSourceName requires an ID field in the mutation")
  2173. }
  2174. oldValue, err := m.oldValue(ctx)
  2175. if err != nil {
  2176. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  2177. }
  2178. return oldValue.SourceName, nil
  2179. }
  2180. // ClearSourceName clears the value of the "source_name" field.
  2181. func (m *AgentBaseMutation) ClearSourceName() {
  2182. m.source_name = nil
  2183. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  2184. }
  2185. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  2186. func (m *AgentBaseMutation) SourceNameCleared() bool {
  2187. _, ok := m.clearedFields[agentbase.FieldSourceName]
  2188. return ok
  2189. }
  2190. // ResetSourceName resets all changes to the "source_name" field.
  2191. func (m *AgentBaseMutation) ResetSourceName() {
  2192. m.source_name = nil
  2193. delete(m.clearedFields, agentbase.FieldSourceName)
  2194. }
  2195. // SetCanWrite sets the "can_write" field.
  2196. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  2197. m.can_write = &b
  2198. m.appendcan_write = nil
  2199. }
  2200. // CanWrite returns the value of the "can_write" field in the mutation.
  2201. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  2202. v := m.can_write
  2203. if v == nil {
  2204. return
  2205. }
  2206. return *v, true
  2207. }
  2208. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  2209. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2210. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2211. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  2212. if !m.op.Is(OpUpdateOne) {
  2213. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  2214. }
  2215. if m.id == nil || m.oldValue == nil {
  2216. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  2217. }
  2218. oldValue, err := m.oldValue(ctx)
  2219. if err != nil {
  2220. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  2221. }
  2222. return oldValue.CanWrite, nil
  2223. }
  2224. // AppendCanWrite adds b to the "can_write" field.
  2225. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  2226. m.appendcan_write = append(m.appendcan_write, b...)
  2227. }
  2228. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  2229. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  2230. if len(m.appendcan_write) == 0 {
  2231. return nil, false
  2232. }
  2233. return m.appendcan_write, true
  2234. }
  2235. // ClearCanWrite clears the value of the "can_write" field.
  2236. func (m *AgentBaseMutation) ClearCanWrite() {
  2237. m.can_write = nil
  2238. m.appendcan_write = nil
  2239. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  2240. }
  2241. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  2242. func (m *AgentBaseMutation) CanWriteCleared() bool {
  2243. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  2244. return ok
  2245. }
  2246. // ResetCanWrite resets all changes to the "can_write" field.
  2247. func (m *AgentBaseMutation) ResetCanWrite() {
  2248. m.can_write = nil
  2249. m.appendcan_write = nil
  2250. delete(m.clearedFields, agentbase.FieldCanWrite)
  2251. }
  2252. // SetIsOwner sets the "is_owner" field.
  2253. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  2254. m.is_owner = &b
  2255. m.appendis_owner = nil
  2256. }
  2257. // IsOwner returns the value of the "is_owner" field in the mutation.
  2258. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  2259. v := m.is_owner
  2260. if v == nil {
  2261. return
  2262. }
  2263. return *v, true
  2264. }
  2265. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  2266. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2267. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2268. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  2269. if !m.op.Is(OpUpdateOne) {
  2270. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  2271. }
  2272. if m.id == nil || m.oldValue == nil {
  2273. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  2274. }
  2275. oldValue, err := m.oldValue(ctx)
  2276. if err != nil {
  2277. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  2278. }
  2279. return oldValue.IsOwner, nil
  2280. }
  2281. // AppendIsOwner adds b to the "is_owner" field.
  2282. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  2283. m.appendis_owner = append(m.appendis_owner, b...)
  2284. }
  2285. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  2286. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  2287. if len(m.appendis_owner) == 0 {
  2288. return nil, false
  2289. }
  2290. return m.appendis_owner, true
  2291. }
  2292. // ClearIsOwner clears the value of the "is_owner" field.
  2293. func (m *AgentBaseMutation) ClearIsOwner() {
  2294. m.is_owner = nil
  2295. m.appendis_owner = nil
  2296. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  2297. }
  2298. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  2299. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  2300. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  2301. return ok
  2302. }
  2303. // ResetIsOwner resets all changes to the "is_owner" field.
  2304. func (m *AgentBaseMutation) ResetIsOwner() {
  2305. m.is_owner = nil
  2306. m.appendis_owner = nil
  2307. delete(m.clearedFields, agentbase.FieldIsOwner)
  2308. }
  2309. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  2310. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  2311. if m.wx_agent == nil {
  2312. m.wx_agent = make(map[uint64]struct{})
  2313. }
  2314. for i := range ids {
  2315. m.wx_agent[ids[i]] = struct{}{}
  2316. }
  2317. }
  2318. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  2319. func (m *AgentBaseMutation) ClearWxAgent() {
  2320. m.clearedwx_agent = true
  2321. }
  2322. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  2323. func (m *AgentBaseMutation) WxAgentCleared() bool {
  2324. return m.clearedwx_agent
  2325. }
  2326. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  2327. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  2328. if m.removedwx_agent == nil {
  2329. m.removedwx_agent = make(map[uint64]struct{})
  2330. }
  2331. for i := range ids {
  2332. delete(m.wx_agent, ids[i])
  2333. m.removedwx_agent[ids[i]] = struct{}{}
  2334. }
  2335. }
  2336. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  2337. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  2338. for id := range m.removedwx_agent {
  2339. ids = append(ids, id)
  2340. }
  2341. return
  2342. }
  2343. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  2344. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  2345. for id := range m.wx_agent {
  2346. ids = append(ids, id)
  2347. }
  2348. return
  2349. }
  2350. // ResetWxAgent resets all changes to the "wx_agent" edge.
  2351. func (m *AgentBaseMutation) ResetWxAgent() {
  2352. m.wx_agent = nil
  2353. m.clearedwx_agent = false
  2354. m.removedwx_agent = nil
  2355. }
  2356. // Where appends a list predicates to the AgentBaseMutation builder.
  2357. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  2358. m.predicates = append(m.predicates, ps...)
  2359. }
  2360. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  2361. // users can use type-assertion to append predicates that do not depend on any generated package.
  2362. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  2363. p := make([]predicate.AgentBase, len(ps))
  2364. for i := range ps {
  2365. p[i] = ps[i]
  2366. }
  2367. m.Where(p...)
  2368. }
  2369. // Op returns the operation name.
  2370. func (m *AgentBaseMutation) Op() Op {
  2371. return m.op
  2372. }
  2373. // SetOp allows setting the mutation operation.
  2374. func (m *AgentBaseMutation) SetOp(op Op) {
  2375. m.op = op
  2376. }
  2377. // Type returns the node type of this mutation (AgentBase).
  2378. func (m *AgentBaseMutation) Type() string {
  2379. return m.typ
  2380. }
  2381. // Fields returns all fields that were changed during this mutation. Note that in
  2382. // order to get all numeric fields that were incremented/decremented, call
  2383. // AddedFields().
  2384. func (m *AgentBaseMutation) Fields() []string {
  2385. fields := make([]string, 0, 9)
  2386. if m.q != nil {
  2387. fields = append(fields, agentbase.FieldQ)
  2388. }
  2389. if m.a != nil {
  2390. fields = append(fields, agentbase.FieldA)
  2391. }
  2392. if m.chunk_index != nil {
  2393. fields = append(fields, agentbase.FieldChunkIndex)
  2394. }
  2395. if m.indexes != nil {
  2396. fields = append(fields, agentbase.FieldIndexes)
  2397. }
  2398. if m.dataset_id != nil {
  2399. fields = append(fields, agentbase.FieldDatasetID)
  2400. }
  2401. if m.collection_id != nil {
  2402. fields = append(fields, agentbase.FieldCollectionID)
  2403. }
  2404. if m.source_name != nil {
  2405. fields = append(fields, agentbase.FieldSourceName)
  2406. }
  2407. if m.can_write != nil {
  2408. fields = append(fields, agentbase.FieldCanWrite)
  2409. }
  2410. if m.is_owner != nil {
  2411. fields = append(fields, agentbase.FieldIsOwner)
  2412. }
  2413. return fields
  2414. }
  2415. // Field returns the value of a field with the given name. The second boolean
  2416. // return value indicates that this field was not set, or was not defined in the
  2417. // schema.
  2418. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  2419. switch name {
  2420. case agentbase.FieldQ:
  2421. return m.Q()
  2422. case agentbase.FieldA:
  2423. return m.A()
  2424. case agentbase.FieldChunkIndex:
  2425. return m.ChunkIndex()
  2426. case agentbase.FieldIndexes:
  2427. return m.Indexes()
  2428. case agentbase.FieldDatasetID:
  2429. return m.DatasetID()
  2430. case agentbase.FieldCollectionID:
  2431. return m.CollectionID()
  2432. case agentbase.FieldSourceName:
  2433. return m.SourceName()
  2434. case agentbase.FieldCanWrite:
  2435. return m.CanWrite()
  2436. case agentbase.FieldIsOwner:
  2437. return m.IsOwner()
  2438. }
  2439. return nil, false
  2440. }
  2441. // OldField returns the old value of the field from the database. An error is
  2442. // returned if the mutation operation is not UpdateOne, or the query to the
  2443. // database failed.
  2444. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2445. switch name {
  2446. case agentbase.FieldQ:
  2447. return m.OldQ(ctx)
  2448. case agentbase.FieldA:
  2449. return m.OldA(ctx)
  2450. case agentbase.FieldChunkIndex:
  2451. return m.OldChunkIndex(ctx)
  2452. case agentbase.FieldIndexes:
  2453. return m.OldIndexes(ctx)
  2454. case agentbase.FieldDatasetID:
  2455. return m.OldDatasetID(ctx)
  2456. case agentbase.FieldCollectionID:
  2457. return m.OldCollectionID(ctx)
  2458. case agentbase.FieldSourceName:
  2459. return m.OldSourceName(ctx)
  2460. case agentbase.FieldCanWrite:
  2461. return m.OldCanWrite(ctx)
  2462. case agentbase.FieldIsOwner:
  2463. return m.OldIsOwner(ctx)
  2464. }
  2465. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  2466. }
  2467. // SetField sets the value of a field with the given name. It returns an error if
  2468. // the field is not defined in the schema, or if the type mismatched the field
  2469. // type.
  2470. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  2471. switch name {
  2472. case agentbase.FieldQ:
  2473. v, ok := value.(string)
  2474. if !ok {
  2475. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2476. }
  2477. m.SetQ(v)
  2478. return nil
  2479. case agentbase.FieldA:
  2480. v, ok := value.(string)
  2481. if !ok {
  2482. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2483. }
  2484. m.SetA(v)
  2485. return nil
  2486. case agentbase.FieldChunkIndex:
  2487. v, ok := value.(uint64)
  2488. if !ok {
  2489. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2490. }
  2491. m.SetChunkIndex(v)
  2492. return nil
  2493. case agentbase.FieldIndexes:
  2494. v, ok := value.([]string)
  2495. if !ok {
  2496. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2497. }
  2498. m.SetIndexes(v)
  2499. return nil
  2500. case agentbase.FieldDatasetID:
  2501. v, ok := value.(string)
  2502. if !ok {
  2503. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2504. }
  2505. m.SetDatasetID(v)
  2506. return nil
  2507. case agentbase.FieldCollectionID:
  2508. v, ok := value.(string)
  2509. if !ok {
  2510. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2511. }
  2512. m.SetCollectionID(v)
  2513. return nil
  2514. case agentbase.FieldSourceName:
  2515. v, ok := value.(string)
  2516. if !ok {
  2517. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2518. }
  2519. m.SetSourceName(v)
  2520. return nil
  2521. case agentbase.FieldCanWrite:
  2522. v, ok := value.([]bool)
  2523. if !ok {
  2524. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2525. }
  2526. m.SetCanWrite(v)
  2527. return nil
  2528. case agentbase.FieldIsOwner:
  2529. v, ok := value.([]bool)
  2530. if !ok {
  2531. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2532. }
  2533. m.SetIsOwner(v)
  2534. return nil
  2535. }
  2536. return fmt.Errorf("unknown AgentBase field %s", name)
  2537. }
  2538. // AddedFields returns all numeric fields that were incremented/decremented during
  2539. // this mutation.
  2540. func (m *AgentBaseMutation) AddedFields() []string {
  2541. var fields []string
  2542. if m.addchunk_index != nil {
  2543. fields = append(fields, agentbase.FieldChunkIndex)
  2544. }
  2545. return fields
  2546. }
  2547. // AddedField returns the numeric value that was incremented/decremented on a field
  2548. // with the given name. The second boolean return value indicates that this field
  2549. // was not set, or was not defined in the schema.
  2550. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  2551. switch name {
  2552. case agentbase.FieldChunkIndex:
  2553. return m.AddedChunkIndex()
  2554. }
  2555. return nil, false
  2556. }
  2557. // AddField adds the value to the field with the given name. It returns an error if
  2558. // the field is not defined in the schema, or if the type mismatched the field
  2559. // type.
  2560. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  2561. switch name {
  2562. case agentbase.FieldChunkIndex:
  2563. v, ok := value.(int64)
  2564. if !ok {
  2565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2566. }
  2567. m.AddChunkIndex(v)
  2568. return nil
  2569. }
  2570. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  2571. }
  2572. // ClearedFields returns all nullable fields that were cleared during this
  2573. // mutation.
  2574. func (m *AgentBaseMutation) ClearedFields() []string {
  2575. var fields []string
  2576. if m.FieldCleared(agentbase.FieldQ) {
  2577. fields = append(fields, agentbase.FieldQ)
  2578. }
  2579. if m.FieldCleared(agentbase.FieldA) {
  2580. fields = append(fields, agentbase.FieldA)
  2581. }
  2582. if m.FieldCleared(agentbase.FieldIndexes) {
  2583. fields = append(fields, agentbase.FieldIndexes)
  2584. }
  2585. if m.FieldCleared(agentbase.FieldDatasetID) {
  2586. fields = append(fields, agentbase.FieldDatasetID)
  2587. }
  2588. if m.FieldCleared(agentbase.FieldCollectionID) {
  2589. fields = append(fields, agentbase.FieldCollectionID)
  2590. }
  2591. if m.FieldCleared(agentbase.FieldSourceName) {
  2592. fields = append(fields, agentbase.FieldSourceName)
  2593. }
  2594. if m.FieldCleared(agentbase.FieldCanWrite) {
  2595. fields = append(fields, agentbase.FieldCanWrite)
  2596. }
  2597. if m.FieldCleared(agentbase.FieldIsOwner) {
  2598. fields = append(fields, agentbase.FieldIsOwner)
  2599. }
  2600. return fields
  2601. }
  2602. // FieldCleared returns a boolean indicating if a field with the given name was
  2603. // cleared in this mutation.
  2604. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2605. _, ok := m.clearedFields[name]
  2606. return ok
  2607. }
  2608. // ClearField clears the value of the field with the given name. It returns an
  2609. // error if the field is not defined in the schema.
  2610. func (m *AgentBaseMutation) ClearField(name string) error {
  2611. switch name {
  2612. case agentbase.FieldQ:
  2613. m.ClearQ()
  2614. return nil
  2615. case agentbase.FieldA:
  2616. m.ClearA()
  2617. return nil
  2618. case agentbase.FieldIndexes:
  2619. m.ClearIndexes()
  2620. return nil
  2621. case agentbase.FieldDatasetID:
  2622. m.ClearDatasetID()
  2623. return nil
  2624. case agentbase.FieldCollectionID:
  2625. m.ClearCollectionID()
  2626. return nil
  2627. case agentbase.FieldSourceName:
  2628. m.ClearSourceName()
  2629. return nil
  2630. case agentbase.FieldCanWrite:
  2631. m.ClearCanWrite()
  2632. return nil
  2633. case agentbase.FieldIsOwner:
  2634. m.ClearIsOwner()
  2635. return nil
  2636. }
  2637. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2638. }
  2639. // ResetField resets all changes in the mutation for the field with the given name.
  2640. // It returns an error if the field is not defined in the schema.
  2641. func (m *AgentBaseMutation) ResetField(name string) error {
  2642. switch name {
  2643. case agentbase.FieldQ:
  2644. m.ResetQ()
  2645. return nil
  2646. case agentbase.FieldA:
  2647. m.ResetA()
  2648. return nil
  2649. case agentbase.FieldChunkIndex:
  2650. m.ResetChunkIndex()
  2651. return nil
  2652. case agentbase.FieldIndexes:
  2653. m.ResetIndexes()
  2654. return nil
  2655. case agentbase.FieldDatasetID:
  2656. m.ResetDatasetID()
  2657. return nil
  2658. case agentbase.FieldCollectionID:
  2659. m.ResetCollectionID()
  2660. return nil
  2661. case agentbase.FieldSourceName:
  2662. m.ResetSourceName()
  2663. return nil
  2664. case agentbase.FieldCanWrite:
  2665. m.ResetCanWrite()
  2666. return nil
  2667. case agentbase.FieldIsOwner:
  2668. m.ResetIsOwner()
  2669. return nil
  2670. }
  2671. return fmt.Errorf("unknown AgentBase field %s", name)
  2672. }
  2673. // AddedEdges returns all edge names that were set/added in this mutation.
  2674. func (m *AgentBaseMutation) AddedEdges() []string {
  2675. edges := make([]string, 0, 1)
  2676. if m.wx_agent != nil {
  2677. edges = append(edges, agentbase.EdgeWxAgent)
  2678. }
  2679. return edges
  2680. }
  2681. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2682. // name in this mutation.
  2683. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2684. switch name {
  2685. case agentbase.EdgeWxAgent:
  2686. ids := make([]ent.Value, 0, len(m.wx_agent))
  2687. for id := range m.wx_agent {
  2688. ids = append(ids, id)
  2689. }
  2690. return ids
  2691. }
  2692. return nil
  2693. }
  2694. // RemovedEdges returns all edge names that were removed in this mutation.
  2695. func (m *AgentBaseMutation) RemovedEdges() []string {
  2696. edges := make([]string, 0, 1)
  2697. if m.removedwx_agent != nil {
  2698. edges = append(edges, agentbase.EdgeWxAgent)
  2699. }
  2700. return edges
  2701. }
  2702. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2703. // the given name in this mutation.
  2704. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2705. switch name {
  2706. case agentbase.EdgeWxAgent:
  2707. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2708. for id := range m.removedwx_agent {
  2709. ids = append(ids, id)
  2710. }
  2711. return ids
  2712. }
  2713. return nil
  2714. }
  2715. // ClearedEdges returns all edge names that were cleared in this mutation.
  2716. func (m *AgentBaseMutation) ClearedEdges() []string {
  2717. edges := make([]string, 0, 1)
  2718. if m.clearedwx_agent {
  2719. edges = append(edges, agentbase.EdgeWxAgent)
  2720. }
  2721. return edges
  2722. }
  2723. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2724. // was cleared in this mutation.
  2725. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2726. switch name {
  2727. case agentbase.EdgeWxAgent:
  2728. return m.clearedwx_agent
  2729. }
  2730. return false
  2731. }
  2732. // ClearEdge clears the value of the edge with the given name. It returns an error
  2733. // if that edge is not defined in the schema.
  2734. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2735. switch name {
  2736. }
  2737. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2738. }
  2739. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2740. // It returns an error if the edge is not defined in the schema.
  2741. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2742. switch name {
  2743. case agentbase.EdgeWxAgent:
  2744. m.ResetWxAgent()
  2745. return nil
  2746. }
  2747. return fmt.Errorf("unknown AgentBase edge %s", name)
  2748. }
  2749. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2750. type AliyunAvatarMutation struct {
  2751. config
  2752. op Op
  2753. typ string
  2754. id *uint64
  2755. created_at *time.Time
  2756. updated_at *time.Time
  2757. deleted_at *time.Time
  2758. user_id *uint64
  2759. adduser_id *int64
  2760. biz_id *string
  2761. access_key_id *string
  2762. access_key_secret *string
  2763. app_id *string
  2764. tenant_id *uint64
  2765. addtenant_id *int64
  2766. response *string
  2767. token *string
  2768. session_id *string
  2769. clearedFields map[string]struct{}
  2770. done bool
  2771. oldValue func(context.Context) (*AliyunAvatar, error)
  2772. predicates []predicate.AliyunAvatar
  2773. }
  2774. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2775. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2776. type aliyunavatarOption func(*AliyunAvatarMutation)
  2777. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2778. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2779. m := &AliyunAvatarMutation{
  2780. config: c,
  2781. op: op,
  2782. typ: TypeAliyunAvatar,
  2783. clearedFields: make(map[string]struct{}),
  2784. }
  2785. for _, opt := range opts {
  2786. opt(m)
  2787. }
  2788. return m
  2789. }
  2790. // withAliyunAvatarID sets the ID field of the mutation.
  2791. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2792. return func(m *AliyunAvatarMutation) {
  2793. var (
  2794. err error
  2795. once sync.Once
  2796. value *AliyunAvatar
  2797. )
  2798. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2799. once.Do(func() {
  2800. if m.done {
  2801. err = errors.New("querying old values post mutation is not allowed")
  2802. } else {
  2803. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2804. }
  2805. })
  2806. return value, err
  2807. }
  2808. m.id = &id
  2809. }
  2810. }
  2811. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2812. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2813. return func(m *AliyunAvatarMutation) {
  2814. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2815. return node, nil
  2816. }
  2817. m.id = &node.ID
  2818. }
  2819. }
  2820. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2821. // executed in a transaction (ent.Tx), a transactional client is returned.
  2822. func (m AliyunAvatarMutation) Client() *Client {
  2823. client := &Client{config: m.config}
  2824. client.init()
  2825. return client
  2826. }
  2827. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2828. // it returns an error otherwise.
  2829. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2830. if _, ok := m.driver.(*txDriver); !ok {
  2831. return nil, errors.New("ent: mutation is not running in a transaction")
  2832. }
  2833. tx := &Tx{config: m.config}
  2834. tx.init()
  2835. return tx, nil
  2836. }
  2837. // SetID sets the value of the id field. Note that this
  2838. // operation is only accepted on creation of AliyunAvatar entities.
  2839. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2840. m.id = &id
  2841. }
  2842. // ID returns the ID value in the mutation. Note that the ID is only available
  2843. // if it was provided to the builder or after it was returned from the database.
  2844. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2845. if m.id == nil {
  2846. return
  2847. }
  2848. return *m.id, true
  2849. }
  2850. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2851. // That means, if the mutation is applied within a transaction with an isolation level such
  2852. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2853. // or updated by the mutation.
  2854. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2855. switch {
  2856. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2857. id, exists := m.ID()
  2858. if exists {
  2859. return []uint64{id}, nil
  2860. }
  2861. fallthrough
  2862. case m.op.Is(OpUpdate | OpDelete):
  2863. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2864. default:
  2865. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2866. }
  2867. }
  2868. // SetCreatedAt sets the "created_at" field.
  2869. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2870. m.created_at = &t
  2871. }
  2872. // CreatedAt returns the value of the "created_at" field in the mutation.
  2873. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2874. v := m.created_at
  2875. if v == nil {
  2876. return
  2877. }
  2878. return *v, true
  2879. }
  2880. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2881. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2882. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2883. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2884. if !m.op.Is(OpUpdateOne) {
  2885. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2886. }
  2887. if m.id == nil || m.oldValue == nil {
  2888. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2889. }
  2890. oldValue, err := m.oldValue(ctx)
  2891. if err != nil {
  2892. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2893. }
  2894. return oldValue.CreatedAt, nil
  2895. }
  2896. // ResetCreatedAt resets all changes to the "created_at" field.
  2897. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2898. m.created_at = nil
  2899. }
  2900. // SetUpdatedAt sets the "updated_at" field.
  2901. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2902. m.updated_at = &t
  2903. }
  2904. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2905. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2906. v := m.updated_at
  2907. if v == nil {
  2908. return
  2909. }
  2910. return *v, true
  2911. }
  2912. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2913. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2914. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2915. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2916. if !m.op.Is(OpUpdateOne) {
  2917. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2918. }
  2919. if m.id == nil || m.oldValue == nil {
  2920. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2921. }
  2922. oldValue, err := m.oldValue(ctx)
  2923. if err != nil {
  2924. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2925. }
  2926. return oldValue.UpdatedAt, nil
  2927. }
  2928. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2929. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2930. m.updated_at = nil
  2931. }
  2932. // SetDeletedAt sets the "deleted_at" field.
  2933. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2934. m.deleted_at = &t
  2935. }
  2936. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2937. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2938. v := m.deleted_at
  2939. if v == nil {
  2940. return
  2941. }
  2942. return *v, true
  2943. }
  2944. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2945. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2946. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2947. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2948. if !m.op.Is(OpUpdateOne) {
  2949. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2950. }
  2951. if m.id == nil || m.oldValue == nil {
  2952. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2953. }
  2954. oldValue, err := m.oldValue(ctx)
  2955. if err != nil {
  2956. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2957. }
  2958. return oldValue.DeletedAt, nil
  2959. }
  2960. // ClearDeletedAt clears the value of the "deleted_at" field.
  2961. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2962. m.deleted_at = nil
  2963. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2964. }
  2965. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2966. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2967. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2968. return ok
  2969. }
  2970. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2971. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2972. m.deleted_at = nil
  2973. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2974. }
  2975. // SetUserID sets the "user_id" field.
  2976. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2977. m.user_id = &u
  2978. m.adduser_id = nil
  2979. }
  2980. // UserID returns the value of the "user_id" field in the mutation.
  2981. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2982. v := m.user_id
  2983. if v == nil {
  2984. return
  2985. }
  2986. return *v, true
  2987. }
  2988. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2989. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2990. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2991. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2992. if !m.op.Is(OpUpdateOne) {
  2993. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2994. }
  2995. if m.id == nil || m.oldValue == nil {
  2996. return v, errors.New("OldUserID requires an ID field in the mutation")
  2997. }
  2998. oldValue, err := m.oldValue(ctx)
  2999. if err != nil {
  3000. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  3001. }
  3002. return oldValue.UserID, nil
  3003. }
  3004. // AddUserID adds u to the "user_id" field.
  3005. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  3006. if m.adduser_id != nil {
  3007. *m.adduser_id += u
  3008. } else {
  3009. m.adduser_id = &u
  3010. }
  3011. }
  3012. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  3013. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  3014. v := m.adduser_id
  3015. if v == nil {
  3016. return
  3017. }
  3018. return *v, true
  3019. }
  3020. // ResetUserID resets all changes to the "user_id" field.
  3021. func (m *AliyunAvatarMutation) ResetUserID() {
  3022. m.user_id = nil
  3023. m.adduser_id = nil
  3024. }
  3025. // SetBizID sets the "biz_id" field.
  3026. func (m *AliyunAvatarMutation) SetBizID(s string) {
  3027. m.biz_id = &s
  3028. }
  3029. // BizID returns the value of the "biz_id" field in the mutation.
  3030. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  3031. v := m.biz_id
  3032. if v == nil {
  3033. return
  3034. }
  3035. return *v, true
  3036. }
  3037. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  3038. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3039. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3040. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  3041. if !m.op.Is(OpUpdateOne) {
  3042. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  3043. }
  3044. if m.id == nil || m.oldValue == nil {
  3045. return v, errors.New("OldBizID requires an ID field in the mutation")
  3046. }
  3047. oldValue, err := m.oldValue(ctx)
  3048. if err != nil {
  3049. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  3050. }
  3051. return oldValue.BizID, nil
  3052. }
  3053. // ResetBizID resets all changes to the "biz_id" field.
  3054. func (m *AliyunAvatarMutation) ResetBizID() {
  3055. m.biz_id = nil
  3056. }
  3057. // SetAccessKeyID sets the "access_key_id" field.
  3058. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  3059. m.access_key_id = &s
  3060. }
  3061. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  3062. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  3063. v := m.access_key_id
  3064. if v == nil {
  3065. return
  3066. }
  3067. return *v, true
  3068. }
  3069. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  3070. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3071. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3072. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  3073. if !m.op.Is(OpUpdateOne) {
  3074. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  3075. }
  3076. if m.id == nil || m.oldValue == nil {
  3077. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  3078. }
  3079. oldValue, err := m.oldValue(ctx)
  3080. if err != nil {
  3081. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  3082. }
  3083. return oldValue.AccessKeyID, nil
  3084. }
  3085. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  3086. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  3087. m.access_key_id = nil
  3088. }
  3089. // SetAccessKeySecret sets the "access_key_secret" field.
  3090. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  3091. m.access_key_secret = &s
  3092. }
  3093. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  3094. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  3095. v := m.access_key_secret
  3096. if v == nil {
  3097. return
  3098. }
  3099. return *v, true
  3100. }
  3101. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  3102. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3103. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3104. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  3105. if !m.op.Is(OpUpdateOne) {
  3106. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  3107. }
  3108. if m.id == nil || m.oldValue == nil {
  3109. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  3110. }
  3111. oldValue, err := m.oldValue(ctx)
  3112. if err != nil {
  3113. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  3114. }
  3115. return oldValue.AccessKeySecret, nil
  3116. }
  3117. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  3118. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  3119. m.access_key_secret = nil
  3120. }
  3121. // SetAppID sets the "app_id" field.
  3122. func (m *AliyunAvatarMutation) SetAppID(s string) {
  3123. m.app_id = &s
  3124. }
  3125. // AppID returns the value of the "app_id" field in the mutation.
  3126. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  3127. v := m.app_id
  3128. if v == nil {
  3129. return
  3130. }
  3131. return *v, true
  3132. }
  3133. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  3134. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3135. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3136. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  3137. if !m.op.Is(OpUpdateOne) {
  3138. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  3139. }
  3140. if m.id == nil || m.oldValue == nil {
  3141. return v, errors.New("OldAppID requires an ID field in the mutation")
  3142. }
  3143. oldValue, err := m.oldValue(ctx)
  3144. if err != nil {
  3145. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  3146. }
  3147. return oldValue.AppID, nil
  3148. }
  3149. // ClearAppID clears the value of the "app_id" field.
  3150. func (m *AliyunAvatarMutation) ClearAppID() {
  3151. m.app_id = nil
  3152. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  3153. }
  3154. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  3155. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  3156. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  3157. return ok
  3158. }
  3159. // ResetAppID resets all changes to the "app_id" field.
  3160. func (m *AliyunAvatarMutation) ResetAppID() {
  3161. m.app_id = nil
  3162. delete(m.clearedFields, aliyunavatar.FieldAppID)
  3163. }
  3164. // SetTenantID sets the "tenant_id" field.
  3165. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  3166. m.tenant_id = &u
  3167. m.addtenant_id = nil
  3168. }
  3169. // TenantID returns the value of the "tenant_id" field in the mutation.
  3170. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  3171. v := m.tenant_id
  3172. if v == nil {
  3173. return
  3174. }
  3175. return *v, true
  3176. }
  3177. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  3178. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3179. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3180. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  3181. if !m.op.Is(OpUpdateOne) {
  3182. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  3183. }
  3184. if m.id == nil || m.oldValue == nil {
  3185. return v, errors.New("OldTenantID requires an ID field in the mutation")
  3186. }
  3187. oldValue, err := m.oldValue(ctx)
  3188. if err != nil {
  3189. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  3190. }
  3191. return oldValue.TenantID, nil
  3192. }
  3193. // AddTenantID adds u to the "tenant_id" field.
  3194. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  3195. if m.addtenant_id != nil {
  3196. *m.addtenant_id += u
  3197. } else {
  3198. m.addtenant_id = &u
  3199. }
  3200. }
  3201. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  3202. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  3203. v := m.addtenant_id
  3204. if v == nil {
  3205. return
  3206. }
  3207. return *v, true
  3208. }
  3209. // ResetTenantID resets all changes to the "tenant_id" field.
  3210. func (m *AliyunAvatarMutation) ResetTenantID() {
  3211. m.tenant_id = nil
  3212. m.addtenant_id = nil
  3213. }
  3214. // SetResponse sets the "response" field.
  3215. func (m *AliyunAvatarMutation) SetResponse(s string) {
  3216. m.response = &s
  3217. }
  3218. // Response returns the value of the "response" field in the mutation.
  3219. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  3220. v := m.response
  3221. if v == nil {
  3222. return
  3223. }
  3224. return *v, true
  3225. }
  3226. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  3227. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3228. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3229. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  3230. if !m.op.Is(OpUpdateOne) {
  3231. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  3232. }
  3233. if m.id == nil || m.oldValue == nil {
  3234. return v, errors.New("OldResponse requires an ID field in the mutation")
  3235. }
  3236. oldValue, err := m.oldValue(ctx)
  3237. if err != nil {
  3238. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  3239. }
  3240. return oldValue.Response, nil
  3241. }
  3242. // ResetResponse resets all changes to the "response" field.
  3243. func (m *AliyunAvatarMutation) ResetResponse() {
  3244. m.response = nil
  3245. }
  3246. // SetToken sets the "token" field.
  3247. func (m *AliyunAvatarMutation) SetToken(s string) {
  3248. m.token = &s
  3249. }
  3250. // Token returns the value of the "token" field in the mutation.
  3251. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  3252. v := m.token
  3253. if v == nil {
  3254. return
  3255. }
  3256. return *v, true
  3257. }
  3258. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  3259. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3260. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3261. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  3262. if !m.op.Is(OpUpdateOne) {
  3263. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  3264. }
  3265. if m.id == nil || m.oldValue == nil {
  3266. return v, errors.New("OldToken requires an ID field in the mutation")
  3267. }
  3268. oldValue, err := m.oldValue(ctx)
  3269. if err != nil {
  3270. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  3271. }
  3272. return oldValue.Token, nil
  3273. }
  3274. // ResetToken resets all changes to the "token" field.
  3275. func (m *AliyunAvatarMutation) ResetToken() {
  3276. m.token = nil
  3277. }
  3278. // SetSessionID sets the "session_id" field.
  3279. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  3280. m.session_id = &s
  3281. }
  3282. // SessionID returns the value of the "session_id" field in the mutation.
  3283. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  3284. v := m.session_id
  3285. if v == nil {
  3286. return
  3287. }
  3288. return *v, true
  3289. }
  3290. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  3291. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3292. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3293. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  3294. if !m.op.Is(OpUpdateOne) {
  3295. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  3296. }
  3297. if m.id == nil || m.oldValue == nil {
  3298. return v, errors.New("OldSessionID requires an ID field in the mutation")
  3299. }
  3300. oldValue, err := m.oldValue(ctx)
  3301. if err != nil {
  3302. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  3303. }
  3304. return oldValue.SessionID, nil
  3305. }
  3306. // ResetSessionID resets all changes to the "session_id" field.
  3307. func (m *AliyunAvatarMutation) ResetSessionID() {
  3308. m.session_id = nil
  3309. }
  3310. // Where appends a list predicates to the AliyunAvatarMutation builder.
  3311. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  3312. m.predicates = append(m.predicates, ps...)
  3313. }
  3314. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  3315. // users can use type-assertion to append predicates that do not depend on any generated package.
  3316. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  3317. p := make([]predicate.AliyunAvatar, len(ps))
  3318. for i := range ps {
  3319. p[i] = ps[i]
  3320. }
  3321. m.Where(p...)
  3322. }
  3323. // Op returns the operation name.
  3324. func (m *AliyunAvatarMutation) Op() Op {
  3325. return m.op
  3326. }
  3327. // SetOp allows setting the mutation operation.
  3328. func (m *AliyunAvatarMutation) SetOp(op Op) {
  3329. m.op = op
  3330. }
  3331. // Type returns the node type of this mutation (AliyunAvatar).
  3332. func (m *AliyunAvatarMutation) Type() string {
  3333. return m.typ
  3334. }
  3335. // Fields returns all fields that were changed during this mutation. Note that in
  3336. // order to get all numeric fields that were incremented/decremented, call
  3337. // AddedFields().
  3338. func (m *AliyunAvatarMutation) Fields() []string {
  3339. fields := make([]string, 0, 12)
  3340. if m.created_at != nil {
  3341. fields = append(fields, aliyunavatar.FieldCreatedAt)
  3342. }
  3343. if m.updated_at != nil {
  3344. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  3345. }
  3346. if m.deleted_at != nil {
  3347. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3348. }
  3349. if m.user_id != nil {
  3350. fields = append(fields, aliyunavatar.FieldUserID)
  3351. }
  3352. if m.biz_id != nil {
  3353. fields = append(fields, aliyunavatar.FieldBizID)
  3354. }
  3355. if m.access_key_id != nil {
  3356. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  3357. }
  3358. if m.access_key_secret != nil {
  3359. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  3360. }
  3361. if m.app_id != nil {
  3362. fields = append(fields, aliyunavatar.FieldAppID)
  3363. }
  3364. if m.tenant_id != nil {
  3365. fields = append(fields, aliyunavatar.FieldTenantID)
  3366. }
  3367. if m.response != nil {
  3368. fields = append(fields, aliyunavatar.FieldResponse)
  3369. }
  3370. if m.token != nil {
  3371. fields = append(fields, aliyunavatar.FieldToken)
  3372. }
  3373. if m.session_id != nil {
  3374. fields = append(fields, aliyunavatar.FieldSessionID)
  3375. }
  3376. return fields
  3377. }
  3378. // Field returns the value of a field with the given name. The second boolean
  3379. // return value indicates that this field was not set, or was not defined in the
  3380. // schema.
  3381. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  3382. switch name {
  3383. case aliyunavatar.FieldCreatedAt:
  3384. return m.CreatedAt()
  3385. case aliyunavatar.FieldUpdatedAt:
  3386. return m.UpdatedAt()
  3387. case aliyunavatar.FieldDeletedAt:
  3388. return m.DeletedAt()
  3389. case aliyunavatar.FieldUserID:
  3390. return m.UserID()
  3391. case aliyunavatar.FieldBizID:
  3392. return m.BizID()
  3393. case aliyunavatar.FieldAccessKeyID:
  3394. return m.AccessKeyID()
  3395. case aliyunavatar.FieldAccessKeySecret:
  3396. return m.AccessKeySecret()
  3397. case aliyunavatar.FieldAppID:
  3398. return m.AppID()
  3399. case aliyunavatar.FieldTenantID:
  3400. return m.TenantID()
  3401. case aliyunavatar.FieldResponse:
  3402. return m.Response()
  3403. case aliyunavatar.FieldToken:
  3404. return m.Token()
  3405. case aliyunavatar.FieldSessionID:
  3406. return m.SessionID()
  3407. }
  3408. return nil, false
  3409. }
  3410. // OldField returns the old value of the field from the database. An error is
  3411. // returned if the mutation operation is not UpdateOne, or the query to the
  3412. // database failed.
  3413. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3414. switch name {
  3415. case aliyunavatar.FieldCreatedAt:
  3416. return m.OldCreatedAt(ctx)
  3417. case aliyunavatar.FieldUpdatedAt:
  3418. return m.OldUpdatedAt(ctx)
  3419. case aliyunavatar.FieldDeletedAt:
  3420. return m.OldDeletedAt(ctx)
  3421. case aliyunavatar.FieldUserID:
  3422. return m.OldUserID(ctx)
  3423. case aliyunavatar.FieldBizID:
  3424. return m.OldBizID(ctx)
  3425. case aliyunavatar.FieldAccessKeyID:
  3426. return m.OldAccessKeyID(ctx)
  3427. case aliyunavatar.FieldAccessKeySecret:
  3428. return m.OldAccessKeySecret(ctx)
  3429. case aliyunavatar.FieldAppID:
  3430. return m.OldAppID(ctx)
  3431. case aliyunavatar.FieldTenantID:
  3432. return m.OldTenantID(ctx)
  3433. case aliyunavatar.FieldResponse:
  3434. return m.OldResponse(ctx)
  3435. case aliyunavatar.FieldToken:
  3436. return m.OldToken(ctx)
  3437. case aliyunavatar.FieldSessionID:
  3438. return m.OldSessionID(ctx)
  3439. }
  3440. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  3441. }
  3442. // SetField sets the value of a field with the given name. It returns an error if
  3443. // the field is not defined in the schema, or if the type mismatched the field
  3444. // type.
  3445. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  3446. switch name {
  3447. case aliyunavatar.FieldCreatedAt:
  3448. v, ok := value.(time.Time)
  3449. if !ok {
  3450. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3451. }
  3452. m.SetCreatedAt(v)
  3453. return nil
  3454. case aliyunavatar.FieldUpdatedAt:
  3455. v, ok := value.(time.Time)
  3456. if !ok {
  3457. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3458. }
  3459. m.SetUpdatedAt(v)
  3460. return nil
  3461. case aliyunavatar.FieldDeletedAt:
  3462. v, ok := value.(time.Time)
  3463. if !ok {
  3464. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3465. }
  3466. m.SetDeletedAt(v)
  3467. return nil
  3468. case aliyunavatar.FieldUserID:
  3469. v, ok := value.(uint64)
  3470. if !ok {
  3471. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3472. }
  3473. m.SetUserID(v)
  3474. return nil
  3475. case aliyunavatar.FieldBizID:
  3476. v, ok := value.(string)
  3477. if !ok {
  3478. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3479. }
  3480. m.SetBizID(v)
  3481. return nil
  3482. case aliyunavatar.FieldAccessKeyID:
  3483. v, ok := value.(string)
  3484. if !ok {
  3485. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3486. }
  3487. m.SetAccessKeyID(v)
  3488. return nil
  3489. case aliyunavatar.FieldAccessKeySecret:
  3490. v, ok := value.(string)
  3491. if !ok {
  3492. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3493. }
  3494. m.SetAccessKeySecret(v)
  3495. return nil
  3496. case aliyunavatar.FieldAppID:
  3497. v, ok := value.(string)
  3498. if !ok {
  3499. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3500. }
  3501. m.SetAppID(v)
  3502. return nil
  3503. case aliyunavatar.FieldTenantID:
  3504. v, ok := value.(uint64)
  3505. if !ok {
  3506. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3507. }
  3508. m.SetTenantID(v)
  3509. return nil
  3510. case aliyunavatar.FieldResponse:
  3511. v, ok := value.(string)
  3512. if !ok {
  3513. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3514. }
  3515. m.SetResponse(v)
  3516. return nil
  3517. case aliyunavatar.FieldToken:
  3518. v, ok := value.(string)
  3519. if !ok {
  3520. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3521. }
  3522. m.SetToken(v)
  3523. return nil
  3524. case aliyunavatar.FieldSessionID:
  3525. v, ok := value.(string)
  3526. if !ok {
  3527. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3528. }
  3529. m.SetSessionID(v)
  3530. return nil
  3531. }
  3532. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3533. }
  3534. // AddedFields returns all numeric fields that were incremented/decremented during
  3535. // this mutation.
  3536. func (m *AliyunAvatarMutation) AddedFields() []string {
  3537. var fields []string
  3538. if m.adduser_id != nil {
  3539. fields = append(fields, aliyunavatar.FieldUserID)
  3540. }
  3541. if m.addtenant_id != nil {
  3542. fields = append(fields, aliyunavatar.FieldTenantID)
  3543. }
  3544. return fields
  3545. }
  3546. // AddedField returns the numeric value that was incremented/decremented on a field
  3547. // with the given name. The second boolean return value indicates that this field
  3548. // was not set, or was not defined in the schema.
  3549. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  3550. switch name {
  3551. case aliyunavatar.FieldUserID:
  3552. return m.AddedUserID()
  3553. case aliyunavatar.FieldTenantID:
  3554. return m.AddedTenantID()
  3555. }
  3556. return nil, false
  3557. }
  3558. // AddField adds the value to the field with the given name. It returns an error if
  3559. // the field is not defined in the schema, or if the type mismatched the field
  3560. // type.
  3561. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  3562. switch name {
  3563. case aliyunavatar.FieldUserID:
  3564. v, ok := value.(int64)
  3565. if !ok {
  3566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3567. }
  3568. m.AddUserID(v)
  3569. return nil
  3570. case aliyunavatar.FieldTenantID:
  3571. v, ok := value.(int64)
  3572. if !ok {
  3573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3574. }
  3575. m.AddTenantID(v)
  3576. return nil
  3577. }
  3578. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3579. }
  3580. // ClearedFields returns all nullable fields that were cleared during this
  3581. // mutation.
  3582. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3583. var fields []string
  3584. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3585. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3586. }
  3587. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3588. fields = append(fields, aliyunavatar.FieldAppID)
  3589. }
  3590. return fields
  3591. }
  3592. // FieldCleared returns a boolean indicating if a field with the given name was
  3593. // cleared in this mutation.
  3594. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3595. _, ok := m.clearedFields[name]
  3596. return ok
  3597. }
  3598. // ClearField clears the value of the field with the given name. It returns an
  3599. // error if the field is not defined in the schema.
  3600. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3601. switch name {
  3602. case aliyunavatar.FieldDeletedAt:
  3603. m.ClearDeletedAt()
  3604. return nil
  3605. case aliyunavatar.FieldAppID:
  3606. m.ClearAppID()
  3607. return nil
  3608. }
  3609. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3610. }
  3611. // ResetField resets all changes in the mutation for the field with the given name.
  3612. // It returns an error if the field is not defined in the schema.
  3613. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3614. switch name {
  3615. case aliyunavatar.FieldCreatedAt:
  3616. m.ResetCreatedAt()
  3617. return nil
  3618. case aliyunavatar.FieldUpdatedAt:
  3619. m.ResetUpdatedAt()
  3620. return nil
  3621. case aliyunavatar.FieldDeletedAt:
  3622. m.ResetDeletedAt()
  3623. return nil
  3624. case aliyunavatar.FieldUserID:
  3625. m.ResetUserID()
  3626. return nil
  3627. case aliyunavatar.FieldBizID:
  3628. m.ResetBizID()
  3629. return nil
  3630. case aliyunavatar.FieldAccessKeyID:
  3631. m.ResetAccessKeyID()
  3632. return nil
  3633. case aliyunavatar.FieldAccessKeySecret:
  3634. m.ResetAccessKeySecret()
  3635. return nil
  3636. case aliyunavatar.FieldAppID:
  3637. m.ResetAppID()
  3638. return nil
  3639. case aliyunavatar.FieldTenantID:
  3640. m.ResetTenantID()
  3641. return nil
  3642. case aliyunavatar.FieldResponse:
  3643. m.ResetResponse()
  3644. return nil
  3645. case aliyunavatar.FieldToken:
  3646. m.ResetToken()
  3647. return nil
  3648. case aliyunavatar.FieldSessionID:
  3649. m.ResetSessionID()
  3650. return nil
  3651. }
  3652. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3653. }
  3654. // AddedEdges returns all edge names that were set/added in this mutation.
  3655. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3656. edges := make([]string, 0, 0)
  3657. return edges
  3658. }
  3659. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3660. // name in this mutation.
  3661. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3662. return nil
  3663. }
  3664. // RemovedEdges returns all edge names that were removed in this mutation.
  3665. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3666. edges := make([]string, 0, 0)
  3667. return edges
  3668. }
  3669. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3670. // the given name in this mutation.
  3671. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3672. return nil
  3673. }
  3674. // ClearedEdges returns all edge names that were cleared in this mutation.
  3675. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3676. edges := make([]string, 0, 0)
  3677. return edges
  3678. }
  3679. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3680. // was cleared in this mutation.
  3681. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3682. return false
  3683. }
  3684. // ClearEdge clears the value of the edge with the given name. It returns an error
  3685. // if that edge is not defined in the schema.
  3686. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3687. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3688. }
  3689. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3690. // It returns an error if the edge is not defined in the schema.
  3691. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3692. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3693. }
  3694. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  3695. type AllocAgentMutation struct {
  3696. config
  3697. op Op
  3698. typ string
  3699. id *uint64
  3700. created_at *time.Time
  3701. updated_at *time.Time
  3702. deleted_at *time.Time
  3703. user_id *string
  3704. organization_id *uint64
  3705. addorganization_id *int64
  3706. agents *[]uint64
  3707. appendagents []uint64
  3708. status *int
  3709. addstatus *int
  3710. clearedFields map[string]struct{}
  3711. done bool
  3712. oldValue func(context.Context) (*AllocAgent, error)
  3713. predicates []predicate.AllocAgent
  3714. }
  3715. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  3716. // allocagentOption allows management of the mutation configuration using functional options.
  3717. type allocagentOption func(*AllocAgentMutation)
  3718. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  3719. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  3720. m := &AllocAgentMutation{
  3721. config: c,
  3722. op: op,
  3723. typ: TypeAllocAgent,
  3724. clearedFields: make(map[string]struct{}),
  3725. }
  3726. for _, opt := range opts {
  3727. opt(m)
  3728. }
  3729. return m
  3730. }
  3731. // withAllocAgentID sets the ID field of the mutation.
  3732. func withAllocAgentID(id uint64) allocagentOption {
  3733. return func(m *AllocAgentMutation) {
  3734. var (
  3735. err error
  3736. once sync.Once
  3737. value *AllocAgent
  3738. )
  3739. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  3740. once.Do(func() {
  3741. if m.done {
  3742. err = errors.New("querying old values post mutation is not allowed")
  3743. } else {
  3744. value, err = m.Client().AllocAgent.Get(ctx, id)
  3745. }
  3746. })
  3747. return value, err
  3748. }
  3749. m.id = &id
  3750. }
  3751. }
  3752. // withAllocAgent sets the old AllocAgent of the mutation.
  3753. func withAllocAgent(node *AllocAgent) allocagentOption {
  3754. return func(m *AllocAgentMutation) {
  3755. m.oldValue = func(context.Context) (*AllocAgent, error) {
  3756. return node, nil
  3757. }
  3758. m.id = &node.ID
  3759. }
  3760. }
  3761. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3762. // executed in a transaction (ent.Tx), a transactional client is returned.
  3763. func (m AllocAgentMutation) Client() *Client {
  3764. client := &Client{config: m.config}
  3765. client.init()
  3766. return client
  3767. }
  3768. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3769. // it returns an error otherwise.
  3770. func (m AllocAgentMutation) Tx() (*Tx, error) {
  3771. if _, ok := m.driver.(*txDriver); !ok {
  3772. return nil, errors.New("ent: mutation is not running in a transaction")
  3773. }
  3774. tx := &Tx{config: m.config}
  3775. tx.init()
  3776. return tx, nil
  3777. }
  3778. // SetID sets the value of the id field. Note that this
  3779. // operation is only accepted on creation of AllocAgent entities.
  3780. func (m *AllocAgentMutation) SetID(id uint64) {
  3781. m.id = &id
  3782. }
  3783. // ID returns the ID value in the mutation. Note that the ID is only available
  3784. // if it was provided to the builder or after it was returned from the database.
  3785. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  3786. if m.id == nil {
  3787. return
  3788. }
  3789. return *m.id, true
  3790. }
  3791. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3792. // That means, if the mutation is applied within a transaction with an isolation level such
  3793. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3794. // or updated by the mutation.
  3795. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  3796. switch {
  3797. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3798. id, exists := m.ID()
  3799. if exists {
  3800. return []uint64{id}, nil
  3801. }
  3802. fallthrough
  3803. case m.op.Is(OpUpdate | OpDelete):
  3804. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  3805. default:
  3806. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3807. }
  3808. }
  3809. // SetCreatedAt sets the "created_at" field.
  3810. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  3811. m.created_at = &t
  3812. }
  3813. // CreatedAt returns the value of the "created_at" field in the mutation.
  3814. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  3815. v := m.created_at
  3816. if v == nil {
  3817. return
  3818. }
  3819. return *v, true
  3820. }
  3821. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  3822. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3823. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3824. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3825. if !m.op.Is(OpUpdateOne) {
  3826. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3827. }
  3828. if m.id == nil || m.oldValue == nil {
  3829. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3830. }
  3831. oldValue, err := m.oldValue(ctx)
  3832. if err != nil {
  3833. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3834. }
  3835. return oldValue.CreatedAt, nil
  3836. }
  3837. // ResetCreatedAt resets all changes to the "created_at" field.
  3838. func (m *AllocAgentMutation) ResetCreatedAt() {
  3839. m.created_at = nil
  3840. }
  3841. // SetUpdatedAt sets the "updated_at" field.
  3842. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  3843. m.updated_at = &t
  3844. }
  3845. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3846. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  3847. v := m.updated_at
  3848. if v == nil {
  3849. return
  3850. }
  3851. return *v, true
  3852. }
  3853. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  3854. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3855. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3856. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3857. if !m.op.Is(OpUpdateOne) {
  3858. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3859. }
  3860. if m.id == nil || m.oldValue == nil {
  3861. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3862. }
  3863. oldValue, err := m.oldValue(ctx)
  3864. if err != nil {
  3865. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3866. }
  3867. return oldValue.UpdatedAt, nil
  3868. }
  3869. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3870. func (m *AllocAgentMutation) ResetUpdatedAt() {
  3871. m.updated_at = nil
  3872. }
  3873. // SetDeletedAt sets the "deleted_at" field.
  3874. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  3875. m.deleted_at = &t
  3876. }
  3877. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3878. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  3879. v := m.deleted_at
  3880. if v == nil {
  3881. return
  3882. }
  3883. return *v, true
  3884. }
  3885. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  3886. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3887. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3888. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3889. if !m.op.Is(OpUpdateOne) {
  3890. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3891. }
  3892. if m.id == nil || m.oldValue == nil {
  3893. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3894. }
  3895. oldValue, err := m.oldValue(ctx)
  3896. if err != nil {
  3897. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3898. }
  3899. return oldValue.DeletedAt, nil
  3900. }
  3901. // ClearDeletedAt clears the value of the "deleted_at" field.
  3902. func (m *AllocAgentMutation) ClearDeletedAt() {
  3903. m.deleted_at = nil
  3904. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  3905. }
  3906. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3907. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  3908. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  3909. return ok
  3910. }
  3911. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3912. func (m *AllocAgentMutation) ResetDeletedAt() {
  3913. m.deleted_at = nil
  3914. delete(m.clearedFields, allocagent.FieldDeletedAt)
  3915. }
  3916. // SetUserID sets the "user_id" field.
  3917. func (m *AllocAgentMutation) SetUserID(s string) {
  3918. m.user_id = &s
  3919. }
  3920. // UserID returns the value of the "user_id" field in the mutation.
  3921. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  3922. v := m.user_id
  3923. if v == nil {
  3924. return
  3925. }
  3926. return *v, true
  3927. }
  3928. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  3929. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3930. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3931. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  3932. if !m.op.Is(OpUpdateOne) {
  3933. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  3934. }
  3935. if m.id == nil || m.oldValue == nil {
  3936. return v, errors.New("OldUserID requires an ID field in the mutation")
  3937. }
  3938. oldValue, err := m.oldValue(ctx)
  3939. if err != nil {
  3940. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  3941. }
  3942. return oldValue.UserID, nil
  3943. }
  3944. // ClearUserID clears the value of the "user_id" field.
  3945. func (m *AllocAgentMutation) ClearUserID() {
  3946. m.user_id = nil
  3947. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  3948. }
  3949. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  3950. func (m *AllocAgentMutation) UserIDCleared() bool {
  3951. _, ok := m.clearedFields[allocagent.FieldUserID]
  3952. return ok
  3953. }
  3954. // ResetUserID resets all changes to the "user_id" field.
  3955. func (m *AllocAgentMutation) ResetUserID() {
  3956. m.user_id = nil
  3957. delete(m.clearedFields, allocagent.FieldUserID)
  3958. }
  3959. // SetOrganizationID sets the "organization_id" field.
  3960. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  3961. m.organization_id = &u
  3962. m.addorganization_id = nil
  3963. }
  3964. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3965. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  3966. v := m.organization_id
  3967. if v == nil {
  3968. return
  3969. }
  3970. return *v, true
  3971. }
  3972. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  3973. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3974. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3975. func (m *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3976. if !m.op.Is(OpUpdateOne) {
  3977. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3978. }
  3979. if m.id == nil || m.oldValue == nil {
  3980. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3981. }
  3982. oldValue, err := m.oldValue(ctx)
  3983. if err != nil {
  3984. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3985. }
  3986. return oldValue.OrganizationID, nil
  3987. }
  3988. // AddOrganizationID adds u to the "organization_id" field.
  3989. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  3990. if m.addorganization_id != nil {
  3991. *m.addorganization_id += u
  3992. } else {
  3993. m.addorganization_id = &u
  3994. }
  3995. }
  3996. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3997. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  3998. v := m.addorganization_id
  3999. if v == nil {
  4000. return
  4001. }
  4002. return *v, true
  4003. }
  4004. // ClearOrganizationID clears the value of the "organization_id" field.
  4005. func (m *AllocAgentMutation) ClearOrganizationID() {
  4006. m.organization_id = nil
  4007. m.addorganization_id = nil
  4008. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  4009. }
  4010. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  4011. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  4012. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  4013. return ok
  4014. }
  4015. // ResetOrganizationID resets all changes to the "organization_id" field.
  4016. func (m *AllocAgentMutation) ResetOrganizationID() {
  4017. m.organization_id = nil
  4018. m.addorganization_id = nil
  4019. delete(m.clearedFields, allocagent.FieldOrganizationID)
  4020. }
  4021. // SetAgents sets the "agents" field.
  4022. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  4023. m.agents = &u
  4024. m.appendagents = nil
  4025. }
  4026. // Agents returns the value of the "agents" field in the mutation.
  4027. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  4028. v := m.agents
  4029. if v == nil {
  4030. return
  4031. }
  4032. return *v, true
  4033. }
  4034. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  4035. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  4036. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4037. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  4038. if !m.op.Is(OpUpdateOne) {
  4039. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  4040. }
  4041. if m.id == nil || m.oldValue == nil {
  4042. return v, errors.New("OldAgents requires an ID field in the mutation")
  4043. }
  4044. oldValue, err := m.oldValue(ctx)
  4045. if err != nil {
  4046. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  4047. }
  4048. return oldValue.Agents, nil
  4049. }
  4050. // AppendAgents adds u to the "agents" field.
  4051. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  4052. m.appendagents = append(m.appendagents, u...)
  4053. }
  4054. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  4055. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  4056. if len(m.appendagents) == 0 {
  4057. return nil, false
  4058. }
  4059. return m.appendagents, true
  4060. }
  4061. // ResetAgents resets all changes to the "agents" field.
  4062. func (m *AllocAgentMutation) ResetAgents() {
  4063. m.agents = nil
  4064. m.appendagents = nil
  4065. }
  4066. // SetStatus sets the "status" field.
  4067. func (m *AllocAgentMutation) SetStatus(i int) {
  4068. m.status = &i
  4069. m.addstatus = nil
  4070. }
  4071. // Status returns the value of the "status" field in the mutation.
  4072. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  4073. v := m.status
  4074. if v == nil {
  4075. return
  4076. }
  4077. return *v, true
  4078. }
  4079. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  4080. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  4081. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4082. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  4083. if !m.op.Is(OpUpdateOne) {
  4084. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  4085. }
  4086. if m.id == nil || m.oldValue == nil {
  4087. return v, errors.New("OldStatus requires an ID field in the mutation")
  4088. }
  4089. oldValue, err := m.oldValue(ctx)
  4090. if err != nil {
  4091. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  4092. }
  4093. return oldValue.Status, nil
  4094. }
  4095. // AddStatus adds i to the "status" field.
  4096. func (m *AllocAgentMutation) AddStatus(i int) {
  4097. if m.addstatus != nil {
  4098. *m.addstatus += i
  4099. } else {
  4100. m.addstatus = &i
  4101. }
  4102. }
  4103. // AddedStatus returns the value that was added to the "status" field in this mutation.
  4104. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  4105. v := m.addstatus
  4106. if v == nil {
  4107. return
  4108. }
  4109. return *v, true
  4110. }
  4111. // ClearStatus clears the value of the "status" field.
  4112. func (m *AllocAgentMutation) ClearStatus() {
  4113. m.status = nil
  4114. m.addstatus = nil
  4115. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  4116. }
  4117. // StatusCleared returns if the "status" field was cleared in this mutation.
  4118. func (m *AllocAgentMutation) StatusCleared() bool {
  4119. _, ok := m.clearedFields[allocagent.FieldStatus]
  4120. return ok
  4121. }
  4122. // ResetStatus resets all changes to the "status" field.
  4123. func (m *AllocAgentMutation) ResetStatus() {
  4124. m.status = nil
  4125. m.addstatus = nil
  4126. delete(m.clearedFields, allocagent.FieldStatus)
  4127. }
  4128. // Where appends a list predicates to the AllocAgentMutation builder.
  4129. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  4130. m.predicates = append(m.predicates, ps...)
  4131. }
  4132. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  4133. // users can use type-assertion to append predicates that do not depend on any generated package.
  4134. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  4135. p := make([]predicate.AllocAgent, len(ps))
  4136. for i := range ps {
  4137. p[i] = ps[i]
  4138. }
  4139. m.Where(p...)
  4140. }
  4141. // Op returns the operation name.
  4142. func (m *AllocAgentMutation) Op() Op {
  4143. return m.op
  4144. }
  4145. // SetOp allows setting the mutation operation.
  4146. func (m *AllocAgentMutation) SetOp(op Op) {
  4147. m.op = op
  4148. }
  4149. // Type returns the node type of this mutation (AllocAgent).
  4150. func (m *AllocAgentMutation) Type() string {
  4151. return m.typ
  4152. }
  4153. // Fields returns all fields that were changed during this mutation. Note that in
  4154. // order to get all numeric fields that were incremented/decremented, call
  4155. // AddedFields().
  4156. func (m *AllocAgentMutation) Fields() []string {
  4157. fields := make([]string, 0, 7)
  4158. if m.created_at != nil {
  4159. fields = append(fields, allocagent.FieldCreatedAt)
  4160. }
  4161. if m.updated_at != nil {
  4162. fields = append(fields, allocagent.FieldUpdatedAt)
  4163. }
  4164. if m.deleted_at != nil {
  4165. fields = append(fields, allocagent.FieldDeletedAt)
  4166. }
  4167. if m.user_id != nil {
  4168. fields = append(fields, allocagent.FieldUserID)
  4169. }
  4170. if m.organization_id != nil {
  4171. fields = append(fields, allocagent.FieldOrganizationID)
  4172. }
  4173. if m.agents != nil {
  4174. fields = append(fields, allocagent.FieldAgents)
  4175. }
  4176. if m.status != nil {
  4177. fields = append(fields, allocagent.FieldStatus)
  4178. }
  4179. return fields
  4180. }
  4181. // Field returns the value of a field with the given name. The second boolean
  4182. // return value indicates that this field was not set, or was not defined in the
  4183. // schema.
  4184. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  4185. switch name {
  4186. case allocagent.FieldCreatedAt:
  4187. return m.CreatedAt()
  4188. case allocagent.FieldUpdatedAt:
  4189. return m.UpdatedAt()
  4190. case allocagent.FieldDeletedAt:
  4191. return m.DeletedAt()
  4192. case allocagent.FieldUserID:
  4193. return m.UserID()
  4194. case allocagent.FieldOrganizationID:
  4195. return m.OrganizationID()
  4196. case allocagent.FieldAgents:
  4197. return m.Agents()
  4198. case allocagent.FieldStatus:
  4199. return m.Status()
  4200. }
  4201. return nil, false
  4202. }
  4203. // OldField returns the old value of the field from the database. An error is
  4204. // returned if the mutation operation is not UpdateOne, or the query to the
  4205. // database failed.
  4206. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4207. switch name {
  4208. case allocagent.FieldCreatedAt:
  4209. return m.OldCreatedAt(ctx)
  4210. case allocagent.FieldUpdatedAt:
  4211. return m.OldUpdatedAt(ctx)
  4212. case allocagent.FieldDeletedAt:
  4213. return m.OldDeletedAt(ctx)
  4214. case allocagent.FieldUserID:
  4215. return m.OldUserID(ctx)
  4216. case allocagent.FieldOrganizationID:
  4217. return m.OldOrganizationID(ctx)
  4218. case allocagent.FieldAgents:
  4219. return m.OldAgents(ctx)
  4220. case allocagent.FieldStatus:
  4221. return m.OldStatus(ctx)
  4222. }
  4223. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  4224. }
  4225. // SetField sets the value of a field with the given name. It returns an error if
  4226. // the field is not defined in the schema, or if the type mismatched the field
  4227. // type.
  4228. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  4229. switch name {
  4230. case allocagent.FieldCreatedAt:
  4231. v, ok := value.(time.Time)
  4232. if !ok {
  4233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4234. }
  4235. m.SetCreatedAt(v)
  4236. return nil
  4237. case allocagent.FieldUpdatedAt:
  4238. v, ok := value.(time.Time)
  4239. if !ok {
  4240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4241. }
  4242. m.SetUpdatedAt(v)
  4243. return nil
  4244. case allocagent.FieldDeletedAt:
  4245. v, ok := value.(time.Time)
  4246. if !ok {
  4247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4248. }
  4249. m.SetDeletedAt(v)
  4250. return nil
  4251. case allocagent.FieldUserID:
  4252. v, ok := value.(string)
  4253. if !ok {
  4254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4255. }
  4256. m.SetUserID(v)
  4257. return nil
  4258. case allocagent.FieldOrganizationID:
  4259. v, ok := value.(uint64)
  4260. if !ok {
  4261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4262. }
  4263. m.SetOrganizationID(v)
  4264. return nil
  4265. case allocagent.FieldAgents:
  4266. v, ok := value.([]uint64)
  4267. if !ok {
  4268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4269. }
  4270. m.SetAgents(v)
  4271. return nil
  4272. case allocagent.FieldStatus:
  4273. v, ok := value.(int)
  4274. if !ok {
  4275. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4276. }
  4277. m.SetStatus(v)
  4278. return nil
  4279. }
  4280. return fmt.Errorf("unknown AllocAgent field %s", name)
  4281. }
  4282. // AddedFields returns all numeric fields that were incremented/decremented during
  4283. // this mutation.
  4284. func (m *AllocAgentMutation) AddedFields() []string {
  4285. var fields []string
  4286. if m.addorganization_id != nil {
  4287. fields = append(fields, allocagent.FieldOrganizationID)
  4288. }
  4289. if m.addstatus != nil {
  4290. fields = append(fields, allocagent.FieldStatus)
  4291. }
  4292. return fields
  4293. }
  4294. // AddedField returns the numeric value that was incremented/decremented on a field
  4295. // with the given name. The second boolean return value indicates that this field
  4296. // was not set, or was not defined in the schema.
  4297. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  4298. switch name {
  4299. case allocagent.FieldOrganizationID:
  4300. return m.AddedOrganizationID()
  4301. case allocagent.FieldStatus:
  4302. return m.AddedStatus()
  4303. }
  4304. return nil, false
  4305. }
  4306. // AddField adds the value to the field with the given name. It returns an error if
  4307. // the field is not defined in the schema, or if the type mismatched the field
  4308. // type.
  4309. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  4310. switch name {
  4311. case allocagent.FieldOrganizationID:
  4312. v, ok := value.(int64)
  4313. if !ok {
  4314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4315. }
  4316. m.AddOrganizationID(v)
  4317. return nil
  4318. case allocagent.FieldStatus:
  4319. v, ok := value.(int)
  4320. if !ok {
  4321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4322. }
  4323. m.AddStatus(v)
  4324. return nil
  4325. }
  4326. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  4327. }
  4328. // ClearedFields returns all nullable fields that were cleared during this
  4329. // mutation.
  4330. func (m *AllocAgentMutation) ClearedFields() []string {
  4331. var fields []string
  4332. if m.FieldCleared(allocagent.FieldDeletedAt) {
  4333. fields = append(fields, allocagent.FieldDeletedAt)
  4334. }
  4335. if m.FieldCleared(allocagent.FieldUserID) {
  4336. fields = append(fields, allocagent.FieldUserID)
  4337. }
  4338. if m.FieldCleared(allocagent.FieldOrganizationID) {
  4339. fields = append(fields, allocagent.FieldOrganizationID)
  4340. }
  4341. if m.FieldCleared(allocagent.FieldStatus) {
  4342. fields = append(fields, allocagent.FieldStatus)
  4343. }
  4344. return fields
  4345. }
  4346. // FieldCleared returns a boolean indicating if a field with the given name was
  4347. // cleared in this mutation.
  4348. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  4349. _, ok := m.clearedFields[name]
  4350. return ok
  4351. }
  4352. // ClearField clears the value of the field with the given name. It returns an
  4353. // error if the field is not defined in the schema.
  4354. func (m *AllocAgentMutation) ClearField(name string) error {
  4355. switch name {
  4356. case allocagent.FieldDeletedAt:
  4357. m.ClearDeletedAt()
  4358. return nil
  4359. case allocagent.FieldUserID:
  4360. m.ClearUserID()
  4361. return nil
  4362. case allocagent.FieldOrganizationID:
  4363. m.ClearOrganizationID()
  4364. return nil
  4365. case allocagent.FieldStatus:
  4366. m.ClearStatus()
  4367. return nil
  4368. }
  4369. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  4370. }
  4371. // ResetField resets all changes in the mutation for the field with the given name.
  4372. // It returns an error if the field is not defined in the schema.
  4373. func (m *AllocAgentMutation) ResetField(name string) error {
  4374. switch name {
  4375. case allocagent.FieldCreatedAt:
  4376. m.ResetCreatedAt()
  4377. return nil
  4378. case allocagent.FieldUpdatedAt:
  4379. m.ResetUpdatedAt()
  4380. return nil
  4381. case allocagent.FieldDeletedAt:
  4382. m.ResetDeletedAt()
  4383. return nil
  4384. case allocagent.FieldUserID:
  4385. m.ResetUserID()
  4386. return nil
  4387. case allocagent.FieldOrganizationID:
  4388. m.ResetOrganizationID()
  4389. return nil
  4390. case allocagent.FieldAgents:
  4391. m.ResetAgents()
  4392. return nil
  4393. case allocagent.FieldStatus:
  4394. m.ResetStatus()
  4395. return nil
  4396. }
  4397. return fmt.Errorf("unknown AllocAgent field %s", name)
  4398. }
  4399. // AddedEdges returns all edge names that were set/added in this mutation.
  4400. func (m *AllocAgentMutation) AddedEdges() []string {
  4401. edges := make([]string, 0, 0)
  4402. return edges
  4403. }
  4404. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4405. // name in this mutation.
  4406. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  4407. return nil
  4408. }
  4409. // RemovedEdges returns all edge names that were removed in this mutation.
  4410. func (m *AllocAgentMutation) RemovedEdges() []string {
  4411. edges := make([]string, 0, 0)
  4412. return edges
  4413. }
  4414. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4415. // the given name in this mutation.
  4416. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  4417. return nil
  4418. }
  4419. // ClearedEdges returns all edge names that were cleared in this mutation.
  4420. func (m *AllocAgentMutation) ClearedEdges() []string {
  4421. edges := make([]string, 0, 0)
  4422. return edges
  4423. }
  4424. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4425. // was cleared in this mutation.
  4426. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  4427. return false
  4428. }
  4429. // ClearEdge clears the value of the edge with the given name. It returns an error
  4430. // if that edge is not defined in the schema.
  4431. func (m *AllocAgentMutation) ClearEdge(name string) error {
  4432. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  4433. }
  4434. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4435. // It returns an error if the edge is not defined in the schema.
  4436. func (m *AllocAgentMutation) ResetEdge(name string) error {
  4437. return fmt.Errorf("unknown AllocAgent edge %s", name)
  4438. }
  4439. // ApiKeyMutation represents an operation that mutates the ApiKey nodes in the graph.
  4440. type ApiKeyMutation struct {
  4441. config
  4442. op Op
  4443. typ string
  4444. id *uint64
  4445. created_at *time.Time
  4446. updated_at *time.Time
  4447. deleted_at *time.Time
  4448. title *string
  4449. key *string
  4450. organization_id *uint64
  4451. addorganization_id *int64
  4452. custom_agent_base *string
  4453. custom_agent_key *string
  4454. openai_base *string
  4455. openai_key *string
  4456. clearedFields map[string]struct{}
  4457. agent *uint64
  4458. clearedagent bool
  4459. done bool
  4460. oldValue func(context.Context) (*ApiKey, error)
  4461. predicates []predicate.ApiKey
  4462. }
  4463. var _ ent.Mutation = (*ApiKeyMutation)(nil)
  4464. // apikeyOption allows management of the mutation configuration using functional options.
  4465. type apikeyOption func(*ApiKeyMutation)
  4466. // newApiKeyMutation creates new mutation for the ApiKey entity.
  4467. func newApiKeyMutation(c config, op Op, opts ...apikeyOption) *ApiKeyMutation {
  4468. m := &ApiKeyMutation{
  4469. config: c,
  4470. op: op,
  4471. typ: TypeApiKey,
  4472. clearedFields: make(map[string]struct{}),
  4473. }
  4474. for _, opt := range opts {
  4475. opt(m)
  4476. }
  4477. return m
  4478. }
  4479. // withApiKeyID sets the ID field of the mutation.
  4480. func withApiKeyID(id uint64) apikeyOption {
  4481. return func(m *ApiKeyMutation) {
  4482. var (
  4483. err error
  4484. once sync.Once
  4485. value *ApiKey
  4486. )
  4487. m.oldValue = func(ctx context.Context) (*ApiKey, error) {
  4488. once.Do(func() {
  4489. if m.done {
  4490. err = errors.New("querying old values post mutation is not allowed")
  4491. } else {
  4492. value, err = m.Client().ApiKey.Get(ctx, id)
  4493. }
  4494. })
  4495. return value, err
  4496. }
  4497. m.id = &id
  4498. }
  4499. }
  4500. // withApiKey sets the old ApiKey of the mutation.
  4501. func withApiKey(node *ApiKey) apikeyOption {
  4502. return func(m *ApiKeyMutation) {
  4503. m.oldValue = func(context.Context) (*ApiKey, error) {
  4504. return node, nil
  4505. }
  4506. m.id = &node.ID
  4507. }
  4508. }
  4509. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4510. // executed in a transaction (ent.Tx), a transactional client is returned.
  4511. func (m ApiKeyMutation) Client() *Client {
  4512. client := &Client{config: m.config}
  4513. client.init()
  4514. return client
  4515. }
  4516. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4517. // it returns an error otherwise.
  4518. func (m ApiKeyMutation) Tx() (*Tx, error) {
  4519. if _, ok := m.driver.(*txDriver); !ok {
  4520. return nil, errors.New("ent: mutation is not running in a transaction")
  4521. }
  4522. tx := &Tx{config: m.config}
  4523. tx.init()
  4524. return tx, nil
  4525. }
  4526. // SetID sets the value of the id field. Note that this
  4527. // operation is only accepted on creation of ApiKey entities.
  4528. func (m *ApiKeyMutation) SetID(id uint64) {
  4529. m.id = &id
  4530. }
  4531. // ID returns the ID value in the mutation. Note that the ID is only available
  4532. // if it was provided to the builder or after it was returned from the database.
  4533. func (m *ApiKeyMutation) ID() (id uint64, exists bool) {
  4534. if m.id == nil {
  4535. return
  4536. }
  4537. return *m.id, true
  4538. }
  4539. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4540. // That means, if the mutation is applied within a transaction with an isolation level such
  4541. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4542. // or updated by the mutation.
  4543. func (m *ApiKeyMutation) IDs(ctx context.Context) ([]uint64, error) {
  4544. switch {
  4545. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4546. id, exists := m.ID()
  4547. if exists {
  4548. return []uint64{id}, nil
  4549. }
  4550. fallthrough
  4551. case m.op.Is(OpUpdate | OpDelete):
  4552. return m.Client().ApiKey.Query().Where(m.predicates...).IDs(ctx)
  4553. default:
  4554. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4555. }
  4556. }
  4557. // SetCreatedAt sets the "created_at" field.
  4558. func (m *ApiKeyMutation) SetCreatedAt(t time.Time) {
  4559. m.created_at = &t
  4560. }
  4561. // CreatedAt returns the value of the "created_at" field in the mutation.
  4562. func (m *ApiKeyMutation) CreatedAt() (r time.Time, exists bool) {
  4563. v := m.created_at
  4564. if v == nil {
  4565. return
  4566. }
  4567. return *v, true
  4568. }
  4569. // OldCreatedAt returns the old "created_at" field's value of the ApiKey entity.
  4570. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4572. func (m *ApiKeyMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4573. if !m.op.Is(OpUpdateOne) {
  4574. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4575. }
  4576. if m.id == nil || m.oldValue == nil {
  4577. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4578. }
  4579. oldValue, err := m.oldValue(ctx)
  4580. if err != nil {
  4581. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4582. }
  4583. return oldValue.CreatedAt, nil
  4584. }
  4585. // ResetCreatedAt resets all changes to the "created_at" field.
  4586. func (m *ApiKeyMutation) ResetCreatedAt() {
  4587. m.created_at = nil
  4588. }
  4589. // SetUpdatedAt sets the "updated_at" field.
  4590. func (m *ApiKeyMutation) SetUpdatedAt(t time.Time) {
  4591. m.updated_at = &t
  4592. }
  4593. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4594. func (m *ApiKeyMutation) UpdatedAt() (r time.Time, exists bool) {
  4595. v := m.updated_at
  4596. if v == nil {
  4597. return
  4598. }
  4599. return *v, true
  4600. }
  4601. // OldUpdatedAt returns the old "updated_at" field's value of the ApiKey entity.
  4602. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4603. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4604. func (m *ApiKeyMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4605. if !m.op.Is(OpUpdateOne) {
  4606. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4607. }
  4608. if m.id == nil || m.oldValue == nil {
  4609. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4610. }
  4611. oldValue, err := m.oldValue(ctx)
  4612. if err != nil {
  4613. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4614. }
  4615. return oldValue.UpdatedAt, nil
  4616. }
  4617. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4618. func (m *ApiKeyMutation) ResetUpdatedAt() {
  4619. m.updated_at = nil
  4620. }
  4621. // SetDeletedAt sets the "deleted_at" field.
  4622. func (m *ApiKeyMutation) SetDeletedAt(t time.Time) {
  4623. m.deleted_at = &t
  4624. }
  4625. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4626. func (m *ApiKeyMutation) DeletedAt() (r time.Time, exists bool) {
  4627. v := m.deleted_at
  4628. if v == nil {
  4629. return
  4630. }
  4631. return *v, true
  4632. }
  4633. // OldDeletedAt returns the old "deleted_at" field's value of the ApiKey entity.
  4634. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4636. func (m *ApiKeyMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4637. if !m.op.Is(OpUpdateOne) {
  4638. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4639. }
  4640. if m.id == nil || m.oldValue == nil {
  4641. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4642. }
  4643. oldValue, err := m.oldValue(ctx)
  4644. if err != nil {
  4645. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4646. }
  4647. return oldValue.DeletedAt, nil
  4648. }
  4649. // ClearDeletedAt clears the value of the "deleted_at" field.
  4650. func (m *ApiKeyMutation) ClearDeletedAt() {
  4651. m.deleted_at = nil
  4652. m.clearedFields[apikey.FieldDeletedAt] = struct{}{}
  4653. }
  4654. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4655. func (m *ApiKeyMutation) DeletedAtCleared() bool {
  4656. _, ok := m.clearedFields[apikey.FieldDeletedAt]
  4657. return ok
  4658. }
  4659. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4660. func (m *ApiKeyMutation) ResetDeletedAt() {
  4661. m.deleted_at = nil
  4662. delete(m.clearedFields, apikey.FieldDeletedAt)
  4663. }
  4664. // SetTitle sets the "title" field.
  4665. func (m *ApiKeyMutation) SetTitle(s string) {
  4666. m.title = &s
  4667. }
  4668. // Title returns the value of the "title" field in the mutation.
  4669. func (m *ApiKeyMutation) Title() (r string, exists bool) {
  4670. v := m.title
  4671. if v == nil {
  4672. return
  4673. }
  4674. return *v, true
  4675. }
  4676. // OldTitle returns the old "title" field's value of the ApiKey entity.
  4677. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4678. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4679. func (m *ApiKeyMutation) OldTitle(ctx context.Context) (v string, err error) {
  4680. if !m.op.Is(OpUpdateOne) {
  4681. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  4682. }
  4683. if m.id == nil || m.oldValue == nil {
  4684. return v, errors.New("OldTitle requires an ID field in the mutation")
  4685. }
  4686. oldValue, err := m.oldValue(ctx)
  4687. if err != nil {
  4688. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  4689. }
  4690. return oldValue.Title, nil
  4691. }
  4692. // ClearTitle clears the value of the "title" field.
  4693. func (m *ApiKeyMutation) ClearTitle() {
  4694. m.title = nil
  4695. m.clearedFields[apikey.FieldTitle] = struct{}{}
  4696. }
  4697. // TitleCleared returns if the "title" field was cleared in this mutation.
  4698. func (m *ApiKeyMutation) TitleCleared() bool {
  4699. _, ok := m.clearedFields[apikey.FieldTitle]
  4700. return ok
  4701. }
  4702. // ResetTitle resets all changes to the "title" field.
  4703. func (m *ApiKeyMutation) ResetTitle() {
  4704. m.title = nil
  4705. delete(m.clearedFields, apikey.FieldTitle)
  4706. }
  4707. // SetKey sets the "key" field.
  4708. func (m *ApiKeyMutation) SetKey(s string) {
  4709. m.key = &s
  4710. }
  4711. // Key returns the value of the "key" field in the mutation.
  4712. func (m *ApiKeyMutation) Key() (r string, exists bool) {
  4713. v := m.key
  4714. if v == nil {
  4715. return
  4716. }
  4717. return *v, true
  4718. }
  4719. // OldKey returns the old "key" field's value of the ApiKey entity.
  4720. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4721. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4722. func (m *ApiKeyMutation) OldKey(ctx context.Context) (v string, err error) {
  4723. if !m.op.Is(OpUpdateOne) {
  4724. return v, errors.New("OldKey is only allowed on UpdateOne operations")
  4725. }
  4726. if m.id == nil || m.oldValue == nil {
  4727. return v, errors.New("OldKey requires an ID field in the mutation")
  4728. }
  4729. oldValue, err := m.oldValue(ctx)
  4730. if err != nil {
  4731. return v, fmt.Errorf("querying old value for OldKey: %w", err)
  4732. }
  4733. return oldValue.Key, nil
  4734. }
  4735. // ClearKey clears the value of the "key" field.
  4736. func (m *ApiKeyMutation) ClearKey() {
  4737. m.key = nil
  4738. m.clearedFields[apikey.FieldKey] = struct{}{}
  4739. }
  4740. // KeyCleared returns if the "key" field was cleared in this mutation.
  4741. func (m *ApiKeyMutation) KeyCleared() bool {
  4742. _, ok := m.clearedFields[apikey.FieldKey]
  4743. return ok
  4744. }
  4745. // ResetKey resets all changes to the "key" field.
  4746. func (m *ApiKeyMutation) ResetKey() {
  4747. m.key = nil
  4748. delete(m.clearedFields, apikey.FieldKey)
  4749. }
  4750. // SetOrganizationID sets the "organization_id" field.
  4751. func (m *ApiKeyMutation) SetOrganizationID(u uint64) {
  4752. m.organization_id = &u
  4753. m.addorganization_id = nil
  4754. }
  4755. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4756. func (m *ApiKeyMutation) OrganizationID() (r uint64, exists bool) {
  4757. v := m.organization_id
  4758. if v == nil {
  4759. return
  4760. }
  4761. return *v, true
  4762. }
  4763. // OldOrganizationID returns the old "organization_id" field's value of the ApiKey entity.
  4764. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4765. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4766. func (m *ApiKeyMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4767. if !m.op.Is(OpUpdateOne) {
  4768. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4769. }
  4770. if m.id == nil || m.oldValue == nil {
  4771. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4772. }
  4773. oldValue, err := m.oldValue(ctx)
  4774. if err != nil {
  4775. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4776. }
  4777. return oldValue.OrganizationID, nil
  4778. }
  4779. // AddOrganizationID adds u to the "organization_id" field.
  4780. func (m *ApiKeyMutation) AddOrganizationID(u int64) {
  4781. if m.addorganization_id != nil {
  4782. *m.addorganization_id += u
  4783. } else {
  4784. m.addorganization_id = &u
  4785. }
  4786. }
  4787. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4788. func (m *ApiKeyMutation) AddedOrganizationID() (r int64, exists bool) {
  4789. v := m.addorganization_id
  4790. if v == nil {
  4791. return
  4792. }
  4793. return *v, true
  4794. }
  4795. // ResetOrganizationID resets all changes to the "organization_id" field.
  4796. func (m *ApiKeyMutation) ResetOrganizationID() {
  4797. m.organization_id = nil
  4798. m.addorganization_id = nil
  4799. }
  4800. // SetAgentID sets the "agent_id" field.
  4801. func (m *ApiKeyMutation) SetAgentID(u uint64) {
  4802. m.agent = &u
  4803. }
  4804. // AgentID returns the value of the "agent_id" field in the mutation.
  4805. func (m *ApiKeyMutation) AgentID() (r uint64, exists bool) {
  4806. v := m.agent
  4807. if v == nil {
  4808. return
  4809. }
  4810. return *v, true
  4811. }
  4812. // OldAgentID returns the old "agent_id" field's value of the ApiKey entity.
  4813. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4814. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4815. func (m *ApiKeyMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  4816. if !m.op.Is(OpUpdateOne) {
  4817. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  4818. }
  4819. if m.id == nil || m.oldValue == nil {
  4820. return v, errors.New("OldAgentID requires an ID field in the mutation")
  4821. }
  4822. oldValue, err := m.oldValue(ctx)
  4823. if err != nil {
  4824. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  4825. }
  4826. return oldValue.AgentID, nil
  4827. }
  4828. // ResetAgentID resets all changes to the "agent_id" field.
  4829. func (m *ApiKeyMutation) ResetAgentID() {
  4830. m.agent = nil
  4831. }
  4832. // SetCustomAgentBase sets the "custom_agent_base" field.
  4833. func (m *ApiKeyMutation) SetCustomAgentBase(s string) {
  4834. m.custom_agent_base = &s
  4835. }
  4836. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  4837. func (m *ApiKeyMutation) CustomAgentBase() (r string, exists bool) {
  4838. v := m.custom_agent_base
  4839. if v == nil {
  4840. return
  4841. }
  4842. return *v, true
  4843. }
  4844. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the ApiKey entity.
  4845. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4846. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4847. func (m *ApiKeyMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  4848. if !m.op.Is(OpUpdateOne) {
  4849. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  4850. }
  4851. if m.id == nil || m.oldValue == nil {
  4852. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  4853. }
  4854. oldValue, err := m.oldValue(ctx)
  4855. if err != nil {
  4856. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  4857. }
  4858. return oldValue.CustomAgentBase, nil
  4859. }
  4860. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  4861. func (m *ApiKeyMutation) ClearCustomAgentBase() {
  4862. m.custom_agent_base = nil
  4863. m.clearedFields[apikey.FieldCustomAgentBase] = struct{}{}
  4864. }
  4865. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  4866. func (m *ApiKeyMutation) CustomAgentBaseCleared() bool {
  4867. _, ok := m.clearedFields[apikey.FieldCustomAgentBase]
  4868. return ok
  4869. }
  4870. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  4871. func (m *ApiKeyMutation) ResetCustomAgentBase() {
  4872. m.custom_agent_base = nil
  4873. delete(m.clearedFields, apikey.FieldCustomAgentBase)
  4874. }
  4875. // SetCustomAgentKey sets the "custom_agent_key" field.
  4876. func (m *ApiKeyMutation) SetCustomAgentKey(s string) {
  4877. m.custom_agent_key = &s
  4878. }
  4879. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  4880. func (m *ApiKeyMutation) CustomAgentKey() (r string, exists bool) {
  4881. v := m.custom_agent_key
  4882. if v == nil {
  4883. return
  4884. }
  4885. return *v, true
  4886. }
  4887. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the ApiKey entity.
  4888. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4889. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4890. func (m *ApiKeyMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  4891. if !m.op.Is(OpUpdateOne) {
  4892. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  4893. }
  4894. if m.id == nil || m.oldValue == nil {
  4895. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  4896. }
  4897. oldValue, err := m.oldValue(ctx)
  4898. if err != nil {
  4899. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  4900. }
  4901. return oldValue.CustomAgentKey, nil
  4902. }
  4903. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  4904. func (m *ApiKeyMutation) ClearCustomAgentKey() {
  4905. m.custom_agent_key = nil
  4906. m.clearedFields[apikey.FieldCustomAgentKey] = struct{}{}
  4907. }
  4908. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  4909. func (m *ApiKeyMutation) CustomAgentKeyCleared() bool {
  4910. _, ok := m.clearedFields[apikey.FieldCustomAgentKey]
  4911. return ok
  4912. }
  4913. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  4914. func (m *ApiKeyMutation) ResetCustomAgentKey() {
  4915. m.custom_agent_key = nil
  4916. delete(m.clearedFields, apikey.FieldCustomAgentKey)
  4917. }
  4918. // SetOpenaiBase sets the "openai_base" field.
  4919. func (m *ApiKeyMutation) SetOpenaiBase(s string) {
  4920. m.openai_base = &s
  4921. }
  4922. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  4923. func (m *ApiKeyMutation) OpenaiBase() (r string, exists bool) {
  4924. v := m.openai_base
  4925. if v == nil {
  4926. return
  4927. }
  4928. return *v, true
  4929. }
  4930. // OldOpenaiBase returns the old "openai_base" field's value of the ApiKey entity.
  4931. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4932. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4933. func (m *ApiKeyMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  4934. if !m.op.Is(OpUpdateOne) {
  4935. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  4936. }
  4937. if m.id == nil || m.oldValue == nil {
  4938. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  4939. }
  4940. oldValue, err := m.oldValue(ctx)
  4941. if err != nil {
  4942. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  4943. }
  4944. return oldValue.OpenaiBase, nil
  4945. }
  4946. // ClearOpenaiBase clears the value of the "openai_base" field.
  4947. func (m *ApiKeyMutation) ClearOpenaiBase() {
  4948. m.openai_base = nil
  4949. m.clearedFields[apikey.FieldOpenaiBase] = struct{}{}
  4950. }
  4951. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  4952. func (m *ApiKeyMutation) OpenaiBaseCleared() bool {
  4953. _, ok := m.clearedFields[apikey.FieldOpenaiBase]
  4954. return ok
  4955. }
  4956. // ResetOpenaiBase resets all changes to the "openai_base" field.
  4957. func (m *ApiKeyMutation) ResetOpenaiBase() {
  4958. m.openai_base = nil
  4959. delete(m.clearedFields, apikey.FieldOpenaiBase)
  4960. }
  4961. // SetOpenaiKey sets the "openai_key" field.
  4962. func (m *ApiKeyMutation) SetOpenaiKey(s string) {
  4963. m.openai_key = &s
  4964. }
  4965. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  4966. func (m *ApiKeyMutation) OpenaiKey() (r string, exists bool) {
  4967. v := m.openai_key
  4968. if v == nil {
  4969. return
  4970. }
  4971. return *v, true
  4972. }
  4973. // OldOpenaiKey returns the old "openai_key" field's value of the ApiKey entity.
  4974. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4975. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4976. func (m *ApiKeyMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  4977. if !m.op.Is(OpUpdateOne) {
  4978. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  4979. }
  4980. if m.id == nil || m.oldValue == nil {
  4981. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  4982. }
  4983. oldValue, err := m.oldValue(ctx)
  4984. if err != nil {
  4985. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  4986. }
  4987. return oldValue.OpenaiKey, nil
  4988. }
  4989. // ClearOpenaiKey clears the value of the "openai_key" field.
  4990. func (m *ApiKeyMutation) ClearOpenaiKey() {
  4991. m.openai_key = nil
  4992. m.clearedFields[apikey.FieldOpenaiKey] = struct{}{}
  4993. }
  4994. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  4995. func (m *ApiKeyMutation) OpenaiKeyCleared() bool {
  4996. _, ok := m.clearedFields[apikey.FieldOpenaiKey]
  4997. return ok
  4998. }
  4999. // ResetOpenaiKey resets all changes to the "openai_key" field.
  5000. func (m *ApiKeyMutation) ResetOpenaiKey() {
  5001. m.openai_key = nil
  5002. delete(m.clearedFields, apikey.FieldOpenaiKey)
  5003. }
  5004. // ClearAgent clears the "agent" edge to the Agent entity.
  5005. func (m *ApiKeyMutation) ClearAgent() {
  5006. m.clearedagent = true
  5007. m.clearedFields[apikey.FieldAgentID] = struct{}{}
  5008. }
  5009. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  5010. func (m *ApiKeyMutation) AgentCleared() bool {
  5011. return m.clearedagent
  5012. }
  5013. // AgentIDs returns the "agent" edge IDs in the mutation.
  5014. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  5015. // AgentID instead. It exists only for internal usage by the builders.
  5016. func (m *ApiKeyMutation) AgentIDs() (ids []uint64) {
  5017. if id := m.agent; id != nil {
  5018. ids = append(ids, *id)
  5019. }
  5020. return
  5021. }
  5022. // ResetAgent resets all changes to the "agent" edge.
  5023. func (m *ApiKeyMutation) ResetAgent() {
  5024. m.agent = nil
  5025. m.clearedagent = false
  5026. }
  5027. // Where appends a list predicates to the ApiKeyMutation builder.
  5028. func (m *ApiKeyMutation) Where(ps ...predicate.ApiKey) {
  5029. m.predicates = append(m.predicates, ps...)
  5030. }
  5031. // WhereP appends storage-level predicates to the ApiKeyMutation builder. Using this method,
  5032. // users can use type-assertion to append predicates that do not depend on any generated package.
  5033. func (m *ApiKeyMutation) WhereP(ps ...func(*sql.Selector)) {
  5034. p := make([]predicate.ApiKey, len(ps))
  5035. for i := range ps {
  5036. p[i] = ps[i]
  5037. }
  5038. m.Where(p...)
  5039. }
  5040. // Op returns the operation name.
  5041. func (m *ApiKeyMutation) Op() Op {
  5042. return m.op
  5043. }
  5044. // SetOp allows setting the mutation operation.
  5045. func (m *ApiKeyMutation) SetOp(op Op) {
  5046. m.op = op
  5047. }
  5048. // Type returns the node type of this mutation (ApiKey).
  5049. func (m *ApiKeyMutation) Type() string {
  5050. return m.typ
  5051. }
  5052. // Fields returns all fields that were changed during this mutation. Note that in
  5053. // order to get all numeric fields that were incremented/decremented, call
  5054. // AddedFields().
  5055. func (m *ApiKeyMutation) Fields() []string {
  5056. fields := make([]string, 0, 11)
  5057. if m.created_at != nil {
  5058. fields = append(fields, apikey.FieldCreatedAt)
  5059. }
  5060. if m.updated_at != nil {
  5061. fields = append(fields, apikey.FieldUpdatedAt)
  5062. }
  5063. if m.deleted_at != nil {
  5064. fields = append(fields, apikey.FieldDeletedAt)
  5065. }
  5066. if m.title != nil {
  5067. fields = append(fields, apikey.FieldTitle)
  5068. }
  5069. if m.key != nil {
  5070. fields = append(fields, apikey.FieldKey)
  5071. }
  5072. if m.organization_id != nil {
  5073. fields = append(fields, apikey.FieldOrganizationID)
  5074. }
  5075. if m.agent != nil {
  5076. fields = append(fields, apikey.FieldAgentID)
  5077. }
  5078. if m.custom_agent_base != nil {
  5079. fields = append(fields, apikey.FieldCustomAgentBase)
  5080. }
  5081. if m.custom_agent_key != nil {
  5082. fields = append(fields, apikey.FieldCustomAgentKey)
  5083. }
  5084. if m.openai_base != nil {
  5085. fields = append(fields, apikey.FieldOpenaiBase)
  5086. }
  5087. if m.openai_key != nil {
  5088. fields = append(fields, apikey.FieldOpenaiKey)
  5089. }
  5090. return fields
  5091. }
  5092. // Field returns the value of a field with the given name. The second boolean
  5093. // return value indicates that this field was not set, or was not defined in the
  5094. // schema.
  5095. func (m *ApiKeyMutation) Field(name string) (ent.Value, bool) {
  5096. switch name {
  5097. case apikey.FieldCreatedAt:
  5098. return m.CreatedAt()
  5099. case apikey.FieldUpdatedAt:
  5100. return m.UpdatedAt()
  5101. case apikey.FieldDeletedAt:
  5102. return m.DeletedAt()
  5103. case apikey.FieldTitle:
  5104. return m.Title()
  5105. case apikey.FieldKey:
  5106. return m.Key()
  5107. case apikey.FieldOrganizationID:
  5108. return m.OrganizationID()
  5109. case apikey.FieldAgentID:
  5110. return m.AgentID()
  5111. case apikey.FieldCustomAgentBase:
  5112. return m.CustomAgentBase()
  5113. case apikey.FieldCustomAgentKey:
  5114. return m.CustomAgentKey()
  5115. case apikey.FieldOpenaiBase:
  5116. return m.OpenaiBase()
  5117. case apikey.FieldOpenaiKey:
  5118. return m.OpenaiKey()
  5119. }
  5120. return nil, false
  5121. }
  5122. // OldField returns the old value of the field from the database. An error is
  5123. // returned if the mutation operation is not UpdateOne, or the query to the
  5124. // database failed.
  5125. func (m *ApiKeyMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5126. switch name {
  5127. case apikey.FieldCreatedAt:
  5128. return m.OldCreatedAt(ctx)
  5129. case apikey.FieldUpdatedAt:
  5130. return m.OldUpdatedAt(ctx)
  5131. case apikey.FieldDeletedAt:
  5132. return m.OldDeletedAt(ctx)
  5133. case apikey.FieldTitle:
  5134. return m.OldTitle(ctx)
  5135. case apikey.FieldKey:
  5136. return m.OldKey(ctx)
  5137. case apikey.FieldOrganizationID:
  5138. return m.OldOrganizationID(ctx)
  5139. case apikey.FieldAgentID:
  5140. return m.OldAgentID(ctx)
  5141. case apikey.FieldCustomAgentBase:
  5142. return m.OldCustomAgentBase(ctx)
  5143. case apikey.FieldCustomAgentKey:
  5144. return m.OldCustomAgentKey(ctx)
  5145. case apikey.FieldOpenaiBase:
  5146. return m.OldOpenaiBase(ctx)
  5147. case apikey.FieldOpenaiKey:
  5148. return m.OldOpenaiKey(ctx)
  5149. }
  5150. return nil, fmt.Errorf("unknown ApiKey field %s", name)
  5151. }
  5152. // SetField sets the value of a field with the given name. It returns an error if
  5153. // the field is not defined in the schema, or if the type mismatched the field
  5154. // type.
  5155. func (m *ApiKeyMutation) SetField(name string, value ent.Value) error {
  5156. switch name {
  5157. case apikey.FieldCreatedAt:
  5158. v, ok := value.(time.Time)
  5159. if !ok {
  5160. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5161. }
  5162. m.SetCreatedAt(v)
  5163. return nil
  5164. case apikey.FieldUpdatedAt:
  5165. v, ok := value.(time.Time)
  5166. if !ok {
  5167. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5168. }
  5169. m.SetUpdatedAt(v)
  5170. return nil
  5171. case apikey.FieldDeletedAt:
  5172. v, ok := value.(time.Time)
  5173. if !ok {
  5174. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5175. }
  5176. m.SetDeletedAt(v)
  5177. return nil
  5178. case apikey.FieldTitle:
  5179. v, ok := value.(string)
  5180. if !ok {
  5181. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5182. }
  5183. m.SetTitle(v)
  5184. return nil
  5185. case apikey.FieldKey:
  5186. v, ok := value.(string)
  5187. if !ok {
  5188. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5189. }
  5190. m.SetKey(v)
  5191. return nil
  5192. case apikey.FieldOrganizationID:
  5193. v, ok := value.(uint64)
  5194. if !ok {
  5195. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5196. }
  5197. m.SetOrganizationID(v)
  5198. return nil
  5199. case apikey.FieldAgentID:
  5200. v, ok := value.(uint64)
  5201. if !ok {
  5202. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5203. }
  5204. m.SetAgentID(v)
  5205. return nil
  5206. case apikey.FieldCustomAgentBase:
  5207. v, ok := value.(string)
  5208. if !ok {
  5209. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5210. }
  5211. m.SetCustomAgentBase(v)
  5212. return nil
  5213. case apikey.FieldCustomAgentKey:
  5214. v, ok := value.(string)
  5215. if !ok {
  5216. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5217. }
  5218. m.SetCustomAgentKey(v)
  5219. return nil
  5220. case apikey.FieldOpenaiBase:
  5221. v, ok := value.(string)
  5222. if !ok {
  5223. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5224. }
  5225. m.SetOpenaiBase(v)
  5226. return nil
  5227. case apikey.FieldOpenaiKey:
  5228. v, ok := value.(string)
  5229. if !ok {
  5230. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5231. }
  5232. m.SetOpenaiKey(v)
  5233. return nil
  5234. }
  5235. return fmt.Errorf("unknown ApiKey field %s", name)
  5236. }
  5237. // AddedFields returns all numeric fields that were incremented/decremented during
  5238. // this mutation.
  5239. func (m *ApiKeyMutation) AddedFields() []string {
  5240. var fields []string
  5241. if m.addorganization_id != nil {
  5242. fields = append(fields, apikey.FieldOrganizationID)
  5243. }
  5244. return fields
  5245. }
  5246. // AddedField returns the numeric value that was incremented/decremented on a field
  5247. // with the given name. The second boolean return value indicates that this field
  5248. // was not set, or was not defined in the schema.
  5249. func (m *ApiKeyMutation) AddedField(name string) (ent.Value, bool) {
  5250. switch name {
  5251. case apikey.FieldOrganizationID:
  5252. return m.AddedOrganizationID()
  5253. }
  5254. return nil, false
  5255. }
  5256. // AddField adds the value to the field with the given name. It returns an error if
  5257. // the field is not defined in the schema, or if the type mismatched the field
  5258. // type.
  5259. func (m *ApiKeyMutation) AddField(name string, value ent.Value) error {
  5260. switch name {
  5261. case apikey.FieldOrganizationID:
  5262. v, ok := value.(int64)
  5263. if !ok {
  5264. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5265. }
  5266. m.AddOrganizationID(v)
  5267. return nil
  5268. }
  5269. return fmt.Errorf("unknown ApiKey numeric field %s", name)
  5270. }
  5271. // ClearedFields returns all nullable fields that were cleared during this
  5272. // mutation.
  5273. func (m *ApiKeyMutation) ClearedFields() []string {
  5274. var fields []string
  5275. if m.FieldCleared(apikey.FieldDeletedAt) {
  5276. fields = append(fields, apikey.FieldDeletedAt)
  5277. }
  5278. if m.FieldCleared(apikey.FieldTitle) {
  5279. fields = append(fields, apikey.FieldTitle)
  5280. }
  5281. if m.FieldCleared(apikey.FieldKey) {
  5282. fields = append(fields, apikey.FieldKey)
  5283. }
  5284. if m.FieldCleared(apikey.FieldCustomAgentBase) {
  5285. fields = append(fields, apikey.FieldCustomAgentBase)
  5286. }
  5287. if m.FieldCleared(apikey.FieldCustomAgentKey) {
  5288. fields = append(fields, apikey.FieldCustomAgentKey)
  5289. }
  5290. if m.FieldCleared(apikey.FieldOpenaiBase) {
  5291. fields = append(fields, apikey.FieldOpenaiBase)
  5292. }
  5293. if m.FieldCleared(apikey.FieldOpenaiKey) {
  5294. fields = append(fields, apikey.FieldOpenaiKey)
  5295. }
  5296. return fields
  5297. }
  5298. // FieldCleared returns a boolean indicating if a field with the given name was
  5299. // cleared in this mutation.
  5300. func (m *ApiKeyMutation) FieldCleared(name string) bool {
  5301. _, ok := m.clearedFields[name]
  5302. return ok
  5303. }
  5304. // ClearField clears the value of the field with the given name. It returns an
  5305. // error if the field is not defined in the schema.
  5306. func (m *ApiKeyMutation) ClearField(name string) error {
  5307. switch name {
  5308. case apikey.FieldDeletedAt:
  5309. m.ClearDeletedAt()
  5310. return nil
  5311. case apikey.FieldTitle:
  5312. m.ClearTitle()
  5313. return nil
  5314. case apikey.FieldKey:
  5315. m.ClearKey()
  5316. return nil
  5317. case apikey.FieldCustomAgentBase:
  5318. m.ClearCustomAgentBase()
  5319. return nil
  5320. case apikey.FieldCustomAgentKey:
  5321. m.ClearCustomAgentKey()
  5322. return nil
  5323. case apikey.FieldOpenaiBase:
  5324. m.ClearOpenaiBase()
  5325. return nil
  5326. case apikey.FieldOpenaiKey:
  5327. m.ClearOpenaiKey()
  5328. return nil
  5329. }
  5330. return fmt.Errorf("unknown ApiKey nullable field %s", name)
  5331. }
  5332. // ResetField resets all changes in the mutation for the field with the given name.
  5333. // It returns an error if the field is not defined in the schema.
  5334. func (m *ApiKeyMutation) ResetField(name string) error {
  5335. switch name {
  5336. case apikey.FieldCreatedAt:
  5337. m.ResetCreatedAt()
  5338. return nil
  5339. case apikey.FieldUpdatedAt:
  5340. m.ResetUpdatedAt()
  5341. return nil
  5342. case apikey.FieldDeletedAt:
  5343. m.ResetDeletedAt()
  5344. return nil
  5345. case apikey.FieldTitle:
  5346. m.ResetTitle()
  5347. return nil
  5348. case apikey.FieldKey:
  5349. m.ResetKey()
  5350. return nil
  5351. case apikey.FieldOrganizationID:
  5352. m.ResetOrganizationID()
  5353. return nil
  5354. case apikey.FieldAgentID:
  5355. m.ResetAgentID()
  5356. return nil
  5357. case apikey.FieldCustomAgentBase:
  5358. m.ResetCustomAgentBase()
  5359. return nil
  5360. case apikey.FieldCustomAgentKey:
  5361. m.ResetCustomAgentKey()
  5362. return nil
  5363. case apikey.FieldOpenaiBase:
  5364. m.ResetOpenaiBase()
  5365. return nil
  5366. case apikey.FieldOpenaiKey:
  5367. m.ResetOpenaiKey()
  5368. return nil
  5369. }
  5370. return fmt.Errorf("unknown ApiKey field %s", name)
  5371. }
  5372. // AddedEdges returns all edge names that were set/added in this mutation.
  5373. func (m *ApiKeyMutation) AddedEdges() []string {
  5374. edges := make([]string, 0, 1)
  5375. if m.agent != nil {
  5376. edges = append(edges, apikey.EdgeAgent)
  5377. }
  5378. return edges
  5379. }
  5380. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5381. // name in this mutation.
  5382. func (m *ApiKeyMutation) AddedIDs(name string) []ent.Value {
  5383. switch name {
  5384. case apikey.EdgeAgent:
  5385. if id := m.agent; id != nil {
  5386. return []ent.Value{*id}
  5387. }
  5388. }
  5389. return nil
  5390. }
  5391. // RemovedEdges returns all edge names that were removed in this mutation.
  5392. func (m *ApiKeyMutation) RemovedEdges() []string {
  5393. edges := make([]string, 0, 1)
  5394. return edges
  5395. }
  5396. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5397. // the given name in this mutation.
  5398. func (m *ApiKeyMutation) RemovedIDs(name string) []ent.Value {
  5399. return nil
  5400. }
  5401. // ClearedEdges returns all edge names that were cleared in this mutation.
  5402. func (m *ApiKeyMutation) ClearedEdges() []string {
  5403. edges := make([]string, 0, 1)
  5404. if m.clearedagent {
  5405. edges = append(edges, apikey.EdgeAgent)
  5406. }
  5407. return edges
  5408. }
  5409. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5410. // was cleared in this mutation.
  5411. func (m *ApiKeyMutation) EdgeCleared(name string) bool {
  5412. switch name {
  5413. case apikey.EdgeAgent:
  5414. return m.clearedagent
  5415. }
  5416. return false
  5417. }
  5418. // ClearEdge clears the value of the edge with the given name. It returns an error
  5419. // if that edge is not defined in the schema.
  5420. func (m *ApiKeyMutation) ClearEdge(name string) error {
  5421. switch name {
  5422. case apikey.EdgeAgent:
  5423. m.ClearAgent()
  5424. return nil
  5425. }
  5426. return fmt.Errorf("unknown ApiKey unique edge %s", name)
  5427. }
  5428. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5429. // It returns an error if the edge is not defined in the schema.
  5430. func (m *ApiKeyMutation) ResetEdge(name string) error {
  5431. switch name {
  5432. case apikey.EdgeAgent:
  5433. m.ResetAgent()
  5434. return nil
  5435. }
  5436. return fmt.Errorf("unknown ApiKey edge %s", name)
  5437. }
  5438. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  5439. type BatchMsgMutation struct {
  5440. config
  5441. op Op
  5442. typ string
  5443. id *uint64
  5444. created_at *time.Time
  5445. updated_at *time.Time
  5446. deleted_at *time.Time
  5447. status *uint8
  5448. addstatus *int8
  5449. batch_no *string
  5450. task_name *string
  5451. fromwxid *string
  5452. msg *string
  5453. tag *string
  5454. tagids *string
  5455. total *int32
  5456. addtotal *int32
  5457. success *int32
  5458. addsuccess *int32
  5459. fail *int32
  5460. addfail *int32
  5461. start_time *time.Time
  5462. stop_time *time.Time
  5463. send_time *time.Time
  5464. _type *int32
  5465. add_type *int32
  5466. organization_id *uint64
  5467. addorganization_id *int64
  5468. ctype *uint64
  5469. addctype *int64
  5470. cc *string
  5471. phone *string
  5472. template_name *string
  5473. template_code *string
  5474. lang *string
  5475. clearedFields map[string]struct{}
  5476. done bool
  5477. oldValue func(context.Context) (*BatchMsg, error)
  5478. predicates []predicate.BatchMsg
  5479. }
  5480. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  5481. // batchmsgOption allows management of the mutation configuration using functional options.
  5482. type batchmsgOption func(*BatchMsgMutation)
  5483. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  5484. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  5485. m := &BatchMsgMutation{
  5486. config: c,
  5487. op: op,
  5488. typ: TypeBatchMsg,
  5489. clearedFields: make(map[string]struct{}),
  5490. }
  5491. for _, opt := range opts {
  5492. opt(m)
  5493. }
  5494. return m
  5495. }
  5496. // withBatchMsgID sets the ID field of the mutation.
  5497. func withBatchMsgID(id uint64) batchmsgOption {
  5498. return func(m *BatchMsgMutation) {
  5499. var (
  5500. err error
  5501. once sync.Once
  5502. value *BatchMsg
  5503. )
  5504. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  5505. once.Do(func() {
  5506. if m.done {
  5507. err = errors.New("querying old values post mutation is not allowed")
  5508. } else {
  5509. value, err = m.Client().BatchMsg.Get(ctx, id)
  5510. }
  5511. })
  5512. return value, err
  5513. }
  5514. m.id = &id
  5515. }
  5516. }
  5517. // withBatchMsg sets the old BatchMsg of the mutation.
  5518. func withBatchMsg(node *BatchMsg) batchmsgOption {
  5519. return func(m *BatchMsgMutation) {
  5520. m.oldValue = func(context.Context) (*BatchMsg, error) {
  5521. return node, nil
  5522. }
  5523. m.id = &node.ID
  5524. }
  5525. }
  5526. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5527. // executed in a transaction (ent.Tx), a transactional client is returned.
  5528. func (m BatchMsgMutation) Client() *Client {
  5529. client := &Client{config: m.config}
  5530. client.init()
  5531. return client
  5532. }
  5533. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5534. // it returns an error otherwise.
  5535. func (m BatchMsgMutation) Tx() (*Tx, error) {
  5536. if _, ok := m.driver.(*txDriver); !ok {
  5537. return nil, errors.New("ent: mutation is not running in a transaction")
  5538. }
  5539. tx := &Tx{config: m.config}
  5540. tx.init()
  5541. return tx, nil
  5542. }
  5543. // SetID sets the value of the id field. Note that this
  5544. // operation is only accepted on creation of BatchMsg entities.
  5545. func (m *BatchMsgMutation) SetID(id uint64) {
  5546. m.id = &id
  5547. }
  5548. // ID returns the ID value in the mutation. Note that the ID is only available
  5549. // if it was provided to the builder or after it was returned from the database.
  5550. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  5551. if m.id == nil {
  5552. return
  5553. }
  5554. return *m.id, true
  5555. }
  5556. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5557. // That means, if the mutation is applied within a transaction with an isolation level such
  5558. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5559. // or updated by the mutation.
  5560. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  5561. switch {
  5562. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5563. id, exists := m.ID()
  5564. if exists {
  5565. return []uint64{id}, nil
  5566. }
  5567. fallthrough
  5568. case m.op.Is(OpUpdate | OpDelete):
  5569. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  5570. default:
  5571. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5572. }
  5573. }
  5574. // SetCreatedAt sets the "created_at" field.
  5575. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  5576. m.created_at = &t
  5577. }
  5578. // CreatedAt returns the value of the "created_at" field in the mutation.
  5579. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  5580. v := m.created_at
  5581. if v == nil {
  5582. return
  5583. }
  5584. return *v, true
  5585. }
  5586. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  5587. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5588. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5589. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5590. if !m.op.Is(OpUpdateOne) {
  5591. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5592. }
  5593. if m.id == nil || m.oldValue == nil {
  5594. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5595. }
  5596. oldValue, err := m.oldValue(ctx)
  5597. if err != nil {
  5598. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5599. }
  5600. return oldValue.CreatedAt, nil
  5601. }
  5602. // ResetCreatedAt resets all changes to the "created_at" field.
  5603. func (m *BatchMsgMutation) ResetCreatedAt() {
  5604. m.created_at = nil
  5605. }
  5606. // SetUpdatedAt sets the "updated_at" field.
  5607. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  5608. m.updated_at = &t
  5609. }
  5610. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5611. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  5612. v := m.updated_at
  5613. if v == nil {
  5614. return
  5615. }
  5616. return *v, true
  5617. }
  5618. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  5619. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5621. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5622. if !m.op.Is(OpUpdateOne) {
  5623. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5624. }
  5625. if m.id == nil || m.oldValue == nil {
  5626. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5627. }
  5628. oldValue, err := m.oldValue(ctx)
  5629. if err != nil {
  5630. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5631. }
  5632. return oldValue.UpdatedAt, nil
  5633. }
  5634. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5635. func (m *BatchMsgMutation) ResetUpdatedAt() {
  5636. m.updated_at = nil
  5637. }
  5638. // SetDeletedAt sets the "deleted_at" field.
  5639. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  5640. m.deleted_at = &t
  5641. }
  5642. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5643. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  5644. v := m.deleted_at
  5645. if v == nil {
  5646. return
  5647. }
  5648. return *v, true
  5649. }
  5650. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  5651. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5652. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5653. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5654. if !m.op.Is(OpUpdateOne) {
  5655. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5656. }
  5657. if m.id == nil || m.oldValue == nil {
  5658. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5659. }
  5660. oldValue, err := m.oldValue(ctx)
  5661. if err != nil {
  5662. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5663. }
  5664. return oldValue.DeletedAt, nil
  5665. }
  5666. // ClearDeletedAt clears the value of the "deleted_at" field.
  5667. func (m *BatchMsgMutation) ClearDeletedAt() {
  5668. m.deleted_at = nil
  5669. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  5670. }
  5671. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5672. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  5673. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  5674. return ok
  5675. }
  5676. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5677. func (m *BatchMsgMutation) ResetDeletedAt() {
  5678. m.deleted_at = nil
  5679. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  5680. }
  5681. // SetStatus sets the "status" field.
  5682. func (m *BatchMsgMutation) SetStatus(u uint8) {
  5683. m.status = &u
  5684. m.addstatus = nil
  5685. }
  5686. // Status returns the value of the "status" field in the mutation.
  5687. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  5688. v := m.status
  5689. if v == nil {
  5690. return
  5691. }
  5692. return *v, true
  5693. }
  5694. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  5695. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5696. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5697. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  5698. if !m.op.Is(OpUpdateOne) {
  5699. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  5700. }
  5701. if m.id == nil || m.oldValue == nil {
  5702. return v, errors.New("OldStatus requires an ID field in the mutation")
  5703. }
  5704. oldValue, err := m.oldValue(ctx)
  5705. if err != nil {
  5706. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  5707. }
  5708. return oldValue.Status, nil
  5709. }
  5710. // AddStatus adds u to the "status" field.
  5711. func (m *BatchMsgMutation) AddStatus(u int8) {
  5712. if m.addstatus != nil {
  5713. *m.addstatus += u
  5714. } else {
  5715. m.addstatus = &u
  5716. }
  5717. }
  5718. // AddedStatus returns the value that was added to the "status" field in this mutation.
  5719. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  5720. v := m.addstatus
  5721. if v == nil {
  5722. return
  5723. }
  5724. return *v, true
  5725. }
  5726. // ClearStatus clears the value of the "status" field.
  5727. func (m *BatchMsgMutation) ClearStatus() {
  5728. m.status = nil
  5729. m.addstatus = nil
  5730. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  5731. }
  5732. // StatusCleared returns if the "status" field was cleared in this mutation.
  5733. func (m *BatchMsgMutation) StatusCleared() bool {
  5734. _, ok := m.clearedFields[batchmsg.FieldStatus]
  5735. return ok
  5736. }
  5737. // ResetStatus resets all changes to the "status" field.
  5738. func (m *BatchMsgMutation) ResetStatus() {
  5739. m.status = nil
  5740. m.addstatus = nil
  5741. delete(m.clearedFields, batchmsg.FieldStatus)
  5742. }
  5743. // SetBatchNo sets the "batch_no" field.
  5744. func (m *BatchMsgMutation) SetBatchNo(s string) {
  5745. m.batch_no = &s
  5746. }
  5747. // BatchNo returns the value of the "batch_no" field in the mutation.
  5748. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  5749. v := m.batch_no
  5750. if v == nil {
  5751. return
  5752. }
  5753. return *v, true
  5754. }
  5755. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  5756. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5757. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5758. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  5759. if !m.op.Is(OpUpdateOne) {
  5760. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  5761. }
  5762. if m.id == nil || m.oldValue == nil {
  5763. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  5764. }
  5765. oldValue, err := m.oldValue(ctx)
  5766. if err != nil {
  5767. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  5768. }
  5769. return oldValue.BatchNo, nil
  5770. }
  5771. // ClearBatchNo clears the value of the "batch_no" field.
  5772. func (m *BatchMsgMutation) ClearBatchNo() {
  5773. m.batch_no = nil
  5774. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  5775. }
  5776. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  5777. func (m *BatchMsgMutation) BatchNoCleared() bool {
  5778. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  5779. return ok
  5780. }
  5781. // ResetBatchNo resets all changes to the "batch_no" field.
  5782. func (m *BatchMsgMutation) ResetBatchNo() {
  5783. m.batch_no = nil
  5784. delete(m.clearedFields, batchmsg.FieldBatchNo)
  5785. }
  5786. // SetTaskName sets the "task_name" field.
  5787. func (m *BatchMsgMutation) SetTaskName(s string) {
  5788. m.task_name = &s
  5789. }
  5790. // TaskName returns the value of the "task_name" field in the mutation.
  5791. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  5792. v := m.task_name
  5793. if v == nil {
  5794. return
  5795. }
  5796. return *v, true
  5797. }
  5798. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  5799. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5801. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  5802. if !m.op.Is(OpUpdateOne) {
  5803. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  5804. }
  5805. if m.id == nil || m.oldValue == nil {
  5806. return v, errors.New("OldTaskName requires an ID field in the mutation")
  5807. }
  5808. oldValue, err := m.oldValue(ctx)
  5809. if err != nil {
  5810. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  5811. }
  5812. return oldValue.TaskName, nil
  5813. }
  5814. // ClearTaskName clears the value of the "task_name" field.
  5815. func (m *BatchMsgMutation) ClearTaskName() {
  5816. m.task_name = nil
  5817. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  5818. }
  5819. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  5820. func (m *BatchMsgMutation) TaskNameCleared() bool {
  5821. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  5822. return ok
  5823. }
  5824. // ResetTaskName resets all changes to the "task_name" field.
  5825. func (m *BatchMsgMutation) ResetTaskName() {
  5826. m.task_name = nil
  5827. delete(m.clearedFields, batchmsg.FieldTaskName)
  5828. }
  5829. // SetFromwxid sets the "fromwxid" field.
  5830. func (m *BatchMsgMutation) SetFromwxid(s string) {
  5831. m.fromwxid = &s
  5832. }
  5833. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  5834. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  5835. v := m.fromwxid
  5836. if v == nil {
  5837. return
  5838. }
  5839. return *v, true
  5840. }
  5841. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  5842. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5843. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5844. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  5845. if !m.op.Is(OpUpdateOne) {
  5846. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  5847. }
  5848. if m.id == nil || m.oldValue == nil {
  5849. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  5850. }
  5851. oldValue, err := m.oldValue(ctx)
  5852. if err != nil {
  5853. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  5854. }
  5855. return oldValue.Fromwxid, nil
  5856. }
  5857. // ClearFromwxid clears the value of the "fromwxid" field.
  5858. func (m *BatchMsgMutation) ClearFromwxid() {
  5859. m.fromwxid = nil
  5860. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  5861. }
  5862. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  5863. func (m *BatchMsgMutation) FromwxidCleared() bool {
  5864. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  5865. return ok
  5866. }
  5867. // ResetFromwxid resets all changes to the "fromwxid" field.
  5868. func (m *BatchMsgMutation) ResetFromwxid() {
  5869. m.fromwxid = nil
  5870. delete(m.clearedFields, batchmsg.FieldFromwxid)
  5871. }
  5872. // SetMsg sets the "msg" field.
  5873. func (m *BatchMsgMutation) SetMsg(s string) {
  5874. m.msg = &s
  5875. }
  5876. // Msg returns the value of the "msg" field in the mutation.
  5877. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  5878. v := m.msg
  5879. if v == nil {
  5880. return
  5881. }
  5882. return *v, true
  5883. }
  5884. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  5885. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5886. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5887. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  5888. if !m.op.Is(OpUpdateOne) {
  5889. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  5890. }
  5891. if m.id == nil || m.oldValue == nil {
  5892. return v, errors.New("OldMsg requires an ID field in the mutation")
  5893. }
  5894. oldValue, err := m.oldValue(ctx)
  5895. if err != nil {
  5896. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  5897. }
  5898. return oldValue.Msg, nil
  5899. }
  5900. // ClearMsg clears the value of the "msg" field.
  5901. func (m *BatchMsgMutation) ClearMsg() {
  5902. m.msg = nil
  5903. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  5904. }
  5905. // MsgCleared returns if the "msg" field was cleared in this mutation.
  5906. func (m *BatchMsgMutation) MsgCleared() bool {
  5907. _, ok := m.clearedFields[batchmsg.FieldMsg]
  5908. return ok
  5909. }
  5910. // ResetMsg resets all changes to the "msg" field.
  5911. func (m *BatchMsgMutation) ResetMsg() {
  5912. m.msg = nil
  5913. delete(m.clearedFields, batchmsg.FieldMsg)
  5914. }
  5915. // SetTag sets the "tag" field.
  5916. func (m *BatchMsgMutation) SetTag(s string) {
  5917. m.tag = &s
  5918. }
  5919. // Tag returns the value of the "tag" field in the mutation.
  5920. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  5921. v := m.tag
  5922. if v == nil {
  5923. return
  5924. }
  5925. return *v, true
  5926. }
  5927. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  5928. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5929. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5930. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  5931. if !m.op.Is(OpUpdateOne) {
  5932. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  5933. }
  5934. if m.id == nil || m.oldValue == nil {
  5935. return v, errors.New("OldTag requires an ID field in the mutation")
  5936. }
  5937. oldValue, err := m.oldValue(ctx)
  5938. if err != nil {
  5939. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  5940. }
  5941. return oldValue.Tag, nil
  5942. }
  5943. // ClearTag clears the value of the "tag" field.
  5944. func (m *BatchMsgMutation) ClearTag() {
  5945. m.tag = nil
  5946. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  5947. }
  5948. // TagCleared returns if the "tag" field was cleared in this mutation.
  5949. func (m *BatchMsgMutation) TagCleared() bool {
  5950. _, ok := m.clearedFields[batchmsg.FieldTag]
  5951. return ok
  5952. }
  5953. // ResetTag resets all changes to the "tag" field.
  5954. func (m *BatchMsgMutation) ResetTag() {
  5955. m.tag = nil
  5956. delete(m.clearedFields, batchmsg.FieldTag)
  5957. }
  5958. // SetTagids sets the "tagids" field.
  5959. func (m *BatchMsgMutation) SetTagids(s string) {
  5960. m.tagids = &s
  5961. }
  5962. // Tagids returns the value of the "tagids" field in the mutation.
  5963. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  5964. v := m.tagids
  5965. if v == nil {
  5966. return
  5967. }
  5968. return *v, true
  5969. }
  5970. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  5971. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5972. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5973. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  5974. if !m.op.Is(OpUpdateOne) {
  5975. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  5976. }
  5977. if m.id == nil || m.oldValue == nil {
  5978. return v, errors.New("OldTagids requires an ID field in the mutation")
  5979. }
  5980. oldValue, err := m.oldValue(ctx)
  5981. if err != nil {
  5982. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  5983. }
  5984. return oldValue.Tagids, nil
  5985. }
  5986. // ClearTagids clears the value of the "tagids" field.
  5987. func (m *BatchMsgMutation) ClearTagids() {
  5988. m.tagids = nil
  5989. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  5990. }
  5991. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  5992. func (m *BatchMsgMutation) TagidsCleared() bool {
  5993. _, ok := m.clearedFields[batchmsg.FieldTagids]
  5994. return ok
  5995. }
  5996. // ResetTagids resets all changes to the "tagids" field.
  5997. func (m *BatchMsgMutation) ResetTagids() {
  5998. m.tagids = nil
  5999. delete(m.clearedFields, batchmsg.FieldTagids)
  6000. }
  6001. // SetTotal sets the "total" field.
  6002. func (m *BatchMsgMutation) SetTotal(i int32) {
  6003. m.total = &i
  6004. m.addtotal = nil
  6005. }
  6006. // Total returns the value of the "total" field in the mutation.
  6007. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  6008. v := m.total
  6009. if v == nil {
  6010. return
  6011. }
  6012. return *v, true
  6013. }
  6014. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  6015. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6016. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6017. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  6018. if !m.op.Is(OpUpdateOne) {
  6019. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  6020. }
  6021. if m.id == nil || m.oldValue == nil {
  6022. return v, errors.New("OldTotal requires an ID field in the mutation")
  6023. }
  6024. oldValue, err := m.oldValue(ctx)
  6025. if err != nil {
  6026. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  6027. }
  6028. return oldValue.Total, nil
  6029. }
  6030. // AddTotal adds i to the "total" field.
  6031. func (m *BatchMsgMutation) AddTotal(i int32) {
  6032. if m.addtotal != nil {
  6033. *m.addtotal += i
  6034. } else {
  6035. m.addtotal = &i
  6036. }
  6037. }
  6038. // AddedTotal returns the value that was added to the "total" field in this mutation.
  6039. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  6040. v := m.addtotal
  6041. if v == nil {
  6042. return
  6043. }
  6044. return *v, true
  6045. }
  6046. // ClearTotal clears the value of the "total" field.
  6047. func (m *BatchMsgMutation) ClearTotal() {
  6048. m.total = nil
  6049. m.addtotal = nil
  6050. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  6051. }
  6052. // TotalCleared returns if the "total" field was cleared in this mutation.
  6053. func (m *BatchMsgMutation) TotalCleared() bool {
  6054. _, ok := m.clearedFields[batchmsg.FieldTotal]
  6055. return ok
  6056. }
  6057. // ResetTotal resets all changes to the "total" field.
  6058. func (m *BatchMsgMutation) ResetTotal() {
  6059. m.total = nil
  6060. m.addtotal = nil
  6061. delete(m.clearedFields, batchmsg.FieldTotal)
  6062. }
  6063. // SetSuccess sets the "success" field.
  6064. func (m *BatchMsgMutation) SetSuccess(i int32) {
  6065. m.success = &i
  6066. m.addsuccess = nil
  6067. }
  6068. // Success returns the value of the "success" field in the mutation.
  6069. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  6070. v := m.success
  6071. if v == nil {
  6072. return
  6073. }
  6074. return *v, true
  6075. }
  6076. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  6077. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6078. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6079. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  6080. if !m.op.Is(OpUpdateOne) {
  6081. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  6082. }
  6083. if m.id == nil || m.oldValue == nil {
  6084. return v, errors.New("OldSuccess requires an ID field in the mutation")
  6085. }
  6086. oldValue, err := m.oldValue(ctx)
  6087. if err != nil {
  6088. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  6089. }
  6090. return oldValue.Success, nil
  6091. }
  6092. // AddSuccess adds i to the "success" field.
  6093. func (m *BatchMsgMutation) AddSuccess(i int32) {
  6094. if m.addsuccess != nil {
  6095. *m.addsuccess += i
  6096. } else {
  6097. m.addsuccess = &i
  6098. }
  6099. }
  6100. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  6101. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  6102. v := m.addsuccess
  6103. if v == nil {
  6104. return
  6105. }
  6106. return *v, true
  6107. }
  6108. // ClearSuccess clears the value of the "success" field.
  6109. func (m *BatchMsgMutation) ClearSuccess() {
  6110. m.success = nil
  6111. m.addsuccess = nil
  6112. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  6113. }
  6114. // SuccessCleared returns if the "success" field was cleared in this mutation.
  6115. func (m *BatchMsgMutation) SuccessCleared() bool {
  6116. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  6117. return ok
  6118. }
  6119. // ResetSuccess resets all changes to the "success" field.
  6120. func (m *BatchMsgMutation) ResetSuccess() {
  6121. m.success = nil
  6122. m.addsuccess = nil
  6123. delete(m.clearedFields, batchmsg.FieldSuccess)
  6124. }
  6125. // SetFail sets the "fail" field.
  6126. func (m *BatchMsgMutation) SetFail(i int32) {
  6127. m.fail = &i
  6128. m.addfail = nil
  6129. }
  6130. // Fail returns the value of the "fail" field in the mutation.
  6131. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  6132. v := m.fail
  6133. if v == nil {
  6134. return
  6135. }
  6136. return *v, true
  6137. }
  6138. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  6139. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6140. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6141. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  6142. if !m.op.Is(OpUpdateOne) {
  6143. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  6144. }
  6145. if m.id == nil || m.oldValue == nil {
  6146. return v, errors.New("OldFail requires an ID field in the mutation")
  6147. }
  6148. oldValue, err := m.oldValue(ctx)
  6149. if err != nil {
  6150. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  6151. }
  6152. return oldValue.Fail, nil
  6153. }
  6154. // AddFail adds i to the "fail" field.
  6155. func (m *BatchMsgMutation) AddFail(i int32) {
  6156. if m.addfail != nil {
  6157. *m.addfail += i
  6158. } else {
  6159. m.addfail = &i
  6160. }
  6161. }
  6162. // AddedFail returns the value that was added to the "fail" field in this mutation.
  6163. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  6164. v := m.addfail
  6165. if v == nil {
  6166. return
  6167. }
  6168. return *v, true
  6169. }
  6170. // ClearFail clears the value of the "fail" field.
  6171. func (m *BatchMsgMutation) ClearFail() {
  6172. m.fail = nil
  6173. m.addfail = nil
  6174. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  6175. }
  6176. // FailCleared returns if the "fail" field was cleared in this mutation.
  6177. func (m *BatchMsgMutation) FailCleared() bool {
  6178. _, ok := m.clearedFields[batchmsg.FieldFail]
  6179. return ok
  6180. }
  6181. // ResetFail resets all changes to the "fail" field.
  6182. func (m *BatchMsgMutation) ResetFail() {
  6183. m.fail = nil
  6184. m.addfail = nil
  6185. delete(m.clearedFields, batchmsg.FieldFail)
  6186. }
  6187. // SetStartTime sets the "start_time" field.
  6188. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  6189. m.start_time = &t
  6190. }
  6191. // StartTime returns the value of the "start_time" field in the mutation.
  6192. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  6193. v := m.start_time
  6194. if v == nil {
  6195. return
  6196. }
  6197. return *v, true
  6198. }
  6199. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  6200. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6201. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6202. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  6203. if !m.op.Is(OpUpdateOne) {
  6204. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  6205. }
  6206. if m.id == nil || m.oldValue == nil {
  6207. return v, errors.New("OldStartTime requires an ID field in the mutation")
  6208. }
  6209. oldValue, err := m.oldValue(ctx)
  6210. if err != nil {
  6211. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  6212. }
  6213. return oldValue.StartTime, nil
  6214. }
  6215. // ClearStartTime clears the value of the "start_time" field.
  6216. func (m *BatchMsgMutation) ClearStartTime() {
  6217. m.start_time = nil
  6218. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  6219. }
  6220. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  6221. func (m *BatchMsgMutation) StartTimeCleared() bool {
  6222. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  6223. return ok
  6224. }
  6225. // ResetStartTime resets all changes to the "start_time" field.
  6226. func (m *BatchMsgMutation) ResetStartTime() {
  6227. m.start_time = nil
  6228. delete(m.clearedFields, batchmsg.FieldStartTime)
  6229. }
  6230. // SetStopTime sets the "stop_time" field.
  6231. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  6232. m.stop_time = &t
  6233. }
  6234. // StopTime returns the value of the "stop_time" field in the mutation.
  6235. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  6236. v := m.stop_time
  6237. if v == nil {
  6238. return
  6239. }
  6240. return *v, true
  6241. }
  6242. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  6243. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6244. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6245. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  6246. if !m.op.Is(OpUpdateOne) {
  6247. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  6248. }
  6249. if m.id == nil || m.oldValue == nil {
  6250. return v, errors.New("OldStopTime requires an ID field in the mutation")
  6251. }
  6252. oldValue, err := m.oldValue(ctx)
  6253. if err != nil {
  6254. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  6255. }
  6256. return oldValue.StopTime, nil
  6257. }
  6258. // ClearStopTime clears the value of the "stop_time" field.
  6259. func (m *BatchMsgMutation) ClearStopTime() {
  6260. m.stop_time = nil
  6261. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  6262. }
  6263. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  6264. func (m *BatchMsgMutation) StopTimeCleared() bool {
  6265. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  6266. return ok
  6267. }
  6268. // ResetStopTime resets all changes to the "stop_time" field.
  6269. func (m *BatchMsgMutation) ResetStopTime() {
  6270. m.stop_time = nil
  6271. delete(m.clearedFields, batchmsg.FieldStopTime)
  6272. }
  6273. // SetSendTime sets the "send_time" field.
  6274. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  6275. m.send_time = &t
  6276. }
  6277. // SendTime returns the value of the "send_time" field in the mutation.
  6278. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  6279. v := m.send_time
  6280. if v == nil {
  6281. return
  6282. }
  6283. return *v, true
  6284. }
  6285. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  6286. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6287. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6288. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  6289. if !m.op.Is(OpUpdateOne) {
  6290. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  6291. }
  6292. if m.id == nil || m.oldValue == nil {
  6293. return v, errors.New("OldSendTime requires an ID field in the mutation")
  6294. }
  6295. oldValue, err := m.oldValue(ctx)
  6296. if err != nil {
  6297. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  6298. }
  6299. return oldValue.SendTime, nil
  6300. }
  6301. // ClearSendTime clears the value of the "send_time" field.
  6302. func (m *BatchMsgMutation) ClearSendTime() {
  6303. m.send_time = nil
  6304. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  6305. }
  6306. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  6307. func (m *BatchMsgMutation) SendTimeCleared() bool {
  6308. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  6309. return ok
  6310. }
  6311. // ResetSendTime resets all changes to the "send_time" field.
  6312. func (m *BatchMsgMutation) ResetSendTime() {
  6313. m.send_time = nil
  6314. delete(m.clearedFields, batchmsg.FieldSendTime)
  6315. }
  6316. // SetType sets the "type" field.
  6317. func (m *BatchMsgMutation) SetType(i int32) {
  6318. m._type = &i
  6319. m.add_type = nil
  6320. }
  6321. // GetType returns the value of the "type" field in the mutation.
  6322. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  6323. v := m._type
  6324. if v == nil {
  6325. return
  6326. }
  6327. return *v, true
  6328. }
  6329. // OldType returns the old "type" field's value of the BatchMsg entity.
  6330. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6331. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6332. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  6333. if !m.op.Is(OpUpdateOne) {
  6334. return v, errors.New("OldType is only allowed on UpdateOne operations")
  6335. }
  6336. if m.id == nil || m.oldValue == nil {
  6337. return v, errors.New("OldType requires an ID field in the mutation")
  6338. }
  6339. oldValue, err := m.oldValue(ctx)
  6340. if err != nil {
  6341. return v, fmt.Errorf("querying old value for OldType: %w", err)
  6342. }
  6343. return oldValue.Type, nil
  6344. }
  6345. // AddType adds i to the "type" field.
  6346. func (m *BatchMsgMutation) AddType(i int32) {
  6347. if m.add_type != nil {
  6348. *m.add_type += i
  6349. } else {
  6350. m.add_type = &i
  6351. }
  6352. }
  6353. // AddedType returns the value that was added to the "type" field in this mutation.
  6354. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  6355. v := m.add_type
  6356. if v == nil {
  6357. return
  6358. }
  6359. return *v, true
  6360. }
  6361. // ClearType clears the value of the "type" field.
  6362. func (m *BatchMsgMutation) ClearType() {
  6363. m._type = nil
  6364. m.add_type = nil
  6365. m.clearedFields[batchmsg.FieldType] = struct{}{}
  6366. }
  6367. // TypeCleared returns if the "type" field was cleared in this mutation.
  6368. func (m *BatchMsgMutation) TypeCleared() bool {
  6369. _, ok := m.clearedFields[batchmsg.FieldType]
  6370. return ok
  6371. }
  6372. // ResetType resets all changes to the "type" field.
  6373. func (m *BatchMsgMutation) ResetType() {
  6374. m._type = nil
  6375. m.add_type = nil
  6376. delete(m.clearedFields, batchmsg.FieldType)
  6377. }
  6378. // SetOrganizationID sets the "organization_id" field.
  6379. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  6380. m.organization_id = &u
  6381. m.addorganization_id = nil
  6382. }
  6383. // OrganizationID returns the value of the "organization_id" field in the mutation.
  6384. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  6385. v := m.organization_id
  6386. if v == nil {
  6387. return
  6388. }
  6389. return *v, true
  6390. }
  6391. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  6392. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6393. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6394. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  6395. if !m.op.Is(OpUpdateOne) {
  6396. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  6397. }
  6398. if m.id == nil || m.oldValue == nil {
  6399. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  6400. }
  6401. oldValue, err := m.oldValue(ctx)
  6402. if err != nil {
  6403. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6404. }
  6405. return oldValue.OrganizationID, nil
  6406. }
  6407. // AddOrganizationID adds u to the "organization_id" field.
  6408. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  6409. if m.addorganization_id != nil {
  6410. *m.addorganization_id += u
  6411. } else {
  6412. m.addorganization_id = &u
  6413. }
  6414. }
  6415. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6416. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  6417. v := m.addorganization_id
  6418. if v == nil {
  6419. return
  6420. }
  6421. return *v, true
  6422. }
  6423. // ResetOrganizationID resets all changes to the "organization_id" field.
  6424. func (m *BatchMsgMutation) ResetOrganizationID() {
  6425. m.organization_id = nil
  6426. m.addorganization_id = nil
  6427. }
  6428. // SetCtype sets the "ctype" field.
  6429. func (m *BatchMsgMutation) SetCtype(u uint64) {
  6430. m.ctype = &u
  6431. m.addctype = nil
  6432. }
  6433. // Ctype returns the value of the "ctype" field in the mutation.
  6434. func (m *BatchMsgMutation) Ctype() (r uint64, exists bool) {
  6435. v := m.ctype
  6436. if v == nil {
  6437. return
  6438. }
  6439. return *v, true
  6440. }
  6441. // OldCtype returns the old "ctype" field's value of the BatchMsg entity.
  6442. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6443. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6444. func (m *BatchMsgMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  6445. if !m.op.Is(OpUpdateOne) {
  6446. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  6447. }
  6448. if m.id == nil || m.oldValue == nil {
  6449. return v, errors.New("OldCtype requires an ID field in the mutation")
  6450. }
  6451. oldValue, err := m.oldValue(ctx)
  6452. if err != nil {
  6453. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  6454. }
  6455. return oldValue.Ctype, nil
  6456. }
  6457. // AddCtype adds u to the "ctype" field.
  6458. func (m *BatchMsgMutation) AddCtype(u int64) {
  6459. if m.addctype != nil {
  6460. *m.addctype += u
  6461. } else {
  6462. m.addctype = &u
  6463. }
  6464. }
  6465. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  6466. func (m *BatchMsgMutation) AddedCtype() (r int64, exists bool) {
  6467. v := m.addctype
  6468. if v == nil {
  6469. return
  6470. }
  6471. return *v, true
  6472. }
  6473. // ResetCtype resets all changes to the "ctype" field.
  6474. func (m *BatchMsgMutation) ResetCtype() {
  6475. m.ctype = nil
  6476. m.addctype = nil
  6477. }
  6478. // SetCc sets the "cc" field.
  6479. func (m *BatchMsgMutation) SetCc(s string) {
  6480. m.cc = &s
  6481. }
  6482. // Cc returns the value of the "cc" field in the mutation.
  6483. func (m *BatchMsgMutation) Cc() (r string, exists bool) {
  6484. v := m.cc
  6485. if v == nil {
  6486. return
  6487. }
  6488. return *v, true
  6489. }
  6490. // OldCc returns the old "cc" field's value of the BatchMsg entity.
  6491. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6492. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6493. func (m *BatchMsgMutation) OldCc(ctx context.Context) (v string, err error) {
  6494. if !m.op.Is(OpUpdateOne) {
  6495. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  6496. }
  6497. if m.id == nil || m.oldValue == nil {
  6498. return v, errors.New("OldCc requires an ID field in the mutation")
  6499. }
  6500. oldValue, err := m.oldValue(ctx)
  6501. if err != nil {
  6502. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  6503. }
  6504. return oldValue.Cc, nil
  6505. }
  6506. // ClearCc clears the value of the "cc" field.
  6507. func (m *BatchMsgMutation) ClearCc() {
  6508. m.cc = nil
  6509. m.clearedFields[batchmsg.FieldCc] = struct{}{}
  6510. }
  6511. // CcCleared returns if the "cc" field was cleared in this mutation.
  6512. func (m *BatchMsgMutation) CcCleared() bool {
  6513. _, ok := m.clearedFields[batchmsg.FieldCc]
  6514. return ok
  6515. }
  6516. // ResetCc resets all changes to the "cc" field.
  6517. func (m *BatchMsgMutation) ResetCc() {
  6518. m.cc = nil
  6519. delete(m.clearedFields, batchmsg.FieldCc)
  6520. }
  6521. // SetPhone sets the "phone" field.
  6522. func (m *BatchMsgMutation) SetPhone(s string) {
  6523. m.phone = &s
  6524. }
  6525. // Phone returns the value of the "phone" field in the mutation.
  6526. func (m *BatchMsgMutation) Phone() (r string, exists bool) {
  6527. v := m.phone
  6528. if v == nil {
  6529. return
  6530. }
  6531. return *v, true
  6532. }
  6533. // OldPhone returns the old "phone" field's value of the BatchMsg entity.
  6534. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6535. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6536. func (m *BatchMsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  6537. if !m.op.Is(OpUpdateOne) {
  6538. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  6539. }
  6540. if m.id == nil || m.oldValue == nil {
  6541. return v, errors.New("OldPhone requires an ID field in the mutation")
  6542. }
  6543. oldValue, err := m.oldValue(ctx)
  6544. if err != nil {
  6545. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  6546. }
  6547. return oldValue.Phone, nil
  6548. }
  6549. // ClearPhone clears the value of the "phone" field.
  6550. func (m *BatchMsgMutation) ClearPhone() {
  6551. m.phone = nil
  6552. m.clearedFields[batchmsg.FieldPhone] = struct{}{}
  6553. }
  6554. // PhoneCleared returns if the "phone" field was cleared in this mutation.
  6555. func (m *BatchMsgMutation) PhoneCleared() bool {
  6556. _, ok := m.clearedFields[batchmsg.FieldPhone]
  6557. return ok
  6558. }
  6559. // ResetPhone resets all changes to the "phone" field.
  6560. func (m *BatchMsgMutation) ResetPhone() {
  6561. m.phone = nil
  6562. delete(m.clearedFields, batchmsg.FieldPhone)
  6563. }
  6564. // SetTemplateName sets the "template_name" field.
  6565. func (m *BatchMsgMutation) SetTemplateName(s string) {
  6566. m.template_name = &s
  6567. }
  6568. // TemplateName returns the value of the "template_name" field in the mutation.
  6569. func (m *BatchMsgMutation) TemplateName() (r string, exists bool) {
  6570. v := m.template_name
  6571. if v == nil {
  6572. return
  6573. }
  6574. return *v, true
  6575. }
  6576. // OldTemplateName returns the old "template_name" field's value of the BatchMsg entity.
  6577. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6578. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6579. func (m *BatchMsgMutation) OldTemplateName(ctx context.Context) (v string, err error) {
  6580. if !m.op.Is(OpUpdateOne) {
  6581. return v, errors.New("OldTemplateName is only allowed on UpdateOne operations")
  6582. }
  6583. if m.id == nil || m.oldValue == nil {
  6584. return v, errors.New("OldTemplateName requires an ID field in the mutation")
  6585. }
  6586. oldValue, err := m.oldValue(ctx)
  6587. if err != nil {
  6588. return v, fmt.Errorf("querying old value for OldTemplateName: %w", err)
  6589. }
  6590. return oldValue.TemplateName, nil
  6591. }
  6592. // ClearTemplateName clears the value of the "template_name" field.
  6593. func (m *BatchMsgMutation) ClearTemplateName() {
  6594. m.template_name = nil
  6595. m.clearedFields[batchmsg.FieldTemplateName] = struct{}{}
  6596. }
  6597. // TemplateNameCleared returns if the "template_name" field was cleared in this mutation.
  6598. func (m *BatchMsgMutation) TemplateNameCleared() bool {
  6599. _, ok := m.clearedFields[batchmsg.FieldTemplateName]
  6600. return ok
  6601. }
  6602. // ResetTemplateName resets all changes to the "template_name" field.
  6603. func (m *BatchMsgMutation) ResetTemplateName() {
  6604. m.template_name = nil
  6605. delete(m.clearedFields, batchmsg.FieldTemplateName)
  6606. }
  6607. // SetTemplateCode sets the "template_code" field.
  6608. func (m *BatchMsgMutation) SetTemplateCode(s string) {
  6609. m.template_code = &s
  6610. }
  6611. // TemplateCode returns the value of the "template_code" field in the mutation.
  6612. func (m *BatchMsgMutation) TemplateCode() (r string, exists bool) {
  6613. v := m.template_code
  6614. if v == nil {
  6615. return
  6616. }
  6617. return *v, true
  6618. }
  6619. // OldTemplateCode returns the old "template_code" field's value of the BatchMsg entity.
  6620. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6621. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6622. func (m *BatchMsgMutation) OldTemplateCode(ctx context.Context) (v string, err error) {
  6623. if !m.op.Is(OpUpdateOne) {
  6624. return v, errors.New("OldTemplateCode is only allowed on UpdateOne operations")
  6625. }
  6626. if m.id == nil || m.oldValue == nil {
  6627. return v, errors.New("OldTemplateCode requires an ID field in the mutation")
  6628. }
  6629. oldValue, err := m.oldValue(ctx)
  6630. if err != nil {
  6631. return v, fmt.Errorf("querying old value for OldTemplateCode: %w", err)
  6632. }
  6633. return oldValue.TemplateCode, nil
  6634. }
  6635. // ClearTemplateCode clears the value of the "template_code" field.
  6636. func (m *BatchMsgMutation) ClearTemplateCode() {
  6637. m.template_code = nil
  6638. m.clearedFields[batchmsg.FieldTemplateCode] = struct{}{}
  6639. }
  6640. // TemplateCodeCleared returns if the "template_code" field was cleared in this mutation.
  6641. func (m *BatchMsgMutation) TemplateCodeCleared() bool {
  6642. _, ok := m.clearedFields[batchmsg.FieldTemplateCode]
  6643. return ok
  6644. }
  6645. // ResetTemplateCode resets all changes to the "template_code" field.
  6646. func (m *BatchMsgMutation) ResetTemplateCode() {
  6647. m.template_code = nil
  6648. delete(m.clearedFields, batchmsg.FieldTemplateCode)
  6649. }
  6650. // SetLang sets the "lang" field.
  6651. func (m *BatchMsgMutation) SetLang(s string) {
  6652. m.lang = &s
  6653. }
  6654. // Lang returns the value of the "lang" field in the mutation.
  6655. func (m *BatchMsgMutation) Lang() (r string, exists bool) {
  6656. v := m.lang
  6657. if v == nil {
  6658. return
  6659. }
  6660. return *v, true
  6661. }
  6662. // OldLang returns the old "lang" field's value of the BatchMsg entity.
  6663. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6664. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6665. func (m *BatchMsgMutation) OldLang(ctx context.Context) (v string, err error) {
  6666. if !m.op.Is(OpUpdateOne) {
  6667. return v, errors.New("OldLang is only allowed on UpdateOne operations")
  6668. }
  6669. if m.id == nil || m.oldValue == nil {
  6670. return v, errors.New("OldLang requires an ID field in the mutation")
  6671. }
  6672. oldValue, err := m.oldValue(ctx)
  6673. if err != nil {
  6674. return v, fmt.Errorf("querying old value for OldLang: %w", err)
  6675. }
  6676. return oldValue.Lang, nil
  6677. }
  6678. // ClearLang clears the value of the "lang" field.
  6679. func (m *BatchMsgMutation) ClearLang() {
  6680. m.lang = nil
  6681. m.clearedFields[batchmsg.FieldLang] = struct{}{}
  6682. }
  6683. // LangCleared returns if the "lang" field was cleared in this mutation.
  6684. func (m *BatchMsgMutation) LangCleared() bool {
  6685. _, ok := m.clearedFields[batchmsg.FieldLang]
  6686. return ok
  6687. }
  6688. // ResetLang resets all changes to the "lang" field.
  6689. func (m *BatchMsgMutation) ResetLang() {
  6690. m.lang = nil
  6691. delete(m.clearedFields, batchmsg.FieldLang)
  6692. }
  6693. // Where appends a list predicates to the BatchMsgMutation builder.
  6694. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  6695. m.predicates = append(m.predicates, ps...)
  6696. }
  6697. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  6698. // users can use type-assertion to append predicates that do not depend on any generated package.
  6699. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  6700. p := make([]predicate.BatchMsg, len(ps))
  6701. for i := range ps {
  6702. p[i] = ps[i]
  6703. }
  6704. m.Where(p...)
  6705. }
  6706. // Op returns the operation name.
  6707. func (m *BatchMsgMutation) Op() Op {
  6708. return m.op
  6709. }
  6710. // SetOp allows setting the mutation operation.
  6711. func (m *BatchMsgMutation) SetOp(op Op) {
  6712. m.op = op
  6713. }
  6714. // Type returns the node type of this mutation (BatchMsg).
  6715. func (m *BatchMsgMutation) Type() string {
  6716. return m.typ
  6717. }
  6718. // Fields returns all fields that were changed during this mutation. Note that in
  6719. // order to get all numeric fields that were incremented/decremented, call
  6720. // AddedFields().
  6721. func (m *BatchMsgMutation) Fields() []string {
  6722. fields := make([]string, 0, 24)
  6723. if m.created_at != nil {
  6724. fields = append(fields, batchmsg.FieldCreatedAt)
  6725. }
  6726. if m.updated_at != nil {
  6727. fields = append(fields, batchmsg.FieldUpdatedAt)
  6728. }
  6729. if m.deleted_at != nil {
  6730. fields = append(fields, batchmsg.FieldDeletedAt)
  6731. }
  6732. if m.status != nil {
  6733. fields = append(fields, batchmsg.FieldStatus)
  6734. }
  6735. if m.batch_no != nil {
  6736. fields = append(fields, batchmsg.FieldBatchNo)
  6737. }
  6738. if m.task_name != nil {
  6739. fields = append(fields, batchmsg.FieldTaskName)
  6740. }
  6741. if m.fromwxid != nil {
  6742. fields = append(fields, batchmsg.FieldFromwxid)
  6743. }
  6744. if m.msg != nil {
  6745. fields = append(fields, batchmsg.FieldMsg)
  6746. }
  6747. if m.tag != nil {
  6748. fields = append(fields, batchmsg.FieldTag)
  6749. }
  6750. if m.tagids != nil {
  6751. fields = append(fields, batchmsg.FieldTagids)
  6752. }
  6753. if m.total != nil {
  6754. fields = append(fields, batchmsg.FieldTotal)
  6755. }
  6756. if m.success != nil {
  6757. fields = append(fields, batchmsg.FieldSuccess)
  6758. }
  6759. if m.fail != nil {
  6760. fields = append(fields, batchmsg.FieldFail)
  6761. }
  6762. if m.start_time != nil {
  6763. fields = append(fields, batchmsg.FieldStartTime)
  6764. }
  6765. if m.stop_time != nil {
  6766. fields = append(fields, batchmsg.FieldStopTime)
  6767. }
  6768. if m.send_time != nil {
  6769. fields = append(fields, batchmsg.FieldSendTime)
  6770. }
  6771. if m._type != nil {
  6772. fields = append(fields, batchmsg.FieldType)
  6773. }
  6774. if m.organization_id != nil {
  6775. fields = append(fields, batchmsg.FieldOrganizationID)
  6776. }
  6777. if m.ctype != nil {
  6778. fields = append(fields, batchmsg.FieldCtype)
  6779. }
  6780. if m.cc != nil {
  6781. fields = append(fields, batchmsg.FieldCc)
  6782. }
  6783. if m.phone != nil {
  6784. fields = append(fields, batchmsg.FieldPhone)
  6785. }
  6786. if m.template_name != nil {
  6787. fields = append(fields, batchmsg.FieldTemplateName)
  6788. }
  6789. if m.template_code != nil {
  6790. fields = append(fields, batchmsg.FieldTemplateCode)
  6791. }
  6792. if m.lang != nil {
  6793. fields = append(fields, batchmsg.FieldLang)
  6794. }
  6795. return fields
  6796. }
  6797. // Field returns the value of a field with the given name. The second boolean
  6798. // return value indicates that this field was not set, or was not defined in the
  6799. // schema.
  6800. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  6801. switch name {
  6802. case batchmsg.FieldCreatedAt:
  6803. return m.CreatedAt()
  6804. case batchmsg.FieldUpdatedAt:
  6805. return m.UpdatedAt()
  6806. case batchmsg.FieldDeletedAt:
  6807. return m.DeletedAt()
  6808. case batchmsg.FieldStatus:
  6809. return m.Status()
  6810. case batchmsg.FieldBatchNo:
  6811. return m.BatchNo()
  6812. case batchmsg.FieldTaskName:
  6813. return m.TaskName()
  6814. case batchmsg.FieldFromwxid:
  6815. return m.Fromwxid()
  6816. case batchmsg.FieldMsg:
  6817. return m.Msg()
  6818. case batchmsg.FieldTag:
  6819. return m.Tag()
  6820. case batchmsg.FieldTagids:
  6821. return m.Tagids()
  6822. case batchmsg.FieldTotal:
  6823. return m.Total()
  6824. case batchmsg.FieldSuccess:
  6825. return m.Success()
  6826. case batchmsg.FieldFail:
  6827. return m.Fail()
  6828. case batchmsg.FieldStartTime:
  6829. return m.StartTime()
  6830. case batchmsg.FieldStopTime:
  6831. return m.StopTime()
  6832. case batchmsg.FieldSendTime:
  6833. return m.SendTime()
  6834. case batchmsg.FieldType:
  6835. return m.GetType()
  6836. case batchmsg.FieldOrganizationID:
  6837. return m.OrganizationID()
  6838. case batchmsg.FieldCtype:
  6839. return m.Ctype()
  6840. case batchmsg.FieldCc:
  6841. return m.Cc()
  6842. case batchmsg.FieldPhone:
  6843. return m.Phone()
  6844. case batchmsg.FieldTemplateName:
  6845. return m.TemplateName()
  6846. case batchmsg.FieldTemplateCode:
  6847. return m.TemplateCode()
  6848. case batchmsg.FieldLang:
  6849. return m.Lang()
  6850. }
  6851. return nil, false
  6852. }
  6853. // OldField returns the old value of the field from the database. An error is
  6854. // returned if the mutation operation is not UpdateOne, or the query to the
  6855. // database failed.
  6856. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6857. switch name {
  6858. case batchmsg.FieldCreatedAt:
  6859. return m.OldCreatedAt(ctx)
  6860. case batchmsg.FieldUpdatedAt:
  6861. return m.OldUpdatedAt(ctx)
  6862. case batchmsg.FieldDeletedAt:
  6863. return m.OldDeletedAt(ctx)
  6864. case batchmsg.FieldStatus:
  6865. return m.OldStatus(ctx)
  6866. case batchmsg.FieldBatchNo:
  6867. return m.OldBatchNo(ctx)
  6868. case batchmsg.FieldTaskName:
  6869. return m.OldTaskName(ctx)
  6870. case batchmsg.FieldFromwxid:
  6871. return m.OldFromwxid(ctx)
  6872. case batchmsg.FieldMsg:
  6873. return m.OldMsg(ctx)
  6874. case batchmsg.FieldTag:
  6875. return m.OldTag(ctx)
  6876. case batchmsg.FieldTagids:
  6877. return m.OldTagids(ctx)
  6878. case batchmsg.FieldTotal:
  6879. return m.OldTotal(ctx)
  6880. case batchmsg.FieldSuccess:
  6881. return m.OldSuccess(ctx)
  6882. case batchmsg.FieldFail:
  6883. return m.OldFail(ctx)
  6884. case batchmsg.FieldStartTime:
  6885. return m.OldStartTime(ctx)
  6886. case batchmsg.FieldStopTime:
  6887. return m.OldStopTime(ctx)
  6888. case batchmsg.FieldSendTime:
  6889. return m.OldSendTime(ctx)
  6890. case batchmsg.FieldType:
  6891. return m.OldType(ctx)
  6892. case batchmsg.FieldOrganizationID:
  6893. return m.OldOrganizationID(ctx)
  6894. case batchmsg.FieldCtype:
  6895. return m.OldCtype(ctx)
  6896. case batchmsg.FieldCc:
  6897. return m.OldCc(ctx)
  6898. case batchmsg.FieldPhone:
  6899. return m.OldPhone(ctx)
  6900. case batchmsg.FieldTemplateName:
  6901. return m.OldTemplateName(ctx)
  6902. case batchmsg.FieldTemplateCode:
  6903. return m.OldTemplateCode(ctx)
  6904. case batchmsg.FieldLang:
  6905. return m.OldLang(ctx)
  6906. }
  6907. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  6908. }
  6909. // SetField sets the value of a field with the given name. It returns an error if
  6910. // the field is not defined in the schema, or if the type mismatched the field
  6911. // type.
  6912. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  6913. switch name {
  6914. case batchmsg.FieldCreatedAt:
  6915. v, ok := value.(time.Time)
  6916. if !ok {
  6917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6918. }
  6919. m.SetCreatedAt(v)
  6920. return nil
  6921. case batchmsg.FieldUpdatedAt:
  6922. v, ok := value.(time.Time)
  6923. if !ok {
  6924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6925. }
  6926. m.SetUpdatedAt(v)
  6927. return nil
  6928. case batchmsg.FieldDeletedAt:
  6929. v, ok := value.(time.Time)
  6930. if !ok {
  6931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6932. }
  6933. m.SetDeletedAt(v)
  6934. return nil
  6935. case batchmsg.FieldStatus:
  6936. v, ok := value.(uint8)
  6937. if !ok {
  6938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6939. }
  6940. m.SetStatus(v)
  6941. return nil
  6942. case batchmsg.FieldBatchNo:
  6943. v, ok := value.(string)
  6944. if !ok {
  6945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6946. }
  6947. m.SetBatchNo(v)
  6948. return nil
  6949. case batchmsg.FieldTaskName:
  6950. v, ok := value.(string)
  6951. if !ok {
  6952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6953. }
  6954. m.SetTaskName(v)
  6955. return nil
  6956. case batchmsg.FieldFromwxid:
  6957. v, ok := value.(string)
  6958. if !ok {
  6959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6960. }
  6961. m.SetFromwxid(v)
  6962. return nil
  6963. case batchmsg.FieldMsg:
  6964. v, ok := value.(string)
  6965. if !ok {
  6966. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6967. }
  6968. m.SetMsg(v)
  6969. return nil
  6970. case batchmsg.FieldTag:
  6971. v, ok := value.(string)
  6972. if !ok {
  6973. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6974. }
  6975. m.SetTag(v)
  6976. return nil
  6977. case batchmsg.FieldTagids:
  6978. v, ok := value.(string)
  6979. if !ok {
  6980. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6981. }
  6982. m.SetTagids(v)
  6983. return nil
  6984. case batchmsg.FieldTotal:
  6985. v, ok := value.(int32)
  6986. if !ok {
  6987. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6988. }
  6989. m.SetTotal(v)
  6990. return nil
  6991. case batchmsg.FieldSuccess:
  6992. v, ok := value.(int32)
  6993. if !ok {
  6994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6995. }
  6996. m.SetSuccess(v)
  6997. return nil
  6998. case batchmsg.FieldFail:
  6999. v, ok := value.(int32)
  7000. if !ok {
  7001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7002. }
  7003. m.SetFail(v)
  7004. return nil
  7005. case batchmsg.FieldStartTime:
  7006. v, ok := value.(time.Time)
  7007. if !ok {
  7008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7009. }
  7010. m.SetStartTime(v)
  7011. return nil
  7012. case batchmsg.FieldStopTime:
  7013. v, ok := value.(time.Time)
  7014. if !ok {
  7015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7016. }
  7017. m.SetStopTime(v)
  7018. return nil
  7019. case batchmsg.FieldSendTime:
  7020. v, ok := value.(time.Time)
  7021. if !ok {
  7022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7023. }
  7024. m.SetSendTime(v)
  7025. return nil
  7026. case batchmsg.FieldType:
  7027. v, ok := value.(int32)
  7028. if !ok {
  7029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7030. }
  7031. m.SetType(v)
  7032. return nil
  7033. case batchmsg.FieldOrganizationID:
  7034. v, ok := value.(uint64)
  7035. if !ok {
  7036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7037. }
  7038. m.SetOrganizationID(v)
  7039. return nil
  7040. case batchmsg.FieldCtype:
  7041. v, ok := value.(uint64)
  7042. if !ok {
  7043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7044. }
  7045. m.SetCtype(v)
  7046. return nil
  7047. case batchmsg.FieldCc:
  7048. v, ok := value.(string)
  7049. if !ok {
  7050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7051. }
  7052. m.SetCc(v)
  7053. return nil
  7054. case batchmsg.FieldPhone:
  7055. v, ok := value.(string)
  7056. if !ok {
  7057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7058. }
  7059. m.SetPhone(v)
  7060. return nil
  7061. case batchmsg.FieldTemplateName:
  7062. v, ok := value.(string)
  7063. if !ok {
  7064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7065. }
  7066. m.SetTemplateName(v)
  7067. return nil
  7068. case batchmsg.FieldTemplateCode:
  7069. v, ok := value.(string)
  7070. if !ok {
  7071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7072. }
  7073. m.SetTemplateCode(v)
  7074. return nil
  7075. case batchmsg.FieldLang:
  7076. v, ok := value.(string)
  7077. if !ok {
  7078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7079. }
  7080. m.SetLang(v)
  7081. return nil
  7082. }
  7083. return fmt.Errorf("unknown BatchMsg field %s", name)
  7084. }
  7085. // AddedFields returns all numeric fields that were incremented/decremented during
  7086. // this mutation.
  7087. func (m *BatchMsgMutation) AddedFields() []string {
  7088. var fields []string
  7089. if m.addstatus != nil {
  7090. fields = append(fields, batchmsg.FieldStatus)
  7091. }
  7092. if m.addtotal != nil {
  7093. fields = append(fields, batchmsg.FieldTotal)
  7094. }
  7095. if m.addsuccess != nil {
  7096. fields = append(fields, batchmsg.FieldSuccess)
  7097. }
  7098. if m.addfail != nil {
  7099. fields = append(fields, batchmsg.FieldFail)
  7100. }
  7101. if m.add_type != nil {
  7102. fields = append(fields, batchmsg.FieldType)
  7103. }
  7104. if m.addorganization_id != nil {
  7105. fields = append(fields, batchmsg.FieldOrganizationID)
  7106. }
  7107. if m.addctype != nil {
  7108. fields = append(fields, batchmsg.FieldCtype)
  7109. }
  7110. return fields
  7111. }
  7112. // AddedField returns the numeric value that was incremented/decremented on a field
  7113. // with the given name. The second boolean return value indicates that this field
  7114. // was not set, or was not defined in the schema.
  7115. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  7116. switch name {
  7117. case batchmsg.FieldStatus:
  7118. return m.AddedStatus()
  7119. case batchmsg.FieldTotal:
  7120. return m.AddedTotal()
  7121. case batchmsg.FieldSuccess:
  7122. return m.AddedSuccess()
  7123. case batchmsg.FieldFail:
  7124. return m.AddedFail()
  7125. case batchmsg.FieldType:
  7126. return m.AddedType()
  7127. case batchmsg.FieldOrganizationID:
  7128. return m.AddedOrganizationID()
  7129. case batchmsg.FieldCtype:
  7130. return m.AddedCtype()
  7131. }
  7132. return nil, false
  7133. }
  7134. // AddField adds the value to the field with the given name. It returns an error if
  7135. // the field is not defined in the schema, or if the type mismatched the field
  7136. // type.
  7137. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  7138. switch name {
  7139. case batchmsg.FieldStatus:
  7140. v, ok := value.(int8)
  7141. if !ok {
  7142. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7143. }
  7144. m.AddStatus(v)
  7145. return nil
  7146. case batchmsg.FieldTotal:
  7147. v, ok := value.(int32)
  7148. if !ok {
  7149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7150. }
  7151. m.AddTotal(v)
  7152. return nil
  7153. case batchmsg.FieldSuccess:
  7154. v, ok := value.(int32)
  7155. if !ok {
  7156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7157. }
  7158. m.AddSuccess(v)
  7159. return nil
  7160. case batchmsg.FieldFail:
  7161. v, ok := value.(int32)
  7162. if !ok {
  7163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7164. }
  7165. m.AddFail(v)
  7166. return nil
  7167. case batchmsg.FieldType:
  7168. v, ok := value.(int32)
  7169. if !ok {
  7170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7171. }
  7172. m.AddType(v)
  7173. return nil
  7174. case batchmsg.FieldOrganizationID:
  7175. v, ok := value.(int64)
  7176. if !ok {
  7177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7178. }
  7179. m.AddOrganizationID(v)
  7180. return nil
  7181. case batchmsg.FieldCtype:
  7182. v, ok := value.(int64)
  7183. if !ok {
  7184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7185. }
  7186. m.AddCtype(v)
  7187. return nil
  7188. }
  7189. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  7190. }
  7191. // ClearedFields returns all nullable fields that were cleared during this
  7192. // mutation.
  7193. func (m *BatchMsgMutation) ClearedFields() []string {
  7194. var fields []string
  7195. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  7196. fields = append(fields, batchmsg.FieldDeletedAt)
  7197. }
  7198. if m.FieldCleared(batchmsg.FieldStatus) {
  7199. fields = append(fields, batchmsg.FieldStatus)
  7200. }
  7201. if m.FieldCleared(batchmsg.FieldBatchNo) {
  7202. fields = append(fields, batchmsg.FieldBatchNo)
  7203. }
  7204. if m.FieldCleared(batchmsg.FieldTaskName) {
  7205. fields = append(fields, batchmsg.FieldTaskName)
  7206. }
  7207. if m.FieldCleared(batchmsg.FieldFromwxid) {
  7208. fields = append(fields, batchmsg.FieldFromwxid)
  7209. }
  7210. if m.FieldCleared(batchmsg.FieldMsg) {
  7211. fields = append(fields, batchmsg.FieldMsg)
  7212. }
  7213. if m.FieldCleared(batchmsg.FieldTag) {
  7214. fields = append(fields, batchmsg.FieldTag)
  7215. }
  7216. if m.FieldCleared(batchmsg.FieldTagids) {
  7217. fields = append(fields, batchmsg.FieldTagids)
  7218. }
  7219. if m.FieldCleared(batchmsg.FieldTotal) {
  7220. fields = append(fields, batchmsg.FieldTotal)
  7221. }
  7222. if m.FieldCleared(batchmsg.FieldSuccess) {
  7223. fields = append(fields, batchmsg.FieldSuccess)
  7224. }
  7225. if m.FieldCleared(batchmsg.FieldFail) {
  7226. fields = append(fields, batchmsg.FieldFail)
  7227. }
  7228. if m.FieldCleared(batchmsg.FieldStartTime) {
  7229. fields = append(fields, batchmsg.FieldStartTime)
  7230. }
  7231. if m.FieldCleared(batchmsg.FieldStopTime) {
  7232. fields = append(fields, batchmsg.FieldStopTime)
  7233. }
  7234. if m.FieldCleared(batchmsg.FieldSendTime) {
  7235. fields = append(fields, batchmsg.FieldSendTime)
  7236. }
  7237. if m.FieldCleared(batchmsg.FieldType) {
  7238. fields = append(fields, batchmsg.FieldType)
  7239. }
  7240. if m.FieldCleared(batchmsg.FieldCc) {
  7241. fields = append(fields, batchmsg.FieldCc)
  7242. }
  7243. if m.FieldCleared(batchmsg.FieldPhone) {
  7244. fields = append(fields, batchmsg.FieldPhone)
  7245. }
  7246. if m.FieldCleared(batchmsg.FieldTemplateName) {
  7247. fields = append(fields, batchmsg.FieldTemplateName)
  7248. }
  7249. if m.FieldCleared(batchmsg.FieldTemplateCode) {
  7250. fields = append(fields, batchmsg.FieldTemplateCode)
  7251. }
  7252. if m.FieldCleared(batchmsg.FieldLang) {
  7253. fields = append(fields, batchmsg.FieldLang)
  7254. }
  7255. return fields
  7256. }
  7257. // FieldCleared returns a boolean indicating if a field with the given name was
  7258. // cleared in this mutation.
  7259. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  7260. _, ok := m.clearedFields[name]
  7261. return ok
  7262. }
  7263. // ClearField clears the value of the field with the given name. It returns an
  7264. // error if the field is not defined in the schema.
  7265. func (m *BatchMsgMutation) ClearField(name string) error {
  7266. switch name {
  7267. case batchmsg.FieldDeletedAt:
  7268. m.ClearDeletedAt()
  7269. return nil
  7270. case batchmsg.FieldStatus:
  7271. m.ClearStatus()
  7272. return nil
  7273. case batchmsg.FieldBatchNo:
  7274. m.ClearBatchNo()
  7275. return nil
  7276. case batchmsg.FieldTaskName:
  7277. m.ClearTaskName()
  7278. return nil
  7279. case batchmsg.FieldFromwxid:
  7280. m.ClearFromwxid()
  7281. return nil
  7282. case batchmsg.FieldMsg:
  7283. m.ClearMsg()
  7284. return nil
  7285. case batchmsg.FieldTag:
  7286. m.ClearTag()
  7287. return nil
  7288. case batchmsg.FieldTagids:
  7289. m.ClearTagids()
  7290. return nil
  7291. case batchmsg.FieldTotal:
  7292. m.ClearTotal()
  7293. return nil
  7294. case batchmsg.FieldSuccess:
  7295. m.ClearSuccess()
  7296. return nil
  7297. case batchmsg.FieldFail:
  7298. m.ClearFail()
  7299. return nil
  7300. case batchmsg.FieldStartTime:
  7301. m.ClearStartTime()
  7302. return nil
  7303. case batchmsg.FieldStopTime:
  7304. m.ClearStopTime()
  7305. return nil
  7306. case batchmsg.FieldSendTime:
  7307. m.ClearSendTime()
  7308. return nil
  7309. case batchmsg.FieldType:
  7310. m.ClearType()
  7311. return nil
  7312. case batchmsg.FieldCc:
  7313. m.ClearCc()
  7314. return nil
  7315. case batchmsg.FieldPhone:
  7316. m.ClearPhone()
  7317. return nil
  7318. case batchmsg.FieldTemplateName:
  7319. m.ClearTemplateName()
  7320. return nil
  7321. case batchmsg.FieldTemplateCode:
  7322. m.ClearTemplateCode()
  7323. return nil
  7324. case batchmsg.FieldLang:
  7325. m.ClearLang()
  7326. return nil
  7327. }
  7328. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  7329. }
  7330. // ResetField resets all changes in the mutation for the field with the given name.
  7331. // It returns an error if the field is not defined in the schema.
  7332. func (m *BatchMsgMutation) ResetField(name string) error {
  7333. switch name {
  7334. case batchmsg.FieldCreatedAt:
  7335. m.ResetCreatedAt()
  7336. return nil
  7337. case batchmsg.FieldUpdatedAt:
  7338. m.ResetUpdatedAt()
  7339. return nil
  7340. case batchmsg.FieldDeletedAt:
  7341. m.ResetDeletedAt()
  7342. return nil
  7343. case batchmsg.FieldStatus:
  7344. m.ResetStatus()
  7345. return nil
  7346. case batchmsg.FieldBatchNo:
  7347. m.ResetBatchNo()
  7348. return nil
  7349. case batchmsg.FieldTaskName:
  7350. m.ResetTaskName()
  7351. return nil
  7352. case batchmsg.FieldFromwxid:
  7353. m.ResetFromwxid()
  7354. return nil
  7355. case batchmsg.FieldMsg:
  7356. m.ResetMsg()
  7357. return nil
  7358. case batchmsg.FieldTag:
  7359. m.ResetTag()
  7360. return nil
  7361. case batchmsg.FieldTagids:
  7362. m.ResetTagids()
  7363. return nil
  7364. case batchmsg.FieldTotal:
  7365. m.ResetTotal()
  7366. return nil
  7367. case batchmsg.FieldSuccess:
  7368. m.ResetSuccess()
  7369. return nil
  7370. case batchmsg.FieldFail:
  7371. m.ResetFail()
  7372. return nil
  7373. case batchmsg.FieldStartTime:
  7374. m.ResetStartTime()
  7375. return nil
  7376. case batchmsg.FieldStopTime:
  7377. m.ResetStopTime()
  7378. return nil
  7379. case batchmsg.FieldSendTime:
  7380. m.ResetSendTime()
  7381. return nil
  7382. case batchmsg.FieldType:
  7383. m.ResetType()
  7384. return nil
  7385. case batchmsg.FieldOrganizationID:
  7386. m.ResetOrganizationID()
  7387. return nil
  7388. case batchmsg.FieldCtype:
  7389. m.ResetCtype()
  7390. return nil
  7391. case batchmsg.FieldCc:
  7392. m.ResetCc()
  7393. return nil
  7394. case batchmsg.FieldPhone:
  7395. m.ResetPhone()
  7396. return nil
  7397. case batchmsg.FieldTemplateName:
  7398. m.ResetTemplateName()
  7399. return nil
  7400. case batchmsg.FieldTemplateCode:
  7401. m.ResetTemplateCode()
  7402. return nil
  7403. case batchmsg.FieldLang:
  7404. m.ResetLang()
  7405. return nil
  7406. }
  7407. return fmt.Errorf("unknown BatchMsg field %s", name)
  7408. }
  7409. // AddedEdges returns all edge names that were set/added in this mutation.
  7410. func (m *BatchMsgMutation) AddedEdges() []string {
  7411. edges := make([]string, 0, 0)
  7412. return edges
  7413. }
  7414. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7415. // name in this mutation.
  7416. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  7417. return nil
  7418. }
  7419. // RemovedEdges returns all edge names that were removed in this mutation.
  7420. func (m *BatchMsgMutation) RemovedEdges() []string {
  7421. edges := make([]string, 0, 0)
  7422. return edges
  7423. }
  7424. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7425. // the given name in this mutation.
  7426. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  7427. return nil
  7428. }
  7429. // ClearedEdges returns all edge names that were cleared in this mutation.
  7430. func (m *BatchMsgMutation) ClearedEdges() []string {
  7431. edges := make([]string, 0, 0)
  7432. return edges
  7433. }
  7434. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7435. // was cleared in this mutation.
  7436. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  7437. return false
  7438. }
  7439. // ClearEdge clears the value of the edge with the given name. It returns an error
  7440. // if that edge is not defined in the schema.
  7441. func (m *BatchMsgMutation) ClearEdge(name string) error {
  7442. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  7443. }
  7444. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7445. // It returns an error if the edge is not defined in the schema.
  7446. func (m *BatchMsgMutation) ResetEdge(name string) error {
  7447. return fmt.Errorf("unknown BatchMsg edge %s", name)
  7448. }
  7449. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  7450. type CategoryMutation struct {
  7451. config
  7452. op Op
  7453. typ string
  7454. id *uint64
  7455. created_at *time.Time
  7456. updated_at *time.Time
  7457. deleted_at *time.Time
  7458. name *string
  7459. organization_id *uint64
  7460. addorganization_id *int64
  7461. clearedFields map[string]struct{}
  7462. done bool
  7463. oldValue func(context.Context) (*Category, error)
  7464. predicates []predicate.Category
  7465. }
  7466. var _ ent.Mutation = (*CategoryMutation)(nil)
  7467. // categoryOption allows management of the mutation configuration using functional options.
  7468. type categoryOption func(*CategoryMutation)
  7469. // newCategoryMutation creates new mutation for the Category entity.
  7470. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  7471. m := &CategoryMutation{
  7472. config: c,
  7473. op: op,
  7474. typ: TypeCategory,
  7475. clearedFields: make(map[string]struct{}),
  7476. }
  7477. for _, opt := range opts {
  7478. opt(m)
  7479. }
  7480. return m
  7481. }
  7482. // withCategoryID sets the ID field of the mutation.
  7483. func withCategoryID(id uint64) categoryOption {
  7484. return func(m *CategoryMutation) {
  7485. var (
  7486. err error
  7487. once sync.Once
  7488. value *Category
  7489. )
  7490. m.oldValue = func(ctx context.Context) (*Category, error) {
  7491. once.Do(func() {
  7492. if m.done {
  7493. err = errors.New("querying old values post mutation is not allowed")
  7494. } else {
  7495. value, err = m.Client().Category.Get(ctx, id)
  7496. }
  7497. })
  7498. return value, err
  7499. }
  7500. m.id = &id
  7501. }
  7502. }
  7503. // withCategory sets the old Category of the mutation.
  7504. func withCategory(node *Category) categoryOption {
  7505. return func(m *CategoryMutation) {
  7506. m.oldValue = func(context.Context) (*Category, error) {
  7507. return node, nil
  7508. }
  7509. m.id = &node.ID
  7510. }
  7511. }
  7512. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7513. // executed in a transaction (ent.Tx), a transactional client is returned.
  7514. func (m CategoryMutation) Client() *Client {
  7515. client := &Client{config: m.config}
  7516. client.init()
  7517. return client
  7518. }
  7519. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7520. // it returns an error otherwise.
  7521. func (m CategoryMutation) Tx() (*Tx, error) {
  7522. if _, ok := m.driver.(*txDriver); !ok {
  7523. return nil, errors.New("ent: mutation is not running in a transaction")
  7524. }
  7525. tx := &Tx{config: m.config}
  7526. tx.init()
  7527. return tx, nil
  7528. }
  7529. // SetID sets the value of the id field. Note that this
  7530. // operation is only accepted on creation of Category entities.
  7531. func (m *CategoryMutation) SetID(id uint64) {
  7532. m.id = &id
  7533. }
  7534. // ID returns the ID value in the mutation. Note that the ID is only available
  7535. // if it was provided to the builder or after it was returned from the database.
  7536. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  7537. if m.id == nil {
  7538. return
  7539. }
  7540. return *m.id, true
  7541. }
  7542. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7543. // That means, if the mutation is applied within a transaction with an isolation level such
  7544. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7545. // or updated by the mutation.
  7546. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  7547. switch {
  7548. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7549. id, exists := m.ID()
  7550. if exists {
  7551. return []uint64{id}, nil
  7552. }
  7553. fallthrough
  7554. case m.op.Is(OpUpdate | OpDelete):
  7555. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  7556. default:
  7557. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7558. }
  7559. }
  7560. // SetCreatedAt sets the "created_at" field.
  7561. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  7562. m.created_at = &t
  7563. }
  7564. // CreatedAt returns the value of the "created_at" field in the mutation.
  7565. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  7566. v := m.created_at
  7567. if v == nil {
  7568. return
  7569. }
  7570. return *v, true
  7571. }
  7572. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  7573. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7574. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7575. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7576. if !m.op.Is(OpUpdateOne) {
  7577. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7578. }
  7579. if m.id == nil || m.oldValue == nil {
  7580. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7581. }
  7582. oldValue, err := m.oldValue(ctx)
  7583. if err != nil {
  7584. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7585. }
  7586. return oldValue.CreatedAt, nil
  7587. }
  7588. // ResetCreatedAt resets all changes to the "created_at" field.
  7589. func (m *CategoryMutation) ResetCreatedAt() {
  7590. m.created_at = nil
  7591. }
  7592. // SetUpdatedAt sets the "updated_at" field.
  7593. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  7594. m.updated_at = &t
  7595. }
  7596. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7597. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  7598. v := m.updated_at
  7599. if v == nil {
  7600. return
  7601. }
  7602. return *v, true
  7603. }
  7604. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  7605. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7606. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7607. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7608. if !m.op.Is(OpUpdateOne) {
  7609. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7610. }
  7611. if m.id == nil || m.oldValue == nil {
  7612. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7613. }
  7614. oldValue, err := m.oldValue(ctx)
  7615. if err != nil {
  7616. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7617. }
  7618. return oldValue.UpdatedAt, nil
  7619. }
  7620. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7621. func (m *CategoryMutation) ResetUpdatedAt() {
  7622. m.updated_at = nil
  7623. }
  7624. // SetDeletedAt sets the "deleted_at" field.
  7625. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  7626. m.deleted_at = &t
  7627. }
  7628. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7629. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  7630. v := m.deleted_at
  7631. if v == nil {
  7632. return
  7633. }
  7634. return *v, true
  7635. }
  7636. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  7637. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7638. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7639. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7640. if !m.op.Is(OpUpdateOne) {
  7641. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7642. }
  7643. if m.id == nil || m.oldValue == nil {
  7644. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7645. }
  7646. oldValue, err := m.oldValue(ctx)
  7647. if err != nil {
  7648. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7649. }
  7650. return oldValue.DeletedAt, nil
  7651. }
  7652. // ClearDeletedAt clears the value of the "deleted_at" field.
  7653. func (m *CategoryMutation) ClearDeletedAt() {
  7654. m.deleted_at = nil
  7655. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  7656. }
  7657. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7658. func (m *CategoryMutation) DeletedAtCleared() bool {
  7659. _, ok := m.clearedFields[category.FieldDeletedAt]
  7660. return ok
  7661. }
  7662. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7663. func (m *CategoryMutation) ResetDeletedAt() {
  7664. m.deleted_at = nil
  7665. delete(m.clearedFields, category.FieldDeletedAt)
  7666. }
  7667. // SetName sets the "name" field.
  7668. func (m *CategoryMutation) SetName(s string) {
  7669. m.name = &s
  7670. }
  7671. // Name returns the value of the "name" field in the mutation.
  7672. func (m *CategoryMutation) Name() (r string, exists bool) {
  7673. v := m.name
  7674. if v == nil {
  7675. return
  7676. }
  7677. return *v, true
  7678. }
  7679. // OldName returns the old "name" field's value of the Category entity.
  7680. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7681. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7682. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  7683. if !m.op.Is(OpUpdateOne) {
  7684. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7685. }
  7686. if m.id == nil || m.oldValue == nil {
  7687. return v, errors.New("OldName requires an ID field in the mutation")
  7688. }
  7689. oldValue, err := m.oldValue(ctx)
  7690. if err != nil {
  7691. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7692. }
  7693. return oldValue.Name, nil
  7694. }
  7695. // ResetName resets all changes to the "name" field.
  7696. func (m *CategoryMutation) ResetName() {
  7697. m.name = nil
  7698. }
  7699. // SetOrganizationID sets the "organization_id" field.
  7700. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  7701. m.organization_id = &u
  7702. m.addorganization_id = nil
  7703. }
  7704. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7705. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  7706. v := m.organization_id
  7707. if v == nil {
  7708. return
  7709. }
  7710. return *v, true
  7711. }
  7712. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  7713. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7714. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7715. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7716. if !m.op.Is(OpUpdateOne) {
  7717. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7718. }
  7719. if m.id == nil || m.oldValue == nil {
  7720. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  7721. }
  7722. oldValue, err := m.oldValue(ctx)
  7723. if err != nil {
  7724. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  7725. }
  7726. return oldValue.OrganizationID, nil
  7727. }
  7728. // AddOrganizationID adds u to the "organization_id" field.
  7729. func (m *CategoryMutation) AddOrganizationID(u int64) {
  7730. if m.addorganization_id != nil {
  7731. *m.addorganization_id += u
  7732. } else {
  7733. m.addorganization_id = &u
  7734. }
  7735. }
  7736. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7737. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  7738. v := m.addorganization_id
  7739. if v == nil {
  7740. return
  7741. }
  7742. return *v, true
  7743. }
  7744. // ResetOrganizationID resets all changes to the "organization_id" field.
  7745. func (m *CategoryMutation) ResetOrganizationID() {
  7746. m.organization_id = nil
  7747. m.addorganization_id = nil
  7748. }
  7749. // Where appends a list predicates to the CategoryMutation builder.
  7750. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  7751. m.predicates = append(m.predicates, ps...)
  7752. }
  7753. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  7754. // users can use type-assertion to append predicates that do not depend on any generated package.
  7755. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  7756. p := make([]predicate.Category, len(ps))
  7757. for i := range ps {
  7758. p[i] = ps[i]
  7759. }
  7760. m.Where(p...)
  7761. }
  7762. // Op returns the operation name.
  7763. func (m *CategoryMutation) Op() Op {
  7764. return m.op
  7765. }
  7766. // SetOp allows setting the mutation operation.
  7767. func (m *CategoryMutation) SetOp(op Op) {
  7768. m.op = op
  7769. }
  7770. // Type returns the node type of this mutation (Category).
  7771. func (m *CategoryMutation) Type() string {
  7772. return m.typ
  7773. }
  7774. // Fields returns all fields that were changed during this mutation. Note that in
  7775. // order to get all numeric fields that were incremented/decremented, call
  7776. // AddedFields().
  7777. func (m *CategoryMutation) Fields() []string {
  7778. fields := make([]string, 0, 5)
  7779. if m.created_at != nil {
  7780. fields = append(fields, category.FieldCreatedAt)
  7781. }
  7782. if m.updated_at != nil {
  7783. fields = append(fields, category.FieldUpdatedAt)
  7784. }
  7785. if m.deleted_at != nil {
  7786. fields = append(fields, category.FieldDeletedAt)
  7787. }
  7788. if m.name != nil {
  7789. fields = append(fields, category.FieldName)
  7790. }
  7791. if m.organization_id != nil {
  7792. fields = append(fields, category.FieldOrganizationID)
  7793. }
  7794. return fields
  7795. }
  7796. // Field returns the value of a field with the given name. The second boolean
  7797. // return value indicates that this field was not set, or was not defined in the
  7798. // schema.
  7799. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  7800. switch name {
  7801. case category.FieldCreatedAt:
  7802. return m.CreatedAt()
  7803. case category.FieldUpdatedAt:
  7804. return m.UpdatedAt()
  7805. case category.FieldDeletedAt:
  7806. return m.DeletedAt()
  7807. case category.FieldName:
  7808. return m.Name()
  7809. case category.FieldOrganizationID:
  7810. return m.OrganizationID()
  7811. }
  7812. return nil, false
  7813. }
  7814. // OldField returns the old value of the field from the database. An error is
  7815. // returned if the mutation operation is not UpdateOne, or the query to the
  7816. // database failed.
  7817. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7818. switch name {
  7819. case category.FieldCreatedAt:
  7820. return m.OldCreatedAt(ctx)
  7821. case category.FieldUpdatedAt:
  7822. return m.OldUpdatedAt(ctx)
  7823. case category.FieldDeletedAt:
  7824. return m.OldDeletedAt(ctx)
  7825. case category.FieldName:
  7826. return m.OldName(ctx)
  7827. case category.FieldOrganizationID:
  7828. return m.OldOrganizationID(ctx)
  7829. }
  7830. return nil, fmt.Errorf("unknown Category field %s", name)
  7831. }
  7832. // SetField sets the value of a field with the given name. It returns an error if
  7833. // the field is not defined in the schema, or if the type mismatched the field
  7834. // type.
  7835. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  7836. switch name {
  7837. case category.FieldCreatedAt:
  7838. v, ok := value.(time.Time)
  7839. if !ok {
  7840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7841. }
  7842. m.SetCreatedAt(v)
  7843. return nil
  7844. case category.FieldUpdatedAt:
  7845. v, ok := value.(time.Time)
  7846. if !ok {
  7847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7848. }
  7849. m.SetUpdatedAt(v)
  7850. return nil
  7851. case category.FieldDeletedAt:
  7852. v, ok := value.(time.Time)
  7853. if !ok {
  7854. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7855. }
  7856. m.SetDeletedAt(v)
  7857. return nil
  7858. case category.FieldName:
  7859. v, ok := value.(string)
  7860. if !ok {
  7861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7862. }
  7863. m.SetName(v)
  7864. return nil
  7865. case category.FieldOrganizationID:
  7866. v, ok := value.(uint64)
  7867. if !ok {
  7868. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7869. }
  7870. m.SetOrganizationID(v)
  7871. return nil
  7872. }
  7873. return fmt.Errorf("unknown Category field %s", name)
  7874. }
  7875. // AddedFields returns all numeric fields that were incremented/decremented during
  7876. // this mutation.
  7877. func (m *CategoryMutation) AddedFields() []string {
  7878. var fields []string
  7879. if m.addorganization_id != nil {
  7880. fields = append(fields, category.FieldOrganizationID)
  7881. }
  7882. return fields
  7883. }
  7884. // AddedField returns the numeric value that was incremented/decremented on a field
  7885. // with the given name. The second boolean return value indicates that this field
  7886. // was not set, or was not defined in the schema.
  7887. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  7888. switch name {
  7889. case category.FieldOrganizationID:
  7890. return m.AddedOrganizationID()
  7891. }
  7892. return nil, false
  7893. }
  7894. // AddField adds the value to the field with the given name. It returns an error if
  7895. // the field is not defined in the schema, or if the type mismatched the field
  7896. // type.
  7897. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  7898. switch name {
  7899. case category.FieldOrganizationID:
  7900. v, ok := value.(int64)
  7901. if !ok {
  7902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7903. }
  7904. m.AddOrganizationID(v)
  7905. return nil
  7906. }
  7907. return fmt.Errorf("unknown Category numeric field %s", name)
  7908. }
  7909. // ClearedFields returns all nullable fields that were cleared during this
  7910. // mutation.
  7911. func (m *CategoryMutation) ClearedFields() []string {
  7912. var fields []string
  7913. if m.FieldCleared(category.FieldDeletedAt) {
  7914. fields = append(fields, category.FieldDeletedAt)
  7915. }
  7916. return fields
  7917. }
  7918. // FieldCleared returns a boolean indicating if a field with the given name was
  7919. // cleared in this mutation.
  7920. func (m *CategoryMutation) FieldCleared(name string) bool {
  7921. _, ok := m.clearedFields[name]
  7922. return ok
  7923. }
  7924. // ClearField clears the value of the field with the given name. It returns an
  7925. // error if the field is not defined in the schema.
  7926. func (m *CategoryMutation) ClearField(name string) error {
  7927. switch name {
  7928. case category.FieldDeletedAt:
  7929. m.ClearDeletedAt()
  7930. return nil
  7931. }
  7932. return fmt.Errorf("unknown Category nullable field %s", name)
  7933. }
  7934. // ResetField resets all changes in the mutation for the field with the given name.
  7935. // It returns an error if the field is not defined in the schema.
  7936. func (m *CategoryMutation) ResetField(name string) error {
  7937. switch name {
  7938. case category.FieldCreatedAt:
  7939. m.ResetCreatedAt()
  7940. return nil
  7941. case category.FieldUpdatedAt:
  7942. m.ResetUpdatedAt()
  7943. return nil
  7944. case category.FieldDeletedAt:
  7945. m.ResetDeletedAt()
  7946. return nil
  7947. case category.FieldName:
  7948. m.ResetName()
  7949. return nil
  7950. case category.FieldOrganizationID:
  7951. m.ResetOrganizationID()
  7952. return nil
  7953. }
  7954. return fmt.Errorf("unknown Category field %s", name)
  7955. }
  7956. // AddedEdges returns all edge names that were set/added in this mutation.
  7957. func (m *CategoryMutation) AddedEdges() []string {
  7958. edges := make([]string, 0, 0)
  7959. return edges
  7960. }
  7961. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7962. // name in this mutation.
  7963. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  7964. return nil
  7965. }
  7966. // RemovedEdges returns all edge names that were removed in this mutation.
  7967. func (m *CategoryMutation) RemovedEdges() []string {
  7968. edges := make([]string, 0, 0)
  7969. return edges
  7970. }
  7971. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7972. // the given name in this mutation.
  7973. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  7974. return nil
  7975. }
  7976. // ClearedEdges returns all edge names that were cleared in this mutation.
  7977. func (m *CategoryMutation) ClearedEdges() []string {
  7978. edges := make([]string, 0, 0)
  7979. return edges
  7980. }
  7981. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7982. // was cleared in this mutation.
  7983. func (m *CategoryMutation) EdgeCleared(name string) bool {
  7984. return false
  7985. }
  7986. // ClearEdge clears the value of the edge with the given name. It returns an error
  7987. // if that edge is not defined in the schema.
  7988. func (m *CategoryMutation) ClearEdge(name string) error {
  7989. return fmt.Errorf("unknown Category unique edge %s", name)
  7990. }
  7991. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7992. // It returns an error if the edge is not defined in the schema.
  7993. func (m *CategoryMutation) ResetEdge(name string) error {
  7994. return fmt.Errorf("unknown Category edge %s", name)
  7995. }
  7996. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  7997. type ChatRecordsMutation struct {
  7998. config
  7999. op Op
  8000. typ string
  8001. id *uint64
  8002. created_at *time.Time
  8003. updated_at *time.Time
  8004. deleted_at *time.Time
  8005. content *string
  8006. content_type *uint8
  8007. addcontent_type *int8
  8008. session_id *uint64
  8009. addsession_id *int64
  8010. user_id *uint64
  8011. adduser_id *int64
  8012. bot_id *uint64
  8013. addbot_id *int64
  8014. bot_type *uint8
  8015. addbot_type *int8
  8016. clearedFields map[string]struct{}
  8017. done bool
  8018. oldValue func(context.Context) (*ChatRecords, error)
  8019. predicates []predicate.ChatRecords
  8020. }
  8021. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  8022. // chatrecordsOption allows management of the mutation configuration using functional options.
  8023. type chatrecordsOption func(*ChatRecordsMutation)
  8024. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  8025. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  8026. m := &ChatRecordsMutation{
  8027. config: c,
  8028. op: op,
  8029. typ: TypeChatRecords,
  8030. clearedFields: make(map[string]struct{}),
  8031. }
  8032. for _, opt := range opts {
  8033. opt(m)
  8034. }
  8035. return m
  8036. }
  8037. // withChatRecordsID sets the ID field of the mutation.
  8038. func withChatRecordsID(id uint64) chatrecordsOption {
  8039. return func(m *ChatRecordsMutation) {
  8040. var (
  8041. err error
  8042. once sync.Once
  8043. value *ChatRecords
  8044. )
  8045. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  8046. once.Do(func() {
  8047. if m.done {
  8048. err = errors.New("querying old values post mutation is not allowed")
  8049. } else {
  8050. value, err = m.Client().ChatRecords.Get(ctx, id)
  8051. }
  8052. })
  8053. return value, err
  8054. }
  8055. m.id = &id
  8056. }
  8057. }
  8058. // withChatRecords sets the old ChatRecords of the mutation.
  8059. func withChatRecords(node *ChatRecords) chatrecordsOption {
  8060. return func(m *ChatRecordsMutation) {
  8061. m.oldValue = func(context.Context) (*ChatRecords, error) {
  8062. return node, nil
  8063. }
  8064. m.id = &node.ID
  8065. }
  8066. }
  8067. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8068. // executed in a transaction (ent.Tx), a transactional client is returned.
  8069. func (m ChatRecordsMutation) Client() *Client {
  8070. client := &Client{config: m.config}
  8071. client.init()
  8072. return client
  8073. }
  8074. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8075. // it returns an error otherwise.
  8076. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  8077. if _, ok := m.driver.(*txDriver); !ok {
  8078. return nil, errors.New("ent: mutation is not running in a transaction")
  8079. }
  8080. tx := &Tx{config: m.config}
  8081. tx.init()
  8082. return tx, nil
  8083. }
  8084. // SetID sets the value of the id field. Note that this
  8085. // operation is only accepted on creation of ChatRecords entities.
  8086. func (m *ChatRecordsMutation) SetID(id uint64) {
  8087. m.id = &id
  8088. }
  8089. // ID returns the ID value in the mutation. Note that the ID is only available
  8090. // if it was provided to the builder or after it was returned from the database.
  8091. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  8092. if m.id == nil {
  8093. return
  8094. }
  8095. return *m.id, true
  8096. }
  8097. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8098. // That means, if the mutation is applied within a transaction with an isolation level such
  8099. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8100. // or updated by the mutation.
  8101. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  8102. switch {
  8103. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8104. id, exists := m.ID()
  8105. if exists {
  8106. return []uint64{id}, nil
  8107. }
  8108. fallthrough
  8109. case m.op.Is(OpUpdate | OpDelete):
  8110. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  8111. default:
  8112. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8113. }
  8114. }
  8115. // SetCreatedAt sets the "created_at" field.
  8116. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  8117. m.created_at = &t
  8118. }
  8119. // CreatedAt returns the value of the "created_at" field in the mutation.
  8120. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  8121. v := m.created_at
  8122. if v == nil {
  8123. return
  8124. }
  8125. return *v, true
  8126. }
  8127. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  8128. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8129. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8130. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8131. if !m.op.Is(OpUpdateOne) {
  8132. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8133. }
  8134. if m.id == nil || m.oldValue == nil {
  8135. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8136. }
  8137. oldValue, err := m.oldValue(ctx)
  8138. if err != nil {
  8139. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8140. }
  8141. return oldValue.CreatedAt, nil
  8142. }
  8143. // ResetCreatedAt resets all changes to the "created_at" field.
  8144. func (m *ChatRecordsMutation) ResetCreatedAt() {
  8145. m.created_at = nil
  8146. }
  8147. // SetUpdatedAt sets the "updated_at" field.
  8148. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  8149. m.updated_at = &t
  8150. }
  8151. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8152. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  8153. v := m.updated_at
  8154. if v == nil {
  8155. return
  8156. }
  8157. return *v, true
  8158. }
  8159. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  8160. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8161. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8162. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8163. if !m.op.Is(OpUpdateOne) {
  8164. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8165. }
  8166. if m.id == nil || m.oldValue == nil {
  8167. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8168. }
  8169. oldValue, err := m.oldValue(ctx)
  8170. if err != nil {
  8171. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8172. }
  8173. return oldValue.UpdatedAt, nil
  8174. }
  8175. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8176. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  8177. m.updated_at = nil
  8178. }
  8179. // SetDeletedAt sets the "deleted_at" field.
  8180. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  8181. m.deleted_at = &t
  8182. }
  8183. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8184. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  8185. v := m.deleted_at
  8186. if v == nil {
  8187. return
  8188. }
  8189. return *v, true
  8190. }
  8191. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  8192. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8193. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8194. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8195. if !m.op.Is(OpUpdateOne) {
  8196. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8197. }
  8198. if m.id == nil || m.oldValue == nil {
  8199. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8200. }
  8201. oldValue, err := m.oldValue(ctx)
  8202. if err != nil {
  8203. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8204. }
  8205. return oldValue.DeletedAt, nil
  8206. }
  8207. // ClearDeletedAt clears the value of the "deleted_at" field.
  8208. func (m *ChatRecordsMutation) ClearDeletedAt() {
  8209. m.deleted_at = nil
  8210. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  8211. }
  8212. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8213. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  8214. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  8215. return ok
  8216. }
  8217. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8218. func (m *ChatRecordsMutation) ResetDeletedAt() {
  8219. m.deleted_at = nil
  8220. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  8221. }
  8222. // SetContent sets the "content" field.
  8223. func (m *ChatRecordsMutation) SetContent(s string) {
  8224. m.content = &s
  8225. }
  8226. // Content returns the value of the "content" field in the mutation.
  8227. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  8228. v := m.content
  8229. if v == nil {
  8230. return
  8231. }
  8232. return *v, true
  8233. }
  8234. // OldContent returns the old "content" field's value of the ChatRecords entity.
  8235. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8236. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8237. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  8238. if !m.op.Is(OpUpdateOne) {
  8239. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  8240. }
  8241. if m.id == nil || m.oldValue == nil {
  8242. return v, errors.New("OldContent requires an ID field in the mutation")
  8243. }
  8244. oldValue, err := m.oldValue(ctx)
  8245. if err != nil {
  8246. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  8247. }
  8248. return oldValue.Content, nil
  8249. }
  8250. // ResetContent resets all changes to the "content" field.
  8251. func (m *ChatRecordsMutation) ResetContent() {
  8252. m.content = nil
  8253. }
  8254. // SetContentType sets the "content_type" field.
  8255. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  8256. m.content_type = &u
  8257. m.addcontent_type = nil
  8258. }
  8259. // ContentType returns the value of the "content_type" field in the mutation.
  8260. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  8261. v := m.content_type
  8262. if v == nil {
  8263. return
  8264. }
  8265. return *v, true
  8266. }
  8267. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  8268. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8269. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8270. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  8271. if !m.op.Is(OpUpdateOne) {
  8272. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  8273. }
  8274. if m.id == nil || m.oldValue == nil {
  8275. return v, errors.New("OldContentType requires an ID field in the mutation")
  8276. }
  8277. oldValue, err := m.oldValue(ctx)
  8278. if err != nil {
  8279. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  8280. }
  8281. return oldValue.ContentType, nil
  8282. }
  8283. // AddContentType adds u to the "content_type" field.
  8284. func (m *ChatRecordsMutation) AddContentType(u int8) {
  8285. if m.addcontent_type != nil {
  8286. *m.addcontent_type += u
  8287. } else {
  8288. m.addcontent_type = &u
  8289. }
  8290. }
  8291. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  8292. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  8293. v := m.addcontent_type
  8294. if v == nil {
  8295. return
  8296. }
  8297. return *v, true
  8298. }
  8299. // ResetContentType resets all changes to the "content_type" field.
  8300. func (m *ChatRecordsMutation) ResetContentType() {
  8301. m.content_type = nil
  8302. m.addcontent_type = nil
  8303. }
  8304. // SetSessionID sets the "session_id" field.
  8305. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  8306. m.session_id = &u
  8307. m.addsession_id = nil
  8308. }
  8309. // SessionID returns the value of the "session_id" field in the mutation.
  8310. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  8311. v := m.session_id
  8312. if v == nil {
  8313. return
  8314. }
  8315. return *v, true
  8316. }
  8317. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  8318. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8319. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8320. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  8321. if !m.op.Is(OpUpdateOne) {
  8322. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  8323. }
  8324. if m.id == nil || m.oldValue == nil {
  8325. return v, errors.New("OldSessionID requires an ID field in the mutation")
  8326. }
  8327. oldValue, err := m.oldValue(ctx)
  8328. if err != nil {
  8329. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  8330. }
  8331. return oldValue.SessionID, nil
  8332. }
  8333. // AddSessionID adds u to the "session_id" field.
  8334. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  8335. if m.addsession_id != nil {
  8336. *m.addsession_id += u
  8337. } else {
  8338. m.addsession_id = &u
  8339. }
  8340. }
  8341. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  8342. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  8343. v := m.addsession_id
  8344. if v == nil {
  8345. return
  8346. }
  8347. return *v, true
  8348. }
  8349. // ResetSessionID resets all changes to the "session_id" field.
  8350. func (m *ChatRecordsMutation) ResetSessionID() {
  8351. m.session_id = nil
  8352. m.addsession_id = nil
  8353. }
  8354. // SetUserID sets the "user_id" field.
  8355. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  8356. m.user_id = &u
  8357. m.adduser_id = nil
  8358. }
  8359. // UserID returns the value of the "user_id" field in the mutation.
  8360. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  8361. v := m.user_id
  8362. if v == nil {
  8363. return
  8364. }
  8365. return *v, true
  8366. }
  8367. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  8368. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8369. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8370. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  8371. if !m.op.Is(OpUpdateOne) {
  8372. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  8373. }
  8374. if m.id == nil || m.oldValue == nil {
  8375. return v, errors.New("OldUserID requires an ID field in the mutation")
  8376. }
  8377. oldValue, err := m.oldValue(ctx)
  8378. if err != nil {
  8379. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  8380. }
  8381. return oldValue.UserID, nil
  8382. }
  8383. // AddUserID adds u to the "user_id" field.
  8384. func (m *ChatRecordsMutation) AddUserID(u int64) {
  8385. if m.adduser_id != nil {
  8386. *m.adduser_id += u
  8387. } else {
  8388. m.adduser_id = &u
  8389. }
  8390. }
  8391. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  8392. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  8393. v := m.adduser_id
  8394. if v == nil {
  8395. return
  8396. }
  8397. return *v, true
  8398. }
  8399. // ResetUserID resets all changes to the "user_id" field.
  8400. func (m *ChatRecordsMutation) ResetUserID() {
  8401. m.user_id = nil
  8402. m.adduser_id = nil
  8403. }
  8404. // SetBotID sets the "bot_id" field.
  8405. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  8406. m.bot_id = &u
  8407. m.addbot_id = nil
  8408. }
  8409. // BotID returns the value of the "bot_id" field in the mutation.
  8410. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  8411. v := m.bot_id
  8412. if v == nil {
  8413. return
  8414. }
  8415. return *v, true
  8416. }
  8417. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  8418. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8419. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8420. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  8421. if !m.op.Is(OpUpdateOne) {
  8422. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  8423. }
  8424. if m.id == nil || m.oldValue == nil {
  8425. return v, errors.New("OldBotID requires an ID field in the mutation")
  8426. }
  8427. oldValue, err := m.oldValue(ctx)
  8428. if err != nil {
  8429. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  8430. }
  8431. return oldValue.BotID, nil
  8432. }
  8433. // AddBotID adds u to the "bot_id" field.
  8434. func (m *ChatRecordsMutation) AddBotID(u int64) {
  8435. if m.addbot_id != nil {
  8436. *m.addbot_id += u
  8437. } else {
  8438. m.addbot_id = &u
  8439. }
  8440. }
  8441. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  8442. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  8443. v := m.addbot_id
  8444. if v == nil {
  8445. return
  8446. }
  8447. return *v, true
  8448. }
  8449. // ResetBotID resets all changes to the "bot_id" field.
  8450. func (m *ChatRecordsMutation) ResetBotID() {
  8451. m.bot_id = nil
  8452. m.addbot_id = nil
  8453. }
  8454. // SetBotType sets the "bot_type" field.
  8455. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  8456. m.bot_type = &u
  8457. m.addbot_type = nil
  8458. }
  8459. // BotType returns the value of the "bot_type" field in the mutation.
  8460. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  8461. v := m.bot_type
  8462. if v == nil {
  8463. return
  8464. }
  8465. return *v, true
  8466. }
  8467. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  8468. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8469. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8470. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  8471. if !m.op.Is(OpUpdateOne) {
  8472. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  8473. }
  8474. if m.id == nil || m.oldValue == nil {
  8475. return v, errors.New("OldBotType requires an ID field in the mutation")
  8476. }
  8477. oldValue, err := m.oldValue(ctx)
  8478. if err != nil {
  8479. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  8480. }
  8481. return oldValue.BotType, nil
  8482. }
  8483. // AddBotType adds u to the "bot_type" field.
  8484. func (m *ChatRecordsMutation) AddBotType(u int8) {
  8485. if m.addbot_type != nil {
  8486. *m.addbot_type += u
  8487. } else {
  8488. m.addbot_type = &u
  8489. }
  8490. }
  8491. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  8492. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  8493. v := m.addbot_type
  8494. if v == nil {
  8495. return
  8496. }
  8497. return *v, true
  8498. }
  8499. // ResetBotType resets all changes to the "bot_type" field.
  8500. func (m *ChatRecordsMutation) ResetBotType() {
  8501. m.bot_type = nil
  8502. m.addbot_type = nil
  8503. }
  8504. // Where appends a list predicates to the ChatRecordsMutation builder.
  8505. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  8506. m.predicates = append(m.predicates, ps...)
  8507. }
  8508. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  8509. // users can use type-assertion to append predicates that do not depend on any generated package.
  8510. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  8511. p := make([]predicate.ChatRecords, len(ps))
  8512. for i := range ps {
  8513. p[i] = ps[i]
  8514. }
  8515. m.Where(p...)
  8516. }
  8517. // Op returns the operation name.
  8518. func (m *ChatRecordsMutation) Op() Op {
  8519. return m.op
  8520. }
  8521. // SetOp allows setting the mutation operation.
  8522. func (m *ChatRecordsMutation) SetOp(op Op) {
  8523. m.op = op
  8524. }
  8525. // Type returns the node type of this mutation (ChatRecords).
  8526. func (m *ChatRecordsMutation) Type() string {
  8527. return m.typ
  8528. }
  8529. // Fields returns all fields that were changed during this mutation. Note that in
  8530. // order to get all numeric fields that were incremented/decremented, call
  8531. // AddedFields().
  8532. func (m *ChatRecordsMutation) Fields() []string {
  8533. fields := make([]string, 0, 9)
  8534. if m.created_at != nil {
  8535. fields = append(fields, chatrecords.FieldCreatedAt)
  8536. }
  8537. if m.updated_at != nil {
  8538. fields = append(fields, chatrecords.FieldUpdatedAt)
  8539. }
  8540. if m.deleted_at != nil {
  8541. fields = append(fields, chatrecords.FieldDeletedAt)
  8542. }
  8543. if m.content != nil {
  8544. fields = append(fields, chatrecords.FieldContent)
  8545. }
  8546. if m.content_type != nil {
  8547. fields = append(fields, chatrecords.FieldContentType)
  8548. }
  8549. if m.session_id != nil {
  8550. fields = append(fields, chatrecords.FieldSessionID)
  8551. }
  8552. if m.user_id != nil {
  8553. fields = append(fields, chatrecords.FieldUserID)
  8554. }
  8555. if m.bot_id != nil {
  8556. fields = append(fields, chatrecords.FieldBotID)
  8557. }
  8558. if m.bot_type != nil {
  8559. fields = append(fields, chatrecords.FieldBotType)
  8560. }
  8561. return fields
  8562. }
  8563. // Field returns the value of a field with the given name. The second boolean
  8564. // return value indicates that this field was not set, or was not defined in the
  8565. // schema.
  8566. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  8567. switch name {
  8568. case chatrecords.FieldCreatedAt:
  8569. return m.CreatedAt()
  8570. case chatrecords.FieldUpdatedAt:
  8571. return m.UpdatedAt()
  8572. case chatrecords.FieldDeletedAt:
  8573. return m.DeletedAt()
  8574. case chatrecords.FieldContent:
  8575. return m.Content()
  8576. case chatrecords.FieldContentType:
  8577. return m.ContentType()
  8578. case chatrecords.FieldSessionID:
  8579. return m.SessionID()
  8580. case chatrecords.FieldUserID:
  8581. return m.UserID()
  8582. case chatrecords.FieldBotID:
  8583. return m.BotID()
  8584. case chatrecords.FieldBotType:
  8585. return m.BotType()
  8586. }
  8587. return nil, false
  8588. }
  8589. // OldField returns the old value of the field from the database. An error is
  8590. // returned if the mutation operation is not UpdateOne, or the query to the
  8591. // database failed.
  8592. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8593. switch name {
  8594. case chatrecords.FieldCreatedAt:
  8595. return m.OldCreatedAt(ctx)
  8596. case chatrecords.FieldUpdatedAt:
  8597. return m.OldUpdatedAt(ctx)
  8598. case chatrecords.FieldDeletedAt:
  8599. return m.OldDeletedAt(ctx)
  8600. case chatrecords.FieldContent:
  8601. return m.OldContent(ctx)
  8602. case chatrecords.FieldContentType:
  8603. return m.OldContentType(ctx)
  8604. case chatrecords.FieldSessionID:
  8605. return m.OldSessionID(ctx)
  8606. case chatrecords.FieldUserID:
  8607. return m.OldUserID(ctx)
  8608. case chatrecords.FieldBotID:
  8609. return m.OldBotID(ctx)
  8610. case chatrecords.FieldBotType:
  8611. return m.OldBotType(ctx)
  8612. }
  8613. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  8614. }
  8615. // SetField sets the value of a field with the given name. It returns an error if
  8616. // the field is not defined in the schema, or if the type mismatched the field
  8617. // type.
  8618. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  8619. switch name {
  8620. case chatrecords.FieldCreatedAt:
  8621. v, ok := value.(time.Time)
  8622. if !ok {
  8623. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8624. }
  8625. m.SetCreatedAt(v)
  8626. return nil
  8627. case chatrecords.FieldUpdatedAt:
  8628. v, ok := value.(time.Time)
  8629. if !ok {
  8630. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8631. }
  8632. m.SetUpdatedAt(v)
  8633. return nil
  8634. case chatrecords.FieldDeletedAt:
  8635. v, ok := value.(time.Time)
  8636. if !ok {
  8637. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8638. }
  8639. m.SetDeletedAt(v)
  8640. return nil
  8641. case chatrecords.FieldContent:
  8642. v, ok := value.(string)
  8643. if !ok {
  8644. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8645. }
  8646. m.SetContent(v)
  8647. return nil
  8648. case chatrecords.FieldContentType:
  8649. v, ok := value.(uint8)
  8650. if !ok {
  8651. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8652. }
  8653. m.SetContentType(v)
  8654. return nil
  8655. case chatrecords.FieldSessionID:
  8656. v, ok := value.(uint64)
  8657. if !ok {
  8658. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8659. }
  8660. m.SetSessionID(v)
  8661. return nil
  8662. case chatrecords.FieldUserID:
  8663. v, ok := value.(uint64)
  8664. if !ok {
  8665. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8666. }
  8667. m.SetUserID(v)
  8668. return nil
  8669. case chatrecords.FieldBotID:
  8670. v, ok := value.(uint64)
  8671. if !ok {
  8672. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8673. }
  8674. m.SetBotID(v)
  8675. return nil
  8676. case chatrecords.FieldBotType:
  8677. v, ok := value.(uint8)
  8678. if !ok {
  8679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8680. }
  8681. m.SetBotType(v)
  8682. return nil
  8683. }
  8684. return fmt.Errorf("unknown ChatRecords field %s", name)
  8685. }
  8686. // AddedFields returns all numeric fields that were incremented/decremented during
  8687. // this mutation.
  8688. func (m *ChatRecordsMutation) AddedFields() []string {
  8689. var fields []string
  8690. if m.addcontent_type != nil {
  8691. fields = append(fields, chatrecords.FieldContentType)
  8692. }
  8693. if m.addsession_id != nil {
  8694. fields = append(fields, chatrecords.FieldSessionID)
  8695. }
  8696. if m.adduser_id != nil {
  8697. fields = append(fields, chatrecords.FieldUserID)
  8698. }
  8699. if m.addbot_id != nil {
  8700. fields = append(fields, chatrecords.FieldBotID)
  8701. }
  8702. if m.addbot_type != nil {
  8703. fields = append(fields, chatrecords.FieldBotType)
  8704. }
  8705. return fields
  8706. }
  8707. // AddedField returns the numeric value that was incremented/decremented on a field
  8708. // with the given name. The second boolean return value indicates that this field
  8709. // was not set, or was not defined in the schema.
  8710. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  8711. switch name {
  8712. case chatrecords.FieldContentType:
  8713. return m.AddedContentType()
  8714. case chatrecords.FieldSessionID:
  8715. return m.AddedSessionID()
  8716. case chatrecords.FieldUserID:
  8717. return m.AddedUserID()
  8718. case chatrecords.FieldBotID:
  8719. return m.AddedBotID()
  8720. case chatrecords.FieldBotType:
  8721. return m.AddedBotType()
  8722. }
  8723. return nil, false
  8724. }
  8725. // AddField adds the value to the field with the given name. It returns an error if
  8726. // the field is not defined in the schema, or if the type mismatched the field
  8727. // type.
  8728. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  8729. switch name {
  8730. case chatrecords.FieldContentType:
  8731. v, ok := value.(int8)
  8732. if !ok {
  8733. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8734. }
  8735. m.AddContentType(v)
  8736. return nil
  8737. case chatrecords.FieldSessionID:
  8738. v, ok := value.(int64)
  8739. if !ok {
  8740. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8741. }
  8742. m.AddSessionID(v)
  8743. return nil
  8744. case chatrecords.FieldUserID:
  8745. v, ok := value.(int64)
  8746. if !ok {
  8747. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8748. }
  8749. m.AddUserID(v)
  8750. return nil
  8751. case chatrecords.FieldBotID:
  8752. v, ok := value.(int64)
  8753. if !ok {
  8754. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8755. }
  8756. m.AddBotID(v)
  8757. return nil
  8758. case chatrecords.FieldBotType:
  8759. v, ok := value.(int8)
  8760. if !ok {
  8761. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8762. }
  8763. m.AddBotType(v)
  8764. return nil
  8765. }
  8766. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  8767. }
  8768. // ClearedFields returns all nullable fields that were cleared during this
  8769. // mutation.
  8770. func (m *ChatRecordsMutation) ClearedFields() []string {
  8771. var fields []string
  8772. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  8773. fields = append(fields, chatrecords.FieldDeletedAt)
  8774. }
  8775. return fields
  8776. }
  8777. // FieldCleared returns a boolean indicating if a field with the given name was
  8778. // cleared in this mutation.
  8779. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  8780. _, ok := m.clearedFields[name]
  8781. return ok
  8782. }
  8783. // ClearField clears the value of the field with the given name. It returns an
  8784. // error if the field is not defined in the schema.
  8785. func (m *ChatRecordsMutation) ClearField(name string) error {
  8786. switch name {
  8787. case chatrecords.FieldDeletedAt:
  8788. m.ClearDeletedAt()
  8789. return nil
  8790. }
  8791. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  8792. }
  8793. // ResetField resets all changes in the mutation for the field with the given name.
  8794. // It returns an error if the field is not defined in the schema.
  8795. func (m *ChatRecordsMutation) ResetField(name string) error {
  8796. switch name {
  8797. case chatrecords.FieldCreatedAt:
  8798. m.ResetCreatedAt()
  8799. return nil
  8800. case chatrecords.FieldUpdatedAt:
  8801. m.ResetUpdatedAt()
  8802. return nil
  8803. case chatrecords.FieldDeletedAt:
  8804. m.ResetDeletedAt()
  8805. return nil
  8806. case chatrecords.FieldContent:
  8807. m.ResetContent()
  8808. return nil
  8809. case chatrecords.FieldContentType:
  8810. m.ResetContentType()
  8811. return nil
  8812. case chatrecords.FieldSessionID:
  8813. m.ResetSessionID()
  8814. return nil
  8815. case chatrecords.FieldUserID:
  8816. m.ResetUserID()
  8817. return nil
  8818. case chatrecords.FieldBotID:
  8819. m.ResetBotID()
  8820. return nil
  8821. case chatrecords.FieldBotType:
  8822. m.ResetBotType()
  8823. return nil
  8824. }
  8825. return fmt.Errorf("unknown ChatRecords field %s", name)
  8826. }
  8827. // AddedEdges returns all edge names that were set/added in this mutation.
  8828. func (m *ChatRecordsMutation) AddedEdges() []string {
  8829. edges := make([]string, 0, 0)
  8830. return edges
  8831. }
  8832. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8833. // name in this mutation.
  8834. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  8835. return nil
  8836. }
  8837. // RemovedEdges returns all edge names that were removed in this mutation.
  8838. func (m *ChatRecordsMutation) RemovedEdges() []string {
  8839. edges := make([]string, 0, 0)
  8840. return edges
  8841. }
  8842. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8843. // the given name in this mutation.
  8844. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  8845. return nil
  8846. }
  8847. // ClearedEdges returns all edge names that were cleared in this mutation.
  8848. func (m *ChatRecordsMutation) ClearedEdges() []string {
  8849. edges := make([]string, 0, 0)
  8850. return edges
  8851. }
  8852. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8853. // was cleared in this mutation.
  8854. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  8855. return false
  8856. }
  8857. // ClearEdge clears the value of the edge with the given name. It returns an error
  8858. // if that edge is not defined in the schema.
  8859. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  8860. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  8861. }
  8862. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8863. // It returns an error if the edge is not defined in the schema.
  8864. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  8865. return fmt.Errorf("unknown ChatRecords edge %s", name)
  8866. }
  8867. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  8868. type ChatSessionMutation struct {
  8869. config
  8870. op Op
  8871. typ string
  8872. id *uint64
  8873. created_at *time.Time
  8874. updated_at *time.Time
  8875. deleted_at *time.Time
  8876. name *string
  8877. user_id *uint64
  8878. adduser_id *int64
  8879. bot_id *uint64
  8880. addbot_id *int64
  8881. bot_type *uint8
  8882. addbot_type *int8
  8883. clearedFields map[string]struct{}
  8884. done bool
  8885. oldValue func(context.Context) (*ChatSession, error)
  8886. predicates []predicate.ChatSession
  8887. }
  8888. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  8889. // chatsessionOption allows management of the mutation configuration using functional options.
  8890. type chatsessionOption func(*ChatSessionMutation)
  8891. // newChatSessionMutation creates new mutation for the ChatSession entity.
  8892. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  8893. m := &ChatSessionMutation{
  8894. config: c,
  8895. op: op,
  8896. typ: TypeChatSession,
  8897. clearedFields: make(map[string]struct{}),
  8898. }
  8899. for _, opt := range opts {
  8900. opt(m)
  8901. }
  8902. return m
  8903. }
  8904. // withChatSessionID sets the ID field of the mutation.
  8905. func withChatSessionID(id uint64) chatsessionOption {
  8906. return func(m *ChatSessionMutation) {
  8907. var (
  8908. err error
  8909. once sync.Once
  8910. value *ChatSession
  8911. )
  8912. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  8913. once.Do(func() {
  8914. if m.done {
  8915. err = errors.New("querying old values post mutation is not allowed")
  8916. } else {
  8917. value, err = m.Client().ChatSession.Get(ctx, id)
  8918. }
  8919. })
  8920. return value, err
  8921. }
  8922. m.id = &id
  8923. }
  8924. }
  8925. // withChatSession sets the old ChatSession of the mutation.
  8926. func withChatSession(node *ChatSession) chatsessionOption {
  8927. return func(m *ChatSessionMutation) {
  8928. m.oldValue = func(context.Context) (*ChatSession, error) {
  8929. return node, nil
  8930. }
  8931. m.id = &node.ID
  8932. }
  8933. }
  8934. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8935. // executed in a transaction (ent.Tx), a transactional client is returned.
  8936. func (m ChatSessionMutation) Client() *Client {
  8937. client := &Client{config: m.config}
  8938. client.init()
  8939. return client
  8940. }
  8941. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8942. // it returns an error otherwise.
  8943. func (m ChatSessionMutation) Tx() (*Tx, error) {
  8944. if _, ok := m.driver.(*txDriver); !ok {
  8945. return nil, errors.New("ent: mutation is not running in a transaction")
  8946. }
  8947. tx := &Tx{config: m.config}
  8948. tx.init()
  8949. return tx, nil
  8950. }
  8951. // SetID sets the value of the id field. Note that this
  8952. // operation is only accepted on creation of ChatSession entities.
  8953. func (m *ChatSessionMutation) SetID(id uint64) {
  8954. m.id = &id
  8955. }
  8956. // ID returns the ID value in the mutation. Note that the ID is only available
  8957. // if it was provided to the builder or after it was returned from the database.
  8958. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  8959. if m.id == nil {
  8960. return
  8961. }
  8962. return *m.id, true
  8963. }
  8964. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8965. // That means, if the mutation is applied within a transaction with an isolation level such
  8966. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8967. // or updated by the mutation.
  8968. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  8969. switch {
  8970. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8971. id, exists := m.ID()
  8972. if exists {
  8973. return []uint64{id}, nil
  8974. }
  8975. fallthrough
  8976. case m.op.Is(OpUpdate | OpDelete):
  8977. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  8978. default:
  8979. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8980. }
  8981. }
  8982. // SetCreatedAt sets the "created_at" field.
  8983. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  8984. m.created_at = &t
  8985. }
  8986. // CreatedAt returns the value of the "created_at" field in the mutation.
  8987. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  8988. v := m.created_at
  8989. if v == nil {
  8990. return
  8991. }
  8992. return *v, true
  8993. }
  8994. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  8995. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8996. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8997. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8998. if !m.op.Is(OpUpdateOne) {
  8999. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9000. }
  9001. if m.id == nil || m.oldValue == nil {
  9002. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9003. }
  9004. oldValue, err := m.oldValue(ctx)
  9005. if err != nil {
  9006. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9007. }
  9008. return oldValue.CreatedAt, nil
  9009. }
  9010. // ResetCreatedAt resets all changes to the "created_at" field.
  9011. func (m *ChatSessionMutation) ResetCreatedAt() {
  9012. m.created_at = nil
  9013. }
  9014. // SetUpdatedAt sets the "updated_at" field.
  9015. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  9016. m.updated_at = &t
  9017. }
  9018. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9019. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  9020. v := m.updated_at
  9021. if v == nil {
  9022. return
  9023. }
  9024. return *v, true
  9025. }
  9026. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  9027. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9028. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9029. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9030. if !m.op.Is(OpUpdateOne) {
  9031. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9032. }
  9033. if m.id == nil || m.oldValue == nil {
  9034. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9035. }
  9036. oldValue, err := m.oldValue(ctx)
  9037. if err != nil {
  9038. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9039. }
  9040. return oldValue.UpdatedAt, nil
  9041. }
  9042. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9043. func (m *ChatSessionMutation) ResetUpdatedAt() {
  9044. m.updated_at = nil
  9045. }
  9046. // SetDeletedAt sets the "deleted_at" field.
  9047. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  9048. m.deleted_at = &t
  9049. }
  9050. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9051. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  9052. v := m.deleted_at
  9053. if v == nil {
  9054. return
  9055. }
  9056. return *v, true
  9057. }
  9058. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  9059. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9060. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9061. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9062. if !m.op.Is(OpUpdateOne) {
  9063. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9064. }
  9065. if m.id == nil || m.oldValue == nil {
  9066. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9067. }
  9068. oldValue, err := m.oldValue(ctx)
  9069. if err != nil {
  9070. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9071. }
  9072. return oldValue.DeletedAt, nil
  9073. }
  9074. // ClearDeletedAt clears the value of the "deleted_at" field.
  9075. func (m *ChatSessionMutation) ClearDeletedAt() {
  9076. m.deleted_at = nil
  9077. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  9078. }
  9079. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9080. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  9081. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  9082. return ok
  9083. }
  9084. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9085. func (m *ChatSessionMutation) ResetDeletedAt() {
  9086. m.deleted_at = nil
  9087. delete(m.clearedFields, chatsession.FieldDeletedAt)
  9088. }
  9089. // SetName sets the "name" field.
  9090. func (m *ChatSessionMutation) SetName(s string) {
  9091. m.name = &s
  9092. }
  9093. // Name returns the value of the "name" field in the mutation.
  9094. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  9095. v := m.name
  9096. if v == nil {
  9097. return
  9098. }
  9099. return *v, true
  9100. }
  9101. // OldName returns the old "name" field's value of the ChatSession entity.
  9102. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9103. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9104. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  9105. if !m.op.Is(OpUpdateOne) {
  9106. return v, errors.New("OldName is only allowed on UpdateOne operations")
  9107. }
  9108. if m.id == nil || m.oldValue == nil {
  9109. return v, errors.New("OldName requires an ID field in the mutation")
  9110. }
  9111. oldValue, err := m.oldValue(ctx)
  9112. if err != nil {
  9113. return v, fmt.Errorf("querying old value for OldName: %w", err)
  9114. }
  9115. return oldValue.Name, nil
  9116. }
  9117. // ResetName resets all changes to the "name" field.
  9118. func (m *ChatSessionMutation) ResetName() {
  9119. m.name = nil
  9120. }
  9121. // SetUserID sets the "user_id" field.
  9122. func (m *ChatSessionMutation) SetUserID(u uint64) {
  9123. m.user_id = &u
  9124. m.adduser_id = nil
  9125. }
  9126. // UserID returns the value of the "user_id" field in the mutation.
  9127. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  9128. v := m.user_id
  9129. if v == nil {
  9130. return
  9131. }
  9132. return *v, true
  9133. }
  9134. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  9135. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9136. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9137. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  9138. if !m.op.Is(OpUpdateOne) {
  9139. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  9140. }
  9141. if m.id == nil || m.oldValue == nil {
  9142. return v, errors.New("OldUserID requires an ID field in the mutation")
  9143. }
  9144. oldValue, err := m.oldValue(ctx)
  9145. if err != nil {
  9146. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  9147. }
  9148. return oldValue.UserID, nil
  9149. }
  9150. // AddUserID adds u to the "user_id" field.
  9151. func (m *ChatSessionMutation) AddUserID(u int64) {
  9152. if m.adduser_id != nil {
  9153. *m.adduser_id += u
  9154. } else {
  9155. m.adduser_id = &u
  9156. }
  9157. }
  9158. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  9159. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  9160. v := m.adduser_id
  9161. if v == nil {
  9162. return
  9163. }
  9164. return *v, true
  9165. }
  9166. // ResetUserID resets all changes to the "user_id" field.
  9167. func (m *ChatSessionMutation) ResetUserID() {
  9168. m.user_id = nil
  9169. m.adduser_id = nil
  9170. }
  9171. // SetBotID sets the "bot_id" field.
  9172. func (m *ChatSessionMutation) SetBotID(u uint64) {
  9173. m.bot_id = &u
  9174. m.addbot_id = nil
  9175. }
  9176. // BotID returns the value of the "bot_id" field in the mutation.
  9177. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  9178. v := m.bot_id
  9179. if v == nil {
  9180. return
  9181. }
  9182. return *v, true
  9183. }
  9184. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  9185. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9186. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9187. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  9188. if !m.op.Is(OpUpdateOne) {
  9189. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  9190. }
  9191. if m.id == nil || m.oldValue == nil {
  9192. return v, errors.New("OldBotID requires an ID field in the mutation")
  9193. }
  9194. oldValue, err := m.oldValue(ctx)
  9195. if err != nil {
  9196. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  9197. }
  9198. return oldValue.BotID, nil
  9199. }
  9200. // AddBotID adds u to the "bot_id" field.
  9201. func (m *ChatSessionMutation) AddBotID(u int64) {
  9202. if m.addbot_id != nil {
  9203. *m.addbot_id += u
  9204. } else {
  9205. m.addbot_id = &u
  9206. }
  9207. }
  9208. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  9209. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  9210. v := m.addbot_id
  9211. if v == nil {
  9212. return
  9213. }
  9214. return *v, true
  9215. }
  9216. // ResetBotID resets all changes to the "bot_id" field.
  9217. func (m *ChatSessionMutation) ResetBotID() {
  9218. m.bot_id = nil
  9219. m.addbot_id = nil
  9220. }
  9221. // SetBotType sets the "bot_type" field.
  9222. func (m *ChatSessionMutation) SetBotType(u uint8) {
  9223. m.bot_type = &u
  9224. m.addbot_type = nil
  9225. }
  9226. // BotType returns the value of the "bot_type" field in the mutation.
  9227. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  9228. v := m.bot_type
  9229. if v == nil {
  9230. return
  9231. }
  9232. return *v, true
  9233. }
  9234. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  9235. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9236. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9237. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  9238. if !m.op.Is(OpUpdateOne) {
  9239. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  9240. }
  9241. if m.id == nil || m.oldValue == nil {
  9242. return v, errors.New("OldBotType requires an ID field in the mutation")
  9243. }
  9244. oldValue, err := m.oldValue(ctx)
  9245. if err != nil {
  9246. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  9247. }
  9248. return oldValue.BotType, nil
  9249. }
  9250. // AddBotType adds u to the "bot_type" field.
  9251. func (m *ChatSessionMutation) AddBotType(u int8) {
  9252. if m.addbot_type != nil {
  9253. *m.addbot_type += u
  9254. } else {
  9255. m.addbot_type = &u
  9256. }
  9257. }
  9258. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  9259. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  9260. v := m.addbot_type
  9261. if v == nil {
  9262. return
  9263. }
  9264. return *v, true
  9265. }
  9266. // ResetBotType resets all changes to the "bot_type" field.
  9267. func (m *ChatSessionMutation) ResetBotType() {
  9268. m.bot_type = nil
  9269. m.addbot_type = nil
  9270. }
  9271. // Where appends a list predicates to the ChatSessionMutation builder.
  9272. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  9273. m.predicates = append(m.predicates, ps...)
  9274. }
  9275. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  9276. // users can use type-assertion to append predicates that do not depend on any generated package.
  9277. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  9278. p := make([]predicate.ChatSession, len(ps))
  9279. for i := range ps {
  9280. p[i] = ps[i]
  9281. }
  9282. m.Where(p...)
  9283. }
  9284. // Op returns the operation name.
  9285. func (m *ChatSessionMutation) Op() Op {
  9286. return m.op
  9287. }
  9288. // SetOp allows setting the mutation operation.
  9289. func (m *ChatSessionMutation) SetOp(op Op) {
  9290. m.op = op
  9291. }
  9292. // Type returns the node type of this mutation (ChatSession).
  9293. func (m *ChatSessionMutation) Type() string {
  9294. return m.typ
  9295. }
  9296. // Fields returns all fields that were changed during this mutation. Note that in
  9297. // order to get all numeric fields that were incremented/decremented, call
  9298. // AddedFields().
  9299. func (m *ChatSessionMutation) Fields() []string {
  9300. fields := make([]string, 0, 7)
  9301. if m.created_at != nil {
  9302. fields = append(fields, chatsession.FieldCreatedAt)
  9303. }
  9304. if m.updated_at != nil {
  9305. fields = append(fields, chatsession.FieldUpdatedAt)
  9306. }
  9307. if m.deleted_at != nil {
  9308. fields = append(fields, chatsession.FieldDeletedAt)
  9309. }
  9310. if m.name != nil {
  9311. fields = append(fields, chatsession.FieldName)
  9312. }
  9313. if m.user_id != nil {
  9314. fields = append(fields, chatsession.FieldUserID)
  9315. }
  9316. if m.bot_id != nil {
  9317. fields = append(fields, chatsession.FieldBotID)
  9318. }
  9319. if m.bot_type != nil {
  9320. fields = append(fields, chatsession.FieldBotType)
  9321. }
  9322. return fields
  9323. }
  9324. // Field returns the value of a field with the given name. The second boolean
  9325. // return value indicates that this field was not set, or was not defined in the
  9326. // schema.
  9327. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  9328. switch name {
  9329. case chatsession.FieldCreatedAt:
  9330. return m.CreatedAt()
  9331. case chatsession.FieldUpdatedAt:
  9332. return m.UpdatedAt()
  9333. case chatsession.FieldDeletedAt:
  9334. return m.DeletedAt()
  9335. case chatsession.FieldName:
  9336. return m.Name()
  9337. case chatsession.FieldUserID:
  9338. return m.UserID()
  9339. case chatsession.FieldBotID:
  9340. return m.BotID()
  9341. case chatsession.FieldBotType:
  9342. return m.BotType()
  9343. }
  9344. return nil, false
  9345. }
  9346. // OldField returns the old value of the field from the database. An error is
  9347. // returned if the mutation operation is not UpdateOne, or the query to the
  9348. // database failed.
  9349. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9350. switch name {
  9351. case chatsession.FieldCreatedAt:
  9352. return m.OldCreatedAt(ctx)
  9353. case chatsession.FieldUpdatedAt:
  9354. return m.OldUpdatedAt(ctx)
  9355. case chatsession.FieldDeletedAt:
  9356. return m.OldDeletedAt(ctx)
  9357. case chatsession.FieldName:
  9358. return m.OldName(ctx)
  9359. case chatsession.FieldUserID:
  9360. return m.OldUserID(ctx)
  9361. case chatsession.FieldBotID:
  9362. return m.OldBotID(ctx)
  9363. case chatsession.FieldBotType:
  9364. return m.OldBotType(ctx)
  9365. }
  9366. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  9367. }
  9368. // SetField sets the value of a field with the given name. It returns an error if
  9369. // the field is not defined in the schema, or if the type mismatched the field
  9370. // type.
  9371. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  9372. switch name {
  9373. case chatsession.FieldCreatedAt:
  9374. v, ok := value.(time.Time)
  9375. if !ok {
  9376. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9377. }
  9378. m.SetCreatedAt(v)
  9379. return nil
  9380. case chatsession.FieldUpdatedAt:
  9381. v, ok := value.(time.Time)
  9382. if !ok {
  9383. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9384. }
  9385. m.SetUpdatedAt(v)
  9386. return nil
  9387. case chatsession.FieldDeletedAt:
  9388. v, ok := value.(time.Time)
  9389. if !ok {
  9390. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9391. }
  9392. m.SetDeletedAt(v)
  9393. return nil
  9394. case chatsession.FieldName:
  9395. v, ok := value.(string)
  9396. if !ok {
  9397. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9398. }
  9399. m.SetName(v)
  9400. return nil
  9401. case chatsession.FieldUserID:
  9402. v, ok := value.(uint64)
  9403. if !ok {
  9404. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9405. }
  9406. m.SetUserID(v)
  9407. return nil
  9408. case chatsession.FieldBotID:
  9409. v, ok := value.(uint64)
  9410. if !ok {
  9411. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9412. }
  9413. m.SetBotID(v)
  9414. return nil
  9415. case chatsession.FieldBotType:
  9416. v, ok := value.(uint8)
  9417. if !ok {
  9418. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9419. }
  9420. m.SetBotType(v)
  9421. return nil
  9422. }
  9423. return fmt.Errorf("unknown ChatSession field %s", name)
  9424. }
  9425. // AddedFields returns all numeric fields that were incremented/decremented during
  9426. // this mutation.
  9427. func (m *ChatSessionMutation) AddedFields() []string {
  9428. var fields []string
  9429. if m.adduser_id != nil {
  9430. fields = append(fields, chatsession.FieldUserID)
  9431. }
  9432. if m.addbot_id != nil {
  9433. fields = append(fields, chatsession.FieldBotID)
  9434. }
  9435. if m.addbot_type != nil {
  9436. fields = append(fields, chatsession.FieldBotType)
  9437. }
  9438. return fields
  9439. }
  9440. // AddedField returns the numeric value that was incremented/decremented on a field
  9441. // with the given name. The second boolean return value indicates that this field
  9442. // was not set, or was not defined in the schema.
  9443. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  9444. switch name {
  9445. case chatsession.FieldUserID:
  9446. return m.AddedUserID()
  9447. case chatsession.FieldBotID:
  9448. return m.AddedBotID()
  9449. case chatsession.FieldBotType:
  9450. return m.AddedBotType()
  9451. }
  9452. return nil, false
  9453. }
  9454. // AddField adds the value to the field with the given name. It returns an error if
  9455. // the field is not defined in the schema, or if the type mismatched the field
  9456. // type.
  9457. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  9458. switch name {
  9459. case chatsession.FieldUserID:
  9460. v, ok := value.(int64)
  9461. if !ok {
  9462. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9463. }
  9464. m.AddUserID(v)
  9465. return nil
  9466. case chatsession.FieldBotID:
  9467. v, ok := value.(int64)
  9468. if !ok {
  9469. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9470. }
  9471. m.AddBotID(v)
  9472. return nil
  9473. case chatsession.FieldBotType:
  9474. v, ok := value.(int8)
  9475. if !ok {
  9476. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9477. }
  9478. m.AddBotType(v)
  9479. return nil
  9480. }
  9481. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  9482. }
  9483. // ClearedFields returns all nullable fields that were cleared during this
  9484. // mutation.
  9485. func (m *ChatSessionMutation) ClearedFields() []string {
  9486. var fields []string
  9487. if m.FieldCleared(chatsession.FieldDeletedAt) {
  9488. fields = append(fields, chatsession.FieldDeletedAt)
  9489. }
  9490. return fields
  9491. }
  9492. // FieldCleared returns a boolean indicating if a field with the given name was
  9493. // cleared in this mutation.
  9494. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  9495. _, ok := m.clearedFields[name]
  9496. return ok
  9497. }
  9498. // ClearField clears the value of the field with the given name. It returns an
  9499. // error if the field is not defined in the schema.
  9500. func (m *ChatSessionMutation) ClearField(name string) error {
  9501. switch name {
  9502. case chatsession.FieldDeletedAt:
  9503. m.ClearDeletedAt()
  9504. return nil
  9505. }
  9506. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  9507. }
  9508. // ResetField resets all changes in the mutation for the field with the given name.
  9509. // It returns an error if the field is not defined in the schema.
  9510. func (m *ChatSessionMutation) ResetField(name string) error {
  9511. switch name {
  9512. case chatsession.FieldCreatedAt:
  9513. m.ResetCreatedAt()
  9514. return nil
  9515. case chatsession.FieldUpdatedAt:
  9516. m.ResetUpdatedAt()
  9517. return nil
  9518. case chatsession.FieldDeletedAt:
  9519. m.ResetDeletedAt()
  9520. return nil
  9521. case chatsession.FieldName:
  9522. m.ResetName()
  9523. return nil
  9524. case chatsession.FieldUserID:
  9525. m.ResetUserID()
  9526. return nil
  9527. case chatsession.FieldBotID:
  9528. m.ResetBotID()
  9529. return nil
  9530. case chatsession.FieldBotType:
  9531. m.ResetBotType()
  9532. return nil
  9533. }
  9534. return fmt.Errorf("unknown ChatSession field %s", name)
  9535. }
  9536. // AddedEdges returns all edge names that were set/added in this mutation.
  9537. func (m *ChatSessionMutation) AddedEdges() []string {
  9538. edges := make([]string, 0, 0)
  9539. return edges
  9540. }
  9541. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9542. // name in this mutation.
  9543. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  9544. return nil
  9545. }
  9546. // RemovedEdges returns all edge names that were removed in this mutation.
  9547. func (m *ChatSessionMutation) RemovedEdges() []string {
  9548. edges := make([]string, 0, 0)
  9549. return edges
  9550. }
  9551. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9552. // the given name in this mutation.
  9553. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  9554. return nil
  9555. }
  9556. // ClearedEdges returns all edge names that were cleared in this mutation.
  9557. func (m *ChatSessionMutation) ClearedEdges() []string {
  9558. edges := make([]string, 0, 0)
  9559. return edges
  9560. }
  9561. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9562. // was cleared in this mutation.
  9563. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  9564. return false
  9565. }
  9566. // ClearEdge clears the value of the edge with the given name. It returns an error
  9567. // if that edge is not defined in the schema.
  9568. func (m *ChatSessionMutation) ClearEdge(name string) error {
  9569. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  9570. }
  9571. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9572. // It returns an error if the edge is not defined in the schema.
  9573. func (m *ChatSessionMutation) ResetEdge(name string) error {
  9574. return fmt.Errorf("unknown ChatSession edge %s", name)
  9575. }
  9576. // CompapiAsynctaskMutation represents an operation that mutates the CompapiAsynctask nodes in the graph.
  9577. type CompapiAsynctaskMutation struct {
  9578. config
  9579. op Op
  9580. typ string
  9581. id *uint64
  9582. created_at *time.Time
  9583. updated_at *time.Time
  9584. auth_token *string
  9585. event_type *string
  9586. chat_id *string
  9587. response_chat_item_id *string
  9588. organization_id *uint64
  9589. addorganization_id *int64
  9590. openai_base *string
  9591. openai_key *string
  9592. request_raw *string
  9593. response_raw *string
  9594. callback_url *string
  9595. callback_response_raw *string
  9596. model *string
  9597. task_status *int8
  9598. addtask_status *int8
  9599. retry_count *int8
  9600. addretry_count *int8
  9601. last_error *string
  9602. clearedFields map[string]struct{}
  9603. done bool
  9604. oldValue func(context.Context) (*CompapiAsynctask, error)
  9605. predicates []predicate.CompapiAsynctask
  9606. }
  9607. var _ ent.Mutation = (*CompapiAsynctaskMutation)(nil)
  9608. // compapiasynctaskOption allows management of the mutation configuration using functional options.
  9609. type compapiasynctaskOption func(*CompapiAsynctaskMutation)
  9610. // newCompapiAsynctaskMutation creates new mutation for the CompapiAsynctask entity.
  9611. func newCompapiAsynctaskMutation(c config, op Op, opts ...compapiasynctaskOption) *CompapiAsynctaskMutation {
  9612. m := &CompapiAsynctaskMutation{
  9613. config: c,
  9614. op: op,
  9615. typ: TypeCompapiAsynctask,
  9616. clearedFields: make(map[string]struct{}),
  9617. }
  9618. for _, opt := range opts {
  9619. opt(m)
  9620. }
  9621. return m
  9622. }
  9623. // withCompapiAsynctaskID sets the ID field of the mutation.
  9624. func withCompapiAsynctaskID(id uint64) compapiasynctaskOption {
  9625. return func(m *CompapiAsynctaskMutation) {
  9626. var (
  9627. err error
  9628. once sync.Once
  9629. value *CompapiAsynctask
  9630. )
  9631. m.oldValue = func(ctx context.Context) (*CompapiAsynctask, error) {
  9632. once.Do(func() {
  9633. if m.done {
  9634. err = errors.New("querying old values post mutation is not allowed")
  9635. } else {
  9636. value, err = m.Client().CompapiAsynctask.Get(ctx, id)
  9637. }
  9638. })
  9639. return value, err
  9640. }
  9641. m.id = &id
  9642. }
  9643. }
  9644. // withCompapiAsynctask sets the old CompapiAsynctask of the mutation.
  9645. func withCompapiAsynctask(node *CompapiAsynctask) compapiasynctaskOption {
  9646. return func(m *CompapiAsynctaskMutation) {
  9647. m.oldValue = func(context.Context) (*CompapiAsynctask, error) {
  9648. return node, nil
  9649. }
  9650. m.id = &node.ID
  9651. }
  9652. }
  9653. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9654. // executed in a transaction (ent.Tx), a transactional client is returned.
  9655. func (m CompapiAsynctaskMutation) Client() *Client {
  9656. client := &Client{config: m.config}
  9657. client.init()
  9658. return client
  9659. }
  9660. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9661. // it returns an error otherwise.
  9662. func (m CompapiAsynctaskMutation) Tx() (*Tx, error) {
  9663. if _, ok := m.driver.(*txDriver); !ok {
  9664. return nil, errors.New("ent: mutation is not running in a transaction")
  9665. }
  9666. tx := &Tx{config: m.config}
  9667. tx.init()
  9668. return tx, nil
  9669. }
  9670. // SetID sets the value of the id field. Note that this
  9671. // operation is only accepted on creation of CompapiAsynctask entities.
  9672. func (m *CompapiAsynctaskMutation) SetID(id uint64) {
  9673. m.id = &id
  9674. }
  9675. // ID returns the ID value in the mutation. Note that the ID is only available
  9676. // if it was provided to the builder or after it was returned from the database.
  9677. func (m *CompapiAsynctaskMutation) ID() (id uint64, exists bool) {
  9678. if m.id == nil {
  9679. return
  9680. }
  9681. return *m.id, true
  9682. }
  9683. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9684. // That means, if the mutation is applied within a transaction with an isolation level such
  9685. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9686. // or updated by the mutation.
  9687. func (m *CompapiAsynctaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  9688. switch {
  9689. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9690. id, exists := m.ID()
  9691. if exists {
  9692. return []uint64{id}, nil
  9693. }
  9694. fallthrough
  9695. case m.op.Is(OpUpdate | OpDelete):
  9696. return m.Client().CompapiAsynctask.Query().Where(m.predicates...).IDs(ctx)
  9697. default:
  9698. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9699. }
  9700. }
  9701. // SetCreatedAt sets the "created_at" field.
  9702. func (m *CompapiAsynctaskMutation) SetCreatedAt(t time.Time) {
  9703. m.created_at = &t
  9704. }
  9705. // CreatedAt returns the value of the "created_at" field in the mutation.
  9706. func (m *CompapiAsynctaskMutation) CreatedAt() (r time.Time, exists bool) {
  9707. v := m.created_at
  9708. if v == nil {
  9709. return
  9710. }
  9711. return *v, true
  9712. }
  9713. // OldCreatedAt returns the old "created_at" field's value of the CompapiAsynctask entity.
  9714. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9715. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9716. func (m *CompapiAsynctaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9717. if !m.op.Is(OpUpdateOne) {
  9718. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9719. }
  9720. if m.id == nil || m.oldValue == nil {
  9721. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9722. }
  9723. oldValue, err := m.oldValue(ctx)
  9724. if err != nil {
  9725. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9726. }
  9727. return oldValue.CreatedAt, nil
  9728. }
  9729. // ResetCreatedAt resets all changes to the "created_at" field.
  9730. func (m *CompapiAsynctaskMutation) ResetCreatedAt() {
  9731. m.created_at = nil
  9732. }
  9733. // SetUpdatedAt sets the "updated_at" field.
  9734. func (m *CompapiAsynctaskMutation) SetUpdatedAt(t time.Time) {
  9735. m.updated_at = &t
  9736. }
  9737. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9738. func (m *CompapiAsynctaskMutation) UpdatedAt() (r time.Time, exists bool) {
  9739. v := m.updated_at
  9740. if v == nil {
  9741. return
  9742. }
  9743. return *v, true
  9744. }
  9745. // OldUpdatedAt returns the old "updated_at" field's value of the CompapiAsynctask entity.
  9746. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9747. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9748. func (m *CompapiAsynctaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9749. if !m.op.Is(OpUpdateOne) {
  9750. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9751. }
  9752. if m.id == nil || m.oldValue == nil {
  9753. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9754. }
  9755. oldValue, err := m.oldValue(ctx)
  9756. if err != nil {
  9757. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9758. }
  9759. return oldValue.UpdatedAt, nil
  9760. }
  9761. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9762. func (m *CompapiAsynctaskMutation) ResetUpdatedAt() {
  9763. m.updated_at = nil
  9764. }
  9765. // SetAuthToken sets the "auth_token" field.
  9766. func (m *CompapiAsynctaskMutation) SetAuthToken(s string) {
  9767. m.auth_token = &s
  9768. }
  9769. // AuthToken returns the value of the "auth_token" field in the mutation.
  9770. func (m *CompapiAsynctaskMutation) AuthToken() (r string, exists bool) {
  9771. v := m.auth_token
  9772. if v == nil {
  9773. return
  9774. }
  9775. return *v, true
  9776. }
  9777. // OldAuthToken returns the old "auth_token" field's value of the CompapiAsynctask entity.
  9778. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9780. func (m *CompapiAsynctaskMutation) OldAuthToken(ctx context.Context) (v string, err error) {
  9781. if !m.op.Is(OpUpdateOne) {
  9782. return v, errors.New("OldAuthToken is only allowed on UpdateOne operations")
  9783. }
  9784. if m.id == nil || m.oldValue == nil {
  9785. return v, errors.New("OldAuthToken requires an ID field in the mutation")
  9786. }
  9787. oldValue, err := m.oldValue(ctx)
  9788. if err != nil {
  9789. return v, fmt.Errorf("querying old value for OldAuthToken: %w", err)
  9790. }
  9791. return oldValue.AuthToken, nil
  9792. }
  9793. // ResetAuthToken resets all changes to the "auth_token" field.
  9794. func (m *CompapiAsynctaskMutation) ResetAuthToken() {
  9795. m.auth_token = nil
  9796. }
  9797. // SetEventType sets the "event_type" field.
  9798. func (m *CompapiAsynctaskMutation) SetEventType(s string) {
  9799. m.event_type = &s
  9800. }
  9801. // EventType returns the value of the "event_type" field in the mutation.
  9802. func (m *CompapiAsynctaskMutation) EventType() (r string, exists bool) {
  9803. v := m.event_type
  9804. if v == nil {
  9805. return
  9806. }
  9807. return *v, true
  9808. }
  9809. // OldEventType returns the old "event_type" field's value of the CompapiAsynctask entity.
  9810. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9811. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9812. func (m *CompapiAsynctaskMutation) OldEventType(ctx context.Context) (v string, err error) {
  9813. if !m.op.Is(OpUpdateOne) {
  9814. return v, errors.New("OldEventType is only allowed on UpdateOne operations")
  9815. }
  9816. if m.id == nil || m.oldValue == nil {
  9817. return v, errors.New("OldEventType requires an ID field in the mutation")
  9818. }
  9819. oldValue, err := m.oldValue(ctx)
  9820. if err != nil {
  9821. return v, fmt.Errorf("querying old value for OldEventType: %w", err)
  9822. }
  9823. return oldValue.EventType, nil
  9824. }
  9825. // ResetEventType resets all changes to the "event_type" field.
  9826. func (m *CompapiAsynctaskMutation) ResetEventType() {
  9827. m.event_type = nil
  9828. }
  9829. // SetChatID sets the "chat_id" field.
  9830. func (m *CompapiAsynctaskMutation) SetChatID(s string) {
  9831. m.chat_id = &s
  9832. }
  9833. // ChatID returns the value of the "chat_id" field in the mutation.
  9834. func (m *CompapiAsynctaskMutation) ChatID() (r string, exists bool) {
  9835. v := m.chat_id
  9836. if v == nil {
  9837. return
  9838. }
  9839. return *v, true
  9840. }
  9841. // OldChatID returns the old "chat_id" field's value of the CompapiAsynctask entity.
  9842. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9843. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9844. func (m *CompapiAsynctaskMutation) OldChatID(ctx context.Context) (v string, err error) {
  9845. if !m.op.Is(OpUpdateOne) {
  9846. return v, errors.New("OldChatID is only allowed on UpdateOne operations")
  9847. }
  9848. if m.id == nil || m.oldValue == nil {
  9849. return v, errors.New("OldChatID requires an ID field in the mutation")
  9850. }
  9851. oldValue, err := m.oldValue(ctx)
  9852. if err != nil {
  9853. return v, fmt.Errorf("querying old value for OldChatID: %w", err)
  9854. }
  9855. return oldValue.ChatID, nil
  9856. }
  9857. // ClearChatID clears the value of the "chat_id" field.
  9858. func (m *CompapiAsynctaskMutation) ClearChatID() {
  9859. m.chat_id = nil
  9860. m.clearedFields[compapiasynctask.FieldChatID] = struct{}{}
  9861. }
  9862. // ChatIDCleared returns if the "chat_id" field was cleared in this mutation.
  9863. func (m *CompapiAsynctaskMutation) ChatIDCleared() bool {
  9864. _, ok := m.clearedFields[compapiasynctask.FieldChatID]
  9865. return ok
  9866. }
  9867. // ResetChatID resets all changes to the "chat_id" field.
  9868. func (m *CompapiAsynctaskMutation) ResetChatID() {
  9869. m.chat_id = nil
  9870. delete(m.clearedFields, compapiasynctask.FieldChatID)
  9871. }
  9872. // SetResponseChatItemID sets the "response_chat_item_id" field.
  9873. func (m *CompapiAsynctaskMutation) SetResponseChatItemID(s string) {
  9874. m.response_chat_item_id = &s
  9875. }
  9876. // ResponseChatItemID returns the value of the "response_chat_item_id" field in the mutation.
  9877. func (m *CompapiAsynctaskMutation) ResponseChatItemID() (r string, exists bool) {
  9878. v := m.response_chat_item_id
  9879. if v == nil {
  9880. return
  9881. }
  9882. return *v, true
  9883. }
  9884. // OldResponseChatItemID returns the old "response_chat_item_id" field's value of the CompapiAsynctask entity.
  9885. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9886. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9887. func (m *CompapiAsynctaskMutation) OldResponseChatItemID(ctx context.Context) (v string, err error) {
  9888. if !m.op.Is(OpUpdateOne) {
  9889. return v, errors.New("OldResponseChatItemID is only allowed on UpdateOne operations")
  9890. }
  9891. if m.id == nil || m.oldValue == nil {
  9892. return v, errors.New("OldResponseChatItemID requires an ID field in the mutation")
  9893. }
  9894. oldValue, err := m.oldValue(ctx)
  9895. if err != nil {
  9896. return v, fmt.Errorf("querying old value for OldResponseChatItemID: %w", err)
  9897. }
  9898. return oldValue.ResponseChatItemID, nil
  9899. }
  9900. // ClearResponseChatItemID clears the value of the "response_chat_item_id" field.
  9901. func (m *CompapiAsynctaskMutation) ClearResponseChatItemID() {
  9902. m.response_chat_item_id = nil
  9903. m.clearedFields[compapiasynctask.FieldResponseChatItemID] = struct{}{}
  9904. }
  9905. // ResponseChatItemIDCleared returns if the "response_chat_item_id" field was cleared in this mutation.
  9906. func (m *CompapiAsynctaskMutation) ResponseChatItemIDCleared() bool {
  9907. _, ok := m.clearedFields[compapiasynctask.FieldResponseChatItemID]
  9908. return ok
  9909. }
  9910. // ResetResponseChatItemID resets all changes to the "response_chat_item_id" field.
  9911. func (m *CompapiAsynctaskMutation) ResetResponseChatItemID() {
  9912. m.response_chat_item_id = nil
  9913. delete(m.clearedFields, compapiasynctask.FieldResponseChatItemID)
  9914. }
  9915. // SetOrganizationID sets the "organization_id" field.
  9916. func (m *CompapiAsynctaskMutation) SetOrganizationID(u uint64) {
  9917. m.organization_id = &u
  9918. m.addorganization_id = nil
  9919. }
  9920. // OrganizationID returns the value of the "organization_id" field in the mutation.
  9921. func (m *CompapiAsynctaskMutation) OrganizationID() (r uint64, exists bool) {
  9922. v := m.organization_id
  9923. if v == nil {
  9924. return
  9925. }
  9926. return *v, true
  9927. }
  9928. // OldOrganizationID returns the old "organization_id" field's value of the CompapiAsynctask entity.
  9929. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9930. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9931. func (m *CompapiAsynctaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  9932. if !m.op.Is(OpUpdateOne) {
  9933. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  9934. }
  9935. if m.id == nil || m.oldValue == nil {
  9936. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  9937. }
  9938. oldValue, err := m.oldValue(ctx)
  9939. if err != nil {
  9940. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  9941. }
  9942. return oldValue.OrganizationID, nil
  9943. }
  9944. // AddOrganizationID adds u to the "organization_id" field.
  9945. func (m *CompapiAsynctaskMutation) AddOrganizationID(u int64) {
  9946. if m.addorganization_id != nil {
  9947. *m.addorganization_id += u
  9948. } else {
  9949. m.addorganization_id = &u
  9950. }
  9951. }
  9952. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  9953. func (m *CompapiAsynctaskMutation) AddedOrganizationID() (r int64, exists bool) {
  9954. v := m.addorganization_id
  9955. if v == nil {
  9956. return
  9957. }
  9958. return *v, true
  9959. }
  9960. // ResetOrganizationID resets all changes to the "organization_id" field.
  9961. func (m *CompapiAsynctaskMutation) ResetOrganizationID() {
  9962. m.organization_id = nil
  9963. m.addorganization_id = nil
  9964. }
  9965. // SetOpenaiBase sets the "openai_base" field.
  9966. func (m *CompapiAsynctaskMutation) SetOpenaiBase(s string) {
  9967. m.openai_base = &s
  9968. }
  9969. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  9970. func (m *CompapiAsynctaskMutation) OpenaiBase() (r string, exists bool) {
  9971. v := m.openai_base
  9972. if v == nil {
  9973. return
  9974. }
  9975. return *v, true
  9976. }
  9977. // OldOpenaiBase returns the old "openai_base" field's value of the CompapiAsynctask entity.
  9978. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9979. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9980. func (m *CompapiAsynctaskMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  9981. if !m.op.Is(OpUpdateOne) {
  9982. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  9983. }
  9984. if m.id == nil || m.oldValue == nil {
  9985. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  9986. }
  9987. oldValue, err := m.oldValue(ctx)
  9988. if err != nil {
  9989. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  9990. }
  9991. return oldValue.OpenaiBase, nil
  9992. }
  9993. // ResetOpenaiBase resets all changes to the "openai_base" field.
  9994. func (m *CompapiAsynctaskMutation) ResetOpenaiBase() {
  9995. m.openai_base = nil
  9996. }
  9997. // SetOpenaiKey sets the "openai_key" field.
  9998. func (m *CompapiAsynctaskMutation) SetOpenaiKey(s string) {
  9999. m.openai_key = &s
  10000. }
  10001. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  10002. func (m *CompapiAsynctaskMutation) OpenaiKey() (r string, exists bool) {
  10003. v := m.openai_key
  10004. if v == nil {
  10005. return
  10006. }
  10007. return *v, true
  10008. }
  10009. // OldOpenaiKey returns the old "openai_key" field's value of the CompapiAsynctask entity.
  10010. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10011. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10012. func (m *CompapiAsynctaskMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  10013. if !m.op.Is(OpUpdateOne) {
  10014. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  10015. }
  10016. if m.id == nil || m.oldValue == nil {
  10017. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  10018. }
  10019. oldValue, err := m.oldValue(ctx)
  10020. if err != nil {
  10021. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  10022. }
  10023. return oldValue.OpenaiKey, nil
  10024. }
  10025. // ResetOpenaiKey resets all changes to the "openai_key" field.
  10026. func (m *CompapiAsynctaskMutation) ResetOpenaiKey() {
  10027. m.openai_key = nil
  10028. }
  10029. // SetRequestRaw sets the "request_raw" field.
  10030. func (m *CompapiAsynctaskMutation) SetRequestRaw(s string) {
  10031. m.request_raw = &s
  10032. }
  10033. // RequestRaw returns the value of the "request_raw" field in the mutation.
  10034. func (m *CompapiAsynctaskMutation) RequestRaw() (r string, exists bool) {
  10035. v := m.request_raw
  10036. if v == nil {
  10037. return
  10038. }
  10039. return *v, true
  10040. }
  10041. // OldRequestRaw returns the old "request_raw" field's value of the CompapiAsynctask entity.
  10042. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10043. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10044. func (m *CompapiAsynctaskMutation) OldRequestRaw(ctx context.Context) (v string, err error) {
  10045. if !m.op.Is(OpUpdateOne) {
  10046. return v, errors.New("OldRequestRaw is only allowed on UpdateOne operations")
  10047. }
  10048. if m.id == nil || m.oldValue == nil {
  10049. return v, errors.New("OldRequestRaw requires an ID field in the mutation")
  10050. }
  10051. oldValue, err := m.oldValue(ctx)
  10052. if err != nil {
  10053. return v, fmt.Errorf("querying old value for OldRequestRaw: %w", err)
  10054. }
  10055. return oldValue.RequestRaw, nil
  10056. }
  10057. // ResetRequestRaw resets all changes to the "request_raw" field.
  10058. func (m *CompapiAsynctaskMutation) ResetRequestRaw() {
  10059. m.request_raw = nil
  10060. }
  10061. // SetResponseRaw sets the "response_raw" field.
  10062. func (m *CompapiAsynctaskMutation) SetResponseRaw(s string) {
  10063. m.response_raw = &s
  10064. }
  10065. // ResponseRaw returns the value of the "response_raw" field in the mutation.
  10066. func (m *CompapiAsynctaskMutation) ResponseRaw() (r string, exists bool) {
  10067. v := m.response_raw
  10068. if v == nil {
  10069. return
  10070. }
  10071. return *v, true
  10072. }
  10073. // OldResponseRaw returns the old "response_raw" field's value of the CompapiAsynctask entity.
  10074. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10075. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10076. func (m *CompapiAsynctaskMutation) OldResponseRaw(ctx context.Context) (v string, err error) {
  10077. if !m.op.Is(OpUpdateOne) {
  10078. return v, errors.New("OldResponseRaw is only allowed on UpdateOne operations")
  10079. }
  10080. if m.id == nil || m.oldValue == nil {
  10081. return v, errors.New("OldResponseRaw requires an ID field in the mutation")
  10082. }
  10083. oldValue, err := m.oldValue(ctx)
  10084. if err != nil {
  10085. return v, fmt.Errorf("querying old value for OldResponseRaw: %w", err)
  10086. }
  10087. return oldValue.ResponseRaw, nil
  10088. }
  10089. // ClearResponseRaw clears the value of the "response_raw" field.
  10090. func (m *CompapiAsynctaskMutation) ClearResponseRaw() {
  10091. m.response_raw = nil
  10092. m.clearedFields[compapiasynctask.FieldResponseRaw] = struct{}{}
  10093. }
  10094. // ResponseRawCleared returns if the "response_raw" field was cleared in this mutation.
  10095. func (m *CompapiAsynctaskMutation) ResponseRawCleared() bool {
  10096. _, ok := m.clearedFields[compapiasynctask.FieldResponseRaw]
  10097. return ok
  10098. }
  10099. // ResetResponseRaw resets all changes to the "response_raw" field.
  10100. func (m *CompapiAsynctaskMutation) ResetResponseRaw() {
  10101. m.response_raw = nil
  10102. delete(m.clearedFields, compapiasynctask.FieldResponseRaw)
  10103. }
  10104. // SetCallbackURL sets the "callback_url" field.
  10105. func (m *CompapiAsynctaskMutation) SetCallbackURL(s string) {
  10106. m.callback_url = &s
  10107. }
  10108. // CallbackURL returns the value of the "callback_url" field in the mutation.
  10109. func (m *CompapiAsynctaskMutation) CallbackURL() (r string, exists bool) {
  10110. v := m.callback_url
  10111. if v == nil {
  10112. return
  10113. }
  10114. return *v, true
  10115. }
  10116. // OldCallbackURL returns the old "callback_url" field's value of the CompapiAsynctask entity.
  10117. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10118. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10119. func (m *CompapiAsynctaskMutation) OldCallbackURL(ctx context.Context) (v string, err error) {
  10120. if !m.op.Is(OpUpdateOne) {
  10121. return v, errors.New("OldCallbackURL is only allowed on UpdateOne operations")
  10122. }
  10123. if m.id == nil || m.oldValue == nil {
  10124. return v, errors.New("OldCallbackURL requires an ID field in the mutation")
  10125. }
  10126. oldValue, err := m.oldValue(ctx)
  10127. if err != nil {
  10128. return v, fmt.Errorf("querying old value for OldCallbackURL: %w", err)
  10129. }
  10130. return oldValue.CallbackURL, nil
  10131. }
  10132. // ResetCallbackURL resets all changes to the "callback_url" field.
  10133. func (m *CompapiAsynctaskMutation) ResetCallbackURL() {
  10134. m.callback_url = nil
  10135. }
  10136. // SetCallbackResponseRaw sets the "callback_response_raw" field.
  10137. func (m *CompapiAsynctaskMutation) SetCallbackResponseRaw(s string) {
  10138. m.callback_response_raw = &s
  10139. }
  10140. // CallbackResponseRaw returns the value of the "callback_response_raw" field in the mutation.
  10141. func (m *CompapiAsynctaskMutation) CallbackResponseRaw() (r string, exists bool) {
  10142. v := m.callback_response_raw
  10143. if v == nil {
  10144. return
  10145. }
  10146. return *v, true
  10147. }
  10148. // OldCallbackResponseRaw returns the old "callback_response_raw" field's value of the CompapiAsynctask entity.
  10149. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10150. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10151. func (m *CompapiAsynctaskMutation) OldCallbackResponseRaw(ctx context.Context) (v string, err error) {
  10152. if !m.op.Is(OpUpdateOne) {
  10153. return v, errors.New("OldCallbackResponseRaw is only allowed on UpdateOne operations")
  10154. }
  10155. if m.id == nil || m.oldValue == nil {
  10156. return v, errors.New("OldCallbackResponseRaw requires an ID field in the mutation")
  10157. }
  10158. oldValue, err := m.oldValue(ctx)
  10159. if err != nil {
  10160. return v, fmt.Errorf("querying old value for OldCallbackResponseRaw: %w", err)
  10161. }
  10162. return oldValue.CallbackResponseRaw, nil
  10163. }
  10164. // ClearCallbackResponseRaw clears the value of the "callback_response_raw" field.
  10165. func (m *CompapiAsynctaskMutation) ClearCallbackResponseRaw() {
  10166. m.callback_response_raw = nil
  10167. m.clearedFields[compapiasynctask.FieldCallbackResponseRaw] = struct{}{}
  10168. }
  10169. // CallbackResponseRawCleared returns if the "callback_response_raw" field was cleared in this mutation.
  10170. func (m *CompapiAsynctaskMutation) CallbackResponseRawCleared() bool {
  10171. _, ok := m.clearedFields[compapiasynctask.FieldCallbackResponseRaw]
  10172. return ok
  10173. }
  10174. // ResetCallbackResponseRaw resets all changes to the "callback_response_raw" field.
  10175. func (m *CompapiAsynctaskMutation) ResetCallbackResponseRaw() {
  10176. m.callback_response_raw = nil
  10177. delete(m.clearedFields, compapiasynctask.FieldCallbackResponseRaw)
  10178. }
  10179. // SetModel sets the "model" field.
  10180. func (m *CompapiAsynctaskMutation) SetModel(s string) {
  10181. m.model = &s
  10182. }
  10183. // Model returns the value of the "model" field in the mutation.
  10184. func (m *CompapiAsynctaskMutation) Model() (r string, exists bool) {
  10185. v := m.model
  10186. if v == nil {
  10187. return
  10188. }
  10189. return *v, true
  10190. }
  10191. // OldModel returns the old "model" field's value of the CompapiAsynctask entity.
  10192. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10193. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10194. func (m *CompapiAsynctaskMutation) OldModel(ctx context.Context) (v string, err error) {
  10195. if !m.op.Is(OpUpdateOne) {
  10196. return v, errors.New("OldModel is only allowed on UpdateOne operations")
  10197. }
  10198. if m.id == nil || m.oldValue == nil {
  10199. return v, errors.New("OldModel requires an ID field in the mutation")
  10200. }
  10201. oldValue, err := m.oldValue(ctx)
  10202. if err != nil {
  10203. return v, fmt.Errorf("querying old value for OldModel: %w", err)
  10204. }
  10205. return oldValue.Model, nil
  10206. }
  10207. // ClearModel clears the value of the "model" field.
  10208. func (m *CompapiAsynctaskMutation) ClearModel() {
  10209. m.model = nil
  10210. m.clearedFields[compapiasynctask.FieldModel] = struct{}{}
  10211. }
  10212. // ModelCleared returns if the "model" field was cleared in this mutation.
  10213. func (m *CompapiAsynctaskMutation) ModelCleared() bool {
  10214. _, ok := m.clearedFields[compapiasynctask.FieldModel]
  10215. return ok
  10216. }
  10217. // ResetModel resets all changes to the "model" field.
  10218. func (m *CompapiAsynctaskMutation) ResetModel() {
  10219. m.model = nil
  10220. delete(m.clearedFields, compapiasynctask.FieldModel)
  10221. }
  10222. // SetTaskStatus sets the "task_status" field.
  10223. func (m *CompapiAsynctaskMutation) SetTaskStatus(i int8) {
  10224. m.task_status = &i
  10225. m.addtask_status = nil
  10226. }
  10227. // TaskStatus returns the value of the "task_status" field in the mutation.
  10228. func (m *CompapiAsynctaskMutation) TaskStatus() (r int8, exists bool) {
  10229. v := m.task_status
  10230. if v == nil {
  10231. return
  10232. }
  10233. return *v, true
  10234. }
  10235. // OldTaskStatus returns the old "task_status" field's value of the CompapiAsynctask entity.
  10236. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10237. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10238. func (m *CompapiAsynctaskMutation) OldTaskStatus(ctx context.Context) (v int8, err error) {
  10239. if !m.op.Is(OpUpdateOne) {
  10240. return v, errors.New("OldTaskStatus is only allowed on UpdateOne operations")
  10241. }
  10242. if m.id == nil || m.oldValue == nil {
  10243. return v, errors.New("OldTaskStatus requires an ID field in the mutation")
  10244. }
  10245. oldValue, err := m.oldValue(ctx)
  10246. if err != nil {
  10247. return v, fmt.Errorf("querying old value for OldTaskStatus: %w", err)
  10248. }
  10249. return oldValue.TaskStatus, nil
  10250. }
  10251. // AddTaskStatus adds i to the "task_status" field.
  10252. func (m *CompapiAsynctaskMutation) AddTaskStatus(i int8) {
  10253. if m.addtask_status != nil {
  10254. *m.addtask_status += i
  10255. } else {
  10256. m.addtask_status = &i
  10257. }
  10258. }
  10259. // AddedTaskStatus returns the value that was added to the "task_status" field in this mutation.
  10260. func (m *CompapiAsynctaskMutation) AddedTaskStatus() (r int8, exists bool) {
  10261. v := m.addtask_status
  10262. if v == nil {
  10263. return
  10264. }
  10265. return *v, true
  10266. }
  10267. // ClearTaskStatus clears the value of the "task_status" field.
  10268. func (m *CompapiAsynctaskMutation) ClearTaskStatus() {
  10269. m.task_status = nil
  10270. m.addtask_status = nil
  10271. m.clearedFields[compapiasynctask.FieldTaskStatus] = struct{}{}
  10272. }
  10273. // TaskStatusCleared returns if the "task_status" field was cleared in this mutation.
  10274. func (m *CompapiAsynctaskMutation) TaskStatusCleared() bool {
  10275. _, ok := m.clearedFields[compapiasynctask.FieldTaskStatus]
  10276. return ok
  10277. }
  10278. // ResetTaskStatus resets all changes to the "task_status" field.
  10279. func (m *CompapiAsynctaskMutation) ResetTaskStatus() {
  10280. m.task_status = nil
  10281. m.addtask_status = nil
  10282. delete(m.clearedFields, compapiasynctask.FieldTaskStatus)
  10283. }
  10284. // SetRetryCount sets the "retry_count" field.
  10285. func (m *CompapiAsynctaskMutation) SetRetryCount(i int8) {
  10286. m.retry_count = &i
  10287. m.addretry_count = nil
  10288. }
  10289. // RetryCount returns the value of the "retry_count" field in the mutation.
  10290. func (m *CompapiAsynctaskMutation) RetryCount() (r int8, exists bool) {
  10291. v := m.retry_count
  10292. if v == nil {
  10293. return
  10294. }
  10295. return *v, true
  10296. }
  10297. // OldRetryCount returns the old "retry_count" field's value of the CompapiAsynctask entity.
  10298. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10299. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10300. func (m *CompapiAsynctaskMutation) OldRetryCount(ctx context.Context) (v int8, err error) {
  10301. if !m.op.Is(OpUpdateOne) {
  10302. return v, errors.New("OldRetryCount is only allowed on UpdateOne operations")
  10303. }
  10304. if m.id == nil || m.oldValue == nil {
  10305. return v, errors.New("OldRetryCount requires an ID field in the mutation")
  10306. }
  10307. oldValue, err := m.oldValue(ctx)
  10308. if err != nil {
  10309. return v, fmt.Errorf("querying old value for OldRetryCount: %w", err)
  10310. }
  10311. return oldValue.RetryCount, nil
  10312. }
  10313. // AddRetryCount adds i to the "retry_count" field.
  10314. func (m *CompapiAsynctaskMutation) AddRetryCount(i int8) {
  10315. if m.addretry_count != nil {
  10316. *m.addretry_count += i
  10317. } else {
  10318. m.addretry_count = &i
  10319. }
  10320. }
  10321. // AddedRetryCount returns the value that was added to the "retry_count" field in this mutation.
  10322. func (m *CompapiAsynctaskMutation) AddedRetryCount() (r int8, exists bool) {
  10323. v := m.addretry_count
  10324. if v == nil {
  10325. return
  10326. }
  10327. return *v, true
  10328. }
  10329. // ClearRetryCount clears the value of the "retry_count" field.
  10330. func (m *CompapiAsynctaskMutation) ClearRetryCount() {
  10331. m.retry_count = nil
  10332. m.addretry_count = nil
  10333. m.clearedFields[compapiasynctask.FieldRetryCount] = struct{}{}
  10334. }
  10335. // RetryCountCleared returns if the "retry_count" field was cleared in this mutation.
  10336. func (m *CompapiAsynctaskMutation) RetryCountCleared() bool {
  10337. _, ok := m.clearedFields[compapiasynctask.FieldRetryCount]
  10338. return ok
  10339. }
  10340. // ResetRetryCount resets all changes to the "retry_count" field.
  10341. func (m *CompapiAsynctaskMutation) ResetRetryCount() {
  10342. m.retry_count = nil
  10343. m.addretry_count = nil
  10344. delete(m.clearedFields, compapiasynctask.FieldRetryCount)
  10345. }
  10346. // SetLastError sets the "last_error" field.
  10347. func (m *CompapiAsynctaskMutation) SetLastError(s string) {
  10348. m.last_error = &s
  10349. }
  10350. // LastError returns the value of the "last_error" field in the mutation.
  10351. func (m *CompapiAsynctaskMutation) LastError() (r string, exists bool) {
  10352. v := m.last_error
  10353. if v == nil {
  10354. return
  10355. }
  10356. return *v, true
  10357. }
  10358. // OldLastError returns the old "last_error" field's value of the CompapiAsynctask entity.
  10359. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10360. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10361. func (m *CompapiAsynctaskMutation) OldLastError(ctx context.Context) (v string, err error) {
  10362. if !m.op.Is(OpUpdateOne) {
  10363. return v, errors.New("OldLastError is only allowed on UpdateOne operations")
  10364. }
  10365. if m.id == nil || m.oldValue == nil {
  10366. return v, errors.New("OldLastError requires an ID field in the mutation")
  10367. }
  10368. oldValue, err := m.oldValue(ctx)
  10369. if err != nil {
  10370. return v, fmt.Errorf("querying old value for OldLastError: %w", err)
  10371. }
  10372. return oldValue.LastError, nil
  10373. }
  10374. // ClearLastError clears the value of the "last_error" field.
  10375. func (m *CompapiAsynctaskMutation) ClearLastError() {
  10376. m.last_error = nil
  10377. m.clearedFields[compapiasynctask.FieldLastError] = struct{}{}
  10378. }
  10379. // LastErrorCleared returns if the "last_error" field was cleared in this mutation.
  10380. func (m *CompapiAsynctaskMutation) LastErrorCleared() bool {
  10381. _, ok := m.clearedFields[compapiasynctask.FieldLastError]
  10382. return ok
  10383. }
  10384. // ResetLastError resets all changes to the "last_error" field.
  10385. func (m *CompapiAsynctaskMutation) ResetLastError() {
  10386. m.last_error = nil
  10387. delete(m.clearedFields, compapiasynctask.FieldLastError)
  10388. }
  10389. // Where appends a list predicates to the CompapiAsynctaskMutation builder.
  10390. func (m *CompapiAsynctaskMutation) Where(ps ...predicate.CompapiAsynctask) {
  10391. m.predicates = append(m.predicates, ps...)
  10392. }
  10393. // WhereP appends storage-level predicates to the CompapiAsynctaskMutation builder. Using this method,
  10394. // users can use type-assertion to append predicates that do not depend on any generated package.
  10395. func (m *CompapiAsynctaskMutation) WhereP(ps ...func(*sql.Selector)) {
  10396. p := make([]predicate.CompapiAsynctask, len(ps))
  10397. for i := range ps {
  10398. p[i] = ps[i]
  10399. }
  10400. m.Where(p...)
  10401. }
  10402. // Op returns the operation name.
  10403. func (m *CompapiAsynctaskMutation) Op() Op {
  10404. return m.op
  10405. }
  10406. // SetOp allows setting the mutation operation.
  10407. func (m *CompapiAsynctaskMutation) SetOp(op Op) {
  10408. m.op = op
  10409. }
  10410. // Type returns the node type of this mutation (CompapiAsynctask).
  10411. func (m *CompapiAsynctaskMutation) Type() string {
  10412. return m.typ
  10413. }
  10414. // Fields returns all fields that were changed during this mutation. Note that in
  10415. // order to get all numeric fields that were incremented/decremented, call
  10416. // AddedFields().
  10417. func (m *CompapiAsynctaskMutation) Fields() []string {
  10418. fields := make([]string, 0, 17)
  10419. if m.created_at != nil {
  10420. fields = append(fields, compapiasynctask.FieldCreatedAt)
  10421. }
  10422. if m.updated_at != nil {
  10423. fields = append(fields, compapiasynctask.FieldUpdatedAt)
  10424. }
  10425. if m.auth_token != nil {
  10426. fields = append(fields, compapiasynctask.FieldAuthToken)
  10427. }
  10428. if m.event_type != nil {
  10429. fields = append(fields, compapiasynctask.FieldEventType)
  10430. }
  10431. if m.chat_id != nil {
  10432. fields = append(fields, compapiasynctask.FieldChatID)
  10433. }
  10434. if m.response_chat_item_id != nil {
  10435. fields = append(fields, compapiasynctask.FieldResponseChatItemID)
  10436. }
  10437. if m.organization_id != nil {
  10438. fields = append(fields, compapiasynctask.FieldOrganizationID)
  10439. }
  10440. if m.openai_base != nil {
  10441. fields = append(fields, compapiasynctask.FieldOpenaiBase)
  10442. }
  10443. if m.openai_key != nil {
  10444. fields = append(fields, compapiasynctask.FieldOpenaiKey)
  10445. }
  10446. if m.request_raw != nil {
  10447. fields = append(fields, compapiasynctask.FieldRequestRaw)
  10448. }
  10449. if m.response_raw != nil {
  10450. fields = append(fields, compapiasynctask.FieldResponseRaw)
  10451. }
  10452. if m.callback_url != nil {
  10453. fields = append(fields, compapiasynctask.FieldCallbackURL)
  10454. }
  10455. if m.callback_response_raw != nil {
  10456. fields = append(fields, compapiasynctask.FieldCallbackResponseRaw)
  10457. }
  10458. if m.model != nil {
  10459. fields = append(fields, compapiasynctask.FieldModel)
  10460. }
  10461. if m.task_status != nil {
  10462. fields = append(fields, compapiasynctask.FieldTaskStatus)
  10463. }
  10464. if m.retry_count != nil {
  10465. fields = append(fields, compapiasynctask.FieldRetryCount)
  10466. }
  10467. if m.last_error != nil {
  10468. fields = append(fields, compapiasynctask.FieldLastError)
  10469. }
  10470. return fields
  10471. }
  10472. // Field returns the value of a field with the given name. The second boolean
  10473. // return value indicates that this field was not set, or was not defined in the
  10474. // schema.
  10475. func (m *CompapiAsynctaskMutation) Field(name string) (ent.Value, bool) {
  10476. switch name {
  10477. case compapiasynctask.FieldCreatedAt:
  10478. return m.CreatedAt()
  10479. case compapiasynctask.FieldUpdatedAt:
  10480. return m.UpdatedAt()
  10481. case compapiasynctask.FieldAuthToken:
  10482. return m.AuthToken()
  10483. case compapiasynctask.FieldEventType:
  10484. return m.EventType()
  10485. case compapiasynctask.FieldChatID:
  10486. return m.ChatID()
  10487. case compapiasynctask.FieldResponseChatItemID:
  10488. return m.ResponseChatItemID()
  10489. case compapiasynctask.FieldOrganizationID:
  10490. return m.OrganizationID()
  10491. case compapiasynctask.FieldOpenaiBase:
  10492. return m.OpenaiBase()
  10493. case compapiasynctask.FieldOpenaiKey:
  10494. return m.OpenaiKey()
  10495. case compapiasynctask.FieldRequestRaw:
  10496. return m.RequestRaw()
  10497. case compapiasynctask.FieldResponseRaw:
  10498. return m.ResponseRaw()
  10499. case compapiasynctask.FieldCallbackURL:
  10500. return m.CallbackURL()
  10501. case compapiasynctask.FieldCallbackResponseRaw:
  10502. return m.CallbackResponseRaw()
  10503. case compapiasynctask.FieldModel:
  10504. return m.Model()
  10505. case compapiasynctask.FieldTaskStatus:
  10506. return m.TaskStatus()
  10507. case compapiasynctask.FieldRetryCount:
  10508. return m.RetryCount()
  10509. case compapiasynctask.FieldLastError:
  10510. return m.LastError()
  10511. }
  10512. return nil, false
  10513. }
  10514. // OldField returns the old value of the field from the database. An error is
  10515. // returned if the mutation operation is not UpdateOne, or the query to the
  10516. // database failed.
  10517. func (m *CompapiAsynctaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10518. switch name {
  10519. case compapiasynctask.FieldCreatedAt:
  10520. return m.OldCreatedAt(ctx)
  10521. case compapiasynctask.FieldUpdatedAt:
  10522. return m.OldUpdatedAt(ctx)
  10523. case compapiasynctask.FieldAuthToken:
  10524. return m.OldAuthToken(ctx)
  10525. case compapiasynctask.FieldEventType:
  10526. return m.OldEventType(ctx)
  10527. case compapiasynctask.FieldChatID:
  10528. return m.OldChatID(ctx)
  10529. case compapiasynctask.FieldResponseChatItemID:
  10530. return m.OldResponseChatItemID(ctx)
  10531. case compapiasynctask.FieldOrganizationID:
  10532. return m.OldOrganizationID(ctx)
  10533. case compapiasynctask.FieldOpenaiBase:
  10534. return m.OldOpenaiBase(ctx)
  10535. case compapiasynctask.FieldOpenaiKey:
  10536. return m.OldOpenaiKey(ctx)
  10537. case compapiasynctask.FieldRequestRaw:
  10538. return m.OldRequestRaw(ctx)
  10539. case compapiasynctask.FieldResponseRaw:
  10540. return m.OldResponseRaw(ctx)
  10541. case compapiasynctask.FieldCallbackURL:
  10542. return m.OldCallbackURL(ctx)
  10543. case compapiasynctask.FieldCallbackResponseRaw:
  10544. return m.OldCallbackResponseRaw(ctx)
  10545. case compapiasynctask.FieldModel:
  10546. return m.OldModel(ctx)
  10547. case compapiasynctask.FieldTaskStatus:
  10548. return m.OldTaskStatus(ctx)
  10549. case compapiasynctask.FieldRetryCount:
  10550. return m.OldRetryCount(ctx)
  10551. case compapiasynctask.FieldLastError:
  10552. return m.OldLastError(ctx)
  10553. }
  10554. return nil, fmt.Errorf("unknown CompapiAsynctask field %s", name)
  10555. }
  10556. // SetField sets the value of a field with the given name. It returns an error if
  10557. // the field is not defined in the schema, or if the type mismatched the field
  10558. // type.
  10559. func (m *CompapiAsynctaskMutation) SetField(name string, value ent.Value) error {
  10560. switch name {
  10561. case compapiasynctask.FieldCreatedAt:
  10562. v, ok := value.(time.Time)
  10563. if !ok {
  10564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10565. }
  10566. m.SetCreatedAt(v)
  10567. return nil
  10568. case compapiasynctask.FieldUpdatedAt:
  10569. v, ok := value.(time.Time)
  10570. if !ok {
  10571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10572. }
  10573. m.SetUpdatedAt(v)
  10574. return nil
  10575. case compapiasynctask.FieldAuthToken:
  10576. v, ok := value.(string)
  10577. if !ok {
  10578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10579. }
  10580. m.SetAuthToken(v)
  10581. return nil
  10582. case compapiasynctask.FieldEventType:
  10583. v, ok := value.(string)
  10584. if !ok {
  10585. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10586. }
  10587. m.SetEventType(v)
  10588. return nil
  10589. case compapiasynctask.FieldChatID:
  10590. v, ok := value.(string)
  10591. if !ok {
  10592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10593. }
  10594. m.SetChatID(v)
  10595. return nil
  10596. case compapiasynctask.FieldResponseChatItemID:
  10597. v, ok := value.(string)
  10598. if !ok {
  10599. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10600. }
  10601. m.SetResponseChatItemID(v)
  10602. return nil
  10603. case compapiasynctask.FieldOrganizationID:
  10604. v, ok := value.(uint64)
  10605. if !ok {
  10606. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10607. }
  10608. m.SetOrganizationID(v)
  10609. return nil
  10610. case compapiasynctask.FieldOpenaiBase:
  10611. v, ok := value.(string)
  10612. if !ok {
  10613. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10614. }
  10615. m.SetOpenaiBase(v)
  10616. return nil
  10617. case compapiasynctask.FieldOpenaiKey:
  10618. v, ok := value.(string)
  10619. if !ok {
  10620. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10621. }
  10622. m.SetOpenaiKey(v)
  10623. return nil
  10624. case compapiasynctask.FieldRequestRaw:
  10625. v, ok := value.(string)
  10626. if !ok {
  10627. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10628. }
  10629. m.SetRequestRaw(v)
  10630. return nil
  10631. case compapiasynctask.FieldResponseRaw:
  10632. v, ok := value.(string)
  10633. if !ok {
  10634. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10635. }
  10636. m.SetResponseRaw(v)
  10637. return nil
  10638. case compapiasynctask.FieldCallbackURL:
  10639. v, ok := value.(string)
  10640. if !ok {
  10641. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10642. }
  10643. m.SetCallbackURL(v)
  10644. return nil
  10645. case compapiasynctask.FieldCallbackResponseRaw:
  10646. v, ok := value.(string)
  10647. if !ok {
  10648. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10649. }
  10650. m.SetCallbackResponseRaw(v)
  10651. return nil
  10652. case compapiasynctask.FieldModel:
  10653. v, ok := value.(string)
  10654. if !ok {
  10655. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10656. }
  10657. m.SetModel(v)
  10658. return nil
  10659. case compapiasynctask.FieldTaskStatus:
  10660. v, ok := value.(int8)
  10661. if !ok {
  10662. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10663. }
  10664. m.SetTaskStatus(v)
  10665. return nil
  10666. case compapiasynctask.FieldRetryCount:
  10667. v, ok := value.(int8)
  10668. if !ok {
  10669. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10670. }
  10671. m.SetRetryCount(v)
  10672. return nil
  10673. case compapiasynctask.FieldLastError:
  10674. v, ok := value.(string)
  10675. if !ok {
  10676. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10677. }
  10678. m.SetLastError(v)
  10679. return nil
  10680. }
  10681. return fmt.Errorf("unknown CompapiAsynctask field %s", name)
  10682. }
  10683. // AddedFields returns all numeric fields that were incremented/decremented during
  10684. // this mutation.
  10685. func (m *CompapiAsynctaskMutation) AddedFields() []string {
  10686. var fields []string
  10687. if m.addorganization_id != nil {
  10688. fields = append(fields, compapiasynctask.FieldOrganizationID)
  10689. }
  10690. if m.addtask_status != nil {
  10691. fields = append(fields, compapiasynctask.FieldTaskStatus)
  10692. }
  10693. if m.addretry_count != nil {
  10694. fields = append(fields, compapiasynctask.FieldRetryCount)
  10695. }
  10696. return fields
  10697. }
  10698. // AddedField returns the numeric value that was incremented/decremented on a field
  10699. // with the given name. The second boolean return value indicates that this field
  10700. // was not set, or was not defined in the schema.
  10701. func (m *CompapiAsynctaskMutation) AddedField(name string) (ent.Value, bool) {
  10702. switch name {
  10703. case compapiasynctask.FieldOrganizationID:
  10704. return m.AddedOrganizationID()
  10705. case compapiasynctask.FieldTaskStatus:
  10706. return m.AddedTaskStatus()
  10707. case compapiasynctask.FieldRetryCount:
  10708. return m.AddedRetryCount()
  10709. }
  10710. return nil, false
  10711. }
  10712. // AddField adds the value to the field with the given name. It returns an error if
  10713. // the field is not defined in the schema, or if the type mismatched the field
  10714. // type.
  10715. func (m *CompapiAsynctaskMutation) AddField(name string, value ent.Value) error {
  10716. switch name {
  10717. case compapiasynctask.FieldOrganizationID:
  10718. v, ok := value.(int64)
  10719. if !ok {
  10720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10721. }
  10722. m.AddOrganizationID(v)
  10723. return nil
  10724. case compapiasynctask.FieldTaskStatus:
  10725. v, ok := value.(int8)
  10726. if !ok {
  10727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10728. }
  10729. m.AddTaskStatus(v)
  10730. return nil
  10731. case compapiasynctask.FieldRetryCount:
  10732. v, ok := value.(int8)
  10733. if !ok {
  10734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10735. }
  10736. m.AddRetryCount(v)
  10737. return nil
  10738. }
  10739. return fmt.Errorf("unknown CompapiAsynctask numeric field %s", name)
  10740. }
  10741. // ClearedFields returns all nullable fields that were cleared during this
  10742. // mutation.
  10743. func (m *CompapiAsynctaskMutation) ClearedFields() []string {
  10744. var fields []string
  10745. if m.FieldCleared(compapiasynctask.FieldChatID) {
  10746. fields = append(fields, compapiasynctask.FieldChatID)
  10747. }
  10748. if m.FieldCleared(compapiasynctask.FieldResponseChatItemID) {
  10749. fields = append(fields, compapiasynctask.FieldResponseChatItemID)
  10750. }
  10751. if m.FieldCleared(compapiasynctask.FieldResponseRaw) {
  10752. fields = append(fields, compapiasynctask.FieldResponseRaw)
  10753. }
  10754. if m.FieldCleared(compapiasynctask.FieldCallbackResponseRaw) {
  10755. fields = append(fields, compapiasynctask.FieldCallbackResponseRaw)
  10756. }
  10757. if m.FieldCleared(compapiasynctask.FieldModel) {
  10758. fields = append(fields, compapiasynctask.FieldModel)
  10759. }
  10760. if m.FieldCleared(compapiasynctask.FieldTaskStatus) {
  10761. fields = append(fields, compapiasynctask.FieldTaskStatus)
  10762. }
  10763. if m.FieldCleared(compapiasynctask.FieldRetryCount) {
  10764. fields = append(fields, compapiasynctask.FieldRetryCount)
  10765. }
  10766. if m.FieldCleared(compapiasynctask.FieldLastError) {
  10767. fields = append(fields, compapiasynctask.FieldLastError)
  10768. }
  10769. return fields
  10770. }
  10771. // FieldCleared returns a boolean indicating if a field with the given name was
  10772. // cleared in this mutation.
  10773. func (m *CompapiAsynctaskMutation) FieldCleared(name string) bool {
  10774. _, ok := m.clearedFields[name]
  10775. return ok
  10776. }
  10777. // ClearField clears the value of the field with the given name. It returns an
  10778. // error if the field is not defined in the schema.
  10779. func (m *CompapiAsynctaskMutation) ClearField(name string) error {
  10780. switch name {
  10781. case compapiasynctask.FieldChatID:
  10782. m.ClearChatID()
  10783. return nil
  10784. case compapiasynctask.FieldResponseChatItemID:
  10785. m.ClearResponseChatItemID()
  10786. return nil
  10787. case compapiasynctask.FieldResponseRaw:
  10788. m.ClearResponseRaw()
  10789. return nil
  10790. case compapiasynctask.FieldCallbackResponseRaw:
  10791. m.ClearCallbackResponseRaw()
  10792. return nil
  10793. case compapiasynctask.FieldModel:
  10794. m.ClearModel()
  10795. return nil
  10796. case compapiasynctask.FieldTaskStatus:
  10797. m.ClearTaskStatus()
  10798. return nil
  10799. case compapiasynctask.FieldRetryCount:
  10800. m.ClearRetryCount()
  10801. return nil
  10802. case compapiasynctask.FieldLastError:
  10803. m.ClearLastError()
  10804. return nil
  10805. }
  10806. return fmt.Errorf("unknown CompapiAsynctask nullable field %s", name)
  10807. }
  10808. // ResetField resets all changes in the mutation for the field with the given name.
  10809. // It returns an error if the field is not defined in the schema.
  10810. func (m *CompapiAsynctaskMutation) ResetField(name string) error {
  10811. switch name {
  10812. case compapiasynctask.FieldCreatedAt:
  10813. m.ResetCreatedAt()
  10814. return nil
  10815. case compapiasynctask.FieldUpdatedAt:
  10816. m.ResetUpdatedAt()
  10817. return nil
  10818. case compapiasynctask.FieldAuthToken:
  10819. m.ResetAuthToken()
  10820. return nil
  10821. case compapiasynctask.FieldEventType:
  10822. m.ResetEventType()
  10823. return nil
  10824. case compapiasynctask.FieldChatID:
  10825. m.ResetChatID()
  10826. return nil
  10827. case compapiasynctask.FieldResponseChatItemID:
  10828. m.ResetResponseChatItemID()
  10829. return nil
  10830. case compapiasynctask.FieldOrganizationID:
  10831. m.ResetOrganizationID()
  10832. return nil
  10833. case compapiasynctask.FieldOpenaiBase:
  10834. m.ResetOpenaiBase()
  10835. return nil
  10836. case compapiasynctask.FieldOpenaiKey:
  10837. m.ResetOpenaiKey()
  10838. return nil
  10839. case compapiasynctask.FieldRequestRaw:
  10840. m.ResetRequestRaw()
  10841. return nil
  10842. case compapiasynctask.FieldResponseRaw:
  10843. m.ResetResponseRaw()
  10844. return nil
  10845. case compapiasynctask.FieldCallbackURL:
  10846. m.ResetCallbackURL()
  10847. return nil
  10848. case compapiasynctask.FieldCallbackResponseRaw:
  10849. m.ResetCallbackResponseRaw()
  10850. return nil
  10851. case compapiasynctask.FieldModel:
  10852. m.ResetModel()
  10853. return nil
  10854. case compapiasynctask.FieldTaskStatus:
  10855. m.ResetTaskStatus()
  10856. return nil
  10857. case compapiasynctask.FieldRetryCount:
  10858. m.ResetRetryCount()
  10859. return nil
  10860. case compapiasynctask.FieldLastError:
  10861. m.ResetLastError()
  10862. return nil
  10863. }
  10864. return fmt.Errorf("unknown CompapiAsynctask field %s", name)
  10865. }
  10866. // AddedEdges returns all edge names that were set/added in this mutation.
  10867. func (m *CompapiAsynctaskMutation) AddedEdges() []string {
  10868. edges := make([]string, 0, 0)
  10869. return edges
  10870. }
  10871. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10872. // name in this mutation.
  10873. func (m *CompapiAsynctaskMutation) AddedIDs(name string) []ent.Value {
  10874. return nil
  10875. }
  10876. // RemovedEdges returns all edge names that were removed in this mutation.
  10877. func (m *CompapiAsynctaskMutation) RemovedEdges() []string {
  10878. edges := make([]string, 0, 0)
  10879. return edges
  10880. }
  10881. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10882. // the given name in this mutation.
  10883. func (m *CompapiAsynctaskMutation) RemovedIDs(name string) []ent.Value {
  10884. return nil
  10885. }
  10886. // ClearedEdges returns all edge names that were cleared in this mutation.
  10887. func (m *CompapiAsynctaskMutation) ClearedEdges() []string {
  10888. edges := make([]string, 0, 0)
  10889. return edges
  10890. }
  10891. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10892. // was cleared in this mutation.
  10893. func (m *CompapiAsynctaskMutation) EdgeCleared(name string) bool {
  10894. return false
  10895. }
  10896. // ClearEdge clears the value of the edge with the given name. It returns an error
  10897. // if that edge is not defined in the schema.
  10898. func (m *CompapiAsynctaskMutation) ClearEdge(name string) error {
  10899. return fmt.Errorf("unknown CompapiAsynctask unique edge %s", name)
  10900. }
  10901. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10902. // It returns an error if the edge is not defined in the schema.
  10903. func (m *CompapiAsynctaskMutation) ResetEdge(name string) error {
  10904. return fmt.Errorf("unknown CompapiAsynctask edge %s", name)
  10905. }
  10906. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  10907. type ContactMutation struct {
  10908. config
  10909. op Op
  10910. typ string
  10911. id *uint64
  10912. created_at *time.Time
  10913. updated_at *time.Time
  10914. status *uint8
  10915. addstatus *int8
  10916. deleted_at *time.Time
  10917. wx_wxid *string
  10918. _type *int
  10919. add_type *int
  10920. wxid *string
  10921. account *string
  10922. nickname *string
  10923. markname *string
  10924. headimg *string
  10925. sex *int
  10926. addsex *int
  10927. starrole *string
  10928. dontseeit *int
  10929. adddontseeit *int
  10930. dontseeme *int
  10931. adddontseeme *int
  10932. lag *string
  10933. gid *string
  10934. gname *string
  10935. v3 *string
  10936. organization_id *uint64
  10937. addorganization_id *int64
  10938. ctype *uint64
  10939. addctype *int64
  10940. cage *int
  10941. addcage *int
  10942. cname *string
  10943. carea *string
  10944. cbirthday *string
  10945. cbirtharea *string
  10946. cidcard_no *string
  10947. ctitle *string
  10948. cc *string
  10949. phone *string
  10950. clearedFields map[string]struct{}
  10951. contact_relationships map[uint64]struct{}
  10952. removedcontact_relationships map[uint64]struct{}
  10953. clearedcontact_relationships bool
  10954. contact_fields map[uint64]struct{}
  10955. removedcontact_fields map[uint64]struct{}
  10956. clearedcontact_fields bool
  10957. contact_messages map[uint64]struct{}
  10958. removedcontact_messages map[uint64]struct{}
  10959. clearedcontact_messages bool
  10960. done bool
  10961. oldValue func(context.Context) (*Contact, error)
  10962. predicates []predicate.Contact
  10963. }
  10964. var _ ent.Mutation = (*ContactMutation)(nil)
  10965. // contactOption allows management of the mutation configuration using functional options.
  10966. type contactOption func(*ContactMutation)
  10967. // newContactMutation creates new mutation for the Contact entity.
  10968. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  10969. m := &ContactMutation{
  10970. config: c,
  10971. op: op,
  10972. typ: TypeContact,
  10973. clearedFields: make(map[string]struct{}),
  10974. }
  10975. for _, opt := range opts {
  10976. opt(m)
  10977. }
  10978. return m
  10979. }
  10980. // withContactID sets the ID field of the mutation.
  10981. func withContactID(id uint64) contactOption {
  10982. return func(m *ContactMutation) {
  10983. var (
  10984. err error
  10985. once sync.Once
  10986. value *Contact
  10987. )
  10988. m.oldValue = func(ctx context.Context) (*Contact, error) {
  10989. once.Do(func() {
  10990. if m.done {
  10991. err = errors.New("querying old values post mutation is not allowed")
  10992. } else {
  10993. value, err = m.Client().Contact.Get(ctx, id)
  10994. }
  10995. })
  10996. return value, err
  10997. }
  10998. m.id = &id
  10999. }
  11000. }
  11001. // withContact sets the old Contact of the mutation.
  11002. func withContact(node *Contact) contactOption {
  11003. return func(m *ContactMutation) {
  11004. m.oldValue = func(context.Context) (*Contact, error) {
  11005. return node, nil
  11006. }
  11007. m.id = &node.ID
  11008. }
  11009. }
  11010. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11011. // executed in a transaction (ent.Tx), a transactional client is returned.
  11012. func (m ContactMutation) Client() *Client {
  11013. client := &Client{config: m.config}
  11014. client.init()
  11015. return client
  11016. }
  11017. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11018. // it returns an error otherwise.
  11019. func (m ContactMutation) Tx() (*Tx, error) {
  11020. if _, ok := m.driver.(*txDriver); !ok {
  11021. return nil, errors.New("ent: mutation is not running in a transaction")
  11022. }
  11023. tx := &Tx{config: m.config}
  11024. tx.init()
  11025. return tx, nil
  11026. }
  11027. // SetID sets the value of the id field. Note that this
  11028. // operation is only accepted on creation of Contact entities.
  11029. func (m *ContactMutation) SetID(id uint64) {
  11030. m.id = &id
  11031. }
  11032. // ID returns the ID value in the mutation. Note that the ID is only available
  11033. // if it was provided to the builder or after it was returned from the database.
  11034. func (m *ContactMutation) ID() (id uint64, exists bool) {
  11035. if m.id == nil {
  11036. return
  11037. }
  11038. return *m.id, true
  11039. }
  11040. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11041. // That means, if the mutation is applied within a transaction with an isolation level such
  11042. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11043. // or updated by the mutation.
  11044. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  11045. switch {
  11046. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11047. id, exists := m.ID()
  11048. if exists {
  11049. return []uint64{id}, nil
  11050. }
  11051. fallthrough
  11052. case m.op.Is(OpUpdate | OpDelete):
  11053. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  11054. default:
  11055. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11056. }
  11057. }
  11058. // SetCreatedAt sets the "created_at" field.
  11059. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  11060. m.created_at = &t
  11061. }
  11062. // CreatedAt returns the value of the "created_at" field in the mutation.
  11063. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  11064. v := m.created_at
  11065. if v == nil {
  11066. return
  11067. }
  11068. return *v, true
  11069. }
  11070. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  11071. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11072. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11073. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11074. if !m.op.Is(OpUpdateOne) {
  11075. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11076. }
  11077. if m.id == nil || m.oldValue == nil {
  11078. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11079. }
  11080. oldValue, err := m.oldValue(ctx)
  11081. if err != nil {
  11082. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11083. }
  11084. return oldValue.CreatedAt, nil
  11085. }
  11086. // ResetCreatedAt resets all changes to the "created_at" field.
  11087. func (m *ContactMutation) ResetCreatedAt() {
  11088. m.created_at = nil
  11089. }
  11090. // SetUpdatedAt sets the "updated_at" field.
  11091. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  11092. m.updated_at = &t
  11093. }
  11094. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11095. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  11096. v := m.updated_at
  11097. if v == nil {
  11098. return
  11099. }
  11100. return *v, true
  11101. }
  11102. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  11103. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11104. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11105. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11106. if !m.op.Is(OpUpdateOne) {
  11107. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11108. }
  11109. if m.id == nil || m.oldValue == nil {
  11110. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11111. }
  11112. oldValue, err := m.oldValue(ctx)
  11113. if err != nil {
  11114. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11115. }
  11116. return oldValue.UpdatedAt, nil
  11117. }
  11118. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11119. func (m *ContactMutation) ResetUpdatedAt() {
  11120. m.updated_at = nil
  11121. }
  11122. // SetStatus sets the "status" field.
  11123. func (m *ContactMutation) SetStatus(u uint8) {
  11124. m.status = &u
  11125. m.addstatus = nil
  11126. }
  11127. // Status returns the value of the "status" field in the mutation.
  11128. func (m *ContactMutation) Status() (r uint8, exists bool) {
  11129. v := m.status
  11130. if v == nil {
  11131. return
  11132. }
  11133. return *v, true
  11134. }
  11135. // OldStatus returns the old "status" field's value of the Contact entity.
  11136. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11137. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11138. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  11139. if !m.op.Is(OpUpdateOne) {
  11140. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11141. }
  11142. if m.id == nil || m.oldValue == nil {
  11143. return v, errors.New("OldStatus requires an ID field in the mutation")
  11144. }
  11145. oldValue, err := m.oldValue(ctx)
  11146. if err != nil {
  11147. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11148. }
  11149. return oldValue.Status, nil
  11150. }
  11151. // AddStatus adds u to the "status" field.
  11152. func (m *ContactMutation) AddStatus(u int8) {
  11153. if m.addstatus != nil {
  11154. *m.addstatus += u
  11155. } else {
  11156. m.addstatus = &u
  11157. }
  11158. }
  11159. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11160. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  11161. v := m.addstatus
  11162. if v == nil {
  11163. return
  11164. }
  11165. return *v, true
  11166. }
  11167. // ClearStatus clears the value of the "status" field.
  11168. func (m *ContactMutation) ClearStatus() {
  11169. m.status = nil
  11170. m.addstatus = nil
  11171. m.clearedFields[contact.FieldStatus] = struct{}{}
  11172. }
  11173. // StatusCleared returns if the "status" field was cleared in this mutation.
  11174. func (m *ContactMutation) StatusCleared() bool {
  11175. _, ok := m.clearedFields[contact.FieldStatus]
  11176. return ok
  11177. }
  11178. // ResetStatus resets all changes to the "status" field.
  11179. func (m *ContactMutation) ResetStatus() {
  11180. m.status = nil
  11181. m.addstatus = nil
  11182. delete(m.clearedFields, contact.FieldStatus)
  11183. }
  11184. // SetDeletedAt sets the "deleted_at" field.
  11185. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  11186. m.deleted_at = &t
  11187. }
  11188. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11189. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  11190. v := m.deleted_at
  11191. if v == nil {
  11192. return
  11193. }
  11194. return *v, true
  11195. }
  11196. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  11197. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11198. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11199. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11200. if !m.op.Is(OpUpdateOne) {
  11201. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11202. }
  11203. if m.id == nil || m.oldValue == nil {
  11204. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11205. }
  11206. oldValue, err := m.oldValue(ctx)
  11207. if err != nil {
  11208. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11209. }
  11210. return oldValue.DeletedAt, nil
  11211. }
  11212. // ClearDeletedAt clears the value of the "deleted_at" field.
  11213. func (m *ContactMutation) ClearDeletedAt() {
  11214. m.deleted_at = nil
  11215. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  11216. }
  11217. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11218. func (m *ContactMutation) DeletedAtCleared() bool {
  11219. _, ok := m.clearedFields[contact.FieldDeletedAt]
  11220. return ok
  11221. }
  11222. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11223. func (m *ContactMutation) ResetDeletedAt() {
  11224. m.deleted_at = nil
  11225. delete(m.clearedFields, contact.FieldDeletedAt)
  11226. }
  11227. // SetWxWxid sets the "wx_wxid" field.
  11228. func (m *ContactMutation) SetWxWxid(s string) {
  11229. m.wx_wxid = &s
  11230. }
  11231. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  11232. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  11233. v := m.wx_wxid
  11234. if v == nil {
  11235. return
  11236. }
  11237. return *v, true
  11238. }
  11239. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  11240. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11241. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11242. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  11243. if !m.op.Is(OpUpdateOne) {
  11244. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  11245. }
  11246. if m.id == nil || m.oldValue == nil {
  11247. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  11248. }
  11249. oldValue, err := m.oldValue(ctx)
  11250. if err != nil {
  11251. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  11252. }
  11253. return oldValue.WxWxid, nil
  11254. }
  11255. // ResetWxWxid resets all changes to the "wx_wxid" field.
  11256. func (m *ContactMutation) ResetWxWxid() {
  11257. m.wx_wxid = nil
  11258. }
  11259. // SetType sets the "type" field.
  11260. func (m *ContactMutation) SetType(i int) {
  11261. m._type = &i
  11262. m.add_type = nil
  11263. }
  11264. // GetType returns the value of the "type" field in the mutation.
  11265. func (m *ContactMutation) GetType() (r int, exists bool) {
  11266. v := m._type
  11267. if v == nil {
  11268. return
  11269. }
  11270. return *v, true
  11271. }
  11272. // OldType returns the old "type" field's value of the Contact entity.
  11273. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11274. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11275. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  11276. if !m.op.Is(OpUpdateOne) {
  11277. return v, errors.New("OldType is only allowed on UpdateOne operations")
  11278. }
  11279. if m.id == nil || m.oldValue == nil {
  11280. return v, errors.New("OldType requires an ID field in the mutation")
  11281. }
  11282. oldValue, err := m.oldValue(ctx)
  11283. if err != nil {
  11284. return v, fmt.Errorf("querying old value for OldType: %w", err)
  11285. }
  11286. return oldValue.Type, nil
  11287. }
  11288. // AddType adds i to the "type" field.
  11289. func (m *ContactMutation) AddType(i int) {
  11290. if m.add_type != nil {
  11291. *m.add_type += i
  11292. } else {
  11293. m.add_type = &i
  11294. }
  11295. }
  11296. // AddedType returns the value that was added to the "type" field in this mutation.
  11297. func (m *ContactMutation) AddedType() (r int, exists bool) {
  11298. v := m.add_type
  11299. if v == nil {
  11300. return
  11301. }
  11302. return *v, true
  11303. }
  11304. // ClearType clears the value of the "type" field.
  11305. func (m *ContactMutation) ClearType() {
  11306. m._type = nil
  11307. m.add_type = nil
  11308. m.clearedFields[contact.FieldType] = struct{}{}
  11309. }
  11310. // TypeCleared returns if the "type" field was cleared in this mutation.
  11311. func (m *ContactMutation) TypeCleared() bool {
  11312. _, ok := m.clearedFields[contact.FieldType]
  11313. return ok
  11314. }
  11315. // ResetType resets all changes to the "type" field.
  11316. func (m *ContactMutation) ResetType() {
  11317. m._type = nil
  11318. m.add_type = nil
  11319. delete(m.clearedFields, contact.FieldType)
  11320. }
  11321. // SetWxid sets the "wxid" field.
  11322. func (m *ContactMutation) SetWxid(s string) {
  11323. m.wxid = &s
  11324. }
  11325. // Wxid returns the value of the "wxid" field in the mutation.
  11326. func (m *ContactMutation) Wxid() (r string, exists bool) {
  11327. v := m.wxid
  11328. if v == nil {
  11329. return
  11330. }
  11331. return *v, true
  11332. }
  11333. // OldWxid returns the old "wxid" field's value of the Contact entity.
  11334. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11335. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11336. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  11337. if !m.op.Is(OpUpdateOne) {
  11338. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  11339. }
  11340. if m.id == nil || m.oldValue == nil {
  11341. return v, errors.New("OldWxid requires an ID field in the mutation")
  11342. }
  11343. oldValue, err := m.oldValue(ctx)
  11344. if err != nil {
  11345. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  11346. }
  11347. return oldValue.Wxid, nil
  11348. }
  11349. // ResetWxid resets all changes to the "wxid" field.
  11350. func (m *ContactMutation) ResetWxid() {
  11351. m.wxid = nil
  11352. }
  11353. // SetAccount sets the "account" field.
  11354. func (m *ContactMutation) SetAccount(s string) {
  11355. m.account = &s
  11356. }
  11357. // Account returns the value of the "account" field in the mutation.
  11358. func (m *ContactMutation) Account() (r string, exists bool) {
  11359. v := m.account
  11360. if v == nil {
  11361. return
  11362. }
  11363. return *v, true
  11364. }
  11365. // OldAccount returns the old "account" field's value of the Contact entity.
  11366. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11367. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11368. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  11369. if !m.op.Is(OpUpdateOne) {
  11370. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  11371. }
  11372. if m.id == nil || m.oldValue == nil {
  11373. return v, errors.New("OldAccount requires an ID field in the mutation")
  11374. }
  11375. oldValue, err := m.oldValue(ctx)
  11376. if err != nil {
  11377. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  11378. }
  11379. return oldValue.Account, nil
  11380. }
  11381. // ResetAccount resets all changes to the "account" field.
  11382. func (m *ContactMutation) ResetAccount() {
  11383. m.account = nil
  11384. }
  11385. // SetNickname sets the "nickname" field.
  11386. func (m *ContactMutation) SetNickname(s string) {
  11387. m.nickname = &s
  11388. }
  11389. // Nickname returns the value of the "nickname" field in the mutation.
  11390. func (m *ContactMutation) Nickname() (r string, exists bool) {
  11391. v := m.nickname
  11392. if v == nil {
  11393. return
  11394. }
  11395. return *v, true
  11396. }
  11397. // OldNickname returns the old "nickname" field's value of the Contact entity.
  11398. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11400. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  11401. if !m.op.Is(OpUpdateOne) {
  11402. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  11403. }
  11404. if m.id == nil || m.oldValue == nil {
  11405. return v, errors.New("OldNickname requires an ID field in the mutation")
  11406. }
  11407. oldValue, err := m.oldValue(ctx)
  11408. if err != nil {
  11409. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  11410. }
  11411. return oldValue.Nickname, nil
  11412. }
  11413. // ResetNickname resets all changes to the "nickname" field.
  11414. func (m *ContactMutation) ResetNickname() {
  11415. m.nickname = nil
  11416. }
  11417. // SetMarkname sets the "markname" field.
  11418. func (m *ContactMutation) SetMarkname(s string) {
  11419. m.markname = &s
  11420. }
  11421. // Markname returns the value of the "markname" field in the mutation.
  11422. func (m *ContactMutation) Markname() (r string, exists bool) {
  11423. v := m.markname
  11424. if v == nil {
  11425. return
  11426. }
  11427. return *v, true
  11428. }
  11429. // OldMarkname returns the old "markname" field's value of the Contact entity.
  11430. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11432. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  11433. if !m.op.Is(OpUpdateOne) {
  11434. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  11435. }
  11436. if m.id == nil || m.oldValue == nil {
  11437. return v, errors.New("OldMarkname requires an ID field in the mutation")
  11438. }
  11439. oldValue, err := m.oldValue(ctx)
  11440. if err != nil {
  11441. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  11442. }
  11443. return oldValue.Markname, nil
  11444. }
  11445. // ResetMarkname resets all changes to the "markname" field.
  11446. func (m *ContactMutation) ResetMarkname() {
  11447. m.markname = nil
  11448. }
  11449. // SetHeadimg sets the "headimg" field.
  11450. func (m *ContactMutation) SetHeadimg(s string) {
  11451. m.headimg = &s
  11452. }
  11453. // Headimg returns the value of the "headimg" field in the mutation.
  11454. func (m *ContactMutation) Headimg() (r string, exists bool) {
  11455. v := m.headimg
  11456. if v == nil {
  11457. return
  11458. }
  11459. return *v, true
  11460. }
  11461. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  11462. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11463. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11464. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  11465. if !m.op.Is(OpUpdateOne) {
  11466. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  11467. }
  11468. if m.id == nil || m.oldValue == nil {
  11469. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  11470. }
  11471. oldValue, err := m.oldValue(ctx)
  11472. if err != nil {
  11473. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  11474. }
  11475. return oldValue.Headimg, nil
  11476. }
  11477. // ResetHeadimg resets all changes to the "headimg" field.
  11478. func (m *ContactMutation) ResetHeadimg() {
  11479. m.headimg = nil
  11480. }
  11481. // SetSex sets the "sex" field.
  11482. func (m *ContactMutation) SetSex(i int) {
  11483. m.sex = &i
  11484. m.addsex = nil
  11485. }
  11486. // Sex returns the value of the "sex" field in the mutation.
  11487. func (m *ContactMutation) Sex() (r int, exists bool) {
  11488. v := m.sex
  11489. if v == nil {
  11490. return
  11491. }
  11492. return *v, true
  11493. }
  11494. // OldSex returns the old "sex" field's value of the Contact entity.
  11495. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11496. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11497. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  11498. if !m.op.Is(OpUpdateOne) {
  11499. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  11500. }
  11501. if m.id == nil || m.oldValue == nil {
  11502. return v, errors.New("OldSex requires an ID field in the mutation")
  11503. }
  11504. oldValue, err := m.oldValue(ctx)
  11505. if err != nil {
  11506. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  11507. }
  11508. return oldValue.Sex, nil
  11509. }
  11510. // AddSex adds i to the "sex" field.
  11511. func (m *ContactMutation) AddSex(i int) {
  11512. if m.addsex != nil {
  11513. *m.addsex += i
  11514. } else {
  11515. m.addsex = &i
  11516. }
  11517. }
  11518. // AddedSex returns the value that was added to the "sex" field in this mutation.
  11519. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  11520. v := m.addsex
  11521. if v == nil {
  11522. return
  11523. }
  11524. return *v, true
  11525. }
  11526. // ResetSex resets all changes to the "sex" field.
  11527. func (m *ContactMutation) ResetSex() {
  11528. m.sex = nil
  11529. m.addsex = nil
  11530. }
  11531. // SetStarrole sets the "starrole" field.
  11532. func (m *ContactMutation) SetStarrole(s string) {
  11533. m.starrole = &s
  11534. }
  11535. // Starrole returns the value of the "starrole" field in the mutation.
  11536. func (m *ContactMutation) Starrole() (r string, exists bool) {
  11537. v := m.starrole
  11538. if v == nil {
  11539. return
  11540. }
  11541. return *v, true
  11542. }
  11543. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  11544. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11545. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11546. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  11547. if !m.op.Is(OpUpdateOne) {
  11548. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  11549. }
  11550. if m.id == nil || m.oldValue == nil {
  11551. return v, errors.New("OldStarrole requires an ID field in the mutation")
  11552. }
  11553. oldValue, err := m.oldValue(ctx)
  11554. if err != nil {
  11555. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  11556. }
  11557. return oldValue.Starrole, nil
  11558. }
  11559. // ResetStarrole resets all changes to the "starrole" field.
  11560. func (m *ContactMutation) ResetStarrole() {
  11561. m.starrole = nil
  11562. }
  11563. // SetDontseeit sets the "dontseeit" field.
  11564. func (m *ContactMutation) SetDontseeit(i int) {
  11565. m.dontseeit = &i
  11566. m.adddontseeit = nil
  11567. }
  11568. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  11569. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  11570. v := m.dontseeit
  11571. if v == nil {
  11572. return
  11573. }
  11574. return *v, true
  11575. }
  11576. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  11577. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11578. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11579. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  11580. if !m.op.Is(OpUpdateOne) {
  11581. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  11582. }
  11583. if m.id == nil || m.oldValue == nil {
  11584. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  11585. }
  11586. oldValue, err := m.oldValue(ctx)
  11587. if err != nil {
  11588. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  11589. }
  11590. return oldValue.Dontseeit, nil
  11591. }
  11592. // AddDontseeit adds i to the "dontseeit" field.
  11593. func (m *ContactMutation) AddDontseeit(i int) {
  11594. if m.adddontseeit != nil {
  11595. *m.adddontseeit += i
  11596. } else {
  11597. m.adddontseeit = &i
  11598. }
  11599. }
  11600. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  11601. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  11602. v := m.adddontseeit
  11603. if v == nil {
  11604. return
  11605. }
  11606. return *v, true
  11607. }
  11608. // ResetDontseeit resets all changes to the "dontseeit" field.
  11609. func (m *ContactMutation) ResetDontseeit() {
  11610. m.dontseeit = nil
  11611. m.adddontseeit = nil
  11612. }
  11613. // SetDontseeme sets the "dontseeme" field.
  11614. func (m *ContactMutation) SetDontseeme(i int) {
  11615. m.dontseeme = &i
  11616. m.adddontseeme = nil
  11617. }
  11618. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  11619. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  11620. v := m.dontseeme
  11621. if v == nil {
  11622. return
  11623. }
  11624. return *v, true
  11625. }
  11626. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  11627. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11628. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11629. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  11630. if !m.op.Is(OpUpdateOne) {
  11631. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  11632. }
  11633. if m.id == nil || m.oldValue == nil {
  11634. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  11635. }
  11636. oldValue, err := m.oldValue(ctx)
  11637. if err != nil {
  11638. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  11639. }
  11640. return oldValue.Dontseeme, nil
  11641. }
  11642. // AddDontseeme adds i to the "dontseeme" field.
  11643. func (m *ContactMutation) AddDontseeme(i int) {
  11644. if m.adddontseeme != nil {
  11645. *m.adddontseeme += i
  11646. } else {
  11647. m.adddontseeme = &i
  11648. }
  11649. }
  11650. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  11651. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  11652. v := m.adddontseeme
  11653. if v == nil {
  11654. return
  11655. }
  11656. return *v, true
  11657. }
  11658. // ResetDontseeme resets all changes to the "dontseeme" field.
  11659. func (m *ContactMutation) ResetDontseeme() {
  11660. m.dontseeme = nil
  11661. m.adddontseeme = nil
  11662. }
  11663. // SetLag sets the "lag" field.
  11664. func (m *ContactMutation) SetLag(s string) {
  11665. m.lag = &s
  11666. }
  11667. // Lag returns the value of the "lag" field in the mutation.
  11668. func (m *ContactMutation) Lag() (r string, exists bool) {
  11669. v := m.lag
  11670. if v == nil {
  11671. return
  11672. }
  11673. return *v, true
  11674. }
  11675. // OldLag returns the old "lag" field's value of the Contact entity.
  11676. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11677. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11678. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  11679. if !m.op.Is(OpUpdateOne) {
  11680. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  11681. }
  11682. if m.id == nil || m.oldValue == nil {
  11683. return v, errors.New("OldLag requires an ID field in the mutation")
  11684. }
  11685. oldValue, err := m.oldValue(ctx)
  11686. if err != nil {
  11687. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  11688. }
  11689. return oldValue.Lag, nil
  11690. }
  11691. // ResetLag resets all changes to the "lag" field.
  11692. func (m *ContactMutation) ResetLag() {
  11693. m.lag = nil
  11694. }
  11695. // SetGid sets the "gid" field.
  11696. func (m *ContactMutation) SetGid(s string) {
  11697. m.gid = &s
  11698. }
  11699. // Gid returns the value of the "gid" field in the mutation.
  11700. func (m *ContactMutation) Gid() (r string, exists bool) {
  11701. v := m.gid
  11702. if v == nil {
  11703. return
  11704. }
  11705. return *v, true
  11706. }
  11707. // OldGid returns the old "gid" field's value of the Contact entity.
  11708. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11709. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11710. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  11711. if !m.op.Is(OpUpdateOne) {
  11712. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  11713. }
  11714. if m.id == nil || m.oldValue == nil {
  11715. return v, errors.New("OldGid requires an ID field in the mutation")
  11716. }
  11717. oldValue, err := m.oldValue(ctx)
  11718. if err != nil {
  11719. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  11720. }
  11721. return oldValue.Gid, nil
  11722. }
  11723. // ResetGid resets all changes to the "gid" field.
  11724. func (m *ContactMutation) ResetGid() {
  11725. m.gid = nil
  11726. }
  11727. // SetGname sets the "gname" field.
  11728. func (m *ContactMutation) SetGname(s string) {
  11729. m.gname = &s
  11730. }
  11731. // Gname returns the value of the "gname" field in the mutation.
  11732. func (m *ContactMutation) Gname() (r string, exists bool) {
  11733. v := m.gname
  11734. if v == nil {
  11735. return
  11736. }
  11737. return *v, true
  11738. }
  11739. // OldGname returns the old "gname" field's value of the Contact entity.
  11740. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11741. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11742. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  11743. if !m.op.Is(OpUpdateOne) {
  11744. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  11745. }
  11746. if m.id == nil || m.oldValue == nil {
  11747. return v, errors.New("OldGname requires an ID field in the mutation")
  11748. }
  11749. oldValue, err := m.oldValue(ctx)
  11750. if err != nil {
  11751. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  11752. }
  11753. return oldValue.Gname, nil
  11754. }
  11755. // ResetGname resets all changes to the "gname" field.
  11756. func (m *ContactMutation) ResetGname() {
  11757. m.gname = nil
  11758. }
  11759. // SetV3 sets the "v3" field.
  11760. func (m *ContactMutation) SetV3(s string) {
  11761. m.v3 = &s
  11762. }
  11763. // V3 returns the value of the "v3" field in the mutation.
  11764. func (m *ContactMutation) V3() (r string, exists bool) {
  11765. v := m.v3
  11766. if v == nil {
  11767. return
  11768. }
  11769. return *v, true
  11770. }
  11771. // OldV3 returns the old "v3" field's value of the Contact entity.
  11772. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11773. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11774. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  11775. if !m.op.Is(OpUpdateOne) {
  11776. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  11777. }
  11778. if m.id == nil || m.oldValue == nil {
  11779. return v, errors.New("OldV3 requires an ID field in the mutation")
  11780. }
  11781. oldValue, err := m.oldValue(ctx)
  11782. if err != nil {
  11783. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  11784. }
  11785. return oldValue.V3, nil
  11786. }
  11787. // ResetV3 resets all changes to the "v3" field.
  11788. func (m *ContactMutation) ResetV3() {
  11789. m.v3 = nil
  11790. }
  11791. // SetOrganizationID sets the "organization_id" field.
  11792. func (m *ContactMutation) SetOrganizationID(u uint64) {
  11793. m.organization_id = &u
  11794. m.addorganization_id = nil
  11795. }
  11796. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11797. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  11798. v := m.organization_id
  11799. if v == nil {
  11800. return
  11801. }
  11802. return *v, true
  11803. }
  11804. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  11805. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11807. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11808. if !m.op.Is(OpUpdateOne) {
  11809. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11810. }
  11811. if m.id == nil || m.oldValue == nil {
  11812. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11813. }
  11814. oldValue, err := m.oldValue(ctx)
  11815. if err != nil {
  11816. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11817. }
  11818. return oldValue.OrganizationID, nil
  11819. }
  11820. // AddOrganizationID adds u to the "organization_id" field.
  11821. func (m *ContactMutation) AddOrganizationID(u int64) {
  11822. if m.addorganization_id != nil {
  11823. *m.addorganization_id += u
  11824. } else {
  11825. m.addorganization_id = &u
  11826. }
  11827. }
  11828. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11829. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  11830. v := m.addorganization_id
  11831. if v == nil {
  11832. return
  11833. }
  11834. return *v, true
  11835. }
  11836. // ClearOrganizationID clears the value of the "organization_id" field.
  11837. func (m *ContactMutation) ClearOrganizationID() {
  11838. m.organization_id = nil
  11839. m.addorganization_id = nil
  11840. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  11841. }
  11842. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  11843. func (m *ContactMutation) OrganizationIDCleared() bool {
  11844. _, ok := m.clearedFields[contact.FieldOrganizationID]
  11845. return ok
  11846. }
  11847. // ResetOrganizationID resets all changes to the "organization_id" field.
  11848. func (m *ContactMutation) ResetOrganizationID() {
  11849. m.organization_id = nil
  11850. m.addorganization_id = nil
  11851. delete(m.clearedFields, contact.FieldOrganizationID)
  11852. }
  11853. // SetCtype sets the "ctype" field.
  11854. func (m *ContactMutation) SetCtype(u uint64) {
  11855. m.ctype = &u
  11856. m.addctype = nil
  11857. }
  11858. // Ctype returns the value of the "ctype" field in the mutation.
  11859. func (m *ContactMutation) Ctype() (r uint64, exists bool) {
  11860. v := m.ctype
  11861. if v == nil {
  11862. return
  11863. }
  11864. return *v, true
  11865. }
  11866. // OldCtype returns the old "ctype" field's value of the Contact entity.
  11867. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11868. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11869. func (m *ContactMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  11870. if !m.op.Is(OpUpdateOne) {
  11871. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  11872. }
  11873. if m.id == nil || m.oldValue == nil {
  11874. return v, errors.New("OldCtype requires an ID field in the mutation")
  11875. }
  11876. oldValue, err := m.oldValue(ctx)
  11877. if err != nil {
  11878. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  11879. }
  11880. return oldValue.Ctype, nil
  11881. }
  11882. // AddCtype adds u to the "ctype" field.
  11883. func (m *ContactMutation) AddCtype(u int64) {
  11884. if m.addctype != nil {
  11885. *m.addctype += u
  11886. } else {
  11887. m.addctype = &u
  11888. }
  11889. }
  11890. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  11891. func (m *ContactMutation) AddedCtype() (r int64, exists bool) {
  11892. v := m.addctype
  11893. if v == nil {
  11894. return
  11895. }
  11896. return *v, true
  11897. }
  11898. // ResetCtype resets all changes to the "ctype" field.
  11899. func (m *ContactMutation) ResetCtype() {
  11900. m.ctype = nil
  11901. m.addctype = nil
  11902. }
  11903. // SetCage sets the "cage" field.
  11904. func (m *ContactMutation) SetCage(i int) {
  11905. m.cage = &i
  11906. m.addcage = nil
  11907. }
  11908. // Cage returns the value of the "cage" field in the mutation.
  11909. func (m *ContactMutation) Cage() (r int, exists bool) {
  11910. v := m.cage
  11911. if v == nil {
  11912. return
  11913. }
  11914. return *v, true
  11915. }
  11916. // OldCage returns the old "cage" field's value of the Contact entity.
  11917. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11918. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11919. func (m *ContactMutation) OldCage(ctx context.Context) (v int, err error) {
  11920. if !m.op.Is(OpUpdateOne) {
  11921. return v, errors.New("OldCage is only allowed on UpdateOne operations")
  11922. }
  11923. if m.id == nil || m.oldValue == nil {
  11924. return v, errors.New("OldCage requires an ID field in the mutation")
  11925. }
  11926. oldValue, err := m.oldValue(ctx)
  11927. if err != nil {
  11928. return v, fmt.Errorf("querying old value for OldCage: %w", err)
  11929. }
  11930. return oldValue.Cage, nil
  11931. }
  11932. // AddCage adds i to the "cage" field.
  11933. func (m *ContactMutation) AddCage(i int) {
  11934. if m.addcage != nil {
  11935. *m.addcage += i
  11936. } else {
  11937. m.addcage = &i
  11938. }
  11939. }
  11940. // AddedCage returns the value that was added to the "cage" field in this mutation.
  11941. func (m *ContactMutation) AddedCage() (r int, exists bool) {
  11942. v := m.addcage
  11943. if v == nil {
  11944. return
  11945. }
  11946. return *v, true
  11947. }
  11948. // ResetCage resets all changes to the "cage" field.
  11949. func (m *ContactMutation) ResetCage() {
  11950. m.cage = nil
  11951. m.addcage = nil
  11952. }
  11953. // SetCname sets the "cname" field.
  11954. func (m *ContactMutation) SetCname(s string) {
  11955. m.cname = &s
  11956. }
  11957. // Cname returns the value of the "cname" field in the mutation.
  11958. func (m *ContactMutation) Cname() (r string, exists bool) {
  11959. v := m.cname
  11960. if v == nil {
  11961. return
  11962. }
  11963. return *v, true
  11964. }
  11965. // OldCname returns the old "cname" field's value of the Contact entity.
  11966. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11967. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11968. func (m *ContactMutation) OldCname(ctx context.Context) (v string, err error) {
  11969. if !m.op.Is(OpUpdateOne) {
  11970. return v, errors.New("OldCname is only allowed on UpdateOne operations")
  11971. }
  11972. if m.id == nil || m.oldValue == nil {
  11973. return v, errors.New("OldCname requires an ID field in the mutation")
  11974. }
  11975. oldValue, err := m.oldValue(ctx)
  11976. if err != nil {
  11977. return v, fmt.Errorf("querying old value for OldCname: %w", err)
  11978. }
  11979. return oldValue.Cname, nil
  11980. }
  11981. // ResetCname resets all changes to the "cname" field.
  11982. func (m *ContactMutation) ResetCname() {
  11983. m.cname = nil
  11984. }
  11985. // SetCarea sets the "carea" field.
  11986. func (m *ContactMutation) SetCarea(s string) {
  11987. m.carea = &s
  11988. }
  11989. // Carea returns the value of the "carea" field in the mutation.
  11990. func (m *ContactMutation) Carea() (r string, exists bool) {
  11991. v := m.carea
  11992. if v == nil {
  11993. return
  11994. }
  11995. return *v, true
  11996. }
  11997. // OldCarea returns the old "carea" field's value of the Contact entity.
  11998. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11999. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12000. func (m *ContactMutation) OldCarea(ctx context.Context) (v string, err error) {
  12001. if !m.op.Is(OpUpdateOne) {
  12002. return v, errors.New("OldCarea is only allowed on UpdateOne operations")
  12003. }
  12004. if m.id == nil || m.oldValue == nil {
  12005. return v, errors.New("OldCarea requires an ID field in the mutation")
  12006. }
  12007. oldValue, err := m.oldValue(ctx)
  12008. if err != nil {
  12009. return v, fmt.Errorf("querying old value for OldCarea: %w", err)
  12010. }
  12011. return oldValue.Carea, nil
  12012. }
  12013. // ResetCarea resets all changes to the "carea" field.
  12014. func (m *ContactMutation) ResetCarea() {
  12015. m.carea = nil
  12016. }
  12017. // SetCbirthday sets the "cbirthday" field.
  12018. func (m *ContactMutation) SetCbirthday(s string) {
  12019. m.cbirthday = &s
  12020. }
  12021. // Cbirthday returns the value of the "cbirthday" field in the mutation.
  12022. func (m *ContactMutation) Cbirthday() (r string, exists bool) {
  12023. v := m.cbirthday
  12024. if v == nil {
  12025. return
  12026. }
  12027. return *v, true
  12028. }
  12029. // OldCbirthday returns the old "cbirthday" field's value of the Contact entity.
  12030. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12031. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12032. func (m *ContactMutation) OldCbirthday(ctx context.Context) (v string, err error) {
  12033. if !m.op.Is(OpUpdateOne) {
  12034. return v, errors.New("OldCbirthday is only allowed on UpdateOne operations")
  12035. }
  12036. if m.id == nil || m.oldValue == nil {
  12037. return v, errors.New("OldCbirthday requires an ID field in the mutation")
  12038. }
  12039. oldValue, err := m.oldValue(ctx)
  12040. if err != nil {
  12041. return v, fmt.Errorf("querying old value for OldCbirthday: %w", err)
  12042. }
  12043. return oldValue.Cbirthday, nil
  12044. }
  12045. // ResetCbirthday resets all changes to the "cbirthday" field.
  12046. func (m *ContactMutation) ResetCbirthday() {
  12047. m.cbirthday = nil
  12048. }
  12049. // SetCbirtharea sets the "cbirtharea" field.
  12050. func (m *ContactMutation) SetCbirtharea(s string) {
  12051. m.cbirtharea = &s
  12052. }
  12053. // Cbirtharea returns the value of the "cbirtharea" field in the mutation.
  12054. func (m *ContactMutation) Cbirtharea() (r string, exists bool) {
  12055. v := m.cbirtharea
  12056. if v == nil {
  12057. return
  12058. }
  12059. return *v, true
  12060. }
  12061. // OldCbirtharea returns the old "cbirtharea" field's value of the Contact entity.
  12062. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12063. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12064. func (m *ContactMutation) OldCbirtharea(ctx context.Context) (v string, err error) {
  12065. if !m.op.Is(OpUpdateOne) {
  12066. return v, errors.New("OldCbirtharea is only allowed on UpdateOne operations")
  12067. }
  12068. if m.id == nil || m.oldValue == nil {
  12069. return v, errors.New("OldCbirtharea requires an ID field in the mutation")
  12070. }
  12071. oldValue, err := m.oldValue(ctx)
  12072. if err != nil {
  12073. return v, fmt.Errorf("querying old value for OldCbirtharea: %w", err)
  12074. }
  12075. return oldValue.Cbirtharea, nil
  12076. }
  12077. // ResetCbirtharea resets all changes to the "cbirtharea" field.
  12078. func (m *ContactMutation) ResetCbirtharea() {
  12079. m.cbirtharea = nil
  12080. }
  12081. // SetCidcardNo sets the "cidcard_no" field.
  12082. func (m *ContactMutation) SetCidcardNo(s string) {
  12083. m.cidcard_no = &s
  12084. }
  12085. // CidcardNo returns the value of the "cidcard_no" field in the mutation.
  12086. func (m *ContactMutation) CidcardNo() (r string, exists bool) {
  12087. v := m.cidcard_no
  12088. if v == nil {
  12089. return
  12090. }
  12091. return *v, true
  12092. }
  12093. // OldCidcardNo returns the old "cidcard_no" field's value of the Contact entity.
  12094. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12095. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12096. func (m *ContactMutation) OldCidcardNo(ctx context.Context) (v string, err error) {
  12097. if !m.op.Is(OpUpdateOne) {
  12098. return v, errors.New("OldCidcardNo is only allowed on UpdateOne operations")
  12099. }
  12100. if m.id == nil || m.oldValue == nil {
  12101. return v, errors.New("OldCidcardNo requires an ID field in the mutation")
  12102. }
  12103. oldValue, err := m.oldValue(ctx)
  12104. if err != nil {
  12105. return v, fmt.Errorf("querying old value for OldCidcardNo: %w", err)
  12106. }
  12107. return oldValue.CidcardNo, nil
  12108. }
  12109. // ResetCidcardNo resets all changes to the "cidcard_no" field.
  12110. func (m *ContactMutation) ResetCidcardNo() {
  12111. m.cidcard_no = nil
  12112. }
  12113. // SetCtitle sets the "ctitle" field.
  12114. func (m *ContactMutation) SetCtitle(s string) {
  12115. m.ctitle = &s
  12116. }
  12117. // Ctitle returns the value of the "ctitle" field in the mutation.
  12118. func (m *ContactMutation) Ctitle() (r string, exists bool) {
  12119. v := m.ctitle
  12120. if v == nil {
  12121. return
  12122. }
  12123. return *v, true
  12124. }
  12125. // OldCtitle returns the old "ctitle" field's value of the Contact entity.
  12126. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12127. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12128. func (m *ContactMutation) OldCtitle(ctx context.Context) (v string, err error) {
  12129. if !m.op.Is(OpUpdateOne) {
  12130. return v, errors.New("OldCtitle is only allowed on UpdateOne operations")
  12131. }
  12132. if m.id == nil || m.oldValue == nil {
  12133. return v, errors.New("OldCtitle requires an ID field in the mutation")
  12134. }
  12135. oldValue, err := m.oldValue(ctx)
  12136. if err != nil {
  12137. return v, fmt.Errorf("querying old value for OldCtitle: %w", err)
  12138. }
  12139. return oldValue.Ctitle, nil
  12140. }
  12141. // ResetCtitle resets all changes to the "ctitle" field.
  12142. func (m *ContactMutation) ResetCtitle() {
  12143. m.ctitle = nil
  12144. }
  12145. // SetCc sets the "cc" field.
  12146. func (m *ContactMutation) SetCc(s string) {
  12147. m.cc = &s
  12148. }
  12149. // Cc returns the value of the "cc" field in the mutation.
  12150. func (m *ContactMutation) Cc() (r string, exists bool) {
  12151. v := m.cc
  12152. if v == nil {
  12153. return
  12154. }
  12155. return *v, true
  12156. }
  12157. // OldCc returns the old "cc" field's value of the Contact entity.
  12158. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12159. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12160. func (m *ContactMutation) OldCc(ctx context.Context) (v string, err error) {
  12161. if !m.op.Is(OpUpdateOne) {
  12162. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  12163. }
  12164. if m.id == nil || m.oldValue == nil {
  12165. return v, errors.New("OldCc requires an ID field in the mutation")
  12166. }
  12167. oldValue, err := m.oldValue(ctx)
  12168. if err != nil {
  12169. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  12170. }
  12171. return oldValue.Cc, nil
  12172. }
  12173. // ResetCc resets all changes to the "cc" field.
  12174. func (m *ContactMutation) ResetCc() {
  12175. m.cc = nil
  12176. }
  12177. // SetPhone sets the "phone" field.
  12178. func (m *ContactMutation) SetPhone(s string) {
  12179. m.phone = &s
  12180. }
  12181. // Phone returns the value of the "phone" field in the mutation.
  12182. func (m *ContactMutation) Phone() (r string, exists bool) {
  12183. v := m.phone
  12184. if v == nil {
  12185. return
  12186. }
  12187. return *v, true
  12188. }
  12189. // OldPhone returns the old "phone" field's value of the Contact entity.
  12190. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12191. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12192. func (m *ContactMutation) OldPhone(ctx context.Context) (v string, err error) {
  12193. if !m.op.Is(OpUpdateOne) {
  12194. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  12195. }
  12196. if m.id == nil || m.oldValue == nil {
  12197. return v, errors.New("OldPhone requires an ID field in the mutation")
  12198. }
  12199. oldValue, err := m.oldValue(ctx)
  12200. if err != nil {
  12201. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  12202. }
  12203. return oldValue.Phone, nil
  12204. }
  12205. // ResetPhone resets all changes to the "phone" field.
  12206. func (m *ContactMutation) ResetPhone() {
  12207. m.phone = nil
  12208. }
  12209. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  12210. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  12211. if m.contact_relationships == nil {
  12212. m.contact_relationships = make(map[uint64]struct{})
  12213. }
  12214. for i := range ids {
  12215. m.contact_relationships[ids[i]] = struct{}{}
  12216. }
  12217. }
  12218. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  12219. func (m *ContactMutation) ClearContactRelationships() {
  12220. m.clearedcontact_relationships = true
  12221. }
  12222. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  12223. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  12224. return m.clearedcontact_relationships
  12225. }
  12226. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  12227. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  12228. if m.removedcontact_relationships == nil {
  12229. m.removedcontact_relationships = make(map[uint64]struct{})
  12230. }
  12231. for i := range ids {
  12232. delete(m.contact_relationships, ids[i])
  12233. m.removedcontact_relationships[ids[i]] = struct{}{}
  12234. }
  12235. }
  12236. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  12237. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  12238. for id := range m.removedcontact_relationships {
  12239. ids = append(ids, id)
  12240. }
  12241. return
  12242. }
  12243. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  12244. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  12245. for id := range m.contact_relationships {
  12246. ids = append(ids, id)
  12247. }
  12248. return
  12249. }
  12250. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  12251. func (m *ContactMutation) ResetContactRelationships() {
  12252. m.contact_relationships = nil
  12253. m.clearedcontact_relationships = false
  12254. m.removedcontact_relationships = nil
  12255. }
  12256. // AddContactFieldIDs adds the "contact_fields" edge to the ContactField entity by ids.
  12257. func (m *ContactMutation) AddContactFieldIDs(ids ...uint64) {
  12258. if m.contact_fields == nil {
  12259. m.contact_fields = make(map[uint64]struct{})
  12260. }
  12261. for i := range ids {
  12262. m.contact_fields[ids[i]] = struct{}{}
  12263. }
  12264. }
  12265. // ClearContactFields clears the "contact_fields" edge to the ContactField entity.
  12266. func (m *ContactMutation) ClearContactFields() {
  12267. m.clearedcontact_fields = true
  12268. }
  12269. // ContactFieldsCleared reports if the "contact_fields" edge to the ContactField entity was cleared.
  12270. func (m *ContactMutation) ContactFieldsCleared() bool {
  12271. return m.clearedcontact_fields
  12272. }
  12273. // RemoveContactFieldIDs removes the "contact_fields" edge to the ContactField entity by IDs.
  12274. func (m *ContactMutation) RemoveContactFieldIDs(ids ...uint64) {
  12275. if m.removedcontact_fields == nil {
  12276. m.removedcontact_fields = make(map[uint64]struct{})
  12277. }
  12278. for i := range ids {
  12279. delete(m.contact_fields, ids[i])
  12280. m.removedcontact_fields[ids[i]] = struct{}{}
  12281. }
  12282. }
  12283. // RemovedContactFields returns the removed IDs of the "contact_fields" edge to the ContactField entity.
  12284. func (m *ContactMutation) RemovedContactFieldsIDs() (ids []uint64) {
  12285. for id := range m.removedcontact_fields {
  12286. ids = append(ids, id)
  12287. }
  12288. return
  12289. }
  12290. // ContactFieldsIDs returns the "contact_fields" edge IDs in the mutation.
  12291. func (m *ContactMutation) ContactFieldsIDs() (ids []uint64) {
  12292. for id := range m.contact_fields {
  12293. ids = append(ids, id)
  12294. }
  12295. return
  12296. }
  12297. // ResetContactFields resets all changes to the "contact_fields" edge.
  12298. func (m *ContactMutation) ResetContactFields() {
  12299. m.contact_fields = nil
  12300. m.clearedcontact_fields = false
  12301. m.removedcontact_fields = nil
  12302. }
  12303. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  12304. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  12305. if m.contact_messages == nil {
  12306. m.contact_messages = make(map[uint64]struct{})
  12307. }
  12308. for i := range ids {
  12309. m.contact_messages[ids[i]] = struct{}{}
  12310. }
  12311. }
  12312. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  12313. func (m *ContactMutation) ClearContactMessages() {
  12314. m.clearedcontact_messages = true
  12315. }
  12316. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  12317. func (m *ContactMutation) ContactMessagesCleared() bool {
  12318. return m.clearedcontact_messages
  12319. }
  12320. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  12321. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  12322. if m.removedcontact_messages == nil {
  12323. m.removedcontact_messages = make(map[uint64]struct{})
  12324. }
  12325. for i := range ids {
  12326. delete(m.contact_messages, ids[i])
  12327. m.removedcontact_messages[ids[i]] = struct{}{}
  12328. }
  12329. }
  12330. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  12331. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  12332. for id := range m.removedcontact_messages {
  12333. ids = append(ids, id)
  12334. }
  12335. return
  12336. }
  12337. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  12338. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  12339. for id := range m.contact_messages {
  12340. ids = append(ids, id)
  12341. }
  12342. return
  12343. }
  12344. // ResetContactMessages resets all changes to the "contact_messages" edge.
  12345. func (m *ContactMutation) ResetContactMessages() {
  12346. m.contact_messages = nil
  12347. m.clearedcontact_messages = false
  12348. m.removedcontact_messages = nil
  12349. }
  12350. // Where appends a list predicates to the ContactMutation builder.
  12351. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  12352. m.predicates = append(m.predicates, ps...)
  12353. }
  12354. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  12355. // users can use type-assertion to append predicates that do not depend on any generated package.
  12356. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  12357. p := make([]predicate.Contact, len(ps))
  12358. for i := range ps {
  12359. p[i] = ps[i]
  12360. }
  12361. m.Where(p...)
  12362. }
  12363. // Op returns the operation name.
  12364. func (m *ContactMutation) Op() Op {
  12365. return m.op
  12366. }
  12367. // SetOp allows setting the mutation operation.
  12368. func (m *ContactMutation) SetOp(op Op) {
  12369. m.op = op
  12370. }
  12371. // Type returns the node type of this mutation (Contact).
  12372. func (m *ContactMutation) Type() string {
  12373. return m.typ
  12374. }
  12375. // Fields returns all fields that were changed during this mutation. Note that in
  12376. // order to get all numeric fields that were incremented/decremented, call
  12377. // AddedFields().
  12378. func (m *ContactMutation) Fields() []string {
  12379. fields := make([]string, 0, 30)
  12380. if m.created_at != nil {
  12381. fields = append(fields, contact.FieldCreatedAt)
  12382. }
  12383. if m.updated_at != nil {
  12384. fields = append(fields, contact.FieldUpdatedAt)
  12385. }
  12386. if m.status != nil {
  12387. fields = append(fields, contact.FieldStatus)
  12388. }
  12389. if m.deleted_at != nil {
  12390. fields = append(fields, contact.FieldDeletedAt)
  12391. }
  12392. if m.wx_wxid != nil {
  12393. fields = append(fields, contact.FieldWxWxid)
  12394. }
  12395. if m._type != nil {
  12396. fields = append(fields, contact.FieldType)
  12397. }
  12398. if m.wxid != nil {
  12399. fields = append(fields, contact.FieldWxid)
  12400. }
  12401. if m.account != nil {
  12402. fields = append(fields, contact.FieldAccount)
  12403. }
  12404. if m.nickname != nil {
  12405. fields = append(fields, contact.FieldNickname)
  12406. }
  12407. if m.markname != nil {
  12408. fields = append(fields, contact.FieldMarkname)
  12409. }
  12410. if m.headimg != nil {
  12411. fields = append(fields, contact.FieldHeadimg)
  12412. }
  12413. if m.sex != nil {
  12414. fields = append(fields, contact.FieldSex)
  12415. }
  12416. if m.starrole != nil {
  12417. fields = append(fields, contact.FieldStarrole)
  12418. }
  12419. if m.dontseeit != nil {
  12420. fields = append(fields, contact.FieldDontseeit)
  12421. }
  12422. if m.dontseeme != nil {
  12423. fields = append(fields, contact.FieldDontseeme)
  12424. }
  12425. if m.lag != nil {
  12426. fields = append(fields, contact.FieldLag)
  12427. }
  12428. if m.gid != nil {
  12429. fields = append(fields, contact.FieldGid)
  12430. }
  12431. if m.gname != nil {
  12432. fields = append(fields, contact.FieldGname)
  12433. }
  12434. if m.v3 != nil {
  12435. fields = append(fields, contact.FieldV3)
  12436. }
  12437. if m.organization_id != nil {
  12438. fields = append(fields, contact.FieldOrganizationID)
  12439. }
  12440. if m.ctype != nil {
  12441. fields = append(fields, contact.FieldCtype)
  12442. }
  12443. if m.cage != nil {
  12444. fields = append(fields, contact.FieldCage)
  12445. }
  12446. if m.cname != nil {
  12447. fields = append(fields, contact.FieldCname)
  12448. }
  12449. if m.carea != nil {
  12450. fields = append(fields, contact.FieldCarea)
  12451. }
  12452. if m.cbirthday != nil {
  12453. fields = append(fields, contact.FieldCbirthday)
  12454. }
  12455. if m.cbirtharea != nil {
  12456. fields = append(fields, contact.FieldCbirtharea)
  12457. }
  12458. if m.cidcard_no != nil {
  12459. fields = append(fields, contact.FieldCidcardNo)
  12460. }
  12461. if m.ctitle != nil {
  12462. fields = append(fields, contact.FieldCtitle)
  12463. }
  12464. if m.cc != nil {
  12465. fields = append(fields, contact.FieldCc)
  12466. }
  12467. if m.phone != nil {
  12468. fields = append(fields, contact.FieldPhone)
  12469. }
  12470. return fields
  12471. }
  12472. // Field returns the value of a field with the given name. The second boolean
  12473. // return value indicates that this field was not set, or was not defined in the
  12474. // schema.
  12475. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  12476. switch name {
  12477. case contact.FieldCreatedAt:
  12478. return m.CreatedAt()
  12479. case contact.FieldUpdatedAt:
  12480. return m.UpdatedAt()
  12481. case contact.FieldStatus:
  12482. return m.Status()
  12483. case contact.FieldDeletedAt:
  12484. return m.DeletedAt()
  12485. case contact.FieldWxWxid:
  12486. return m.WxWxid()
  12487. case contact.FieldType:
  12488. return m.GetType()
  12489. case contact.FieldWxid:
  12490. return m.Wxid()
  12491. case contact.FieldAccount:
  12492. return m.Account()
  12493. case contact.FieldNickname:
  12494. return m.Nickname()
  12495. case contact.FieldMarkname:
  12496. return m.Markname()
  12497. case contact.FieldHeadimg:
  12498. return m.Headimg()
  12499. case contact.FieldSex:
  12500. return m.Sex()
  12501. case contact.FieldStarrole:
  12502. return m.Starrole()
  12503. case contact.FieldDontseeit:
  12504. return m.Dontseeit()
  12505. case contact.FieldDontseeme:
  12506. return m.Dontseeme()
  12507. case contact.FieldLag:
  12508. return m.Lag()
  12509. case contact.FieldGid:
  12510. return m.Gid()
  12511. case contact.FieldGname:
  12512. return m.Gname()
  12513. case contact.FieldV3:
  12514. return m.V3()
  12515. case contact.FieldOrganizationID:
  12516. return m.OrganizationID()
  12517. case contact.FieldCtype:
  12518. return m.Ctype()
  12519. case contact.FieldCage:
  12520. return m.Cage()
  12521. case contact.FieldCname:
  12522. return m.Cname()
  12523. case contact.FieldCarea:
  12524. return m.Carea()
  12525. case contact.FieldCbirthday:
  12526. return m.Cbirthday()
  12527. case contact.FieldCbirtharea:
  12528. return m.Cbirtharea()
  12529. case contact.FieldCidcardNo:
  12530. return m.CidcardNo()
  12531. case contact.FieldCtitle:
  12532. return m.Ctitle()
  12533. case contact.FieldCc:
  12534. return m.Cc()
  12535. case contact.FieldPhone:
  12536. return m.Phone()
  12537. }
  12538. return nil, false
  12539. }
  12540. // OldField returns the old value of the field from the database. An error is
  12541. // returned if the mutation operation is not UpdateOne, or the query to the
  12542. // database failed.
  12543. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12544. switch name {
  12545. case contact.FieldCreatedAt:
  12546. return m.OldCreatedAt(ctx)
  12547. case contact.FieldUpdatedAt:
  12548. return m.OldUpdatedAt(ctx)
  12549. case contact.FieldStatus:
  12550. return m.OldStatus(ctx)
  12551. case contact.FieldDeletedAt:
  12552. return m.OldDeletedAt(ctx)
  12553. case contact.FieldWxWxid:
  12554. return m.OldWxWxid(ctx)
  12555. case contact.FieldType:
  12556. return m.OldType(ctx)
  12557. case contact.FieldWxid:
  12558. return m.OldWxid(ctx)
  12559. case contact.FieldAccount:
  12560. return m.OldAccount(ctx)
  12561. case contact.FieldNickname:
  12562. return m.OldNickname(ctx)
  12563. case contact.FieldMarkname:
  12564. return m.OldMarkname(ctx)
  12565. case contact.FieldHeadimg:
  12566. return m.OldHeadimg(ctx)
  12567. case contact.FieldSex:
  12568. return m.OldSex(ctx)
  12569. case contact.FieldStarrole:
  12570. return m.OldStarrole(ctx)
  12571. case contact.FieldDontseeit:
  12572. return m.OldDontseeit(ctx)
  12573. case contact.FieldDontseeme:
  12574. return m.OldDontseeme(ctx)
  12575. case contact.FieldLag:
  12576. return m.OldLag(ctx)
  12577. case contact.FieldGid:
  12578. return m.OldGid(ctx)
  12579. case contact.FieldGname:
  12580. return m.OldGname(ctx)
  12581. case contact.FieldV3:
  12582. return m.OldV3(ctx)
  12583. case contact.FieldOrganizationID:
  12584. return m.OldOrganizationID(ctx)
  12585. case contact.FieldCtype:
  12586. return m.OldCtype(ctx)
  12587. case contact.FieldCage:
  12588. return m.OldCage(ctx)
  12589. case contact.FieldCname:
  12590. return m.OldCname(ctx)
  12591. case contact.FieldCarea:
  12592. return m.OldCarea(ctx)
  12593. case contact.FieldCbirthday:
  12594. return m.OldCbirthday(ctx)
  12595. case contact.FieldCbirtharea:
  12596. return m.OldCbirtharea(ctx)
  12597. case contact.FieldCidcardNo:
  12598. return m.OldCidcardNo(ctx)
  12599. case contact.FieldCtitle:
  12600. return m.OldCtitle(ctx)
  12601. case contact.FieldCc:
  12602. return m.OldCc(ctx)
  12603. case contact.FieldPhone:
  12604. return m.OldPhone(ctx)
  12605. }
  12606. return nil, fmt.Errorf("unknown Contact field %s", name)
  12607. }
  12608. // SetField sets the value of a field with the given name. It returns an error if
  12609. // the field is not defined in the schema, or if the type mismatched the field
  12610. // type.
  12611. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  12612. switch name {
  12613. case contact.FieldCreatedAt:
  12614. v, ok := value.(time.Time)
  12615. if !ok {
  12616. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12617. }
  12618. m.SetCreatedAt(v)
  12619. return nil
  12620. case contact.FieldUpdatedAt:
  12621. v, ok := value.(time.Time)
  12622. if !ok {
  12623. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12624. }
  12625. m.SetUpdatedAt(v)
  12626. return nil
  12627. case contact.FieldStatus:
  12628. v, ok := value.(uint8)
  12629. if !ok {
  12630. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12631. }
  12632. m.SetStatus(v)
  12633. return nil
  12634. case contact.FieldDeletedAt:
  12635. v, ok := value.(time.Time)
  12636. if !ok {
  12637. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12638. }
  12639. m.SetDeletedAt(v)
  12640. return nil
  12641. case contact.FieldWxWxid:
  12642. v, ok := value.(string)
  12643. if !ok {
  12644. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12645. }
  12646. m.SetWxWxid(v)
  12647. return nil
  12648. case contact.FieldType:
  12649. v, ok := value.(int)
  12650. if !ok {
  12651. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12652. }
  12653. m.SetType(v)
  12654. return nil
  12655. case contact.FieldWxid:
  12656. v, ok := value.(string)
  12657. if !ok {
  12658. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12659. }
  12660. m.SetWxid(v)
  12661. return nil
  12662. case contact.FieldAccount:
  12663. v, ok := value.(string)
  12664. if !ok {
  12665. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12666. }
  12667. m.SetAccount(v)
  12668. return nil
  12669. case contact.FieldNickname:
  12670. v, ok := value.(string)
  12671. if !ok {
  12672. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12673. }
  12674. m.SetNickname(v)
  12675. return nil
  12676. case contact.FieldMarkname:
  12677. v, ok := value.(string)
  12678. if !ok {
  12679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12680. }
  12681. m.SetMarkname(v)
  12682. return nil
  12683. case contact.FieldHeadimg:
  12684. v, ok := value.(string)
  12685. if !ok {
  12686. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12687. }
  12688. m.SetHeadimg(v)
  12689. return nil
  12690. case contact.FieldSex:
  12691. v, ok := value.(int)
  12692. if !ok {
  12693. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12694. }
  12695. m.SetSex(v)
  12696. return nil
  12697. case contact.FieldStarrole:
  12698. v, ok := value.(string)
  12699. if !ok {
  12700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12701. }
  12702. m.SetStarrole(v)
  12703. return nil
  12704. case contact.FieldDontseeit:
  12705. v, ok := value.(int)
  12706. if !ok {
  12707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12708. }
  12709. m.SetDontseeit(v)
  12710. return nil
  12711. case contact.FieldDontseeme:
  12712. v, ok := value.(int)
  12713. if !ok {
  12714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12715. }
  12716. m.SetDontseeme(v)
  12717. return nil
  12718. case contact.FieldLag:
  12719. v, ok := value.(string)
  12720. if !ok {
  12721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12722. }
  12723. m.SetLag(v)
  12724. return nil
  12725. case contact.FieldGid:
  12726. v, ok := value.(string)
  12727. if !ok {
  12728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12729. }
  12730. m.SetGid(v)
  12731. return nil
  12732. case contact.FieldGname:
  12733. v, ok := value.(string)
  12734. if !ok {
  12735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12736. }
  12737. m.SetGname(v)
  12738. return nil
  12739. case contact.FieldV3:
  12740. v, ok := value.(string)
  12741. if !ok {
  12742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12743. }
  12744. m.SetV3(v)
  12745. return nil
  12746. case contact.FieldOrganizationID:
  12747. v, ok := value.(uint64)
  12748. if !ok {
  12749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12750. }
  12751. m.SetOrganizationID(v)
  12752. return nil
  12753. case contact.FieldCtype:
  12754. v, ok := value.(uint64)
  12755. if !ok {
  12756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12757. }
  12758. m.SetCtype(v)
  12759. return nil
  12760. case contact.FieldCage:
  12761. v, ok := value.(int)
  12762. if !ok {
  12763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12764. }
  12765. m.SetCage(v)
  12766. return nil
  12767. case contact.FieldCname:
  12768. v, ok := value.(string)
  12769. if !ok {
  12770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12771. }
  12772. m.SetCname(v)
  12773. return nil
  12774. case contact.FieldCarea:
  12775. v, ok := value.(string)
  12776. if !ok {
  12777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12778. }
  12779. m.SetCarea(v)
  12780. return nil
  12781. case contact.FieldCbirthday:
  12782. v, ok := value.(string)
  12783. if !ok {
  12784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12785. }
  12786. m.SetCbirthday(v)
  12787. return nil
  12788. case contact.FieldCbirtharea:
  12789. v, ok := value.(string)
  12790. if !ok {
  12791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12792. }
  12793. m.SetCbirtharea(v)
  12794. return nil
  12795. case contact.FieldCidcardNo:
  12796. v, ok := value.(string)
  12797. if !ok {
  12798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12799. }
  12800. m.SetCidcardNo(v)
  12801. return nil
  12802. case contact.FieldCtitle:
  12803. v, ok := value.(string)
  12804. if !ok {
  12805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12806. }
  12807. m.SetCtitle(v)
  12808. return nil
  12809. case contact.FieldCc:
  12810. v, ok := value.(string)
  12811. if !ok {
  12812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12813. }
  12814. m.SetCc(v)
  12815. return nil
  12816. case contact.FieldPhone:
  12817. v, ok := value.(string)
  12818. if !ok {
  12819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12820. }
  12821. m.SetPhone(v)
  12822. return nil
  12823. }
  12824. return fmt.Errorf("unknown Contact field %s", name)
  12825. }
  12826. // AddedFields returns all numeric fields that were incremented/decremented during
  12827. // this mutation.
  12828. func (m *ContactMutation) AddedFields() []string {
  12829. var fields []string
  12830. if m.addstatus != nil {
  12831. fields = append(fields, contact.FieldStatus)
  12832. }
  12833. if m.add_type != nil {
  12834. fields = append(fields, contact.FieldType)
  12835. }
  12836. if m.addsex != nil {
  12837. fields = append(fields, contact.FieldSex)
  12838. }
  12839. if m.adddontseeit != nil {
  12840. fields = append(fields, contact.FieldDontseeit)
  12841. }
  12842. if m.adddontseeme != nil {
  12843. fields = append(fields, contact.FieldDontseeme)
  12844. }
  12845. if m.addorganization_id != nil {
  12846. fields = append(fields, contact.FieldOrganizationID)
  12847. }
  12848. if m.addctype != nil {
  12849. fields = append(fields, contact.FieldCtype)
  12850. }
  12851. if m.addcage != nil {
  12852. fields = append(fields, contact.FieldCage)
  12853. }
  12854. return fields
  12855. }
  12856. // AddedField returns the numeric value that was incremented/decremented on a field
  12857. // with the given name. The second boolean return value indicates that this field
  12858. // was not set, or was not defined in the schema.
  12859. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  12860. switch name {
  12861. case contact.FieldStatus:
  12862. return m.AddedStatus()
  12863. case contact.FieldType:
  12864. return m.AddedType()
  12865. case contact.FieldSex:
  12866. return m.AddedSex()
  12867. case contact.FieldDontseeit:
  12868. return m.AddedDontseeit()
  12869. case contact.FieldDontseeme:
  12870. return m.AddedDontseeme()
  12871. case contact.FieldOrganizationID:
  12872. return m.AddedOrganizationID()
  12873. case contact.FieldCtype:
  12874. return m.AddedCtype()
  12875. case contact.FieldCage:
  12876. return m.AddedCage()
  12877. }
  12878. return nil, false
  12879. }
  12880. // AddField adds the value to the field with the given name. It returns an error if
  12881. // the field is not defined in the schema, or if the type mismatched the field
  12882. // type.
  12883. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  12884. switch name {
  12885. case contact.FieldStatus:
  12886. v, ok := value.(int8)
  12887. if !ok {
  12888. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12889. }
  12890. m.AddStatus(v)
  12891. return nil
  12892. case contact.FieldType:
  12893. v, ok := value.(int)
  12894. if !ok {
  12895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12896. }
  12897. m.AddType(v)
  12898. return nil
  12899. case contact.FieldSex:
  12900. v, ok := value.(int)
  12901. if !ok {
  12902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12903. }
  12904. m.AddSex(v)
  12905. return nil
  12906. case contact.FieldDontseeit:
  12907. v, ok := value.(int)
  12908. if !ok {
  12909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12910. }
  12911. m.AddDontseeit(v)
  12912. return nil
  12913. case contact.FieldDontseeme:
  12914. v, ok := value.(int)
  12915. if !ok {
  12916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12917. }
  12918. m.AddDontseeme(v)
  12919. return nil
  12920. case contact.FieldOrganizationID:
  12921. v, ok := value.(int64)
  12922. if !ok {
  12923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12924. }
  12925. m.AddOrganizationID(v)
  12926. return nil
  12927. case contact.FieldCtype:
  12928. v, ok := value.(int64)
  12929. if !ok {
  12930. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12931. }
  12932. m.AddCtype(v)
  12933. return nil
  12934. case contact.FieldCage:
  12935. v, ok := value.(int)
  12936. if !ok {
  12937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12938. }
  12939. m.AddCage(v)
  12940. return nil
  12941. }
  12942. return fmt.Errorf("unknown Contact numeric field %s", name)
  12943. }
  12944. // ClearedFields returns all nullable fields that were cleared during this
  12945. // mutation.
  12946. func (m *ContactMutation) ClearedFields() []string {
  12947. var fields []string
  12948. if m.FieldCleared(contact.FieldStatus) {
  12949. fields = append(fields, contact.FieldStatus)
  12950. }
  12951. if m.FieldCleared(contact.FieldDeletedAt) {
  12952. fields = append(fields, contact.FieldDeletedAt)
  12953. }
  12954. if m.FieldCleared(contact.FieldType) {
  12955. fields = append(fields, contact.FieldType)
  12956. }
  12957. if m.FieldCleared(contact.FieldOrganizationID) {
  12958. fields = append(fields, contact.FieldOrganizationID)
  12959. }
  12960. return fields
  12961. }
  12962. // FieldCleared returns a boolean indicating if a field with the given name was
  12963. // cleared in this mutation.
  12964. func (m *ContactMutation) FieldCleared(name string) bool {
  12965. _, ok := m.clearedFields[name]
  12966. return ok
  12967. }
  12968. // ClearField clears the value of the field with the given name. It returns an
  12969. // error if the field is not defined in the schema.
  12970. func (m *ContactMutation) ClearField(name string) error {
  12971. switch name {
  12972. case contact.FieldStatus:
  12973. m.ClearStatus()
  12974. return nil
  12975. case contact.FieldDeletedAt:
  12976. m.ClearDeletedAt()
  12977. return nil
  12978. case contact.FieldType:
  12979. m.ClearType()
  12980. return nil
  12981. case contact.FieldOrganizationID:
  12982. m.ClearOrganizationID()
  12983. return nil
  12984. }
  12985. return fmt.Errorf("unknown Contact nullable field %s", name)
  12986. }
  12987. // ResetField resets all changes in the mutation for the field with the given name.
  12988. // It returns an error if the field is not defined in the schema.
  12989. func (m *ContactMutation) ResetField(name string) error {
  12990. switch name {
  12991. case contact.FieldCreatedAt:
  12992. m.ResetCreatedAt()
  12993. return nil
  12994. case contact.FieldUpdatedAt:
  12995. m.ResetUpdatedAt()
  12996. return nil
  12997. case contact.FieldStatus:
  12998. m.ResetStatus()
  12999. return nil
  13000. case contact.FieldDeletedAt:
  13001. m.ResetDeletedAt()
  13002. return nil
  13003. case contact.FieldWxWxid:
  13004. m.ResetWxWxid()
  13005. return nil
  13006. case contact.FieldType:
  13007. m.ResetType()
  13008. return nil
  13009. case contact.FieldWxid:
  13010. m.ResetWxid()
  13011. return nil
  13012. case contact.FieldAccount:
  13013. m.ResetAccount()
  13014. return nil
  13015. case contact.FieldNickname:
  13016. m.ResetNickname()
  13017. return nil
  13018. case contact.FieldMarkname:
  13019. m.ResetMarkname()
  13020. return nil
  13021. case contact.FieldHeadimg:
  13022. m.ResetHeadimg()
  13023. return nil
  13024. case contact.FieldSex:
  13025. m.ResetSex()
  13026. return nil
  13027. case contact.FieldStarrole:
  13028. m.ResetStarrole()
  13029. return nil
  13030. case contact.FieldDontseeit:
  13031. m.ResetDontseeit()
  13032. return nil
  13033. case contact.FieldDontseeme:
  13034. m.ResetDontseeme()
  13035. return nil
  13036. case contact.FieldLag:
  13037. m.ResetLag()
  13038. return nil
  13039. case contact.FieldGid:
  13040. m.ResetGid()
  13041. return nil
  13042. case contact.FieldGname:
  13043. m.ResetGname()
  13044. return nil
  13045. case contact.FieldV3:
  13046. m.ResetV3()
  13047. return nil
  13048. case contact.FieldOrganizationID:
  13049. m.ResetOrganizationID()
  13050. return nil
  13051. case contact.FieldCtype:
  13052. m.ResetCtype()
  13053. return nil
  13054. case contact.FieldCage:
  13055. m.ResetCage()
  13056. return nil
  13057. case contact.FieldCname:
  13058. m.ResetCname()
  13059. return nil
  13060. case contact.FieldCarea:
  13061. m.ResetCarea()
  13062. return nil
  13063. case contact.FieldCbirthday:
  13064. m.ResetCbirthday()
  13065. return nil
  13066. case contact.FieldCbirtharea:
  13067. m.ResetCbirtharea()
  13068. return nil
  13069. case contact.FieldCidcardNo:
  13070. m.ResetCidcardNo()
  13071. return nil
  13072. case contact.FieldCtitle:
  13073. m.ResetCtitle()
  13074. return nil
  13075. case contact.FieldCc:
  13076. m.ResetCc()
  13077. return nil
  13078. case contact.FieldPhone:
  13079. m.ResetPhone()
  13080. return nil
  13081. }
  13082. return fmt.Errorf("unknown Contact field %s", name)
  13083. }
  13084. // AddedEdges returns all edge names that were set/added in this mutation.
  13085. func (m *ContactMutation) AddedEdges() []string {
  13086. edges := make([]string, 0, 3)
  13087. if m.contact_relationships != nil {
  13088. edges = append(edges, contact.EdgeContactRelationships)
  13089. }
  13090. if m.contact_fields != nil {
  13091. edges = append(edges, contact.EdgeContactFields)
  13092. }
  13093. if m.contact_messages != nil {
  13094. edges = append(edges, contact.EdgeContactMessages)
  13095. }
  13096. return edges
  13097. }
  13098. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13099. // name in this mutation.
  13100. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  13101. switch name {
  13102. case contact.EdgeContactRelationships:
  13103. ids := make([]ent.Value, 0, len(m.contact_relationships))
  13104. for id := range m.contact_relationships {
  13105. ids = append(ids, id)
  13106. }
  13107. return ids
  13108. case contact.EdgeContactFields:
  13109. ids := make([]ent.Value, 0, len(m.contact_fields))
  13110. for id := range m.contact_fields {
  13111. ids = append(ids, id)
  13112. }
  13113. return ids
  13114. case contact.EdgeContactMessages:
  13115. ids := make([]ent.Value, 0, len(m.contact_messages))
  13116. for id := range m.contact_messages {
  13117. ids = append(ids, id)
  13118. }
  13119. return ids
  13120. }
  13121. return nil
  13122. }
  13123. // RemovedEdges returns all edge names that were removed in this mutation.
  13124. func (m *ContactMutation) RemovedEdges() []string {
  13125. edges := make([]string, 0, 3)
  13126. if m.removedcontact_relationships != nil {
  13127. edges = append(edges, contact.EdgeContactRelationships)
  13128. }
  13129. if m.removedcontact_fields != nil {
  13130. edges = append(edges, contact.EdgeContactFields)
  13131. }
  13132. if m.removedcontact_messages != nil {
  13133. edges = append(edges, contact.EdgeContactMessages)
  13134. }
  13135. return edges
  13136. }
  13137. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13138. // the given name in this mutation.
  13139. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  13140. switch name {
  13141. case contact.EdgeContactRelationships:
  13142. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  13143. for id := range m.removedcontact_relationships {
  13144. ids = append(ids, id)
  13145. }
  13146. return ids
  13147. case contact.EdgeContactFields:
  13148. ids := make([]ent.Value, 0, len(m.removedcontact_fields))
  13149. for id := range m.removedcontact_fields {
  13150. ids = append(ids, id)
  13151. }
  13152. return ids
  13153. case contact.EdgeContactMessages:
  13154. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  13155. for id := range m.removedcontact_messages {
  13156. ids = append(ids, id)
  13157. }
  13158. return ids
  13159. }
  13160. return nil
  13161. }
  13162. // ClearedEdges returns all edge names that were cleared in this mutation.
  13163. func (m *ContactMutation) ClearedEdges() []string {
  13164. edges := make([]string, 0, 3)
  13165. if m.clearedcontact_relationships {
  13166. edges = append(edges, contact.EdgeContactRelationships)
  13167. }
  13168. if m.clearedcontact_fields {
  13169. edges = append(edges, contact.EdgeContactFields)
  13170. }
  13171. if m.clearedcontact_messages {
  13172. edges = append(edges, contact.EdgeContactMessages)
  13173. }
  13174. return edges
  13175. }
  13176. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13177. // was cleared in this mutation.
  13178. func (m *ContactMutation) EdgeCleared(name string) bool {
  13179. switch name {
  13180. case contact.EdgeContactRelationships:
  13181. return m.clearedcontact_relationships
  13182. case contact.EdgeContactFields:
  13183. return m.clearedcontact_fields
  13184. case contact.EdgeContactMessages:
  13185. return m.clearedcontact_messages
  13186. }
  13187. return false
  13188. }
  13189. // ClearEdge clears the value of the edge with the given name. It returns an error
  13190. // if that edge is not defined in the schema.
  13191. func (m *ContactMutation) ClearEdge(name string) error {
  13192. switch name {
  13193. }
  13194. return fmt.Errorf("unknown Contact unique edge %s", name)
  13195. }
  13196. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13197. // It returns an error if the edge is not defined in the schema.
  13198. func (m *ContactMutation) ResetEdge(name string) error {
  13199. switch name {
  13200. case contact.EdgeContactRelationships:
  13201. m.ResetContactRelationships()
  13202. return nil
  13203. case contact.EdgeContactFields:
  13204. m.ResetContactFields()
  13205. return nil
  13206. case contact.EdgeContactMessages:
  13207. m.ResetContactMessages()
  13208. return nil
  13209. }
  13210. return fmt.Errorf("unknown Contact edge %s", name)
  13211. }
  13212. // ContactFieldMutation represents an operation that mutates the ContactField nodes in the graph.
  13213. type ContactFieldMutation struct {
  13214. config
  13215. op Op
  13216. typ string
  13217. id *uint64
  13218. created_at *time.Time
  13219. updated_at *time.Time
  13220. status *uint8
  13221. addstatus *int8
  13222. deleted_at *time.Time
  13223. form_id *string
  13224. value *[]string
  13225. appendvalue []string
  13226. clearedFields map[string]struct{}
  13227. field_contact *uint64
  13228. clearedfield_contact bool
  13229. done bool
  13230. oldValue func(context.Context) (*ContactField, error)
  13231. predicates []predicate.ContactField
  13232. }
  13233. var _ ent.Mutation = (*ContactFieldMutation)(nil)
  13234. // contactfieldOption allows management of the mutation configuration using functional options.
  13235. type contactfieldOption func(*ContactFieldMutation)
  13236. // newContactFieldMutation creates new mutation for the ContactField entity.
  13237. func newContactFieldMutation(c config, op Op, opts ...contactfieldOption) *ContactFieldMutation {
  13238. m := &ContactFieldMutation{
  13239. config: c,
  13240. op: op,
  13241. typ: TypeContactField,
  13242. clearedFields: make(map[string]struct{}),
  13243. }
  13244. for _, opt := range opts {
  13245. opt(m)
  13246. }
  13247. return m
  13248. }
  13249. // withContactFieldID sets the ID field of the mutation.
  13250. func withContactFieldID(id uint64) contactfieldOption {
  13251. return func(m *ContactFieldMutation) {
  13252. var (
  13253. err error
  13254. once sync.Once
  13255. value *ContactField
  13256. )
  13257. m.oldValue = func(ctx context.Context) (*ContactField, error) {
  13258. once.Do(func() {
  13259. if m.done {
  13260. err = errors.New("querying old values post mutation is not allowed")
  13261. } else {
  13262. value, err = m.Client().ContactField.Get(ctx, id)
  13263. }
  13264. })
  13265. return value, err
  13266. }
  13267. m.id = &id
  13268. }
  13269. }
  13270. // withContactField sets the old ContactField of the mutation.
  13271. func withContactField(node *ContactField) contactfieldOption {
  13272. return func(m *ContactFieldMutation) {
  13273. m.oldValue = func(context.Context) (*ContactField, error) {
  13274. return node, nil
  13275. }
  13276. m.id = &node.ID
  13277. }
  13278. }
  13279. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13280. // executed in a transaction (ent.Tx), a transactional client is returned.
  13281. func (m ContactFieldMutation) Client() *Client {
  13282. client := &Client{config: m.config}
  13283. client.init()
  13284. return client
  13285. }
  13286. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13287. // it returns an error otherwise.
  13288. func (m ContactFieldMutation) Tx() (*Tx, error) {
  13289. if _, ok := m.driver.(*txDriver); !ok {
  13290. return nil, errors.New("ent: mutation is not running in a transaction")
  13291. }
  13292. tx := &Tx{config: m.config}
  13293. tx.init()
  13294. return tx, nil
  13295. }
  13296. // SetID sets the value of the id field. Note that this
  13297. // operation is only accepted on creation of ContactField entities.
  13298. func (m *ContactFieldMutation) SetID(id uint64) {
  13299. m.id = &id
  13300. }
  13301. // ID returns the ID value in the mutation. Note that the ID is only available
  13302. // if it was provided to the builder or after it was returned from the database.
  13303. func (m *ContactFieldMutation) ID() (id uint64, exists bool) {
  13304. if m.id == nil {
  13305. return
  13306. }
  13307. return *m.id, true
  13308. }
  13309. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13310. // That means, if the mutation is applied within a transaction with an isolation level such
  13311. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13312. // or updated by the mutation.
  13313. func (m *ContactFieldMutation) IDs(ctx context.Context) ([]uint64, error) {
  13314. switch {
  13315. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13316. id, exists := m.ID()
  13317. if exists {
  13318. return []uint64{id}, nil
  13319. }
  13320. fallthrough
  13321. case m.op.Is(OpUpdate | OpDelete):
  13322. return m.Client().ContactField.Query().Where(m.predicates...).IDs(ctx)
  13323. default:
  13324. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13325. }
  13326. }
  13327. // SetCreatedAt sets the "created_at" field.
  13328. func (m *ContactFieldMutation) SetCreatedAt(t time.Time) {
  13329. m.created_at = &t
  13330. }
  13331. // CreatedAt returns the value of the "created_at" field in the mutation.
  13332. func (m *ContactFieldMutation) CreatedAt() (r time.Time, exists bool) {
  13333. v := m.created_at
  13334. if v == nil {
  13335. return
  13336. }
  13337. return *v, true
  13338. }
  13339. // OldCreatedAt returns the old "created_at" field's value of the ContactField entity.
  13340. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  13341. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13342. func (m *ContactFieldMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13343. if !m.op.Is(OpUpdateOne) {
  13344. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13345. }
  13346. if m.id == nil || m.oldValue == nil {
  13347. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13348. }
  13349. oldValue, err := m.oldValue(ctx)
  13350. if err != nil {
  13351. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13352. }
  13353. return oldValue.CreatedAt, nil
  13354. }
  13355. // ResetCreatedAt resets all changes to the "created_at" field.
  13356. func (m *ContactFieldMutation) ResetCreatedAt() {
  13357. m.created_at = nil
  13358. }
  13359. // SetUpdatedAt sets the "updated_at" field.
  13360. func (m *ContactFieldMutation) SetUpdatedAt(t time.Time) {
  13361. m.updated_at = &t
  13362. }
  13363. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13364. func (m *ContactFieldMutation) UpdatedAt() (r time.Time, exists bool) {
  13365. v := m.updated_at
  13366. if v == nil {
  13367. return
  13368. }
  13369. return *v, true
  13370. }
  13371. // OldUpdatedAt returns the old "updated_at" field's value of the ContactField entity.
  13372. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  13373. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13374. func (m *ContactFieldMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13375. if !m.op.Is(OpUpdateOne) {
  13376. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13377. }
  13378. if m.id == nil || m.oldValue == nil {
  13379. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13380. }
  13381. oldValue, err := m.oldValue(ctx)
  13382. if err != nil {
  13383. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13384. }
  13385. return oldValue.UpdatedAt, nil
  13386. }
  13387. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13388. func (m *ContactFieldMutation) ResetUpdatedAt() {
  13389. m.updated_at = nil
  13390. }
  13391. // SetStatus sets the "status" field.
  13392. func (m *ContactFieldMutation) SetStatus(u uint8) {
  13393. m.status = &u
  13394. m.addstatus = nil
  13395. }
  13396. // Status returns the value of the "status" field in the mutation.
  13397. func (m *ContactFieldMutation) Status() (r uint8, exists bool) {
  13398. v := m.status
  13399. if v == nil {
  13400. return
  13401. }
  13402. return *v, true
  13403. }
  13404. // OldStatus returns the old "status" field's value of the ContactField entity.
  13405. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  13406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13407. func (m *ContactFieldMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13408. if !m.op.Is(OpUpdateOne) {
  13409. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13410. }
  13411. if m.id == nil || m.oldValue == nil {
  13412. return v, errors.New("OldStatus requires an ID field in the mutation")
  13413. }
  13414. oldValue, err := m.oldValue(ctx)
  13415. if err != nil {
  13416. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13417. }
  13418. return oldValue.Status, nil
  13419. }
  13420. // AddStatus adds u to the "status" field.
  13421. func (m *ContactFieldMutation) AddStatus(u int8) {
  13422. if m.addstatus != nil {
  13423. *m.addstatus += u
  13424. } else {
  13425. m.addstatus = &u
  13426. }
  13427. }
  13428. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13429. func (m *ContactFieldMutation) AddedStatus() (r int8, exists bool) {
  13430. v := m.addstatus
  13431. if v == nil {
  13432. return
  13433. }
  13434. return *v, true
  13435. }
  13436. // ClearStatus clears the value of the "status" field.
  13437. func (m *ContactFieldMutation) ClearStatus() {
  13438. m.status = nil
  13439. m.addstatus = nil
  13440. m.clearedFields[contactfield.FieldStatus] = struct{}{}
  13441. }
  13442. // StatusCleared returns if the "status" field was cleared in this mutation.
  13443. func (m *ContactFieldMutation) StatusCleared() bool {
  13444. _, ok := m.clearedFields[contactfield.FieldStatus]
  13445. return ok
  13446. }
  13447. // ResetStatus resets all changes to the "status" field.
  13448. func (m *ContactFieldMutation) ResetStatus() {
  13449. m.status = nil
  13450. m.addstatus = nil
  13451. delete(m.clearedFields, contactfield.FieldStatus)
  13452. }
  13453. // SetDeletedAt sets the "deleted_at" field.
  13454. func (m *ContactFieldMutation) SetDeletedAt(t time.Time) {
  13455. m.deleted_at = &t
  13456. }
  13457. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13458. func (m *ContactFieldMutation) DeletedAt() (r time.Time, exists bool) {
  13459. v := m.deleted_at
  13460. if v == nil {
  13461. return
  13462. }
  13463. return *v, true
  13464. }
  13465. // OldDeletedAt returns the old "deleted_at" field's value of the ContactField entity.
  13466. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  13467. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13468. func (m *ContactFieldMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13469. if !m.op.Is(OpUpdateOne) {
  13470. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13471. }
  13472. if m.id == nil || m.oldValue == nil {
  13473. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13474. }
  13475. oldValue, err := m.oldValue(ctx)
  13476. if err != nil {
  13477. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13478. }
  13479. return oldValue.DeletedAt, nil
  13480. }
  13481. // ClearDeletedAt clears the value of the "deleted_at" field.
  13482. func (m *ContactFieldMutation) ClearDeletedAt() {
  13483. m.deleted_at = nil
  13484. m.clearedFields[contactfield.FieldDeletedAt] = struct{}{}
  13485. }
  13486. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13487. func (m *ContactFieldMutation) DeletedAtCleared() bool {
  13488. _, ok := m.clearedFields[contactfield.FieldDeletedAt]
  13489. return ok
  13490. }
  13491. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13492. func (m *ContactFieldMutation) ResetDeletedAt() {
  13493. m.deleted_at = nil
  13494. delete(m.clearedFields, contactfield.FieldDeletedAt)
  13495. }
  13496. // SetContactID sets the "contact_id" field.
  13497. func (m *ContactFieldMutation) SetContactID(u uint64) {
  13498. m.field_contact = &u
  13499. }
  13500. // ContactID returns the value of the "contact_id" field in the mutation.
  13501. func (m *ContactFieldMutation) ContactID() (r uint64, exists bool) {
  13502. v := m.field_contact
  13503. if v == nil {
  13504. return
  13505. }
  13506. return *v, true
  13507. }
  13508. // OldContactID returns the old "contact_id" field's value of the ContactField entity.
  13509. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  13510. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13511. func (m *ContactFieldMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  13512. if !m.op.Is(OpUpdateOne) {
  13513. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  13514. }
  13515. if m.id == nil || m.oldValue == nil {
  13516. return v, errors.New("OldContactID requires an ID field in the mutation")
  13517. }
  13518. oldValue, err := m.oldValue(ctx)
  13519. if err != nil {
  13520. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  13521. }
  13522. return oldValue.ContactID, nil
  13523. }
  13524. // ResetContactID resets all changes to the "contact_id" field.
  13525. func (m *ContactFieldMutation) ResetContactID() {
  13526. m.field_contact = nil
  13527. }
  13528. // SetFormID sets the "form_id" field.
  13529. func (m *ContactFieldMutation) SetFormID(s string) {
  13530. m.form_id = &s
  13531. }
  13532. // FormID returns the value of the "form_id" field in the mutation.
  13533. func (m *ContactFieldMutation) FormID() (r string, exists bool) {
  13534. v := m.form_id
  13535. if v == nil {
  13536. return
  13537. }
  13538. return *v, true
  13539. }
  13540. // OldFormID returns the old "form_id" field's value of the ContactField entity.
  13541. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  13542. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13543. func (m *ContactFieldMutation) OldFormID(ctx context.Context) (v string, err error) {
  13544. if !m.op.Is(OpUpdateOne) {
  13545. return v, errors.New("OldFormID is only allowed on UpdateOne operations")
  13546. }
  13547. if m.id == nil || m.oldValue == nil {
  13548. return v, errors.New("OldFormID requires an ID field in the mutation")
  13549. }
  13550. oldValue, err := m.oldValue(ctx)
  13551. if err != nil {
  13552. return v, fmt.Errorf("querying old value for OldFormID: %w", err)
  13553. }
  13554. return oldValue.FormID, nil
  13555. }
  13556. // ResetFormID resets all changes to the "form_id" field.
  13557. func (m *ContactFieldMutation) ResetFormID() {
  13558. m.form_id = nil
  13559. }
  13560. // SetValue sets the "value" field.
  13561. func (m *ContactFieldMutation) SetValue(s []string) {
  13562. m.value = &s
  13563. m.appendvalue = nil
  13564. }
  13565. // Value returns the value of the "value" field in the mutation.
  13566. func (m *ContactFieldMutation) Value() (r []string, exists bool) {
  13567. v := m.value
  13568. if v == nil {
  13569. return
  13570. }
  13571. return *v, true
  13572. }
  13573. // OldValue returns the old "value" field's value of the ContactField entity.
  13574. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  13575. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13576. func (m *ContactFieldMutation) OldValue(ctx context.Context) (v []string, err error) {
  13577. if !m.op.Is(OpUpdateOne) {
  13578. return v, errors.New("OldValue is only allowed on UpdateOne operations")
  13579. }
  13580. if m.id == nil || m.oldValue == nil {
  13581. return v, errors.New("OldValue requires an ID field in the mutation")
  13582. }
  13583. oldValue, err := m.oldValue(ctx)
  13584. if err != nil {
  13585. return v, fmt.Errorf("querying old value for OldValue: %w", err)
  13586. }
  13587. return oldValue.Value, nil
  13588. }
  13589. // AppendValue adds s to the "value" field.
  13590. func (m *ContactFieldMutation) AppendValue(s []string) {
  13591. m.appendvalue = append(m.appendvalue, s...)
  13592. }
  13593. // AppendedValue returns the list of values that were appended to the "value" field in this mutation.
  13594. func (m *ContactFieldMutation) AppendedValue() ([]string, bool) {
  13595. if len(m.appendvalue) == 0 {
  13596. return nil, false
  13597. }
  13598. return m.appendvalue, true
  13599. }
  13600. // ResetValue resets all changes to the "value" field.
  13601. func (m *ContactFieldMutation) ResetValue() {
  13602. m.value = nil
  13603. m.appendvalue = nil
  13604. }
  13605. // SetFieldContactID sets the "field_contact" edge to the Contact entity by id.
  13606. func (m *ContactFieldMutation) SetFieldContactID(id uint64) {
  13607. m.field_contact = &id
  13608. }
  13609. // ClearFieldContact clears the "field_contact" edge to the Contact entity.
  13610. func (m *ContactFieldMutation) ClearFieldContact() {
  13611. m.clearedfield_contact = true
  13612. m.clearedFields[contactfield.FieldContactID] = struct{}{}
  13613. }
  13614. // FieldContactCleared reports if the "field_contact" edge to the Contact entity was cleared.
  13615. func (m *ContactFieldMutation) FieldContactCleared() bool {
  13616. return m.clearedfield_contact
  13617. }
  13618. // FieldContactID returns the "field_contact" edge ID in the mutation.
  13619. func (m *ContactFieldMutation) FieldContactID() (id uint64, exists bool) {
  13620. if m.field_contact != nil {
  13621. return *m.field_contact, true
  13622. }
  13623. return
  13624. }
  13625. // FieldContactIDs returns the "field_contact" edge IDs in the mutation.
  13626. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  13627. // FieldContactID instead. It exists only for internal usage by the builders.
  13628. func (m *ContactFieldMutation) FieldContactIDs() (ids []uint64) {
  13629. if id := m.field_contact; id != nil {
  13630. ids = append(ids, *id)
  13631. }
  13632. return
  13633. }
  13634. // ResetFieldContact resets all changes to the "field_contact" edge.
  13635. func (m *ContactFieldMutation) ResetFieldContact() {
  13636. m.field_contact = nil
  13637. m.clearedfield_contact = false
  13638. }
  13639. // Where appends a list predicates to the ContactFieldMutation builder.
  13640. func (m *ContactFieldMutation) Where(ps ...predicate.ContactField) {
  13641. m.predicates = append(m.predicates, ps...)
  13642. }
  13643. // WhereP appends storage-level predicates to the ContactFieldMutation builder. Using this method,
  13644. // users can use type-assertion to append predicates that do not depend on any generated package.
  13645. func (m *ContactFieldMutation) WhereP(ps ...func(*sql.Selector)) {
  13646. p := make([]predicate.ContactField, len(ps))
  13647. for i := range ps {
  13648. p[i] = ps[i]
  13649. }
  13650. m.Where(p...)
  13651. }
  13652. // Op returns the operation name.
  13653. func (m *ContactFieldMutation) Op() Op {
  13654. return m.op
  13655. }
  13656. // SetOp allows setting the mutation operation.
  13657. func (m *ContactFieldMutation) SetOp(op Op) {
  13658. m.op = op
  13659. }
  13660. // Type returns the node type of this mutation (ContactField).
  13661. func (m *ContactFieldMutation) Type() string {
  13662. return m.typ
  13663. }
  13664. // Fields returns all fields that were changed during this mutation. Note that in
  13665. // order to get all numeric fields that were incremented/decremented, call
  13666. // AddedFields().
  13667. func (m *ContactFieldMutation) Fields() []string {
  13668. fields := make([]string, 0, 7)
  13669. if m.created_at != nil {
  13670. fields = append(fields, contactfield.FieldCreatedAt)
  13671. }
  13672. if m.updated_at != nil {
  13673. fields = append(fields, contactfield.FieldUpdatedAt)
  13674. }
  13675. if m.status != nil {
  13676. fields = append(fields, contactfield.FieldStatus)
  13677. }
  13678. if m.deleted_at != nil {
  13679. fields = append(fields, contactfield.FieldDeletedAt)
  13680. }
  13681. if m.field_contact != nil {
  13682. fields = append(fields, contactfield.FieldContactID)
  13683. }
  13684. if m.form_id != nil {
  13685. fields = append(fields, contactfield.FieldFormID)
  13686. }
  13687. if m.value != nil {
  13688. fields = append(fields, contactfield.FieldValue)
  13689. }
  13690. return fields
  13691. }
  13692. // Field returns the value of a field with the given name. The second boolean
  13693. // return value indicates that this field was not set, or was not defined in the
  13694. // schema.
  13695. func (m *ContactFieldMutation) Field(name string) (ent.Value, bool) {
  13696. switch name {
  13697. case contactfield.FieldCreatedAt:
  13698. return m.CreatedAt()
  13699. case contactfield.FieldUpdatedAt:
  13700. return m.UpdatedAt()
  13701. case contactfield.FieldStatus:
  13702. return m.Status()
  13703. case contactfield.FieldDeletedAt:
  13704. return m.DeletedAt()
  13705. case contactfield.FieldContactID:
  13706. return m.ContactID()
  13707. case contactfield.FieldFormID:
  13708. return m.FormID()
  13709. case contactfield.FieldValue:
  13710. return m.Value()
  13711. }
  13712. return nil, false
  13713. }
  13714. // OldField returns the old value of the field from the database. An error is
  13715. // returned if the mutation operation is not UpdateOne, or the query to the
  13716. // database failed.
  13717. func (m *ContactFieldMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13718. switch name {
  13719. case contactfield.FieldCreatedAt:
  13720. return m.OldCreatedAt(ctx)
  13721. case contactfield.FieldUpdatedAt:
  13722. return m.OldUpdatedAt(ctx)
  13723. case contactfield.FieldStatus:
  13724. return m.OldStatus(ctx)
  13725. case contactfield.FieldDeletedAt:
  13726. return m.OldDeletedAt(ctx)
  13727. case contactfield.FieldContactID:
  13728. return m.OldContactID(ctx)
  13729. case contactfield.FieldFormID:
  13730. return m.OldFormID(ctx)
  13731. case contactfield.FieldValue:
  13732. return m.OldValue(ctx)
  13733. }
  13734. return nil, fmt.Errorf("unknown ContactField field %s", name)
  13735. }
  13736. // SetField sets the value of a field with the given name. It returns an error if
  13737. // the field is not defined in the schema, or if the type mismatched the field
  13738. // type.
  13739. func (m *ContactFieldMutation) SetField(name string, value ent.Value) error {
  13740. switch name {
  13741. case contactfield.FieldCreatedAt:
  13742. v, ok := value.(time.Time)
  13743. if !ok {
  13744. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13745. }
  13746. m.SetCreatedAt(v)
  13747. return nil
  13748. case contactfield.FieldUpdatedAt:
  13749. v, ok := value.(time.Time)
  13750. if !ok {
  13751. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13752. }
  13753. m.SetUpdatedAt(v)
  13754. return nil
  13755. case contactfield.FieldStatus:
  13756. v, ok := value.(uint8)
  13757. if !ok {
  13758. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13759. }
  13760. m.SetStatus(v)
  13761. return nil
  13762. case contactfield.FieldDeletedAt:
  13763. v, ok := value.(time.Time)
  13764. if !ok {
  13765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13766. }
  13767. m.SetDeletedAt(v)
  13768. return nil
  13769. case contactfield.FieldContactID:
  13770. v, ok := value.(uint64)
  13771. if !ok {
  13772. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13773. }
  13774. m.SetContactID(v)
  13775. return nil
  13776. case contactfield.FieldFormID:
  13777. v, ok := value.(string)
  13778. if !ok {
  13779. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13780. }
  13781. m.SetFormID(v)
  13782. return nil
  13783. case contactfield.FieldValue:
  13784. v, ok := value.([]string)
  13785. if !ok {
  13786. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13787. }
  13788. m.SetValue(v)
  13789. return nil
  13790. }
  13791. return fmt.Errorf("unknown ContactField field %s", name)
  13792. }
  13793. // AddedFields returns all numeric fields that were incremented/decremented during
  13794. // this mutation.
  13795. func (m *ContactFieldMutation) AddedFields() []string {
  13796. var fields []string
  13797. if m.addstatus != nil {
  13798. fields = append(fields, contactfield.FieldStatus)
  13799. }
  13800. return fields
  13801. }
  13802. // AddedField returns the numeric value that was incremented/decremented on a field
  13803. // with the given name. The second boolean return value indicates that this field
  13804. // was not set, or was not defined in the schema.
  13805. func (m *ContactFieldMutation) AddedField(name string) (ent.Value, bool) {
  13806. switch name {
  13807. case contactfield.FieldStatus:
  13808. return m.AddedStatus()
  13809. }
  13810. return nil, false
  13811. }
  13812. // AddField adds the value to the field with the given name. It returns an error if
  13813. // the field is not defined in the schema, or if the type mismatched the field
  13814. // type.
  13815. func (m *ContactFieldMutation) AddField(name string, value ent.Value) error {
  13816. switch name {
  13817. case contactfield.FieldStatus:
  13818. v, ok := value.(int8)
  13819. if !ok {
  13820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13821. }
  13822. m.AddStatus(v)
  13823. return nil
  13824. }
  13825. return fmt.Errorf("unknown ContactField numeric field %s", name)
  13826. }
  13827. // ClearedFields returns all nullable fields that were cleared during this
  13828. // mutation.
  13829. func (m *ContactFieldMutation) ClearedFields() []string {
  13830. var fields []string
  13831. if m.FieldCleared(contactfield.FieldStatus) {
  13832. fields = append(fields, contactfield.FieldStatus)
  13833. }
  13834. if m.FieldCleared(contactfield.FieldDeletedAt) {
  13835. fields = append(fields, contactfield.FieldDeletedAt)
  13836. }
  13837. return fields
  13838. }
  13839. // FieldCleared returns a boolean indicating if a field with the given name was
  13840. // cleared in this mutation.
  13841. func (m *ContactFieldMutation) FieldCleared(name string) bool {
  13842. _, ok := m.clearedFields[name]
  13843. return ok
  13844. }
  13845. // ClearField clears the value of the field with the given name. It returns an
  13846. // error if the field is not defined in the schema.
  13847. func (m *ContactFieldMutation) ClearField(name string) error {
  13848. switch name {
  13849. case contactfield.FieldStatus:
  13850. m.ClearStatus()
  13851. return nil
  13852. case contactfield.FieldDeletedAt:
  13853. m.ClearDeletedAt()
  13854. return nil
  13855. }
  13856. return fmt.Errorf("unknown ContactField nullable field %s", name)
  13857. }
  13858. // ResetField resets all changes in the mutation for the field with the given name.
  13859. // It returns an error if the field is not defined in the schema.
  13860. func (m *ContactFieldMutation) ResetField(name string) error {
  13861. switch name {
  13862. case contactfield.FieldCreatedAt:
  13863. m.ResetCreatedAt()
  13864. return nil
  13865. case contactfield.FieldUpdatedAt:
  13866. m.ResetUpdatedAt()
  13867. return nil
  13868. case contactfield.FieldStatus:
  13869. m.ResetStatus()
  13870. return nil
  13871. case contactfield.FieldDeletedAt:
  13872. m.ResetDeletedAt()
  13873. return nil
  13874. case contactfield.FieldContactID:
  13875. m.ResetContactID()
  13876. return nil
  13877. case contactfield.FieldFormID:
  13878. m.ResetFormID()
  13879. return nil
  13880. case contactfield.FieldValue:
  13881. m.ResetValue()
  13882. return nil
  13883. }
  13884. return fmt.Errorf("unknown ContactField field %s", name)
  13885. }
  13886. // AddedEdges returns all edge names that were set/added in this mutation.
  13887. func (m *ContactFieldMutation) AddedEdges() []string {
  13888. edges := make([]string, 0, 1)
  13889. if m.field_contact != nil {
  13890. edges = append(edges, contactfield.EdgeFieldContact)
  13891. }
  13892. return edges
  13893. }
  13894. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13895. // name in this mutation.
  13896. func (m *ContactFieldMutation) AddedIDs(name string) []ent.Value {
  13897. switch name {
  13898. case contactfield.EdgeFieldContact:
  13899. if id := m.field_contact; id != nil {
  13900. return []ent.Value{*id}
  13901. }
  13902. }
  13903. return nil
  13904. }
  13905. // RemovedEdges returns all edge names that were removed in this mutation.
  13906. func (m *ContactFieldMutation) RemovedEdges() []string {
  13907. edges := make([]string, 0, 1)
  13908. return edges
  13909. }
  13910. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13911. // the given name in this mutation.
  13912. func (m *ContactFieldMutation) RemovedIDs(name string) []ent.Value {
  13913. return nil
  13914. }
  13915. // ClearedEdges returns all edge names that were cleared in this mutation.
  13916. func (m *ContactFieldMutation) ClearedEdges() []string {
  13917. edges := make([]string, 0, 1)
  13918. if m.clearedfield_contact {
  13919. edges = append(edges, contactfield.EdgeFieldContact)
  13920. }
  13921. return edges
  13922. }
  13923. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13924. // was cleared in this mutation.
  13925. func (m *ContactFieldMutation) EdgeCleared(name string) bool {
  13926. switch name {
  13927. case contactfield.EdgeFieldContact:
  13928. return m.clearedfield_contact
  13929. }
  13930. return false
  13931. }
  13932. // ClearEdge clears the value of the edge with the given name. It returns an error
  13933. // if that edge is not defined in the schema.
  13934. func (m *ContactFieldMutation) ClearEdge(name string) error {
  13935. switch name {
  13936. case contactfield.EdgeFieldContact:
  13937. m.ClearFieldContact()
  13938. return nil
  13939. }
  13940. return fmt.Errorf("unknown ContactField unique edge %s", name)
  13941. }
  13942. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13943. // It returns an error if the edge is not defined in the schema.
  13944. func (m *ContactFieldMutation) ResetEdge(name string) error {
  13945. switch name {
  13946. case contactfield.EdgeFieldContact:
  13947. m.ResetFieldContact()
  13948. return nil
  13949. }
  13950. return fmt.Errorf("unknown ContactField edge %s", name)
  13951. }
  13952. // ContactFieldTemplateMutation represents an operation that mutates the ContactFieldTemplate nodes in the graph.
  13953. type ContactFieldTemplateMutation struct {
  13954. config
  13955. op Op
  13956. typ string
  13957. id *uint64
  13958. created_at *time.Time
  13959. updated_at *time.Time
  13960. status *uint8
  13961. addstatus *int8
  13962. deleted_at *time.Time
  13963. organization_id *uint64
  13964. addorganization_id *int64
  13965. template *[]custom_types.ContactFieldTemplate
  13966. appendtemplate []custom_types.ContactFieldTemplate
  13967. clearedFields map[string]struct{}
  13968. done bool
  13969. oldValue func(context.Context) (*ContactFieldTemplate, error)
  13970. predicates []predicate.ContactFieldTemplate
  13971. }
  13972. var _ ent.Mutation = (*ContactFieldTemplateMutation)(nil)
  13973. // contactfieldtemplateOption allows management of the mutation configuration using functional options.
  13974. type contactfieldtemplateOption func(*ContactFieldTemplateMutation)
  13975. // newContactFieldTemplateMutation creates new mutation for the ContactFieldTemplate entity.
  13976. func newContactFieldTemplateMutation(c config, op Op, opts ...contactfieldtemplateOption) *ContactFieldTemplateMutation {
  13977. m := &ContactFieldTemplateMutation{
  13978. config: c,
  13979. op: op,
  13980. typ: TypeContactFieldTemplate,
  13981. clearedFields: make(map[string]struct{}),
  13982. }
  13983. for _, opt := range opts {
  13984. opt(m)
  13985. }
  13986. return m
  13987. }
  13988. // withContactFieldTemplateID sets the ID field of the mutation.
  13989. func withContactFieldTemplateID(id uint64) contactfieldtemplateOption {
  13990. return func(m *ContactFieldTemplateMutation) {
  13991. var (
  13992. err error
  13993. once sync.Once
  13994. value *ContactFieldTemplate
  13995. )
  13996. m.oldValue = func(ctx context.Context) (*ContactFieldTemplate, error) {
  13997. once.Do(func() {
  13998. if m.done {
  13999. err = errors.New("querying old values post mutation is not allowed")
  14000. } else {
  14001. value, err = m.Client().ContactFieldTemplate.Get(ctx, id)
  14002. }
  14003. })
  14004. return value, err
  14005. }
  14006. m.id = &id
  14007. }
  14008. }
  14009. // withContactFieldTemplate sets the old ContactFieldTemplate of the mutation.
  14010. func withContactFieldTemplate(node *ContactFieldTemplate) contactfieldtemplateOption {
  14011. return func(m *ContactFieldTemplateMutation) {
  14012. m.oldValue = func(context.Context) (*ContactFieldTemplate, error) {
  14013. return node, nil
  14014. }
  14015. m.id = &node.ID
  14016. }
  14017. }
  14018. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14019. // executed in a transaction (ent.Tx), a transactional client is returned.
  14020. func (m ContactFieldTemplateMutation) Client() *Client {
  14021. client := &Client{config: m.config}
  14022. client.init()
  14023. return client
  14024. }
  14025. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14026. // it returns an error otherwise.
  14027. func (m ContactFieldTemplateMutation) Tx() (*Tx, error) {
  14028. if _, ok := m.driver.(*txDriver); !ok {
  14029. return nil, errors.New("ent: mutation is not running in a transaction")
  14030. }
  14031. tx := &Tx{config: m.config}
  14032. tx.init()
  14033. return tx, nil
  14034. }
  14035. // SetID sets the value of the id field. Note that this
  14036. // operation is only accepted on creation of ContactFieldTemplate entities.
  14037. func (m *ContactFieldTemplateMutation) SetID(id uint64) {
  14038. m.id = &id
  14039. }
  14040. // ID returns the ID value in the mutation. Note that the ID is only available
  14041. // if it was provided to the builder or after it was returned from the database.
  14042. func (m *ContactFieldTemplateMutation) ID() (id uint64, exists bool) {
  14043. if m.id == nil {
  14044. return
  14045. }
  14046. return *m.id, true
  14047. }
  14048. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14049. // That means, if the mutation is applied within a transaction with an isolation level such
  14050. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14051. // or updated by the mutation.
  14052. func (m *ContactFieldTemplateMutation) IDs(ctx context.Context) ([]uint64, error) {
  14053. switch {
  14054. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14055. id, exists := m.ID()
  14056. if exists {
  14057. return []uint64{id}, nil
  14058. }
  14059. fallthrough
  14060. case m.op.Is(OpUpdate | OpDelete):
  14061. return m.Client().ContactFieldTemplate.Query().Where(m.predicates...).IDs(ctx)
  14062. default:
  14063. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14064. }
  14065. }
  14066. // SetCreatedAt sets the "created_at" field.
  14067. func (m *ContactFieldTemplateMutation) SetCreatedAt(t time.Time) {
  14068. m.created_at = &t
  14069. }
  14070. // CreatedAt returns the value of the "created_at" field in the mutation.
  14071. func (m *ContactFieldTemplateMutation) CreatedAt() (r time.Time, exists bool) {
  14072. v := m.created_at
  14073. if v == nil {
  14074. return
  14075. }
  14076. return *v, true
  14077. }
  14078. // OldCreatedAt returns the old "created_at" field's value of the ContactFieldTemplate entity.
  14079. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  14080. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14081. func (m *ContactFieldTemplateMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14082. if !m.op.Is(OpUpdateOne) {
  14083. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14084. }
  14085. if m.id == nil || m.oldValue == nil {
  14086. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14087. }
  14088. oldValue, err := m.oldValue(ctx)
  14089. if err != nil {
  14090. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14091. }
  14092. return oldValue.CreatedAt, nil
  14093. }
  14094. // ResetCreatedAt resets all changes to the "created_at" field.
  14095. func (m *ContactFieldTemplateMutation) ResetCreatedAt() {
  14096. m.created_at = nil
  14097. }
  14098. // SetUpdatedAt sets the "updated_at" field.
  14099. func (m *ContactFieldTemplateMutation) SetUpdatedAt(t time.Time) {
  14100. m.updated_at = &t
  14101. }
  14102. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14103. func (m *ContactFieldTemplateMutation) UpdatedAt() (r time.Time, exists bool) {
  14104. v := m.updated_at
  14105. if v == nil {
  14106. return
  14107. }
  14108. return *v, true
  14109. }
  14110. // OldUpdatedAt returns the old "updated_at" field's value of the ContactFieldTemplate entity.
  14111. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  14112. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14113. func (m *ContactFieldTemplateMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14114. if !m.op.Is(OpUpdateOne) {
  14115. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14116. }
  14117. if m.id == nil || m.oldValue == nil {
  14118. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14119. }
  14120. oldValue, err := m.oldValue(ctx)
  14121. if err != nil {
  14122. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14123. }
  14124. return oldValue.UpdatedAt, nil
  14125. }
  14126. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14127. func (m *ContactFieldTemplateMutation) ResetUpdatedAt() {
  14128. m.updated_at = nil
  14129. }
  14130. // SetStatus sets the "status" field.
  14131. func (m *ContactFieldTemplateMutation) SetStatus(u uint8) {
  14132. m.status = &u
  14133. m.addstatus = nil
  14134. }
  14135. // Status returns the value of the "status" field in the mutation.
  14136. func (m *ContactFieldTemplateMutation) Status() (r uint8, exists bool) {
  14137. v := m.status
  14138. if v == nil {
  14139. return
  14140. }
  14141. return *v, true
  14142. }
  14143. // OldStatus returns the old "status" field's value of the ContactFieldTemplate entity.
  14144. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  14145. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14146. func (m *ContactFieldTemplateMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14147. if !m.op.Is(OpUpdateOne) {
  14148. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14149. }
  14150. if m.id == nil || m.oldValue == nil {
  14151. return v, errors.New("OldStatus requires an ID field in the mutation")
  14152. }
  14153. oldValue, err := m.oldValue(ctx)
  14154. if err != nil {
  14155. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14156. }
  14157. return oldValue.Status, nil
  14158. }
  14159. // AddStatus adds u to the "status" field.
  14160. func (m *ContactFieldTemplateMutation) AddStatus(u int8) {
  14161. if m.addstatus != nil {
  14162. *m.addstatus += u
  14163. } else {
  14164. m.addstatus = &u
  14165. }
  14166. }
  14167. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14168. func (m *ContactFieldTemplateMutation) AddedStatus() (r int8, exists bool) {
  14169. v := m.addstatus
  14170. if v == nil {
  14171. return
  14172. }
  14173. return *v, true
  14174. }
  14175. // ClearStatus clears the value of the "status" field.
  14176. func (m *ContactFieldTemplateMutation) ClearStatus() {
  14177. m.status = nil
  14178. m.addstatus = nil
  14179. m.clearedFields[contactfieldtemplate.FieldStatus] = struct{}{}
  14180. }
  14181. // StatusCleared returns if the "status" field was cleared in this mutation.
  14182. func (m *ContactFieldTemplateMutation) StatusCleared() bool {
  14183. _, ok := m.clearedFields[contactfieldtemplate.FieldStatus]
  14184. return ok
  14185. }
  14186. // ResetStatus resets all changes to the "status" field.
  14187. func (m *ContactFieldTemplateMutation) ResetStatus() {
  14188. m.status = nil
  14189. m.addstatus = nil
  14190. delete(m.clearedFields, contactfieldtemplate.FieldStatus)
  14191. }
  14192. // SetDeletedAt sets the "deleted_at" field.
  14193. func (m *ContactFieldTemplateMutation) SetDeletedAt(t time.Time) {
  14194. m.deleted_at = &t
  14195. }
  14196. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14197. func (m *ContactFieldTemplateMutation) DeletedAt() (r time.Time, exists bool) {
  14198. v := m.deleted_at
  14199. if v == nil {
  14200. return
  14201. }
  14202. return *v, true
  14203. }
  14204. // OldDeletedAt returns the old "deleted_at" field's value of the ContactFieldTemplate entity.
  14205. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  14206. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14207. func (m *ContactFieldTemplateMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14208. if !m.op.Is(OpUpdateOne) {
  14209. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14210. }
  14211. if m.id == nil || m.oldValue == nil {
  14212. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14213. }
  14214. oldValue, err := m.oldValue(ctx)
  14215. if err != nil {
  14216. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14217. }
  14218. return oldValue.DeletedAt, nil
  14219. }
  14220. // ClearDeletedAt clears the value of the "deleted_at" field.
  14221. func (m *ContactFieldTemplateMutation) ClearDeletedAt() {
  14222. m.deleted_at = nil
  14223. m.clearedFields[contactfieldtemplate.FieldDeletedAt] = struct{}{}
  14224. }
  14225. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14226. func (m *ContactFieldTemplateMutation) DeletedAtCleared() bool {
  14227. _, ok := m.clearedFields[contactfieldtemplate.FieldDeletedAt]
  14228. return ok
  14229. }
  14230. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14231. func (m *ContactFieldTemplateMutation) ResetDeletedAt() {
  14232. m.deleted_at = nil
  14233. delete(m.clearedFields, contactfieldtemplate.FieldDeletedAt)
  14234. }
  14235. // SetOrganizationID sets the "organization_id" field.
  14236. func (m *ContactFieldTemplateMutation) SetOrganizationID(u uint64) {
  14237. m.organization_id = &u
  14238. m.addorganization_id = nil
  14239. }
  14240. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14241. func (m *ContactFieldTemplateMutation) OrganizationID() (r uint64, exists bool) {
  14242. v := m.organization_id
  14243. if v == nil {
  14244. return
  14245. }
  14246. return *v, true
  14247. }
  14248. // OldOrganizationID returns the old "organization_id" field's value of the ContactFieldTemplate entity.
  14249. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  14250. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14251. func (m *ContactFieldTemplateMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14252. if !m.op.Is(OpUpdateOne) {
  14253. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14254. }
  14255. if m.id == nil || m.oldValue == nil {
  14256. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14257. }
  14258. oldValue, err := m.oldValue(ctx)
  14259. if err != nil {
  14260. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14261. }
  14262. return oldValue.OrganizationID, nil
  14263. }
  14264. // AddOrganizationID adds u to the "organization_id" field.
  14265. func (m *ContactFieldTemplateMutation) AddOrganizationID(u int64) {
  14266. if m.addorganization_id != nil {
  14267. *m.addorganization_id += u
  14268. } else {
  14269. m.addorganization_id = &u
  14270. }
  14271. }
  14272. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14273. func (m *ContactFieldTemplateMutation) AddedOrganizationID() (r int64, exists bool) {
  14274. v := m.addorganization_id
  14275. if v == nil {
  14276. return
  14277. }
  14278. return *v, true
  14279. }
  14280. // ResetOrganizationID resets all changes to the "organization_id" field.
  14281. func (m *ContactFieldTemplateMutation) ResetOrganizationID() {
  14282. m.organization_id = nil
  14283. m.addorganization_id = nil
  14284. }
  14285. // SetTemplate sets the "template" field.
  14286. func (m *ContactFieldTemplateMutation) SetTemplate(ctft []custom_types.ContactFieldTemplate) {
  14287. m.template = &ctft
  14288. m.appendtemplate = nil
  14289. }
  14290. // Template returns the value of the "template" field in the mutation.
  14291. func (m *ContactFieldTemplateMutation) Template() (r []custom_types.ContactFieldTemplate, exists bool) {
  14292. v := m.template
  14293. if v == nil {
  14294. return
  14295. }
  14296. return *v, true
  14297. }
  14298. // OldTemplate returns the old "template" field's value of the ContactFieldTemplate entity.
  14299. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  14300. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14301. func (m *ContactFieldTemplateMutation) OldTemplate(ctx context.Context) (v []custom_types.ContactFieldTemplate, err error) {
  14302. if !m.op.Is(OpUpdateOne) {
  14303. return v, errors.New("OldTemplate is only allowed on UpdateOne operations")
  14304. }
  14305. if m.id == nil || m.oldValue == nil {
  14306. return v, errors.New("OldTemplate requires an ID field in the mutation")
  14307. }
  14308. oldValue, err := m.oldValue(ctx)
  14309. if err != nil {
  14310. return v, fmt.Errorf("querying old value for OldTemplate: %w", err)
  14311. }
  14312. return oldValue.Template, nil
  14313. }
  14314. // AppendTemplate adds ctft to the "template" field.
  14315. func (m *ContactFieldTemplateMutation) AppendTemplate(ctft []custom_types.ContactFieldTemplate) {
  14316. m.appendtemplate = append(m.appendtemplate, ctft...)
  14317. }
  14318. // AppendedTemplate returns the list of values that were appended to the "template" field in this mutation.
  14319. func (m *ContactFieldTemplateMutation) AppendedTemplate() ([]custom_types.ContactFieldTemplate, bool) {
  14320. if len(m.appendtemplate) == 0 {
  14321. return nil, false
  14322. }
  14323. return m.appendtemplate, true
  14324. }
  14325. // ResetTemplate resets all changes to the "template" field.
  14326. func (m *ContactFieldTemplateMutation) ResetTemplate() {
  14327. m.template = nil
  14328. m.appendtemplate = nil
  14329. }
  14330. // Where appends a list predicates to the ContactFieldTemplateMutation builder.
  14331. func (m *ContactFieldTemplateMutation) Where(ps ...predicate.ContactFieldTemplate) {
  14332. m.predicates = append(m.predicates, ps...)
  14333. }
  14334. // WhereP appends storage-level predicates to the ContactFieldTemplateMutation builder. Using this method,
  14335. // users can use type-assertion to append predicates that do not depend on any generated package.
  14336. func (m *ContactFieldTemplateMutation) WhereP(ps ...func(*sql.Selector)) {
  14337. p := make([]predicate.ContactFieldTemplate, len(ps))
  14338. for i := range ps {
  14339. p[i] = ps[i]
  14340. }
  14341. m.Where(p...)
  14342. }
  14343. // Op returns the operation name.
  14344. func (m *ContactFieldTemplateMutation) Op() Op {
  14345. return m.op
  14346. }
  14347. // SetOp allows setting the mutation operation.
  14348. func (m *ContactFieldTemplateMutation) SetOp(op Op) {
  14349. m.op = op
  14350. }
  14351. // Type returns the node type of this mutation (ContactFieldTemplate).
  14352. func (m *ContactFieldTemplateMutation) Type() string {
  14353. return m.typ
  14354. }
  14355. // Fields returns all fields that were changed during this mutation. Note that in
  14356. // order to get all numeric fields that were incremented/decremented, call
  14357. // AddedFields().
  14358. func (m *ContactFieldTemplateMutation) Fields() []string {
  14359. fields := make([]string, 0, 6)
  14360. if m.created_at != nil {
  14361. fields = append(fields, contactfieldtemplate.FieldCreatedAt)
  14362. }
  14363. if m.updated_at != nil {
  14364. fields = append(fields, contactfieldtemplate.FieldUpdatedAt)
  14365. }
  14366. if m.status != nil {
  14367. fields = append(fields, contactfieldtemplate.FieldStatus)
  14368. }
  14369. if m.deleted_at != nil {
  14370. fields = append(fields, contactfieldtemplate.FieldDeletedAt)
  14371. }
  14372. if m.organization_id != nil {
  14373. fields = append(fields, contactfieldtemplate.FieldOrganizationID)
  14374. }
  14375. if m.template != nil {
  14376. fields = append(fields, contactfieldtemplate.FieldTemplate)
  14377. }
  14378. return fields
  14379. }
  14380. // Field returns the value of a field with the given name. The second boolean
  14381. // return value indicates that this field was not set, or was not defined in the
  14382. // schema.
  14383. func (m *ContactFieldTemplateMutation) Field(name string) (ent.Value, bool) {
  14384. switch name {
  14385. case contactfieldtemplate.FieldCreatedAt:
  14386. return m.CreatedAt()
  14387. case contactfieldtemplate.FieldUpdatedAt:
  14388. return m.UpdatedAt()
  14389. case contactfieldtemplate.FieldStatus:
  14390. return m.Status()
  14391. case contactfieldtemplate.FieldDeletedAt:
  14392. return m.DeletedAt()
  14393. case contactfieldtemplate.FieldOrganizationID:
  14394. return m.OrganizationID()
  14395. case contactfieldtemplate.FieldTemplate:
  14396. return m.Template()
  14397. }
  14398. return nil, false
  14399. }
  14400. // OldField returns the old value of the field from the database. An error is
  14401. // returned if the mutation operation is not UpdateOne, or the query to the
  14402. // database failed.
  14403. func (m *ContactFieldTemplateMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14404. switch name {
  14405. case contactfieldtemplate.FieldCreatedAt:
  14406. return m.OldCreatedAt(ctx)
  14407. case contactfieldtemplate.FieldUpdatedAt:
  14408. return m.OldUpdatedAt(ctx)
  14409. case contactfieldtemplate.FieldStatus:
  14410. return m.OldStatus(ctx)
  14411. case contactfieldtemplate.FieldDeletedAt:
  14412. return m.OldDeletedAt(ctx)
  14413. case contactfieldtemplate.FieldOrganizationID:
  14414. return m.OldOrganizationID(ctx)
  14415. case contactfieldtemplate.FieldTemplate:
  14416. return m.OldTemplate(ctx)
  14417. }
  14418. return nil, fmt.Errorf("unknown ContactFieldTemplate 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 *ContactFieldTemplateMutation) SetField(name string, value ent.Value) error {
  14424. switch name {
  14425. case contactfieldtemplate.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 contactfieldtemplate.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 contactfieldtemplate.FieldStatus:
  14440. v, ok := value.(uint8)
  14441. if !ok {
  14442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14443. }
  14444. m.SetStatus(v)
  14445. return nil
  14446. case contactfieldtemplate.FieldDeletedAt:
  14447. v, ok := value.(time.Time)
  14448. if !ok {
  14449. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14450. }
  14451. m.SetDeletedAt(v)
  14452. return nil
  14453. case contactfieldtemplate.FieldOrganizationID:
  14454. v, ok := value.(uint64)
  14455. if !ok {
  14456. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14457. }
  14458. m.SetOrganizationID(v)
  14459. return nil
  14460. case contactfieldtemplate.FieldTemplate:
  14461. v, ok := value.([]custom_types.ContactFieldTemplate)
  14462. if !ok {
  14463. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14464. }
  14465. m.SetTemplate(v)
  14466. return nil
  14467. }
  14468. return fmt.Errorf("unknown ContactFieldTemplate field %s", name)
  14469. }
  14470. // AddedFields returns all numeric fields that were incremented/decremented during
  14471. // this mutation.
  14472. func (m *ContactFieldTemplateMutation) AddedFields() []string {
  14473. var fields []string
  14474. if m.addstatus != nil {
  14475. fields = append(fields, contactfieldtemplate.FieldStatus)
  14476. }
  14477. if m.addorganization_id != nil {
  14478. fields = append(fields, contactfieldtemplate.FieldOrganizationID)
  14479. }
  14480. return fields
  14481. }
  14482. // AddedField returns the numeric value that was incremented/decremented on a field
  14483. // with the given name. The second boolean return value indicates that this field
  14484. // was not set, or was not defined in the schema.
  14485. func (m *ContactFieldTemplateMutation) AddedField(name string) (ent.Value, bool) {
  14486. switch name {
  14487. case contactfieldtemplate.FieldStatus:
  14488. return m.AddedStatus()
  14489. case contactfieldtemplate.FieldOrganizationID:
  14490. return m.AddedOrganizationID()
  14491. }
  14492. return nil, false
  14493. }
  14494. // AddField adds the value to the field with the given name. It returns an error if
  14495. // the field is not defined in the schema, or if the type mismatched the field
  14496. // type.
  14497. func (m *ContactFieldTemplateMutation) AddField(name string, value ent.Value) error {
  14498. switch name {
  14499. case contactfieldtemplate.FieldStatus:
  14500. v, ok := value.(int8)
  14501. if !ok {
  14502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14503. }
  14504. m.AddStatus(v)
  14505. return nil
  14506. case contactfieldtemplate.FieldOrganizationID:
  14507. v, ok := value.(int64)
  14508. if !ok {
  14509. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14510. }
  14511. m.AddOrganizationID(v)
  14512. return nil
  14513. }
  14514. return fmt.Errorf("unknown ContactFieldTemplate numeric field %s", name)
  14515. }
  14516. // ClearedFields returns all nullable fields that were cleared during this
  14517. // mutation.
  14518. func (m *ContactFieldTemplateMutation) ClearedFields() []string {
  14519. var fields []string
  14520. if m.FieldCleared(contactfieldtemplate.FieldStatus) {
  14521. fields = append(fields, contactfieldtemplate.FieldStatus)
  14522. }
  14523. if m.FieldCleared(contactfieldtemplate.FieldDeletedAt) {
  14524. fields = append(fields, contactfieldtemplate.FieldDeletedAt)
  14525. }
  14526. return fields
  14527. }
  14528. // FieldCleared returns a boolean indicating if a field with the given name was
  14529. // cleared in this mutation.
  14530. func (m *ContactFieldTemplateMutation) FieldCleared(name string) bool {
  14531. _, ok := m.clearedFields[name]
  14532. return ok
  14533. }
  14534. // ClearField clears the value of the field with the given name. It returns an
  14535. // error if the field is not defined in the schema.
  14536. func (m *ContactFieldTemplateMutation) ClearField(name string) error {
  14537. switch name {
  14538. case contactfieldtemplate.FieldStatus:
  14539. m.ClearStatus()
  14540. return nil
  14541. case contactfieldtemplate.FieldDeletedAt:
  14542. m.ClearDeletedAt()
  14543. return nil
  14544. }
  14545. return fmt.Errorf("unknown ContactFieldTemplate nullable field %s", name)
  14546. }
  14547. // ResetField resets all changes in the mutation for the field with the given name.
  14548. // It returns an error if the field is not defined in the schema.
  14549. func (m *ContactFieldTemplateMutation) ResetField(name string) error {
  14550. switch name {
  14551. case contactfieldtemplate.FieldCreatedAt:
  14552. m.ResetCreatedAt()
  14553. return nil
  14554. case contactfieldtemplate.FieldUpdatedAt:
  14555. m.ResetUpdatedAt()
  14556. return nil
  14557. case contactfieldtemplate.FieldStatus:
  14558. m.ResetStatus()
  14559. return nil
  14560. case contactfieldtemplate.FieldDeletedAt:
  14561. m.ResetDeletedAt()
  14562. return nil
  14563. case contactfieldtemplate.FieldOrganizationID:
  14564. m.ResetOrganizationID()
  14565. return nil
  14566. case contactfieldtemplate.FieldTemplate:
  14567. m.ResetTemplate()
  14568. return nil
  14569. }
  14570. return fmt.Errorf("unknown ContactFieldTemplate field %s", name)
  14571. }
  14572. // AddedEdges returns all edge names that were set/added in this mutation.
  14573. func (m *ContactFieldTemplateMutation) AddedEdges() []string {
  14574. edges := make([]string, 0, 0)
  14575. return edges
  14576. }
  14577. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14578. // name in this mutation.
  14579. func (m *ContactFieldTemplateMutation) AddedIDs(name string) []ent.Value {
  14580. return nil
  14581. }
  14582. // RemovedEdges returns all edge names that were removed in this mutation.
  14583. func (m *ContactFieldTemplateMutation) RemovedEdges() []string {
  14584. edges := make([]string, 0, 0)
  14585. return edges
  14586. }
  14587. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14588. // the given name in this mutation.
  14589. func (m *ContactFieldTemplateMutation) RemovedIDs(name string) []ent.Value {
  14590. return nil
  14591. }
  14592. // ClearedEdges returns all edge names that were cleared in this mutation.
  14593. func (m *ContactFieldTemplateMutation) ClearedEdges() []string {
  14594. edges := make([]string, 0, 0)
  14595. return edges
  14596. }
  14597. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14598. // was cleared in this mutation.
  14599. func (m *ContactFieldTemplateMutation) EdgeCleared(name string) bool {
  14600. return false
  14601. }
  14602. // ClearEdge clears the value of the edge with the given name. It returns an error
  14603. // if that edge is not defined in the schema.
  14604. func (m *ContactFieldTemplateMutation) ClearEdge(name string) error {
  14605. return fmt.Errorf("unknown ContactFieldTemplate unique edge %s", name)
  14606. }
  14607. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14608. // It returns an error if the edge is not defined in the schema.
  14609. func (m *ContactFieldTemplateMutation) ResetEdge(name string) error {
  14610. return fmt.Errorf("unknown ContactFieldTemplate edge %s", name)
  14611. }
  14612. // CreditBalanceMutation represents an operation that mutates the CreditBalance nodes in the graph.
  14613. type CreditBalanceMutation struct {
  14614. config
  14615. op Op
  14616. typ string
  14617. id *uint64
  14618. created_at *time.Time
  14619. updated_at *time.Time
  14620. deleted_at *time.Time
  14621. user_id *string
  14622. balance *float64
  14623. addbalance *float64
  14624. status *int
  14625. addstatus *int
  14626. organization_id *uint64
  14627. addorganization_id *int64
  14628. clearedFields map[string]struct{}
  14629. done bool
  14630. oldValue func(context.Context) (*CreditBalance, error)
  14631. predicates []predicate.CreditBalance
  14632. }
  14633. var _ ent.Mutation = (*CreditBalanceMutation)(nil)
  14634. // creditbalanceOption allows management of the mutation configuration using functional options.
  14635. type creditbalanceOption func(*CreditBalanceMutation)
  14636. // newCreditBalanceMutation creates new mutation for the CreditBalance entity.
  14637. func newCreditBalanceMutation(c config, op Op, opts ...creditbalanceOption) *CreditBalanceMutation {
  14638. m := &CreditBalanceMutation{
  14639. config: c,
  14640. op: op,
  14641. typ: TypeCreditBalance,
  14642. clearedFields: make(map[string]struct{}),
  14643. }
  14644. for _, opt := range opts {
  14645. opt(m)
  14646. }
  14647. return m
  14648. }
  14649. // withCreditBalanceID sets the ID field of the mutation.
  14650. func withCreditBalanceID(id uint64) creditbalanceOption {
  14651. return func(m *CreditBalanceMutation) {
  14652. var (
  14653. err error
  14654. once sync.Once
  14655. value *CreditBalance
  14656. )
  14657. m.oldValue = func(ctx context.Context) (*CreditBalance, error) {
  14658. once.Do(func() {
  14659. if m.done {
  14660. err = errors.New("querying old values post mutation is not allowed")
  14661. } else {
  14662. value, err = m.Client().CreditBalance.Get(ctx, id)
  14663. }
  14664. })
  14665. return value, err
  14666. }
  14667. m.id = &id
  14668. }
  14669. }
  14670. // withCreditBalance sets the old CreditBalance of the mutation.
  14671. func withCreditBalance(node *CreditBalance) creditbalanceOption {
  14672. return func(m *CreditBalanceMutation) {
  14673. m.oldValue = func(context.Context) (*CreditBalance, error) {
  14674. return node, nil
  14675. }
  14676. m.id = &node.ID
  14677. }
  14678. }
  14679. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14680. // executed in a transaction (ent.Tx), a transactional client is returned.
  14681. func (m CreditBalanceMutation) Client() *Client {
  14682. client := &Client{config: m.config}
  14683. client.init()
  14684. return client
  14685. }
  14686. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14687. // it returns an error otherwise.
  14688. func (m CreditBalanceMutation) Tx() (*Tx, error) {
  14689. if _, ok := m.driver.(*txDriver); !ok {
  14690. return nil, errors.New("ent: mutation is not running in a transaction")
  14691. }
  14692. tx := &Tx{config: m.config}
  14693. tx.init()
  14694. return tx, nil
  14695. }
  14696. // SetID sets the value of the id field. Note that this
  14697. // operation is only accepted on creation of CreditBalance entities.
  14698. func (m *CreditBalanceMutation) SetID(id uint64) {
  14699. m.id = &id
  14700. }
  14701. // ID returns the ID value in the mutation. Note that the ID is only available
  14702. // if it was provided to the builder or after it was returned from the database.
  14703. func (m *CreditBalanceMutation) ID() (id uint64, exists bool) {
  14704. if m.id == nil {
  14705. return
  14706. }
  14707. return *m.id, true
  14708. }
  14709. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14710. // That means, if the mutation is applied within a transaction with an isolation level such
  14711. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14712. // or updated by the mutation.
  14713. func (m *CreditBalanceMutation) IDs(ctx context.Context) ([]uint64, error) {
  14714. switch {
  14715. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14716. id, exists := m.ID()
  14717. if exists {
  14718. return []uint64{id}, nil
  14719. }
  14720. fallthrough
  14721. case m.op.Is(OpUpdate | OpDelete):
  14722. return m.Client().CreditBalance.Query().Where(m.predicates...).IDs(ctx)
  14723. default:
  14724. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14725. }
  14726. }
  14727. // SetCreatedAt sets the "created_at" field.
  14728. func (m *CreditBalanceMutation) SetCreatedAt(t time.Time) {
  14729. m.created_at = &t
  14730. }
  14731. // CreatedAt returns the value of the "created_at" field in the mutation.
  14732. func (m *CreditBalanceMutation) CreatedAt() (r time.Time, exists bool) {
  14733. v := m.created_at
  14734. if v == nil {
  14735. return
  14736. }
  14737. return *v, true
  14738. }
  14739. // OldCreatedAt returns the old "created_at" field's value of the CreditBalance entity.
  14740. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  14741. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14742. func (m *CreditBalanceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14743. if !m.op.Is(OpUpdateOne) {
  14744. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14745. }
  14746. if m.id == nil || m.oldValue == nil {
  14747. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14748. }
  14749. oldValue, err := m.oldValue(ctx)
  14750. if err != nil {
  14751. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14752. }
  14753. return oldValue.CreatedAt, nil
  14754. }
  14755. // ResetCreatedAt resets all changes to the "created_at" field.
  14756. func (m *CreditBalanceMutation) ResetCreatedAt() {
  14757. m.created_at = nil
  14758. }
  14759. // SetUpdatedAt sets the "updated_at" field.
  14760. func (m *CreditBalanceMutation) SetUpdatedAt(t time.Time) {
  14761. m.updated_at = &t
  14762. }
  14763. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14764. func (m *CreditBalanceMutation) UpdatedAt() (r time.Time, exists bool) {
  14765. v := m.updated_at
  14766. if v == nil {
  14767. return
  14768. }
  14769. return *v, true
  14770. }
  14771. // OldUpdatedAt returns the old "updated_at" field's value of the CreditBalance entity.
  14772. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  14773. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14774. func (m *CreditBalanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14775. if !m.op.Is(OpUpdateOne) {
  14776. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14777. }
  14778. if m.id == nil || m.oldValue == nil {
  14779. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14780. }
  14781. oldValue, err := m.oldValue(ctx)
  14782. if err != nil {
  14783. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14784. }
  14785. return oldValue.UpdatedAt, nil
  14786. }
  14787. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14788. func (m *CreditBalanceMutation) ResetUpdatedAt() {
  14789. m.updated_at = nil
  14790. }
  14791. // SetDeletedAt sets the "deleted_at" field.
  14792. func (m *CreditBalanceMutation) SetDeletedAt(t time.Time) {
  14793. m.deleted_at = &t
  14794. }
  14795. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14796. func (m *CreditBalanceMutation) DeletedAt() (r time.Time, exists bool) {
  14797. v := m.deleted_at
  14798. if v == nil {
  14799. return
  14800. }
  14801. return *v, true
  14802. }
  14803. // OldDeletedAt returns the old "deleted_at" field's value of the CreditBalance entity.
  14804. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  14805. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14806. func (m *CreditBalanceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14807. if !m.op.Is(OpUpdateOne) {
  14808. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14809. }
  14810. if m.id == nil || m.oldValue == nil {
  14811. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14812. }
  14813. oldValue, err := m.oldValue(ctx)
  14814. if err != nil {
  14815. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14816. }
  14817. return oldValue.DeletedAt, nil
  14818. }
  14819. // ClearDeletedAt clears the value of the "deleted_at" field.
  14820. func (m *CreditBalanceMutation) ClearDeletedAt() {
  14821. m.deleted_at = nil
  14822. m.clearedFields[creditbalance.FieldDeletedAt] = struct{}{}
  14823. }
  14824. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14825. func (m *CreditBalanceMutation) DeletedAtCleared() bool {
  14826. _, ok := m.clearedFields[creditbalance.FieldDeletedAt]
  14827. return ok
  14828. }
  14829. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14830. func (m *CreditBalanceMutation) ResetDeletedAt() {
  14831. m.deleted_at = nil
  14832. delete(m.clearedFields, creditbalance.FieldDeletedAt)
  14833. }
  14834. // SetUserID sets the "user_id" field.
  14835. func (m *CreditBalanceMutation) SetUserID(s string) {
  14836. m.user_id = &s
  14837. }
  14838. // UserID returns the value of the "user_id" field in the mutation.
  14839. func (m *CreditBalanceMutation) UserID() (r string, exists bool) {
  14840. v := m.user_id
  14841. if v == nil {
  14842. return
  14843. }
  14844. return *v, true
  14845. }
  14846. // OldUserID returns the old "user_id" field's value of the CreditBalance entity.
  14847. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  14848. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14849. func (m *CreditBalanceMutation) OldUserID(ctx context.Context) (v string, err error) {
  14850. if !m.op.Is(OpUpdateOne) {
  14851. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  14852. }
  14853. if m.id == nil || m.oldValue == nil {
  14854. return v, errors.New("OldUserID requires an ID field in the mutation")
  14855. }
  14856. oldValue, err := m.oldValue(ctx)
  14857. if err != nil {
  14858. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  14859. }
  14860. return oldValue.UserID, nil
  14861. }
  14862. // ClearUserID clears the value of the "user_id" field.
  14863. func (m *CreditBalanceMutation) ClearUserID() {
  14864. m.user_id = nil
  14865. m.clearedFields[creditbalance.FieldUserID] = struct{}{}
  14866. }
  14867. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  14868. func (m *CreditBalanceMutation) UserIDCleared() bool {
  14869. _, ok := m.clearedFields[creditbalance.FieldUserID]
  14870. return ok
  14871. }
  14872. // ResetUserID resets all changes to the "user_id" field.
  14873. func (m *CreditBalanceMutation) ResetUserID() {
  14874. m.user_id = nil
  14875. delete(m.clearedFields, creditbalance.FieldUserID)
  14876. }
  14877. // SetBalance sets the "balance" field.
  14878. func (m *CreditBalanceMutation) SetBalance(f float64) {
  14879. m.balance = &f
  14880. m.addbalance = nil
  14881. }
  14882. // Balance returns the value of the "balance" field in the mutation.
  14883. func (m *CreditBalanceMutation) Balance() (r float64, exists bool) {
  14884. v := m.balance
  14885. if v == nil {
  14886. return
  14887. }
  14888. return *v, true
  14889. }
  14890. // OldBalance returns the old "balance" field's value of the CreditBalance entity.
  14891. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  14892. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14893. func (m *CreditBalanceMutation) OldBalance(ctx context.Context) (v float64, err error) {
  14894. if !m.op.Is(OpUpdateOne) {
  14895. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  14896. }
  14897. if m.id == nil || m.oldValue == nil {
  14898. return v, errors.New("OldBalance requires an ID field in the mutation")
  14899. }
  14900. oldValue, err := m.oldValue(ctx)
  14901. if err != nil {
  14902. return v, fmt.Errorf("querying old value for OldBalance: %w", err)
  14903. }
  14904. return oldValue.Balance, nil
  14905. }
  14906. // AddBalance adds f to the "balance" field.
  14907. func (m *CreditBalanceMutation) AddBalance(f float64) {
  14908. if m.addbalance != nil {
  14909. *m.addbalance += f
  14910. } else {
  14911. m.addbalance = &f
  14912. }
  14913. }
  14914. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  14915. func (m *CreditBalanceMutation) AddedBalance() (r float64, exists bool) {
  14916. v := m.addbalance
  14917. if v == nil {
  14918. return
  14919. }
  14920. return *v, true
  14921. }
  14922. // ResetBalance resets all changes to the "balance" field.
  14923. func (m *CreditBalanceMutation) ResetBalance() {
  14924. m.balance = nil
  14925. m.addbalance = nil
  14926. }
  14927. // SetStatus sets the "status" field.
  14928. func (m *CreditBalanceMutation) SetStatus(i int) {
  14929. m.status = &i
  14930. m.addstatus = nil
  14931. }
  14932. // Status returns the value of the "status" field in the mutation.
  14933. func (m *CreditBalanceMutation) Status() (r int, exists bool) {
  14934. v := m.status
  14935. if v == nil {
  14936. return
  14937. }
  14938. return *v, true
  14939. }
  14940. // OldStatus returns the old "status" field's value of the CreditBalance entity.
  14941. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  14942. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14943. func (m *CreditBalanceMutation) OldStatus(ctx context.Context) (v int, err error) {
  14944. if !m.op.Is(OpUpdateOne) {
  14945. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14946. }
  14947. if m.id == nil || m.oldValue == nil {
  14948. return v, errors.New("OldStatus requires an ID field in the mutation")
  14949. }
  14950. oldValue, err := m.oldValue(ctx)
  14951. if err != nil {
  14952. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14953. }
  14954. return oldValue.Status, nil
  14955. }
  14956. // AddStatus adds i to the "status" field.
  14957. func (m *CreditBalanceMutation) AddStatus(i int) {
  14958. if m.addstatus != nil {
  14959. *m.addstatus += i
  14960. } else {
  14961. m.addstatus = &i
  14962. }
  14963. }
  14964. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14965. func (m *CreditBalanceMutation) AddedStatus() (r int, exists bool) {
  14966. v := m.addstatus
  14967. if v == nil {
  14968. return
  14969. }
  14970. return *v, true
  14971. }
  14972. // ClearStatus clears the value of the "status" field.
  14973. func (m *CreditBalanceMutation) ClearStatus() {
  14974. m.status = nil
  14975. m.addstatus = nil
  14976. m.clearedFields[creditbalance.FieldStatus] = struct{}{}
  14977. }
  14978. // StatusCleared returns if the "status" field was cleared in this mutation.
  14979. func (m *CreditBalanceMutation) StatusCleared() bool {
  14980. _, ok := m.clearedFields[creditbalance.FieldStatus]
  14981. return ok
  14982. }
  14983. // ResetStatus resets all changes to the "status" field.
  14984. func (m *CreditBalanceMutation) ResetStatus() {
  14985. m.status = nil
  14986. m.addstatus = nil
  14987. delete(m.clearedFields, creditbalance.FieldStatus)
  14988. }
  14989. // SetOrganizationID sets the "organization_id" field.
  14990. func (m *CreditBalanceMutation) SetOrganizationID(u uint64) {
  14991. m.organization_id = &u
  14992. m.addorganization_id = nil
  14993. }
  14994. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14995. func (m *CreditBalanceMutation) OrganizationID() (r uint64, exists bool) {
  14996. v := m.organization_id
  14997. if v == nil {
  14998. return
  14999. }
  15000. return *v, true
  15001. }
  15002. // OldOrganizationID returns the old "organization_id" field's value of the CreditBalance entity.
  15003. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  15004. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15005. func (m *CreditBalanceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15006. if !m.op.Is(OpUpdateOne) {
  15007. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15008. }
  15009. if m.id == nil || m.oldValue == nil {
  15010. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15011. }
  15012. oldValue, err := m.oldValue(ctx)
  15013. if err != nil {
  15014. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15015. }
  15016. return oldValue.OrganizationID, nil
  15017. }
  15018. // AddOrganizationID adds u to the "organization_id" field.
  15019. func (m *CreditBalanceMutation) AddOrganizationID(u int64) {
  15020. if m.addorganization_id != nil {
  15021. *m.addorganization_id += u
  15022. } else {
  15023. m.addorganization_id = &u
  15024. }
  15025. }
  15026. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15027. func (m *CreditBalanceMutation) AddedOrganizationID() (r int64, exists bool) {
  15028. v := m.addorganization_id
  15029. if v == nil {
  15030. return
  15031. }
  15032. return *v, true
  15033. }
  15034. // ClearOrganizationID clears the value of the "organization_id" field.
  15035. func (m *CreditBalanceMutation) ClearOrganizationID() {
  15036. m.organization_id = nil
  15037. m.addorganization_id = nil
  15038. m.clearedFields[creditbalance.FieldOrganizationID] = struct{}{}
  15039. }
  15040. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  15041. func (m *CreditBalanceMutation) OrganizationIDCleared() bool {
  15042. _, ok := m.clearedFields[creditbalance.FieldOrganizationID]
  15043. return ok
  15044. }
  15045. // ResetOrganizationID resets all changes to the "organization_id" field.
  15046. func (m *CreditBalanceMutation) ResetOrganizationID() {
  15047. m.organization_id = nil
  15048. m.addorganization_id = nil
  15049. delete(m.clearedFields, creditbalance.FieldOrganizationID)
  15050. }
  15051. // Where appends a list predicates to the CreditBalanceMutation builder.
  15052. func (m *CreditBalanceMutation) Where(ps ...predicate.CreditBalance) {
  15053. m.predicates = append(m.predicates, ps...)
  15054. }
  15055. // WhereP appends storage-level predicates to the CreditBalanceMutation builder. Using this method,
  15056. // users can use type-assertion to append predicates that do not depend on any generated package.
  15057. func (m *CreditBalanceMutation) WhereP(ps ...func(*sql.Selector)) {
  15058. p := make([]predicate.CreditBalance, len(ps))
  15059. for i := range ps {
  15060. p[i] = ps[i]
  15061. }
  15062. m.Where(p...)
  15063. }
  15064. // Op returns the operation name.
  15065. func (m *CreditBalanceMutation) Op() Op {
  15066. return m.op
  15067. }
  15068. // SetOp allows setting the mutation operation.
  15069. func (m *CreditBalanceMutation) SetOp(op Op) {
  15070. m.op = op
  15071. }
  15072. // Type returns the node type of this mutation (CreditBalance).
  15073. func (m *CreditBalanceMutation) Type() string {
  15074. return m.typ
  15075. }
  15076. // Fields returns all fields that were changed during this mutation. Note that in
  15077. // order to get all numeric fields that were incremented/decremented, call
  15078. // AddedFields().
  15079. func (m *CreditBalanceMutation) Fields() []string {
  15080. fields := make([]string, 0, 7)
  15081. if m.created_at != nil {
  15082. fields = append(fields, creditbalance.FieldCreatedAt)
  15083. }
  15084. if m.updated_at != nil {
  15085. fields = append(fields, creditbalance.FieldUpdatedAt)
  15086. }
  15087. if m.deleted_at != nil {
  15088. fields = append(fields, creditbalance.FieldDeletedAt)
  15089. }
  15090. if m.user_id != nil {
  15091. fields = append(fields, creditbalance.FieldUserID)
  15092. }
  15093. if m.balance != nil {
  15094. fields = append(fields, creditbalance.FieldBalance)
  15095. }
  15096. if m.status != nil {
  15097. fields = append(fields, creditbalance.FieldStatus)
  15098. }
  15099. if m.organization_id != nil {
  15100. fields = append(fields, creditbalance.FieldOrganizationID)
  15101. }
  15102. return fields
  15103. }
  15104. // Field returns the value of a field with the given name. The second boolean
  15105. // return value indicates that this field was not set, or was not defined in the
  15106. // schema.
  15107. func (m *CreditBalanceMutation) Field(name string) (ent.Value, bool) {
  15108. switch name {
  15109. case creditbalance.FieldCreatedAt:
  15110. return m.CreatedAt()
  15111. case creditbalance.FieldUpdatedAt:
  15112. return m.UpdatedAt()
  15113. case creditbalance.FieldDeletedAt:
  15114. return m.DeletedAt()
  15115. case creditbalance.FieldUserID:
  15116. return m.UserID()
  15117. case creditbalance.FieldBalance:
  15118. return m.Balance()
  15119. case creditbalance.FieldStatus:
  15120. return m.Status()
  15121. case creditbalance.FieldOrganizationID:
  15122. return m.OrganizationID()
  15123. }
  15124. return nil, false
  15125. }
  15126. // OldField returns the old value of the field from the database. An error is
  15127. // returned if the mutation operation is not UpdateOne, or the query to the
  15128. // database failed.
  15129. func (m *CreditBalanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15130. switch name {
  15131. case creditbalance.FieldCreatedAt:
  15132. return m.OldCreatedAt(ctx)
  15133. case creditbalance.FieldUpdatedAt:
  15134. return m.OldUpdatedAt(ctx)
  15135. case creditbalance.FieldDeletedAt:
  15136. return m.OldDeletedAt(ctx)
  15137. case creditbalance.FieldUserID:
  15138. return m.OldUserID(ctx)
  15139. case creditbalance.FieldBalance:
  15140. return m.OldBalance(ctx)
  15141. case creditbalance.FieldStatus:
  15142. return m.OldStatus(ctx)
  15143. case creditbalance.FieldOrganizationID:
  15144. return m.OldOrganizationID(ctx)
  15145. }
  15146. return nil, fmt.Errorf("unknown CreditBalance field %s", name)
  15147. }
  15148. // SetField sets the value of a field with the given name. It returns an error if
  15149. // the field is not defined in the schema, or if the type mismatched the field
  15150. // type.
  15151. func (m *CreditBalanceMutation) SetField(name string, value ent.Value) error {
  15152. switch name {
  15153. case creditbalance.FieldCreatedAt:
  15154. v, ok := value.(time.Time)
  15155. if !ok {
  15156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15157. }
  15158. m.SetCreatedAt(v)
  15159. return nil
  15160. case creditbalance.FieldUpdatedAt:
  15161. v, ok := value.(time.Time)
  15162. if !ok {
  15163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15164. }
  15165. m.SetUpdatedAt(v)
  15166. return nil
  15167. case creditbalance.FieldDeletedAt:
  15168. v, ok := value.(time.Time)
  15169. if !ok {
  15170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15171. }
  15172. m.SetDeletedAt(v)
  15173. return nil
  15174. case creditbalance.FieldUserID:
  15175. v, ok := value.(string)
  15176. if !ok {
  15177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15178. }
  15179. m.SetUserID(v)
  15180. return nil
  15181. case creditbalance.FieldBalance:
  15182. v, ok := value.(float64)
  15183. if !ok {
  15184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15185. }
  15186. m.SetBalance(v)
  15187. return nil
  15188. case creditbalance.FieldStatus:
  15189. v, ok := value.(int)
  15190. if !ok {
  15191. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15192. }
  15193. m.SetStatus(v)
  15194. return nil
  15195. case creditbalance.FieldOrganizationID:
  15196. v, ok := value.(uint64)
  15197. if !ok {
  15198. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15199. }
  15200. m.SetOrganizationID(v)
  15201. return nil
  15202. }
  15203. return fmt.Errorf("unknown CreditBalance field %s", name)
  15204. }
  15205. // AddedFields returns all numeric fields that were incremented/decremented during
  15206. // this mutation.
  15207. func (m *CreditBalanceMutation) AddedFields() []string {
  15208. var fields []string
  15209. if m.addbalance != nil {
  15210. fields = append(fields, creditbalance.FieldBalance)
  15211. }
  15212. if m.addstatus != nil {
  15213. fields = append(fields, creditbalance.FieldStatus)
  15214. }
  15215. if m.addorganization_id != nil {
  15216. fields = append(fields, creditbalance.FieldOrganizationID)
  15217. }
  15218. return fields
  15219. }
  15220. // AddedField returns the numeric value that was incremented/decremented on a field
  15221. // with the given name. The second boolean return value indicates that this field
  15222. // was not set, or was not defined in the schema.
  15223. func (m *CreditBalanceMutation) AddedField(name string) (ent.Value, bool) {
  15224. switch name {
  15225. case creditbalance.FieldBalance:
  15226. return m.AddedBalance()
  15227. case creditbalance.FieldStatus:
  15228. return m.AddedStatus()
  15229. case creditbalance.FieldOrganizationID:
  15230. return m.AddedOrganizationID()
  15231. }
  15232. return nil, false
  15233. }
  15234. // AddField adds the value to the field with the given name. It returns an error if
  15235. // the field is not defined in the schema, or if the type mismatched the field
  15236. // type.
  15237. func (m *CreditBalanceMutation) AddField(name string, value ent.Value) error {
  15238. switch name {
  15239. case creditbalance.FieldBalance:
  15240. v, ok := value.(float64)
  15241. if !ok {
  15242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15243. }
  15244. m.AddBalance(v)
  15245. return nil
  15246. case creditbalance.FieldStatus:
  15247. v, ok := value.(int)
  15248. if !ok {
  15249. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15250. }
  15251. m.AddStatus(v)
  15252. return nil
  15253. case creditbalance.FieldOrganizationID:
  15254. v, ok := value.(int64)
  15255. if !ok {
  15256. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15257. }
  15258. m.AddOrganizationID(v)
  15259. return nil
  15260. }
  15261. return fmt.Errorf("unknown CreditBalance numeric field %s", name)
  15262. }
  15263. // ClearedFields returns all nullable fields that were cleared during this
  15264. // mutation.
  15265. func (m *CreditBalanceMutation) ClearedFields() []string {
  15266. var fields []string
  15267. if m.FieldCleared(creditbalance.FieldDeletedAt) {
  15268. fields = append(fields, creditbalance.FieldDeletedAt)
  15269. }
  15270. if m.FieldCleared(creditbalance.FieldUserID) {
  15271. fields = append(fields, creditbalance.FieldUserID)
  15272. }
  15273. if m.FieldCleared(creditbalance.FieldStatus) {
  15274. fields = append(fields, creditbalance.FieldStatus)
  15275. }
  15276. if m.FieldCleared(creditbalance.FieldOrganizationID) {
  15277. fields = append(fields, creditbalance.FieldOrganizationID)
  15278. }
  15279. return fields
  15280. }
  15281. // FieldCleared returns a boolean indicating if a field with the given name was
  15282. // cleared in this mutation.
  15283. func (m *CreditBalanceMutation) FieldCleared(name string) bool {
  15284. _, ok := m.clearedFields[name]
  15285. return ok
  15286. }
  15287. // ClearField clears the value of the field with the given name. It returns an
  15288. // error if the field is not defined in the schema.
  15289. func (m *CreditBalanceMutation) ClearField(name string) error {
  15290. switch name {
  15291. case creditbalance.FieldDeletedAt:
  15292. m.ClearDeletedAt()
  15293. return nil
  15294. case creditbalance.FieldUserID:
  15295. m.ClearUserID()
  15296. return nil
  15297. case creditbalance.FieldStatus:
  15298. m.ClearStatus()
  15299. return nil
  15300. case creditbalance.FieldOrganizationID:
  15301. m.ClearOrganizationID()
  15302. return nil
  15303. }
  15304. return fmt.Errorf("unknown CreditBalance nullable field %s", name)
  15305. }
  15306. // ResetField resets all changes in the mutation for the field with the given name.
  15307. // It returns an error if the field is not defined in the schema.
  15308. func (m *CreditBalanceMutation) ResetField(name string) error {
  15309. switch name {
  15310. case creditbalance.FieldCreatedAt:
  15311. m.ResetCreatedAt()
  15312. return nil
  15313. case creditbalance.FieldUpdatedAt:
  15314. m.ResetUpdatedAt()
  15315. return nil
  15316. case creditbalance.FieldDeletedAt:
  15317. m.ResetDeletedAt()
  15318. return nil
  15319. case creditbalance.FieldUserID:
  15320. m.ResetUserID()
  15321. return nil
  15322. case creditbalance.FieldBalance:
  15323. m.ResetBalance()
  15324. return nil
  15325. case creditbalance.FieldStatus:
  15326. m.ResetStatus()
  15327. return nil
  15328. case creditbalance.FieldOrganizationID:
  15329. m.ResetOrganizationID()
  15330. return nil
  15331. }
  15332. return fmt.Errorf("unknown CreditBalance field %s", name)
  15333. }
  15334. // AddedEdges returns all edge names that were set/added in this mutation.
  15335. func (m *CreditBalanceMutation) AddedEdges() []string {
  15336. edges := make([]string, 0, 0)
  15337. return edges
  15338. }
  15339. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15340. // name in this mutation.
  15341. func (m *CreditBalanceMutation) AddedIDs(name string) []ent.Value {
  15342. return nil
  15343. }
  15344. // RemovedEdges returns all edge names that were removed in this mutation.
  15345. func (m *CreditBalanceMutation) RemovedEdges() []string {
  15346. edges := make([]string, 0, 0)
  15347. return edges
  15348. }
  15349. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15350. // the given name in this mutation.
  15351. func (m *CreditBalanceMutation) RemovedIDs(name string) []ent.Value {
  15352. return nil
  15353. }
  15354. // ClearedEdges returns all edge names that were cleared in this mutation.
  15355. func (m *CreditBalanceMutation) ClearedEdges() []string {
  15356. edges := make([]string, 0, 0)
  15357. return edges
  15358. }
  15359. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15360. // was cleared in this mutation.
  15361. func (m *CreditBalanceMutation) EdgeCleared(name string) bool {
  15362. return false
  15363. }
  15364. // ClearEdge clears the value of the edge with the given name. It returns an error
  15365. // if that edge is not defined in the schema.
  15366. func (m *CreditBalanceMutation) ClearEdge(name string) error {
  15367. return fmt.Errorf("unknown CreditBalance unique edge %s", name)
  15368. }
  15369. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15370. // It returns an error if the edge is not defined in the schema.
  15371. func (m *CreditBalanceMutation) ResetEdge(name string) error {
  15372. return fmt.Errorf("unknown CreditBalance edge %s", name)
  15373. }
  15374. // CreditUsageMutation represents an operation that mutates the CreditUsage nodes in the graph.
  15375. type CreditUsageMutation struct {
  15376. config
  15377. op Op
  15378. typ string
  15379. id *uint64
  15380. created_at *time.Time
  15381. updated_at *time.Time
  15382. deleted_at *time.Time
  15383. user_id *string
  15384. number *float64
  15385. addnumber *float64
  15386. pay_number *float64
  15387. addpay_number *float64
  15388. before_number *float64
  15389. addbefore_number *float64
  15390. after_number *float64
  15391. addafter_number *float64
  15392. pay_method *int
  15393. addpay_method *int
  15394. status *int
  15395. addstatus *int
  15396. ntype *int
  15397. addntype *int
  15398. table *string
  15399. organization_id *uint64
  15400. addorganization_id *int64
  15401. nid *uint64
  15402. addnid *int64
  15403. reason *string
  15404. operator *string
  15405. clearedFields map[string]struct{}
  15406. done bool
  15407. oldValue func(context.Context) (*CreditUsage, error)
  15408. predicates []predicate.CreditUsage
  15409. }
  15410. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  15411. // creditusageOption allows management of the mutation configuration using functional options.
  15412. type creditusageOption func(*CreditUsageMutation)
  15413. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  15414. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  15415. m := &CreditUsageMutation{
  15416. config: c,
  15417. op: op,
  15418. typ: TypeCreditUsage,
  15419. clearedFields: make(map[string]struct{}),
  15420. }
  15421. for _, opt := range opts {
  15422. opt(m)
  15423. }
  15424. return m
  15425. }
  15426. // withCreditUsageID sets the ID field of the mutation.
  15427. func withCreditUsageID(id uint64) creditusageOption {
  15428. return func(m *CreditUsageMutation) {
  15429. var (
  15430. err error
  15431. once sync.Once
  15432. value *CreditUsage
  15433. )
  15434. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  15435. once.Do(func() {
  15436. if m.done {
  15437. err = errors.New("querying old values post mutation is not allowed")
  15438. } else {
  15439. value, err = m.Client().CreditUsage.Get(ctx, id)
  15440. }
  15441. })
  15442. return value, err
  15443. }
  15444. m.id = &id
  15445. }
  15446. }
  15447. // withCreditUsage sets the old CreditUsage of the mutation.
  15448. func withCreditUsage(node *CreditUsage) creditusageOption {
  15449. return func(m *CreditUsageMutation) {
  15450. m.oldValue = func(context.Context) (*CreditUsage, error) {
  15451. return node, nil
  15452. }
  15453. m.id = &node.ID
  15454. }
  15455. }
  15456. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15457. // executed in a transaction (ent.Tx), a transactional client is returned.
  15458. func (m CreditUsageMutation) Client() *Client {
  15459. client := &Client{config: m.config}
  15460. client.init()
  15461. return client
  15462. }
  15463. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15464. // it returns an error otherwise.
  15465. func (m CreditUsageMutation) Tx() (*Tx, error) {
  15466. if _, ok := m.driver.(*txDriver); !ok {
  15467. return nil, errors.New("ent: mutation is not running in a transaction")
  15468. }
  15469. tx := &Tx{config: m.config}
  15470. tx.init()
  15471. return tx, nil
  15472. }
  15473. // SetID sets the value of the id field. Note that this
  15474. // operation is only accepted on creation of CreditUsage entities.
  15475. func (m *CreditUsageMutation) SetID(id uint64) {
  15476. m.id = &id
  15477. }
  15478. // ID returns the ID value in the mutation. Note that the ID is only available
  15479. // if it was provided to the builder or after it was returned from the database.
  15480. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  15481. if m.id == nil {
  15482. return
  15483. }
  15484. return *m.id, true
  15485. }
  15486. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15487. // That means, if the mutation is applied within a transaction with an isolation level such
  15488. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15489. // or updated by the mutation.
  15490. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  15491. switch {
  15492. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15493. id, exists := m.ID()
  15494. if exists {
  15495. return []uint64{id}, nil
  15496. }
  15497. fallthrough
  15498. case m.op.Is(OpUpdate | OpDelete):
  15499. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  15500. default:
  15501. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15502. }
  15503. }
  15504. // SetCreatedAt sets the "created_at" field.
  15505. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  15506. m.created_at = &t
  15507. }
  15508. // CreatedAt returns the value of the "created_at" field in the mutation.
  15509. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  15510. v := m.created_at
  15511. if v == nil {
  15512. return
  15513. }
  15514. return *v, true
  15515. }
  15516. // OldCreatedAt returns the old "created_at" field's value of the CreditUsage entity.
  15517. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15518. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15519. func (m *CreditUsageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15520. if !m.op.Is(OpUpdateOne) {
  15521. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15522. }
  15523. if m.id == nil || m.oldValue == nil {
  15524. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15525. }
  15526. oldValue, err := m.oldValue(ctx)
  15527. if err != nil {
  15528. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15529. }
  15530. return oldValue.CreatedAt, nil
  15531. }
  15532. // ResetCreatedAt resets all changes to the "created_at" field.
  15533. func (m *CreditUsageMutation) ResetCreatedAt() {
  15534. m.created_at = nil
  15535. }
  15536. // SetUpdatedAt sets the "updated_at" field.
  15537. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  15538. m.updated_at = &t
  15539. }
  15540. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15541. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  15542. v := m.updated_at
  15543. if v == nil {
  15544. return
  15545. }
  15546. return *v, true
  15547. }
  15548. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  15549. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15550. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15551. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15552. if !m.op.Is(OpUpdateOne) {
  15553. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15554. }
  15555. if m.id == nil || m.oldValue == nil {
  15556. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15557. }
  15558. oldValue, err := m.oldValue(ctx)
  15559. if err != nil {
  15560. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15561. }
  15562. return oldValue.UpdatedAt, nil
  15563. }
  15564. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15565. func (m *CreditUsageMutation) ResetUpdatedAt() {
  15566. m.updated_at = nil
  15567. }
  15568. // SetDeletedAt sets the "deleted_at" field.
  15569. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  15570. m.deleted_at = &t
  15571. }
  15572. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15573. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  15574. v := m.deleted_at
  15575. if v == nil {
  15576. return
  15577. }
  15578. return *v, true
  15579. }
  15580. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  15581. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15582. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15583. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15584. if !m.op.Is(OpUpdateOne) {
  15585. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15586. }
  15587. if m.id == nil || m.oldValue == nil {
  15588. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15589. }
  15590. oldValue, err := m.oldValue(ctx)
  15591. if err != nil {
  15592. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15593. }
  15594. return oldValue.DeletedAt, nil
  15595. }
  15596. // ClearDeletedAt clears the value of the "deleted_at" field.
  15597. func (m *CreditUsageMutation) ClearDeletedAt() {
  15598. m.deleted_at = nil
  15599. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  15600. }
  15601. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15602. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  15603. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  15604. return ok
  15605. }
  15606. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15607. func (m *CreditUsageMutation) ResetDeletedAt() {
  15608. m.deleted_at = nil
  15609. delete(m.clearedFields, creditusage.FieldDeletedAt)
  15610. }
  15611. // SetUserID sets the "user_id" field.
  15612. func (m *CreditUsageMutation) SetUserID(s string) {
  15613. m.user_id = &s
  15614. }
  15615. // UserID returns the value of the "user_id" field in the mutation.
  15616. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  15617. v := m.user_id
  15618. if v == nil {
  15619. return
  15620. }
  15621. return *v, true
  15622. }
  15623. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  15624. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15626. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  15627. if !m.op.Is(OpUpdateOne) {
  15628. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  15629. }
  15630. if m.id == nil || m.oldValue == nil {
  15631. return v, errors.New("OldUserID requires an ID field in the mutation")
  15632. }
  15633. oldValue, err := m.oldValue(ctx)
  15634. if err != nil {
  15635. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  15636. }
  15637. return oldValue.UserID, nil
  15638. }
  15639. // ClearUserID clears the value of the "user_id" field.
  15640. func (m *CreditUsageMutation) ClearUserID() {
  15641. m.user_id = nil
  15642. m.clearedFields[creditusage.FieldUserID] = struct{}{}
  15643. }
  15644. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  15645. func (m *CreditUsageMutation) UserIDCleared() bool {
  15646. _, ok := m.clearedFields[creditusage.FieldUserID]
  15647. return ok
  15648. }
  15649. // ResetUserID resets all changes to the "user_id" field.
  15650. func (m *CreditUsageMutation) ResetUserID() {
  15651. m.user_id = nil
  15652. delete(m.clearedFields, creditusage.FieldUserID)
  15653. }
  15654. // SetNumber sets the "number" field.
  15655. func (m *CreditUsageMutation) SetNumber(f float64) {
  15656. m.number = &f
  15657. m.addnumber = nil
  15658. }
  15659. // Number returns the value of the "number" field in the mutation.
  15660. func (m *CreditUsageMutation) Number() (r float64, exists bool) {
  15661. v := m.number
  15662. if v == nil {
  15663. return
  15664. }
  15665. return *v, true
  15666. }
  15667. // OldNumber returns the old "number" field's value of the CreditUsage entity.
  15668. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15669. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15670. func (m *CreditUsageMutation) OldNumber(ctx context.Context) (v float64, err error) {
  15671. if !m.op.Is(OpUpdateOne) {
  15672. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  15673. }
  15674. if m.id == nil || m.oldValue == nil {
  15675. return v, errors.New("OldNumber requires an ID field in the mutation")
  15676. }
  15677. oldValue, err := m.oldValue(ctx)
  15678. if err != nil {
  15679. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  15680. }
  15681. return oldValue.Number, nil
  15682. }
  15683. // AddNumber adds f to the "number" field.
  15684. func (m *CreditUsageMutation) AddNumber(f float64) {
  15685. if m.addnumber != nil {
  15686. *m.addnumber += f
  15687. } else {
  15688. m.addnumber = &f
  15689. }
  15690. }
  15691. // AddedNumber returns the value that was added to the "number" field in this mutation.
  15692. func (m *CreditUsageMutation) AddedNumber() (r float64, exists bool) {
  15693. v := m.addnumber
  15694. if v == nil {
  15695. return
  15696. }
  15697. return *v, true
  15698. }
  15699. // ResetNumber resets all changes to the "number" field.
  15700. func (m *CreditUsageMutation) ResetNumber() {
  15701. m.number = nil
  15702. m.addnumber = nil
  15703. }
  15704. // SetPayNumber sets the "pay_number" field.
  15705. func (m *CreditUsageMutation) SetPayNumber(f float64) {
  15706. m.pay_number = &f
  15707. m.addpay_number = nil
  15708. }
  15709. // PayNumber returns the value of the "pay_number" field in the mutation.
  15710. func (m *CreditUsageMutation) PayNumber() (r float64, exists bool) {
  15711. v := m.pay_number
  15712. if v == nil {
  15713. return
  15714. }
  15715. return *v, true
  15716. }
  15717. // OldPayNumber returns the old "pay_number" field's value of the CreditUsage entity.
  15718. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15719. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15720. func (m *CreditUsageMutation) OldPayNumber(ctx context.Context) (v float64, err error) {
  15721. if !m.op.Is(OpUpdateOne) {
  15722. return v, errors.New("OldPayNumber is only allowed on UpdateOne operations")
  15723. }
  15724. if m.id == nil || m.oldValue == nil {
  15725. return v, errors.New("OldPayNumber requires an ID field in the mutation")
  15726. }
  15727. oldValue, err := m.oldValue(ctx)
  15728. if err != nil {
  15729. return v, fmt.Errorf("querying old value for OldPayNumber: %w", err)
  15730. }
  15731. return oldValue.PayNumber, nil
  15732. }
  15733. // AddPayNumber adds f to the "pay_number" field.
  15734. func (m *CreditUsageMutation) AddPayNumber(f float64) {
  15735. if m.addpay_number != nil {
  15736. *m.addpay_number += f
  15737. } else {
  15738. m.addpay_number = &f
  15739. }
  15740. }
  15741. // AddedPayNumber returns the value that was added to the "pay_number" field in this mutation.
  15742. func (m *CreditUsageMutation) AddedPayNumber() (r float64, exists bool) {
  15743. v := m.addpay_number
  15744. if v == nil {
  15745. return
  15746. }
  15747. return *v, true
  15748. }
  15749. // ClearPayNumber clears the value of the "pay_number" field.
  15750. func (m *CreditUsageMutation) ClearPayNumber() {
  15751. m.pay_number = nil
  15752. m.addpay_number = nil
  15753. m.clearedFields[creditusage.FieldPayNumber] = struct{}{}
  15754. }
  15755. // PayNumberCleared returns if the "pay_number" field was cleared in this mutation.
  15756. func (m *CreditUsageMutation) PayNumberCleared() bool {
  15757. _, ok := m.clearedFields[creditusage.FieldPayNumber]
  15758. return ok
  15759. }
  15760. // ResetPayNumber resets all changes to the "pay_number" field.
  15761. func (m *CreditUsageMutation) ResetPayNumber() {
  15762. m.pay_number = nil
  15763. m.addpay_number = nil
  15764. delete(m.clearedFields, creditusage.FieldPayNumber)
  15765. }
  15766. // SetBeforeNumber sets the "before_number" field.
  15767. func (m *CreditUsageMutation) SetBeforeNumber(f float64) {
  15768. m.before_number = &f
  15769. m.addbefore_number = nil
  15770. }
  15771. // BeforeNumber returns the value of the "before_number" field in the mutation.
  15772. func (m *CreditUsageMutation) BeforeNumber() (r float64, exists bool) {
  15773. v := m.before_number
  15774. if v == nil {
  15775. return
  15776. }
  15777. return *v, true
  15778. }
  15779. // OldBeforeNumber returns the old "before_number" field's value of the CreditUsage entity.
  15780. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15781. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15782. func (m *CreditUsageMutation) OldBeforeNumber(ctx context.Context) (v float64, err error) {
  15783. if !m.op.Is(OpUpdateOne) {
  15784. return v, errors.New("OldBeforeNumber is only allowed on UpdateOne operations")
  15785. }
  15786. if m.id == nil || m.oldValue == nil {
  15787. return v, errors.New("OldBeforeNumber requires an ID field in the mutation")
  15788. }
  15789. oldValue, err := m.oldValue(ctx)
  15790. if err != nil {
  15791. return v, fmt.Errorf("querying old value for OldBeforeNumber: %w", err)
  15792. }
  15793. return oldValue.BeforeNumber, nil
  15794. }
  15795. // AddBeforeNumber adds f to the "before_number" field.
  15796. func (m *CreditUsageMutation) AddBeforeNumber(f float64) {
  15797. if m.addbefore_number != nil {
  15798. *m.addbefore_number += f
  15799. } else {
  15800. m.addbefore_number = &f
  15801. }
  15802. }
  15803. // AddedBeforeNumber returns the value that was added to the "before_number" field in this mutation.
  15804. func (m *CreditUsageMutation) AddedBeforeNumber() (r float64, exists bool) {
  15805. v := m.addbefore_number
  15806. if v == nil {
  15807. return
  15808. }
  15809. return *v, true
  15810. }
  15811. // ClearBeforeNumber clears the value of the "before_number" field.
  15812. func (m *CreditUsageMutation) ClearBeforeNumber() {
  15813. m.before_number = nil
  15814. m.addbefore_number = nil
  15815. m.clearedFields[creditusage.FieldBeforeNumber] = struct{}{}
  15816. }
  15817. // BeforeNumberCleared returns if the "before_number" field was cleared in this mutation.
  15818. func (m *CreditUsageMutation) BeforeNumberCleared() bool {
  15819. _, ok := m.clearedFields[creditusage.FieldBeforeNumber]
  15820. return ok
  15821. }
  15822. // ResetBeforeNumber resets all changes to the "before_number" field.
  15823. func (m *CreditUsageMutation) ResetBeforeNumber() {
  15824. m.before_number = nil
  15825. m.addbefore_number = nil
  15826. delete(m.clearedFields, creditusage.FieldBeforeNumber)
  15827. }
  15828. // SetAfterNumber sets the "after_number" field.
  15829. func (m *CreditUsageMutation) SetAfterNumber(f float64) {
  15830. m.after_number = &f
  15831. m.addafter_number = nil
  15832. }
  15833. // AfterNumber returns the value of the "after_number" field in the mutation.
  15834. func (m *CreditUsageMutation) AfterNumber() (r float64, exists bool) {
  15835. v := m.after_number
  15836. if v == nil {
  15837. return
  15838. }
  15839. return *v, true
  15840. }
  15841. // OldAfterNumber returns the old "after_number" field's value of the CreditUsage entity.
  15842. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15843. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15844. func (m *CreditUsageMutation) OldAfterNumber(ctx context.Context) (v float64, err error) {
  15845. if !m.op.Is(OpUpdateOne) {
  15846. return v, errors.New("OldAfterNumber is only allowed on UpdateOne operations")
  15847. }
  15848. if m.id == nil || m.oldValue == nil {
  15849. return v, errors.New("OldAfterNumber requires an ID field in the mutation")
  15850. }
  15851. oldValue, err := m.oldValue(ctx)
  15852. if err != nil {
  15853. return v, fmt.Errorf("querying old value for OldAfterNumber: %w", err)
  15854. }
  15855. return oldValue.AfterNumber, nil
  15856. }
  15857. // AddAfterNumber adds f to the "after_number" field.
  15858. func (m *CreditUsageMutation) AddAfterNumber(f float64) {
  15859. if m.addafter_number != nil {
  15860. *m.addafter_number += f
  15861. } else {
  15862. m.addafter_number = &f
  15863. }
  15864. }
  15865. // AddedAfterNumber returns the value that was added to the "after_number" field in this mutation.
  15866. func (m *CreditUsageMutation) AddedAfterNumber() (r float64, exists bool) {
  15867. v := m.addafter_number
  15868. if v == nil {
  15869. return
  15870. }
  15871. return *v, true
  15872. }
  15873. // ClearAfterNumber clears the value of the "after_number" field.
  15874. func (m *CreditUsageMutation) ClearAfterNumber() {
  15875. m.after_number = nil
  15876. m.addafter_number = nil
  15877. m.clearedFields[creditusage.FieldAfterNumber] = struct{}{}
  15878. }
  15879. // AfterNumberCleared returns if the "after_number" field was cleared in this mutation.
  15880. func (m *CreditUsageMutation) AfterNumberCleared() bool {
  15881. _, ok := m.clearedFields[creditusage.FieldAfterNumber]
  15882. return ok
  15883. }
  15884. // ResetAfterNumber resets all changes to the "after_number" field.
  15885. func (m *CreditUsageMutation) ResetAfterNumber() {
  15886. m.after_number = nil
  15887. m.addafter_number = nil
  15888. delete(m.clearedFields, creditusage.FieldAfterNumber)
  15889. }
  15890. // SetPayMethod sets the "pay_method" field.
  15891. func (m *CreditUsageMutation) SetPayMethod(i int) {
  15892. m.pay_method = &i
  15893. m.addpay_method = nil
  15894. }
  15895. // PayMethod returns the value of the "pay_method" field in the mutation.
  15896. func (m *CreditUsageMutation) PayMethod() (r int, exists bool) {
  15897. v := m.pay_method
  15898. if v == nil {
  15899. return
  15900. }
  15901. return *v, true
  15902. }
  15903. // OldPayMethod returns the old "pay_method" field's value of the CreditUsage entity.
  15904. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15905. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15906. func (m *CreditUsageMutation) OldPayMethod(ctx context.Context) (v int, err error) {
  15907. if !m.op.Is(OpUpdateOne) {
  15908. return v, errors.New("OldPayMethod is only allowed on UpdateOne operations")
  15909. }
  15910. if m.id == nil || m.oldValue == nil {
  15911. return v, errors.New("OldPayMethod requires an ID field in the mutation")
  15912. }
  15913. oldValue, err := m.oldValue(ctx)
  15914. if err != nil {
  15915. return v, fmt.Errorf("querying old value for OldPayMethod: %w", err)
  15916. }
  15917. return oldValue.PayMethod, nil
  15918. }
  15919. // AddPayMethod adds i to the "pay_method" field.
  15920. func (m *CreditUsageMutation) AddPayMethod(i int) {
  15921. if m.addpay_method != nil {
  15922. *m.addpay_method += i
  15923. } else {
  15924. m.addpay_method = &i
  15925. }
  15926. }
  15927. // AddedPayMethod returns the value that was added to the "pay_method" field in this mutation.
  15928. func (m *CreditUsageMutation) AddedPayMethod() (r int, exists bool) {
  15929. v := m.addpay_method
  15930. if v == nil {
  15931. return
  15932. }
  15933. return *v, true
  15934. }
  15935. // ClearPayMethod clears the value of the "pay_method" field.
  15936. func (m *CreditUsageMutation) ClearPayMethod() {
  15937. m.pay_method = nil
  15938. m.addpay_method = nil
  15939. m.clearedFields[creditusage.FieldPayMethod] = struct{}{}
  15940. }
  15941. // PayMethodCleared returns if the "pay_method" field was cleared in this mutation.
  15942. func (m *CreditUsageMutation) PayMethodCleared() bool {
  15943. _, ok := m.clearedFields[creditusage.FieldPayMethod]
  15944. return ok
  15945. }
  15946. // ResetPayMethod resets all changes to the "pay_method" field.
  15947. func (m *CreditUsageMutation) ResetPayMethod() {
  15948. m.pay_method = nil
  15949. m.addpay_method = nil
  15950. delete(m.clearedFields, creditusage.FieldPayMethod)
  15951. }
  15952. // SetStatus sets the "status" field.
  15953. func (m *CreditUsageMutation) SetStatus(i int) {
  15954. m.status = &i
  15955. m.addstatus = nil
  15956. }
  15957. // Status returns the value of the "status" field in the mutation.
  15958. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  15959. v := m.status
  15960. if v == nil {
  15961. return
  15962. }
  15963. return *v, true
  15964. }
  15965. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  15966. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15967. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15968. func (m *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  15969. if !m.op.Is(OpUpdateOne) {
  15970. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15971. }
  15972. if m.id == nil || m.oldValue == nil {
  15973. return v, errors.New("OldStatus requires an ID field in the mutation")
  15974. }
  15975. oldValue, err := m.oldValue(ctx)
  15976. if err != nil {
  15977. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15978. }
  15979. return oldValue.Status, nil
  15980. }
  15981. // AddStatus adds i to the "status" field.
  15982. func (m *CreditUsageMutation) AddStatus(i int) {
  15983. if m.addstatus != nil {
  15984. *m.addstatus += i
  15985. } else {
  15986. m.addstatus = &i
  15987. }
  15988. }
  15989. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15990. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  15991. v := m.addstatus
  15992. if v == nil {
  15993. return
  15994. }
  15995. return *v, true
  15996. }
  15997. // ClearStatus clears the value of the "status" field.
  15998. func (m *CreditUsageMutation) ClearStatus() {
  15999. m.status = nil
  16000. m.addstatus = nil
  16001. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  16002. }
  16003. // StatusCleared returns if the "status" field was cleared in this mutation.
  16004. func (m *CreditUsageMutation) StatusCleared() bool {
  16005. _, ok := m.clearedFields[creditusage.FieldStatus]
  16006. return ok
  16007. }
  16008. // ResetStatus resets all changes to the "status" field.
  16009. func (m *CreditUsageMutation) ResetStatus() {
  16010. m.status = nil
  16011. m.addstatus = nil
  16012. delete(m.clearedFields, creditusage.FieldStatus)
  16013. }
  16014. // SetNtype sets the "ntype" field.
  16015. func (m *CreditUsageMutation) SetNtype(i int) {
  16016. m.ntype = &i
  16017. m.addntype = nil
  16018. }
  16019. // Ntype returns the value of the "ntype" field in the mutation.
  16020. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  16021. v := m.ntype
  16022. if v == nil {
  16023. return
  16024. }
  16025. return *v, true
  16026. }
  16027. // OldNtype returns the old "ntype" field's value of the CreditUsage entity.
  16028. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16029. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16030. func (m *CreditUsageMutation) OldNtype(ctx context.Context) (v int, err error) {
  16031. if !m.op.Is(OpUpdateOne) {
  16032. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  16033. }
  16034. if m.id == nil || m.oldValue == nil {
  16035. return v, errors.New("OldNtype requires an ID field in the mutation")
  16036. }
  16037. oldValue, err := m.oldValue(ctx)
  16038. if err != nil {
  16039. return v, fmt.Errorf("querying old value for OldNtype: %w", err)
  16040. }
  16041. return oldValue.Ntype, nil
  16042. }
  16043. // AddNtype adds i to the "ntype" field.
  16044. func (m *CreditUsageMutation) AddNtype(i int) {
  16045. if m.addntype != nil {
  16046. *m.addntype += i
  16047. } else {
  16048. m.addntype = &i
  16049. }
  16050. }
  16051. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  16052. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  16053. v := m.addntype
  16054. if v == nil {
  16055. return
  16056. }
  16057. return *v, true
  16058. }
  16059. // ResetNtype resets all changes to the "ntype" field.
  16060. func (m *CreditUsageMutation) ResetNtype() {
  16061. m.ntype = nil
  16062. m.addntype = nil
  16063. }
  16064. // SetTable sets the "table" field.
  16065. func (m *CreditUsageMutation) SetTable(s string) {
  16066. m.table = &s
  16067. }
  16068. // Table returns the value of the "table" field in the mutation.
  16069. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  16070. v := m.table
  16071. if v == nil {
  16072. return
  16073. }
  16074. return *v, true
  16075. }
  16076. // OldTable returns the old "table" field's value of the CreditUsage entity.
  16077. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16078. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16079. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  16080. if !m.op.Is(OpUpdateOne) {
  16081. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  16082. }
  16083. if m.id == nil || m.oldValue == nil {
  16084. return v, errors.New("OldTable requires an ID field in the mutation")
  16085. }
  16086. oldValue, err := m.oldValue(ctx)
  16087. if err != nil {
  16088. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  16089. }
  16090. return oldValue.Table, nil
  16091. }
  16092. // ResetTable resets all changes to the "table" field.
  16093. func (m *CreditUsageMutation) ResetTable() {
  16094. m.table = nil
  16095. }
  16096. // SetOrganizationID sets the "organization_id" field.
  16097. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  16098. m.organization_id = &u
  16099. m.addorganization_id = nil
  16100. }
  16101. // OrganizationID returns the value of the "organization_id" field in the mutation.
  16102. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  16103. v := m.organization_id
  16104. if v == nil {
  16105. return
  16106. }
  16107. return *v, true
  16108. }
  16109. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  16110. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16111. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16112. func (m *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  16113. if !m.op.Is(OpUpdateOne) {
  16114. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  16115. }
  16116. if m.id == nil || m.oldValue == nil {
  16117. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  16118. }
  16119. oldValue, err := m.oldValue(ctx)
  16120. if err != nil {
  16121. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  16122. }
  16123. return oldValue.OrganizationID, nil
  16124. }
  16125. // AddOrganizationID adds u to the "organization_id" field.
  16126. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  16127. if m.addorganization_id != nil {
  16128. *m.addorganization_id += u
  16129. } else {
  16130. m.addorganization_id = &u
  16131. }
  16132. }
  16133. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  16134. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  16135. v := m.addorganization_id
  16136. if v == nil {
  16137. return
  16138. }
  16139. return *v, true
  16140. }
  16141. // ClearOrganizationID clears the value of the "organization_id" field.
  16142. func (m *CreditUsageMutation) ClearOrganizationID() {
  16143. m.organization_id = nil
  16144. m.addorganization_id = nil
  16145. m.clearedFields[creditusage.FieldOrganizationID] = struct{}{}
  16146. }
  16147. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  16148. func (m *CreditUsageMutation) OrganizationIDCleared() bool {
  16149. _, ok := m.clearedFields[creditusage.FieldOrganizationID]
  16150. return ok
  16151. }
  16152. // ResetOrganizationID resets all changes to the "organization_id" field.
  16153. func (m *CreditUsageMutation) ResetOrganizationID() {
  16154. m.organization_id = nil
  16155. m.addorganization_id = nil
  16156. delete(m.clearedFields, creditusage.FieldOrganizationID)
  16157. }
  16158. // SetNid sets the "nid" field.
  16159. func (m *CreditUsageMutation) SetNid(u uint64) {
  16160. m.nid = &u
  16161. m.addnid = nil
  16162. }
  16163. // Nid returns the value of the "nid" field in the mutation.
  16164. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  16165. v := m.nid
  16166. if v == nil {
  16167. return
  16168. }
  16169. return *v, true
  16170. }
  16171. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  16172. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16173. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16174. func (m *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  16175. if !m.op.Is(OpUpdateOne) {
  16176. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  16177. }
  16178. if m.id == nil || m.oldValue == nil {
  16179. return v, errors.New("OldNid requires an ID field in the mutation")
  16180. }
  16181. oldValue, err := m.oldValue(ctx)
  16182. if err != nil {
  16183. return v, fmt.Errorf("querying old value for OldNid: %w", err)
  16184. }
  16185. return oldValue.Nid, nil
  16186. }
  16187. // AddNid adds u to the "nid" field.
  16188. func (m *CreditUsageMutation) AddNid(u int64) {
  16189. if m.addnid != nil {
  16190. *m.addnid += u
  16191. } else {
  16192. m.addnid = &u
  16193. }
  16194. }
  16195. // AddedNid returns the value that was added to the "nid" field in this mutation.
  16196. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  16197. v := m.addnid
  16198. if v == nil {
  16199. return
  16200. }
  16201. return *v, true
  16202. }
  16203. // ResetNid resets all changes to the "nid" field.
  16204. func (m *CreditUsageMutation) ResetNid() {
  16205. m.nid = nil
  16206. m.addnid = nil
  16207. }
  16208. // SetReason sets the "reason" field.
  16209. func (m *CreditUsageMutation) SetReason(s string) {
  16210. m.reason = &s
  16211. }
  16212. // Reason returns the value of the "reason" field in the mutation.
  16213. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  16214. v := m.reason
  16215. if v == nil {
  16216. return
  16217. }
  16218. return *v, true
  16219. }
  16220. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  16221. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16222. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16223. func (m *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  16224. if !m.op.Is(OpUpdateOne) {
  16225. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  16226. }
  16227. if m.id == nil || m.oldValue == nil {
  16228. return v, errors.New("OldReason requires an ID field in the mutation")
  16229. }
  16230. oldValue, err := m.oldValue(ctx)
  16231. if err != nil {
  16232. return v, fmt.Errorf("querying old value for OldReason: %w", err)
  16233. }
  16234. return oldValue.Reason, nil
  16235. }
  16236. // ResetReason resets all changes to the "reason" field.
  16237. func (m *CreditUsageMutation) ResetReason() {
  16238. m.reason = nil
  16239. }
  16240. // SetOperator sets the "operator" field.
  16241. func (m *CreditUsageMutation) SetOperator(s string) {
  16242. m.operator = &s
  16243. }
  16244. // Operator returns the value of the "operator" field in the mutation.
  16245. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  16246. v := m.operator
  16247. if v == nil {
  16248. return
  16249. }
  16250. return *v, true
  16251. }
  16252. // OldOperator returns the old "operator" field's value of the CreditUsage entity.
  16253. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16255. func (m *CreditUsageMutation) OldOperator(ctx context.Context) (v string, err error) {
  16256. if !m.op.Is(OpUpdateOne) {
  16257. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  16258. }
  16259. if m.id == nil || m.oldValue == nil {
  16260. return v, errors.New("OldOperator requires an ID field in the mutation")
  16261. }
  16262. oldValue, err := m.oldValue(ctx)
  16263. if err != nil {
  16264. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  16265. }
  16266. return oldValue.Operator, nil
  16267. }
  16268. // ResetOperator resets all changes to the "operator" field.
  16269. func (m *CreditUsageMutation) ResetOperator() {
  16270. m.operator = nil
  16271. }
  16272. // Where appends a list predicates to the CreditUsageMutation builder.
  16273. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  16274. m.predicates = append(m.predicates, ps...)
  16275. }
  16276. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  16277. // users can use type-assertion to append predicates that do not depend on any generated package.
  16278. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  16279. p := make([]predicate.CreditUsage, len(ps))
  16280. for i := range ps {
  16281. p[i] = ps[i]
  16282. }
  16283. m.Where(p...)
  16284. }
  16285. // Op returns the operation name.
  16286. func (m *CreditUsageMutation) Op() Op {
  16287. return m.op
  16288. }
  16289. // SetOp allows setting the mutation operation.
  16290. func (m *CreditUsageMutation) SetOp(op Op) {
  16291. m.op = op
  16292. }
  16293. // Type returns the node type of this mutation (CreditUsage).
  16294. func (m *CreditUsageMutation) Type() string {
  16295. return m.typ
  16296. }
  16297. // Fields returns all fields that were changed during this mutation. Note that in
  16298. // order to get all numeric fields that were incremented/decremented, call
  16299. // AddedFields().
  16300. func (m *CreditUsageMutation) Fields() []string {
  16301. fields := make([]string, 0, 16)
  16302. if m.created_at != nil {
  16303. fields = append(fields, creditusage.FieldCreatedAt)
  16304. }
  16305. if m.updated_at != nil {
  16306. fields = append(fields, creditusage.FieldUpdatedAt)
  16307. }
  16308. if m.deleted_at != nil {
  16309. fields = append(fields, creditusage.FieldDeletedAt)
  16310. }
  16311. if m.user_id != nil {
  16312. fields = append(fields, creditusage.FieldUserID)
  16313. }
  16314. if m.number != nil {
  16315. fields = append(fields, creditusage.FieldNumber)
  16316. }
  16317. if m.pay_number != nil {
  16318. fields = append(fields, creditusage.FieldPayNumber)
  16319. }
  16320. if m.before_number != nil {
  16321. fields = append(fields, creditusage.FieldBeforeNumber)
  16322. }
  16323. if m.after_number != nil {
  16324. fields = append(fields, creditusage.FieldAfterNumber)
  16325. }
  16326. if m.pay_method != nil {
  16327. fields = append(fields, creditusage.FieldPayMethod)
  16328. }
  16329. if m.status != nil {
  16330. fields = append(fields, creditusage.FieldStatus)
  16331. }
  16332. if m.ntype != nil {
  16333. fields = append(fields, creditusage.FieldNtype)
  16334. }
  16335. if m.table != nil {
  16336. fields = append(fields, creditusage.FieldTable)
  16337. }
  16338. if m.organization_id != nil {
  16339. fields = append(fields, creditusage.FieldOrganizationID)
  16340. }
  16341. if m.nid != nil {
  16342. fields = append(fields, creditusage.FieldNid)
  16343. }
  16344. if m.reason != nil {
  16345. fields = append(fields, creditusage.FieldReason)
  16346. }
  16347. if m.operator != nil {
  16348. fields = append(fields, creditusage.FieldOperator)
  16349. }
  16350. return fields
  16351. }
  16352. // Field returns the value of a field with the given name. The second boolean
  16353. // return value indicates that this field was not set, or was not defined in the
  16354. // schema.
  16355. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  16356. switch name {
  16357. case creditusage.FieldCreatedAt:
  16358. return m.CreatedAt()
  16359. case creditusage.FieldUpdatedAt:
  16360. return m.UpdatedAt()
  16361. case creditusage.FieldDeletedAt:
  16362. return m.DeletedAt()
  16363. case creditusage.FieldUserID:
  16364. return m.UserID()
  16365. case creditusage.FieldNumber:
  16366. return m.Number()
  16367. case creditusage.FieldPayNumber:
  16368. return m.PayNumber()
  16369. case creditusage.FieldBeforeNumber:
  16370. return m.BeforeNumber()
  16371. case creditusage.FieldAfterNumber:
  16372. return m.AfterNumber()
  16373. case creditusage.FieldPayMethod:
  16374. return m.PayMethod()
  16375. case creditusage.FieldStatus:
  16376. return m.Status()
  16377. case creditusage.FieldNtype:
  16378. return m.Ntype()
  16379. case creditusage.FieldTable:
  16380. return m.Table()
  16381. case creditusage.FieldOrganizationID:
  16382. return m.OrganizationID()
  16383. case creditusage.FieldNid:
  16384. return m.Nid()
  16385. case creditusage.FieldReason:
  16386. return m.Reason()
  16387. case creditusage.FieldOperator:
  16388. return m.Operator()
  16389. }
  16390. return nil, false
  16391. }
  16392. // OldField returns the old value of the field from the database. An error is
  16393. // returned if the mutation operation is not UpdateOne, or the query to the
  16394. // database failed.
  16395. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16396. switch name {
  16397. case creditusage.FieldCreatedAt:
  16398. return m.OldCreatedAt(ctx)
  16399. case creditusage.FieldUpdatedAt:
  16400. return m.OldUpdatedAt(ctx)
  16401. case creditusage.FieldDeletedAt:
  16402. return m.OldDeletedAt(ctx)
  16403. case creditusage.FieldUserID:
  16404. return m.OldUserID(ctx)
  16405. case creditusage.FieldNumber:
  16406. return m.OldNumber(ctx)
  16407. case creditusage.FieldPayNumber:
  16408. return m.OldPayNumber(ctx)
  16409. case creditusage.FieldBeforeNumber:
  16410. return m.OldBeforeNumber(ctx)
  16411. case creditusage.FieldAfterNumber:
  16412. return m.OldAfterNumber(ctx)
  16413. case creditusage.FieldPayMethod:
  16414. return m.OldPayMethod(ctx)
  16415. case creditusage.FieldStatus:
  16416. return m.OldStatus(ctx)
  16417. case creditusage.FieldNtype:
  16418. return m.OldNtype(ctx)
  16419. case creditusage.FieldTable:
  16420. return m.OldTable(ctx)
  16421. case creditusage.FieldOrganizationID:
  16422. return m.OldOrganizationID(ctx)
  16423. case creditusage.FieldNid:
  16424. return m.OldNid(ctx)
  16425. case creditusage.FieldReason:
  16426. return m.OldReason(ctx)
  16427. case creditusage.FieldOperator:
  16428. return m.OldOperator(ctx)
  16429. }
  16430. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  16431. }
  16432. // SetField sets the value of a field with the given name. It returns an error if
  16433. // the field is not defined in the schema, or if the type mismatched the field
  16434. // type.
  16435. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  16436. switch name {
  16437. case creditusage.FieldCreatedAt:
  16438. v, ok := value.(time.Time)
  16439. if !ok {
  16440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16441. }
  16442. m.SetCreatedAt(v)
  16443. return nil
  16444. case creditusage.FieldUpdatedAt:
  16445. v, ok := value.(time.Time)
  16446. if !ok {
  16447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16448. }
  16449. m.SetUpdatedAt(v)
  16450. return nil
  16451. case creditusage.FieldDeletedAt:
  16452. v, ok := value.(time.Time)
  16453. if !ok {
  16454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16455. }
  16456. m.SetDeletedAt(v)
  16457. return nil
  16458. case creditusage.FieldUserID:
  16459. v, ok := value.(string)
  16460. if !ok {
  16461. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16462. }
  16463. m.SetUserID(v)
  16464. return nil
  16465. case creditusage.FieldNumber:
  16466. v, ok := value.(float64)
  16467. if !ok {
  16468. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16469. }
  16470. m.SetNumber(v)
  16471. return nil
  16472. case creditusage.FieldPayNumber:
  16473. v, ok := value.(float64)
  16474. if !ok {
  16475. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16476. }
  16477. m.SetPayNumber(v)
  16478. return nil
  16479. case creditusage.FieldBeforeNumber:
  16480. v, ok := value.(float64)
  16481. if !ok {
  16482. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16483. }
  16484. m.SetBeforeNumber(v)
  16485. return nil
  16486. case creditusage.FieldAfterNumber:
  16487. v, ok := value.(float64)
  16488. if !ok {
  16489. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16490. }
  16491. m.SetAfterNumber(v)
  16492. return nil
  16493. case creditusage.FieldPayMethod:
  16494. v, ok := value.(int)
  16495. if !ok {
  16496. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16497. }
  16498. m.SetPayMethod(v)
  16499. return nil
  16500. case creditusage.FieldStatus:
  16501. v, ok := value.(int)
  16502. if !ok {
  16503. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16504. }
  16505. m.SetStatus(v)
  16506. return nil
  16507. case creditusage.FieldNtype:
  16508. v, ok := value.(int)
  16509. if !ok {
  16510. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16511. }
  16512. m.SetNtype(v)
  16513. return nil
  16514. case creditusage.FieldTable:
  16515. v, ok := value.(string)
  16516. if !ok {
  16517. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16518. }
  16519. m.SetTable(v)
  16520. return nil
  16521. case creditusage.FieldOrganizationID:
  16522. v, ok := value.(uint64)
  16523. if !ok {
  16524. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16525. }
  16526. m.SetOrganizationID(v)
  16527. return nil
  16528. case creditusage.FieldNid:
  16529. v, ok := value.(uint64)
  16530. if !ok {
  16531. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16532. }
  16533. m.SetNid(v)
  16534. return nil
  16535. case creditusage.FieldReason:
  16536. v, ok := value.(string)
  16537. if !ok {
  16538. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16539. }
  16540. m.SetReason(v)
  16541. return nil
  16542. case creditusage.FieldOperator:
  16543. v, ok := value.(string)
  16544. if !ok {
  16545. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16546. }
  16547. m.SetOperator(v)
  16548. return nil
  16549. }
  16550. return fmt.Errorf("unknown CreditUsage field %s", name)
  16551. }
  16552. // AddedFields returns all numeric fields that were incremented/decremented during
  16553. // this mutation.
  16554. func (m *CreditUsageMutation) AddedFields() []string {
  16555. var fields []string
  16556. if m.addnumber != nil {
  16557. fields = append(fields, creditusage.FieldNumber)
  16558. }
  16559. if m.addpay_number != nil {
  16560. fields = append(fields, creditusage.FieldPayNumber)
  16561. }
  16562. if m.addbefore_number != nil {
  16563. fields = append(fields, creditusage.FieldBeforeNumber)
  16564. }
  16565. if m.addafter_number != nil {
  16566. fields = append(fields, creditusage.FieldAfterNumber)
  16567. }
  16568. if m.addpay_method != nil {
  16569. fields = append(fields, creditusage.FieldPayMethod)
  16570. }
  16571. if m.addstatus != nil {
  16572. fields = append(fields, creditusage.FieldStatus)
  16573. }
  16574. if m.addntype != nil {
  16575. fields = append(fields, creditusage.FieldNtype)
  16576. }
  16577. if m.addorganization_id != nil {
  16578. fields = append(fields, creditusage.FieldOrganizationID)
  16579. }
  16580. if m.addnid != nil {
  16581. fields = append(fields, creditusage.FieldNid)
  16582. }
  16583. return fields
  16584. }
  16585. // AddedField returns the numeric value that was incremented/decremented on a field
  16586. // with the given name. The second boolean return value indicates that this field
  16587. // was not set, or was not defined in the schema.
  16588. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  16589. switch name {
  16590. case creditusage.FieldNumber:
  16591. return m.AddedNumber()
  16592. case creditusage.FieldPayNumber:
  16593. return m.AddedPayNumber()
  16594. case creditusage.FieldBeforeNumber:
  16595. return m.AddedBeforeNumber()
  16596. case creditusage.FieldAfterNumber:
  16597. return m.AddedAfterNumber()
  16598. case creditusage.FieldPayMethod:
  16599. return m.AddedPayMethod()
  16600. case creditusage.FieldStatus:
  16601. return m.AddedStatus()
  16602. case creditusage.FieldNtype:
  16603. return m.AddedNtype()
  16604. case creditusage.FieldOrganizationID:
  16605. return m.AddedOrganizationID()
  16606. case creditusage.FieldNid:
  16607. return m.AddedNid()
  16608. }
  16609. return nil, false
  16610. }
  16611. // AddField adds the value to the field with the given name. It returns an error if
  16612. // the field is not defined in the schema, or if the type mismatched the field
  16613. // type.
  16614. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  16615. switch name {
  16616. case creditusage.FieldNumber:
  16617. v, ok := value.(float64)
  16618. if !ok {
  16619. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16620. }
  16621. m.AddNumber(v)
  16622. return nil
  16623. case creditusage.FieldPayNumber:
  16624. v, ok := value.(float64)
  16625. if !ok {
  16626. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16627. }
  16628. m.AddPayNumber(v)
  16629. return nil
  16630. case creditusage.FieldBeforeNumber:
  16631. v, ok := value.(float64)
  16632. if !ok {
  16633. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16634. }
  16635. m.AddBeforeNumber(v)
  16636. return nil
  16637. case creditusage.FieldAfterNumber:
  16638. v, ok := value.(float64)
  16639. if !ok {
  16640. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16641. }
  16642. m.AddAfterNumber(v)
  16643. return nil
  16644. case creditusage.FieldPayMethod:
  16645. v, ok := value.(int)
  16646. if !ok {
  16647. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16648. }
  16649. m.AddPayMethod(v)
  16650. return nil
  16651. case creditusage.FieldStatus:
  16652. v, ok := value.(int)
  16653. if !ok {
  16654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16655. }
  16656. m.AddStatus(v)
  16657. return nil
  16658. case creditusage.FieldNtype:
  16659. v, ok := value.(int)
  16660. if !ok {
  16661. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16662. }
  16663. m.AddNtype(v)
  16664. return nil
  16665. case creditusage.FieldOrganizationID:
  16666. v, ok := value.(int64)
  16667. if !ok {
  16668. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16669. }
  16670. m.AddOrganizationID(v)
  16671. return nil
  16672. case creditusage.FieldNid:
  16673. v, ok := value.(int64)
  16674. if !ok {
  16675. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16676. }
  16677. m.AddNid(v)
  16678. return nil
  16679. }
  16680. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  16681. }
  16682. // ClearedFields returns all nullable fields that were cleared during this
  16683. // mutation.
  16684. func (m *CreditUsageMutation) ClearedFields() []string {
  16685. var fields []string
  16686. if m.FieldCleared(creditusage.FieldDeletedAt) {
  16687. fields = append(fields, creditusage.FieldDeletedAt)
  16688. }
  16689. if m.FieldCleared(creditusage.FieldUserID) {
  16690. fields = append(fields, creditusage.FieldUserID)
  16691. }
  16692. if m.FieldCleared(creditusage.FieldPayNumber) {
  16693. fields = append(fields, creditusage.FieldPayNumber)
  16694. }
  16695. if m.FieldCleared(creditusage.FieldBeforeNumber) {
  16696. fields = append(fields, creditusage.FieldBeforeNumber)
  16697. }
  16698. if m.FieldCleared(creditusage.FieldAfterNumber) {
  16699. fields = append(fields, creditusage.FieldAfterNumber)
  16700. }
  16701. if m.FieldCleared(creditusage.FieldPayMethod) {
  16702. fields = append(fields, creditusage.FieldPayMethod)
  16703. }
  16704. if m.FieldCleared(creditusage.FieldStatus) {
  16705. fields = append(fields, creditusage.FieldStatus)
  16706. }
  16707. if m.FieldCleared(creditusage.FieldOrganizationID) {
  16708. fields = append(fields, creditusage.FieldOrganizationID)
  16709. }
  16710. return fields
  16711. }
  16712. // FieldCleared returns a boolean indicating if a field with the given name was
  16713. // cleared in this mutation.
  16714. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  16715. _, ok := m.clearedFields[name]
  16716. return ok
  16717. }
  16718. // ClearField clears the value of the field with the given name. It returns an
  16719. // error if the field is not defined in the schema.
  16720. func (m *CreditUsageMutation) ClearField(name string) error {
  16721. switch name {
  16722. case creditusage.FieldDeletedAt:
  16723. m.ClearDeletedAt()
  16724. return nil
  16725. case creditusage.FieldUserID:
  16726. m.ClearUserID()
  16727. return nil
  16728. case creditusage.FieldPayNumber:
  16729. m.ClearPayNumber()
  16730. return nil
  16731. case creditusage.FieldBeforeNumber:
  16732. m.ClearBeforeNumber()
  16733. return nil
  16734. case creditusage.FieldAfterNumber:
  16735. m.ClearAfterNumber()
  16736. return nil
  16737. case creditusage.FieldPayMethod:
  16738. m.ClearPayMethod()
  16739. return nil
  16740. case creditusage.FieldStatus:
  16741. m.ClearStatus()
  16742. return nil
  16743. case creditusage.FieldOrganizationID:
  16744. m.ClearOrganizationID()
  16745. return nil
  16746. }
  16747. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  16748. }
  16749. // ResetField resets all changes in the mutation for the field with the given name.
  16750. // It returns an error if the field is not defined in the schema.
  16751. func (m *CreditUsageMutation) ResetField(name string) error {
  16752. switch name {
  16753. case creditusage.FieldCreatedAt:
  16754. m.ResetCreatedAt()
  16755. return nil
  16756. case creditusage.FieldUpdatedAt:
  16757. m.ResetUpdatedAt()
  16758. return nil
  16759. case creditusage.FieldDeletedAt:
  16760. m.ResetDeletedAt()
  16761. return nil
  16762. case creditusage.FieldUserID:
  16763. m.ResetUserID()
  16764. return nil
  16765. case creditusage.FieldNumber:
  16766. m.ResetNumber()
  16767. return nil
  16768. case creditusage.FieldPayNumber:
  16769. m.ResetPayNumber()
  16770. return nil
  16771. case creditusage.FieldBeforeNumber:
  16772. m.ResetBeforeNumber()
  16773. return nil
  16774. case creditusage.FieldAfterNumber:
  16775. m.ResetAfterNumber()
  16776. return nil
  16777. case creditusage.FieldPayMethod:
  16778. m.ResetPayMethod()
  16779. return nil
  16780. case creditusage.FieldStatus:
  16781. m.ResetStatus()
  16782. return nil
  16783. case creditusage.FieldNtype:
  16784. m.ResetNtype()
  16785. return nil
  16786. case creditusage.FieldTable:
  16787. m.ResetTable()
  16788. return nil
  16789. case creditusage.FieldOrganizationID:
  16790. m.ResetOrganizationID()
  16791. return nil
  16792. case creditusage.FieldNid:
  16793. m.ResetNid()
  16794. return nil
  16795. case creditusage.FieldReason:
  16796. m.ResetReason()
  16797. return nil
  16798. case creditusage.FieldOperator:
  16799. m.ResetOperator()
  16800. return nil
  16801. }
  16802. return fmt.Errorf("unknown CreditUsage field %s", name)
  16803. }
  16804. // AddedEdges returns all edge names that were set/added in this mutation.
  16805. func (m *CreditUsageMutation) AddedEdges() []string {
  16806. edges := make([]string, 0, 0)
  16807. return edges
  16808. }
  16809. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16810. // name in this mutation.
  16811. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  16812. return nil
  16813. }
  16814. // RemovedEdges returns all edge names that were removed in this mutation.
  16815. func (m *CreditUsageMutation) RemovedEdges() []string {
  16816. edges := make([]string, 0, 0)
  16817. return edges
  16818. }
  16819. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16820. // the given name in this mutation.
  16821. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  16822. return nil
  16823. }
  16824. // ClearedEdges returns all edge names that were cleared in this mutation.
  16825. func (m *CreditUsageMutation) ClearedEdges() []string {
  16826. edges := make([]string, 0, 0)
  16827. return edges
  16828. }
  16829. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16830. // was cleared in this mutation.
  16831. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  16832. return false
  16833. }
  16834. // ClearEdge clears the value of the edge with the given name. It returns an error
  16835. // if that edge is not defined in the schema.
  16836. func (m *CreditUsageMutation) ClearEdge(name string) error {
  16837. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  16838. }
  16839. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16840. // It returns an error if the edge is not defined in the schema.
  16841. func (m *CreditUsageMutation) ResetEdge(name string) error {
  16842. return fmt.Errorf("unknown CreditUsage edge %s", name)
  16843. }
  16844. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  16845. type EmployeeMutation struct {
  16846. config
  16847. op Op
  16848. typ string
  16849. id *uint64
  16850. created_at *time.Time
  16851. updated_at *time.Time
  16852. deleted_at *time.Time
  16853. title *string
  16854. avatar *string
  16855. tags *string
  16856. hire_count *int
  16857. addhire_count *int
  16858. service_count *int
  16859. addservice_count *int
  16860. achievement_count *int
  16861. addachievement_count *int
  16862. intro *string
  16863. estimate *string
  16864. skill *string
  16865. ability_type *string
  16866. scene *string
  16867. switch_in *string
  16868. video_url *string
  16869. organization_id *uint64
  16870. addorganization_id *int64
  16871. category_id *uint64
  16872. addcategory_id *int64
  16873. api_base *string
  16874. api_key *string
  16875. ai_info *string
  16876. is_vip *int
  16877. addis_vip *int
  16878. chat_url *string
  16879. clearedFields map[string]struct{}
  16880. em_work_experiences map[uint64]struct{}
  16881. removedem_work_experiences map[uint64]struct{}
  16882. clearedem_work_experiences bool
  16883. em_tutorial map[uint64]struct{}
  16884. removedem_tutorial map[uint64]struct{}
  16885. clearedem_tutorial bool
  16886. done bool
  16887. oldValue func(context.Context) (*Employee, error)
  16888. predicates []predicate.Employee
  16889. }
  16890. var _ ent.Mutation = (*EmployeeMutation)(nil)
  16891. // employeeOption allows management of the mutation configuration using functional options.
  16892. type employeeOption func(*EmployeeMutation)
  16893. // newEmployeeMutation creates new mutation for the Employee entity.
  16894. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  16895. m := &EmployeeMutation{
  16896. config: c,
  16897. op: op,
  16898. typ: TypeEmployee,
  16899. clearedFields: make(map[string]struct{}),
  16900. }
  16901. for _, opt := range opts {
  16902. opt(m)
  16903. }
  16904. return m
  16905. }
  16906. // withEmployeeID sets the ID field of the mutation.
  16907. func withEmployeeID(id uint64) employeeOption {
  16908. return func(m *EmployeeMutation) {
  16909. var (
  16910. err error
  16911. once sync.Once
  16912. value *Employee
  16913. )
  16914. m.oldValue = func(ctx context.Context) (*Employee, error) {
  16915. once.Do(func() {
  16916. if m.done {
  16917. err = errors.New("querying old values post mutation is not allowed")
  16918. } else {
  16919. value, err = m.Client().Employee.Get(ctx, id)
  16920. }
  16921. })
  16922. return value, err
  16923. }
  16924. m.id = &id
  16925. }
  16926. }
  16927. // withEmployee sets the old Employee of the mutation.
  16928. func withEmployee(node *Employee) employeeOption {
  16929. return func(m *EmployeeMutation) {
  16930. m.oldValue = func(context.Context) (*Employee, error) {
  16931. return node, nil
  16932. }
  16933. m.id = &node.ID
  16934. }
  16935. }
  16936. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16937. // executed in a transaction (ent.Tx), a transactional client is returned.
  16938. func (m EmployeeMutation) Client() *Client {
  16939. client := &Client{config: m.config}
  16940. client.init()
  16941. return client
  16942. }
  16943. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16944. // it returns an error otherwise.
  16945. func (m EmployeeMutation) Tx() (*Tx, error) {
  16946. if _, ok := m.driver.(*txDriver); !ok {
  16947. return nil, errors.New("ent: mutation is not running in a transaction")
  16948. }
  16949. tx := &Tx{config: m.config}
  16950. tx.init()
  16951. return tx, nil
  16952. }
  16953. // SetID sets the value of the id field. Note that this
  16954. // operation is only accepted on creation of Employee entities.
  16955. func (m *EmployeeMutation) SetID(id uint64) {
  16956. m.id = &id
  16957. }
  16958. // ID returns the ID value in the mutation. Note that the ID is only available
  16959. // if it was provided to the builder or after it was returned from the database.
  16960. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  16961. if m.id == nil {
  16962. return
  16963. }
  16964. return *m.id, true
  16965. }
  16966. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16967. // That means, if the mutation is applied within a transaction with an isolation level such
  16968. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16969. // or updated by the mutation.
  16970. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  16971. switch {
  16972. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16973. id, exists := m.ID()
  16974. if exists {
  16975. return []uint64{id}, nil
  16976. }
  16977. fallthrough
  16978. case m.op.Is(OpUpdate | OpDelete):
  16979. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  16980. default:
  16981. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16982. }
  16983. }
  16984. // SetCreatedAt sets the "created_at" field.
  16985. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  16986. m.created_at = &t
  16987. }
  16988. // CreatedAt returns the value of the "created_at" field in the mutation.
  16989. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  16990. v := m.created_at
  16991. if v == nil {
  16992. return
  16993. }
  16994. return *v, true
  16995. }
  16996. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  16997. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16998. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16999. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17000. if !m.op.Is(OpUpdateOne) {
  17001. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17002. }
  17003. if m.id == nil || m.oldValue == nil {
  17004. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17005. }
  17006. oldValue, err := m.oldValue(ctx)
  17007. if err != nil {
  17008. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17009. }
  17010. return oldValue.CreatedAt, nil
  17011. }
  17012. // ResetCreatedAt resets all changes to the "created_at" field.
  17013. func (m *EmployeeMutation) ResetCreatedAt() {
  17014. m.created_at = nil
  17015. }
  17016. // SetUpdatedAt sets the "updated_at" field.
  17017. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  17018. m.updated_at = &t
  17019. }
  17020. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17021. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  17022. v := m.updated_at
  17023. if v == nil {
  17024. return
  17025. }
  17026. return *v, true
  17027. }
  17028. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  17029. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17030. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17031. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17032. if !m.op.Is(OpUpdateOne) {
  17033. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17034. }
  17035. if m.id == nil || m.oldValue == nil {
  17036. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17037. }
  17038. oldValue, err := m.oldValue(ctx)
  17039. if err != nil {
  17040. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17041. }
  17042. return oldValue.UpdatedAt, nil
  17043. }
  17044. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17045. func (m *EmployeeMutation) ResetUpdatedAt() {
  17046. m.updated_at = nil
  17047. }
  17048. // SetDeletedAt sets the "deleted_at" field.
  17049. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  17050. m.deleted_at = &t
  17051. }
  17052. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  17053. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  17054. v := m.deleted_at
  17055. if v == nil {
  17056. return
  17057. }
  17058. return *v, true
  17059. }
  17060. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  17061. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17062. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17063. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  17064. if !m.op.Is(OpUpdateOne) {
  17065. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  17066. }
  17067. if m.id == nil || m.oldValue == nil {
  17068. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  17069. }
  17070. oldValue, err := m.oldValue(ctx)
  17071. if err != nil {
  17072. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  17073. }
  17074. return oldValue.DeletedAt, nil
  17075. }
  17076. // ClearDeletedAt clears the value of the "deleted_at" field.
  17077. func (m *EmployeeMutation) ClearDeletedAt() {
  17078. m.deleted_at = nil
  17079. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  17080. }
  17081. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  17082. func (m *EmployeeMutation) DeletedAtCleared() bool {
  17083. _, ok := m.clearedFields[employee.FieldDeletedAt]
  17084. return ok
  17085. }
  17086. // ResetDeletedAt resets all changes to the "deleted_at" field.
  17087. func (m *EmployeeMutation) ResetDeletedAt() {
  17088. m.deleted_at = nil
  17089. delete(m.clearedFields, employee.FieldDeletedAt)
  17090. }
  17091. // SetTitle sets the "title" field.
  17092. func (m *EmployeeMutation) SetTitle(s string) {
  17093. m.title = &s
  17094. }
  17095. // Title returns the value of the "title" field in the mutation.
  17096. func (m *EmployeeMutation) Title() (r string, exists bool) {
  17097. v := m.title
  17098. if v == nil {
  17099. return
  17100. }
  17101. return *v, true
  17102. }
  17103. // OldTitle returns the old "title" field's value of the Employee entity.
  17104. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17105. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17106. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  17107. if !m.op.Is(OpUpdateOne) {
  17108. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  17109. }
  17110. if m.id == nil || m.oldValue == nil {
  17111. return v, errors.New("OldTitle requires an ID field in the mutation")
  17112. }
  17113. oldValue, err := m.oldValue(ctx)
  17114. if err != nil {
  17115. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  17116. }
  17117. return oldValue.Title, nil
  17118. }
  17119. // ResetTitle resets all changes to the "title" field.
  17120. func (m *EmployeeMutation) ResetTitle() {
  17121. m.title = nil
  17122. }
  17123. // SetAvatar sets the "avatar" field.
  17124. func (m *EmployeeMutation) SetAvatar(s string) {
  17125. m.avatar = &s
  17126. }
  17127. // Avatar returns the value of the "avatar" field in the mutation.
  17128. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  17129. v := m.avatar
  17130. if v == nil {
  17131. return
  17132. }
  17133. return *v, true
  17134. }
  17135. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  17136. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17137. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17138. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  17139. if !m.op.Is(OpUpdateOne) {
  17140. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  17141. }
  17142. if m.id == nil || m.oldValue == nil {
  17143. return v, errors.New("OldAvatar requires an ID field in the mutation")
  17144. }
  17145. oldValue, err := m.oldValue(ctx)
  17146. if err != nil {
  17147. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  17148. }
  17149. return oldValue.Avatar, nil
  17150. }
  17151. // ResetAvatar resets all changes to the "avatar" field.
  17152. func (m *EmployeeMutation) ResetAvatar() {
  17153. m.avatar = nil
  17154. }
  17155. // SetTags sets the "tags" field.
  17156. func (m *EmployeeMutation) SetTags(s string) {
  17157. m.tags = &s
  17158. }
  17159. // Tags returns the value of the "tags" field in the mutation.
  17160. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  17161. v := m.tags
  17162. if v == nil {
  17163. return
  17164. }
  17165. return *v, true
  17166. }
  17167. // OldTags returns the old "tags" field's value of the Employee entity.
  17168. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17169. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17170. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  17171. if !m.op.Is(OpUpdateOne) {
  17172. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  17173. }
  17174. if m.id == nil || m.oldValue == nil {
  17175. return v, errors.New("OldTags requires an ID field in the mutation")
  17176. }
  17177. oldValue, err := m.oldValue(ctx)
  17178. if err != nil {
  17179. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  17180. }
  17181. return oldValue.Tags, nil
  17182. }
  17183. // ResetTags resets all changes to the "tags" field.
  17184. func (m *EmployeeMutation) ResetTags() {
  17185. m.tags = nil
  17186. }
  17187. // SetHireCount sets the "hire_count" field.
  17188. func (m *EmployeeMutation) SetHireCount(i int) {
  17189. m.hire_count = &i
  17190. m.addhire_count = nil
  17191. }
  17192. // HireCount returns the value of the "hire_count" field in the mutation.
  17193. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  17194. v := m.hire_count
  17195. if v == nil {
  17196. return
  17197. }
  17198. return *v, true
  17199. }
  17200. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  17201. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17202. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17203. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  17204. if !m.op.Is(OpUpdateOne) {
  17205. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  17206. }
  17207. if m.id == nil || m.oldValue == nil {
  17208. return v, errors.New("OldHireCount requires an ID field in the mutation")
  17209. }
  17210. oldValue, err := m.oldValue(ctx)
  17211. if err != nil {
  17212. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  17213. }
  17214. return oldValue.HireCount, nil
  17215. }
  17216. // AddHireCount adds i to the "hire_count" field.
  17217. func (m *EmployeeMutation) AddHireCount(i int) {
  17218. if m.addhire_count != nil {
  17219. *m.addhire_count += i
  17220. } else {
  17221. m.addhire_count = &i
  17222. }
  17223. }
  17224. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  17225. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  17226. v := m.addhire_count
  17227. if v == nil {
  17228. return
  17229. }
  17230. return *v, true
  17231. }
  17232. // ResetHireCount resets all changes to the "hire_count" field.
  17233. func (m *EmployeeMutation) ResetHireCount() {
  17234. m.hire_count = nil
  17235. m.addhire_count = nil
  17236. }
  17237. // SetServiceCount sets the "service_count" field.
  17238. func (m *EmployeeMutation) SetServiceCount(i int) {
  17239. m.service_count = &i
  17240. m.addservice_count = nil
  17241. }
  17242. // ServiceCount returns the value of the "service_count" field in the mutation.
  17243. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  17244. v := m.service_count
  17245. if v == nil {
  17246. return
  17247. }
  17248. return *v, true
  17249. }
  17250. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  17251. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17252. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17253. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  17254. if !m.op.Is(OpUpdateOne) {
  17255. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  17256. }
  17257. if m.id == nil || m.oldValue == nil {
  17258. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  17259. }
  17260. oldValue, err := m.oldValue(ctx)
  17261. if err != nil {
  17262. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  17263. }
  17264. return oldValue.ServiceCount, nil
  17265. }
  17266. // AddServiceCount adds i to the "service_count" field.
  17267. func (m *EmployeeMutation) AddServiceCount(i int) {
  17268. if m.addservice_count != nil {
  17269. *m.addservice_count += i
  17270. } else {
  17271. m.addservice_count = &i
  17272. }
  17273. }
  17274. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  17275. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  17276. v := m.addservice_count
  17277. if v == nil {
  17278. return
  17279. }
  17280. return *v, true
  17281. }
  17282. // ResetServiceCount resets all changes to the "service_count" field.
  17283. func (m *EmployeeMutation) ResetServiceCount() {
  17284. m.service_count = nil
  17285. m.addservice_count = nil
  17286. }
  17287. // SetAchievementCount sets the "achievement_count" field.
  17288. func (m *EmployeeMutation) SetAchievementCount(i int) {
  17289. m.achievement_count = &i
  17290. m.addachievement_count = nil
  17291. }
  17292. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  17293. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  17294. v := m.achievement_count
  17295. if v == nil {
  17296. return
  17297. }
  17298. return *v, true
  17299. }
  17300. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  17301. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17302. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17303. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  17304. if !m.op.Is(OpUpdateOne) {
  17305. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  17306. }
  17307. if m.id == nil || m.oldValue == nil {
  17308. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  17309. }
  17310. oldValue, err := m.oldValue(ctx)
  17311. if err != nil {
  17312. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  17313. }
  17314. return oldValue.AchievementCount, nil
  17315. }
  17316. // AddAchievementCount adds i to the "achievement_count" field.
  17317. func (m *EmployeeMutation) AddAchievementCount(i int) {
  17318. if m.addachievement_count != nil {
  17319. *m.addachievement_count += i
  17320. } else {
  17321. m.addachievement_count = &i
  17322. }
  17323. }
  17324. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  17325. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  17326. v := m.addachievement_count
  17327. if v == nil {
  17328. return
  17329. }
  17330. return *v, true
  17331. }
  17332. // ResetAchievementCount resets all changes to the "achievement_count" field.
  17333. func (m *EmployeeMutation) ResetAchievementCount() {
  17334. m.achievement_count = nil
  17335. m.addachievement_count = nil
  17336. }
  17337. // SetIntro sets the "intro" field.
  17338. func (m *EmployeeMutation) SetIntro(s string) {
  17339. m.intro = &s
  17340. }
  17341. // Intro returns the value of the "intro" field in the mutation.
  17342. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  17343. v := m.intro
  17344. if v == nil {
  17345. return
  17346. }
  17347. return *v, true
  17348. }
  17349. // OldIntro returns the old "intro" field's value of the Employee entity.
  17350. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17351. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17352. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  17353. if !m.op.Is(OpUpdateOne) {
  17354. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  17355. }
  17356. if m.id == nil || m.oldValue == nil {
  17357. return v, errors.New("OldIntro requires an ID field in the mutation")
  17358. }
  17359. oldValue, err := m.oldValue(ctx)
  17360. if err != nil {
  17361. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  17362. }
  17363. return oldValue.Intro, nil
  17364. }
  17365. // ResetIntro resets all changes to the "intro" field.
  17366. func (m *EmployeeMutation) ResetIntro() {
  17367. m.intro = nil
  17368. }
  17369. // SetEstimate sets the "estimate" field.
  17370. func (m *EmployeeMutation) SetEstimate(s string) {
  17371. m.estimate = &s
  17372. }
  17373. // Estimate returns the value of the "estimate" field in the mutation.
  17374. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  17375. v := m.estimate
  17376. if v == nil {
  17377. return
  17378. }
  17379. return *v, true
  17380. }
  17381. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  17382. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17383. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17384. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  17385. if !m.op.Is(OpUpdateOne) {
  17386. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  17387. }
  17388. if m.id == nil || m.oldValue == nil {
  17389. return v, errors.New("OldEstimate requires an ID field in the mutation")
  17390. }
  17391. oldValue, err := m.oldValue(ctx)
  17392. if err != nil {
  17393. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  17394. }
  17395. return oldValue.Estimate, nil
  17396. }
  17397. // ResetEstimate resets all changes to the "estimate" field.
  17398. func (m *EmployeeMutation) ResetEstimate() {
  17399. m.estimate = nil
  17400. }
  17401. // SetSkill sets the "skill" field.
  17402. func (m *EmployeeMutation) SetSkill(s string) {
  17403. m.skill = &s
  17404. }
  17405. // Skill returns the value of the "skill" field in the mutation.
  17406. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  17407. v := m.skill
  17408. if v == nil {
  17409. return
  17410. }
  17411. return *v, true
  17412. }
  17413. // OldSkill returns the old "skill" field's value of the Employee entity.
  17414. // If the Employee 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 *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  17417. if !m.op.Is(OpUpdateOne) {
  17418. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  17419. }
  17420. if m.id == nil || m.oldValue == nil {
  17421. return v, errors.New("OldSkill 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 OldSkill: %w", err)
  17426. }
  17427. return oldValue.Skill, nil
  17428. }
  17429. // ResetSkill resets all changes to the "skill" field.
  17430. func (m *EmployeeMutation) ResetSkill() {
  17431. m.skill = nil
  17432. }
  17433. // SetAbilityType sets the "ability_type" field.
  17434. func (m *EmployeeMutation) SetAbilityType(s string) {
  17435. m.ability_type = &s
  17436. }
  17437. // AbilityType returns the value of the "ability_type" field in the mutation.
  17438. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  17439. v := m.ability_type
  17440. if v == nil {
  17441. return
  17442. }
  17443. return *v, true
  17444. }
  17445. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  17446. // If the Employee 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 *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  17449. if !m.op.Is(OpUpdateOne) {
  17450. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  17451. }
  17452. if m.id == nil || m.oldValue == nil {
  17453. return v, errors.New("OldAbilityType 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 OldAbilityType: %w", err)
  17458. }
  17459. return oldValue.AbilityType, nil
  17460. }
  17461. // ResetAbilityType resets all changes to the "ability_type" field.
  17462. func (m *EmployeeMutation) ResetAbilityType() {
  17463. m.ability_type = nil
  17464. }
  17465. // SetScene sets the "scene" field.
  17466. func (m *EmployeeMutation) SetScene(s string) {
  17467. m.scene = &s
  17468. }
  17469. // Scene returns the value of the "scene" field in the mutation.
  17470. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  17471. v := m.scene
  17472. if v == nil {
  17473. return
  17474. }
  17475. return *v, true
  17476. }
  17477. // OldScene returns the old "scene" field's value of the Employee entity.
  17478. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17479. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17480. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  17481. if !m.op.Is(OpUpdateOne) {
  17482. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  17483. }
  17484. if m.id == nil || m.oldValue == nil {
  17485. return v, errors.New("OldScene requires an ID field in the mutation")
  17486. }
  17487. oldValue, err := m.oldValue(ctx)
  17488. if err != nil {
  17489. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  17490. }
  17491. return oldValue.Scene, nil
  17492. }
  17493. // ResetScene resets all changes to the "scene" field.
  17494. func (m *EmployeeMutation) ResetScene() {
  17495. m.scene = nil
  17496. }
  17497. // SetSwitchIn sets the "switch_in" field.
  17498. func (m *EmployeeMutation) SetSwitchIn(s string) {
  17499. m.switch_in = &s
  17500. }
  17501. // SwitchIn returns the value of the "switch_in" field in the mutation.
  17502. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  17503. v := m.switch_in
  17504. if v == nil {
  17505. return
  17506. }
  17507. return *v, true
  17508. }
  17509. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  17510. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17511. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17512. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  17513. if !m.op.Is(OpUpdateOne) {
  17514. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  17515. }
  17516. if m.id == nil || m.oldValue == nil {
  17517. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  17518. }
  17519. oldValue, err := m.oldValue(ctx)
  17520. if err != nil {
  17521. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  17522. }
  17523. return oldValue.SwitchIn, nil
  17524. }
  17525. // ResetSwitchIn resets all changes to the "switch_in" field.
  17526. func (m *EmployeeMutation) ResetSwitchIn() {
  17527. m.switch_in = nil
  17528. }
  17529. // SetVideoURL sets the "video_url" field.
  17530. func (m *EmployeeMutation) SetVideoURL(s string) {
  17531. m.video_url = &s
  17532. }
  17533. // VideoURL returns the value of the "video_url" field in the mutation.
  17534. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  17535. v := m.video_url
  17536. if v == nil {
  17537. return
  17538. }
  17539. return *v, true
  17540. }
  17541. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  17542. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17543. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17544. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  17545. if !m.op.Is(OpUpdateOne) {
  17546. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  17547. }
  17548. if m.id == nil || m.oldValue == nil {
  17549. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  17550. }
  17551. oldValue, err := m.oldValue(ctx)
  17552. if err != nil {
  17553. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  17554. }
  17555. return oldValue.VideoURL, nil
  17556. }
  17557. // ResetVideoURL resets all changes to the "video_url" field.
  17558. func (m *EmployeeMutation) ResetVideoURL() {
  17559. m.video_url = nil
  17560. }
  17561. // SetOrganizationID sets the "organization_id" field.
  17562. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  17563. m.organization_id = &u
  17564. m.addorganization_id = nil
  17565. }
  17566. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17567. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  17568. v := m.organization_id
  17569. if v == nil {
  17570. return
  17571. }
  17572. return *v, true
  17573. }
  17574. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  17575. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17576. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17577. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17578. if !m.op.Is(OpUpdateOne) {
  17579. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17580. }
  17581. if m.id == nil || m.oldValue == nil {
  17582. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17583. }
  17584. oldValue, err := m.oldValue(ctx)
  17585. if err != nil {
  17586. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17587. }
  17588. return oldValue.OrganizationID, nil
  17589. }
  17590. // AddOrganizationID adds u to the "organization_id" field.
  17591. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  17592. if m.addorganization_id != nil {
  17593. *m.addorganization_id += u
  17594. } else {
  17595. m.addorganization_id = &u
  17596. }
  17597. }
  17598. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17599. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  17600. v := m.addorganization_id
  17601. if v == nil {
  17602. return
  17603. }
  17604. return *v, true
  17605. }
  17606. // ResetOrganizationID resets all changes to the "organization_id" field.
  17607. func (m *EmployeeMutation) ResetOrganizationID() {
  17608. m.organization_id = nil
  17609. m.addorganization_id = nil
  17610. }
  17611. // SetCategoryID sets the "category_id" field.
  17612. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  17613. m.category_id = &u
  17614. m.addcategory_id = nil
  17615. }
  17616. // CategoryID returns the value of the "category_id" field in the mutation.
  17617. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  17618. v := m.category_id
  17619. if v == nil {
  17620. return
  17621. }
  17622. return *v, true
  17623. }
  17624. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  17625. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17626. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17627. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  17628. if !m.op.Is(OpUpdateOne) {
  17629. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  17630. }
  17631. if m.id == nil || m.oldValue == nil {
  17632. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  17633. }
  17634. oldValue, err := m.oldValue(ctx)
  17635. if err != nil {
  17636. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  17637. }
  17638. return oldValue.CategoryID, nil
  17639. }
  17640. // AddCategoryID adds u to the "category_id" field.
  17641. func (m *EmployeeMutation) AddCategoryID(u int64) {
  17642. if m.addcategory_id != nil {
  17643. *m.addcategory_id += u
  17644. } else {
  17645. m.addcategory_id = &u
  17646. }
  17647. }
  17648. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  17649. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  17650. v := m.addcategory_id
  17651. if v == nil {
  17652. return
  17653. }
  17654. return *v, true
  17655. }
  17656. // ResetCategoryID resets all changes to the "category_id" field.
  17657. func (m *EmployeeMutation) ResetCategoryID() {
  17658. m.category_id = nil
  17659. m.addcategory_id = nil
  17660. }
  17661. // SetAPIBase sets the "api_base" field.
  17662. func (m *EmployeeMutation) SetAPIBase(s string) {
  17663. m.api_base = &s
  17664. }
  17665. // APIBase returns the value of the "api_base" field in the mutation.
  17666. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  17667. v := m.api_base
  17668. if v == nil {
  17669. return
  17670. }
  17671. return *v, true
  17672. }
  17673. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  17674. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17675. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17676. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  17677. if !m.op.Is(OpUpdateOne) {
  17678. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  17679. }
  17680. if m.id == nil || m.oldValue == nil {
  17681. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  17682. }
  17683. oldValue, err := m.oldValue(ctx)
  17684. if err != nil {
  17685. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  17686. }
  17687. return oldValue.APIBase, nil
  17688. }
  17689. // ResetAPIBase resets all changes to the "api_base" field.
  17690. func (m *EmployeeMutation) ResetAPIBase() {
  17691. m.api_base = nil
  17692. }
  17693. // SetAPIKey sets the "api_key" field.
  17694. func (m *EmployeeMutation) SetAPIKey(s string) {
  17695. m.api_key = &s
  17696. }
  17697. // APIKey returns the value of the "api_key" field in the mutation.
  17698. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  17699. v := m.api_key
  17700. if v == nil {
  17701. return
  17702. }
  17703. return *v, true
  17704. }
  17705. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  17706. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17707. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17708. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  17709. if !m.op.Is(OpUpdateOne) {
  17710. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  17711. }
  17712. if m.id == nil || m.oldValue == nil {
  17713. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  17714. }
  17715. oldValue, err := m.oldValue(ctx)
  17716. if err != nil {
  17717. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  17718. }
  17719. return oldValue.APIKey, nil
  17720. }
  17721. // ResetAPIKey resets all changes to the "api_key" field.
  17722. func (m *EmployeeMutation) ResetAPIKey() {
  17723. m.api_key = nil
  17724. }
  17725. // SetAiInfo sets the "ai_info" field.
  17726. func (m *EmployeeMutation) SetAiInfo(s string) {
  17727. m.ai_info = &s
  17728. }
  17729. // AiInfo returns the value of the "ai_info" field in the mutation.
  17730. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  17731. v := m.ai_info
  17732. if v == nil {
  17733. return
  17734. }
  17735. return *v, true
  17736. }
  17737. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  17738. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17739. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17740. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  17741. if !m.op.Is(OpUpdateOne) {
  17742. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  17743. }
  17744. if m.id == nil || m.oldValue == nil {
  17745. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  17746. }
  17747. oldValue, err := m.oldValue(ctx)
  17748. if err != nil {
  17749. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  17750. }
  17751. return oldValue.AiInfo, nil
  17752. }
  17753. // ClearAiInfo clears the value of the "ai_info" field.
  17754. func (m *EmployeeMutation) ClearAiInfo() {
  17755. m.ai_info = nil
  17756. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  17757. }
  17758. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  17759. func (m *EmployeeMutation) AiInfoCleared() bool {
  17760. _, ok := m.clearedFields[employee.FieldAiInfo]
  17761. return ok
  17762. }
  17763. // ResetAiInfo resets all changes to the "ai_info" field.
  17764. func (m *EmployeeMutation) ResetAiInfo() {
  17765. m.ai_info = nil
  17766. delete(m.clearedFields, employee.FieldAiInfo)
  17767. }
  17768. // SetIsVip sets the "is_vip" field.
  17769. func (m *EmployeeMutation) SetIsVip(i int) {
  17770. m.is_vip = &i
  17771. m.addis_vip = nil
  17772. }
  17773. // IsVip returns the value of the "is_vip" field in the mutation.
  17774. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  17775. v := m.is_vip
  17776. if v == nil {
  17777. return
  17778. }
  17779. return *v, true
  17780. }
  17781. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  17782. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17783. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17784. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  17785. if !m.op.Is(OpUpdateOne) {
  17786. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  17787. }
  17788. if m.id == nil || m.oldValue == nil {
  17789. return v, errors.New("OldIsVip requires an ID field in the mutation")
  17790. }
  17791. oldValue, err := m.oldValue(ctx)
  17792. if err != nil {
  17793. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  17794. }
  17795. return oldValue.IsVip, nil
  17796. }
  17797. // AddIsVip adds i to the "is_vip" field.
  17798. func (m *EmployeeMutation) AddIsVip(i int) {
  17799. if m.addis_vip != nil {
  17800. *m.addis_vip += i
  17801. } else {
  17802. m.addis_vip = &i
  17803. }
  17804. }
  17805. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  17806. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  17807. v := m.addis_vip
  17808. if v == nil {
  17809. return
  17810. }
  17811. return *v, true
  17812. }
  17813. // ResetIsVip resets all changes to the "is_vip" field.
  17814. func (m *EmployeeMutation) ResetIsVip() {
  17815. m.is_vip = nil
  17816. m.addis_vip = nil
  17817. }
  17818. // SetChatURL sets the "chat_url" field.
  17819. func (m *EmployeeMutation) SetChatURL(s string) {
  17820. m.chat_url = &s
  17821. }
  17822. // ChatURL returns the value of the "chat_url" field in the mutation.
  17823. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  17824. v := m.chat_url
  17825. if v == nil {
  17826. return
  17827. }
  17828. return *v, true
  17829. }
  17830. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  17831. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17832. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17833. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  17834. if !m.op.Is(OpUpdateOne) {
  17835. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  17836. }
  17837. if m.id == nil || m.oldValue == nil {
  17838. return v, errors.New("OldChatURL requires an ID field in the mutation")
  17839. }
  17840. oldValue, err := m.oldValue(ctx)
  17841. if err != nil {
  17842. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  17843. }
  17844. return oldValue.ChatURL, nil
  17845. }
  17846. // ResetChatURL resets all changes to the "chat_url" field.
  17847. func (m *EmployeeMutation) ResetChatURL() {
  17848. m.chat_url = nil
  17849. }
  17850. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  17851. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  17852. if m.em_work_experiences == nil {
  17853. m.em_work_experiences = make(map[uint64]struct{})
  17854. }
  17855. for i := range ids {
  17856. m.em_work_experiences[ids[i]] = struct{}{}
  17857. }
  17858. }
  17859. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  17860. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  17861. m.clearedem_work_experiences = true
  17862. }
  17863. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  17864. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  17865. return m.clearedem_work_experiences
  17866. }
  17867. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  17868. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  17869. if m.removedem_work_experiences == nil {
  17870. m.removedem_work_experiences = make(map[uint64]struct{})
  17871. }
  17872. for i := range ids {
  17873. delete(m.em_work_experiences, ids[i])
  17874. m.removedem_work_experiences[ids[i]] = struct{}{}
  17875. }
  17876. }
  17877. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  17878. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  17879. for id := range m.removedem_work_experiences {
  17880. ids = append(ids, id)
  17881. }
  17882. return
  17883. }
  17884. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  17885. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  17886. for id := range m.em_work_experiences {
  17887. ids = append(ids, id)
  17888. }
  17889. return
  17890. }
  17891. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  17892. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  17893. m.em_work_experiences = nil
  17894. m.clearedem_work_experiences = false
  17895. m.removedem_work_experiences = nil
  17896. }
  17897. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  17898. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  17899. if m.em_tutorial == nil {
  17900. m.em_tutorial = make(map[uint64]struct{})
  17901. }
  17902. for i := range ids {
  17903. m.em_tutorial[ids[i]] = struct{}{}
  17904. }
  17905. }
  17906. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  17907. func (m *EmployeeMutation) ClearEmTutorial() {
  17908. m.clearedem_tutorial = true
  17909. }
  17910. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  17911. func (m *EmployeeMutation) EmTutorialCleared() bool {
  17912. return m.clearedem_tutorial
  17913. }
  17914. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  17915. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  17916. if m.removedem_tutorial == nil {
  17917. m.removedem_tutorial = make(map[uint64]struct{})
  17918. }
  17919. for i := range ids {
  17920. delete(m.em_tutorial, ids[i])
  17921. m.removedem_tutorial[ids[i]] = struct{}{}
  17922. }
  17923. }
  17924. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  17925. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  17926. for id := range m.removedem_tutorial {
  17927. ids = append(ids, id)
  17928. }
  17929. return
  17930. }
  17931. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  17932. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  17933. for id := range m.em_tutorial {
  17934. ids = append(ids, id)
  17935. }
  17936. return
  17937. }
  17938. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  17939. func (m *EmployeeMutation) ResetEmTutorial() {
  17940. m.em_tutorial = nil
  17941. m.clearedem_tutorial = false
  17942. m.removedem_tutorial = nil
  17943. }
  17944. // Where appends a list predicates to the EmployeeMutation builder.
  17945. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  17946. m.predicates = append(m.predicates, ps...)
  17947. }
  17948. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  17949. // users can use type-assertion to append predicates that do not depend on any generated package.
  17950. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  17951. p := make([]predicate.Employee, len(ps))
  17952. for i := range ps {
  17953. p[i] = ps[i]
  17954. }
  17955. m.Where(p...)
  17956. }
  17957. // Op returns the operation name.
  17958. func (m *EmployeeMutation) Op() Op {
  17959. return m.op
  17960. }
  17961. // SetOp allows setting the mutation operation.
  17962. func (m *EmployeeMutation) SetOp(op Op) {
  17963. m.op = op
  17964. }
  17965. // Type returns the node type of this mutation (Employee).
  17966. func (m *EmployeeMutation) Type() string {
  17967. return m.typ
  17968. }
  17969. // Fields returns all fields that were changed during this mutation. Note that in
  17970. // order to get all numeric fields that were incremented/decremented, call
  17971. // AddedFields().
  17972. func (m *EmployeeMutation) Fields() []string {
  17973. fields := make([]string, 0, 23)
  17974. if m.created_at != nil {
  17975. fields = append(fields, employee.FieldCreatedAt)
  17976. }
  17977. if m.updated_at != nil {
  17978. fields = append(fields, employee.FieldUpdatedAt)
  17979. }
  17980. if m.deleted_at != nil {
  17981. fields = append(fields, employee.FieldDeletedAt)
  17982. }
  17983. if m.title != nil {
  17984. fields = append(fields, employee.FieldTitle)
  17985. }
  17986. if m.avatar != nil {
  17987. fields = append(fields, employee.FieldAvatar)
  17988. }
  17989. if m.tags != nil {
  17990. fields = append(fields, employee.FieldTags)
  17991. }
  17992. if m.hire_count != nil {
  17993. fields = append(fields, employee.FieldHireCount)
  17994. }
  17995. if m.service_count != nil {
  17996. fields = append(fields, employee.FieldServiceCount)
  17997. }
  17998. if m.achievement_count != nil {
  17999. fields = append(fields, employee.FieldAchievementCount)
  18000. }
  18001. if m.intro != nil {
  18002. fields = append(fields, employee.FieldIntro)
  18003. }
  18004. if m.estimate != nil {
  18005. fields = append(fields, employee.FieldEstimate)
  18006. }
  18007. if m.skill != nil {
  18008. fields = append(fields, employee.FieldSkill)
  18009. }
  18010. if m.ability_type != nil {
  18011. fields = append(fields, employee.FieldAbilityType)
  18012. }
  18013. if m.scene != nil {
  18014. fields = append(fields, employee.FieldScene)
  18015. }
  18016. if m.switch_in != nil {
  18017. fields = append(fields, employee.FieldSwitchIn)
  18018. }
  18019. if m.video_url != nil {
  18020. fields = append(fields, employee.FieldVideoURL)
  18021. }
  18022. if m.organization_id != nil {
  18023. fields = append(fields, employee.FieldOrganizationID)
  18024. }
  18025. if m.category_id != nil {
  18026. fields = append(fields, employee.FieldCategoryID)
  18027. }
  18028. if m.api_base != nil {
  18029. fields = append(fields, employee.FieldAPIBase)
  18030. }
  18031. if m.api_key != nil {
  18032. fields = append(fields, employee.FieldAPIKey)
  18033. }
  18034. if m.ai_info != nil {
  18035. fields = append(fields, employee.FieldAiInfo)
  18036. }
  18037. if m.is_vip != nil {
  18038. fields = append(fields, employee.FieldIsVip)
  18039. }
  18040. if m.chat_url != nil {
  18041. fields = append(fields, employee.FieldChatURL)
  18042. }
  18043. return fields
  18044. }
  18045. // Field returns the value of a field with the given name. The second boolean
  18046. // return value indicates that this field was not set, or was not defined in the
  18047. // schema.
  18048. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  18049. switch name {
  18050. case employee.FieldCreatedAt:
  18051. return m.CreatedAt()
  18052. case employee.FieldUpdatedAt:
  18053. return m.UpdatedAt()
  18054. case employee.FieldDeletedAt:
  18055. return m.DeletedAt()
  18056. case employee.FieldTitle:
  18057. return m.Title()
  18058. case employee.FieldAvatar:
  18059. return m.Avatar()
  18060. case employee.FieldTags:
  18061. return m.Tags()
  18062. case employee.FieldHireCount:
  18063. return m.HireCount()
  18064. case employee.FieldServiceCount:
  18065. return m.ServiceCount()
  18066. case employee.FieldAchievementCount:
  18067. return m.AchievementCount()
  18068. case employee.FieldIntro:
  18069. return m.Intro()
  18070. case employee.FieldEstimate:
  18071. return m.Estimate()
  18072. case employee.FieldSkill:
  18073. return m.Skill()
  18074. case employee.FieldAbilityType:
  18075. return m.AbilityType()
  18076. case employee.FieldScene:
  18077. return m.Scene()
  18078. case employee.FieldSwitchIn:
  18079. return m.SwitchIn()
  18080. case employee.FieldVideoURL:
  18081. return m.VideoURL()
  18082. case employee.FieldOrganizationID:
  18083. return m.OrganizationID()
  18084. case employee.FieldCategoryID:
  18085. return m.CategoryID()
  18086. case employee.FieldAPIBase:
  18087. return m.APIBase()
  18088. case employee.FieldAPIKey:
  18089. return m.APIKey()
  18090. case employee.FieldAiInfo:
  18091. return m.AiInfo()
  18092. case employee.FieldIsVip:
  18093. return m.IsVip()
  18094. case employee.FieldChatURL:
  18095. return m.ChatURL()
  18096. }
  18097. return nil, false
  18098. }
  18099. // OldField returns the old value of the field from the database. An error is
  18100. // returned if the mutation operation is not UpdateOne, or the query to the
  18101. // database failed.
  18102. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18103. switch name {
  18104. case employee.FieldCreatedAt:
  18105. return m.OldCreatedAt(ctx)
  18106. case employee.FieldUpdatedAt:
  18107. return m.OldUpdatedAt(ctx)
  18108. case employee.FieldDeletedAt:
  18109. return m.OldDeletedAt(ctx)
  18110. case employee.FieldTitle:
  18111. return m.OldTitle(ctx)
  18112. case employee.FieldAvatar:
  18113. return m.OldAvatar(ctx)
  18114. case employee.FieldTags:
  18115. return m.OldTags(ctx)
  18116. case employee.FieldHireCount:
  18117. return m.OldHireCount(ctx)
  18118. case employee.FieldServiceCount:
  18119. return m.OldServiceCount(ctx)
  18120. case employee.FieldAchievementCount:
  18121. return m.OldAchievementCount(ctx)
  18122. case employee.FieldIntro:
  18123. return m.OldIntro(ctx)
  18124. case employee.FieldEstimate:
  18125. return m.OldEstimate(ctx)
  18126. case employee.FieldSkill:
  18127. return m.OldSkill(ctx)
  18128. case employee.FieldAbilityType:
  18129. return m.OldAbilityType(ctx)
  18130. case employee.FieldScene:
  18131. return m.OldScene(ctx)
  18132. case employee.FieldSwitchIn:
  18133. return m.OldSwitchIn(ctx)
  18134. case employee.FieldVideoURL:
  18135. return m.OldVideoURL(ctx)
  18136. case employee.FieldOrganizationID:
  18137. return m.OldOrganizationID(ctx)
  18138. case employee.FieldCategoryID:
  18139. return m.OldCategoryID(ctx)
  18140. case employee.FieldAPIBase:
  18141. return m.OldAPIBase(ctx)
  18142. case employee.FieldAPIKey:
  18143. return m.OldAPIKey(ctx)
  18144. case employee.FieldAiInfo:
  18145. return m.OldAiInfo(ctx)
  18146. case employee.FieldIsVip:
  18147. return m.OldIsVip(ctx)
  18148. case employee.FieldChatURL:
  18149. return m.OldChatURL(ctx)
  18150. }
  18151. return nil, fmt.Errorf("unknown Employee field %s", name)
  18152. }
  18153. // SetField sets the value of a field with the given name. It returns an error if
  18154. // the field is not defined in the schema, or if the type mismatched the field
  18155. // type.
  18156. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  18157. switch name {
  18158. case employee.FieldCreatedAt:
  18159. v, ok := value.(time.Time)
  18160. if !ok {
  18161. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18162. }
  18163. m.SetCreatedAt(v)
  18164. return nil
  18165. case employee.FieldUpdatedAt:
  18166. v, ok := value.(time.Time)
  18167. if !ok {
  18168. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18169. }
  18170. m.SetUpdatedAt(v)
  18171. return nil
  18172. case employee.FieldDeletedAt:
  18173. v, ok := value.(time.Time)
  18174. if !ok {
  18175. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18176. }
  18177. m.SetDeletedAt(v)
  18178. return nil
  18179. case employee.FieldTitle:
  18180. v, ok := value.(string)
  18181. if !ok {
  18182. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18183. }
  18184. m.SetTitle(v)
  18185. return nil
  18186. case employee.FieldAvatar:
  18187. v, ok := value.(string)
  18188. if !ok {
  18189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18190. }
  18191. m.SetAvatar(v)
  18192. return nil
  18193. case employee.FieldTags:
  18194. v, ok := value.(string)
  18195. if !ok {
  18196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18197. }
  18198. m.SetTags(v)
  18199. return nil
  18200. case employee.FieldHireCount:
  18201. v, ok := value.(int)
  18202. if !ok {
  18203. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18204. }
  18205. m.SetHireCount(v)
  18206. return nil
  18207. case employee.FieldServiceCount:
  18208. v, ok := value.(int)
  18209. if !ok {
  18210. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18211. }
  18212. m.SetServiceCount(v)
  18213. return nil
  18214. case employee.FieldAchievementCount:
  18215. v, ok := value.(int)
  18216. if !ok {
  18217. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18218. }
  18219. m.SetAchievementCount(v)
  18220. return nil
  18221. case employee.FieldIntro:
  18222. v, ok := value.(string)
  18223. if !ok {
  18224. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18225. }
  18226. m.SetIntro(v)
  18227. return nil
  18228. case employee.FieldEstimate:
  18229. v, ok := value.(string)
  18230. if !ok {
  18231. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18232. }
  18233. m.SetEstimate(v)
  18234. return nil
  18235. case employee.FieldSkill:
  18236. v, ok := value.(string)
  18237. if !ok {
  18238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18239. }
  18240. m.SetSkill(v)
  18241. return nil
  18242. case employee.FieldAbilityType:
  18243. v, ok := value.(string)
  18244. if !ok {
  18245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18246. }
  18247. m.SetAbilityType(v)
  18248. return nil
  18249. case employee.FieldScene:
  18250. v, ok := value.(string)
  18251. if !ok {
  18252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18253. }
  18254. m.SetScene(v)
  18255. return nil
  18256. case employee.FieldSwitchIn:
  18257. v, ok := value.(string)
  18258. if !ok {
  18259. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18260. }
  18261. m.SetSwitchIn(v)
  18262. return nil
  18263. case employee.FieldVideoURL:
  18264. v, ok := value.(string)
  18265. if !ok {
  18266. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18267. }
  18268. m.SetVideoURL(v)
  18269. return nil
  18270. case employee.FieldOrganizationID:
  18271. v, ok := value.(uint64)
  18272. if !ok {
  18273. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18274. }
  18275. m.SetOrganizationID(v)
  18276. return nil
  18277. case employee.FieldCategoryID:
  18278. v, ok := value.(uint64)
  18279. if !ok {
  18280. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18281. }
  18282. m.SetCategoryID(v)
  18283. return nil
  18284. case employee.FieldAPIBase:
  18285. v, ok := value.(string)
  18286. if !ok {
  18287. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18288. }
  18289. m.SetAPIBase(v)
  18290. return nil
  18291. case employee.FieldAPIKey:
  18292. v, ok := value.(string)
  18293. if !ok {
  18294. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18295. }
  18296. m.SetAPIKey(v)
  18297. return nil
  18298. case employee.FieldAiInfo:
  18299. v, ok := value.(string)
  18300. if !ok {
  18301. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18302. }
  18303. m.SetAiInfo(v)
  18304. return nil
  18305. case employee.FieldIsVip:
  18306. v, ok := value.(int)
  18307. if !ok {
  18308. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18309. }
  18310. m.SetIsVip(v)
  18311. return nil
  18312. case employee.FieldChatURL:
  18313. v, ok := value.(string)
  18314. if !ok {
  18315. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18316. }
  18317. m.SetChatURL(v)
  18318. return nil
  18319. }
  18320. return fmt.Errorf("unknown Employee field %s", name)
  18321. }
  18322. // AddedFields returns all numeric fields that were incremented/decremented during
  18323. // this mutation.
  18324. func (m *EmployeeMutation) AddedFields() []string {
  18325. var fields []string
  18326. if m.addhire_count != nil {
  18327. fields = append(fields, employee.FieldHireCount)
  18328. }
  18329. if m.addservice_count != nil {
  18330. fields = append(fields, employee.FieldServiceCount)
  18331. }
  18332. if m.addachievement_count != nil {
  18333. fields = append(fields, employee.FieldAchievementCount)
  18334. }
  18335. if m.addorganization_id != nil {
  18336. fields = append(fields, employee.FieldOrganizationID)
  18337. }
  18338. if m.addcategory_id != nil {
  18339. fields = append(fields, employee.FieldCategoryID)
  18340. }
  18341. if m.addis_vip != nil {
  18342. fields = append(fields, employee.FieldIsVip)
  18343. }
  18344. return fields
  18345. }
  18346. // AddedField returns the numeric value that was incremented/decremented on a field
  18347. // with the given name. The second boolean return value indicates that this field
  18348. // was not set, or was not defined in the schema.
  18349. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  18350. switch name {
  18351. case employee.FieldHireCount:
  18352. return m.AddedHireCount()
  18353. case employee.FieldServiceCount:
  18354. return m.AddedServiceCount()
  18355. case employee.FieldAchievementCount:
  18356. return m.AddedAchievementCount()
  18357. case employee.FieldOrganizationID:
  18358. return m.AddedOrganizationID()
  18359. case employee.FieldCategoryID:
  18360. return m.AddedCategoryID()
  18361. case employee.FieldIsVip:
  18362. return m.AddedIsVip()
  18363. }
  18364. return nil, false
  18365. }
  18366. // AddField adds the value to the field with the given name. It returns an error if
  18367. // the field is not defined in the schema, or if the type mismatched the field
  18368. // type.
  18369. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  18370. switch name {
  18371. case employee.FieldHireCount:
  18372. v, ok := value.(int)
  18373. if !ok {
  18374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18375. }
  18376. m.AddHireCount(v)
  18377. return nil
  18378. case employee.FieldServiceCount:
  18379. v, ok := value.(int)
  18380. if !ok {
  18381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18382. }
  18383. m.AddServiceCount(v)
  18384. return nil
  18385. case employee.FieldAchievementCount:
  18386. v, ok := value.(int)
  18387. if !ok {
  18388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18389. }
  18390. m.AddAchievementCount(v)
  18391. return nil
  18392. case employee.FieldOrganizationID:
  18393. v, ok := value.(int64)
  18394. if !ok {
  18395. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18396. }
  18397. m.AddOrganizationID(v)
  18398. return nil
  18399. case employee.FieldCategoryID:
  18400. v, ok := value.(int64)
  18401. if !ok {
  18402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18403. }
  18404. m.AddCategoryID(v)
  18405. return nil
  18406. case employee.FieldIsVip:
  18407. v, ok := value.(int)
  18408. if !ok {
  18409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18410. }
  18411. m.AddIsVip(v)
  18412. return nil
  18413. }
  18414. return fmt.Errorf("unknown Employee numeric field %s", name)
  18415. }
  18416. // ClearedFields returns all nullable fields that were cleared during this
  18417. // mutation.
  18418. func (m *EmployeeMutation) ClearedFields() []string {
  18419. var fields []string
  18420. if m.FieldCleared(employee.FieldDeletedAt) {
  18421. fields = append(fields, employee.FieldDeletedAt)
  18422. }
  18423. if m.FieldCleared(employee.FieldAiInfo) {
  18424. fields = append(fields, employee.FieldAiInfo)
  18425. }
  18426. return fields
  18427. }
  18428. // FieldCleared returns a boolean indicating if a field with the given name was
  18429. // cleared in this mutation.
  18430. func (m *EmployeeMutation) FieldCleared(name string) bool {
  18431. _, ok := m.clearedFields[name]
  18432. return ok
  18433. }
  18434. // ClearField clears the value of the field with the given name. It returns an
  18435. // error if the field is not defined in the schema.
  18436. func (m *EmployeeMutation) ClearField(name string) error {
  18437. switch name {
  18438. case employee.FieldDeletedAt:
  18439. m.ClearDeletedAt()
  18440. return nil
  18441. case employee.FieldAiInfo:
  18442. m.ClearAiInfo()
  18443. return nil
  18444. }
  18445. return fmt.Errorf("unknown Employee nullable field %s", name)
  18446. }
  18447. // ResetField resets all changes in the mutation for the field with the given name.
  18448. // It returns an error if the field is not defined in the schema.
  18449. func (m *EmployeeMutation) ResetField(name string) error {
  18450. switch name {
  18451. case employee.FieldCreatedAt:
  18452. m.ResetCreatedAt()
  18453. return nil
  18454. case employee.FieldUpdatedAt:
  18455. m.ResetUpdatedAt()
  18456. return nil
  18457. case employee.FieldDeletedAt:
  18458. m.ResetDeletedAt()
  18459. return nil
  18460. case employee.FieldTitle:
  18461. m.ResetTitle()
  18462. return nil
  18463. case employee.FieldAvatar:
  18464. m.ResetAvatar()
  18465. return nil
  18466. case employee.FieldTags:
  18467. m.ResetTags()
  18468. return nil
  18469. case employee.FieldHireCount:
  18470. m.ResetHireCount()
  18471. return nil
  18472. case employee.FieldServiceCount:
  18473. m.ResetServiceCount()
  18474. return nil
  18475. case employee.FieldAchievementCount:
  18476. m.ResetAchievementCount()
  18477. return nil
  18478. case employee.FieldIntro:
  18479. m.ResetIntro()
  18480. return nil
  18481. case employee.FieldEstimate:
  18482. m.ResetEstimate()
  18483. return nil
  18484. case employee.FieldSkill:
  18485. m.ResetSkill()
  18486. return nil
  18487. case employee.FieldAbilityType:
  18488. m.ResetAbilityType()
  18489. return nil
  18490. case employee.FieldScene:
  18491. m.ResetScene()
  18492. return nil
  18493. case employee.FieldSwitchIn:
  18494. m.ResetSwitchIn()
  18495. return nil
  18496. case employee.FieldVideoURL:
  18497. m.ResetVideoURL()
  18498. return nil
  18499. case employee.FieldOrganizationID:
  18500. m.ResetOrganizationID()
  18501. return nil
  18502. case employee.FieldCategoryID:
  18503. m.ResetCategoryID()
  18504. return nil
  18505. case employee.FieldAPIBase:
  18506. m.ResetAPIBase()
  18507. return nil
  18508. case employee.FieldAPIKey:
  18509. m.ResetAPIKey()
  18510. return nil
  18511. case employee.FieldAiInfo:
  18512. m.ResetAiInfo()
  18513. return nil
  18514. case employee.FieldIsVip:
  18515. m.ResetIsVip()
  18516. return nil
  18517. case employee.FieldChatURL:
  18518. m.ResetChatURL()
  18519. return nil
  18520. }
  18521. return fmt.Errorf("unknown Employee field %s", name)
  18522. }
  18523. // AddedEdges returns all edge names that were set/added in this mutation.
  18524. func (m *EmployeeMutation) AddedEdges() []string {
  18525. edges := make([]string, 0, 2)
  18526. if m.em_work_experiences != nil {
  18527. edges = append(edges, employee.EdgeEmWorkExperiences)
  18528. }
  18529. if m.em_tutorial != nil {
  18530. edges = append(edges, employee.EdgeEmTutorial)
  18531. }
  18532. return edges
  18533. }
  18534. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18535. // name in this mutation.
  18536. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  18537. switch name {
  18538. case employee.EdgeEmWorkExperiences:
  18539. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  18540. for id := range m.em_work_experiences {
  18541. ids = append(ids, id)
  18542. }
  18543. return ids
  18544. case employee.EdgeEmTutorial:
  18545. ids := make([]ent.Value, 0, len(m.em_tutorial))
  18546. for id := range m.em_tutorial {
  18547. ids = append(ids, id)
  18548. }
  18549. return ids
  18550. }
  18551. return nil
  18552. }
  18553. // RemovedEdges returns all edge names that were removed in this mutation.
  18554. func (m *EmployeeMutation) RemovedEdges() []string {
  18555. edges := make([]string, 0, 2)
  18556. if m.removedem_work_experiences != nil {
  18557. edges = append(edges, employee.EdgeEmWorkExperiences)
  18558. }
  18559. if m.removedem_tutorial != nil {
  18560. edges = append(edges, employee.EdgeEmTutorial)
  18561. }
  18562. return edges
  18563. }
  18564. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18565. // the given name in this mutation.
  18566. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  18567. switch name {
  18568. case employee.EdgeEmWorkExperiences:
  18569. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  18570. for id := range m.removedem_work_experiences {
  18571. ids = append(ids, id)
  18572. }
  18573. return ids
  18574. case employee.EdgeEmTutorial:
  18575. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  18576. for id := range m.removedem_tutorial {
  18577. ids = append(ids, id)
  18578. }
  18579. return ids
  18580. }
  18581. return nil
  18582. }
  18583. // ClearedEdges returns all edge names that were cleared in this mutation.
  18584. func (m *EmployeeMutation) ClearedEdges() []string {
  18585. edges := make([]string, 0, 2)
  18586. if m.clearedem_work_experiences {
  18587. edges = append(edges, employee.EdgeEmWorkExperiences)
  18588. }
  18589. if m.clearedem_tutorial {
  18590. edges = append(edges, employee.EdgeEmTutorial)
  18591. }
  18592. return edges
  18593. }
  18594. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18595. // was cleared in this mutation.
  18596. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  18597. switch name {
  18598. case employee.EdgeEmWorkExperiences:
  18599. return m.clearedem_work_experiences
  18600. case employee.EdgeEmTutorial:
  18601. return m.clearedem_tutorial
  18602. }
  18603. return false
  18604. }
  18605. // ClearEdge clears the value of the edge with the given name. It returns an error
  18606. // if that edge is not defined in the schema.
  18607. func (m *EmployeeMutation) ClearEdge(name string) error {
  18608. switch name {
  18609. }
  18610. return fmt.Errorf("unknown Employee unique edge %s", name)
  18611. }
  18612. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18613. // It returns an error if the edge is not defined in the schema.
  18614. func (m *EmployeeMutation) ResetEdge(name string) error {
  18615. switch name {
  18616. case employee.EdgeEmWorkExperiences:
  18617. m.ResetEmWorkExperiences()
  18618. return nil
  18619. case employee.EdgeEmTutorial:
  18620. m.ResetEmTutorial()
  18621. return nil
  18622. }
  18623. return fmt.Errorf("unknown Employee edge %s", name)
  18624. }
  18625. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  18626. type EmployeeConfigMutation struct {
  18627. config
  18628. op Op
  18629. typ string
  18630. id *uint64
  18631. created_at *time.Time
  18632. updated_at *time.Time
  18633. deleted_at *time.Time
  18634. stype *string
  18635. title *string
  18636. photo *string
  18637. organization_id *uint64
  18638. addorganization_id *int64
  18639. clearedFields map[string]struct{}
  18640. done bool
  18641. oldValue func(context.Context) (*EmployeeConfig, error)
  18642. predicates []predicate.EmployeeConfig
  18643. }
  18644. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  18645. // employeeconfigOption allows management of the mutation configuration using functional options.
  18646. type employeeconfigOption func(*EmployeeConfigMutation)
  18647. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  18648. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  18649. m := &EmployeeConfigMutation{
  18650. config: c,
  18651. op: op,
  18652. typ: TypeEmployeeConfig,
  18653. clearedFields: make(map[string]struct{}),
  18654. }
  18655. for _, opt := range opts {
  18656. opt(m)
  18657. }
  18658. return m
  18659. }
  18660. // withEmployeeConfigID sets the ID field of the mutation.
  18661. func withEmployeeConfigID(id uint64) employeeconfigOption {
  18662. return func(m *EmployeeConfigMutation) {
  18663. var (
  18664. err error
  18665. once sync.Once
  18666. value *EmployeeConfig
  18667. )
  18668. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  18669. once.Do(func() {
  18670. if m.done {
  18671. err = errors.New("querying old values post mutation is not allowed")
  18672. } else {
  18673. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  18674. }
  18675. })
  18676. return value, err
  18677. }
  18678. m.id = &id
  18679. }
  18680. }
  18681. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  18682. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  18683. return func(m *EmployeeConfigMutation) {
  18684. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  18685. return node, nil
  18686. }
  18687. m.id = &node.ID
  18688. }
  18689. }
  18690. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18691. // executed in a transaction (ent.Tx), a transactional client is returned.
  18692. func (m EmployeeConfigMutation) Client() *Client {
  18693. client := &Client{config: m.config}
  18694. client.init()
  18695. return client
  18696. }
  18697. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18698. // it returns an error otherwise.
  18699. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  18700. if _, ok := m.driver.(*txDriver); !ok {
  18701. return nil, errors.New("ent: mutation is not running in a transaction")
  18702. }
  18703. tx := &Tx{config: m.config}
  18704. tx.init()
  18705. return tx, nil
  18706. }
  18707. // SetID sets the value of the id field. Note that this
  18708. // operation is only accepted on creation of EmployeeConfig entities.
  18709. func (m *EmployeeConfigMutation) SetID(id uint64) {
  18710. m.id = &id
  18711. }
  18712. // ID returns the ID value in the mutation. Note that the ID is only available
  18713. // if it was provided to the builder or after it was returned from the database.
  18714. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  18715. if m.id == nil {
  18716. return
  18717. }
  18718. return *m.id, true
  18719. }
  18720. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18721. // That means, if the mutation is applied within a transaction with an isolation level such
  18722. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18723. // or updated by the mutation.
  18724. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  18725. switch {
  18726. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18727. id, exists := m.ID()
  18728. if exists {
  18729. return []uint64{id}, nil
  18730. }
  18731. fallthrough
  18732. case m.op.Is(OpUpdate | OpDelete):
  18733. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  18734. default:
  18735. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18736. }
  18737. }
  18738. // SetCreatedAt sets the "created_at" field.
  18739. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  18740. m.created_at = &t
  18741. }
  18742. // CreatedAt returns the value of the "created_at" field in the mutation.
  18743. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  18744. v := m.created_at
  18745. if v == nil {
  18746. return
  18747. }
  18748. return *v, true
  18749. }
  18750. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  18751. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  18752. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18753. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18754. if !m.op.Is(OpUpdateOne) {
  18755. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18756. }
  18757. if m.id == nil || m.oldValue == nil {
  18758. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18759. }
  18760. oldValue, err := m.oldValue(ctx)
  18761. if err != nil {
  18762. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18763. }
  18764. return oldValue.CreatedAt, nil
  18765. }
  18766. // ResetCreatedAt resets all changes to the "created_at" field.
  18767. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  18768. m.created_at = nil
  18769. }
  18770. // SetUpdatedAt sets the "updated_at" field.
  18771. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  18772. m.updated_at = &t
  18773. }
  18774. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18775. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  18776. v := m.updated_at
  18777. if v == nil {
  18778. return
  18779. }
  18780. return *v, true
  18781. }
  18782. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  18783. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  18784. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18785. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18786. if !m.op.Is(OpUpdateOne) {
  18787. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18788. }
  18789. if m.id == nil || m.oldValue == nil {
  18790. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18791. }
  18792. oldValue, err := m.oldValue(ctx)
  18793. if err != nil {
  18794. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18795. }
  18796. return oldValue.UpdatedAt, nil
  18797. }
  18798. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18799. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  18800. m.updated_at = nil
  18801. }
  18802. // SetDeletedAt sets the "deleted_at" field.
  18803. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  18804. m.deleted_at = &t
  18805. }
  18806. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18807. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  18808. v := m.deleted_at
  18809. if v == nil {
  18810. return
  18811. }
  18812. return *v, true
  18813. }
  18814. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  18815. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  18816. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18817. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18818. if !m.op.Is(OpUpdateOne) {
  18819. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18820. }
  18821. if m.id == nil || m.oldValue == nil {
  18822. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18823. }
  18824. oldValue, err := m.oldValue(ctx)
  18825. if err != nil {
  18826. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18827. }
  18828. return oldValue.DeletedAt, nil
  18829. }
  18830. // ClearDeletedAt clears the value of the "deleted_at" field.
  18831. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  18832. m.deleted_at = nil
  18833. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  18834. }
  18835. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18836. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  18837. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  18838. return ok
  18839. }
  18840. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18841. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  18842. m.deleted_at = nil
  18843. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  18844. }
  18845. // SetStype sets the "stype" field.
  18846. func (m *EmployeeConfigMutation) SetStype(s string) {
  18847. m.stype = &s
  18848. }
  18849. // Stype returns the value of the "stype" field in the mutation.
  18850. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  18851. v := m.stype
  18852. if v == nil {
  18853. return
  18854. }
  18855. return *v, true
  18856. }
  18857. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  18858. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  18859. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18860. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  18861. if !m.op.Is(OpUpdateOne) {
  18862. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  18863. }
  18864. if m.id == nil || m.oldValue == nil {
  18865. return v, errors.New("OldStype requires an ID field in the mutation")
  18866. }
  18867. oldValue, err := m.oldValue(ctx)
  18868. if err != nil {
  18869. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  18870. }
  18871. return oldValue.Stype, nil
  18872. }
  18873. // ResetStype resets all changes to the "stype" field.
  18874. func (m *EmployeeConfigMutation) ResetStype() {
  18875. m.stype = nil
  18876. }
  18877. // SetTitle sets the "title" field.
  18878. func (m *EmployeeConfigMutation) SetTitle(s string) {
  18879. m.title = &s
  18880. }
  18881. // Title returns the value of the "title" field in the mutation.
  18882. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  18883. v := m.title
  18884. if v == nil {
  18885. return
  18886. }
  18887. return *v, true
  18888. }
  18889. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  18890. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  18891. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18892. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  18893. if !m.op.Is(OpUpdateOne) {
  18894. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  18895. }
  18896. if m.id == nil || m.oldValue == nil {
  18897. return v, errors.New("OldTitle requires an ID field in the mutation")
  18898. }
  18899. oldValue, err := m.oldValue(ctx)
  18900. if err != nil {
  18901. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  18902. }
  18903. return oldValue.Title, nil
  18904. }
  18905. // ResetTitle resets all changes to the "title" field.
  18906. func (m *EmployeeConfigMutation) ResetTitle() {
  18907. m.title = nil
  18908. }
  18909. // SetPhoto sets the "photo" field.
  18910. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  18911. m.photo = &s
  18912. }
  18913. // Photo returns the value of the "photo" field in the mutation.
  18914. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  18915. v := m.photo
  18916. if v == nil {
  18917. return
  18918. }
  18919. return *v, true
  18920. }
  18921. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  18922. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  18923. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18924. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  18925. if !m.op.Is(OpUpdateOne) {
  18926. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  18927. }
  18928. if m.id == nil || m.oldValue == nil {
  18929. return v, errors.New("OldPhoto requires an ID field in the mutation")
  18930. }
  18931. oldValue, err := m.oldValue(ctx)
  18932. if err != nil {
  18933. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  18934. }
  18935. return oldValue.Photo, nil
  18936. }
  18937. // ResetPhoto resets all changes to the "photo" field.
  18938. func (m *EmployeeConfigMutation) ResetPhoto() {
  18939. m.photo = nil
  18940. }
  18941. // SetOrganizationID sets the "organization_id" field.
  18942. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  18943. m.organization_id = &u
  18944. m.addorganization_id = nil
  18945. }
  18946. // OrganizationID returns the value of the "organization_id" field in the mutation.
  18947. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  18948. v := m.organization_id
  18949. if v == nil {
  18950. return
  18951. }
  18952. return *v, true
  18953. }
  18954. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  18955. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  18956. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18957. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  18958. if !m.op.Is(OpUpdateOne) {
  18959. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  18960. }
  18961. if m.id == nil || m.oldValue == nil {
  18962. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  18963. }
  18964. oldValue, err := m.oldValue(ctx)
  18965. if err != nil {
  18966. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  18967. }
  18968. return oldValue.OrganizationID, nil
  18969. }
  18970. // AddOrganizationID adds u to the "organization_id" field.
  18971. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  18972. if m.addorganization_id != nil {
  18973. *m.addorganization_id += u
  18974. } else {
  18975. m.addorganization_id = &u
  18976. }
  18977. }
  18978. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  18979. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  18980. v := m.addorganization_id
  18981. if v == nil {
  18982. return
  18983. }
  18984. return *v, true
  18985. }
  18986. // ClearOrganizationID clears the value of the "organization_id" field.
  18987. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  18988. m.organization_id = nil
  18989. m.addorganization_id = nil
  18990. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  18991. }
  18992. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  18993. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  18994. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  18995. return ok
  18996. }
  18997. // ResetOrganizationID resets all changes to the "organization_id" field.
  18998. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  18999. m.organization_id = nil
  19000. m.addorganization_id = nil
  19001. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  19002. }
  19003. // Where appends a list predicates to the EmployeeConfigMutation builder.
  19004. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  19005. m.predicates = append(m.predicates, ps...)
  19006. }
  19007. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  19008. // users can use type-assertion to append predicates that do not depend on any generated package.
  19009. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  19010. p := make([]predicate.EmployeeConfig, len(ps))
  19011. for i := range ps {
  19012. p[i] = ps[i]
  19013. }
  19014. m.Where(p...)
  19015. }
  19016. // Op returns the operation name.
  19017. func (m *EmployeeConfigMutation) Op() Op {
  19018. return m.op
  19019. }
  19020. // SetOp allows setting the mutation operation.
  19021. func (m *EmployeeConfigMutation) SetOp(op Op) {
  19022. m.op = op
  19023. }
  19024. // Type returns the node type of this mutation (EmployeeConfig).
  19025. func (m *EmployeeConfigMutation) Type() string {
  19026. return m.typ
  19027. }
  19028. // Fields returns all fields that were changed during this mutation. Note that in
  19029. // order to get all numeric fields that were incremented/decremented, call
  19030. // AddedFields().
  19031. func (m *EmployeeConfigMutation) Fields() []string {
  19032. fields := make([]string, 0, 7)
  19033. if m.created_at != nil {
  19034. fields = append(fields, employeeconfig.FieldCreatedAt)
  19035. }
  19036. if m.updated_at != nil {
  19037. fields = append(fields, employeeconfig.FieldUpdatedAt)
  19038. }
  19039. if m.deleted_at != nil {
  19040. fields = append(fields, employeeconfig.FieldDeletedAt)
  19041. }
  19042. if m.stype != nil {
  19043. fields = append(fields, employeeconfig.FieldStype)
  19044. }
  19045. if m.title != nil {
  19046. fields = append(fields, employeeconfig.FieldTitle)
  19047. }
  19048. if m.photo != nil {
  19049. fields = append(fields, employeeconfig.FieldPhoto)
  19050. }
  19051. if m.organization_id != nil {
  19052. fields = append(fields, employeeconfig.FieldOrganizationID)
  19053. }
  19054. return fields
  19055. }
  19056. // Field returns the value of a field with the given name. The second boolean
  19057. // return value indicates that this field was not set, or was not defined in the
  19058. // schema.
  19059. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  19060. switch name {
  19061. case employeeconfig.FieldCreatedAt:
  19062. return m.CreatedAt()
  19063. case employeeconfig.FieldUpdatedAt:
  19064. return m.UpdatedAt()
  19065. case employeeconfig.FieldDeletedAt:
  19066. return m.DeletedAt()
  19067. case employeeconfig.FieldStype:
  19068. return m.Stype()
  19069. case employeeconfig.FieldTitle:
  19070. return m.Title()
  19071. case employeeconfig.FieldPhoto:
  19072. return m.Photo()
  19073. case employeeconfig.FieldOrganizationID:
  19074. return m.OrganizationID()
  19075. }
  19076. return nil, false
  19077. }
  19078. // OldField returns the old value of the field from the database. An error is
  19079. // returned if the mutation operation is not UpdateOne, or the query to the
  19080. // database failed.
  19081. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19082. switch name {
  19083. case employeeconfig.FieldCreatedAt:
  19084. return m.OldCreatedAt(ctx)
  19085. case employeeconfig.FieldUpdatedAt:
  19086. return m.OldUpdatedAt(ctx)
  19087. case employeeconfig.FieldDeletedAt:
  19088. return m.OldDeletedAt(ctx)
  19089. case employeeconfig.FieldStype:
  19090. return m.OldStype(ctx)
  19091. case employeeconfig.FieldTitle:
  19092. return m.OldTitle(ctx)
  19093. case employeeconfig.FieldPhoto:
  19094. return m.OldPhoto(ctx)
  19095. case employeeconfig.FieldOrganizationID:
  19096. return m.OldOrganizationID(ctx)
  19097. }
  19098. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  19099. }
  19100. // SetField sets the value of a field with the given name. It returns an error if
  19101. // the field is not defined in the schema, or if the type mismatched the field
  19102. // type.
  19103. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  19104. switch name {
  19105. case employeeconfig.FieldCreatedAt:
  19106. v, ok := value.(time.Time)
  19107. if !ok {
  19108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19109. }
  19110. m.SetCreatedAt(v)
  19111. return nil
  19112. case employeeconfig.FieldUpdatedAt:
  19113. v, ok := value.(time.Time)
  19114. if !ok {
  19115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19116. }
  19117. m.SetUpdatedAt(v)
  19118. return nil
  19119. case employeeconfig.FieldDeletedAt:
  19120. v, ok := value.(time.Time)
  19121. if !ok {
  19122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19123. }
  19124. m.SetDeletedAt(v)
  19125. return nil
  19126. case employeeconfig.FieldStype:
  19127. v, ok := value.(string)
  19128. if !ok {
  19129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19130. }
  19131. m.SetStype(v)
  19132. return nil
  19133. case employeeconfig.FieldTitle:
  19134. v, ok := value.(string)
  19135. if !ok {
  19136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19137. }
  19138. m.SetTitle(v)
  19139. return nil
  19140. case employeeconfig.FieldPhoto:
  19141. v, ok := value.(string)
  19142. if !ok {
  19143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19144. }
  19145. m.SetPhoto(v)
  19146. return nil
  19147. case employeeconfig.FieldOrganizationID:
  19148. v, ok := value.(uint64)
  19149. if !ok {
  19150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19151. }
  19152. m.SetOrganizationID(v)
  19153. return nil
  19154. }
  19155. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  19156. }
  19157. // AddedFields returns all numeric fields that were incremented/decremented during
  19158. // this mutation.
  19159. func (m *EmployeeConfigMutation) AddedFields() []string {
  19160. var fields []string
  19161. if m.addorganization_id != nil {
  19162. fields = append(fields, employeeconfig.FieldOrganizationID)
  19163. }
  19164. return fields
  19165. }
  19166. // AddedField returns the numeric value that was incremented/decremented on a field
  19167. // with the given name. The second boolean return value indicates that this field
  19168. // was not set, or was not defined in the schema.
  19169. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  19170. switch name {
  19171. case employeeconfig.FieldOrganizationID:
  19172. return m.AddedOrganizationID()
  19173. }
  19174. return nil, false
  19175. }
  19176. // AddField adds the value to the field with the given name. It returns an error if
  19177. // the field is not defined in the schema, or if the type mismatched the field
  19178. // type.
  19179. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  19180. switch name {
  19181. case employeeconfig.FieldOrganizationID:
  19182. v, ok := value.(int64)
  19183. if !ok {
  19184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19185. }
  19186. m.AddOrganizationID(v)
  19187. return nil
  19188. }
  19189. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  19190. }
  19191. // ClearedFields returns all nullable fields that were cleared during this
  19192. // mutation.
  19193. func (m *EmployeeConfigMutation) ClearedFields() []string {
  19194. var fields []string
  19195. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  19196. fields = append(fields, employeeconfig.FieldDeletedAt)
  19197. }
  19198. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  19199. fields = append(fields, employeeconfig.FieldOrganizationID)
  19200. }
  19201. return fields
  19202. }
  19203. // FieldCleared returns a boolean indicating if a field with the given name was
  19204. // cleared in this mutation.
  19205. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  19206. _, ok := m.clearedFields[name]
  19207. return ok
  19208. }
  19209. // ClearField clears the value of the field with the given name. It returns an
  19210. // error if the field is not defined in the schema.
  19211. func (m *EmployeeConfigMutation) ClearField(name string) error {
  19212. switch name {
  19213. case employeeconfig.FieldDeletedAt:
  19214. m.ClearDeletedAt()
  19215. return nil
  19216. case employeeconfig.FieldOrganizationID:
  19217. m.ClearOrganizationID()
  19218. return nil
  19219. }
  19220. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  19221. }
  19222. // ResetField resets all changes in the mutation for the field with the given name.
  19223. // It returns an error if the field is not defined in the schema.
  19224. func (m *EmployeeConfigMutation) ResetField(name string) error {
  19225. switch name {
  19226. case employeeconfig.FieldCreatedAt:
  19227. m.ResetCreatedAt()
  19228. return nil
  19229. case employeeconfig.FieldUpdatedAt:
  19230. m.ResetUpdatedAt()
  19231. return nil
  19232. case employeeconfig.FieldDeletedAt:
  19233. m.ResetDeletedAt()
  19234. return nil
  19235. case employeeconfig.FieldStype:
  19236. m.ResetStype()
  19237. return nil
  19238. case employeeconfig.FieldTitle:
  19239. m.ResetTitle()
  19240. return nil
  19241. case employeeconfig.FieldPhoto:
  19242. m.ResetPhoto()
  19243. return nil
  19244. case employeeconfig.FieldOrganizationID:
  19245. m.ResetOrganizationID()
  19246. return nil
  19247. }
  19248. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  19249. }
  19250. // AddedEdges returns all edge names that were set/added in this mutation.
  19251. func (m *EmployeeConfigMutation) AddedEdges() []string {
  19252. edges := make([]string, 0, 0)
  19253. return edges
  19254. }
  19255. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19256. // name in this mutation.
  19257. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  19258. return nil
  19259. }
  19260. // RemovedEdges returns all edge names that were removed in this mutation.
  19261. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  19262. edges := make([]string, 0, 0)
  19263. return edges
  19264. }
  19265. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19266. // the given name in this mutation.
  19267. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  19268. return nil
  19269. }
  19270. // ClearedEdges returns all edge names that were cleared in this mutation.
  19271. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  19272. edges := make([]string, 0, 0)
  19273. return edges
  19274. }
  19275. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19276. // was cleared in this mutation.
  19277. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  19278. return false
  19279. }
  19280. // ClearEdge clears the value of the edge with the given name. It returns an error
  19281. // if that edge is not defined in the schema.
  19282. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  19283. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  19284. }
  19285. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19286. // It returns an error if the edge is not defined in the schema.
  19287. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  19288. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  19289. }
  19290. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  19291. type LabelMutation struct {
  19292. config
  19293. op Op
  19294. typ string
  19295. id *uint64
  19296. created_at *time.Time
  19297. updated_at *time.Time
  19298. status *uint8
  19299. addstatus *int8
  19300. _type *int
  19301. add_type *int
  19302. name *string
  19303. from *int
  19304. addfrom *int
  19305. mode *int
  19306. addmode *int
  19307. conditions *string
  19308. organization_id *uint64
  19309. addorganization_id *int64
  19310. clearedFields map[string]struct{}
  19311. label_relationships map[uint64]struct{}
  19312. removedlabel_relationships map[uint64]struct{}
  19313. clearedlabel_relationships bool
  19314. done bool
  19315. oldValue func(context.Context) (*Label, error)
  19316. predicates []predicate.Label
  19317. }
  19318. var _ ent.Mutation = (*LabelMutation)(nil)
  19319. // labelOption allows management of the mutation configuration using functional options.
  19320. type labelOption func(*LabelMutation)
  19321. // newLabelMutation creates new mutation for the Label entity.
  19322. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  19323. m := &LabelMutation{
  19324. config: c,
  19325. op: op,
  19326. typ: TypeLabel,
  19327. clearedFields: make(map[string]struct{}),
  19328. }
  19329. for _, opt := range opts {
  19330. opt(m)
  19331. }
  19332. return m
  19333. }
  19334. // withLabelID sets the ID field of the mutation.
  19335. func withLabelID(id uint64) labelOption {
  19336. return func(m *LabelMutation) {
  19337. var (
  19338. err error
  19339. once sync.Once
  19340. value *Label
  19341. )
  19342. m.oldValue = func(ctx context.Context) (*Label, error) {
  19343. once.Do(func() {
  19344. if m.done {
  19345. err = errors.New("querying old values post mutation is not allowed")
  19346. } else {
  19347. value, err = m.Client().Label.Get(ctx, id)
  19348. }
  19349. })
  19350. return value, err
  19351. }
  19352. m.id = &id
  19353. }
  19354. }
  19355. // withLabel sets the old Label of the mutation.
  19356. func withLabel(node *Label) labelOption {
  19357. return func(m *LabelMutation) {
  19358. m.oldValue = func(context.Context) (*Label, error) {
  19359. return node, nil
  19360. }
  19361. m.id = &node.ID
  19362. }
  19363. }
  19364. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19365. // executed in a transaction (ent.Tx), a transactional client is returned.
  19366. func (m LabelMutation) Client() *Client {
  19367. client := &Client{config: m.config}
  19368. client.init()
  19369. return client
  19370. }
  19371. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19372. // it returns an error otherwise.
  19373. func (m LabelMutation) Tx() (*Tx, error) {
  19374. if _, ok := m.driver.(*txDriver); !ok {
  19375. return nil, errors.New("ent: mutation is not running in a transaction")
  19376. }
  19377. tx := &Tx{config: m.config}
  19378. tx.init()
  19379. return tx, nil
  19380. }
  19381. // SetID sets the value of the id field. Note that this
  19382. // operation is only accepted on creation of Label entities.
  19383. func (m *LabelMutation) SetID(id uint64) {
  19384. m.id = &id
  19385. }
  19386. // ID returns the ID value in the mutation. Note that the ID is only available
  19387. // if it was provided to the builder or after it was returned from the database.
  19388. func (m *LabelMutation) ID() (id uint64, exists bool) {
  19389. if m.id == nil {
  19390. return
  19391. }
  19392. return *m.id, true
  19393. }
  19394. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19395. // That means, if the mutation is applied within a transaction with an isolation level such
  19396. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19397. // or updated by the mutation.
  19398. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  19399. switch {
  19400. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19401. id, exists := m.ID()
  19402. if exists {
  19403. return []uint64{id}, nil
  19404. }
  19405. fallthrough
  19406. case m.op.Is(OpUpdate | OpDelete):
  19407. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  19408. default:
  19409. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19410. }
  19411. }
  19412. // SetCreatedAt sets the "created_at" field.
  19413. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  19414. m.created_at = &t
  19415. }
  19416. // CreatedAt returns the value of the "created_at" field in the mutation.
  19417. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  19418. v := m.created_at
  19419. if v == nil {
  19420. return
  19421. }
  19422. return *v, true
  19423. }
  19424. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  19425. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19426. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19427. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19428. if !m.op.Is(OpUpdateOne) {
  19429. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19430. }
  19431. if m.id == nil || m.oldValue == nil {
  19432. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19433. }
  19434. oldValue, err := m.oldValue(ctx)
  19435. if err != nil {
  19436. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19437. }
  19438. return oldValue.CreatedAt, nil
  19439. }
  19440. // ResetCreatedAt resets all changes to the "created_at" field.
  19441. func (m *LabelMutation) ResetCreatedAt() {
  19442. m.created_at = nil
  19443. }
  19444. // SetUpdatedAt sets the "updated_at" field.
  19445. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  19446. m.updated_at = &t
  19447. }
  19448. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19449. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  19450. v := m.updated_at
  19451. if v == nil {
  19452. return
  19453. }
  19454. return *v, true
  19455. }
  19456. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  19457. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19458. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19459. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19460. if !m.op.Is(OpUpdateOne) {
  19461. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19462. }
  19463. if m.id == nil || m.oldValue == nil {
  19464. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19465. }
  19466. oldValue, err := m.oldValue(ctx)
  19467. if err != nil {
  19468. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19469. }
  19470. return oldValue.UpdatedAt, nil
  19471. }
  19472. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19473. func (m *LabelMutation) ResetUpdatedAt() {
  19474. m.updated_at = nil
  19475. }
  19476. // SetStatus sets the "status" field.
  19477. func (m *LabelMutation) SetStatus(u uint8) {
  19478. m.status = &u
  19479. m.addstatus = nil
  19480. }
  19481. // Status returns the value of the "status" field in the mutation.
  19482. func (m *LabelMutation) Status() (r uint8, exists bool) {
  19483. v := m.status
  19484. if v == nil {
  19485. return
  19486. }
  19487. return *v, true
  19488. }
  19489. // OldStatus returns the old "status" field's value of the Label entity.
  19490. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19491. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19492. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  19493. if !m.op.Is(OpUpdateOne) {
  19494. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19495. }
  19496. if m.id == nil || m.oldValue == nil {
  19497. return v, errors.New("OldStatus requires an ID field in the mutation")
  19498. }
  19499. oldValue, err := m.oldValue(ctx)
  19500. if err != nil {
  19501. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19502. }
  19503. return oldValue.Status, nil
  19504. }
  19505. // AddStatus adds u to the "status" field.
  19506. func (m *LabelMutation) AddStatus(u int8) {
  19507. if m.addstatus != nil {
  19508. *m.addstatus += u
  19509. } else {
  19510. m.addstatus = &u
  19511. }
  19512. }
  19513. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19514. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  19515. v := m.addstatus
  19516. if v == nil {
  19517. return
  19518. }
  19519. return *v, true
  19520. }
  19521. // ClearStatus clears the value of the "status" field.
  19522. func (m *LabelMutation) ClearStatus() {
  19523. m.status = nil
  19524. m.addstatus = nil
  19525. m.clearedFields[label.FieldStatus] = struct{}{}
  19526. }
  19527. // StatusCleared returns if the "status" field was cleared in this mutation.
  19528. func (m *LabelMutation) StatusCleared() bool {
  19529. _, ok := m.clearedFields[label.FieldStatus]
  19530. return ok
  19531. }
  19532. // ResetStatus resets all changes to the "status" field.
  19533. func (m *LabelMutation) ResetStatus() {
  19534. m.status = nil
  19535. m.addstatus = nil
  19536. delete(m.clearedFields, label.FieldStatus)
  19537. }
  19538. // SetType sets the "type" field.
  19539. func (m *LabelMutation) SetType(i int) {
  19540. m._type = &i
  19541. m.add_type = nil
  19542. }
  19543. // GetType returns the value of the "type" field in the mutation.
  19544. func (m *LabelMutation) GetType() (r int, exists bool) {
  19545. v := m._type
  19546. if v == nil {
  19547. return
  19548. }
  19549. return *v, true
  19550. }
  19551. // OldType returns the old "type" field's value of the Label entity.
  19552. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19553. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19554. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  19555. if !m.op.Is(OpUpdateOne) {
  19556. return v, errors.New("OldType is only allowed on UpdateOne operations")
  19557. }
  19558. if m.id == nil || m.oldValue == nil {
  19559. return v, errors.New("OldType requires an ID field in the mutation")
  19560. }
  19561. oldValue, err := m.oldValue(ctx)
  19562. if err != nil {
  19563. return v, fmt.Errorf("querying old value for OldType: %w", err)
  19564. }
  19565. return oldValue.Type, nil
  19566. }
  19567. // AddType adds i to the "type" field.
  19568. func (m *LabelMutation) AddType(i int) {
  19569. if m.add_type != nil {
  19570. *m.add_type += i
  19571. } else {
  19572. m.add_type = &i
  19573. }
  19574. }
  19575. // AddedType returns the value that was added to the "type" field in this mutation.
  19576. func (m *LabelMutation) AddedType() (r int, exists bool) {
  19577. v := m.add_type
  19578. if v == nil {
  19579. return
  19580. }
  19581. return *v, true
  19582. }
  19583. // ResetType resets all changes to the "type" field.
  19584. func (m *LabelMutation) ResetType() {
  19585. m._type = nil
  19586. m.add_type = nil
  19587. }
  19588. // SetName sets the "name" field.
  19589. func (m *LabelMutation) SetName(s string) {
  19590. m.name = &s
  19591. }
  19592. // Name returns the value of the "name" field in the mutation.
  19593. func (m *LabelMutation) Name() (r string, exists bool) {
  19594. v := m.name
  19595. if v == nil {
  19596. return
  19597. }
  19598. return *v, true
  19599. }
  19600. // OldName returns the old "name" field's value of the Label entity.
  19601. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19602. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19603. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  19604. if !m.op.Is(OpUpdateOne) {
  19605. return v, errors.New("OldName is only allowed on UpdateOne operations")
  19606. }
  19607. if m.id == nil || m.oldValue == nil {
  19608. return v, errors.New("OldName requires an ID field in the mutation")
  19609. }
  19610. oldValue, err := m.oldValue(ctx)
  19611. if err != nil {
  19612. return v, fmt.Errorf("querying old value for OldName: %w", err)
  19613. }
  19614. return oldValue.Name, nil
  19615. }
  19616. // ResetName resets all changes to the "name" field.
  19617. func (m *LabelMutation) ResetName() {
  19618. m.name = nil
  19619. }
  19620. // SetFrom sets the "from" field.
  19621. func (m *LabelMutation) SetFrom(i int) {
  19622. m.from = &i
  19623. m.addfrom = nil
  19624. }
  19625. // From returns the value of the "from" field in the mutation.
  19626. func (m *LabelMutation) From() (r int, exists bool) {
  19627. v := m.from
  19628. if v == nil {
  19629. return
  19630. }
  19631. return *v, true
  19632. }
  19633. // OldFrom returns the old "from" field's value of the Label entity.
  19634. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19636. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  19637. if !m.op.Is(OpUpdateOne) {
  19638. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  19639. }
  19640. if m.id == nil || m.oldValue == nil {
  19641. return v, errors.New("OldFrom requires an ID field in the mutation")
  19642. }
  19643. oldValue, err := m.oldValue(ctx)
  19644. if err != nil {
  19645. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  19646. }
  19647. return oldValue.From, nil
  19648. }
  19649. // AddFrom adds i to the "from" field.
  19650. func (m *LabelMutation) AddFrom(i int) {
  19651. if m.addfrom != nil {
  19652. *m.addfrom += i
  19653. } else {
  19654. m.addfrom = &i
  19655. }
  19656. }
  19657. // AddedFrom returns the value that was added to the "from" field in this mutation.
  19658. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  19659. v := m.addfrom
  19660. if v == nil {
  19661. return
  19662. }
  19663. return *v, true
  19664. }
  19665. // ResetFrom resets all changes to the "from" field.
  19666. func (m *LabelMutation) ResetFrom() {
  19667. m.from = nil
  19668. m.addfrom = nil
  19669. }
  19670. // SetMode sets the "mode" field.
  19671. func (m *LabelMutation) SetMode(i int) {
  19672. m.mode = &i
  19673. m.addmode = nil
  19674. }
  19675. // Mode returns the value of the "mode" field in the mutation.
  19676. func (m *LabelMutation) Mode() (r int, exists bool) {
  19677. v := m.mode
  19678. if v == nil {
  19679. return
  19680. }
  19681. return *v, true
  19682. }
  19683. // OldMode returns the old "mode" field's value of the Label entity.
  19684. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19685. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19686. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  19687. if !m.op.Is(OpUpdateOne) {
  19688. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  19689. }
  19690. if m.id == nil || m.oldValue == nil {
  19691. return v, errors.New("OldMode requires an ID field in the mutation")
  19692. }
  19693. oldValue, err := m.oldValue(ctx)
  19694. if err != nil {
  19695. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  19696. }
  19697. return oldValue.Mode, nil
  19698. }
  19699. // AddMode adds i to the "mode" field.
  19700. func (m *LabelMutation) AddMode(i int) {
  19701. if m.addmode != nil {
  19702. *m.addmode += i
  19703. } else {
  19704. m.addmode = &i
  19705. }
  19706. }
  19707. // AddedMode returns the value that was added to the "mode" field in this mutation.
  19708. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  19709. v := m.addmode
  19710. if v == nil {
  19711. return
  19712. }
  19713. return *v, true
  19714. }
  19715. // ResetMode resets all changes to the "mode" field.
  19716. func (m *LabelMutation) ResetMode() {
  19717. m.mode = nil
  19718. m.addmode = nil
  19719. }
  19720. // SetConditions sets the "conditions" field.
  19721. func (m *LabelMutation) SetConditions(s string) {
  19722. m.conditions = &s
  19723. }
  19724. // Conditions returns the value of the "conditions" field in the mutation.
  19725. func (m *LabelMutation) Conditions() (r string, exists bool) {
  19726. v := m.conditions
  19727. if v == nil {
  19728. return
  19729. }
  19730. return *v, true
  19731. }
  19732. // OldConditions returns the old "conditions" field's value of the Label entity.
  19733. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19734. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19735. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  19736. if !m.op.Is(OpUpdateOne) {
  19737. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  19738. }
  19739. if m.id == nil || m.oldValue == nil {
  19740. return v, errors.New("OldConditions requires an ID field in the mutation")
  19741. }
  19742. oldValue, err := m.oldValue(ctx)
  19743. if err != nil {
  19744. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  19745. }
  19746. return oldValue.Conditions, nil
  19747. }
  19748. // ClearConditions clears the value of the "conditions" field.
  19749. func (m *LabelMutation) ClearConditions() {
  19750. m.conditions = nil
  19751. m.clearedFields[label.FieldConditions] = struct{}{}
  19752. }
  19753. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  19754. func (m *LabelMutation) ConditionsCleared() bool {
  19755. _, ok := m.clearedFields[label.FieldConditions]
  19756. return ok
  19757. }
  19758. // ResetConditions resets all changes to the "conditions" field.
  19759. func (m *LabelMutation) ResetConditions() {
  19760. m.conditions = nil
  19761. delete(m.clearedFields, label.FieldConditions)
  19762. }
  19763. // SetOrganizationID sets the "organization_id" field.
  19764. func (m *LabelMutation) SetOrganizationID(u uint64) {
  19765. m.organization_id = &u
  19766. m.addorganization_id = nil
  19767. }
  19768. // OrganizationID returns the value of the "organization_id" field in the mutation.
  19769. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  19770. v := m.organization_id
  19771. if v == nil {
  19772. return
  19773. }
  19774. return *v, true
  19775. }
  19776. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  19777. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19779. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  19780. if !m.op.Is(OpUpdateOne) {
  19781. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  19782. }
  19783. if m.id == nil || m.oldValue == nil {
  19784. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  19785. }
  19786. oldValue, err := m.oldValue(ctx)
  19787. if err != nil {
  19788. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  19789. }
  19790. return oldValue.OrganizationID, nil
  19791. }
  19792. // AddOrganizationID adds u to the "organization_id" field.
  19793. func (m *LabelMutation) AddOrganizationID(u int64) {
  19794. if m.addorganization_id != nil {
  19795. *m.addorganization_id += u
  19796. } else {
  19797. m.addorganization_id = &u
  19798. }
  19799. }
  19800. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  19801. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  19802. v := m.addorganization_id
  19803. if v == nil {
  19804. return
  19805. }
  19806. return *v, true
  19807. }
  19808. // ClearOrganizationID clears the value of the "organization_id" field.
  19809. func (m *LabelMutation) ClearOrganizationID() {
  19810. m.organization_id = nil
  19811. m.addorganization_id = nil
  19812. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  19813. }
  19814. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  19815. func (m *LabelMutation) OrganizationIDCleared() bool {
  19816. _, ok := m.clearedFields[label.FieldOrganizationID]
  19817. return ok
  19818. }
  19819. // ResetOrganizationID resets all changes to the "organization_id" field.
  19820. func (m *LabelMutation) ResetOrganizationID() {
  19821. m.organization_id = nil
  19822. m.addorganization_id = nil
  19823. delete(m.clearedFields, label.FieldOrganizationID)
  19824. }
  19825. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  19826. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  19827. if m.label_relationships == nil {
  19828. m.label_relationships = make(map[uint64]struct{})
  19829. }
  19830. for i := range ids {
  19831. m.label_relationships[ids[i]] = struct{}{}
  19832. }
  19833. }
  19834. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  19835. func (m *LabelMutation) ClearLabelRelationships() {
  19836. m.clearedlabel_relationships = true
  19837. }
  19838. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  19839. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  19840. return m.clearedlabel_relationships
  19841. }
  19842. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  19843. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  19844. if m.removedlabel_relationships == nil {
  19845. m.removedlabel_relationships = make(map[uint64]struct{})
  19846. }
  19847. for i := range ids {
  19848. delete(m.label_relationships, ids[i])
  19849. m.removedlabel_relationships[ids[i]] = struct{}{}
  19850. }
  19851. }
  19852. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  19853. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  19854. for id := range m.removedlabel_relationships {
  19855. ids = append(ids, id)
  19856. }
  19857. return
  19858. }
  19859. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  19860. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  19861. for id := range m.label_relationships {
  19862. ids = append(ids, id)
  19863. }
  19864. return
  19865. }
  19866. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  19867. func (m *LabelMutation) ResetLabelRelationships() {
  19868. m.label_relationships = nil
  19869. m.clearedlabel_relationships = false
  19870. m.removedlabel_relationships = nil
  19871. }
  19872. // Where appends a list predicates to the LabelMutation builder.
  19873. func (m *LabelMutation) Where(ps ...predicate.Label) {
  19874. m.predicates = append(m.predicates, ps...)
  19875. }
  19876. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  19877. // users can use type-assertion to append predicates that do not depend on any generated package.
  19878. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  19879. p := make([]predicate.Label, len(ps))
  19880. for i := range ps {
  19881. p[i] = ps[i]
  19882. }
  19883. m.Where(p...)
  19884. }
  19885. // Op returns the operation name.
  19886. func (m *LabelMutation) Op() Op {
  19887. return m.op
  19888. }
  19889. // SetOp allows setting the mutation operation.
  19890. func (m *LabelMutation) SetOp(op Op) {
  19891. m.op = op
  19892. }
  19893. // Type returns the node type of this mutation (Label).
  19894. func (m *LabelMutation) Type() string {
  19895. return m.typ
  19896. }
  19897. // Fields returns all fields that were changed during this mutation. Note that in
  19898. // order to get all numeric fields that were incremented/decremented, call
  19899. // AddedFields().
  19900. func (m *LabelMutation) Fields() []string {
  19901. fields := make([]string, 0, 9)
  19902. if m.created_at != nil {
  19903. fields = append(fields, label.FieldCreatedAt)
  19904. }
  19905. if m.updated_at != nil {
  19906. fields = append(fields, label.FieldUpdatedAt)
  19907. }
  19908. if m.status != nil {
  19909. fields = append(fields, label.FieldStatus)
  19910. }
  19911. if m._type != nil {
  19912. fields = append(fields, label.FieldType)
  19913. }
  19914. if m.name != nil {
  19915. fields = append(fields, label.FieldName)
  19916. }
  19917. if m.from != nil {
  19918. fields = append(fields, label.FieldFrom)
  19919. }
  19920. if m.mode != nil {
  19921. fields = append(fields, label.FieldMode)
  19922. }
  19923. if m.conditions != nil {
  19924. fields = append(fields, label.FieldConditions)
  19925. }
  19926. if m.organization_id != nil {
  19927. fields = append(fields, label.FieldOrganizationID)
  19928. }
  19929. return fields
  19930. }
  19931. // Field returns the value of a field with the given name. The second boolean
  19932. // return value indicates that this field was not set, or was not defined in the
  19933. // schema.
  19934. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  19935. switch name {
  19936. case label.FieldCreatedAt:
  19937. return m.CreatedAt()
  19938. case label.FieldUpdatedAt:
  19939. return m.UpdatedAt()
  19940. case label.FieldStatus:
  19941. return m.Status()
  19942. case label.FieldType:
  19943. return m.GetType()
  19944. case label.FieldName:
  19945. return m.Name()
  19946. case label.FieldFrom:
  19947. return m.From()
  19948. case label.FieldMode:
  19949. return m.Mode()
  19950. case label.FieldConditions:
  19951. return m.Conditions()
  19952. case label.FieldOrganizationID:
  19953. return m.OrganizationID()
  19954. }
  19955. return nil, false
  19956. }
  19957. // OldField returns the old value of the field from the database. An error is
  19958. // returned if the mutation operation is not UpdateOne, or the query to the
  19959. // database failed.
  19960. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19961. switch name {
  19962. case label.FieldCreatedAt:
  19963. return m.OldCreatedAt(ctx)
  19964. case label.FieldUpdatedAt:
  19965. return m.OldUpdatedAt(ctx)
  19966. case label.FieldStatus:
  19967. return m.OldStatus(ctx)
  19968. case label.FieldType:
  19969. return m.OldType(ctx)
  19970. case label.FieldName:
  19971. return m.OldName(ctx)
  19972. case label.FieldFrom:
  19973. return m.OldFrom(ctx)
  19974. case label.FieldMode:
  19975. return m.OldMode(ctx)
  19976. case label.FieldConditions:
  19977. return m.OldConditions(ctx)
  19978. case label.FieldOrganizationID:
  19979. return m.OldOrganizationID(ctx)
  19980. }
  19981. return nil, fmt.Errorf("unknown Label field %s", name)
  19982. }
  19983. // SetField sets the value of a field with the given name. It returns an error if
  19984. // the field is not defined in the schema, or if the type mismatched the field
  19985. // type.
  19986. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  19987. switch name {
  19988. case label.FieldCreatedAt:
  19989. v, ok := value.(time.Time)
  19990. if !ok {
  19991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19992. }
  19993. m.SetCreatedAt(v)
  19994. return nil
  19995. case label.FieldUpdatedAt:
  19996. v, ok := value.(time.Time)
  19997. if !ok {
  19998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19999. }
  20000. m.SetUpdatedAt(v)
  20001. return nil
  20002. case label.FieldStatus:
  20003. v, ok := value.(uint8)
  20004. if !ok {
  20005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20006. }
  20007. m.SetStatus(v)
  20008. return nil
  20009. case label.FieldType:
  20010. v, ok := value.(int)
  20011. if !ok {
  20012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20013. }
  20014. m.SetType(v)
  20015. return nil
  20016. case label.FieldName:
  20017. v, ok := value.(string)
  20018. if !ok {
  20019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20020. }
  20021. m.SetName(v)
  20022. return nil
  20023. case label.FieldFrom:
  20024. v, ok := value.(int)
  20025. if !ok {
  20026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20027. }
  20028. m.SetFrom(v)
  20029. return nil
  20030. case label.FieldMode:
  20031. v, ok := value.(int)
  20032. if !ok {
  20033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20034. }
  20035. m.SetMode(v)
  20036. return nil
  20037. case label.FieldConditions:
  20038. v, ok := value.(string)
  20039. if !ok {
  20040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20041. }
  20042. m.SetConditions(v)
  20043. return nil
  20044. case label.FieldOrganizationID:
  20045. v, ok := value.(uint64)
  20046. if !ok {
  20047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20048. }
  20049. m.SetOrganizationID(v)
  20050. return nil
  20051. }
  20052. return fmt.Errorf("unknown Label field %s", name)
  20053. }
  20054. // AddedFields returns all numeric fields that were incremented/decremented during
  20055. // this mutation.
  20056. func (m *LabelMutation) AddedFields() []string {
  20057. var fields []string
  20058. if m.addstatus != nil {
  20059. fields = append(fields, label.FieldStatus)
  20060. }
  20061. if m.add_type != nil {
  20062. fields = append(fields, label.FieldType)
  20063. }
  20064. if m.addfrom != nil {
  20065. fields = append(fields, label.FieldFrom)
  20066. }
  20067. if m.addmode != nil {
  20068. fields = append(fields, label.FieldMode)
  20069. }
  20070. if m.addorganization_id != nil {
  20071. fields = append(fields, label.FieldOrganizationID)
  20072. }
  20073. return fields
  20074. }
  20075. // AddedField returns the numeric value that was incremented/decremented on a field
  20076. // with the given name. The second boolean return value indicates that this field
  20077. // was not set, or was not defined in the schema.
  20078. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  20079. switch name {
  20080. case label.FieldStatus:
  20081. return m.AddedStatus()
  20082. case label.FieldType:
  20083. return m.AddedType()
  20084. case label.FieldFrom:
  20085. return m.AddedFrom()
  20086. case label.FieldMode:
  20087. return m.AddedMode()
  20088. case label.FieldOrganizationID:
  20089. return m.AddedOrganizationID()
  20090. }
  20091. return nil, false
  20092. }
  20093. // AddField adds the value to the field with the given name. It returns an error if
  20094. // the field is not defined in the schema, or if the type mismatched the field
  20095. // type.
  20096. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  20097. switch name {
  20098. case label.FieldStatus:
  20099. v, ok := value.(int8)
  20100. if !ok {
  20101. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20102. }
  20103. m.AddStatus(v)
  20104. return nil
  20105. case label.FieldType:
  20106. v, ok := value.(int)
  20107. if !ok {
  20108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20109. }
  20110. m.AddType(v)
  20111. return nil
  20112. case label.FieldFrom:
  20113. v, ok := value.(int)
  20114. if !ok {
  20115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20116. }
  20117. m.AddFrom(v)
  20118. return nil
  20119. case label.FieldMode:
  20120. v, ok := value.(int)
  20121. if !ok {
  20122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20123. }
  20124. m.AddMode(v)
  20125. return nil
  20126. case label.FieldOrganizationID:
  20127. v, ok := value.(int64)
  20128. if !ok {
  20129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20130. }
  20131. m.AddOrganizationID(v)
  20132. return nil
  20133. }
  20134. return fmt.Errorf("unknown Label numeric field %s", name)
  20135. }
  20136. // ClearedFields returns all nullable fields that were cleared during this
  20137. // mutation.
  20138. func (m *LabelMutation) ClearedFields() []string {
  20139. var fields []string
  20140. if m.FieldCleared(label.FieldStatus) {
  20141. fields = append(fields, label.FieldStatus)
  20142. }
  20143. if m.FieldCleared(label.FieldConditions) {
  20144. fields = append(fields, label.FieldConditions)
  20145. }
  20146. if m.FieldCleared(label.FieldOrganizationID) {
  20147. fields = append(fields, label.FieldOrganizationID)
  20148. }
  20149. return fields
  20150. }
  20151. // FieldCleared returns a boolean indicating if a field with the given name was
  20152. // cleared in this mutation.
  20153. func (m *LabelMutation) FieldCleared(name string) bool {
  20154. _, ok := m.clearedFields[name]
  20155. return ok
  20156. }
  20157. // ClearField clears the value of the field with the given name. It returns an
  20158. // error if the field is not defined in the schema.
  20159. func (m *LabelMutation) ClearField(name string) error {
  20160. switch name {
  20161. case label.FieldStatus:
  20162. m.ClearStatus()
  20163. return nil
  20164. case label.FieldConditions:
  20165. m.ClearConditions()
  20166. return nil
  20167. case label.FieldOrganizationID:
  20168. m.ClearOrganizationID()
  20169. return nil
  20170. }
  20171. return fmt.Errorf("unknown Label nullable field %s", name)
  20172. }
  20173. // ResetField resets all changes in the mutation for the field with the given name.
  20174. // It returns an error if the field is not defined in the schema.
  20175. func (m *LabelMutation) ResetField(name string) error {
  20176. switch name {
  20177. case label.FieldCreatedAt:
  20178. m.ResetCreatedAt()
  20179. return nil
  20180. case label.FieldUpdatedAt:
  20181. m.ResetUpdatedAt()
  20182. return nil
  20183. case label.FieldStatus:
  20184. m.ResetStatus()
  20185. return nil
  20186. case label.FieldType:
  20187. m.ResetType()
  20188. return nil
  20189. case label.FieldName:
  20190. m.ResetName()
  20191. return nil
  20192. case label.FieldFrom:
  20193. m.ResetFrom()
  20194. return nil
  20195. case label.FieldMode:
  20196. m.ResetMode()
  20197. return nil
  20198. case label.FieldConditions:
  20199. m.ResetConditions()
  20200. return nil
  20201. case label.FieldOrganizationID:
  20202. m.ResetOrganizationID()
  20203. return nil
  20204. }
  20205. return fmt.Errorf("unknown Label field %s", name)
  20206. }
  20207. // AddedEdges returns all edge names that were set/added in this mutation.
  20208. func (m *LabelMutation) AddedEdges() []string {
  20209. edges := make([]string, 0, 1)
  20210. if m.label_relationships != nil {
  20211. edges = append(edges, label.EdgeLabelRelationships)
  20212. }
  20213. return edges
  20214. }
  20215. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20216. // name in this mutation.
  20217. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  20218. switch name {
  20219. case label.EdgeLabelRelationships:
  20220. ids := make([]ent.Value, 0, len(m.label_relationships))
  20221. for id := range m.label_relationships {
  20222. ids = append(ids, id)
  20223. }
  20224. return ids
  20225. }
  20226. return nil
  20227. }
  20228. // RemovedEdges returns all edge names that were removed in this mutation.
  20229. func (m *LabelMutation) RemovedEdges() []string {
  20230. edges := make([]string, 0, 1)
  20231. if m.removedlabel_relationships != nil {
  20232. edges = append(edges, label.EdgeLabelRelationships)
  20233. }
  20234. return edges
  20235. }
  20236. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20237. // the given name in this mutation.
  20238. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  20239. switch name {
  20240. case label.EdgeLabelRelationships:
  20241. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  20242. for id := range m.removedlabel_relationships {
  20243. ids = append(ids, id)
  20244. }
  20245. return ids
  20246. }
  20247. return nil
  20248. }
  20249. // ClearedEdges returns all edge names that were cleared in this mutation.
  20250. func (m *LabelMutation) ClearedEdges() []string {
  20251. edges := make([]string, 0, 1)
  20252. if m.clearedlabel_relationships {
  20253. edges = append(edges, label.EdgeLabelRelationships)
  20254. }
  20255. return edges
  20256. }
  20257. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20258. // was cleared in this mutation.
  20259. func (m *LabelMutation) EdgeCleared(name string) bool {
  20260. switch name {
  20261. case label.EdgeLabelRelationships:
  20262. return m.clearedlabel_relationships
  20263. }
  20264. return false
  20265. }
  20266. // ClearEdge clears the value of the edge with the given name. It returns an error
  20267. // if that edge is not defined in the schema.
  20268. func (m *LabelMutation) ClearEdge(name string) error {
  20269. switch name {
  20270. }
  20271. return fmt.Errorf("unknown Label unique edge %s", name)
  20272. }
  20273. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20274. // It returns an error if the edge is not defined in the schema.
  20275. func (m *LabelMutation) ResetEdge(name string) error {
  20276. switch name {
  20277. case label.EdgeLabelRelationships:
  20278. m.ResetLabelRelationships()
  20279. return nil
  20280. }
  20281. return fmt.Errorf("unknown Label edge %s", name)
  20282. }
  20283. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  20284. type LabelRelationshipMutation struct {
  20285. config
  20286. op Op
  20287. typ string
  20288. id *uint64
  20289. created_at *time.Time
  20290. updated_at *time.Time
  20291. status *uint8
  20292. addstatus *int8
  20293. organization_id *uint64
  20294. addorganization_id *int64
  20295. clearedFields map[string]struct{}
  20296. contacts *uint64
  20297. clearedcontacts bool
  20298. labels *uint64
  20299. clearedlabels bool
  20300. done bool
  20301. oldValue func(context.Context) (*LabelRelationship, error)
  20302. predicates []predicate.LabelRelationship
  20303. }
  20304. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  20305. // labelrelationshipOption allows management of the mutation configuration using functional options.
  20306. type labelrelationshipOption func(*LabelRelationshipMutation)
  20307. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  20308. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  20309. m := &LabelRelationshipMutation{
  20310. config: c,
  20311. op: op,
  20312. typ: TypeLabelRelationship,
  20313. clearedFields: make(map[string]struct{}),
  20314. }
  20315. for _, opt := range opts {
  20316. opt(m)
  20317. }
  20318. return m
  20319. }
  20320. // withLabelRelationshipID sets the ID field of the mutation.
  20321. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  20322. return func(m *LabelRelationshipMutation) {
  20323. var (
  20324. err error
  20325. once sync.Once
  20326. value *LabelRelationship
  20327. )
  20328. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  20329. once.Do(func() {
  20330. if m.done {
  20331. err = errors.New("querying old values post mutation is not allowed")
  20332. } else {
  20333. value, err = m.Client().LabelRelationship.Get(ctx, id)
  20334. }
  20335. })
  20336. return value, err
  20337. }
  20338. m.id = &id
  20339. }
  20340. }
  20341. // withLabelRelationship sets the old LabelRelationship of the mutation.
  20342. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  20343. return func(m *LabelRelationshipMutation) {
  20344. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  20345. return node, nil
  20346. }
  20347. m.id = &node.ID
  20348. }
  20349. }
  20350. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20351. // executed in a transaction (ent.Tx), a transactional client is returned.
  20352. func (m LabelRelationshipMutation) Client() *Client {
  20353. client := &Client{config: m.config}
  20354. client.init()
  20355. return client
  20356. }
  20357. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20358. // it returns an error otherwise.
  20359. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  20360. if _, ok := m.driver.(*txDriver); !ok {
  20361. return nil, errors.New("ent: mutation is not running in a transaction")
  20362. }
  20363. tx := &Tx{config: m.config}
  20364. tx.init()
  20365. return tx, nil
  20366. }
  20367. // SetID sets the value of the id field. Note that this
  20368. // operation is only accepted on creation of LabelRelationship entities.
  20369. func (m *LabelRelationshipMutation) SetID(id uint64) {
  20370. m.id = &id
  20371. }
  20372. // ID returns the ID value in the mutation. Note that the ID is only available
  20373. // if it was provided to the builder or after it was returned from the database.
  20374. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  20375. if m.id == nil {
  20376. return
  20377. }
  20378. return *m.id, true
  20379. }
  20380. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20381. // That means, if the mutation is applied within a transaction with an isolation level such
  20382. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20383. // or updated by the mutation.
  20384. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  20385. switch {
  20386. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20387. id, exists := m.ID()
  20388. if exists {
  20389. return []uint64{id}, nil
  20390. }
  20391. fallthrough
  20392. case m.op.Is(OpUpdate | OpDelete):
  20393. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  20394. default:
  20395. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20396. }
  20397. }
  20398. // SetCreatedAt sets the "created_at" field.
  20399. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  20400. m.created_at = &t
  20401. }
  20402. // CreatedAt returns the value of the "created_at" field in the mutation.
  20403. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  20404. v := m.created_at
  20405. if v == nil {
  20406. return
  20407. }
  20408. return *v, true
  20409. }
  20410. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  20411. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  20412. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20413. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20414. if !m.op.Is(OpUpdateOne) {
  20415. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20416. }
  20417. if m.id == nil || m.oldValue == nil {
  20418. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20419. }
  20420. oldValue, err := m.oldValue(ctx)
  20421. if err != nil {
  20422. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20423. }
  20424. return oldValue.CreatedAt, nil
  20425. }
  20426. // ResetCreatedAt resets all changes to the "created_at" field.
  20427. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  20428. m.created_at = nil
  20429. }
  20430. // SetUpdatedAt sets the "updated_at" field.
  20431. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  20432. m.updated_at = &t
  20433. }
  20434. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20435. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  20436. v := m.updated_at
  20437. if v == nil {
  20438. return
  20439. }
  20440. return *v, true
  20441. }
  20442. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  20443. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  20444. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20445. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20446. if !m.op.Is(OpUpdateOne) {
  20447. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20448. }
  20449. if m.id == nil || m.oldValue == nil {
  20450. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20451. }
  20452. oldValue, err := m.oldValue(ctx)
  20453. if err != nil {
  20454. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20455. }
  20456. return oldValue.UpdatedAt, nil
  20457. }
  20458. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20459. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  20460. m.updated_at = nil
  20461. }
  20462. // SetStatus sets the "status" field.
  20463. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  20464. m.status = &u
  20465. m.addstatus = nil
  20466. }
  20467. // Status returns the value of the "status" field in the mutation.
  20468. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  20469. v := m.status
  20470. if v == nil {
  20471. return
  20472. }
  20473. return *v, true
  20474. }
  20475. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  20476. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  20477. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20478. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20479. if !m.op.Is(OpUpdateOne) {
  20480. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20481. }
  20482. if m.id == nil || m.oldValue == nil {
  20483. return v, errors.New("OldStatus requires an ID field in the mutation")
  20484. }
  20485. oldValue, err := m.oldValue(ctx)
  20486. if err != nil {
  20487. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20488. }
  20489. return oldValue.Status, nil
  20490. }
  20491. // AddStatus adds u to the "status" field.
  20492. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  20493. if m.addstatus != nil {
  20494. *m.addstatus += u
  20495. } else {
  20496. m.addstatus = &u
  20497. }
  20498. }
  20499. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20500. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  20501. v := m.addstatus
  20502. if v == nil {
  20503. return
  20504. }
  20505. return *v, true
  20506. }
  20507. // ClearStatus clears the value of the "status" field.
  20508. func (m *LabelRelationshipMutation) ClearStatus() {
  20509. m.status = nil
  20510. m.addstatus = nil
  20511. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  20512. }
  20513. // StatusCleared returns if the "status" field was cleared in this mutation.
  20514. func (m *LabelRelationshipMutation) StatusCleared() bool {
  20515. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  20516. return ok
  20517. }
  20518. // ResetStatus resets all changes to the "status" field.
  20519. func (m *LabelRelationshipMutation) ResetStatus() {
  20520. m.status = nil
  20521. m.addstatus = nil
  20522. delete(m.clearedFields, labelrelationship.FieldStatus)
  20523. }
  20524. // SetLabelID sets the "label_id" field.
  20525. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  20526. m.labels = &u
  20527. }
  20528. // LabelID returns the value of the "label_id" field in the mutation.
  20529. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  20530. v := m.labels
  20531. if v == nil {
  20532. return
  20533. }
  20534. return *v, true
  20535. }
  20536. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  20537. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  20538. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20539. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  20540. if !m.op.Is(OpUpdateOne) {
  20541. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  20542. }
  20543. if m.id == nil || m.oldValue == nil {
  20544. return v, errors.New("OldLabelID requires an ID field in the mutation")
  20545. }
  20546. oldValue, err := m.oldValue(ctx)
  20547. if err != nil {
  20548. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  20549. }
  20550. return oldValue.LabelID, nil
  20551. }
  20552. // ResetLabelID resets all changes to the "label_id" field.
  20553. func (m *LabelRelationshipMutation) ResetLabelID() {
  20554. m.labels = nil
  20555. }
  20556. // SetContactID sets the "contact_id" field.
  20557. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  20558. m.contacts = &u
  20559. }
  20560. // ContactID returns the value of the "contact_id" field in the mutation.
  20561. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  20562. v := m.contacts
  20563. if v == nil {
  20564. return
  20565. }
  20566. return *v, true
  20567. }
  20568. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  20569. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  20570. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20571. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  20572. if !m.op.Is(OpUpdateOne) {
  20573. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  20574. }
  20575. if m.id == nil || m.oldValue == nil {
  20576. return v, errors.New("OldContactID requires an ID field in the mutation")
  20577. }
  20578. oldValue, err := m.oldValue(ctx)
  20579. if err != nil {
  20580. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  20581. }
  20582. return oldValue.ContactID, nil
  20583. }
  20584. // ResetContactID resets all changes to the "contact_id" field.
  20585. func (m *LabelRelationshipMutation) ResetContactID() {
  20586. m.contacts = nil
  20587. }
  20588. // SetOrganizationID sets the "organization_id" field.
  20589. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  20590. m.organization_id = &u
  20591. m.addorganization_id = nil
  20592. }
  20593. // OrganizationID returns the value of the "organization_id" field in the mutation.
  20594. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  20595. v := m.organization_id
  20596. if v == nil {
  20597. return
  20598. }
  20599. return *v, true
  20600. }
  20601. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  20602. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  20603. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20604. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  20605. if !m.op.Is(OpUpdateOne) {
  20606. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  20607. }
  20608. if m.id == nil || m.oldValue == nil {
  20609. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  20610. }
  20611. oldValue, err := m.oldValue(ctx)
  20612. if err != nil {
  20613. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  20614. }
  20615. return oldValue.OrganizationID, nil
  20616. }
  20617. // AddOrganizationID adds u to the "organization_id" field.
  20618. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  20619. if m.addorganization_id != nil {
  20620. *m.addorganization_id += u
  20621. } else {
  20622. m.addorganization_id = &u
  20623. }
  20624. }
  20625. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  20626. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  20627. v := m.addorganization_id
  20628. if v == nil {
  20629. return
  20630. }
  20631. return *v, true
  20632. }
  20633. // ClearOrganizationID clears the value of the "organization_id" field.
  20634. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  20635. m.organization_id = nil
  20636. m.addorganization_id = nil
  20637. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  20638. }
  20639. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  20640. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  20641. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  20642. return ok
  20643. }
  20644. // ResetOrganizationID resets all changes to the "organization_id" field.
  20645. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  20646. m.organization_id = nil
  20647. m.addorganization_id = nil
  20648. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  20649. }
  20650. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  20651. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  20652. m.contacts = &id
  20653. }
  20654. // ClearContacts clears the "contacts" edge to the Contact entity.
  20655. func (m *LabelRelationshipMutation) ClearContacts() {
  20656. m.clearedcontacts = true
  20657. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  20658. }
  20659. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  20660. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  20661. return m.clearedcontacts
  20662. }
  20663. // ContactsID returns the "contacts" edge ID in the mutation.
  20664. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  20665. if m.contacts != nil {
  20666. return *m.contacts, true
  20667. }
  20668. return
  20669. }
  20670. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  20671. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  20672. // ContactsID instead. It exists only for internal usage by the builders.
  20673. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  20674. if id := m.contacts; id != nil {
  20675. ids = append(ids, *id)
  20676. }
  20677. return
  20678. }
  20679. // ResetContacts resets all changes to the "contacts" edge.
  20680. func (m *LabelRelationshipMutation) ResetContacts() {
  20681. m.contacts = nil
  20682. m.clearedcontacts = false
  20683. }
  20684. // SetLabelsID sets the "labels" edge to the Label entity by id.
  20685. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  20686. m.labels = &id
  20687. }
  20688. // ClearLabels clears the "labels" edge to the Label entity.
  20689. func (m *LabelRelationshipMutation) ClearLabels() {
  20690. m.clearedlabels = true
  20691. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  20692. }
  20693. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  20694. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  20695. return m.clearedlabels
  20696. }
  20697. // LabelsID returns the "labels" edge ID in the mutation.
  20698. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  20699. if m.labels != nil {
  20700. return *m.labels, true
  20701. }
  20702. return
  20703. }
  20704. // LabelsIDs returns the "labels" edge IDs in the mutation.
  20705. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  20706. // LabelsID instead. It exists only for internal usage by the builders.
  20707. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  20708. if id := m.labels; id != nil {
  20709. ids = append(ids, *id)
  20710. }
  20711. return
  20712. }
  20713. // ResetLabels resets all changes to the "labels" edge.
  20714. func (m *LabelRelationshipMutation) ResetLabels() {
  20715. m.labels = nil
  20716. m.clearedlabels = false
  20717. }
  20718. // Where appends a list predicates to the LabelRelationshipMutation builder.
  20719. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  20720. m.predicates = append(m.predicates, ps...)
  20721. }
  20722. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  20723. // users can use type-assertion to append predicates that do not depend on any generated package.
  20724. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  20725. p := make([]predicate.LabelRelationship, len(ps))
  20726. for i := range ps {
  20727. p[i] = ps[i]
  20728. }
  20729. m.Where(p...)
  20730. }
  20731. // Op returns the operation name.
  20732. func (m *LabelRelationshipMutation) Op() Op {
  20733. return m.op
  20734. }
  20735. // SetOp allows setting the mutation operation.
  20736. func (m *LabelRelationshipMutation) SetOp(op Op) {
  20737. m.op = op
  20738. }
  20739. // Type returns the node type of this mutation (LabelRelationship).
  20740. func (m *LabelRelationshipMutation) Type() string {
  20741. return m.typ
  20742. }
  20743. // Fields returns all fields that were changed during this mutation. Note that in
  20744. // order to get all numeric fields that were incremented/decremented, call
  20745. // AddedFields().
  20746. func (m *LabelRelationshipMutation) Fields() []string {
  20747. fields := make([]string, 0, 6)
  20748. if m.created_at != nil {
  20749. fields = append(fields, labelrelationship.FieldCreatedAt)
  20750. }
  20751. if m.updated_at != nil {
  20752. fields = append(fields, labelrelationship.FieldUpdatedAt)
  20753. }
  20754. if m.status != nil {
  20755. fields = append(fields, labelrelationship.FieldStatus)
  20756. }
  20757. if m.labels != nil {
  20758. fields = append(fields, labelrelationship.FieldLabelID)
  20759. }
  20760. if m.contacts != nil {
  20761. fields = append(fields, labelrelationship.FieldContactID)
  20762. }
  20763. if m.organization_id != nil {
  20764. fields = append(fields, labelrelationship.FieldOrganizationID)
  20765. }
  20766. return fields
  20767. }
  20768. // Field returns the value of a field with the given name. The second boolean
  20769. // return value indicates that this field was not set, or was not defined in the
  20770. // schema.
  20771. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  20772. switch name {
  20773. case labelrelationship.FieldCreatedAt:
  20774. return m.CreatedAt()
  20775. case labelrelationship.FieldUpdatedAt:
  20776. return m.UpdatedAt()
  20777. case labelrelationship.FieldStatus:
  20778. return m.Status()
  20779. case labelrelationship.FieldLabelID:
  20780. return m.LabelID()
  20781. case labelrelationship.FieldContactID:
  20782. return m.ContactID()
  20783. case labelrelationship.FieldOrganizationID:
  20784. return m.OrganizationID()
  20785. }
  20786. return nil, false
  20787. }
  20788. // OldField returns the old value of the field from the database. An error is
  20789. // returned if the mutation operation is not UpdateOne, or the query to the
  20790. // database failed.
  20791. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20792. switch name {
  20793. case labelrelationship.FieldCreatedAt:
  20794. return m.OldCreatedAt(ctx)
  20795. case labelrelationship.FieldUpdatedAt:
  20796. return m.OldUpdatedAt(ctx)
  20797. case labelrelationship.FieldStatus:
  20798. return m.OldStatus(ctx)
  20799. case labelrelationship.FieldLabelID:
  20800. return m.OldLabelID(ctx)
  20801. case labelrelationship.FieldContactID:
  20802. return m.OldContactID(ctx)
  20803. case labelrelationship.FieldOrganizationID:
  20804. return m.OldOrganizationID(ctx)
  20805. }
  20806. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  20807. }
  20808. // SetField sets the value of a field with the given name. It returns an error if
  20809. // the field is not defined in the schema, or if the type mismatched the field
  20810. // type.
  20811. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  20812. switch name {
  20813. case labelrelationship.FieldCreatedAt:
  20814. v, ok := value.(time.Time)
  20815. if !ok {
  20816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20817. }
  20818. m.SetCreatedAt(v)
  20819. return nil
  20820. case labelrelationship.FieldUpdatedAt:
  20821. v, ok := value.(time.Time)
  20822. if !ok {
  20823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20824. }
  20825. m.SetUpdatedAt(v)
  20826. return nil
  20827. case labelrelationship.FieldStatus:
  20828. v, ok := value.(uint8)
  20829. if !ok {
  20830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20831. }
  20832. m.SetStatus(v)
  20833. return nil
  20834. case labelrelationship.FieldLabelID:
  20835. v, ok := value.(uint64)
  20836. if !ok {
  20837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20838. }
  20839. m.SetLabelID(v)
  20840. return nil
  20841. case labelrelationship.FieldContactID:
  20842. v, ok := value.(uint64)
  20843. if !ok {
  20844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20845. }
  20846. m.SetContactID(v)
  20847. return nil
  20848. case labelrelationship.FieldOrganizationID:
  20849. v, ok := value.(uint64)
  20850. if !ok {
  20851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20852. }
  20853. m.SetOrganizationID(v)
  20854. return nil
  20855. }
  20856. return fmt.Errorf("unknown LabelRelationship field %s", name)
  20857. }
  20858. // AddedFields returns all numeric fields that were incremented/decremented during
  20859. // this mutation.
  20860. func (m *LabelRelationshipMutation) AddedFields() []string {
  20861. var fields []string
  20862. if m.addstatus != nil {
  20863. fields = append(fields, labelrelationship.FieldStatus)
  20864. }
  20865. if m.addorganization_id != nil {
  20866. fields = append(fields, labelrelationship.FieldOrganizationID)
  20867. }
  20868. return fields
  20869. }
  20870. // AddedField returns the numeric value that was incremented/decremented on a field
  20871. // with the given name. The second boolean return value indicates that this field
  20872. // was not set, or was not defined in the schema.
  20873. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  20874. switch name {
  20875. case labelrelationship.FieldStatus:
  20876. return m.AddedStatus()
  20877. case labelrelationship.FieldOrganizationID:
  20878. return m.AddedOrganizationID()
  20879. }
  20880. return nil, false
  20881. }
  20882. // AddField adds the value to the field with the given name. It returns an error if
  20883. // the field is not defined in the schema, or if the type mismatched the field
  20884. // type.
  20885. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  20886. switch name {
  20887. case labelrelationship.FieldStatus:
  20888. v, ok := value.(int8)
  20889. if !ok {
  20890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20891. }
  20892. m.AddStatus(v)
  20893. return nil
  20894. case labelrelationship.FieldOrganizationID:
  20895. v, ok := value.(int64)
  20896. if !ok {
  20897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20898. }
  20899. m.AddOrganizationID(v)
  20900. return nil
  20901. }
  20902. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  20903. }
  20904. // ClearedFields returns all nullable fields that were cleared during this
  20905. // mutation.
  20906. func (m *LabelRelationshipMutation) ClearedFields() []string {
  20907. var fields []string
  20908. if m.FieldCleared(labelrelationship.FieldStatus) {
  20909. fields = append(fields, labelrelationship.FieldStatus)
  20910. }
  20911. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  20912. fields = append(fields, labelrelationship.FieldOrganizationID)
  20913. }
  20914. return fields
  20915. }
  20916. // FieldCleared returns a boolean indicating if a field with the given name was
  20917. // cleared in this mutation.
  20918. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  20919. _, ok := m.clearedFields[name]
  20920. return ok
  20921. }
  20922. // ClearField clears the value of the field with the given name. It returns an
  20923. // error if the field is not defined in the schema.
  20924. func (m *LabelRelationshipMutation) ClearField(name string) error {
  20925. switch name {
  20926. case labelrelationship.FieldStatus:
  20927. m.ClearStatus()
  20928. return nil
  20929. case labelrelationship.FieldOrganizationID:
  20930. m.ClearOrganizationID()
  20931. return nil
  20932. }
  20933. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  20934. }
  20935. // ResetField resets all changes in the mutation for the field with the given name.
  20936. // It returns an error if the field is not defined in the schema.
  20937. func (m *LabelRelationshipMutation) ResetField(name string) error {
  20938. switch name {
  20939. case labelrelationship.FieldCreatedAt:
  20940. m.ResetCreatedAt()
  20941. return nil
  20942. case labelrelationship.FieldUpdatedAt:
  20943. m.ResetUpdatedAt()
  20944. return nil
  20945. case labelrelationship.FieldStatus:
  20946. m.ResetStatus()
  20947. return nil
  20948. case labelrelationship.FieldLabelID:
  20949. m.ResetLabelID()
  20950. return nil
  20951. case labelrelationship.FieldContactID:
  20952. m.ResetContactID()
  20953. return nil
  20954. case labelrelationship.FieldOrganizationID:
  20955. m.ResetOrganizationID()
  20956. return nil
  20957. }
  20958. return fmt.Errorf("unknown LabelRelationship field %s", name)
  20959. }
  20960. // AddedEdges returns all edge names that were set/added in this mutation.
  20961. func (m *LabelRelationshipMutation) AddedEdges() []string {
  20962. edges := make([]string, 0, 2)
  20963. if m.contacts != nil {
  20964. edges = append(edges, labelrelationship.EdgeContacts)
  20965. }
  20966. if m.labels != nil {
  20967. edges = append(edges, labelrelationship.EdgeLabels)
  20968. }
  20969. return edges
  20970. }
  20971. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20972. // name in this mutation.
  20973. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  20974. switch name {
  20975. case labelrelationship.EdgeContacts:
  20976. if id := m.contacts; id != nil {
  20977. return []ent.Value{*id}
  20978. }
  20979. case labelrelationship.EdgeLabels:
  20980. if id := m.labels; id != nil {
  20981. return []ent.Value{*id}
  20982. }
  20983. }
  20984. return nil
  20985. }
  20986. // RemovedEdges returns all edge names that were removed in this mutation.
  20987. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  20988. edges := make([]string, 0, 2)
  20989. return edges
  20990. }
  20991. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20992. // the given name in this mutation.
  20993. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  20994. return nil
  20995. }
  20996. // ClearedEdges returns all edge names that were cleared in this mutation.
  20997. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  20998. edges := make([]string, 0, 2)
  20999. if m.clearedcontacts {
  21000. edges = append(edges, labelrelationship.EdgeContacts)
  21001. }
  21002. if m.clearedlabels {
  21003. edges = append(edges, labelrelationship.EdgeLabels)
  21004. }
  21005. return edges
  21006. }
  21007. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21008. // was cleared in this mutation.
  21009. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  21010. switch name {
  21011. case labelrelationship.EdgeContacts:
  21012. return m.clearedcontacts
  21013. case labelrelationship.EdgeLabels:
  21014. return m.clearedlabels
  21015. }
  21016. return false
  21017. }
  21018. // ClearEdge clears the value of the edge with the given name. It returns an error
  21019. // if that edge is not defined in the schema.
  21020. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  21021. switch name {
  21022. case labelrelationship.EdgeContacts:
  21023. m.ClearContacts()
  21024. return nil
  21025. case labelrelationship.EdgeLabels:
  21026. m.ClearLabels()
  21027. return nil
  21028. }
  21029. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  21030. }
  21031. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21032. // It returns an error if the edge is not defined in the schema.
  21033. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  21034. switch name {
  21035. case labelrelationship.EdgeContacts:
  21036. m.ResetContacts()
  21037. return nil
  21038. case labelrelationship.EdgeLabels:
  21039. m.ResetLabels()
  21040. return nil
  21041. }
  21042. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  21043. }
  21044. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  21045. type LabelTaggingMutation struct {
  21046. config
  21047. op Op
  21048. typ string
  21049. id *uint64
  21050. created_at *time.Time
  21051. updated_at *time.Time
  21052. status *uint8
  21053. addstatus *int8
  21054. deleted_at *time.Time
  21055. organization_id *uint64
  21056. addorganization_id *int64
  21057. _type *int
  21058. add_type *int
  21059. conditions *string
  21060. action_label_add *[]uint64
  21061. appendaction_label_add []uint64
  21062. action_label_del *[]uint64
  21063. appendaction_label_del []uint64
  21064. clearedFields map[string]struct{}
  21065. done bool
  21066. oldValue func(context.Context) (*LabelTagging, error)
  21067. predicates []predicate.LabelTagging
  21068. }
  21069. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  21070. // labeltaggingOption allows management of the mutation configuration using functional options.
  21071. type labeltaggingOption func(*LabelTaggingMutation)
  21072. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  21073. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  21074. m := &LabelTaggingMutation{
  21075. config: c,
  21076. op: op,
  21077. typ: TypeLabelTagging,
  21078. clearedFields: make(map[string]struct{}),
  21079. }
  21080. for _, opt := range opts {
  21081. opt(m)
  21082. }
  21083. return m
  21084. }
  21085. // withLabelTaggingID sets the ID field of the mutation.
  21086. func withLabelTaggingID(id uint64) labeltaggingOption {
  21087. return func(m *LabelTaggingMutation) {
  21088. var (
  21089. err error
  21090. once sync.Once
  21091. value *LabelTagging
  21092. )
  21093. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  21094. once.Do(func() {
  21095. if m.done {
  21096. err = errors.New("querying old values post mutation is not allowed")
  21097. } else {
  21098. value, err = m.Client().LabelTagging.Get(ctx, id)
  21099. }
  21100. })
  21101. return value, err
  21102. }
  21103. m.id = &id
  21104. }
  21105. }
  21106. // withLabelTagging sets the old LabelTagging of the mutation.
  21107. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  21108. return func(m *LabelTaggingMutation) {
  21109. m.oldValue = func(context.Context) (*LabelTagging, error) {
  21110. return node, nil
  21111. }
  21112. m.id = &node.ID
  21113. }
  21114. }
  21115. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21116. // executed in a transaction (ent.Tx), a transactional client is returned.
  21117. func (m LabelTaggingMutation) Client() *Client {
  21118. client := &Client{config: m.config}
  21119. client.init()
  21120. return client
  21121. }
  21122. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21123. // it returns an error otherwise.
  21124. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  21125. if _, ok := m.driver.(*txDriver); !ok {
  21126. return nil, errors.New("ent: mutation is not running in a transaction")
  21127. }
  21128. tx := &Tx{config: m.config}
  21129. tx.init()
  21130. return tx, nil
  21131. }
  21132. // SetID sets the value of the id field. Note that this
  21133. // operation is only accepted on creation of LabelTagging entities.
  21134. func (m *LabelTaggingMutation) SetID(id uint64) {
  21135. m.id = &id
  21136. }
  21137. // ID returns the ID value in the mutation. Note that the ID is only available
  21138. // if it was provided to the builder or after it was returned from the database.
  21139. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  21140. if m.id == nil {
  21141. return
  21142. }
  21143. return *m.id, true
  21144. }
  21145. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21146. // That means, if the mutation is applied within a transaction with an isolation level such
  21147. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21148. // or updated by the mutation.
  21149. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  21150. switch {
  21151. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21152. id, exists := m.ID()
  21153. if exists {
  21154. return []uint64{id}, nil
  21155. }
  21156. fallthrough
  21157. case m.op.Is(OpUpdate | OpDelete):
  21158. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  21159. default:
  21160. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21161. }
  21162. }
  21163. // SetCreatedAt sets the "created_at" field.
  21164. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  21165. m.created_at = &t
  21166. }
  21167. // CreatedAt returns the value of the "created_at" field in the mutation.
  21168. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  21169. v := m.created_at
  21170. if v == nil {
  21171. return
  21172. }
  21173. return *v, true
  21174. }
  21175. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  21176. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  21177. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21178. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21179. if !m.op.Is(OpUpdateOne) {
  21180. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21181. }
  21182. if m.id == nil || m.oldValue == nil {
  21183. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21184. }
  21185. oldValue, err := m.oldValue(ctx)
  21186. if err != nil {
  21187. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21188. }
  21189. return oldValue.CreatedAt, nil
  21190. }
  21191. // ResetCreatedAt resets all changes to the "created_at" field.
  21192. func (m *LabelTaggingMutation) ResetCreatedAt() {
  21193. m.created_at = nil
  21194. }
  21195. // SetUpdatedAt sets the "updated_at" field.
  21196. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  21197. m.updated_at = &t
  21198. }
  21199. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21200. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  21201. v := m.updated_at
  21202. if v == nil {
  21203. return
  21204. }
  21205. return *v, true
  21206. }
  21207. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  21208. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  21209. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21210. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21211. if !m.op.Is(OpUpdateOne) {
  21212. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21213. }
  21214. if m.id == nil || m.oldValue == nil {
  21215. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21216. }
  21217. oldValue, err := m.oldValue(ctx)
  21218. if err != nil {
  21219. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21220. }
  21221. return oldValue.UpdatedAt, nil
  21222. }
  21223. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21224. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  21225. m.updated_at = nil
  21226. }
  21227. // SetStatus sets the "status" field.
  21228. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  21229. m.status = &u
  21230. m.addstatus = nil
  21231. }
  21232. // Status returns the value of the "status" field in the mutation.
  21233. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  21234. v := m.status
  21235. if v == nil {
  21236. return
  21237. }
  21238. return *v, true
  21239. }
  21240. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  21241. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  21242. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21243. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  21244. if !m.op.Is(OpUpdateOne) {
  21245. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  21246. }
  21247. if m.id == nil || m.oldValue == nil {
  21248. return v, errors.New("OldStatus requires an ID field in the mutation")
  21249. }
  21250. oldValue, err := m.oldValue(ctx)
  21251. if err != nil {
  21252. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  21253. }
  21254. return oldValue.Status, nil
  21255. }
  21256. // AddStatus adds u to the "status" field.
  21257. func (m *LabelTaggingMutation) AddStatus(u int8) {
  21258. if m.addstatus != nil {
  21259. *m.addstatus += u
  21260. } else {
  21261. m.addstatus = &u
  21262. }
  21263. }
  21264. // AddedStatus returns the value that was added to the "status" field in this mutation.
  21265. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  21266. v := m.addstatus
  21267. if v == nil {
  21268. return
  21269. }
  21270. return *v, true
  21271. }
  21272. // ClearStatus clears the value of the "status" field.
  21273. func (m *LabelTaggingMutation) ClearStatus() {
  21274. m.status = nil
  21275. m.addstatus = nil
  21276. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  21277. }
  21278. // StatusCleared returns if the "status" field was cleared in this mutation.
  21279. func (m *LabelTaggingMutation) StatusCleared() bool {
  21280. _, ok := m.clearedFields[labeltagging.FieldStatus]
  21281. return ok
  21282. }
  21283. // ResetStatus resets all changes to the "status" field.
  21284. func (m *LabelTaggingMutation) ResetStatus() {
  21285. m.status = nil
  21286. m.addstatus = nil
  21287. delete(m.clearedFields, labeltagging.FieldStatus)
  21288. }
  21289. // SetDeletedAt sets the "deleted_at" field.
  21290. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  21291. m.deleted_at = &t
  21292. }
  21293. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21294. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  21295. v := m.deleted_at
  21296. if v == nil {
  21297. return
  21298. }
  21299. return *v, true
  21300. }
  21301. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  21302. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  21303. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21304. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21305. if !m.op.Is(OpUpdateOne) {
  21306. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21307. }
  21308. if m.id == nil || m.oldValue == nil {
  21309. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21310. }
  21311. oldValue, err := m.oldValue(ctx)
  21312. if err != nil {
  21313. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21314. }
  21315. return oldValue.DeletedAt, nil
  21316. }
  21317. // ClearDeletedAt clears the value of the "deleted_at" field.
  21318. func (m *LabelTaggingMutation) ClearDeletedAt() {
  21319. m.deleted_at = nil
  21320. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  21321. }
  21322. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21323. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  21324. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  21325. return ok
  21326. }
  21327. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21328. func (m *LabelTaggingMutation) ResetDeletedAt() {
  21329. m.deleted_at = nil
  21330. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  21331. }
  21332. // SetOrganizationID sets the "organization_id" field.
  21333. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  21334. m.organization_id = &u
  21335. m.addorganization_id = nil
  21336. }
  21337. // OrganizationID returns the value of the "organization_id" field in the mutation.
  21338. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  21339. v := m.organization_id
  21340. if v == nil {
  21341. return
  21342. }
  21343. return *v, true
  21344. }
  21345. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  21346. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  21347. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21348. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  21349. if !m.op.Is(OpUpdateOne) {
  21350. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  21351. }
  21352. if m.id == nil || m.oldValue == nil {
  21353. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  21354. }
  21355. oldValue, err := m.oldValue(ctx)
  21356. if err != nil {
  21357. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  21358. }
  21359. return oldValue.OrganizationID, nil
  21360. }
  21361. // AddOrganizationID adds u to the "organization_id" field.
  21362. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  21363. if m.addorganization_id != nil {
  21364. *m.addorganization_id += u
  21365. } else {
  21366. m.addorganization_id = &u
  21367. }
  21368. }
  21369. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  21370. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  21371. v := m.addorganization_id
  21372. if v == nil {
  21373. return
  21374. }
  21375. return *v, true
  21376. }
  21377. // ResetOrganizationID resets all changes to the "organization_id" field.
  21378. func (m *LabelTaggingMutation) ResetOrganizationID() {
  21379. m.organization_id = nil
  21380. m.addorganization_id = nil
  21381. }
  21382. // SetType sets the "type" field.
  21383. func (m *LabelTaggingMutation) SetType(i int) {
  21384. m._type = &i
  21385. m.add_type = nil
  21386. }
  21387. // GetType returns the value of the "type" field in the mutation.
  21388. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  21389. v := m._type
  21390. if v == nil {
  21391. return
  21392. }
  21393. return *v, true
  21394. }
  21395. // OldType returns the old "type" field's value of the LabelTagging entity.
  21396. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  21397. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21398. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  21399. if !m.op.Is(OpUpdateOne) {
  21400. return v, errors.New("OldType is only allowed on UpdateOne operations")
  21401. }
  21402. if m.id == nil || m.oldValue == nil {
  21403. return v, errors.New("OldType requires an ID field in the mutation")
  21404. }
  21405. oldValue, err := m.oldValue(ctx)
  21406. if err != nil {
  21407. return v, fmt.Errorf("querying old value for OldType: %w", err)
  21408. }
  21409. return oldValue.Type, nil
  21410. }
  21411. // AddType adds i to the "type" field.
  21412. func (m *LabelTaggingMutation) AddType(i int) {
  21413. if m.add_type != nil {
  21414. *m.add_type += i
  21415. } else {
  21416. m.add_type = &i
  21417. }
  21418. }
  21419. // AddedType returns the value that was added to the "type" field in this mutation.
  21420. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  21421. v := m.add_type
  21422. if v == nil {
  21423. return
  21424. }
  21425. return *v, true
  21426. }
  21427. // ResetType resets all changes to the "type" field.
  21428. func (m *LabelTaggingMutation) ResetType() {
  21429. m._type = nil
  21430. m.add_type = nil
  21431. }
  21432. // SetConditions sets the "conditions" field.
  21433. func (m *LabelTaggingMutation) SetConditions(s string) {
  21434. m.conditions = &s
  21435. }
  21436. // Conditions returns the value of the "conditions" field in the mutation.
  21437. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  21438. v := m.conditions
  21439. if v == nil {
  21440. return
  21441. }
  21442. return *v, true
  21443. }
  21444. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  21445. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  21446. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21447. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  21448. if !m.op.Is(OpUpdateOne) {
  21449. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  21450. }
  21451. if m.id == nil || m.oldValue == nil {
  21452. return v, errors.New("OldConditions requires an ID field in the mutation")
  21453. }
  21454. oldValue, err := m.oldValue(ctx)
  21455. if err != nil {
  21456. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  21457. }
  21458. return oldValue.Conditions, nil
  21459. }
  21460. // ResetConditions resets all changes to the "conditions" field.
  21461. func (m *LabelTaggingMutation) ResetConditions() {
  21462. m.conditions = nil
  21463. }
  21464. // SetActionLabelAdd sets the "action_label_add" field.
  21465. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  21466. m.action_label_add = &u
  21467. m.appendaction_label_add = nil
  21468. }
  21469. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  21470. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  21471. v := m.action_label_add
  21472. if v == nil {
  21473. return
  21474. }
  21475. return *v, true
  21476. }
  21477. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  21478. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  21479. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21480. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  21481. if !m.op.Is(OpUpdateOne) {
  21482. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  21483. }
  21484. if m.id == nil || m.oldValue == nil {
  21485. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  21486. }
  21487. oldValue, err := m.oldValue(ctx)
  21488. if err != nil {
  21489. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  21490. }
  21491. return oldValue.ActionLabelAdd, nil
  21492. }
  21493. // AppendActionLabelAdd adds u to the "action_label_add" field.
  21494. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  21495. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  21496. }
  21497. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  21498. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  21499. if len(m.appendaction_label_add) == 0 {
  21500. return nil, false
  21501. }
  21502. return m.appendaction_label_add, true
  21503. }
  21504. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  21505. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  21506. m.action_label_add = nil
  21507. m.appendaction_label_add = nil
  21508. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  21509. }
  21510. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  21511. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  21512. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  21513. return ok
  21514. }
  21515. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  21516. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  21517. m.action_label_add = nil
  21518. m.appendaction_label_add = nil
  21519. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  21520. }
  21521. // SetActionLabelDel sets the "action_label_del" field.
  21522. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  21523. m.action_label_del = &u
  21524. m.appendaction_label_del = nil
  21525. }
  21526. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  21527. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  21528. v := m.action_label_del
  21529. if v == nil {
  21530. return
  21531. }
  21532. return *v, true
  21533. }
  21534. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  21535. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  21536. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21537. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  21538. if !m.op.Is(OpUpdateOne) {
  21539. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  21540. }
  21541. if m.id == nil || m.oldValue == nil {
  21542. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  21543. }
  21544. oldValue, err := m.oldValue(ctx)
  21545. if err != nil {
  21546. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  21547. }
  21548. return oldValue.ActionLabelDel, nil
  21549. }
  21550. // AppendActionLabelDel adds u to the "action_label_del" field.
  21551. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  21552. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  21553. }
  21554. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  21555. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  21556. if len(m.appendaction_label_del) == 0 {
  21557. return nil, false
  21558. }
  21559. return m.appendaction_label_del, true
  21560. }
  21561. // ClearActionLabelDel clears the value of the "action_label_del" field.
  21562. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  21563. m.action_label_del = nil
  21564. m.appendaction_label_del = nil
  21565. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  21566. }
  21567. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  21568. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  21569. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  21570. return ok
  21571. }
  21572. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  21573. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  21574. m.action_label_del = nil
  21575. m.appendaction_label_del = nil
  21576. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  21577. }
  21578. // Where appends a list predicates to the LabelTaggingMutation builder.
  21579. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  21580. m.predicates = append(m.predicates, ps...)
  21581. }
  21582. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  21583. // users can use type-assertion to append predicates that do not depend on any generated package.
  21584. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  21585. p := make([]predicate.LabelTagging, len(ps))
  21586. for i := range ps {
  21587. p[i] = ps[i]
  21588. }
  21589. m.Where(p...)
  21590. }
  21591. // Op returns the operation name.
  21592. func (m *LabelTaggingMutation) Op() Op {
  21593. return m.op
  21594. }
  21595. // SetOp allows setting the mutation operation.
  21596. func (m *LabelTaggingMutation) SetOp(op Op) {
  21597. m.op = op
  21598. }
  21599. // Type returns the node type of this mutation (LabelTagging).
  21600. func (m *LabelTaggingMutation) Type() string {
  21601. return m.typ
  21602. }
  21603. // Fields returns all fields that were changed during this mutation. Note that in
  21604. // order to get all numeric fields that were incremented/decremented, call
  21605. // AddedFields().
  21606. func (m *LabelTaggingMutation) Fields() []string {
  21607. fields := make([]string, 0, 9)
  21608. if m.created_at != nil {
  21609. fields = append(fields, labeltagging.FieldCreatedAt)
  21610. }
  21611. if m.updated_at != nil {
  21612. fields = append(fields, labeltagging.FieldUpdatedAt)
  21613. }
  21614. if m.status != nil {
  21615. fields = append(fields, labeltagging.FieldStatus)
  21616. }
  21617. if m.deleted_at != nil {
  21618. fields = append(fields, labeltagging.FieldDeletedAt)
  21619. }
  21620. if m.organization_id != nil {
  21621. fields = append(fields, labeltagging.FieldOrganizationID)
  21622. }
  21623. if m._type != nil {
  21624. fields = append(fields, labeltagging.FieldType)
  21625. }
  21626. if m.conditions != nil {
  21627. fields = append(fields, labeltagging.FieldConditions)
  21628. }
  21629. if m.action_label_add != nil {
  21630. fields = append(fields, labeltagging.FieldActionLabelAdd)
  21631. }
  21632. if m.action_label_del != nil {
  21633. fields = append(fields, labeltagging.FieldActionLabelDel)
  21634. }
  21635. return fields
  21636. }
  21637. // Field returns the value of a field with the given name. The second boolean
  21638. // return value indicates that this field was not set, or was not defined in the
  21639. // schema.
  21640. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  21641. switch name {
  21642. case labeltagging.FieldCreatedAt:
  21643. return m.CreatedAt()
  21644. case labeltagging.FieldUpdatedAt:
  21645. return m.UpdatedAt()
  21646. case labeltagging.FieldStatus:
  21647. return m.Status()
  21648. case labeltagging.FieldDeletedAt:
  21649. return m.DeletedAt()
  21650. case labeltagging.FieldOrganizationID:
  21651. return m.OrganizationID()
  21652. case labeltagging.FieldType:
  21653. return m.GetType()
  21654. case labeltagging.FieldConditions:
  21655. return m.Conditions()
  21656. case labeltagging.FieldActionLabelAdd:
  21657. return m.ActionLabelAdd()
  21658. case labeltagging.FieldActionLabelDel:
  21659. return m.ActionLabelDel()
  21660. }
  21661. return nil, false
  21662. }
  21663. // OldField returns the old value of the field from the database. An error is
  21664. // returned if the mutation operation is not UpdateOne, or the query to the
  21665. // database failed.
  21666. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21667. switch name {
  21668. case labeltagging.FieldCreatedAt:
  21669. return m.OldCreatedAt(ctx)
  21670. case labeltagging.FieldUpdatedAt:
  21671. return m.OldUpdatedAt(ctx)
  21672. case labeltagging.FieldStatus:
  21673. return m.OldStatus(ctx)
  21674. case labeltagging.FieldDeletedAt:
  21675. return m.OldDeletedAt(ctx)
  21676. case labeltagging.FieldOrganizationID:
  21677. return m.OldOrganizationID(ctx)
  21678. case labeltagging.FieldType:
  21679. return m.OldType(ctx)
  21680. case labeltagging.FieldConditions:
  21681. return m.OldConditions(ctx)
  21682. case labeltagging.FieldActionLabelAdd:
  21683. return m.OldActionLabelAdd(ctx)
  21684. case labeltagging.FieldActionLabelDel:
  21685. return m.OldActionLabelDel(ctx)
  21686. }
  21687. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  21688. }
  21689. // SetField sets the value of a field with the given name. It returns an error if
  21690. // the field is not defined in the schema, or if the type mismatched the field
  21691. // type.
  21692. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  21693. switch name {
  21694. case labeltagging.FieldCreatedAt:
  21695. v, ok := value.(time.Time)
  21696. if !ok {
  21697. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21698. }
  21699. m.SetCreatedAt(v)
  21700. return nil
  21701. case labeltagging.FieldUpdatedAt:
  21702. v, ok := value.(time.Time)
  21703. if !ok {
  21704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21705. }
  21706. m.SetUpdatedAt(v)
  21707. return nil
  21708. case labeltagging.FieldStatus:
  21709. v, ok := value.(uint8)
  21710. if !ok {
  21711. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21712. }
  21713. m.SetStatus(v)
  21714. return nil
  21715. case labeltagging.FieldDeletedAt:
  21716. v, ok := value.(time.Time)
  21717. if !ok {
  21718. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21719. }
  21720. m.SetDeletedAt(v)
  21721. return nil
  21722. case labeltagging.FieldOrganizationID:
  21723. v, ok := value.(uint64)
  21724. if !ok {
  21725. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21726. }
  21727. m.SetOrganizationID(v)
  21728. return nil
  21729. case labeltagging.FieldType:
  21730. v, ok := value.(int)
  21731. if !ok {
  21732. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21733. }
  21734. m.SetType(v)
  21735. return nil
  21736. case labeltagging.FieldConditions:
  21737. v, ok := value.(string)
  21738. if !ok {
  21739. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21740. }
  21741. m.SetConditions(v)
  21742. return nil
  21743. case labeltagging.FieldActionLabelAdd:
  21744. v, ok := value.([]uint64)
  21745. if !ok {
  21746. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21747. }
  21748. m.SetActionLabelAdd(v)
  21749. return nil
  21750. case labeltagging.FieldActionLabelDel:
  21751. v, ok := value.([]uint64)
  21752. if !ok {
  21753. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21754. }
  21755. m.SetActionLabelDel(v)
  21756. return nil
  21757. }
  21758. return fmt.Errorf("unknown LabelTagging field %s", name)
  21759. }
  21760. // AddedFields returns all numeric fields that were incremented/decremented during
  21761. // this mutation.
  21762. func (m *LabelTaggingMutation) AddedFields() []string {
  21763. var fields []string
  21764. if m.addstatus != nil {
  21765. fields = append(fields, labeltagging.FieldStatus)
  21766. }
  21767. if m.addorganization_id != nil {
  21768. fields = append(fields, labeltagging.FieldOrganizationID)
  21769. }
  21770. if m.add_type != nil {
  21771. fields = append(fields, labeltagging.FieldType)
  21772. }
  21773. return fields
  21774. }
  21775. // AddedField returns the numeric value that was incremented/decremented on a field
  21776. // with the given name. The second boolean return value indicates that this field
  21777. // was not set, or was not defined in the schema.
  21778. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  21779. switch name {
  21780. case labeltagging.FieldStatus:
  21781. return m.AddedStatus()
  21782. case labeltagging.FieldOrganizationID:
  21783. return m.AddedOrganizationID()
  21784. case labeltagging.FieldType:
  21785. return m.AddedType()
  21786. }
  21787. return nil, false
  21788. }
  21789. // AddField adds the value to the field with the given name. It returns an error if
  21790. // the field is not defined in the schema, or if the type mismatched the field
  21791. // type.
  21792. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  21793. switch name {
  21794. case labeltagging.FieldStatus:
  21795. v, ok := value.(int8)
  21796. if !ok {
  21797. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21798. }
  21799. m.AddStatus(v)
  21800. return nil
  21801. case labeltagging.FieldOrganizationID:
  21802. v, ok := value.(int64)
  21803. if !ok {
  21804. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21805. }
  21806. m.AddOrganizationID(v)
  21807. return nil
  21808. case labeltagging.FieldType:
  21809. v, ok := value.(int)
  21810. if !ok {
  21811. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21812. }
  21813. m.AddType(v)
  21814. return nil
  21815. }
  21816. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  21817. }
  21818. // ClearedFields returns all nullable fields that were cleared during this
  21819. // mutation.
  21820. func (m *LabelTaggingMutation) ClearedFields() []string {
  21821. var fields []string
  21822. if m.FieldCleared(labeltagging.FieldStatus) {
  21823. fields = append(fields, labeltagging.FieldStatus)
  21824. }
  21825. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  21826. fields = append(fields, labeltagging.FieldDeletedAt)
  21827. }
  21828. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  21829. fields = append(fields, labeltagging.FieldActionLabelAdd)
  21830. }
  21831. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  21832. fields = append(fields, labeltagging.FieldActionLabelDel)
  21833. }
  21834. return fields
  21835. }
  21836. // FieldCleared returns a boolean indicating if a field with the given name was
  21837. // cleared in this mutation.
  21838. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  21839. _, ok := m.clearedFields[name]
  21840. return ok
  21841. }
  21842. // ClearField clears the value of the field with the given name. It returns an
  21843. // error if the field is not defined in the schema.
  21844. func (m *LabelTaggingMutation) ClearField(name string) error {
  21845. switch name {
  21846. case labeltagging.FieldStatus:
  21847. m.ClearStatus()
  21848. return nil
  21849. case labeltagging.FieldDeletedAt:
  21850. m.ClearDeletedAt()
  21851. return nil
  21852. case labeltagging.FieldActionLabelAdd:
  21853. m.ClearActionLabelAdd()
  21854. return nil
  21855. case labeltagging.FieldActionLabelDel:
  21856. m.ClearActionLabelDel()
  21857. return nil
  21858. }
  21859. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  21860. }
  21861. // ResetField resets all changes in the mutation for the field with the given name.
  21862. // It returns an error if the field is not defined in the schema.
  21863. func (m *LabelTaggingMutation) ResetField(name string) error {
  21864. switch name {
  21865. case labeltagging.FieldCreatedAt:
  21866. m.ResetCreatedAt()
  21867. return nil
  21868. case labeltagging.FieldUpdatedAt:
  21869. m.ResetUpdatedAt()
  21870. return nil
  21871. case labeltagging.FieldStatus:
  21872. m.ResetStatus()
  21873. return nil
  21874. case labeltagging.FieldDeletedAt:
  21875. m.ResetDeletedAt()
  21876. return nil
  21877. case labeltagging.FieldOrganizationID:
  21878. m.ResetOrganizationID()
  21879. return nil
  21880. case labeltagging.FieldType:
  21881. m.ResetType()
  21882. return nil
  21883. case labeltagging.FieldConditions:
  21884. m.ResetConditions()
  21885. return nil
  21886. case labeltagging.FieldActionLabelAdd:
  21887. m.ResetActionLabelAdd()
  21888. return nil
  21889. case labeltagging.FieldActionLabelDel:
  21890. m.ResetActionLabelDel()
  21891. return nil
  21892. }
  21893. return fmt.Errorf("unknown LabelTagging field %s", name)
  21894. }
  21895. // AddedEdges returns all edge names that were set/added in this mutation.
  21896. func (m *LabelTaggingMutation) AddedEdges() []string {
  21897. edges := make([]string, 0, 0)
  21898. return edges
  21899. }
  21900. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21901. // name in this mutation.
  21902. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  21903. return nil
  21904. }
  21905. // RemovedEdges returns all edge names that were removed in this mutation.
  21906. func (m *LabelTaggingMutation) RemovedEdges() []string {
  21907. edges := make([]string, 0, 0)
  21908. return edges
  21909. }
  21910. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21911. // the given name in this mutation.
  21912. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  21913. return nil
  21914. }
  21915. // ClearedEdges returns all edge names that were cleared in this mutation.
  21916. func (m *LabelTaggingMutation) ClearedEdges() []string {
  21917. edges := make([]string, 0, 0)
  21918. return edges
  21919. }
  21920. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21921. // was cleared in this mutation.
  21922. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  21923. return false
  21924. }
  21925. // ClearEdge clears the value of the edge with the given name. It returns an error
  21926. // if that edge is not defined in the schema.
  21927. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  21928. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  21929. }
  21930. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21931. // It returns an error if the edge is not defined in the schema.
  21932. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  21933. return fmt.Errorf("unknown LabelTagging edge %s", name)
  21934. }
  21935. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  21936. type MessageMutation struct {
  21937. config
  21938. op Op
  21939. typ string
  21940. id *int
  21941. wx_wxid *string
  21942. wxid *string
  21943. content *string
  21944. clearedFields map[string]struct{}
  21945. done bool
  21946. oldValue func(context.Context) (*Message, error)
  21947. predicates []predicate.Message
  21948. }
  21949. var _ ent.Mutation = (*MessageMutation)(nil)
  21950. // messageOption allows management of the mutation configuration using functional options.
  21951. type messageOption func(*MessageMutation)
  21952. // newMessageMutation creates new mutation for the Message entity.
  21953. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  21954. m := &MessageMutation{
  21955. config: c,
  21956. op: op,
  21957. typ: TypeMessage,
  21958. clearedFields: make(map[string]struct{}),
  21959. }
  21960. for _, opt := range opts {
  21961. opt(m)
  21962. }
  21963. return m
  21964. }
  21965. // withMessageID sets the ID field of the mutation.
  21966. func withMessageID(id int) messageOption {
  21967. return func(m *MessageMutation) {
  21968. var (
  21969. err error
  21970. once sync.Once
  21971. value *Message
  21972. )
  21973. m.oldValue = func(ctx context.Context) (*Message, error) {
  21974. once.Do(func() {
  21975. if m.done {
  21976. err = errors.New("querying old values post mutation is not allowed")
  21977. } else {
  21978. value, err = m.Client().Message.Get(ctx, id)
  21979. }
  21980. })
  21981. return value, err
  21982. }
  21983. m.id = &id
  21984. }
  21985. }
  21986. // withMessage sets the old Message of the mutation.
  21987. func withMessage(node *Message) messageOption {
  21988. return func(m *MessageMutation) {
  21989. m.oldValue = func(context.Context) (*Message, error) {
  21990. return node, nil
  21991. }
  21992. m.id = &node.ID
  21993. }
  21994. }
  21995. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21996. // executed in a transaction (ent.Tx), a transactional client is returned.
  21997. func (m MessageMutation) Client() *Client {
  21998. client := &Client{config: m.config}
  21999. client.init()
  22000. return client
  22001. }
  22002. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22003. // it returns an error otherwise.
  22004. func (m MessageMutation) Tx() (*Tx, error) {
  22005. if _, ok := m.driver.(*txDriver); !ok {
  22006. return nil, errors.New("ent: mutation is not running in a transaction")
  22007. }
  22008. tx := &Tx{config: m.config}
  22009. tx.init()
  22010. return tx, nil
  22011. }
  22012. // ID returns the ID value in the mutation. Note that the ID is only available
  22013. // if it was provided to the builder or after it was returned from the database.
  22014. func (m *MessageMutation) ID() (id int, exists bool) {
  22015. if m.id == nil {
  22016. return
  22017. }
  22018. return *m.id, true
  22019. }
  22020. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22021. // That means, if the mutation is applied within a transaction with an isolation level such
  22022. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22023. // or updated by the mutation.
  22024. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  22025. switch {
  22026. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22027. id, exists := m.ID()
  22028. if exists {
  22029. return []int{id}, nil
  22030. }
  22031. fallthrough
  22032. case m.op.Is(OpUpdate | OpDelete):
  22033. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  22034. default:
  22035. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22036. }
  22037. }
  22038. // SetWxWxid sets the "wx_wxid" field.
  22039. func (m *MessageMutation) SetWxWxid(s string) {
  22040. m.wx_wxid = &s
  22041. }
  22042. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  22043. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  22044. v := m.wx_wxid
  22045. if v == nil {
  22046. return
  22047. }
  22048. return *v, true
  22049. }
  22050. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  22051. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  22052. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22053. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  22054. if !m.op.Is(OpUpdateOne) {
  22055. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  22056. }
  22057. if m.id == nil || m.oldValue == nil {
  22058. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  22059. }
  22060. oldValue, err := m.oldValue(ctx)
  22061. if err != nil {
  22062. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  22063. }
  22064. return oldValue.WxWxid, nil
  22065. }
  22066. // ClearWxWxid clears the value of the "wx_wxid" field.
  22067. func (m *MessageMutation) ClearWxWxid() {
  22068. m.wx_wxid = nil
  22069. m.clearedFields[message.FieldWxWxid] = struct{}{}
  22070. }
  22071. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  22072. func (m *MessageMutation) WxWxidCleared() bool {
  22073. _, ok := m.clearedFields[message.FieldWxWxid]
  22074. return ok
  22075. }
  22076. // ResetWxWxid resets all changes to the "wx_wxid" field.
  22077. func (m *MessageMutation) ResetWxWxid() {
  22078. m.wx_wxid = nil
  22079. delete(m.clearedFields, message.FieldWxWxid)
  22080. }
  22081. // SetWxid sets the "wxid" field.
  22082. func (m *MessageMutation) SetWxid(s string) {
  22083. m.wxid = &s
  22084. }
  22085. // Wxid returns the value of the "wxid" field in the mutation.
  22086. func (m *MessageMutation) Wxid() (r string, exists bool) {
  22087. v := m.wxid
  22088. if v == nil {
  22089. return
  22090. }
  22091. return *v, true
  22092. }
  22093. // OldWxid returns the old "wxid" field's value of the Message entity.
  22094. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  22095. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22096. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  22097. if !m.op.Is(OpUpdateOne) {
  22098. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  22099. }
  22100. if m.id == nil || m.oldValue == nil {
  22101. return v, errors.New("OldWxid requires an ID field in the mutation")
  22102. }
  22103. oldValue, err := m.oldValue(ctx)
  22104. if err != nil {
  22105. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  22106. }
  22107. return oldValue.Wxid, nil
  22108. }
  22109. // ResetWxid resets all changes to the "wxid" field.
  22110. func (m *MessageMutation) ResetWxid() {
  22111. m.wxid = nil
  22112. }
  22113. // SetContent sets the "content" field.
  22114. func (m *MessageMutation) SetContent(s string) {
  22115. m.content = &s
  22116. }
  22117. // Content returns the value of the "content" field in the mutation.
  22118. func (m *MessageMutation) Content() (r string, exists bool) {
  22119. v := m.content
  22120. if v == nil {
  22121. return
  22122. }
  22123. return *v, true
  22124. }
  22125. // OldContent returns the old "content" field's value of the Message entity.
  22126. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  22127. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22128. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  22129. if !m.op.Is(OpUpdateOne) {
  22130. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  22131. }
  22132. if m.id == nil || m.oldValue == nil {
  22133. return v, errors.New("OldContent requires an ID field in the mutation")
  22134. }
  22135. oldValue, err := m.oldValue(ctx)
  22136. if err != nil {
  22137. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  22138. }
  22139. return oldValue.Content, nil
  22140. }
  22141. // ResetContent resets all changes to the "content" field.
  22142. func (m *MessageMutation) ResetContent() {
  22143. m.content = nil
  22144. }
  22145. // Where appends a list predicates to the MessageMutation builder.
  22146. func (m *MessageMutation) Where(ps ...predicate.Message) {
  22147. m.predicates = append(m.predicates, ps...)
  22148. }
  22149. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  22150. // users can use type-assertion to append predicates that do not depend on any generated package.
  22151. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  22152. p := make([]predicate.Message, len(ps))
  22153. for i := range ps {
  22154. p[i] = ps[i]
  22155. }
  22156. m.Where(p...)
  22157. }
  22158. // Op returns the operation name.
  22159. func (m *MessageMutation) Op() Op {
  22160. return m.op
  22161. }
  22162. // SetOp allows setting the mutation operation.
  22163. func (m *MessageMutation) SetOp(op Op) {
  22164. m.op = op
  22165. }
  22166. // Type returns the node type of this mutation (Message).
  22167. func (m *MessageMutation) Type() string {
  22168. return m.typ
  22169. }
  22170. // Fields returns all fields that were changed during this mutation. Note that in
  22171. // order to get all numeric fields that were incremented/decremented, call
  22172. // AddedFields().
  22173. func (m *MessageMutation) Fields() []string {
  22174. fields := make([]string, 0, 3)
  22175. if m.wx_wxid != nil {
  22176. fields = append(fields, message.FieldWxWxid)
  22177. }
  22178. if m.wxid != nil {
  22179. fields = append(fields, message.FieldWxid)
  22180. }
  22181. if m.content != nil {
  22182. fields = append(fields, message.FieldContent)
  22183. }
  22184. return fields
  22185. }
  22186. // Field returns the value of a field with the given name. The second boolean
  22187. // return value indicates that this field was not set, or was not defined in the
  22188. // schema.
  22189. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  22190. switch name {
  22191. case message.FieldWxWxid:
  22192. return m.WxWxid()
  22193. case message.FieldWxid:
  22194. return m.Wxid()
  22195. case message.FieldContent:
  22196. return m.Content()
  22197. }
  22198. return nil, false
  22199. }
  22200. // OldField returns the old value of the field from the database. An error is
  22201. // returned if the mutation operation is not UpdateOne, or the query to the
  22202. // database failed.
  22203. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22204. switch name {
  22205. case message.FieldWxWxid:
  22206. return m.OldWxWxid(ctx)
  22207. case message.FieldWxid:
  22208. return m.OldWxid(ctx)
  22209. case message.FieldContent:
  22210. return m.OldContent(ctx)
  22211. }
  22212. return nil, fmt.Errorf("unknown Message field %s", name)
  22213. }
  22214. // SetField sets the value of a field with the given name. It returns an error if
  22215. // the field is not defined in the schema, or if the type mismatched the field
  22216. // type.
  22217. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  22218. switch name {
  22219. case message.FieldWxWxid:
  22220. v, ok := value.(string)
  22221. if !ok {
  22222. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22223. }
  22224. m.SetWxWxid(v)
  22225. return nil
  22226. case message.FieldWxid:
  22227. v, ok := value.(string)
  22228. if !ok {
  22229. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22230. }
  22231. m.SetWxid(v)
  22232. return nil
  22233. case message.FieldContent:
  22234. v, ok := value.(string)
  22235. if !ok {
  22236. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22237. }
  22238. m.SetContent(v)
  22239. return nil
  22240. }
  22241. return fmt.Errorf("unknown Message field %s", name)
  22242. }
  22243. // AddedFields returns all numeric fields that were incremented/decremented during
  22244. // this mutation.
  22245. func (m *MessageMutation) AddedFields() []string {
  22246. return nil
  22247. }
  22248. // AddedField returns the numeric value that was incremented/decremented on a field
  22249. // with the given name. The second boolean return value indicates that this field
  22250. // was not set, or was not defined in the schema.
  22251. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  22252. return nil, false
  22253. }
  22254. // AddField adds the value to the field with the given name. It returns an error if
  22255. // the field is not defined in the schema, or if the type mismatched the field
  22256. // type.
  22257. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  22258. switch name {
  22259. }
  22260. return fmt.Errorf("unknown Message numeric field %s", name)
  22261. }
  22262. // ClearedFields returns all nullable fields that were cleared during this
  22263. // mutation.
  22264. func (m *MessageMutation) ClearedFields() []string {
  22265. var fields []string
  22266. if m.FieldCleared(message.FieldWxWxid) {
  22267. fields = append(fields, message.FieldWxWxid)
  22268. }
  22269. return fields
  22270. }
  22271. // FieldCleared returns a boolean indicating if a field with the given name was
  22272. // cleared in this mutation.
  22273. func (m *MessageMutation) FieldCleared(name string) bool {
  22274. _, ok := m.clearedFields[name]
  22275. return ok
  22276. }
  22277. // ClearField clears the value of the field with the given name. It returns an
  22278. // error if the field is not defined in the schema.
  22279. func (m *MessageMutation) ClearField(name string) error {
  22280. switch name {
  22281. case message.FieldWxWxid:
  22282. m.ClearWxWxid()
  22283. return nil
  22284. }
  22285. return fmt.Errorf("unknown Message nullable field %s", name)
  22286. }
  22287. // ResetField resets all changes in the mutation for the field with the given name.
  22288. // It returns an error if the field is not defined in the schema.
  22289. func (m *MessageMutation) ResetField(name string) error {
  22290. switch name {
  22291. case message.FieldWxWxid:
  22292. m.ResetWxWxid()
  22293. return nil
  22294. case message.FieldWxid:
  22295. m.ResetWxid()
  22296. return nil
  22297. case message.FieldContent:
  22298. m.ResetContent()
  22299. return nil
  22300. }
  22301. return fmt.Errorf("unknown Message field %s", name)
  22302. }
  22303. // AddedEdges returns all edge names that were set/added in this mutation.
  22304. func (m *MessageMutation) AddedEdges() []string {
  22305. edges := make([]string, 0, 0)
  22306. return edges
  22307. }
  22308. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22309. // name in this mutation.
  22310. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  22311. return nil
  22312. }
  22313. // RemovedEdges returns all edge names that were removed in this mutation.
  22314. func (m *MessageMutation) RemovedEdges() []string {
  22315. edges := make([]string, 0, 0)
  22316. return edges
  22317. }
  22318. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22319. // the given name in this mutation.
  22320. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  22321. return nil
  22322. }
  22323. // ClearedEdges returns all edge names that were cleared in this mutation.
  22324. func (m *MessageMutation) ClearedEdges() []string {
  22325. edges := make([]string, 0, 0)
  22326. return edges
  22327. }
  22328. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22329. // was cleared in this mutation.
  22330. func (m *MessageMutation) EdgeCleared(name string) bool {
  22331. return false
  22332. }
  22333. // ClearEdge clears the value of the edge with the given name. It returns an error
  22334. // if that edge is not defined in the schema.
  22335. func (m *MessageMutation) ClearEdge(name string) error {
  22336. return fmt.Errorf("unknown Message unique edge %s", name)
  22337. }
  22338. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22339. // It returns an error if the edge is not defined in the schema.
  22340. func (m *MessageMutation) ResetEdge(name string) error {
  22341. return fmt.Errorf("unknown Message edge %s", name)
  22342. }
  22343. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  22344. type MessageRecordsMutation struct {
  22345. config
  22346. op Op
  22347. typ string
  22348. id *uint64
  22349. created_at *time.Time
  22350. updated_at *time.Time
  22351. status *uint8
  22352. addstatus *int8
  22353. bot_wxid *string
  22354. contact_type *int
  22355. addcontact_type *int
  22356. contact_wxid *string
  22357. content_type *int
  22358. addcontent_type *int
  22359. content *string
  22360. meta *custom_types.Meta
  22361. error_detail *string
  22362. send_time *time.Time
  22363. source_type *int
  22364. addsource_type *int
  22365. organization_id *uint64
  22366. addorganization_id *int64
  22367. clearedFields map[string]struct{}
  22368. sop_stage *uint64
  22369. clearedsop_stage bool
  22370. sop_node *uint64
  22371. clearedsop_node bool
  22372. message_contact *uint64
  22373. clearedmessage_contact bool
  22374. done bool
  22375. oldValue func(context.Context) (*MessageRecords, error)
  22376. predicates []predicate.MessageRecords
  22377. }
  22378. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  22379. // messagerecordsOption allows management of the mutation configuration using functional options.
  22380. type messagerecordsOption func(*MessageRecordsMutation)
  22381. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  22382. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  22383. m := &MessageRecordsMutation{
  22384. config: c,
  22385. op: op,
  22386. typ: TypeMessageRecords,
  22387. clearedFields: make(map[string]struct{}),
  22388. }
  22389. for _, opt := range opts {
  22390. opt(m)
  22391. }
  22392. return m
  22393. }
  22394. // withMessageRecordsID sets the ID field of the mutation.
  22395. func withMessageRecordsID(id uint64) messagerecordsOption {
  22396. return func(m *MessageRecordsMutation) {
  22397. var (
  22398. err error
  22399. once sync.Once
  22400. value *MessageRecords
  22401. )
  22402. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  22403. once.Do(func() {
  22404. if m.done {
  22405. err = errors.New("querying old values post mutation is not allowed")
  22406. } else {
  22407. value, err = m.Client().MessageRecords.Get(ctx, id)
  22408. }
  22409. })
  22410. return value, err
  22411. }
  22412. m.id = &id
  22413. }
  22414. }
  22415. // withMessageRecords sets the old MessageRecords of the mutation.
  22416. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  22417. return func(m *MessageRecordsMutation) {
  22418. m.oldValue = func(context.Context) (*MessageRecords, error) {
  22419. return node, nil
  22420. }
  22421. m.id = &node.ID
  22422. }
  22423. }
  22424. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22425. // executed in a transaction (ent.Tx), a transactional client is returned.
  22426. func (m MessageRecordsMutation) Client() *Client {
  22427. client := &Client{config: m.config}
  22428. client.init()
  22429. return client
  22430. }
  22431. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22432. // it returns an error otherwise.
  22433. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  22434. if _, ok := m.driver.(*txDriver); !ok {
  22435. return nil, errors.New("ent: mutation is not running in a transaction")
  22436. }
  22437. tx := &Tx{config: m.config}
  22438. tx.init()
  22439. return tx, nil
  22440. }
  22441. // SetID sets the value of the id field. Note that this
  22442. // operation is only accepted on creation of MessageRecords entities.
  22443. func (m *MessageRecordsMutation) SetID(id uint64) {
  22444. m.id = &id
  22445. }
  22446. // ID returns the ID value in the mutation. Note that the ID is only available
  22447. // if it was provided to the builder or after it was returned from the database.
  22448. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  22449. if m.id == nil {
  22450. return
  22451. }
  22452. return *m.id, true
  22453. }
  22454. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22455. // That means, if the mutation is applied within a transaction with an isolation level such
  22456. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22457. // or updated by the mutation.
  22458. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  22459. switch {
  22460. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22461. id, exists := m.ID()
  22462. if exists {
  22463. return []uint64{id}, nil
  22464. }
  22465. fallthrough
  22466. case m.op.Is(OpUpdate | OpDelete):
  22467. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  22468. default:
  22469. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22470. }
  22471. }
  22472. // SetCreatedAt sets the "created_at" field.
  22473. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  22474. m.created_at = &t
  22475. }
  22476. // CreatedAt returns the value of the "created_at" field in the mutation.
  22477. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  22478. v := m.created_at
  22479. if v == nil {
  22480. return
  22481. }
  22482. return *v, true
  22483. }
  22484. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  22485. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22486. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22487. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22488. if !m.op.Is(OpUpdateOne) {
  22489. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22490. }
  22491. if m.id == nil || m.oldValue == nil {
  22492. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22493. }
  22494. oldValue, err := m.oldValue(ctx)
  22495. if err != nil {
  22496. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22497. }
  22498. return oldValue.CreatedAt, nil
  22499. }
  22500. // ResetCreatedAt resets all changes to the "created_at" field.
  22501. func (m *MessageRecordsMutation) ResetCreatedAt() {
  22502. m.created_at = nil
  22503. }
  22504. // SetUpdatedAt sets the "updated_at" field.
  22505. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  22506. m.updated_at = &t
  22507. }
  22508. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22509. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  22510. v := m.updated_at
  22511. if v == nil {
  22512. return
  22513. }
  22514. return *v, true
  22515. }
  22516. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  22517. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22518. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22519. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22520. if !m.op.Is(OpUpdateOne) {
  22521. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22522. }
  22523. if m.id == nil || m.oldValue == nil {
  22524. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22525. }
  22526. oldValue, err := m.oldValue(ctx)
  22527. if err != nil {
  22528. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22529. }
  22530. return oldValue.UpdatedAt, nil
  22531. }
  22532. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22533. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  22534. m.updated_at = nil
  22535. }
  22536. // SetStatus sets the "status" field.
  22537. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  22538. m.status = &u
  22539. m.addstatus = nil
  22540. }
  22541. // Status returns the value of the "status" field in the mutation.
  22542. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  22543. v := m.status
  22544. if v == nil {
  22545. return
  22546. }
  22547. return *v, true
  22548. }
  22549. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  22550. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22551. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22552. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22553. if !m.op.Is(OpUpdateOne) {
  22554. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22555. }
  22556. if m.id == nil || m.oldValue == nil {
  22557. return v, errors.New("OldStatus requires an ID field in the mutation")
  22558. }
  22559. oldValue, err := m.oldValue(ctx)
  22560. if err != nil {
  22561. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22562. }
  22563. return oldValue.Status, nil
  22564. }
  22565. // AddStatus adds u to the "status" field.
  22566. func (m *MessageRecordsMutation) AddStatus(u int8) {
  22567. if m.addstatus != nil {
  22568. *m.addstatus += u
  22569. } else {
  22570. m.addstatus = &u
  22571. }
  22572. }
  22573. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22574. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  22575. v := m.addstatus
  22576. if v == nil {
  22577. return
  22578. }
  22579. return *v, true
  22580. }
  22581. // ClearStatus clears the value of the "status" field.
  22582. func (m *MessageRecordsMutation) ClearStatus() {
  22583. m.status = nil
  22584. m.addstatus = nil
  22585. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  22586. }
  22587. // StatusCleared returns if the "status" field was cleared in this mutation.
  22588. func (m *MessageRecordsMutation) StatusCleared() bool {
  22589. _, ok := m.clearedFields[messagerecords.FieldStatus]
  22590. return ok
  22591. }
  22592. // ResetStatus resets all changes to the "status" field.
  22593. func (m *MessageRecordsMutation) ResetStatus() {
  22594. m.status = nil
  22595. m.addstatus = nil
  22596. delete(m.clearedFields, messagerecords.FieldStatus)
  22597. }
  22598. // SetBotWxid sets the "bot_wxid" field.
  22599. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  22600. m.bot_wxid = &s
  22601. }
  22602. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  22603. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  22604. v := m.bot_wxid
  22605. if v == nil {
  22606. return
  22607. }
  22608. return *v, true
  22609. }
  22610. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  22611. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22612. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22613. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  22614. if !m.op.Is(OpUpdateOne) {
  22615. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  22616. }
  22617. if m.id == nil || m.oldValue == nil {
  22618. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  22619. }
  22620. oldValue, err := m.oldValue(ctx)
  22621. if err != nil {
  22622. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  22623. }
  22624. return oldValue.BotWxid, nil
  22625. }
  22626. // ResetBotWxid resets all changes to the "bot_wxid" field.
  22627. func (m *MessageRecordsMutation) ResetBotWxid() {
  22628. m.bot_wxid = nil
  22629. }
  22630. // SetContactID sets the "contact_id" field.
  22631. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  22632. m.message_contact = &u
  22633. }
  22634. // ContactID returns the value of the "contact_id" field in the mutation.
  22635. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  22636. v := m.message_contact
  22637. if v == nil {
  22638. return
  22639. }
  22640. return *v, true
  22641. }
  22642. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  22643. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22644. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22645. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  22646. if !m.op.Is(OpUpdateOne) {
  22647. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  22648. }
  22649. if m.id == nil || m.oldValue == nil {
  22650. return v, errors.New("OldContactID requires an ID field in the mutation")
  22651. }
  22652. oldValue, err := m.oldValue(ctx)
  22653. if err != nil {
  22654. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  22655. }
  22656. return oldValue.ContactID, nil
  22657. }
  22658. // ClearContactID clears the value of the "contact_id" field.
  22659. func (m *MessageRecordsMutation) ClearContactID() {
  22660. m.message_contact = nil
  22661. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  22662. }
  22663. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  22664. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  22665. _, ok := m.clearedFields[messagerecords.FieldContactID]
  22666. return ok
  22667. }
  22668. // ResetContactID resets all changes to the "contact_id" field.
  22669. func (m *MessageRecordsMutation) ResetContactID() {
  22670. m.message_contact = nil
  22671. delete(m.clearedFields, messagerecords.FieldContactID)
  22672. }
  22673. // SetContactType sets the "contact_type" field.
  22674. func (m *MessageRecordsMutation) SetContactType(i int) {
  22675. m.contact_type = &i
  22676. m.addcontact_type = nil
  22677. }
  22678. // ContactType returns the value of the "contact_type" field in the mutation.
  22679. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  22680. v := m.contact_type
  22681. if v == nil {
  22682. return
  22683. }
  22684. return *v, true
  22685. }
  22686. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  22687. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22688. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22689. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  22690. if !m.op.Is(OpUpdateOne) {
  22691. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  22692. }
  22693. if m.id == nil || m.oldValue == nil {
  22694. return v, errors.New("OldContactType requires an ID field in the mutation")
  22695. }
  22696. oldValue, err := m.oldValue(ctx)
  22697. if err != nil {
  22698. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  22699. }
  22700. return oldValue.ContactType, nil
  22701. }
  22702. // AddContactType adds i to the "contact_type" field.
  22703. func (m *MessageRecordsMutation) AddContactType(i int) {
  22704. if m.addcontact_type != nil {
  22705. *m.addcontact_type += i
  22706. } else {
  22707. m.addcontact_type = &i
  22708. }
  22709. }
  22710. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  22711. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  22712. v := m.addcontact_type
  22713. if v == nil {
  22714. return
  22715. }
  22716. return *v, true
  22717. }
  22718. // ResetContactType resets all changes to the "contact_type" field.
  22719. func (m *MessageRecordsMutation) ResetContactType() {
  22720. m.contact_type = nil
  22721. m.addcontact_type = nil
  22722. }
  22723. // SetContactWxid sets the "contact_wxid" field.
  22724. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  22725. m.contact_wxid = &s
  22726. }
  22727. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  22728. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  22729. v := m.contact_wxid
  22730. if v == nil {
  22731. return
  22732. }
  22733. return *v, true
  22734. }
  22735. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  22736. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22737. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22738. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  22739. if !m.op.Is(OpUpdateOne) {
  22740. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  22741. }
  22742. if m.id == nil || m.oldValue == nil {
  22743. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  22744. }
  22745. oldValue, err := m.oldValue(ctx)
  22746. if err != nil {
  22747. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  22748. }
  22749. return oldValue.ContactWxid, nil
  22750. }
  22751. // ResetContactWxid resets all changes to the "contact_wxid" field.
  22752. func (m *MessageRecordsMutation) ResetContactWxid() {
  22753. m.contact_wxid = nil
  22754. }
  22755. // SetContentType sets the "content_type" field.
  22756. func (m *MessageRecordsMutation) SetContentType(i int) {
  22757. m.content_type = &i
  22758. m.addcontent_type = nil
  22759. }
  22760. // ContentType returns the value of the "content_type" field in the mutation.
  22761. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  22762. v := m.content_type
  22763. if v == nil {
  22764. return
  22765. }
  22766. return *v, true
  22767. }
  22768. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  22769. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22770. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22771. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  22772. if !m.op.Is(OpUpdateOne) {
  22773. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  22774. }
  22775. if m.id == nil || m.oldValue == nil {
  22776. return v, errors.New("OldContentType requires an ID field in the mutation")
  22777. }
  22778. oldValue, err := m.oldValue(ctx)
  22779. if err != nil {
  22780. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  22781. }
  22782. return oldValue.ContentType, nil
  22783. }
  22784. // AddContentType adds i to the "content_type" field.
  22785. func (m *MessageRecordsMutation) AddContentType(i int) {
  22786. if m.addcontent_type != nil {
  22787. *m.addcontent_type += i
  22788. } else {
  22789. m.addcontent_type = &i
  22790. }
  22791. }
  22792. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  22793. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  22794. v := m.addcontent_type
  22795. if v == nil {
  22796. return
  22797. }
  22798. return *v, true
  22799. }
  22800. // ResetContentType resets all changes to the "content_type" field.
  22801. func (m *MessageRecordsMutation) ResetContentType() {
  22802. m.content_type = nil
  22803. m.addcontent_type = nil
  22804. }
  22805. // SetContent sets the "content" field.
  22806. func (m *MessageRecordsMutation) SetContent(s string) {
  22807. m.content = &s
  22808. }
  22809. // Content returns the value of the "content" field in the mutation.
  22810. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  22811. v := m.content
  22812. if v == nil {
  22813. return
  22814. }
  22815. return *v, true
  22816. }
  22817. // OldContent returns the old "content" field's value of the MessageRecords entity.
  22818. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22819. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22820. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  22821. if !m.op.Is(OpUpdateOne) {
  22822. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  22823. }
  22824. if m.id == nil || m.oldValue == nil {
  22825. return v, errors.New("OldContent requires an ID field in the mutation")
  22826. }
  22827. oldValue, err := m.oldValue(ctx)
  22828. if err != nil {
  22829. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  22830. }
  22831. return oldValue.Content, nil
  22832. }
  22833. // ResetContent resets all changes to the "content" field.
  22834. func (m *MessageRecordsMutation) ResetContent() {
  22835. m.content = nil
  22836. }
  22837. // SetMeta sets the "meta" field.
  22838. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  22839. m.meta = &ct
  22840. }
  22841. // Meta returns the value of the "meta" field in the mutation.
  22842. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  22843. v := m.meta
  22844. if v == nil {
  22845. return
  22846. }
  22847. return *v, true
  22848. }
  22849. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  22850. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22851. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22852. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  22853. if !m.op.Is(OpUpdateOne) {
  22854. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  22855. }
  22856. if m.id == nil || m.oldValue == nil {
  22857. return v, errors.New("OldMeta requires an ID field in the mutation")
  22858. }
  22859. oldValue, err := m.oldValue(ctx)
  22860. if err != nil {
  22861. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  22862. }
  22863. return oldValue.Meta, nil
  22864. }
  22865. // ClearMeta clears the value of the "meta" field.
  22866. func (m *MessageRecordsMutation) ClearMeta() {
  22867. m.meta = nil
  22868. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  22869. }
  22870. // MetaCleared returns if the "meta" field was cleared in this mutation.
  22871. func (m *MessageRecordsMutation) MetaCleared() bool {
  22872. _, ok := m.clearedFields[messagerecords.FieldMeta]
  22873. return ok
  22874. }
  22875. // ResetMeta resets all changes to the "meta" field.
  22876. func (m *MessageRecordsMutation) ResetMeta() {
  22877. m.meta = nil
  22878. delete(m.clearedFields, messagerecords.FieldMeta)
  22879. }
  22880. // SetErrorDetail sets the "error_detail" field.
  22881. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  22882. m.error_detail = &s
  22883. }
  22884. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  22885. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  22886. v := m.error_detail
  22887. if v == nil {
  22888. return
  22889. }
  22890. return *v, true
  22891. }
  22892. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  22893. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22894. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22895. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  22896. if !m.op.Is(OpUpdateOne) {
  22897. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  22898. }
  22899. if m.id == nil || m.oldValue == nil {
  22900. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  22901. }
  22902. oldValue, err := m.oldValue(ctx)
  22903. if err != nil {
  22904. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  22905. }
  22906. return oldValue.ErrorDetail, nil
  22907. }
  22908. // ResetErrorDetail resets all changes to the "error_detail" field.
  22909. func (m *MessageRecordsMutation) ResetErrorDetail() {
  22910. m.error_detail = nil
  22911. }
  22912. // SetSendTime sets the "send_time" field.
  22913. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  22914. m.send_time = &t
  22915. }
  22916. // SendTime returns the value of the "send_time" field in the mutation.
  22917. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  22918. v := m.send_time
  22919. if v == nil {
  22920. return
  22921. }
  22922. return *v, true
  22923. }
  22924. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  22925. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22926. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22927. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  22928. if !m.op.Is(OpUpdateOne) {
  22929. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  22930. }
  22931. if m.id == nil || m.oldValue == nil {
  22932. return v, errors.New("OldSendTime requires an ID field in the mutation")
  22933. }
  22934. oldValue, err := m.oldValue(ctx)
  22935. if err != nil {
  22936. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  22937. }
  22938. return oldValue.SendTime, nil
  22939. }
  22940. // ClearSendTime clears the value of the "send_time" field.
  22941. func (m *MessageRecordsMutation) ClearSendTime() {
  22942. m.send_time = nil
  22943. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  22944. }
  22945. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  22946. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  22947. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  22948. return ok
  22949. }
  22950. // ResetSendTime resets all changes to the "send_time" field.
  22951. func (m *MessageRecordsMutation) ResetSendTime() {
  22952. m.send_time = nil
  22953. delete(m.clearedFields, messagerecords.FieldSendTime)
  22954. }
  22955. // SetSourceType sets the "source_type" field.
  22956. func (m *MessageRecordsMutation) SetSourceType(i int) {
  22957. m.source_type = &i
  22958. m.addsource_type = nil
  22959. }
  22960. // SourceType returns the value of the "source_type" field in the mutation.
  22961. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  22962. v := m.source_type
  22963. if v == nil {
  22964. return
  22965. }
  22966. return *v, true
  22967. }
  22968. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  22969. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22970. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22971. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  22972. if !m.op.Is(OpUpdateOne) {
  22973. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  22974. }
  22975. if m.id == nil || m.oldValue == nil {
  22976. return v, errors.New("OldSourceType requires an ID field in the mutation")
  22977. }
  22978. oldValue, err := m.oldValue(ctx)
  22979. if err != nil {
  22980. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  22981. }
  22982. return oldValue.SourceType, nil
  22983. }
  22984. // AddSourceType adds i to the "source_type" field.
  22985. func (m *MessageRecordsMutation) AddSourceType(i int) {
  22986. if m.addsource_type != nil {
  22987. *m.addsource_type += i
  22988. } else {
  22989. m.addsource_type = &i
  22990. }
  22991. }
  22992. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  22993. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  22994. v := m.addsource_type
  22995. if v == nil {
  22996. return
  22997. }
  22998. return *v, true
  22999. }
  23000. // ResetSourceType resets all changes to the "source_type" field.
  23001. func (m *MessageRecordsMutation) ResetSourceType() {
  23002. m.source_type = nil
  23003. m.addsource_type = nil
  23004. }
  23005. // SetSourceID sets the "source_id" field.
  23006. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  23007. m.sop_stage = &u
  23008. }
  23009. // SourceID returns the value of the "source_id" field in the mutation.
  23010. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  23011. v := m.sop_stage
  23012. if v == nil {
  23013. return
  23014. }
  23015. return *v, true
  23016. }
  23017. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  23018. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  23019. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23020. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  23021. if !m.op.Is(OpUpdateOne) {
  23022. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  23023. }
  23024. if m.id == nil || m.oldValue == nil {
  23025. return v, errors.New("OldSourceID requires an ID field in the mutation")
  23026. }
  23027. oldValue, err := m.oldValue(ctx)
  23028. if err != nil {
  23029. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  23030. }
  23031. return oldValue.SourceID, nil
  23032. }
  23033. // ClearSourceID clears the value of the "source_id" field.
  23034. func (m *MessageRecordsMutation) ClearSourceID() {
  23035. m.sop_stage = nil
  23036. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  23037. }
  23038. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  23039. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  23040. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  23041. return ok
  23042. }
  23043. // ResetSourceID resets all changes to the "source_id" field.
  23044. func (m *MessageRecordsMutation) ResetSourceID() {
  23045. m.sop_stage = nil
  23046. delete(m.clearedFields, messagerecords.FieldSourceID)
  23047. }
  23048. // SetSubSourceID sets the "sub_source_id" field.
  23049. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  23050. m.sop_node = &u
  23051. }
  23052. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  23053. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  23054. v := m.sop_node
  23055. if v == nil {
  23056. return
  23057. }
  23058. return *v, true
  23059. }
  23060. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  23061. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  23062. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23063. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  23064. if !m.op.Is(OpUpdateOne) {
  23065. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  23066. }
  23067. if m.id == nil || m.oldValue == nil {
  23068. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  23069. }
  23070. oldValue, err := m.oldValue(ctx)
  23071. if err != nil {
  23072. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  23073. }
  23074. return oldValue.SubSourceID, nil
  23075. }
  23076. // ClearSubSourceID clears the value of the "sub_source_id" field.
  23077. func (m *MessageRecordsMutation) ClearSubSourceID() {
  23078. m.sop_node = nil
  23079. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  23080. }
  23081. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  23082. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  23083. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  23084. return ok
  23085. }
  23086. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  23087. func (m *MessageRecordsMutation) ResetSubSourceID() {
  23088. m.sop_node = nil
  23089. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  23090. }
  23091. // SetOrganizationID sets the "organization_id" field.
  23092. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  23093. m.organization_id = &u
  23094. m.addorganization_id = nil
  23095. }
  23096. // OrganizationID returns the value of the "organization_id" field in the mutation.
  23097. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  23098. v := m.organization_id
  23099. if v == nil {
  23100. return
  23101. }
  23102. return *v, true
  23103. }
  23104. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  23105. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  23106. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23107. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  23108. if !m.op.Is(OpUpdateOne) {
  23109. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  23110. }
  23111. if m.id == nil || m.oldValue == nil {
  23112. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  23113. }
  23114. oldValue, err := m.oldValue(ctx)
  23115. if err != nil {
  23116. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  23117. }
  23118. return oldValue.OrganizationID, nil
  23119. }
  23120. // AddOrganizationID adds u to the "organization_id" field.
  23121. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  23122. if m.addorganization_id != nil {
  23123. *m.addorganization_id += u
  23124. } else {
  23125. m.addorganization_id = &u
  23126. }
  23127. }
  23128. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  23129. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  23130. v := m.addorganization_id
  23131. if v == nil {
  23132. return
  23133. }
  23134. return *v, true
  23135. }
  23136. // ClearOrganizationID clears the value of the "organization_id" field.
  23137. func (m *MessageRecordsMutation) ClearOrganizationID() {
  23138. m.organization_id = nil
  23139. m.addorganization_id = nil
  23140. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  23141. }
  23142. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  23143. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  23144. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  23145. return ok
  23146. }
  23147. // ResetOrganizationID resets all changes to the "organization_id" field.
  23148. func (m *MessageRecordsMutation) ResetOrganizationID() {
  23149. m.organization_id = nil
  23150. m.addorganization_id = nil
  23151. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  23152. }
  23153. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  23154. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  23155. m.sop_stage = &id
  23156. }
  23157. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  23158. func (m *MessageRecordsMutation) ClearSopStage() {
  23159. m.clearedsop_stage = true
  23160. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  23161. }
  23162. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  23163. func (m *MessageRecordsMutation) SopStageCleared() bool {
  23164. return m.SourceIDCleared() || m.clearedsop_stage
  23165. }
  23166. // SopStageID returns the "sop_stage" edge ID in the mutation.
  23167. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  23168. if m.sop_stage != nil {
  23169. return *m.sop_stage, true
  23170. }
  23171. return
  23172. }
  23173. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  23174. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  23175. // SopStageID instead. It exists only for internal usage by the builders.
  23176. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  23177. if id := m.sop_stage; id != nil {
  23178. ids = append(ids, *id)
  23179. }
  23180. return
  23181. }
  23182. // ResetSopStage resets all changes to the "sop_stage" edge.
  23183. func (m *MessageRecordsMutation) ResetSopStage() {
  23184. m.sop_stage = nil
  23185. m.clearedsop_stage = false
  23186. }
  23187. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  23188. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  23189. m.sop_node = &id
  23190. }
  23191. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  23192. func (m *MessageRecordsMutation) ClearSopNode() {
  23193. m.clearedsop_node = true
  23194. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  23195. }
  23196. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  23197. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  23198. return m.SubSourceIDCleared() || m.clearedsop_node
  23199. }
  23200. // SopNodeID returns the "sop_node" edge ID in the mutation.
  23201. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  23202. if m.sop_node != nil {
  23203. return *m.sop_node, true
  23204. }
  23205. return
  23206. }
  23207. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  23208. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  23209. // SopNodeID instead. It exists only for internal usage by the builders.
  23210. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  23211. if id := m.sop_node; id != nil {
  23212. ids = append(ids, *id)
  23213. }
  23214. return
  23215. }
  23216. // ResetSopNode resets all changes to the "sop_node" edge.
  23217. func (m *MessageRecordsMutation) ResetSopNode() {
  23218. m.sop_node = nil
  23219. m.clearedsop_node = false
  23220. }
  23221. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  23222. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  23223. m.message_contact = &id
  23224. }
  23225. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  23226. func (m *MessageRecordsMutation) ClearMessageContact() {
  23227. m.clearedmessage_contact = true
  23228. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  23229. }
  23230. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  23231. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  23232. return m.ContactIDCleared() || m.clearedmessage_contact
  23233. }
  23234. // MessageContactID returns the "message_contact" edge ID in the mutation.
  23235. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  23236. if m.message_contact != nil {
  23237. return *m.message_contact, true
  23238. }
  23239. return
  23240. }
  23241. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  23242. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  23243. // MessageContactID instead. It exists only for internal usage by the builders.
  23244. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  23245. if id := m.message_contact; id != nil {
  23246. ids = append(ids, *id)
  23247. }
  23248. return
  23249. }
  23250. // ResetMessageContact resets all changes to the "message_contact" edge.
  23251. func (m *MessageRecordsMutation) ResetMessageContact() {
  23252. m.message_contact = nil
  23253. m.clearedmessage_contact = false
  23254. }
  23255. // Where appends a list predicates to the MessageRecordsMutation builder.
  23256. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  23257. m.predicates = append(m.predicates, ps...)
  23258. }
  23259. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  23260. // users can use type-assertion to append predicates that do not depend on any generated package.
  23261. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  23262. p := make([]predicate.MessageRecords, len(ps))
  23263. for i := range ps {
  23264. p[i] = ps[i]
  23265. }
  23266. m.Where(p...)
  23267. }
  23268. // Op returns the operation name.
  23269. func (m *MessageRecordsMutation) Op() Op {
  23270. return m.op
  23271. }
  23272. // SetOp allows setting the mutation operation.
  23273. func (m *MessageRecordsMutation) SetOp(op Op) {
  23274. m.op = op
  23275. }
  23276. // Type returns the node type of this mutation (MessageRecords).
  23277. func (m *MessageRecordsMutation) Type() string {
  23278. return m.typ
  23279. }
  23280. // Fields returns all fields that were changed during this mutation. Note that in
  23281. // order to get all numeric fields that were incremented/decremented, call
  23282. // AddedFields().
  23283. func (m *MessageRecordsMutation) Fields() []string {
  23284. fields := make([]string, 0, 16)
  23285. if m.created_at != nil {
  23286. fields = append(fields, messagerecords.FieldCreatedAt)
  23287. }
  23288. if m.updated_at != nil {
  23289. fields = append(fields, messagerecords.FieldUpdatedAt)
  23290. }
  23291. if m.status != nil {
  23292. fields = append(fields, messagerecords.FieldStatus)
  23293. }
  23294. if m.bot_wxid != nil {
  23295. fields = append(fields, messagerecords.FieldBotWxid)
  23296. }
  23297. if m.message_contact != nil {
  23298. fields = append(fields, messagerecords.FieldContactID)
  23299. }
  23300. if m.contact_type != nil {
  23301. fields = append(fields, messagerecords.FieldContactType)
  23302. }
  23303. if m.contact_wxid != nil {
  23304. fields = append(fields, messagerecords.FieldContactWxid)
  23305. }
  23306. if m.content_type != nil {
  23307. fields = append(fields, messagerecords.FieldContentType)
  23308. }
  23309. if m.content != nil {
  23310. fields = append(fields, messagerecords.FieldContent)
  23311. }
  23312. if m.meta != nil {
  23313. fields = append(fields, messagerecords.FieldMeta)
  23314. }
  23315. if m.error_detail != nil {
  23316. fields = append(fields, messagerecords.FieldErrorDetail)
  23317. }
  23318. if m.send_time != nil {
  23319. fields = append(fields, messagerecords.FieldSendTime)
  23320. }
  23321. if m.source_type != nil {
  23322. fields = append(fields, messagerecords.FieldSourceType)
  23323. }
  23324. if m.sop_stage != nil {
  23325. fields = append(fields, messagerecords.FieldSourceID)
  23326. }
  23327. if m.sop_node != nil {
  23328. fields = append(fields, messagerecords.FieldSubSourceID)
  23329. }
  23330. if m.organization_id != nil {
  23331. fields = append(fields, messagerecords.FieldOrganizationID)
  23332. }
  23333. return fields
  23334. }
  23335. // Field returns the value of a field with the given name. The second boolean
  23336. // return value indicates that this field was not set, or was not defined in the
  23337. // schema.
  23338. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  23339. switch name {
  23340. case messagerecords.FieldCreatedAt:
  23341. return m.CreatedAt()
  23342. case messagerecords.FieldUpdatedAt:
  23343. return m.UpdatedAt()
  23344. case messagerecords.FieldStatus:
  23345. return m.Status()
  23346. case messagerecords.FieldBotWxid:
  23347. return m.BotWxid()
  23348. case messagerecords.FieldContactID:
  23349. return m.ContactID()
  23350. case messagerecords.FieldContactType:
  23351. return m.ContactType()
  23352. case messagerecords.FieldContactWxid:
  23353. return m.ContactWxid()
  23354. case messagerecords.FieldContentType:
  23355. return m.ContentType()
  23356. case messagerecords.FieldContent:
  23357. return m.Content()
  23358. case messagerecords.FieldMeta:
  23359. return m.Meta()
  23360. case messagerecords.FieldErrorDetail:
  23361. return m.ErrorDetail()
  23362. case messagerecords.FieldSendTime:
  23363. return m.SendTime()
  23364. case messagerecords.FieldSourceType:
  23365. return m.SourceType()
  23366. case messagerecords.FieldSourceID:
  23367. return m.SourceID()
  23368. case messagerecords.FieldSubSourceID:
  23369. return m.SubSourceID()
  23370. case messagerecords.FieldOrganizationID:
  23371. return m.OrganizationID()
  23372. }
  23373. return nil, false
  23374. }
  23375. // OldField returns the old value of the field from the database. An error is
  23376. // returned if the mutation operation is not UpdateOne, or the query to the
  23377. // database failed.
  23378. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23379. switch name {
  23380. case messagerecords.FieldCreatedAt:
  23381. return m.OldCreatedAt(ctx)
  23382. case messagerecords.FieldUpdatedAt:
  23383. return m.OldUpdatedAt(ctx)
  23384. case messagerecords.FieldStatus:
  23385. return m.OldStatus(ctx)
  23386. case messagerecords.FieldBotWxid:
  23387. return m.OldBotWxid(ctx)
  23388. case messagerecords.FieldContactID:
  23389. return m.OldContactID(ctx)
  23390. case messagerecords.FieldContactType:
  23391. return m.OldContactType(ctx)
  23392. case messagerecords.FieldContactWxid:
  23393. return m.OldContactWxid(ctx)
  23394. case messagerecords.FieldContentType:
  23395. return m.OldContentType(ctx)
  23396. case messagerecords.FieldContent:
  23397. return m.OldContent(ctx)
  23398. case messagerecords.FieldMeta:
  23399. return m.OldMeta(ctx)
  23400. case messagerecords.FieldErrorDetail:
  23401. return m.OldErrorDetail(ctx)
  23402. case messagerecords.FieldSendTime:
  23403. return m.OldSendTime(ctx)
  23404. case messagerecords.FieldSourceType:
  23405. return m.OldSourceType(ctx)
  23406. case messagerecords.FieldSourceID:
  23407. return m.OldSourceID(ctx)
  23408. case messagerecords.FieldSubSourceID:
  23409. return m.OldSubSourceID(ctx)
  23410. case messagerecords.FieldOrganizationID:
  23411. return m.OldOrganizationID(ctx)
  23412. }
  23413. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  23414. }
  23415. // SetField sets the value of a field with the given name. It returns an error if
  23416. // the field is not defined in the schema, or if the type mismatched the field
  23417. // type.
  23418. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  23419. switch name {
  23420. case messagerecords.FieldCreatedAt:
  23421. v, ok := value.(time.Time)
  23422. if !ok {
  23423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23424. }
  23425. m.SetCreatedAt(v)
  23426. return nil
  23427. case messagerecords.FieldUpdatedAt:
  23428. v, ok := value.(time.Time)
  23429. if !ok {
  23430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23431. }
  23432. m.SetUpdatedAt(v)
  23433. return nil
  23434. case messagerecords.FieldStatus:
  23435. v, ok := value.(uint8)
  23436. if !ok {
  23437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23438. }
  23439. m.SetStatus(v)
  23440. return nil
  23441. case messagerecords.FieldBotWxid:
  23442. v, ok := value.(string)
  23443. if !ok {
  23444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23445. }
  23446. m.SetBotWxid(v)
  23447. return nil
  23448. case messagerecords.FieldContactID:
  23449. v, ok := value.(uint64)
  23450. if !ok {
  23451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23452. }
  23453. m.SetContactID(v)
  23454. return nil
  23455. case messagerecords.FieldContactType:
  23456. v, ok := value.(int)
  23457. if !ok {
  23458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23459. }
  23460. m.SetContactType(v)
  23461. return nil
  23462. case messagerecords.FieldContactWxid:
  23463. v, ok := value.(string)
  23464. if !ok {
  23465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23466. }
  23467. m.SetContactWxid(v)
  23468. return nil
  23469. case messagerecords.FieldContentType:
  23470. v, ok := value.(int)
  23471. if !ok {
  23472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23473. }
  23474. m.SetContentType(v)
  23475. return nil
  23476. case messagerecords.FieldContent:
  23477. v, ok := value.(string)
  23478. if !ok {
  23479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23480. }
  23481. m.SetContent(v)
  23482. return nil
  23483. case messagerecords.FieldMeta:
  23484. v, ok := value.(custom_types.Meta)
  23485. if !ok {
  23486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23487. }
  23488. m.SetMeta(v)
  23489. return nil
  23490. case messagerecords.FieldErrorDetail:
  23491. v, ok := value.(string)
  23492. if !ok {
  23493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23494. }
  23495. m.SetErrorDetail(v)
  23496. return nil
  23497. case messagerecords.FieldSendTime:
  23498. v, ok := value.(time.Time)
  23499. if !ok {
  23500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23501. }
  23502. m.SetSendTime(v)
  23503. return nil
  23504. case messagerecords.FieldSourceType:
  23505. v, ok := value.(int)
  23506. if !ok {
  23507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23508. }
  23509. m.SetSourceType(v)
  23510. return nil
  23511. case messagerecords.FieldSourceID:
  23512. v, ok := value.(uint64)
  23513. if !ok {
  23514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23515. }
  23516. m.SetSourceID(v)
  23517. return nil
  23518. case messagerecords.FieldSubSourceID:
  23519. v, ok := value.(uint64)
  23520. if !ok {
  23521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23522. }
  23523. m.SetSubSourceID(v)
  23524. return nil
  23525. case messagerecords.FieldOrganizationID:
  23526. v, ok := value.(uint64)
  23527. if !ok {
  23528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23529. }
  23530. m.SetOrganizationID(v)
  23531. return nil
  23532. }
  23533. return fmt.Errorf("unknown MessageRecords field %s", name)
  23534. }
  23535. // AddedFields returns all numeric fields that were incremented/decremented during
  23536. // this mutation.
  23537. func (m *MessageRecordsMutation) AddedFields() []string {
  23538. var fields []string
  23539. if m.addstatus != nil {
  23540. fields = append(fields, messagerecords.FieldStatus)
  23541. }
  23542. if m.addcontact_type != nil {
  23543. fields = append(fields, messagerecords.FieldContactType)
  23544. }
  23545. if m.addcontent_type != nil {
  23546. fields = append(fields, messagerecords.FieldContentType)
  23547. }
  23548. if m.addsource_type != nil {
  23549. fields = append(fields, messagerecords.FieldSourceType)
  23550. }
  23551. if m.addorganization_id != nil {
  23552. fields = append(fields, messagerecords.FieldOrganizationID)
  23553. }
  23554. return fields
  23555. }
  23556. // AddedField returns the numeric value that was incremented/decremented on a field
  23557. // with the given name. The second boolean return value indicates that this field
  23558. // was not set, or was not defined in the schema.
  23559. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  23560. switch name {
  23561. case messagerecords.FieldStatus:
  23562. return m.AddedStatus()
  23563. case messagerecords.FieldContactType:
  23564. return m.AddedContactType()
  23565. case messagerecords.FieldContentType:
  23566. return m.AddedContentType()
  23567. case messagerecords.FieldSourceType:
  23568. return m.AddedSourceType()
  23569. case messagerecords.FieldOrganizationID:
  23570. return m.AddedOrganizationID()
  23571. }
  23572. return nil, false
  23573. }
  23574. // AddField adds the value to the field with the given name. It returns an error if
  23575. // the field is not defined in the schema, or if the type mismatched the field
  23576. // type.
  23577. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  23578. switch name {
  23579. case messagerecords.FieldStatus:
  23580. v, ok := value.(int8)
  23581. if !ok {
  23582. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23583. }
  23584. m.AddStatus(v)
  23585. return nil
  23586. case messagerecords.FieldContactType:
  23587. v, ok := value.(int)
  23588. if !ok {
  23589. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23590. }
  23591. m.AddContactType(v)
  23592. return nil
  23593. case messagerecords.FieldContentType:
  23594. v, ok := value.(int)
  23595. if !ok {
  23596. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23597. }
  23598. m.AddContentType(v)
  23599. return nil
  23600. case messagerecords.FieldSourceType:
  23601. v, ok := value.(int)
  23602. if !ok {
  23603. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23604. }
  23605. m.AddSourceType(v)
  23606. return nil
  23607. case messagerecords.FieldOrganizationID:
  23608. v, ok := value.(int64)
  23609. if !ok {
  23610. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23611. }
  23612. m.AddOrganizationID(v)
  23613. return nil
  23614. }
  23615. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  23616. }
  23617. // ClearedFields returns all nullable fields that were cleared during this
  23618. // mutation.
  23619. func (m *MessageRecordsMutation) ClearedFields() []string {
  23620. var fields []string
  23621. if m.FieldCleared(messagerecords.FieldStatus) {
  23622. fields = append(fields, messagerecords.FieldStatus)
  23623. }
  23624. if m.FieldCleared(messagerecords.FieldContactID) {
  23625. fields = append(fields, messagerecords.FieldContactID)
  23626. }
  23627. if m.FieldCleared(messagerecords.FieldMeta) {
  23628. fields = append(fields, messagerecords.FieldMeta)
  23629. }
  23630. if m.FieldCleared(messagerecords.FieldSendTime) {
  23631. fields = append(fields, messagerecords.FieldSendTime)
  23632. }
  23633. if m.FieldCleared(messagerecords.FieldSourceID) {
  23634. fields = append(fields, messagerecords.FieldSourceID)
  23635. }
  23636. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  23637. fields = append(fields, messagerecords.FieldSubSourceID)
  23638. }
  23639. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  23640. fields = append(fields, messagerecords.FieldOrganizationID)
  23641. }
  23642. return fields
  23643. }
  23644. // FieldCleared returns a boolean indicating if a field with the given name was
  23645. // cleared in this mutation.
  23646. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  23647. _, ok := m.clearedFields[name]
  23648. return ok
  23649. }
  23650. // ClearField clears the value of the field with the given name. It returns an
  23651. // error if the field is not defined in the schema.
  23652. func (m *MessageRecordsMutation) ClearField(name string) error {
  23653. switch name {
  23654. case messagerecords.FieldStatus:
  23655. m.ClearStatus()
  23656. return nil
  23657. case messagerecords.FieldContactID:
  23658. m.ClearContactID()
  23659. return nil
  23660. case messagerecords.FieldMeta:
  23661. m.ClearMeta()
  23662. return nil
  23663. case messagerecords.FieldSendTime:
  23664. m.ClearSendTime()
  23665. return nil
  23666. case messagerecords.FieldSourceID:
  23667. m.ClearSourceID()
  23668. return nil
  23669. case messagerecords.FieldSubSourceID:
  23670. m.ClearSubSourceID()
  23671. return nil
  23672. case messagerecords.FieldOrganizationID:
  23673. m.ClearOrganizationID()
  23674. return nil
  23675. }
  23676. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  23677. }
  23678. // ResetField resets all changes in the mutation for the field with the given name.
  23679. // It returns an error if the field is not defined in the schema.
  23680. func (m *MessageRecordsMutation) ResetField(name string) error {
  23681. switch name {
  23682. case messagerecords.FieldCreatedAt:
  23683. m.ResetCreatedAt()
  23684. return nil
  23685. case messagerecords.FieldUpdatedAt:
  23686. m.ResetUpdatedAt()
  23687. return nil
  23688. case messagerecords.FieldStatus:
  23689. m.ResetStatus()
  23690. return nil
  23691. case messagerecords.FieldBotWxid:
  23692. m.ResetBotWxid()
  23693. return nil
  23694. case messagerecords.FieldContactID:
  23695. m.ResetContactID()
  23696. return nil
  23697. case messagerecords.FieldContactType:
  23698. m.ResetContactType()
  23699. return nil
  23700. case messagerecords.FieldContactWxid:
  23701. m.ResetContactWxid()
  23702. return nil
  23703. case messagerecords.FieldContentType:
  23704. m.ResetContentType()
  23705. return nil
  23706. case messagerecords.FieldContent:
  23707. m.ResetContent()
  23708. return nil
  23709. case messagerecords.FieldMeta:
  23710. m.ResetMeta()
  23711. return nil
  23712. case messagerecords.FieldErrorDetail:
  23713. m.ResetErrorDetail()
  23714. return nil
  23715. case messagerecords.FieldSendTime:
  23716. m.ResetSendTime()
  23717. return nil
  23718. case messagerecords.FieldSourceType:
  23719. m.ResetSourceType()
  23720. return nil
  23721. case messagerecords.FieldSourceID:
  23722. m.ResetSourceID()
  23723. return nil
  23724. case messagerecords.FieldSubSourceID:
  23725. m.ResetSubSourceID()
  23726. return nil
  23727. case messagerecords.FieldOrganizationID:
  23728. m.ResetOrganizationID()
  23729. return nil
  23730. }
  23731. return fmt.Errorf("unknown MessageRecords field %s", name)
  23732. }
  23733. // AddedEdges returns all edge names that were set/added in this mutation.
  23734. func (m *MessageRecordsMutation) AddedEdges() []string {
  23735. edges := make([]string, 0, 3)
  23736. if m.sop_stage != nil {
  23737. edges = append(edges, messagerecords.EdgeSopStage)
  23738. }
  23739. if m.sop_node != nil {
  23740. edges = append(edges, messagerecords.EdgeSopNode)
  23741. }
  23742. if m.message_contact != nil {
  23743. edges = append(edges, messagerecords.EdgeMessageContact)
  23744. }
  23745. return edges
  23746. }
  23747. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23748. // name in this mutation.
  23749. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  23750. switch name {
  23751. case messagerecords.EdgeSopStage:
  23752. if id := m.sop_stage; id != nil {
  23753. return []ent.Value{*id}
  23754. }
  23755. case messagerecords.EdgeSopNode:
  23756. if id := m.sop_node; id != nil {
  23757. return []ent.Value{*id}
  23758. }
  23759. case messagerecords.EdgeMessageContact:
  23760. if id := m.message_contact; id != nil {
  23761. return []ent.Value{*id}
  23762. }
  23763. }
  23764. return nil
  23765. }
  23766. // RemovedEdges returns all edge names that were removed in this mutation.
  23767. func (m *MessageRecordsMutation) RemovedEdges() []string {
  23768. edges := make([]string, 0, 3)
  23769. return edges
  23770. }
  23771. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23772. // the given name in this mutation.
  23773. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  23774. return nil
  23775. }
  23776. // ClearedEdges returns all edge names that were cleared in this mutation.
  23777. func (m *MessageRecordsMutation) ClearedEdges() []string {
  23778. edges := make([]string, 0, 3)
  23779. if m.clearedsop_stage {
  23780. edges = append(edges, messagerecords.EdgeSopStage)
  23781. }
  23782. if m.clearedsop_node {
  23783. edges = append(edges, messagerecords.EdgeSopNode)
  23784. }
  23785. if m.clearedmessage_contact {
  23786. edges = append(edges, messagerecords.EdgeMessageContact)
  23787. }
  23788. return edges
  23789. }
  23790. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23791. // was cleared in this mutation.
  23792. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  23793. switch name {
  23794. case messagerecords.EdgeSopStage:
  23795. return m.clearedsop_stage
  23796. case messagerecords.EdgeSopNode:
  23797. return m.clearedsop_node
  23798. case messagerecords.EdgeMessageContact:
  23799. return m.clearedmessage_contact
  23800. }
  23801. return false
  23802. }
  23803. // ClearEdge clears the value of the edge with the given name. It returns an error
  23804. // if that edge is not defined in the schema.
  23805. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  23806. switch name {
  23807. case messagerecords.EdgeSopStage:
  23808. m.ClearSopStage()
  23809. return nil
  23810. case messagerecords.EdgeSopNode:
  23811. m.ClearSopNode()
  23812. return nil
  23813. case messagerecords.EdgeMessageContact:
  23814. m.ClearMessageContact()
  23815. return nil
  23816. }
  23817. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  23818. }
  23819. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23820. // It returns an error if the edge is not defined in the schema.
  23821. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  23822. switch name {
  23823. case messagerecords.EdgeSopStage:
  23824. m.ResetSopStage()
  23825. return nil
  23826. case messagerecords.EdgeSopNode:
  23827. m.ResetSopNode()
  23828. return nil
  23829. case messagerecords.EdgeMessageContact:
  23830. m.ResetMessageContact()
  23831. return nil
  23832. }
  23833. return fmt.Errorf("unknown MessageRecords edge %s", name)
  23834. }
  23835. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  23836. type MsgMutation struct {
  23837. config
  23838. op Op
  23839. typ string
  23840. id *uint64
  23841. created_at *time.Time
  23842. updated_at *time.Time
  23843. deleted_at *time.Time
  23844. status *uint8
  23845. addstatus *int8
  23846. fromwxid *string
  23847. toid *string
  23848. msgtype *int32
  23849. addmsgtype *int32
  23850. msg *string
  23851. batch_no *string
  23852. cc *string
  23853. phone *string
  23854. clearedFields map[string]struct{}
  23855. done bool
  23856. oldValue func(context.Context) (*Msg, error)
  23857. predicates []predicate.Msg
  23858. }
  23859. var _ ent.Mutation = (*MsgMutation)(nil)
  23860. // msgOption allows management of the mutation configuration using functional options.
  23861. type msgOption func(*MsgMutation)
  23862. // newMsgMutation creates new mutation for the Msg entity.
  23863. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  23864. m := &MsgMutation{
  23865. config: c,
  23866. op: op,
  23867. typ: TypeMsg,
  23868. clearedFields: make(map[string]struct{}),
  23869. }
  23870. for _, opt := range opts {
  23871. opt(m)
  23872. }
  23873. return m
  23874. }
  23875. // withMsgID sets the ID field of the mutation.
  23876. func withMsgID(id uint64) msgOption {
  23877. return func(m *MsgMutation) {
  23878. var (
  23879. err error
  23880. once sync.Once
  23881. value *Msg
  23882. )
  23883. m.oldValue = func(ctx context.Context) (*Msg, error) {
  23884. once.Do(func() {
  23885. if m.done {
  23886. err = errors.New("querying old values post mutation is not allowed")
  23887. } else {
  23888. value, err = m.Client().Msg.Get(ctx, id)
  23889. }
  23890. })
  23891. return value, err
  23892. }
  23893. m.id = &id
  23894. }
  23895. }
  23896. // withMsg sets the old Msg of the mutation.
  23897. func withMsg(node *Msg) msgOption {
  23898. return func(m *MsgMutation) {
  23899. m.oldValue = func(context.Context) (*Msg, error) {
  23900. return node, nil
  23901. }
  23902. m.id = &node.ID
  23903. }
  23904. }
  23905. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23906. // executed in a transaction (ent.Tx), a transactional client is returned.
  23907. func (m MsgMutation) Client() *Client {
  23908. client := &Client{config: m.config}
  23909. client.init()
  23910. return client
  23911. }
  23912. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23913. // it returns an error otherwise.
  23914. func (m MsgMutation) Tx() (*Tx, error) {
  23915. if _, ok := m.driver.(*txDriver); !ok {
  23916. return nil, errors.New("ent: mutation is not running in a transaction")
  23917. }
  23918. tx := &Tx{config: m.config}
  23919. tx.init()
  23920. return tx, nil
  23921. }
  23922. // SetID sets the value of the id field. Note that this
  23923. // operation is only accepted on creation of Msg entities.
  23924. func (m *MsgMutation) SetID(id uint64) {
  23925. m.id = &id
  23926. }
  23927. // ID returns the ID value in the mutation. Note that the ID is only available
  23928. // if it was provided to the builder or after it was returned from the database.
  23929. func (m *MsgMutation) ID() (id uint64, exists bool) {
  23930. if m.id == nil {
  23931. return
  23932. }
  23933. return *m.id, true
  23934. }
  23935. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23936. // That means, if the mutation is applied within a transaction with an isolation level such
  23937. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23938. // or updated by the mutation.
  23939. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  23940. switch {
  23941. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23942. id, exists := m.ID()
  23943. if exists {
  23944. return []uint64{id}, nil
  23945. }
  23946. fallthrough
  23947. case m.op.Is(OpUpdate | OpDelete):
  23948. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  23949. default:
  23950. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23951. }
  23952. }
  23953. // SetCreatedAt sets the "created_at" field.
  23954. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  23955. m.created_at = &t
  23956. }
  23957. // CreatedAt returns the value of the "created_at" field in the mutation.
  23958. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  23959. v := m.created_at
  23960. if v == nil {
  23961. return
  23962. }
  23963. return *v, true
  23964. }
  23965. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  23966. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  23967. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23968. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23969. if !m.op.Is(OpUpdateOne) {
  23970. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23971. }
  23972. if m.id == nil || m.oldValue == nil {
  23973. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23974. }
  23975. oldValue, err := m.oldValue(ctx)
  23976. if err != nil {
  23977. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23978. }
  23979. return oldValue.CreatedAt, nil
  23980. }
  23981. // ResetCreatedAt resets all changes to the "created_at" field.
  23982. func (m *MsgMutation) ResetCreatedAt() {
  23983. m.created_at = nil
  23984. }
  23985. // SetUpdatedAt sets the "updated_at" field.
  23986. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  23987. m.updated_at = &t
  23988. }
  23989. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23990. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  23991. v := m.updated_at
  23992. if v == nil {
  23993. return
  23994. }
  23995. return *v, true
  23996. }
  23997. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  23998. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  23999. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24000. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24001. if !m.op.Is(OpUpdateOne) {
  24002. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24003. }
  24004. if m.id == nil || m.oldValue == nil {
  24005. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24006. }
  24007. oldValue, err := m.oldValue(ctx)
  24008. if err != nil {
  24009. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24010. }
  24011. return oldValue.UpdatedAt, nil
  24012. }
  24013. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24014. func (m *MsgMutation) ResetUpdatedAt() {
  24015. m.updated_at = nil
  24016. }
  24017. // SetDeletedAt sets the "deleted_at" field.
  24018. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  24019. m.deleted_at = &t
  24020. }
  24021. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  24022. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  24023. v := m.deleted_at
  24024. if v == nil {
  24025. return
  24026. }
  24027. return *v, true
  24028. }
  24029. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  24030. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  24031. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24032. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  24033. if !m.op.Is(OpUpdateOne) {
  24034. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  24035. }
  24036. if m.id == nil || m.oldValue == nil {
  24037. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  24038. }
  24039. oldValue, err := m.oldValue(ctx)
  24040. if err != nil {
  24041. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  24042. }
  24043. return oldValue.DeletedAt, nil
  24044. }
  24045. // ClearDeletedAt clears the value of the "deleted_at" field.
  24046. func (m *MsgMutation) ClearDeletedAt() {
  24047. m.deleted_at = nil
  24048. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  24049. }
  24050. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  24051. func (m *MsgMutation) DeletedAtCleared() bool {
  24052. _, ok := m.clearedFields[msg.FieldDeletedAt]
  24053. return ok
  24054. }
  24055. // ResetDeletedAt resets all changes to the "deleted_at" field.
  24056. func (m *MsgMutation) ResetDeletedAt() {
  24057. m.deleted_at = nil
  24058. delete(m.clearedFields, msg.FieldDeletedAt)
  24059. }
  24060. // SetStatus sets the "status" field.
  24061. func (m *MsgMutation) SetStatus(u uint8) {
  24062. m.status = &u
  24063. m.addstatus = nil
  24064. }
  24065. // Status returns the value of the "status" field in the mutation.
  24066. func (m *MsgMutation) Status() (r uint8, exists bool) {
  24067. v := m.status
  24068. if v == nil {
  24069. return
  24070. }
  24071. return *v, true
  24072. }
  24073. // OldStatus returns the old "status" field's value of the Msg entity.
  24074. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  24075. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24076. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  24077. if !m.op.Is(OpUpdateOne) {
  24078. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  24079. }
  24080. if m.id == nil || m.oldValue == nil {
  24081. return v, errors.New("OldStatus requires an ID field in the mutation")
  24082. }
  24083. oldValue, err := m.oldValue(ctx)
  24084. if err != nil {
  24085. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  24086. }
  24087. return oldValue.Status, nil
  24088. }
  24089. // AddStatus adds u to the "status" field.
  24090. func (m *MsgMutation) AddStatus(u int8) {
  24091. if m.addstatus != nil {
  24092. *m.addstatus += u
  24093. } else {
  24094. m.addstatus = &u
  24095. }
  24096. }
  24097. // AddedStatus returns the value that was added to the "status" field in this mutation.
  24098. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  24099. v := m.addstatus
  24100. if v == nil {
  24101. return
  24102. }
  24103. return *v, true
  24104. }
  24105. // ClearStatus clears the value of the "status" field.
  24106. func (m *MsgMutation) ClearStatus() {
  24107. m.status = nil
  24108. m.addstatus = nil
  24109. m.clearedFields[msg.FieldStatus] = struct{}{}
  24110. }
  24111. // StatusCleared returns if the "status" field was cleared in this mutation.
  24112. func (m *MsgMutation) StatusCleared() bool {
  24113. _, ok := m.clearedFields[msg.FieldStatus]
  24114. return ok
  24115. }
  24116. // ResetStatus resets all changes to the "status" field.
  24117. func (m *MsgMutation) ResetStatus() {
  24118. m.status = nil
  24119. m.addstatus = nil
  24120. delete(m.clearedFields, msg.FieldStatus)
  24121. }
  24122. // SetFromwxid sets the "fromwxid" field.
  24123. func (m *MsgMutation) SetFromwxid(s string) {
  24124. m.fromwxid = &s
  24125. }
  24126. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  24127. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  24128. v := m.fromwxid
  24129. if v == nil {
  24130. return
  24131. }
  24132. return *v, true
  24133. }
  24134. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  24135. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  24136. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24137. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  24138. if !m.op.Is(OpUpdateOne) {
  24139. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  24140. }
  24141. if m.id == nil || m.oldValue == nil {
  24142. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  24143. }
  24144. oldValue, err := m.oldValue(ctx)
  24145. if err != nil {
  24146. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  24147. }
  24148. return oldValue.Fromwxid, nil
  24149. }
  24150. // ClearFromwxid clears the value of the "fromwxid" field.
  24151. func (m *MsgMutation) ClearFromwxid() {
  24152. m.fromwxid = nil
  24153. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  24154. }
  24155. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  24156. func (m *MsgMutation) FromwxidCleared() bool {
  24157. _, ok := m.clearedFields[msg.FieldFromwxid]
  24158. return ok
  24159. }
  24160. // ResetFromwxid resets all changes to the "fromwxid" field.
  24161. func (m *MsgMutation) ResetFromwxid() {
  24162. m.fromwxid = nil
  24163. delete(m.clearedFields, msg.FieldFromwxid)
  24164. }
  24165. // SetToid sets the "toid" field.
  24166. func (m *MsgMutation) SetToid(s string) {
  24167. m.toid = &s
  24168. }
  24169. // Toid returns the value of the "toid" field in the mutation.
  24170. func (m *MsgMutation) Toid() (r string, exists bool) {
  24171. v := m.toid
  24172. if v == nil {
  24173. return
  24174. }
  24175. return *v, true
  24176. }
  24177. // OldToid returns the old "toid" field's value of the Msg entity.
  24178. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  24179. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24180. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  24181. if !m.op.Is(OpUpdateOne) {
  24182. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  24183. }
  24184. if m.id == nil || m.oldValue == nil {
  24185. return v, errors.New("OldToid requires an ID field in the mutation")
  24186. }
  24187. oldValue, err := m.oldValue(ctx)
  24188. if err != nil {
  24189. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  24190. }
  24191. return oldValue.Toid, nil
  24192. }
  24193. // ClearToid clears the value of the "toid" field.
  24194. func (m *MsgMutation) ClearToid() {
  24195. m.toid = nil
  24196. m.clearedFields[msg.FieldToid] = struct{}{}
  24197. }
  24198. // ToidCleared returns if the "toid" field was cleared in this mutation.
  24199. func (m *MsgMutation) ToidCleared() bool {
  24200. _, ok := m.clearedFields[msg.FieldToid]
  24201. return ok
  24202. }
  24203. // ResetToid resets all changes to the "toid" field.
  24204. func (m *MsgMutation) ResetToid() {
  24205. m.toid = nil
  24206. delete(m.clearedFields, msg.FieldToid)
  24207. }
  24208. // SetMsgtype sets the "msgtype" field.
  24209. func (m *MsgMutation) SetMsgtype(i int32) {
  24210. m.msgtype = &i
  24211. m.addmsgtype = nil
  24212. }
  24213. // Msgtype returns the value of the "msgtype" field in the mutation.
  24214. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  24215. v := m.msgtype
  24216. if v == nil {
  24217. return
  24218. }
  24219. return *v, true
  24220. }
  24221. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  24222. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  24223. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24224. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  24225. if !m.op.Is(OpUpdateOne) {
  24226. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  24227. }
  24228. if m.id == nil || m.oldValue == nil {
  24229. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  24230. }
  24231. oldValue, err := m.oldValue(ctx)
  24232. if err != nil {
  24233. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  24234. }
  24235. return oldValue.Msgtype, nil
  24236. }
  24237. // AddMsgtype adds i to the "msgtype" field.
  24238. func (m *MsgMutation) AddMsgtype(i int32) {
  24239. if m.addmsgtype != nil {
  24240. *m.addmsgtype += i
  24241. } else {
  24242. m.addmsgtype = &i
  24243. }
  24244. }
  24245. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  24246. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  24247. v := m.addmsgtype
  24248. if v == nil {
  24249. return
  24250. }
  24251. return *v, true
  24252. }
  24253. // ClearMsgtype clears the value of the "msgtype" field.
  24254. func (m *MsgMutation) ClearMsgtype() {
  24255. m.msgtype = nil
  24256. m.addmsgtype = nil
  24257. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  24258. }
  24259. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  24260. func (m *MsgMutation) MsgtypeCleared() bool {
  24261. _, ok := m.clearedFields[msg.FieldMsgtype]
  24262. return ok
  24263. }
  24264. // ResetMsgtype resets all changes to the "msgtype" field.
  24265. func (m *MsgMutation) ResetMsgtype() {
  24266. m.msgtype = nil
  24267. m.addmsgtype = nil
  24268. delete(m.clearedFields, msg.FieldMsgtype)
  24269. }
  24270. // SetMsg sets the "msg" field.
  24271. func (m *MsgMutation) SetMsg(s string) {
  24272. m.msg = &s
  24273. }
  24274. // Msg returns the value of the "msg" field in the mutation.
  24275. func (m *MsgMutation) Msg() (r string, exists bool) {
  24276. v := m.msg
  24277. if v == nil {
  24278. return
  24279. }
  24280. return *v, true
  24281. }
  24282. // OldMsg returns the old "msg" field's value of the Msg entity.
  24283. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  24284. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24285. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  24286. if !m.op.Is(OpUpdateOne) {
  24287. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  24288. }
  24289. if m.id == nil || m.oldValue == nil {
  24290. return v, errors.New("OldMsg requires an ID field in the mutation")
  24291. }
  24292. oldValue, err := m.oldValue(ctx)
  24293. if err != nil {
  24294. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  24295. }
  24296. return oldValue.Msg, nil
  24297. }
  24298. // ClearMsg clears the value of the "msg" field.
  24299. func (m *MsgMutation) ClearMsg() {
  24300. m.msg = nil
  24301. m.clearedFields[msg.FieldMsg] = struct{}{}
  24302. }
  24303. // MsgCleared returns if the "msg" field was cleared in this mutation.
  24304. func (m *MsgMutation) MsgCleared() bool {
  24305. _, ok := m.clearedFields[msg.FieldMsg]
  24306. return ok
  24307. }
  24308. // ResetMsg resets all changes to the "msg" field.
  24309. func (m *MsgMutation) ResetMsg() {
  24310. m.msg = nil
  24311. delete(m.clearedFields, msg.FieldMsg)
  24312. }
  24313. // SetBatchNo sets the "batch_no" field.
  24314. func (m *MsgMutation) SetBatchNo(s string) {
  24315. m.batch_no = &s
  24316. }
  24317. // BatchNo returns the value of the "batch_no" field in the mutation.
  24318. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  24319. v := m.batch_no
  24320. if v == nil {
  24321. return
  24322. }
  24323. return *v, true
  24324. }
  24325. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  24326. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  24327. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24328. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  24329. if !m.op.Is(OpUpdateOne) {
  24330. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  24331. }
  24332. if m.id == nil || m.oldValue == nil {
  24333. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  24334. }
  24335. oldValue, err := m.oldValue(ctx)
  24336. if err != nil {
  24337. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  24338. }
  24339. return oldValue.BatchNo, nil
  24340. }
  24341. // ClearBatchNo clears the value of the "batch_no" field.
  24342. func (m *MsgMutation) ClearBatchNo() {
  24343. m.batch_no = nil
  24344. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  24345. }
  24346. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  24347. func (m *MsgMutation) BatchNoCleared() bool {
  24348. _, ok := m.clearedFields[msg.FieldBatchNo]
  24349. return ok
  24350. }
  24351. // ResetBatchNo resets all changes to the "batch_no" field.
  24352. func (m *MsgMutation) ResetBatchNo() {
  24353. m.batch_no = nil
  24354. delete(m.clearedFields, msg.FieldBatchNo)
  24355. }
  24356. // SetCc sets the "cc" field.
  24357. func (m *MsgMutation) SetCc(s string) {
  24358. m.cc = &s
  24359. }
  24360. // Cc returns the value of the "cc" field in the mutation.
  24361. func (m *MsgMutation) Cc() (r string, exists bool) {
  24362. v := m.cc
  24363. if v == nil {
  24364. return
  24365. }
  24366. return *v, true
  24367. }
  24368. // OldCc returns the old "cc" field's value of the Msg entity.
  24369. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  24370. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24371. func (m *MsgMutation) OldCc(ctx context.Context) (v string, err error) {
  24372. if !m.op.Is(OpUpdateOne) {
  24373. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  24374. }
  24375. if m.id == nil || m.oldValue == nil {
  24376. return v, errors.New("OldCc requires an ID field in the mutation")
  24377. }
  24378. oldValue, err := m.oldValue(ctx)
  24379. if err != nil {
  24380. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  24381. }
  24382. return oldValue.Cc, nil
  24383. }
  24384. // ResetCc resets all changes to the "cc" field.
  24385. func (m *MsgMutation) ResetCc() {
  24386. m.cc = nil
  24387. }
  24388. // SetPhone sets the "phone" field.
  24389. func (m *MsgMutation) SetPhone(s string) {
  24390. m.phone = &s
  24391. }
  24392. // Phone returns the value of the "phone" field in the mutation.
  24393. func (m *MsgMutation) Phone() (r string, exists bool) {
  24394. v := m.phone
  24395. if v == nil {
  24396. return
  24397. }
  24398. return *v, true
  24399. }
  24400. // OldPhone returns the old "phone" field's value of the Msg entity.
  24401. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  24402. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24403. func (m *MsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  24404. if !m.op.Is(OpUpdateOne) {
  24405. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  24406. }
  24407. if m.id == nil || m.oldValue == nil {
  24408. return v, errors.New("OldPhone requires an ID field in the mutation")
  24409. }
  24410. oldValue, err := m.oldValue(ctx)
  24411. if err != nil {
  24412. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  24413. }
  24414. return oldValue.Phone, nil
  24415. }
  24416. // ResetPhone resets all changes to the "phone" field.
  24417. func (m *MsgMutation) ResetPhone() {
  24418. m.phone = nil
  24419. }
  24420. // Where appends a list predicates to the MsgMutation builder.
  24421. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  24422. m.predicates = append(m.predicates, ps...)
  24423. }
  24424. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  24425. // users can use type-assertion to append predicates that do not depend on any generated package.
  24426. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  24427. p := make([]predicate.Msg, len(ps))
  24428. for i := range ps {
  24429. p[i] = ps[i]
  24430. }
  24431. m.Where(p...)
  24432. }
  24433. // Op returns the operation name.
  24434. func (m *MsgMutation) Op() Op {
  24435. return m.op
  24436. }
  24437. // SetOp allows setting the mutation operation.
  24438. func (m *MsgMutation) SetOp(op Op) {
  24439. m.op = op
  24440. }
  24441. // Type returns the node type of this mutation (Msg).
  24442. func (m *MsgMutation) Type() string {
  24443. return m.typ
  24444. }
  24445. // Fields returns all fields that were changed during this mutation. Note that in
  24446. // order to get all numeric fields that were incremented/decremented, call
  24447. // AddedFields().
  24448. func (m *MsgMutation) Fields() []string {
  24449. fields := make([]string, 0, 11)
  24450. if m.created_at != nil {
  24451. fields = append(fields, msg.FieldCreatedAt)
  24452. }
  24453. if m.updated_at != nil {
  24454. fields = append(fields, msg.FieldUpdatedAt)
  24455. }
  24456. if m.deleted_at != nil {
  24457. fields = append(fields, msg.FieldDeletedAt)
  24458. }
  24459. if m.status != nil {
  24460. fields = append(fields, msg.FieldStatus)
  24461. }
  24462. if m.fromwxid != nil {
  24463. fields = append(fields, msg.FieldFromwxid)
  24464. }
  24465. if m.toid != nil {
  24466. fields = append(fields, msg.FieldToid)
  24467. }
  24468. if m.msgtype != nil {
  24469. fields = append(fields, msg.FieldMsgtype)
  24470. }
  24471. if m.msg != nil {
  24472. fields = append(fields, msg.FieldMsg)
  24473. }
  24474. if m.batch_no != nil {
  24475. fields = append(fields, msg.FieldBatchNo)
  24476. }
  24477. if m.cc != nil {
  24478. fields = append(fields, msg.FieldCc)
  24479. }
  24480. if m.phone != nil {
  24481. fields = append(fields, msg.FieldPhone)
  24482. }
  24483. return fields
  24484. }
  24485. // Field returns the value of a field with the given name. The second boolean
  24486. // return value indicates that this field was not set, or was not defined in the
  24487. // schema.
  24488. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  24489. switch name {
  24490. case msg.FieldCreatedAt:
  24491. return m.CreatedAt()
  24492. case msg.FieldUpdatedAt:
  24493. return m.UpdatedAt()
  24494. case msg.FieldDeletedAt:
  24495. return m.DeletedAt()
  24496. case msg.FieldStatus:
  24497. return m.Status()
  24498. case msg.FieldFromwxid:
  24499. return m.Fromwxid()
  24500. case msg.FieldToid:
  24501. return m.Toid()
  24502. case msg.FieldMsgtype:
  24503. return m.Msgtype()
  24504. case msg.FieldMsg:
  24505. return m.Msg()
  24506. case msg.FieldBatchNo:
  24507. return m.BatchNo()
  24508. case msg.FieldCc:
  24509. return m.Cc()
  24510. case msg.FieldPhone:
  24511. return m.Phone()
  24512. }
  24513. return nil, false
  24514. }
  24515. // OldField returns the old value of the field from the database. An error is
  24516. // returned if the mutation operation is not UpdateOne, or the query to the
  24517. // database failed.
  24518. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24519. switch name {
  24520. case msg.FieldCreatedAt:
  24521. return m.OldCreatedAt(ctx)
  24522. case msg.FieldUpdatedAt:
  24523. return m.OldUpdatedAt(ctx)
  24524. case msg.FieldDeletedAt:
  24525. return m.OldDeletedAt(ctx)
  24526. case msg.FieldStatus:
  24527. return m.OldStatus(ctx)
  24528. case msg.FieldFromwxid:
  24529. return m.OldFromwxid(ctx)
  24530. case msg.FieldToid:
  24531. return m.OldToid(ctx)
  24532. case msg.FieldMsgtype:
  24533. return m.OldMsgtype(ctx)
  24534. case msg.FieldMsg:
  24535. return m.OldMsg(ctx)
  24536. case msg.FieldBatchNo:
  24537. return m.OldBatchNo(ctx)
  24538. case msg.FieldCc:
  24539. return m.OldCc(ctx)
  24540. case msg.FieldPhone:
  24541. return m.OldPhone(ctx)
  24542. }
  24543. return nil, fmt.Errorf("unknown Msg field %s", name)
  24544. }
  24545. // SetField sets the value of a field with the given name. It returns an error if
  24546. // the field is not defined in the schema, or if the type mismatched the field
  24547. // type.
  24548. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  24549. switch name {
  24550. case msg.FieldCreatedAt:
  24551. v, ok := value.(time.Time)
  24552. if !ok {
  24553. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24554. }
  24555. m.SetCreatedAt(v)
  24556. return nil
  24557. case msg.FieldUpdatedAt:
  24558. v, ok := value.(time.Time)
  24559. if !ok {
  24560. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24561. }
  24562. m.SetUpdatedAt(v)
  24563. return nil
  24564. case msg.FieldDeletedAt:
  24565. v, ok := value.(time.Time)
  24566. if !ok {
  24567. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24568. }
  24569. m.SetDeletedAt(v)
  24570. return nil
  24571. case msg.FieldStatus:
  24572. v, ok := value.(uint8)
  24573. if !ok {
  24574. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24575. }
  24576. m.SetStatus(v)
  24577. return nil
  24578. case msg.FieldFromwxid:
  24579. v, ok := value.(string)
  24580. if !ok {
  24581. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24582. }
  24583. m.SetFromwxid(v)
  24584. return nil
  24585. case msg.FieldToid:
  24586. v, ok := value.(string)
  24587. if !ok {
  24588. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24589. }
  24590. m.SetToid(v)
  24591. return nil
  24592. case msg.FieldMsgtype:
  24593. v, ok := value.(int32)
  24594. if !ok {
  24595. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24596. }
  24597. m.SetMsgtype(v)
  24598. return nil
  24599. case msg.FieldMsg:
  24600. v, ok := value.(string)
  24601. if !ok {
  24602. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24603. }
  24604. m.SetMsg(v)
  24605. return nil
  24606. case msg.FieldBatchNo:
  24607. v, ok := value.(string)
  24608. if !ok {
  24609. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24610. }
  24611. m.SetBatchNo(v)
  24612. return nil
  24613. case msg.FieldCc:
  24614. v, ok := value.(string)
  24615. if !ok {
  24616. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24617. }
  24618. m.SetCc(v)
  24619. return nil
  24620. case msg.FieldPhone:
  24621. v, ok := value.(string)
  24622. if !ok {
  24623. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24624. }
  24625. m.SetPhone(v)
  24626. return nil
  24627. }
  24628. return fmt.Errorf("unknown Msg field %s", name)
  24629. }
  24630. // AddedFields returns all numeric fields that were incremented/decremented during
  24631. // this mutation.
  24632. func (m *MsgMutation) AddedFields() []string {
  24633. var fields []string
  24634. if m.addstatus != nil {
  24635. fields = append(fields, msg.FieldStatus)
  24636. }
  24637. if m.addmsgtype != nil {
  24638. fields = append(fields, msg.FieldMsgtype)
  24639. }
  24640. return fields
  24641. }
  24642. // AddedField returns the numeric value that was incremented/decremented on a field
  24643. // with the given name. The second boolean return value indicates that this field
  24644. // was not set, or was not defined in the schema.
  24645. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  24646. switch name {
  24647. case msg.FieldStatus:
  24648. return m.AddedStatus()
  24649. case msg.FieldMsgtype:
  24650. return m.AddedMsgtype()
  24651. }
  24652. return nil, false
  24653. }
  24654. // AddField adds the value to the field with the given name. It returns an error if
  24655. // the field is not defined in the schema, or if the type mismatched the field
  24656. // type.
  24657. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  24658. switch name {
  24659. case msg.FieldStatus:
  24660. v, ok := value.(int8)
  24661. if !ok {
  24662. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24663. }
  24664. m.AddStatus(v)
  24665. return nil
  24666. case msg.FieldMsgtype:
  24667. v, ok := value.(int32)
  24668. if !ok {
  24669. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24670. }
  24671. m.AddMsgtype(v)
  24672. return nil
  24673. }
  24674. return fmt.Errorf("unknown Msg numeric field %s", name)
  24675. }
  24676. // ClearedFields returns all nullable fields that were cleared during this
  24677. // mutation.
  24678. func (m *MsgMutation) ClearedFields() []string {
  24679. var fields []string
  24680. if m.FieldCleared(msg.FieldDeletedAt) {
  24681. fields = append(fields, msg.FieldDeletedAt)
  24682. }
  24683. if m.FieldCleared(msg.FieldStatus) {
  24684. fields = append(fields, msg.FieldStatus)
  24685. }
  24686. if m.FieldCleared(msg.FieldFromwxid) {
  24687. fields = append(fields, msg.FieldFromwxid)
  24688. }
  24689. if m.FieldCleared(msg.FieldToid) {
  24690. fields = append(fields, msg.FieldToid)
  24691. }
  24692. if m.FieldCleared(msg.FieldMsgtype) {
  24693. fields = append(fields, msg.FieldMsgtype)
  24694. }
  24695. if m.FieldCleared(msg.FieldMsg) {
  24696. fields = append(fields, msg.FieldMsg)
  24697. }
  24698. if m.FieldCleared(msg.FieldBatchNo) {
  24699. fields = append(fields, msg.FieldBatchNo)
  24700. }
  24701. return fields
  24702. }
  24703. // FieldCleared returns a boolean indicating if a field with the given name was
  24704. // cleared in this mutation.
  24705. func (m *MsgMutation) FieldCleared(name string) bool {
  24706. _, ok := m.clearedFields[name]
  24707. return ok
  24708. }
  24709. // ClearField clears the value of the field with the given name. It returns an
  24710. // error if the field is not defined in the schema.
  24711. func (m *MsgMutation) ClearField(name string) error {
  24712. switch name {
  24713. case msg.FieldDeletedAt:
  24714. m.ClearDeletedAt()
  24715. return nil
  24716. case msg.FieldStatus:
  24717. m.ClearStatus()
  24718. return nil
  24719. case msg.FieldFromwxid:
  24720. m.ClearFromwxid()
  24721. return nil
  24722. case msg.FieldToid:
  24723. m.ClearToid()
  24724. return nil
  24725. case msg.FieldMsgtype:
  24726. m.ClearMsgtype()
  24727. return nil
  24728. case msg.FieldMsg:
  24729. m.ClearMsg()
  24730. return nil
  24731. case msg.FieldBatchNo:
  24732. m.ClearBatchNo()
  24733. return nil
  24734. }
  24735. return fmt.Errorf("unknown Msg nullable field %s", name)
  24736. }
  24737. // ResetField resets all changes in the mutation for the field with the given name.
  24738. // It returns an error if the field is not defined in the schema.
  24739. func (m *MsgMutation) ResetField(name string) error {
  24740. switch name {
  24741. case msg.FieldCreatedAt:
  24742. m.ResetCreatedAt()
  24743. return nil
  24744. case msg.FieldUpdatedAt:
  24745. m.ResetUpdatedAt()
  24746. return nil
  24747. case msg.FieldDeletedAt:
  24748. m.ResetDeletedAt()
  24749. return nil
  24750. case msg.FieldStatus:
  24751. m.ResetStatus()
  24752. return nil
  24753. case msg.FieldFromwxid:
  24754. m.ResetFromwxid()
  24755. return nil
  24756. case msg.FieldToid:
  24757. m.ResetToid()
  24758. return nil
  24759. case msg.FieldMsgtype:
  24760. m.ResetMsgtype()
  24761. return nil
  24762. case msg.FieldMsg:
  24763. m.ResetMsg()
  24764. return nil
  24765. case msg.FieldBatchNo:
  24766. m.ResetBatchNo()
  24767. return nil
  24768. case msg.FieldCc:
  24769. m.ResetCc()
  24770. return nil
  24771. case msg.FieldPhone:
  24772. m.ResetPhone()
  24773. return nil
  24774. }
  24775. return fmt.Errorf("unknown Msg field %s", name)
  24776. }
  24777. // AddedEdges returns all edge names that were set/added in this mutation.
  24778. func (m *MsgMutation) AddedEdges() []string {
  24779. edges := make([]string, 0, 0)
  24780. return edges
  24781. }
  24782. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24783. // name in this mutation.
  24784. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  24785. return nil
  24786. }
  24787. // RemovedEdges returns all edge names that were removed in this mutation.
  24788. func (m *MsgMutation) RemovedEdges() []string {
  24789. edges := make([]string, 0, 0)
  24790. return edges
  24791. }
  24792. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24793. // the given name in this mutation.
  24794. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  24795. return nil
  24796. }
  24797. // ClearedEdges returns all edge names that were cleared in this mutation.
  24798. func (m *MsgMutation) ClearedEdges() []string {
  24799. edges := make([]string, 0, 0)
  24800. return edges
  24801. }
  24802. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24803. // was cleared in this mutation.
  24804. func (m *MsgMutation) EdgeCleared(name string) bool {
  24805. return false
  24806. }
  24807. // ClearEdge clears the value of the edge with the given name. It returns an error
  24808. // if that edge is not defined in the schema.
  24809. func (m *MsgMutation) ClearEdge(name string) error {
  24810. return fmt.Errorf("unknown Msg unique edge %s", name)
  24811. }
  24812. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24813. // It returns an error if the edge is not defined in the schema.
  24814. func (m *MsgMutation) ResetEdge(name string) error {
  24815. return fmt.Errorf("unknown Msg edge %s", name)
  24816. }
  24817. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  24818. type PayRechargeMutation struct {
  24819. config
  24820. op Op
  24821. typ string
  24822. id *uint64
  24823. created_at *time.Time
  24824. updated_at *time.Time
  24825. deleted_at *time.Time
  24826. user_id *string
  24827. number *float32
  24828. addnumber *float32
  24829. status *int
  24830. addstatus *int
  24831. money *float32
  24832. addmoney *float32
  24833. out_trade_no *string
  24834. organization_id *uint64
  24835. addorganization_id *int64
  24836. clearedFields map[string]struct{}
  24837. done bool
  24838. oldValue func(context.Context) (*PayRecharge, error)
  24839. predicates []predicate.PayRecharge
  24840. }
  24841. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  24842. // payrechargeOption allows management of the mutation configuration using functional options.
  24843. type payrechargeOption func(*PayRechargeMutation)
  24844. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  24845. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  24846. m := &PayRechargeMutation{
  24847. config: c,
  24848. op: op,
  24849. typ: TypePayRecharge,
  24850. clearedFields: make(map[string]struct{}),
  24851. }
  24852. for _, opt := range opts {
  24853. opt(m)
  24854. }
  24855. return m
  24856. }
  24857. // withPayRechargeID sets the ID field of the mutation.
  24858. func withPayRechargeID(id uint64) payrechargeOption {
  24859. return func(m *PayRechargeMutation) {
  24860. var (
  24861. err error
  24862. once sync.Once
  24863. value *PayRecharge
  24864. )
  24865. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  24866. once.Do(func() {
  24867. if m.done {
  24868. err = errors.New("querying old values post mutation is not allowed")
  24869. } else {
  24870. value, err = m.Client().PayRecharge.Get(ctx, id)
  24871. }
  24872. })
  24873. return value, err
  24874. }
  24875. m.id = &id
  24876. }
  24877. }
  24878. // withPayRecharge sets the old PayRecharge of the mutation.
  24879. func withPayRecharge(node *PayRecharge) payrechargeOption {
  24880. return func(m *PayRechargeMutation) {
  24881. m.oldValue = func(context.Context) (*PayRecharge, error) {
  24882. return node, nil
  24883. }
  24884. m.id = &node.ID
  24885. }
  24886. }
  24887. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24888. // executed in a transaction (ent.Tx), a transactional client is returned.
  24889. func (m PayRechargeMutation) Client() *Client {
  24890. client := &Client{config: m.config}
  24891. client.init()
  24892. return client
  24893. }
  24894. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24895. // it returns an error otherwise.
  24896. func (m PayRechargeMutation) Tx() (*Tx, error) {
  24897. if _, ok := m.driver.(*txDriver); !ok {
  24898. return nil, errors.New("ent: mutation is not running in a transaction")
  24899. }
  24900. tx := &Tx{config: m.config}
  24901. tx.init()
  24902. return tx, nil
  24903. }
  24904. // SetID sets the value of the id field. Note that this
  24905. // operation is only accepted on creation of PayRecharge entities.
  24906. func (m *PayRechargeMutation) SetID(id uint64) {
  24907. m.id = &id
  24908. }
  24909. // ID returns the ID value in the mutation. Note that the ID is only available
  24910. // if it was provided to the builder or after it was returned from the database.
  24911. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  24912. if m.id == nil {
  24913. return
  24914. }
  24915. return *m.id, true
  24916. }
  24917. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24918. // That means, if the mutation is applied within a transaction with an isolation level such
  24919. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24920. // or updated by the mutation.
  24921. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  24922. switch {
  24923. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24924. id, exists := m.ID()
  24925. if exists {
  24926. return []uint64{id}, nil
  24927. }
  24928. fallthrough
  24929. case m.op.Is(OpUpdate | OpDelete):
  24930. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  24931. default:
  24932. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24933. }
  24934. }
  24935. // SetCreatedAt sets the "created_at" field.
  24936. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  24937. m.created_at = &t
  24938. }
  24939. // CreatedAt returns the value of the "created_at" field in the mutation.
  24940. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  24941. v := m.created_at
  24942. if v == nil {
  24943. return
  24944. }
  24945. return *v, true
  24946. }
  24947. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  24948. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  24949. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24950. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24951. if !m.op.Is(OpUpdateOne) {
  24952. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24953. }
  24954. if m.id == nil || m.oldValue == nil {
  24955. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24956. }
  24957. oldValue, err := m.oldValue(ctx)
  24958. if err != nil {
  24959. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24960. }
  24961. return oldValue.CreatedAt, nil
  24962. }
  24963. // ResetCreatedAt resets all changes to the "created_at" field.
  24964. func (m *PayRechargeMutation) ResetCreatedAt() {
  24965. m.created_at = nil
  24966. }
  24967. // SetUpdatedAt sets the "updated_at" field.
  24968. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  24969. m.updated_at = &t
  24970. }
  24971. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24972. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  24973. v := m.updated_at
  24974. if v == nil {
  24975. return
  24976. }
  24977. return *v, true
  24978. }
  24979. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  24980. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  24981. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24982. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24983. if !m.op.Is(OpUpdateOne) {
  24984. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24985. }
  24986. if m.id == nil || m.oldValue == nil {
  24987. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24988. }
  24989. oldValue, err := m.oldValue(ctx)
  24990. if err != nil {
  24991. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24992. }
  24993. return oldValue.UpdatedAt, nil
  24994. }
  24995. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24996. func (m *PayRechargeMutation) ResetUpdatedAt() {
  24997. m.updated_at = nil
  24998. }
  24999. // SetDeletedAt sets the "deleted_at" field.
  25000. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  25001. m.deleted_at = &t
  25002. }
  25003. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25004. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  25005. v := m.deleted_at
  25006. if v == nil {
  25007. return
  25008. }
  25009. return *v, true
  25010. }
  25011. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  25012. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  25013. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25014. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25015. if !m.op.Is(OpUpdateOne) {
  25016. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25017. }
  25018. if m.id == nil || m.oldValue == nil {
  25019. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25020. }
  25021. oldValue, err := m.oldValue(ctx)
  25022. if err != nil {
  25023. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25024. }
  25025. return oldValue.DeletedAt, nil
  25026. }
  25027. // ClearDeletedAt clears the value of the "deleted_at" field.
  25028. func (m *PayRechargeMutation) ClearDeletedAt() {
  25029. m.deleted_at = nil
  25030. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  25031. }
  25032. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25033. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  25034. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  25035. return ok
  25036. }
  25037. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25038. func (m *PayRechargeMutation) ResetDeletedAt() {
  25039. m.deleted_at = nil
  25040. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  25041. }
  25042. // SetUserID sets the "user_id" field.
  25043. func (m *PayRechargeMutation) SetUserID(s string) {
  25044. m.user_id = &s
  25045. }
  25046. // UserID returns the value of the "user_id" field in the mutation.
  25047. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  25048. v := m.user_id
  25049. if v == nil {
  25050. return
  25051. }
  25052. return *v, true
  25053. }
  25054. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  25055. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  25056. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25057. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  25058. if !m.op.Is(OpUpdateOne) {
  25059. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  25060. }
  25061. if m.id == nil || m.oldValue == nil {
  25062. return v, errors.New("OldUserID requires an ID field in the mutation")
  25063. }
  25064. oldValue, err := m.oldValue(ctx)
  25065. if err != nil {
  25066. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  25067. }
  25068. return oldValue.UserID, nil
  25069. }
  25070. // ResetUserID resets all changes to the "user_id" field.
  25071. func (m *PayRechargeMutation) ResetUserID() {
  25072. m.user_id = nil
  25073. }
  25074. // SetNumber sets the "number" field.
  25075. func (m *PayRechargeMutation) SetNumber(f float32) {
  25076. m.number = &f
  25077. m.addnumber = nil
  25078. }
  25079. // Number returns the value of the "number" field in the mutation.
  25080. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  25081. v := m.number
  25082. if v == nil {
  25083. return
  25084. }
  25085. return *v, true
  25086. }
  25087. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  25088. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  25089. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25090. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  25091. if !m.op.Is(OpUpdateOne) {
  25092. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  25093. }
  25094. if m.id == nil || m.oldValue == nil {
  25095. return v, errors.New("OldNumber requires an ID field in the mutation")
  25096. }
  25097. oldValue, err := m.oldValue(ctx)
  25098. if err != nil {
  25099. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  25100. }
  25101. return oldValue.Number, nil
  25102. }
  25103. // AddNumber adds f to the "number" field.
  25104. func (m *PayRechargeMutation) AddNumber(f float32) {
  25105. if m.addnumber != nil {
  25106. *m.addnumber += f
  25107. } else {
  25108. m.addnumber = &f
  25109. }
  25110. }
  25111. // AddedNumber returns the value that was added to the "number" field in this mutation.
  25112. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  25113. v := m.addnumber
  25114. if v == nil {
  25115. return
  25116. }
  25117. return *v, true
  25118. }
  25119. // ResetNumber resets all changes to the "number" field.
  25120. func (m *PayRechargeMutation) ResetNumber() {
  25121. m.number = nil
  25122. m.addnumber = nil
  25123. }
  25124. // SetStatus sets the "status" field.
  25125. func (m *PayRechargeMutation) SetStatus(i int) {
  25126. m.status = &i
  25127. m.addstatus = nil
  25128. }
  25129. // Status returns the value of the "status" field in the mutation.
  25130. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  25131. v := m.status
  25132. if v == nil {
  25133. return
  25134. }
  25135. return *v, true
  25136. }
  25137. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  25138. // If the PayRecharge 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 *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  25141. if !m.op.Is(OpUpdateOne) {
  25142. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  25143. }
  25144. if m.id == nil || m.oldValue == nil {
  25145. return v, errors.New("OldStatus 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 OldStatus: %w", err)
  25150. }
  25151. return oldValue.Status, nil
  25152. }
  25153. // AddStatus adds i to the "status" field.
  25154. func (m *PayRechargeMutation) AddStatus(i int) {
  25155. if m.addstatus != nil {
  25156. *m.addstatus += i
  25157. } else {
  25158. m.addstatus = &i
  25159. }
  25160. }
  25161. // AddedStatus returns the value that was added to the "status" field in this mutation.
  25162. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  25163. v := m.addstatus
  25164. if v == nil {
  25165. return
  25166. }
  25167. return *v, true
  25168. }
  25169. // ClearStatus clears the value of the "status" field.
  25170. func (m *PayRechargeMutation) ClearStatus() {
  25171. m.status = nil
  25172. m.addstatus = nil
  25173. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  25174. }
  25175. // StatusCleared returns if the "status" field was cleared in this mutation.
  25176. func (m *PayRechargeMutation) StatusCleared() bool {
  25177. _, ok := m.clearedFields[payrecharge.FieldStatus]
  25178. return ok
  25179. }
  25180. // ResetStatus resets all changes to the "status" field.
  25181. func (m *PayRechargeMutation) ResetStatus() {
  25182. m.status = nil
  25183. m.addstatus = nil
  25184. delete(m.clearedFields, payrecharge.FieldStatus)
  25185. }
  25186. // SetMoney sets the "money" field.
  25187. func (m *PayRechargeMutation) SetMoney(f float32) {
  25188. m.money = &f
  25189. m.addmoney = nil
  25190. }
  25191. // Money returns the value of the "money" field in the mutation.
  25192. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  25193. v := m.money
  25194. if v == nil {
  25195. return
  25196. }
  25197. return *v, true
  25198. }
  25199. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  25200. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  25201. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25202. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  25203. if !m.op.Is(OpUpdateOne) {
  25204. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  25205. }
  25206. if m.id == nil || m.oldValue == nil {
  25207. return v, errors.New("OldMoney requires an ID field in the mutation")
  25208. }
  25209. oldValue, err := m.oldValue(ctx)
  25210. if err != nil {
  25211. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  25212. }
  25213. return oldValue.Money, nil
  25214. }
  25215. // AddMoney adds f to the "money" field.
  25216. func (m *PayRechargeMutation) AddMoney(f float32) {
  25217. if m.addmoney != nil {
  25218. *m.addmoney += f
  25219. } else {
  25220. m.addmoney = &f
  25221. }
  25222. }
  25223. // AddedMoney returns the value that was added to the "money" field in this mutation.
  25224. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  25225. v := m.addmoney
  25226. if v == nil {
  25227. return
  25228. }
  25229. return *v, true
  25230. }
  25231. // ClearMoney clears the value of the "money" field.
  25232. func (m *PayRechargeMutation) ClearMoney() {
  25233. m.money = nil
  25234. m.addmoney = nil
  25235. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  25236. }
  25237. // MoneyCleared returns if the "money" field was cleared in this mutation.
  25238. func (m *PayRechargeMutation) MoneyCleared() bool {
  25239. _, ok := m.clearedFields[payrecharge.FieldMoney]
  25240. return ok
  25241. }
  25242. // ResetMoney resets all changes to the "money" field.
  25243. func (m *PayRechargeMutation) ResetMoney() {
  25244. m.money = nil
  25245. m.addmoney = nil
  25246. delete(m.clearedFields, payrecharge.FieldMoney)
  25247. }
  25248. // SetOutTradeNo sets the "out_trade_no" field.
  25249. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  25250. m.out_trade_no = &s
  25251. }
  25252. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  25253. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  25254. v := m.out_trade_no
  25255. if v == nil {
  25256. return
  25257. }
  25258. return *v, true
  25259. }
  25260. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  25261. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  25262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25263. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  25264. if !m.op.Is(OpUpdateOne) {
  25265. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  25266. }
  25267. if m.id == nil || m.oldValue == nil {
  25268. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  25269. }
  25270. oldValue, err := m.oldValue(ctx)
  25271. if err != nil {
  25272. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  25273. }
  25274. return oldValue.OutTradeNo, nil
  25275. }
  25276. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  25277. func (m *PayRechargeMutation) ClearOutTradeNo() {
  25278. m.out_trade_no = nil
  25279. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  25280. }
  25281. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  25282. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  25283. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  25284. return ok
  25285. }
  25286. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  25287. func (m *PayRechargeMutation) ResetOutTradeNo() {
  25288. m.out_trade_no = nil
  25289. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  25290. }
  25291. // SetOrganizationID sets the "organization_id" field.
  25292. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  25293. m.organization_id = &u
  25294. m.addorganization_id = nil
  25295. }
  25296. // OrganizationID returns the value of the "organization_id" field in the mutation.
  25297. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  25298. v := m.organization_id
  25299. if v == nil {
  25300. return
  25301. }
  25302. return *v, true
  25303. }
  25304. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  25305. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  25306. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25307. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  25308. if !m.op.Is(OpUpdateOne) {
  25309. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  25310. }
  25311. if m.id == nil || m.oldValue == nil {
  25312. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  25313. }
  25314. oldValue, err := m.oldValue(ctx)
  25315. if err != nil {
  25316. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  25317. }
  25318. return oldValue.OrganizationID, nil
  25319. }
  25320. // AddOrganizationID adds u to the "organization_id" field.
  25321. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  25322. if m.addorganization_id != nil {
  25323. *m.addorganization_id += u
  25324. } else {
  25325. m.addorganization_id = &u
  25326. }
  25327. }
  25328. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  25329. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  25330. v := m.addorganization_id
  25331. if v == nil {
  25332. return
  25333. }
  25334. return *v, true
  25335. }
  25336. // ResetOrganizationID resets all changes to the "organization_id" field.
  25337. func (m *PayRechargeMutation) ResetOrganizationID() {
  25338. m.organization_id = nil
  25339. m.addorganization_id = nil
  25340. }
  25341. // Where appends a list predicates to the PayRechargeMutation builder.
  25342. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  25343. m.predicates = append(m.predicates, ps...)
  25344. }
  25345. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  25346. // users can use type-assertion to append predicates that do not depend on any generated package.
  25347. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  25348. p := make([]predicate.PayRecharge, len(ps))
  25349. for i := range ps {
  25350. p[i] = ps[i]
  25351. }
  25352. m.Where(p...)
  25353. }
  25354. // Op returns the operation name.
  25355. func (m *PayRechargeMutation) Op() Op {
  25356. return m.op
  25357. }
  25358. // SetOp allows setting the mutation operation.
  25359. func (m *PayRechargeMutation) SetOp(op Op) {
  25360. m.op = op
  25361. }
  25362. // Type returns the node type of this mutation (PayRecharge).
  25363. func (m *PayRechargeMutation) Type() string {
  25364. return m.typ
  25365. }
  25366. // Fields returns all fields that were changed during this mutation. Note that in
  25367. // order to get all numeric fields that were incremented/decremented, call
  25368. // AddedFields().
  25369. func (m *PayRechargeMutation) Fields() []string {
  25370. fields := make([]string, 0, 9)
  25371. if m.created_at != nil {
  25372. fields = append(fields, payrecharge.FieldCreatedAt)
  25373. }
  25374. if m.updated_at != nil {
  25375. fields = append(fields, payrecharge.FieldUpdatedAt)
  25376. }
  25377. if m.deleted_at != nil {
  25378. fields = append(fields, payrecharge.FieldDeletedAt)
  25379. }
  25380. if m.user_id != nil {
  25381. fields = append(fields, payrecharge.FieldUserID)
  25382. }
  25383. if m.number != nil {
  25384. fields = append(fields, payrecharge.FieldNumber)
  25385. }
  25386. if m.status != nil {
  25387. fields = append(fields, payrecharge.FieldStatus)
  25388. }
  25389. if m.money != nil {
  25390. fields = append(fields, payrecharge.FieldMoney)
  25391. }
  25392. if m.out_trade_no != nil {
  25393. fields = append(fields, payrecharge.FieldOutTradeNo)
  25394. }
  25395. if m.organization_id != nil {
  25396. fields = append(fields, payrecharge.FieldOrganizationID)
  25397. }
  25398. return fields
  25399. }
  25400. // Field returns the value of a field with the given name. The second boolean
  25401. // return value indicates that this field was not set, or was not defined in the
  25402. // schema.
  25403. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  25404. switch name {
  25405. case payrecharge.FieldCreatedAt:
  25406. return m.CreatedAt()
  25407. case payrecharge.FieldUpdatedAt:
  25408. return m.UpdatedAt()
  25409. case payrecharge.FieldDeletedAt:
  25410. return m.DeletedAt()
  25411. case payrecharge.FieldUserID:
  25412. return m.UserID()
  25413. case payrecharge.FieldNumber:
  25414. return m.Number()
  25415. case payrecharge.FieldStatus:
  25416. return m.Status()
  25417. case payrecharge.FieldMoney:
  25418. return m.Money()
  25419. case payrecharge.FieldOutTradeNo:
  25420. return m.OutTradeNo()
  25421. case payrecharge.FieldOrganizationID:
  25422. return m.OrganizationID()
  25423. }
  25424. return nil, false
  25425. }
  25426. // OldField returns the old value of the field from the database. An error is
  25427. // returned if the mutation operation is not UpdateOne, or the query to the
  25428. // database failed.
  25429. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25430. switch name {
  25431. case payrecharge.FieldCreatedAt:
  25432. return m.OldCreatedAt(ctx)
  25433. case payrecharge.FieldUpdatedAt:
  25434. return m.OldUpdatedAt(ctx)
  25435. case payrecharge.FieldDeletedAt:
  25436. return m.OldDeletedAt(ctx)
  25437. case payrecharge.FieldUserID:
  25438. return m.OldUserID(ctx)
  25439. case payrecharge.FieldNumber:
  25440. return m.OldNumber(ctx)
  25441. case payrecharge.FieldStatus:
  25442. return m.OldStatus(ctx)
  25443. case payrecharge.FieldMoney:
  25444. return m.OldMoney(ctx)
  25445. case payrecharge.FieldOutTradeNo:
  25446. return m.OldOutTradeNo(ctx)
  25447. case payrecharge.FieldOrganizationID:
  25448. return m.OldOrganizationID(ctx)
  25449. }
  25450. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  25451. }
  25452. // SetField sets the value of a field with the given name. It returns an error if
  25453. // the field is not defined in the schema, or if the type mismatched the field
  25454. // type.
  25455. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  25456. switch name {
  25457. case payrecharge.FieldCreatedAt:
  25458. v, ok := value.(time.Time)
  25459. if !ok {
  25460. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25461. }
  25462. m.SetCreatedAt(v)
  25463. return nil
  25464. case payrecharge.FieldUpdatedAt:
  25465. v, ok := value.(time.Time)
  25466. if !ok {
  25467. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25468. }
  25469. m.SetUpdatedAt(v)
  25470. return nil
  25471. case payrecharge.FieldDeletedAt:
  25472. v, ok := value.(time.Time)
  25473. if !ok {
  25474. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25475. }
  25476. m.SetDeletedAt(v)
  25477. return nil
  25478. case payrecharge.FieldUserID:
  25479. v, ok := value.(string)
  25480. if !ok {
  25481. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25482. }
  25483. m.SetUserID(v)
  25484. return nil
  25485. case payrecharge.FieldNumber:
  25486. v, ok := value.(float32)
  25487. if !ok {
  25488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25489. }
  25490. m.SetNumber(v)
  25491. return nil
  25492. case payrecharge.FieldStatus:
  25493. v, ok := value.(int)
  25494. if !ok {
  25495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25496. }
  25497. m.SetStatus(v)
  25498. return nil
  25499. case payrecharge.FieldMoney:
  25500. v, ok := value.(float32)
  25501. if !ok {
  25502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25503. }
  25504. m.SetMoney(v)
  25505. return nil
  25506. case payrecharge.FieldOutTradeNo:
  25507. v, ok := value.(string)
  25508. if !ok {
  25509. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25510. }
  25511. m.SetOutTradeNo(v)
  25512. return nil
  25513. case payrecharge.FieldOrganizationID:
  25514. v, ok := value.(uint64)
  25515. if !ok {
  25516. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25517. }
  25518. m.SetOrganizationID(v)
  25519. return nil
  25520. }
  25521. return fmt.Errorf("unknown PayRecharge field %s", name)
  25522. }
  25523. // AddedFields returns all numeric fields that were incremented/decremented during
  25524. // this mutation.
  25525. func (m *PayRechargeMutation) AddedFields() []string {
  25526. var fields []string
  25527. if m.addnumber != nil {
  25528. fields = append(fields, payrecharge.FieldNumber)
  25529. }
  25530. if m.addstatus != nil {
  25531. fields = append(fields, payrecharge.FieldStatus)
  25532. }
  25533. if m.addmoney != nil {
  25534. fields = append(fields, payrecharge.FieldMoney)
  25535. }
  25536. if m.addorganization_id != nil {
  25537. fields = append(fields, payrecharge.FieldOrganizationID)
  25538. }
  25539. return fields
  25540. }
  25541. // AddedField returns the numeric value that was incremented/decremented on a field
  25542. // with the given name. The second boolean return value indicates that this field
  25543. // was not set, or was not defined in the schema.
  25544. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  25545. switch name {
  25546. case payrecharge.FieldNumber:
  25547. return m.AddedNumber()
  25548. case payrecharge.FieldStatus:
  25549. return m.AddedStatus()
  25550. case payrecharge.FieldMoney:
  25551. return m.AddedMoney()
  25552. case payrecharge.FieldOrganizationID:
  25553. return m.AddedOrganizationID()
  25554. }
  25555. return nil, false
  25556. }
  25557. // AddField adds the value to the field with the given name. It returns an error if
  25558. // the field is not defined in the schema, or if the type mismatched the field
  25559. // type.
  25560. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  25561. switch name {
  25562. case payrecharge.FieldNumber:
  25563. v, ok := value.(float32)
  25564. if !ok {
  25565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25566. }
  25567. m.AddNumber(v)
  25568. return nil
  25569. case payrecharge.FieldStatus:
  25570. v, ok := value.(int)
  25571. if !ok {
  25572. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25573. }
  25574. m.AddStatus(v)
  25575. return nil
  25576. case payrecharge.FieldMoney:
  25577. v, ok := value.(float32)
  25578. if !ok {
  25579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25580. }
  25581. m.AddMoney(v)
  25582. return nil
  25583. case payrecharge.FieldOrganizationID:
  25584. v, ok := value.(int64)
  25585. if !ok {
  25586. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25587. }
  25588. m.AddOrganizationID(v)
  25589. return nil
  25590. }
  25591. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  25592. }
  25593. // ClearedFields returns all nullable fields that were cleared during this
  25594. // mutation.
  25595. func (m *PayRechargeMutation) ClearedFields() []string {
  25596. var fields []string
  25597. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  25598. fields = append(fields, payrecharge.FieldDeletedAt)
  25599. }
  25600. if m.FieldCleared(payrecharge.FieldStatus) {
  25601. fields = append(fields, payrecharge.FieldStatus)
  25602. }
  25603. if m.FieldCleared(payrecharge.FieldMoney) {
  25604. fields = append(fields, payrecharge.FieldMoney)
  25605. }
  25606. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  25607. fields = append(fields, payrecharge.FieldOutTradeNo)
  25608. }
  25609. return fields
  25610. }
  25611. // FieldCleared returns a boolean indicating if a field with the given name was
  25612. // cleared in this mutation.
  25613. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  25614. _, ok := m.clearedFields[name]
  25615. return ok
  25616. }
  25617. // ClearField clears the value of the field with the given name. It returns an
  25618. // error if the field is not defined in the schema.
  25619. func (m *PayRechargeMutation) ClearField(name string) error {
  25620. switch name {
  25621. case payrecharge.FieldDeletedAt:
  25622. m.ClearDeletedAt()
  25623. return nil
  25624. case payrecharge.FieldStatus:
  25625. m.ClearStatus()
  25626. return nil
  25627. case payrecharge.FieldMoney:
  25628. m.ClearMoney()
  25629. return nil
  25630. case payrecharge.FieldOutTradeNo:
  25631. m.ClearOutTradeNo()
  25632. return nil
  25633. }
  25634. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  25635. }
  25636. // ResetField resets all changes in the mutation for the field with the given name.
  25637. // It returns an error if the field is not defined in the schema.
  25638. func (m *PayRechargeMutation) ResetField(name string) error {
  25639. switch name {
  25640. case payrecharge.FieldCreatedAt:
  25641. m.ResetCreatedAt()
  25642. return nil
  25643. case payrecharge.FieldUpdatedAt:
  25644. m.ResetUpdatedAt()
  25645. return nil
  25646. case payrecharge.FieldDeletedAt:
  25647. m.ResetDeletedAt()
  25648. return nil
  25649. case payrecharge.FieldUserID:
  25650. m.ResetUserID()
  25651. return nil
  25652. case payrecharge.FieldNumber:
  25653. m.ResetNumber()
  25654. return nil
  25655. case payrecharge.FieldStatus:
  25656. m.ResetStatus()
  25657. return nil
  25658. case payrecharge.FieldMoney:
  25659. m.ResetMoney()
  25660. return nil
  25661. case payrecharge.FieldOutTradeNo:
  25662. m.ResetOutTradeNo()
  25663. return nil
  25664. case payrecharge.FieldOrganizationID:
  25665. m.ResetOrganizationID()
  25666. return nil
  25667. }
  25668. return fmt.Errorf("unknown PayRecharge field %s", name)
  25669. }
  25670. // AddedEdges returns all edge names that were set/added in this mutation.
  25671. func (m *PayRechargeMutation) AddedEdges() []string {
  25672. edges := make([]string, 0, 0)
  25673. return edges
  25674. }
  25675. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25676. // name in this mutation.
  25677. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  25678. return nil
  25679. }
  25680. // RemovedEdges returns all edge names that were removed in this mutation.
  25681. func (m *PayRechargeMutation) RemovedEdges() []string {
  25682. edges := make([]string, 0, 0)
  25683. return edges
  25684. }
  25685. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25686. // the given name in this mutation.
  25687. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  25688. return nil
  25689. }
  25690. // ClearedEdges returns all edge names that were cleared in this mutation.
  25691. func (m *PayRechargeMutation) ClearedEdges() []string {
  25692. edges := make([]string, 0, 0)
  25693. return edges
  25694. }
  25695. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25696. // was cleared in this mutation.
  25697. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  25698. return false
  25699. }
  25700. // ClearEdge clears the value of the edge with the given name. It returns an error
  25701. // if that edge is not defined in the schema.
  25702. func (m *PayRechargeMutation) ClearEdge(name string) error {
  25703. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  25704. }
  25705. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25706. // It returns an error if the edge is not defined in the schema.
  25707. func (m *PayRechargeMutation) ResetEdge(name string) error {
  25708. return fmt.Errorf("unknown PayRecharge edge %s", name)
  25709. }
  25710. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  25711. type ServerMutation struct {
  25712. config
  25713. op Op
  25714. typ string
  25715. id *uint64
  25716. created_at *time.Time
  25717. updated_at *time.Time
  25718. status *uint8
  25719. addstatus *int8
  25720. deleted_at *time.Time
  25721. name *string
  25722. public_ip *string
  25723. private_ip *string
  25724. admin_port *string
  25725. clearedFields map[string]struct{}
  25726. wxs map[uint64]struct{}
  25727. removedwxs map[uint64]struct{}
  25728. clearedwxs bool
  25729. done bool
  25730. oldValue func(context.Context) (*Server, error)
  25731. predicates []predicate.Server
  25732. }
  25733. var _ ent.Mutation = (*ServerMutation)(nil)
  25734. // serverOption allows management of the mutation configuration using functional options.
  25735. type serverOption func(*ServerMutation)
  25736. // newServerMutation creates new mutation for the Server entity.
  25737. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  25738. m := &ServerMutation{
  25739. config: c,
  25740. op: op,
  25741. typ: TypeServer,
  25742. clearedFields: make(map[string]struct{}),
  25743. }
  25744. for _, opt := range opts {
  25745. opt(m)
  25746. }
  25747. return m
  25748. }
  25749. // withServerID sets the ID field of the mutation.
  25750. func withServerID(id uint64) serverOption {
  25751. return func(m *ServerMutation) {
  25752. var (
  25753. err error
  25754. once sync.Once
  25755. value *Server
  25756. )
  25757. m.oldValue = func(ctx context.Context) (*Server, error) {
  25758. once.Do(func() {
  25759. if m.done {
  25760. err = errors.New("querying old values post mutation is not allowed")
  25761. } else {
  25762. value, err = m.Client().Server.Get(ctx, id)
  25763. }
  25764. })
  25765. return value, err
  25766. }
  25767. m.id = &id
  25768. }
  25769. }
  25770. // withServer sets the old Server of the mutation.
  25771. func withServer(node *Server) serverOption {
  25772. return func(m *ServerMutation) {
  25773. m.oldValue = func(context.Context) (*Server, error) {
  25774. return node, nil
  25775. }
  25776. m.id = &node.ID
  25777. }
  25778. }
  25779. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25780. // executed in a transaction (ent.Tx), a transactional client is returned.
  25781. func (m ServerMutation) Client() *Client {
  25782. client := &Client{config: m.config}
  25783. client.init()
  25784. return client
  25785. }
  25786. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25787. // it returns an error otherwise.
  25788. func (m ServerMutation) Tx() (*Tx, error) {
  25789. if _, ok := m.driver.(*txDriver); !ok {
  25790. return nil, errors.New("ent: mutation is not running in a transaction")
  25791. }
  25792. tx := &Tx{config: m.config}
  25793. tx.init()
  25794. return tx, nil
  25795. }
  25796. // SetID sets the value of the id field. Note that this
  25797. // operation is only accepted on creation of Server entities.
  25798. func (m *ServerMutation) SetID(id uint64) {
  25799. m.id = &id
  25800. }
  25801. // ID returns the ID value in the mutation. Note that the ID is only available
  25802. // if it was provided to the builder or after it was returned from the database.
  25803. func (m *ServerMutation) ID() (id uint64, exists bool) {
  25804. if m.id == nil {
  25805. return
  25806. }
  25807. return *m.id, true
  25808. }
  25809. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  25810. // That means, if the mutation is applied within a transaction with an isolation level such
  25811. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  25812. // or updated by the mutation.
  25813. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  25814. switch {
  25815. case m.op.Is(OpUpdateOne | OpDeleteOne):
  25816. id, exists := m.ID()
  25817. if exists {
  25818. return []uint64{id}, nil
  25819. }
  25820. fallthrough
  25821. case m.op.Is(OpUpdate | OpDelete):
  25822. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  25823. default:
  25824. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  25825. }
  25826. }
  25827. // SetCreatedAt sets the "created_at" field.
  25828. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  25829. m.created_at = &t
  25830. }
  25831. // CreatedAt returns the value of the "created_at" field in the mutation.
  25832. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  25833. v := m.created_at
  25834. if v == nil {
  25835. return
  25836. }
  25837. return *v, true
  25838. }
  25839. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  25840. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  25841. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25842. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  25843. if !m.op.Is(OpUpdateOne) {
  25844. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  25845. }
  25846. if m.id == nil || m.oldValue == nil {
  25847. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  25848. }
  25849. oldValue, err := m.oldValue(ctx)
  25850. if err != nil {
  25851. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  25852. }
  25853. return oldValue.CreatedAt, nil
  25854. }
  25855. // ResetCreatedAt resets all changes to the "created_at" field.
  25856. func (m *ServerMutation) ResetCreatedAt() {
  25857. m.created_at = nil
  25858. }
  25859. // SetUpdatedAt sets the "updated_at" field.
  25860. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  25861. m.updated_at = &t
  25862. }
  25863. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  25864. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  25865. v := m.updated_at
  25866. if v == nil {
  25867. return
  25868. }
  25869. return *v, true
  25870. }
  25871. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  25872. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  25873. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25874. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25875. if !m.op.Is(OpUpdateOne) {
  25876. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25877. }
  25878. if m.id == nil || m.oldValue == nil {
  25879. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  25880. }
  25881. oldValue, err := m.oldValue(ctx)
  25882. if err != nil {
  25883. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  25884. }
  25885. return oldValue.UpdatedAt, nil
  25886. }
  25887. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25888. func (m *ServerMutation) ResetUpdatedAt() {
  25889. m.updated_at = nil
  25890. }
  25891. // SetStatus sets the "status" field.
  25892. func (m *ServerMutation) SetStatus(u uint8) {
  25893. m.status = &u
  25894. m.addstatus = nil
  25895. }
  25896. // Status returns the value of the "status" field in the mutation.
  25897. func (m *ServerMutation) Status() (r uint8, exists bool) {
  25898. v := m.status
  25899. if v == nil {
  25900. return
  25901. }
  25902. return *v, true
  25903. }
  25904. // OldStatus returns the old "status" field's value of the Server entity.
  25905. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  25906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25907. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  25908. if !m.op.Is(OpUpdateOne) {
  25909. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  25910. }
  25911. if m.id == nil || m.oldValue == nil {
  25912. return v, errors.New("OldStatus requires an ID field in the mutation")
  25913. }
  25914. oldValue, err := m.oldValue(ctx)
  25915. if err != nil {
  25916. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  25917. }
  25918. return oldValue.Status, nil
  25919. }
  25920. // AddStatus adds u to the "status" field.
  25921. func (m *ServerMutation) AddStatus(u int8) {
  25922. if m.addstatus != nil {
  25923. *m.addstatus += u
  25924. } else {
  25925. m.addstatus = &u
  25926. }
  25927. }
  25928. // AddedStatus returns the value that was added to the "status" field in this mutation.
  25929. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  25930. v := m.addstatus
  25931. if v == nil {
  25932. return
  25933. }
  25934. return *v, true
  25935. }
  25936. // ClearStatus clears the value of the "status" field.
  25937. func (m *ServerMutation) ClearStatus() {
  25938. m.status = nil
  25939. m.addstatus = nil
  25940. m.clearedFields[server.FieldStatus] = struct{}{}
  25941. }
  25942. // StatusCleared returns if the "status" field was cleared in this mutation.
  25943. func (m *ServerMutation) StatusCleared() bool {
  25944. _, ok := m.clearedFields[server.FieldStatus]
  25945. return ok
  25946. }
  25947. // ResetStatus resets all changes to the "status" field.
  25948. func (m *ServerMutation) ResetStatus() {
  25949. m.status = nil
  25950. m.addstatus = nil
  25951. delete(m.clearedFields, server.FieldStatus)
  25952. }
  25953. // SetDeletedAt sets the "deleted_at" field.
  25954. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  25955. m.deleted_at = &t
  25956. }
  25957. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25958. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  25959. v := m.deleted_at
  25960. if v == nil {
  25961. return
  25962. }
  25963. return *v, true
  25964. }
  25965. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  25966. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  25967. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25968. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25969. if !m.op.Is(OpUpdateOne) {
  25970. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25971. }
  25972. if m.id == nil || m.oldValue == nil {
  25973. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25974. }
  25975. oldValue, err := m.oldValue(ctx)
  25976. if err != nil {
  25977. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25978. }
  25979. return oldValue.DeletedAt, nil
  25980. }
  25981. // ClearDeletedAt clears the value of the "deleted_at" field.
  25982. func (m *ServerMutation) ClearDeletedAt() {
  25983. m.deleted_at = nil
  25984. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  25985. }
  25986. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25987. func (m *ServerMutation) DeletedAtCleared() bool {
  25988. _, ok := m.clearedFields[server.FieldDeletedAt]
  25989. return ok
  25990. }
  25991. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25992. func (m *ServerMutation) ResetDeletedAt() {
  25993. m.deleted_at = nil
  25994. delete(m.clearedFields, server.FieldDeletedAt)
  25995. }
  25996. // SetName sets the "name" field.
  25997. func (m *ServerMutation) SetName(s string) {
  25998. m.name = &s
  25999. }
  26000. // Name returns the value of the "name" field in the mutation.
  26001. func (m *ServerMutation) Name() (r string, exists bool) {
  26002. v := m.name
  26003. if v == nil {
  26004. return
  26005. }
  26006. return *v, true
  26007. }
  26008. // OldName returns the old "name" field's value of the Server entity.
  26009. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  26010. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26011. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  26012. if !m.op.Is(OpUpdateOne) {
  26013. return v, errors.New("OldName is only allowed on UpdateOne operations")
  26014. }
  26015. if m.id == nil || m.oldValue == nil {
  26016. return v, errors.New("OldName requires an ID field in the mutation")
  26017. }
  26018. oldValue, err := m.oldValue(ctx)
  26019. if err != nil {
  26020. return v, fmt.Errorf("querying old value for OldName: %w", err)
  26021. }
  26022. return oldValue.Name, nil
  26023. }
  26024. // ResetName resets all changes to the "name" field.
  26025. func (m *ServerMutation) ResetName() {
  26026. m.name = nil
  26027. }
  26028. // SetPublicIP sets the "public_ip" field.
  26029. func (m *ServerMutation) SetPublicIP(s string) {
  26030. m.public_ip = &s
  26031. }
  26032. // PublicIP returns the value of the "public_ip" field in the mutation.
  26033. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  26034. v := m.public_ip
  26035. if v == nil {
  26036. return
  26037. }
  26038. return *v, true
  26039. }
  26040. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  26041. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  26042. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26043. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  26044. if !m.op.Is(OpUpdateOne) {
  26045. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  26046. }
  26047. if m.id == nil || m.oldValue == nil {
  26048. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  26049. }
  26050. oldValue, err := m.oldValue(ctx)
  26051. if err != nil {
  26052. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  26053. }
  26054. return oldValue.PublicIP, nil
  26055. }
  26056. // ResetPublicIP resets all changes to the "public_ip" field.
  26057. func (m *ServerMutation) ResetPublicIP() {
  26058. m.public_ip = nil
  26059. }
  26060. // SetPrivateIP sets the "private_ip" field.
  26061. func (m *ServerMutation) SetPrivateIP(s string) {
  26062. m.private_ip = &s
  26063. }
  26064. // PrivateIP returns the value of the "private_ip" field in the mutation.
  26065. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  26066. v := m.private_ip
  26067. if v == nil {
  26068. return
  26069. }
  26070. return *v, true
  26071. }
  26072. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  26073. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  26074. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26075. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  26076. if !m.op.Is(OpUpdateOne) {
  26077. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  26078. }
  26079. if m.id == nil || m.oldValue == nil {
  26080. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  26081. }
  26082. oldValue, err := m.oldValue(ctx)
  26083. if err != nil {
  26084. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  26085. }
  26086. return oldValue.PrivateIP, nil
  26087. }
  26088. // ResetPrivateIP resets all changes to the "private_ip" field.
  26089. func (m *ServerMutation) ResetPrivateIP() {
  26090. m.private_ip = nil
  26091. }
  26092. // SetAdminPort sets the "admin_port" field.
  26093. func (m *ServerMutation) SetAdminPort(s string) {
  26094. m.admin_port = &s
  26095. }
  26096. // AdminPort returns the value of the "admin_port" field in the mutation.
  26097. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  26098. v := m.admin_port
  26099. if v == nil {
  26100. return
  26101. }
  26102. return *v, true
  26103. }
  26104. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  26105. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  26106. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26107. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  26108. if !m.op.Is(OpUpdateOne) {
  26109. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  26110. }
  26111. if m.id == nil || m.oldValue == nil {
  26112. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  26113. }
  26114. oldValue, err := m.oldValue(ctx)
  26115. if err != nil {
  26116. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  26117. }
  26118. return oldValue.AdminPort, nil
  26119. }
  26120. // ResetAdminPort resets all changes to the "admin_port" field.
  26121. func (m *ServerMutation) ResetAdminPort() {
  26122. m.admin_port = nil
  26123. }
  26124. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  26125. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  26126. if m.wxs == nil {
  26127. m.wxs = make(map[uint64]struct{})
  26128. }
  26129. for i := range ids {
  26130. m.wxs[ids[i]] = struct{}{}
  26131. }
  26132. }
  26133. // ClearWxs clears the "wxs" edge to the Wx entity.
  26134. func (m *ServerMutation) ClearWxs() {
  26135. m.clearedwxs = true
  26136. }
  26137. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  26138. func (m *ServerMutation) WxsCleared() bool {
  26139. return m.clearedwxs
  26140. }
  26141. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  26142. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  26143. if m.removedwxs == nil {
  26144. m.removedwxs = make(map[uint64]struct{})
  26145. }
  26146. for i := range ids {
  26147. delete(m.wxs, ids[i])
  26148. m.removedwxs[ids[i]] = struct{}{}
  26149. }
  26150. }
  26151. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  26152. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  26153. for id := range m.removedwxs {
  26154. ids = append(ids, id)
  26155. }
  26156. return
  26157. }
  26158. // WxsIDs returns the "wxs" edge IDs in the mutation.
  26159. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  26160. for id := range m.wxs {
  26161. ids = append(ids, id)
  26162. }
  26163. return
  26164. }
  26165. // ResetWxs resets all changes to the "wxs" edge.
  26166. func (m *ServerMutation) ResetWxs() {
  26167. m.wxs = nil
  26168. m.clearedwxs = false
  26169. m.removedwxs = nil
  26170. }
  26171. // Where appends a list predicates to the ServerMutation builder.
  26172. func (m *ServerMutation) Where(ps ...predicate.Server) {
  26173. m.predicates = append(m.predicates, ps...)
  26174. }
  26175. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  26176. // users can use type-assertion to append predicates that do not depend on any generated package.
  26177. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  26178. p := make([]predicate.Server, len(ps))
  26179. for i := range ps {
  26180. p[i] = ps[i]
  26181. }
  26182. m.Where(p...)
  26183. }
  26184. // Op returns the operation name.
  26185. func (m *ServerMutation) Op() Op {
  26186. return m.op
  26187. }
  26188. // SetOp allows setting the mutation operation.
  26189. func (m *ServerMutation) SetOp(op Op) {
  26190. m.op = op
  26191. }
  26192. // Type returns the node type of this mutation (Server).
  26193. func (m *ServerMutation) Type() string {
  26194. return m.typ
  26195. }
  26196. // Fields returns all fields that were changed during this mutation. Note that in
  26197. // order to get all numeric fields that were incremented/decremented, call
  26198. // AddedFields().
  26199. func (m *ServerMutation) Fields() []string {
  26200. fields := make([]string, 0, 8)
  26201. if m.created_at != nil {
  26202. fields = append(fields, server.FieldCreatedAt)
  26203. }
  26204. if m.updated_at != nil {
  26205. fields = append(fields, server.FieldUpdatedAt)
  26206. }
  26207. if m.status != nil {
  26208. fields = append(fields, server.FieldStatus)
  26209. }
  26210. if m.deleted_at != nil {
  26211. fields = append(fields, server.FieldDeletedAt)
  26212. }
  26213. if m.name != nil {
  26214. fields = append(fields, server.FieldName)
  26215. }
  26216. if m.public_ip != nil {
  26217. fields = append(fields, server.FieldPublicIP)
  26218. }
  26219. if m.private_ip != nil {
  26220. fields = append(fields, server.FieldPrivateIP)
  26221. }
  26222. if m.admin_port != nil {
  26223. fields = append(fields, server.FieldAdminPort)
  26224. }
  26225. return fields
  26226. }
  26227. // Field returns the value of a field with the given name. The second boolean
  26228. // return value indicates that this field was not set, or was not defined in the
  26229. // schema.
  26230. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  26231. switch name {
  26232. case server.FieldCreatedAt:
  26233. return m.CreatedAt()
  26234. case server.FieldUpdatedAt:
  26235. return m.UpdatedAt()
  26236. case server.FieldStatus:
  26237. return m.Status()
  26238. case server.FieldDeletedAt:
  26239. return m.DeletedAt()
  26240. case server.FieldName:
  26241. return m.Name()
  26242. case server.FieldPublicIP:
  26243. return m.PublicIP()
  26244. case server.FieldPrivateIP:
  26245. return m.PrivateIP()
  26246. case server.FieldAdminPort:
  26247. return m.AdminPort()
  26248. }
  26249. return nil, false
  26250. }
  26251. // OldField returns the old value of the field from the database. An error is
  26252. // returned if the mutation operation is not UpdateOne, or the query to the
  26253. // database failed.
  26254. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26255. switch name {
  26256. case server.FieldCreatedAt:
  26257. return m.OldCreatedAt(ctx)
  26258. case server.FieldUpdatedAt:
  26259. return m.OldUpdatedAt(ctx)
  26260. case server.FieldStatus:
  26261. return m.OldStatus(ctx)
  26262. case server.FieldDeletedAt:
  26263. return m.OldDeletedAt(ctx)
  26264. case server.FieldName:
  26265. return m.OldName(ctx)
  26266. case server.FieldPublicIP:
  26267. return m.OldPublicIP(ctx)
  26268. case server.FieldPrivateIP:
  26269. return m.OldPrivateIP(ctx)
  26270. case server.FieldAdminPort:
  26271. return m.OldAdminPort(ctx)
  26272. }
  26273. return nil, fmt.Errorf("unknown Server field %s", name)
  26274. }
  26275. // SetField sets the value of a field with the given name. It returns an error if
  26276. // the field is not defined in the schema, or if the type mismatched the field
  26277. // type.
  26278. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  26279. switch name {
  26280. case server.FieldCreatedAt:
  26281. v, ok := value.(time.Time)
  26282. if !ok {
  26283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26284. }
  26285. m.SetCreatedAt(v)
  26286. return nil
  26287. case server.FieldUpdatedAt:
  26288. v, ok := value.(time.Time)
  26289. if !ok {
  26290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26291. }
  26292. m.SetUpdatedAt(v)
  26293. return nil
  26294. case server.FieldStatus:
  26295. v, ok := value.(uint8)
  26296. if !ok {
  26297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26298. }
  26299. m.SetStatus(v)
  26300. return nil
  26301. case server.FieldDeletedAt:
  26302. v, ok := value.(time.Time)
  26303. if !ok {
  26304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26305. }
  26306. m.SetDeletedAt(v)
  26307. return nil
  26308. case server.FieldName:
  26309. v, ok := value.(string)
  26310. if !ok {
  26311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26312. }
  26313. m.SetName(v)
  26314. return nil
  26315. case server.FieldPublicIP:
  26316. v, ok := value.(string)
  26317. if !ok {
  26318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26319. }
  26320. m.SetPublicIP(v)
  26321. return nil
  26322. case server.FieldPrivateIP:
  26323. v, ok := value.(string)
  26324. if !ok {
  26325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26326. }
  26327. m.SetPrivateIP(v)
  26328. return nil
  26329. case server.FieldAdminPort:
  26330. v, ok := value.(string)
  26331. if !ok {
  26332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26333. }
  26334. m.SetAdminPort(v)
  26335. return nil
  26336. }
  26337. return fmt.Errorf("unknown Server field %s", name)
  26338. }
  26339. // AddedFields returns all numeric fields that were incremented/decremented during
  26340. // this mutation.
  26341. func (m *ServerMutation) AddedFields() []string {
  26342. var fields []string
  26343. if m.addstatus != nil {
  26344. fields = append(fields, server.FieldStatus)
  26345. }
  26346. return fields
  26347. }
  26348. // AddedField returns the numeric value that was incremented/decremented on a field
  26349. // with the given name. The second boolean return value indicates that this field
  26350. // was not set, or was not defined in the schema.
  26351. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  26352. switch name {
  26353. case server.FieldStatus:
  26354. return m.AddedStatus()
  26355. }
  26356. return nil, false
  26357. }
  26358. // AddField adds the value to the field with the given name. It returns an error if
  26359. // the field is not defined in the schema, or if the type mismatched the field
  26360. // type.
  26361. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  26362. switch name {
  26363. case server.FieldStatus:
  26364. v, ok := value.(int8)
  26365. if !ok {
  26366. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26367. }
  26368. m.AddStatus(v)
  26369. return nil
  26370. }
  26371. return fmt.Errorf("unknown Server numeric field %s", name)
  26372. }
  26373. // ClearedFields returns all nullable fields that were cleared during this
  26374. // mutation.
  26375. func (m *ServerMutation) ClearedFields() []string {
  26376. var fields []string
  26377. if m.FieldCleared(server.FieldStatus) {
  26378. fields = append(fields, server.FieldStatus)
  26379. }
  26380. if m.FieldCleared(server.FieldDeletedAt) {
  26381. fields = append(fields, server.FieldDeletedAt)
  26382. }
  26383. return fields
  26384. }
  26385. // FieldCleared returns a boolean indicating if a field with the given name was
  26386. // cleared in this mutation.
  26387. func (m *ServerMutation) FieldCleared(name string) bool {
  26388. _, ok := m.clearedFields[name]
  26389. return ok
  26390. }
  26391. // ClearField clears the value of the field with the given name. It returns an
  26392. // error if the field is not defined in the schema.
  26393. func (m *ServerMutation) ClearField(name string) error {
  26394. switch name {
  26395. case server.FieldStatus:
  26396. m.ClearStatus()
  26397. return nil
  26398. case server.FieldDeletedAt:
  26399. m.ClearDeletedAt()
  26400. return nil
  26401. }
  26402. return fmt.Errorf("unknown Server nullable field %s", name)
  26403. }
  26404. // ResetField resets all changes in the mutation for the field with the given name.
  26405. // It returns an error if the field is not defined in the schema.
  26406. func (m *ServerMutation) ResetField(name string) error {
  26407. switch name {
  26408. case server.FieldCreatedAt:
  26409. m.ResetCreatedAt()
  26410. return nil
  26411. case server.FieldUpdatedAt:
  26412. m.ResetUpdatedAt()
  26413. return nil
  26414. case server.FieldStatus:
  26415. m.ResetStatus()
  26416. return nil
  26417. case server.FieldDeletedAt:
  26418. m.ResetDeletedAt()
  26419. return nil
  26420. case server.FieldName:
  26421. m.ResetName()
  26422. return nil
  26423. case server.FieldPublicIP:
  26424. m.ResetPublicIP()
  26425. return nil
  26426. case server.FieldPrivateIP:
  26427. m.ResetPrivateIP()
  26428. return nil
  26429. case server.FieldAdminPort:
  26430. m.ResetAdminPort()
  26431. return nil
  26432. }
  26433. return fmt.Errorf("unknown Server field %s", name)
  26434. }
  26435. // AddedEdges returns all edge names that were set/added in this mutation.
  26436. func (m *ServerMutation) AddedEdges() []string {
  26437. edges := make([]string, 0, 1)
  26438. if m.wxs != nil {
  26439. edges = append(edges, server.EdgeWxs)
  26440. }
  26441. return edges
  26442. }
  26443. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26444. // name in this mutation.
  26445. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  26446. switch name {
  26447. case server.EdgeWxs:
  26448. ids := make([]ent.Value, 0, len(m.wxs))
  26449. for id := range m.wxs {
  26450. ids = append(ids, id)
  26451. }
  26452. return ids
  26453. }
  26454. return nil
  26455. }
  26456. // RemovedEdges returns all edge names that were removed in this mutation.
  26457. func (m *ServerMutation) RemovedEdges() []string {
  26458. edges := make([]string, 0, 1)
  26459. if m.removedwxs != nil {
  26460. edges = append(edges, server.EdgeWxs)
  26461. }
  26462. return edges
  26463. }
  26464. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26465. // the given name in this mutation.
  26466. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  26467. switch name {
  26468. case server.EdgeWxs:
  26469. ids := make([]ent.Value, 0, len(m.removedwxs))
  26470. for id := range m.removedwxs {
  26471. ids = append(ids, id)
  26472. }
  26473. return ids
  26474. }
  26475. return nil
  26476. }
  26477. // ClearedEdges returns all edge names that were cleared in this mutation.
  26478. func (m *ServerMutation) ClearedEdges() []string {
  26479. edges := make([]string, 0, 1)
  26480. if m.clearedwxs {
  26481. edges = append(edges, server.EdgeWxs)
  26482. }
  26483. return edges
  26484. }
  26485. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26486. // was cleared in this mutation.
  26487. func (m *ServerMutation) EdgeCleared(name string) bool {
  26488. switch name {
  26489. case server.EdgeWxs:
  26490. return m.clearedwxs
  26491. }
  26492. return false
  26493. }
  26494. // ClearEdge clears the value of the edge with the given name. It returns an error
  26495. // if that edge is not defined in the schema.
  26496. func (m *ServerMutation) ClearEdge(name string) error {
  26497. switch name {
  26498. }
  26499. return fmt.Errorf("unknown Server unique edge %s", name)
  26500. }
  26501. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26502. // It returns an error if the edge is not defined in the schema.
  26503. func (m *ServerMutation) ResetEdge(name string) error {
  26504. switch name {
  26505. case server.EdgeWxs:
  26506. m.ResetWxs()
  26507. return nil
  26508. }
  26509. return fmt.Errorf("unknown Server edge %s", name)
  26510. }
  26511. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  26512. type SopNodeMutation struct {
  26513. config
  26514. op Op
  26515. typ string
  26516. id *uint64
  26517. created_at *time.Time
  26518. updated_at *time.Time
  26519. status *uint8
  26520. addstatus *int8
  26521. deleted_at *time.Time
  26522. parent_id *uint64
  26523. addparent_id *int64
  26524. name *string
  26525. condition_type *int
  26526. addcondition_type *int
  26527. condition_list *[]string
  26528. appendcondition_list []string
  26529. no_reply_condition *uint64
  26530. addno_reply_condition *int64
  26531. no_reply_unit *string
  26532. action_message *[]custom_types.Action
  26533. appendaction_message []custom_types.Action
  26534. action_label_add *[]uint64
  26535. appendaction_label_add []uint64
  26536. action_label_del *[]uint64
  26537. appendaction_label_del []uint64
  26538. action_forward **custom_types.ActionForward
  26539. clearedFields map[string]struct{}
  26540. sop_stage *uint64
  26541. clearedsop_stage bool
  26542. node_messages map[uint64]struct{}
  26543. removednode_messages map[uint64]struct{}
  26544. clearednode_messages bool
  26545. done bool
  26546. oldValue func(context.Context) (*SopNode, error)
  26547. predicates []predicate.SopNode
  26548. }
  26549. var _ ent.Mutation = (*SopNodeMutation)(nil)
  26550. // sopnodeOption allows management of the mutation configuration using functional options.
  26551. type sopnodeOption func(*SopNodeMutation)
  26552. // newSopNodeMutation creates new mutation for the SopNode entity.
  26553. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  26554. m := &SopNodeMutation{
  26555. config: c,
  26556. op: op,
  26557. typ: TypeSopNode,
  26558. clearedFields: make(map[string]struct{}),
  26559. }
  26560. for _, opt := range opts {
  26561. opt(m)
  26562. }
  26563. return m
  26564. }
  26565. // withSopNodeID sets the ID field of the mutation.
  26566. func withSopNodeID(id uint64) sopnodeOption {
  26567. return func(m *SopNodeMutation) {
  26568. var (
  26569. err error
  26570. once sync.Once
  26571. value *SopNode
  26572. )
  26573. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  26574. once.Do(func() {
  26575. if m.done {
  26576. err = errors.New("querying old values post mutation is not allowed")
  26577. } else {
  26578. value, err = m.Client().SopNode.Get(ctx, id)
  26579. }
  26580. })
  26581. return value, err
  26582. }
  26583. m.id = &id
  26584. }
  26585. }
  26586. // withSopNode sets the old SopNode of the mutation.
  26587. func withSopNode(node *SopNode) sopnodeOption {
  26588. return func(m *SopNodeMutation) {
  26589. m.oldValue = func(context.Context) (*SopNode, error) {
  26590. return node, nil
  26591. }
  26592. m.id = &node.ID
  26593. }
  26594. }
  26595. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26596. // executed in a transaction (ent.Tx), a transactional client is returned.
  26597. func (m SopNodeMutation) Client() *Client {
  26598. client := &Client{config: m.config}
  26599. client.init()
  26600. return client
  26601. }
  26602. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26603. // it returns an error otherwise.
  26604. func (m SopNodeMutation) Tx() (*Tx, error) {
  26605. if _, ok := m.driver.(*txDriver); !ok {
  26606. return nil, errors.New("ent: mutation is not running in a transaction")
  26607. }
  26608. tx := &Tx{config: m.config}
  26609. tx.init()
  26610. return tx, nil
  26611. }
  26612. // SetID sets the value of the id field. Note that this
  26613. // operation is only accepted on creation of SopNode entities.
  26614. func (m *SopNodeMutation) SetID(id uint64) {
  26615. m.id = &id
  26616. }
  26617. // ID returns the ID value in the mutation. Note that the ID is only available
  26618. // if it was provided to the builder or after it was returned from the database.
  26619. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  26620. if m.id == nil {
  26621. return
  26622. }
  26623. return *m.id, true
  26624. }
  26625. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26626. // That means, if the mutation is applied within a transaction with an isolation level such
  26627. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26628. // or updated by the mutation.
  26629. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  26630. switch {
  26631. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26632. id, exists := m.ID()
  26633. if exists {
  26634. return []uint64{id}, nil
  26635. }
  26636. fallthrough
  26637. case m.op.Is(OpUpdate | OpDelete):
  26638. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  26639. default:
  26640. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26641. }
  26642. }
  26643. // SetCreatedAt sets the "created_at" field.
  26644. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  26645. m.created_at = &t
  26646. }
  26647. // CreatedAt returns the value of the "created_at" field in the mutation.
  26648. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  26649. v := m.created_at
  26650. if v == nil {
  26651. return
  26652. }
  26653. return *v, true
  26654. }
  26655. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  26656. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  26657. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26658. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26659. if !m.op.Is(OpUpdateOne) {
  26660. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26661. }
  26662. if m.id == nil || m.oldValue == nil {
  26663. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26664. }
  26665. oldValue, err := m.oldValue(ctx)
  26666. if err != nil {
  26667. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26668. }
  26669. return oldValue.CreatedAt, nil
  26670. }
  26671. // ResetCreatedAt resets all changes to the "created_at" field.
  26672. func (m *SopNodeMutation) ResetCreatedAt() {
  26673. m.created_at = nil
  26674. }
  26675. // SetUpdatedAt sets the "updated_at" field.
  26676. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  26677. m.updated_at = &t
  26678. }
  26679. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26680. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  26681. v := m.updated_at
  26682. if v == nil {
  26683. return
  26684. }
  26685. return *v, true
  26686. }
  26687. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  26688. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  26689. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26690. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26691. if !m.op.Is(OpUpdateOne) {
  26692. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26693. }
  26694. if m.id == nil || m.oldValue == nil {
  26695. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26696. }
  26697. oldValue, err := m.oldValue(ctx)
  26698. if err != nil {
  26699. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26700. }
  26701. return oldValue.UpdatedAt, nil
  26702. }
  26703. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26704. func (m *SopNodeMutation) ResetUpdatedAt() {
  26705. m.updated_at = nil
  26706. }
  26707. // SetStatus sets the "status" field.
  26708. func (m *SopNodeMutation) SetStatus(u uint8) {
  26709. m.status = &u
  26710. m.addstatus = nil
  26711. }
  26712. // Status returns the value of the "status" field in the mutation.
  26713. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  26714. v := m.status
  26715. if v == nil {
  26716. return
  26717. }
  26718. return *v, true
  26719. }
  26720. // OldStatus returns the old "status" field's value of the SopNode entity.
  26721. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  26722. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26723. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  26724. if !m.op.Is(OpUpdateOne) {
  26725. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26726. }
  26727. if m.id == nil || m.oldValue == nil {
  26728. return v, errors.New("OldStatus requires an ID field in the mutation")
  26729. }
  26730. oldValue, err := m.oldValue(ctx)
  26731. if err != nil {
  26732. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26733. }
  26734. return oldValue.Status, nil
  26735. }
  26736. // AddStatus adds u to the "status" field.
  26737. func (m *SopNodeMutation) AddStatus(u int8) {
  26738. if m.addstatus != nil {
  26739. *m.addstatus += u
  26740. } else {
  26741. m.addstatus = &u
  26742. }
  26743. }
  26744. // AddedStatus returns the value that was added to the "status" field in this mutation.
  26745. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  26746. v := m.addstatus
  26747. if v == nil {
  26748. return
  26749. }
  26750. return *v, true
  26751. }
  26752. // ClearStatus clears the value of the "status" field.
  26753. func (m *SopNodeMutation) ClearStatus() {
  26754. m.status = nil
  26755. m.addstatus = nil
  26756. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  26757. }
  26758. // StatusCleared returns if the "status" field was cleared in this mutation.
  26759. func (m *SopNodeMutation) StatusCleared() bool {
  26760. _, ok := m.clearedFields[sopnode.FieldStatus]
  26761. return ok
  26762. }
  26763. // ResetStatus resets all changes to the "status" field.
  26764. func (m *SopNodeMutation) ResetStatus() {
  26765. m.status = nil
  26766. m.addstatus = nil
  26767. delete(m.clearedFields, sopnode.FieldStatus)
  26768. }
  26769. // SetDeletedAt sets the "deleted_at" field.
  26770. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  26771. m.deleted_at = &t
  26772. }
  26773. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26774. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  26775. v := m.deleted_at
  26776. if v == nil {
  26777. return
  26778. }
  26779. return *v, true
  26780. }
  26781. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  26782. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  26783. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26784. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26785. if !m.op.Is(OpUpdateOne) {
  26786. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26787. }
  26788. if m.id == nil || m.oldValue == nil {
  26789. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26790. }
  26791. oldValue, err := m.oldValue(ctx)
  26792. if err != nil {
  26793. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26794. }
  26795. return oldValue.DeletedAt, nil
  26796. }
  26797. // ClearDeletedAt clears the value of the "deleted_at" field.
  26798. func (m *SopNodeMutation) ClearDeletedAt() {
  26799. m.deleted_at = nil
  26800. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  26801. }
  26802. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26803. func (m *SopNodeMutation) DeletedAtCleared() bool {
  26804. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  26805. return ok
  26806. }
  26807. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26808. func (m *SopNodeMutation) ResetDeletedAt() {
  26809. m.deleted_at = nil
  26810. delete(m.clearedFields, sopnode.FieldDeletedAt)
  26811. }
  26812. // SetStageID sets the "stage_id" field.
  26813. func (m *SopNodeMutation) SetStageID(u uint64) {
  26814. m.sop_stage = &u
  26815. }
  26816. // StageID returns the value of the "stage_id" field in the mutation.
  26817. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  26818. v := m.sop_stage
  26819. if v == nil {
  26820. return
  26821. }
  26822. return *v, true
  26823. }
  26824. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  26825. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  26826. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26827. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  26828. if !m.op.Is(OpUpdateOne) {
  26829. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  26830. }
  26831. if m.id == nil || m.oldValue == nil {
  26832. return v, errors.New("OldStageID requires an ID field in the mutation")
  26833. }
  26834. oldValue, err := m.oldValue(ctx)
  26835. if err != nil {
  26836. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  26837. }
  26838. return oldValue.StageID, nil
  26839. }
  26840. // ResetStageID resets all changes to the "stage_id" field.
  26841. func (m *SopNodeMutation) ResetStageID() {
  26842. m.sop_stage = nil
  26843. }
  26844. // SetParentID sets the "parent_id" field.
  26845. func (m *SopNodeMutation) SetParentID(u uint64) {
  26846. m.parent_id = &u
  26847. m.addparent_id = nil
  26848. }
  26849. // ParentID returns the value of the "parent_id" field in the mutation.
  26850. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  26851. v := m.parent_id
  26852. if v == nil {
  26853. return
  26854. }
  26855. return *v, true
  26856. }
  26857. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  26858. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  26859. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26860. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  26861. if !m.op.Is(OpUpdateOne) {
  26862. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  26863. }
  26864. if m.id == nil || m.oldValue == nil {
  26865. return v, errors.New("OldParentID requires an ID field in the mutation")
  26866. }
  26867. oldValue, err := m.oldValue(ctx)
  26868. if err != nil {
  26869. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  26870. }
  26871. return oldValue.ParentID, nil
  26872. }
  26873. // AddParentID adds u to the "parent_id" field.
  26874. func (m *SopNodeMutation) AddParentID(u int64) {
  26875. if m.addparent_id != nil {
  26876. *m.addparent_id += u
  26877. } else {
  26878. m.addparent_id = &u
  26879. }
  26880. }
  26881. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  26882. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  26883. v := m.addparent_id
  26884. if v == nil {
  26885. return
  26886. }
  26887. return *v, true
  26888. }
  26889. // ResetParentID resets all changes to the "parent_id" field.
  26890. func (m *SopNodeMutation) ResetParentID() {
  26891. m.parent_id = nil
  26892. m.addparent_id = nil
  26893. }
  26894. // SetName sets the "name" field.
  26895. func (m *SopNodeMutation) SetName(s string) {
  26896. m.name = &s
  26897. }
  26898. // Name returns the value of the "name" field in the mutation.
  26899. func (m *SopNodeMutation) Name() (r string, exists bool) {
  26900. v := m.name
  26901. if v == nil {
  26902. return
  26903. }
  26904. return *v, true
  26905. }
  26906. // OldName returns the old "name" field's value of the SopNode entity.
  26907. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  26908. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26909. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  26910. if !m.op.Is(OpUpdateOne) {
  26911. return v, errors.New("OldName is only allowed on UpdateOne operations")
  26912. }
  26913. if m.id == nil || m.oldValue == nil {
  26914. return v, errors.New("OldName requires an ID field in the mutation")
  26915. }
  26916. oldValue, err := m.oldValue(ctx)
  26917. if err != nil {
  26918. return v, fmt.Errorf("querying old value for OldName: %w", err)
  26919. }
  26920. return oldValue.Name, nil
  26921. }
  26922. // ResetName resets all changes to the "name" field.
  26923. func (m *SopNodeMutation) ResetName() {
  26924. m.name = nil
  26925. }
  26926. // SetConditionType sets the "condition_type" field.
  26927. func (m *SopNodeMutation) SetConditionType(i int) {
  26928. m.condition_type = &i
  26929. m.addcondition_type = nil
  26930. }
  26931. // ConditionType returns the value of the "condition_type" field in the mutation.
  26932. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  26933. v := m.condition_type
  26934. if v == nil {
  26935. return
  26936. }
  26937. return *v, true
  26938. }
  26939. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  26940. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  26941. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26942. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  26943. if !m.op.Is(OpUpdateOne) {
  26944. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  26945. }
  26946. if m.id == nil || m.oldValue == nil {
  26947. return v, errors.New("OldConditionType requires an ID field in the mutation")
  26948. }
  26949. oldValue, err := m.oldValue(ctx)
  26950. if err != nil {
  26951. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  26952. }
  26953. return oldValue.ConditionType, nil
  26954. }
  26955. // AddConditionType adds i to the "condition_type" field.
  26956. func (m *SopNodeMutation) AddConditionType(i int) {
  26957. if m.addcondition_type != nil {
  26958. *m.addcondition_type += i
  26959. } else {
  26960. m.addcondition_type = &i
  26961. }
  26962. }
  26963. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  26964. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  26965. v := m.addcondition_type
  26966. if v == nil {
  26967. return
  26968. }
  26969. return *v, true
  26970. }
  26971. // ResetConditionType resets all changes to the "condition_type" field.
  26972. func (m *SopNodeMutation) ResetConditionType() {
  26973. m.condition_type = nil
  26974. m.addcondition_type = nil
  26975. }
  26976. // SetConditionList sets the "condition_list" field.
  26977. func (m *SopNodeMutation) SetConditionList(s []string) {
  26978. m.condition_list = &s
  26979. m.appendcondition_list = nil
  26980. }
  26981. // ConditionList returns the value of the "condition_list" field in the mutation.
  26982. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  26983. v := m.condition_list
  26984. if v == nil {
  26985. return
  26986. }
  26987. return *v, true
  26988. }
  26989. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  26990. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  26991. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26992. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  26993. if !m.op.Is(OpUpdateOne) {
  26994. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  26995. }
  26996. if m.id == nil || m.oldValue == nil {
  26997. return v, errors.New("OldConditionList requires an ID field in the mutation")
  26998. }
  26999. oldValue, err := m.oldValue(ctx)
  27000. if err != nil {
  27001. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  27002. }
  27003. return oldValue.ConditionList, nil
  27004. }
  27005. // AppendConditionList adds s to the "condition_list" field.
  27006. func (m *SopNodeMutation) AppendConditionList(s []string) {
  27007. m.appendcondition_list = append(m.appendcondition_list, s...)
  27008. }
  27009. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  27010. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  27011. if len(m.appendcondition_list) == 0 {
  27012. return nil, false
  27013. }
  27014. return m.appendcondition_list, true
  27015. }
  27016. // ClearConditionList clears the value of the "condition_list" field.
  27017. func (m *SopNodeMutation) ClearConditionList() {
  27018. m.condition_list = nil
  27019. m.appendcondition_list = nil
  27020. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  27021. }
  27022. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  27023. func (m *SopNodeMutation) ConditionListCleared() bool {
  27024. _, ok := m.clearedFields[sopnode.FieldConditionList]
  27025. return ok
  27026. }
  27027. // ResetConditionList resets all changes to the "condition_list" field.
  27028. func (m *SopNodeMutation) ResetConditionList() {
  27029. m.condition_list = nil
  27030. m.appendcondition_list = nil
  27031. delete(m.clearedFields, sopnode.FieldConditionList)
  27032. }
  27033. // SetNoReplyCondition sets the "no_reply_condition" field.
  27034. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  27035. m.no_reply_condition = &u
  27036. m.addno_reply_condition = nil
  27037. }
  27038. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  27039. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  27040. v := m.no_reply_condition
  27041. if v == nil {
  27042. return
  27043. }
  27044. return *v, true
  27045. }
  27046. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  27047. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27048. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27049. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  27050. if !m.op.Is(OpUpdateOne) {
  27051. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  27052. }
  27053. if m.id == nil || m.oldValue == nil {
  27054. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  27055. }
  27056. oldValue, err := m.oldValue(ctx)
  27057. if err != nil {
  27058. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  27059. }
  27060. return oldValue.NoReplyCondition, nil
  27061. }
  27062. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  27063. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  27064. if m.addno_reply_condition != nil {
  27065. *m.addno_reply_condition += u
  27066. } else {
  27067. m.addno_reply_condition = &u
  27068. }
  27069. }
  27070. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  27071. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  27072. v := m.addno_reply_condition
  27073. if v == nil {
  27074. return
  27075. }
  27076. return *v, true
  27077. }
  27078. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  27079. func (m *SopNodeMutation) ResetNoReplyCondition() {
  27080. m.no_reply_condition = nil
  27081. m.addno_reply_condition = nil
  27082. }
  27083. // SetNoReplyUnit sets the "no_reply_unit" field.
  27084. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  27085. m.no_reply_unit = &s
  27086. }
  27087. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  27088. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  27089. v := m.no_reply_unit
  27090. if v == nil {
  27091. return
  27092. }
  27093. return *v, true
  27094. }
  27095. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  27096. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27097. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27098. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  27099. if !m.op.Is(OpUpdateOne) {
  27100. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  27101. }
  27102. if m.id == nil || m.oldValue == nil {
  27103. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  27104. }
  27105. oldValue, err := m.oldValue(ctx)
  27106. if err != nil {
  27107. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  27108. }
  27109. return oldValue.NoReplyUnit, nil
  27110. }
  27111. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  27112. func (m *SopNodeMutation) ResetNoReplyUnit() {
  27113. m.no_reply_unit = nil
  27114. }
  27115. // SetActionMessage sets the "action_message" field.
  27116. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  27117. m.action_message = &ct
  27118. m.appendaction_message = nil
  27119. }
  27120. // ActionMessage returns the value of the "action_message" field in the mutation.
  27121. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  27122. v := m.action_message
  27123. if v == nil {
  27124. return
  27125. }
  27126. return *v, true
  27127. }
  27128. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  27129. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27130. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27131. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  27132. if !m.op.Is(OpUpdateOne) {
  27133. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  27134. }
  27135. if m.id == nil || m.oldValue == nil {
  27136. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  27137. }
  27138. oldValue, err := m.oldValue(ctx)
  27139. if err != nil {
  27140. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  27141. }
  27142. return oldValue.ActionMessage, nil
  27143. }
  27144. // AppendActionMessage adds ct to the "action_message" field.
  27145. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  27146. m.appendaction_message = append(m.appendaction_message, ct...)
  27147. }
  27148. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  27149. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  27150. if len(m.appendaction_message) == 0 {
  27151. return nil, false
  27152. }
  27153. return m.appendaction_message, true
  27154. }
  27155. // ClearActionMessage clears the value of the "action_message" field.
  27156. func (m *SopNodeMutation) ClearActionMessage() {
  27157. m.action_message = nil
  27158. m.appendaction_message = nil
  27159. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  27160. }
  27161. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  27162. func (m *SopNodeMutation) ActionMessageCleared() bool {
  27163. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  27164. return ok
  27165. }
  27166. // ResetActionMessage resets all changes to the "action_message" field.
  27167. func (m *SopNodeMutation) ResetActionMessage() {
  27168. m.action_message = nil
  27169. m.appendaction_message = nil
  27170. delete(m.clearedFields, sopnode.FieldActionMessage)
  27171. }
  27172. // SetActionLabelAdd sets the "action_label_add" field.
  27173. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  27174. m.action_label_add = &u
  27175. m.appendaction_label_add = nil
  27176. }
  27177. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  27178. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  27179. v := m.action_label_add
  27180. if v == nil {
  27181. return
  27182. }
  27183. return *v, true
  27184. }
  27185. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  27186. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27187. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27188. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  27189. if !m.op.Is(OpUpdateOne) {
  27190. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  27191. }
  27192. if m.id == nil || m.oldValue == nil {
  27193. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  27194. }
  27195. oldValue, err := m.oldValue(ctx)
  27196. if err != nil {
  27197. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  27198. }
  27199. return oldValue.ActionLabelAdd, nil
  27200. }
  27201. // AppendActionLabelAdd adds u to the "action_label_add" field.
  27202. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  27203. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  27204. }
  27205. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  27206. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  27207. if len(m.appendaction_label_add) == 0 {
  27208. return nil, false
  27209. }
  27210. return m.appendaction_label_add, true
  27211. }
  27212. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  27213. func (m *SopNodeMutation) ClearActionLabelAdd() {
  27214. m.action_label_add = nil
  27215. m.appendaction_label_add = nil
  27216. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  27217. }
  27218. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  27219. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  27220. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  27221. return ok
  27222. }
  27223. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  27224. func (m *SopNodeMutation) ResetActionLabelAdd() {
  27225. m.action_label_add = nil
  27226. m.appendaction_label_add = nil
  27227. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  27228. }
  27229. // SetActionLabelDel sets the "action_label_del" field.
  27230. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  27231. m.action_label_del = &u
  27232. m.appendaction_label_del = nil
  27233. }
  27234. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  27235. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  27236. v := m.action_label_del
  27237. if v == nil {
  27238. return
  27239. }
  27240. return *v, true
  27241. }
  27242. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  27243. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27244. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27245. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  27246. if !m.op.Is(OpUpdateOne) {
  27247. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  27248. }
  27249. if m.id == nil || m.oldValue == nil {
  27250. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  27251. }
  27252. oldValue, err := m.oldValue(ctx)
  27253. if err != nil {
  27254. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  27255. }
  27256. return oldValue.ActionLabelDel, nil
  27257. }
  27258. // AppendActionLabelDel adds u to the "action_label_del" field.
  27259. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  27260. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  27261. }
  27262. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  27263. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  27264. if len(m.appendaction_label_del) == 0 {
  27265. return nil, false
  27266. }
  27267. return m.appendaction_label_del, true
  27268. }
  27269. // ClearActionLabelDel clears the value of the "action_label_del" field.
  27270. func (m *SopNodeMutation) ClearActionLabelDel() {
  27271. m.action_label_del = nil
  27272. m.appendaction_label_del = nil
  27273. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  27274. }
  27275. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  27276. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  27277. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  27278. return ok
  27279. }
  27280. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  27281. func (m *SopNodeMutation) ResetActionLabelDel() {
  27282. m.action_label_del = nil
  27283. m.appendaction_label_del = nil
  27284. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  27285. }
  27286. // SetActionForward sets the "action_forward" field.
  27287. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  27288. m.action_forward = &ctf
  27289. }
  27290. // ActionForward returns the value of the "action_forward" field in the mutation.
  27291. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  27292. v := m.action_forward
  27293. if v == nil {
  27294. return
  27295. }
  27296. return *v, true
  27297. }
  27298. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  27299. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27300. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27301. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  27302. if !m.op.Is(OpUpdateOne) {
  27303. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  27304. }
  27305. if m.id == nil || m.oldValue == nil {
  27306. return v, errors.New("OldActionForward requires an ID field in the mutation")
  27307. }
  27308. oldValue, err := m.oldValue(ctx)
  27309. if err != nil {
  27310. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  27311. }
  27312. return oldValue.ActionForward, nil
  27313. }
  27314. // ClearActionForward clears the value of the "action_forward" field.
  27315. func (m *SopNodeMutation) ClearActionForward() {
  27316. m.action_forward = nil
  27317. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  27318. }
  27319. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  27320. func (m *SopNodeMutation) ActionForwardCleared() bool {
  27321. _, ok := m.clearedFields[sopnode.FieldActionForward]
  27322. return ok
  27323. }
  27324. // ResetActionForward resets all changes to the "action_forward" field.
  27325. func (m *SopNodeMutation) ResetActionForward() {
  27326. m.action_forward = nil
  27327. delete(m.clearedFields, sopnode.FieldActionForward)
  27328. }
  27329. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  27330. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  27331. m.sop_stage = &id
  27332. }
  27333. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  27334. func (m *SopNodeMutation) ClearSopStage() {
  27335. m.clearedsop_stage = true
  27336. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  27337. }
  27338. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  27339. func (m *SopNodeMutation) SopStageCleared() bool {
  27340. return m.clearedsop_stage
  27341. }
  27342. // SopStageID returns the "sop_stage" edge ID in the mutation.
  27343. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  27344. if m.sop_stage != nil {
  27345. return *m.sop_stage, true
  27346. }
  27347. return
  27348. }
  27349. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  27350. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  27351. // SopStageID instead. It exists only for internal usage by the builders.
  27352. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  27353. if id := m.sop_stage; id != nil {
  27354. ids = append(ids, *id)
  27355. }
  27356. return
  27357. }
  27358. // ResetSopStage resets all changes to the "sop_stage" edge.
  27359. func (m *SopNodeMutation) ResetSopStage() {
  27360. m.sop_stage = nil
  27361. m.clearedsop_stage = false
  27362. }
  27363. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  27364. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  27365. if m.node_messages == nil {
  27366. m.node_messages = make(map[uint64]struct{})
  27367. }
  27368. for i := range ids {
  27369. m.node_messages[ids[i]] = struct{}{}
  27370. }
  27371. }
  27372. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  27373. func (m *SopNodeMutation) ClearNodeMessages() {
  27374. m.clearednode_messages = true
  27375. }
  27376. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  27377. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  27378. return m.clearednode_messages
  27379. }
  27380. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  27381. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  27382. if m.removednode_messages == nil {
  27383. m.removednode_messages = make(map[uint64]struct{})
  27384. }
  27385. for i := range ids {
  27386. delete(m.node_messages, ids[i])
  27387. m.removednode_messages[ids[i]] = struct{}{}
  27388. }
  27389. }
  27390. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  27391. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  27392. for id := range m.removednode_messages {
  27393. ids = append(ids, id)
  27394. }
  27395. return
  27396. }
  27397. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  27398. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  27399. for id := range m.node_messages {
  27400. ids = append(ids, id)
  27401. }
  27402. return
  27403. }
  27404. // ResetNodeMessages resets all changes to the "node_messages" edge.
  27405. func (m *SopNodeMutation) ResetNodeMessages() {
  27406. m.node_messages = nil
  27407. m.clearednode_messages = false
  27408. m.removednode_messages = nil
  27409. }
  27410. // Where appends a list predicates to the SopNodeMutation builder.
  27411. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  27412. m.predicates = append(m.predicates, ps...)
  27413. }
  27414. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  27415. // users can use type-assertion to append predicates that do not depend on any generated package.
  27416. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  27417. p := make([]predicate.SopNode, len(ps))
  27418. for i := range ps {
  27419. p[i] = ps[i]
  27420. }
  27421. m.Where(p...)
  27422. }
  27423. // Op returns the operation name.
  27424. func (m *SopNodeMutation) Op() Op {
  27425. return m.op
  27426. }
  27427. // SetOp allows setting the mutation operation.
  27428. func (m *SopNodeMutation) SetOp(op Op) {
  27429. m.op = op
  27430. }
  27431. // Type returns the node type of this mutation (SopNode).
  27432. func (m *SopNodeMutation) Type() string {
  27433. return m.typ
  27434. }
  27435. // Fields returns all fields that were changed during this mutation. Note that in
  27436. // order to get all numeric fields that were incremented/decremented, call
  27437. // AddedFields().
  27438. func (m *SopNodeMutation) Fields() []string {
  27439. fields := make([]string, 0, 15)
  27440. if m.created_at != nil {
  27441. fields = append(fields, sopnode.FieldCreatedAt)
  27442. }
  27443. if m.updated_at != nil {
  27444. fields = append(fields, sopnode.FieldUpdatedAt)
  27445. }
  27446. if m.status != nil {
  27447. fields = append(fields, sopnode.FieldStatus)
  27448. }
  27449. if m.deleted_at != nil {
  27450. fields = append(fields, sopnode.FieldDeletedAt)
  27451. }
  27452. if m.sop_stage != nil {
  27453. fields = append(fields, sopnode.FieldStageID)
  27454. }
  27455. if m.parent_id != nil {
  27456. fields = append(fields, sopnode.FieldParentID)
  27457. }
  27458. if m.name != nil {
  27459. fields = append(fields, sopnode.FieldName)
  27460. }
  27461. if m.condition_type != nil {
  27462. fields = append(fields, sopnode.FieldConditionType)
  27463. }
  27464. if m.condition_list != nil {
  27465. fields = append(fields, sopnode.FieldConditionList)
  27466. }
  27467. if m.no_reply_condition != nil {
  27468. fields = append(fields, sopnode.FieldNoReplyCondition)
  27469. }
  27470. if m.no_reply_unit != nil {
  27471. fields = append(fields, sopnode.FieldNoReplyUnit)
  27472. }
  27473. if m.action_message != nil {
  27474. fields = append(fields, sopnode.FieldActionMessage)
  27475. }
  27476. if m.action_label_add != nil {
  27477. fields = append(fields, sopnode.FieldActionLabelAdd)
  27478. }
  27479. if m.action_label_del != nil {
  27480. fields = append(fields, sopnode.FieldActionLabelDel)
  27481. }
  27482. if m.action_forward != nil {
  27483. fields = append(fields, sopnode.FieldActionForward)
  27484. }
  27485. return fields
  27486. }
  27487. // Field returns the value of a field with the given name. The second boolean
  27488. // return value indicates that this field was not set, or was not defined in the
  27489. // schema.
  27490. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  27491. switch name {
  27492. case sopnode.FieldCreatedAt:
  27493. return m.CreatedAt()
  27494. case sopnode.FieldUpdatedAt:
  27495. return m.UpdatedAt()
  27496. case sopnode.FieldStatus:
  27497. return m.Status()
  27498. case sopnode.FieldDeletedAt:
  27499. return m.DeletedAt()
  27500. case sopnode.FieldStageID:
  27501. return m.StageID()
  27502. case sopnode.FieldParentID:
  27503. return m.ParentID()
  27504. case sopnode.FieldName:
  27505. return m.Name()
  27506. case sopnode.FieldConditionType:
  27507. return m.ConditionType()
  27508. case sopnode.FieldConditionList:
  27509. return m.ConditionList()
  27510. case sopnode.FieldNoReplyCondition:
  27511. return m.NoReplyCondition()
  27512. case sopnode.FieldNoReplyUnit:
  27513. return m.NoReplyUnit()
  27514. case sopnode.FieldActionMessage:
  27515. return m.ActionMessage()
  27516. case sopnode.FieldActionLabelAdd:
  27517. return m.ActionLabelAdd()
  27518. case sopnode.FieldActionLabelDel:
  27519. return m.ActionLabelDel()
  27520. case sopnode.FieldActionForward:
  27521. return m.ActionForward()
  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 *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27529. switch name {
  27530. case sopnode.FieldCreatedAt:
  27531. return m.OldCreatedAt(ctx)
  27532. case sopnode.FieldUpdatedAt:
  27533. return m.OldUpdatedAt(ctx)
  27534. case sopnode.FieldStatus:
  27535. return m.OldStatus(ctx)
  27536. case sopnode.FieldDeletedAt:
  27537. return m.OldDeletedAt(ctx)
  27538. case sopnode.FieldStageID:
  27539. return m.OldStageID(ctx)
  27540. case sopnode.FieldParentID:
  27541. return m.OldParentID(ctx)
  27542. case sopnode.FieldName:
  27543. return m.OldName(ctx)
  27544. case sopnode.FieldConditionType:
  27545. return m.OldConditionType(ctx)
  27546. case sopnode.FieldConditionList:
  27547. return m.OldConditionList(ctx)
  27548. case sopnode.FieldNoReplyCondition:
  27549. return m.OldNoReplyCondition(ctx)
  27550. case sopnode.FieldNoReplyUnit:
  27551. return m.OldNoReplyUnit(ctx)
  27552. case sopnode.FieldActionMessage:
  27553. return m.OldActionMessage(ctx)
  27554. case sopnode.FieldActionLabelAdd:
  27555. return m.OldActionLabelAdd(ctx)
  27556. case sopnode.FieldActionLabelDel:
  27557. return m.OldActionLabelDel(ctx)
  27558. case sopnode.FieldActionForward:
  27559. return m.OldActionForward(ctx)
  27560. }
  27561. return nil, fmt.Errorf("unknown SopNode field %s", name)
  27562. }
  27563. // SetField sets the value of a field with the given name. It returns an error if
  27564. // the field is not defined in the schema, or if the type mismatched the field
  27565. // type.
  27566. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  27567. switch name {
  27568. case sopnode.FieldCreatedAt:
  27569. v, ok := value.(time.Time)
  27570. if !ok {
  27571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27572. }
  27573. m.SetCreatedAt(v)
  27574. return nil
  27575. case sopnode.FieldUpdatedAt:
  27576. v, ok := value.(time.Time)
  27577. if !ok {
  27578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27579. }
  27580. m.SetUpdatedAt(v)
  27581. return nil
  27582. case sopnode.FieldStatus:
  27583. v, ok := value.(uint8)
  27584. if !ok {
  27585. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27586. }
  27587. m.SetStatus(v)
  27588. return nil
  27589. case sopnode.FieldDeletedAt:
  27590. v, ok := value.(time.Time)
  27591. if !ok {
  27592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27593. }
  27594. m.SetDeletedAt(v)
  27595. return nil
  27596. case sopnode.FieldStageID:
  27597. v, ok := value.(uint64)
  27598. if !ok {
  27599. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27600. }
  27601. m.SetStageID(v)
  27602. return nil
  27603. case sopnode.FieldParentID:
  27604. v, ok := value.(uint64)
  27605. if !ok {
  27606. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27607. }
  27608. m.SetParentID(v)
  27609. return nil
  27610. case sopnode.FieldName:
  27611. v, ok := value.(string)
  27612. if !ok {
  27613. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27614. }
  27615. m.SetName(v)
  27616. return nil
  27617. case sopnode.FieldConditionType:
  27618. v, ok := value.(int)
  27619. if !ok {
  27620. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27621. }
  27622. m.SetConditionType(v)
  27623. return nil
  27624. case sopnode.FieldConditionList:
  27625. v, ok := value.([]string)
  27626. if !ok {
  27627. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27628. }
  27629. m.SetConditionList(v)
  27630. return nil
  27631. case sopnode.FieldNoReplyCondition:
  27632. v, ok := value.(uint64)
  27633. if !ok {
  27634. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27635. }
  27636. m.SetNoReplyCondition(v)
  27637. return nil
  27638. case sopnode.FieldNoReplyUnit:
  27639. v, ok := value.(string)
  27640. if !ok {
  27641. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27642. }
  27643. m.SetNoReplyUnit(v)
  27644. return nil
  27645. case sopnode.FieldActionMessage:
  27646. v, ok := value.([]custom_types.Action)
  27647. if !ok {
  27648. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27649. }
  27650. m.SetActionMessage(v)
  27651. return nil
  27652. case sopnode.FieldActionLabelAdd:
  27653. v, ok := value.([]uint64)
  27654. if !ok {
  27655. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27656. }
  27657. m.SetActionLabelAdd(v)
  27658. return nil
  27659. case sopnode.FieldActionLabelDel:
  27660. v, ok := value.([]uint64)
  27661. if !ok {
  27662. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27663. }
  27664. m.SetActionLabelDel(v)
  27665. return nil
  27666. case sopnode.FieldActionForward:
  27667. v, ok := value.(*custom_types.ActionForward)
  27668. if !ok {
  27669. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27670. }
  27671. m.SetActionForward(v)
  27672. return nil
  27673. }
  27674. return fmt.Errorf("unknown SopNode field %s", name)
  27675. }
  27676. // AddedFields returns all numeric fields that were incremented/decremented during
  27677. // this mutation.
  27678. func (m *SopNodeMutation) AddedFields() []string {
  27679. var fields []string
  27680. if m.addstatus != nil {
  27681. fields = append(fields, sopnode.FieldStatus)
  27682. }
  27683. if m.addparent_id != nil {
  27684. fields = append(fields, sopnode.FieldParentID)
  27685. }
  27686. if m.addcondition_type != nil {
  27687. fields = append(fields, sopnode.FieldConditionType)
  27688. }
  27689. if m.addno_reply_condition != nil {
  27690. fields = append(fields, sopnode.FieldNoReplyCondition)
  27691. }
  27692. return fields
  27693. }
  27694. // AddedField returns the numeric value that was incremented/decremented on a field
  27695. // with the given name. The second boolean return value indicates that this field
  27696. // was not set, or was not defined in the schema.
  27697. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  27698. switch name {
  27699. case sopnode.FieldStatus:
  27700. return m.AddedStatus()
  27701. case sopnode.FieldParentID:
  27702. return m.AddedParentID()
  27703. case sopnode.FieldConditionType:
  27704. return m.AddedConditionType()
  27705. case sopnode.FieldNoReplyCondition:
  27706. return m.AddedNoReplyCondition()
  27707. }
  27708. return nil, false
  27709. }
  27710. // AddField adds the value to the field with the given name. It returns an error if
  27711. // the field is not defined in the schema, or if the type mismatched the field
  27712. // type.
  27713. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  27714. switch name {
  27715. case sopnode.FieldStatus:
  27716. v, ok := value.(int8)
  27717. if !ok {
  27718. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27719. }
  27720. m.AddStatus(v)
  27721. return nil
  27722. case sopnode.FieldParentID:
  27723. v, ok := value.(int64)
  27724. if !ok {
  27725. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27726. }
  27727. m.AddParentID(v)
  27728. return nil
  27729. case sopnode.FieldConditionType:
  27730. v, ok := value.(int)
  27731. if !ok {
  27732. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27733. }
  27734. m.AddConditionType(v)
  27735. return nil
  27736. case sopnode.FieldNoReplyCondition:
  27737. v, ok := value.(int64)
  27738. if !ok {
  27739. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27740. }
  27741. m.AddNoReplyCondition(v)
  27742. return nil
  27743. }
  27744. return fmt.Errorf("unknown SopNode numeric field %s", name)
  27745. }
  27746. // ClearedFields returns all nullable fields that were cleared during this
  27747. // mutation.
  27748. func (m *SopNodeMutation) ClearedFields() []string {
  27749. var fields []string
  27750. if m.FieldCleared(sopnode.FieldStatus) {
  27751. fields = append(fields, sopnode.FieldStatus)
  27752. }
  27753. if m.FieldCleared(sopnode.FieldDeletedAt) {
  27754. fields = append(fields, sopnode.FieldDeletedAt)
  27755. }
  27756. if m.FieldCleared(sopnode.FieldConditionList) {
  27757. fields = append(fields, sopnode.FieldConditionList)
  27758. }
  27759. if m.FieldCleared(sopnode.FieldActionMessage) {
  27760. fields = append(fields, sopnode.FieldActionMessage)
  27761. }
  27762. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  27763. fields = append(fields, sopnode.FieldActionLabelAdd)
  27764. }
  27765. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  27766. fields = append(fields, sopnode.FieldActionLabelDel)
  27767. }
  27768. if m.FieldCleared(sopnode.FieldActionForward) {
  27769. fields = append(fields, sopnode.FieldActionForward)
  27770. }
  27771. return fields
  27772. }
  27773. // FieldCleared returns a boolean indicating if a field with the given name was
  27774. // cleared in this mutation.
  27775. func (m *SopNodeMutation) FieldCleared(name string) bool {
  27776. _, ok := m.clearedFields[name]
  27777. return ok
  27778. }
  27779. // ClearField clears the value of the field with the given name. It returns an
  27780. // error if the field is not defined in the schema.
  27781. func (m *SopNodeMutation) ClearField(name string) error {
  27782. switch name {
  27783. case sopnode.FieldStatus:
  27784. m.ClearStatus()
  27785. return nil
  27786. case sopnode.FieldDeletedAt:
  27787. m.ClearDeletedAt()
  27788. return nil
  27789. case sopnode.FieldConditionList:
  27790. m.ClearConditionList()
  27791. return nil
  27792. case sopnode.FieldActionMessage:
  27793. m.ClearActionMessage()
  27794. return nil
  27795. case sopnode.FieldActionLabelAdd:
  27796. m.ClearActionLabelAdd()
  27797. return nil
  27798. case sopnode.FieldActionLabelDel:
  27799. m.ClearActionLabelDel()
  27800. return nil
  27801. case sopnode.FieldActionForward:
  27802. m.ClearActionForward()
  27803. return nil
  27804. }
  27805. return fmt.Errorf("unknown SopNode nullable field %s", name)
  27806. }
  27807. // ResetField resets all changes in the mutation for the field with the given name.
  27808. // It returns an error if the field is not defined in the schema.
  27809. func (m *SopNodeMutation) ResetField(name string) error {
  27810. switch name {
  27811. case sopnode.FieldCreatedAt:
  27812. m.ResetCreatedAt()
  27813. return nil
  27814. case sopnode.FieldUpdatedAt:
  27815. m.ResetUpdatedAt()
  27816. return nil
  27817. case sopnode.FieldStatus:
  27818. m.ResetStatus()
  27819. return nil
  27820. case sopnode.FieldDeletedAt:
  27821. m.ResetDeletedAt()
  27822. return nil
  27823. case sopnode.FieldStageID:
  27824. m.ResetStageID()
  27825. return nil
  27826. case sopnode.FieldParentID:
  27827. m.ResetParentID()
  27828. return nil
  27829. case sopnode.FieldName:
  27830. m.ResetName()
  27831. return nil
  27832. case sopnode.FieldConditionType:
  27833. m.ResetConditionType()
  27834. return nil
  27835. case sopnode.FieldConditionList:
  27836. m.ResetConditionList()
  27837. return nil
  27838. case sopnode.FieldNoReplyCondition:
  27839. m.ResetNoReplyCondition()
  27840. return nil
  27841. case sopnode.FieldNoReplyUnit:
  27842. m.ResetNoReplyUnit()
  27843. return nil
  27844. case sopnode.FieldActionMessage:
  27845. m.ResetActionMessage()
  27846. return nil
  27847. case sopnode.FieldActionLabelAdd:
  27848. m.ResetActionLabelAdd()
  27849. return nil
  27850. case sopnode.FieldActionLabelDel:
  27851. m.ResetActionLabelDel()
  27852. return nil
  27853. case sopnode.FieldActionForward:
  27854. m.ResetActionForward()
  27855. return nil
  27856. }
  27857. return fmt.Errorf("unknown SopNode field %s", name)
  27858. }
  27859. // AddedEdges returns all edge names that were set/added in this mutation.
  27860. func (m *SopNodeMutation) AddedEdges() []string {
  27861. edges := make([]string, 0, 2)
  27862. if m.sop_stage != nil {
  27863. edges = append(edges, sopnode.EdgeSopStage)
  27864. }
  27865. if m.node_messages != nil {
  27866. edges = append(edges, sopnode.EdgeNodeMessages)
  27867. }
  27868. return edges
  27869. }
  27870. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27871. // name in this mutation.
  27872. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  27873. switch name {
  27874. case sopnode.EdgeSopStage:
  27875. if id := m.sop_stage; id != nil {
  27876. return []ent.Value{*id}
  27877. }
  27878. case sopnode.EdgeNodeMessages:
  27879. ids := make([]ent.Value, 0, len(m.node_messages))
  27880. for id := range m.node_messages {
  27881. ids = append(ids, id)
  27882. }
  27883. return ids
  27884. }
  27885. return nil
  27886. }
  27887. // RemovedEdges returns all edge names that were removed in this mutation.
  27888. func (m *SopNodeMutation) RemovedEdges() []string {
  27889. edges := make([]string, 0, 2)
  27890. if m.removednode_messages != nil {
  27891. edges = append(edges, sopnode.EdgeNodeMessages)
  27892. }
  27893. return edges
  27894. }
  27895. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27896. // the given name in this mutation.
  27897. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  27898. switch name {
  27899. case sopnode.EdgeNodeMessages:
  27900. ids := make([]ent.Value, 0, len(m.removednode_messages))
  27901. for id := range m.removednode_messages {
  27902. ids = append(ids, id)
  27903. }
  27904. return ids
  27905. }
  27906. return nil
  27907. }
  27908. // ClearedEdges returns all edge names that were cleared in this mutation.
  27909. func (m *SopNodeMutation) ClearedEdges() []string {
  27910. edges := make([]string, 0, 2)
  27911. if m.clearedsop_stage {
  27912. edges = append(edges, sopnode.EdgeSopStage)
  27913. }
  27914. if m.clearednode_messages {
  27915. edges = append(edges, sopnode.EdgeNodeMessages)
  27916. }
  27917. return edges
  27918. }
  27919. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27920. // was cleared in this mutation.
  27921. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  27922. switch name {
  27923. case sopnode.EdgeSopStage:
  27924. return m.clearedsop_stage
  27925. case sopnode.EdgeNodeMessages:
  27926. return m.clearednode_messages
  27927. }
  27928. return false
  27929. }
  27930. // ClearEdge clears the value of the edge with the given name. It returns an error
  27931. // if that edge is not defined in the schema.
  27932. func (m *SopNodeMutation) ClearEdge(name string) error {
  27933. switch name {
  27934. case sopnode.EdgeSopStage:
  27935. m.ClearSopStage()
  27936. return nil
  27937. }
  27938. return fmt.Errorf("unknown SopNode unique edge %s", name)
  27939. }
  27940. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27941. // It returns an error if the edge is not defined in the schema.
  27942. func (m *SopNodeMutation) ResetEdge(name string) error {
  27943. switch name {
  27944. case sopnode.EdgeSopStage:
  27945. m.ResetSopStage()
  27946. return nil
  27947. case sopnode.EdgeNodeMessages:
  27948. m.ResetNodeMessages()
  27949. return nil
  27950. }
  27951. return fmt.Errorf("unknown SopNode edge %s", name)
  27952. }
  27953. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  27954. type SopStageMutation struct {
  27955. config
  27956. op Op
  27957. typ string
  27958. id *uint64
  27959. created_at *time.Time
  27960. updated_at *time.Time
  27961. status *uint8
  27962. addstatus *int8
  27963. deleted_at *time.Time
  27964. name *string
  27965. condition_type *int
  27966. addcondition_type *int
  27967. condition_operator *int
  27968. addcondition_operator *int
  27969. condition_list *[]custom_types.Condition
  27970. appendcondition_list []custom_types.Condition
  27971. action_message *[]custom_types.Action
  27972. appendaction_message []custom_types.Action
  27973. action_label_add *[]uint64
  27974. appendaction_label_add []uint64
  27975. action_label_del *[]uint64
  27976. appendaction_label_del []uint64
  27977. action_forward **custom_types.ActionForward
  27978. index_sort *int
  27979. addindex_sort *int
  27980. clearedFields map[string]struct{}
  27981. sop_task *uint64
  27982. clearedsop_task bool
  27983. stage_nodes map[uint64]struct{}
  27984. removedstage_nodes map[uint64]struct{}
  27985. clearedstage_nodes bool
  27986. stage_messages map[uint64]struct{}
  27987. removedstage_messages map[uint64]struct{}
  27988. clearedstage_messages bool
  27989. done bool
  27990. oldValue func(context.Context) (*SopStage, error)
  27991. predicates []predicate.SopStage
  27992. }
  27993. var _ ent.Mutation = (*SopStageMutation)(nil)
  27994. // sopstageOption allows management of the mutation configuration using functional options.
  27995. type sopstageOption func(*SopStageMutation)
  27996. // newSopStageMutation creates new mutation for the SopStage entity.
  27997. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  27998. m := &SopStageMutation{
  27999. config: c,
  28000. op: op,
  28001. typ: TypeSopStage,
  28002. clearedFields: make(map[string]struct{}),
  28003. }
  28004. for _, opt := range opts {
  28005. opt(m)
  28006. }
  28007. return m
  28008. }
  28009. // withSopStageID sets the ID field of the mutation.
  28010. func withSopStageID(id uint64) sopstageOption {
  28011. return func(m *SopStageMutation) {
  28012. var (
  28013. err error
  28014. once sync.Once
  28015. value *SopStage
  28016. )
  28017. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  28018. once.Do(func() {
  28019. if m.done {
  28020. err = errors.New("querying old values post mutation is not allowed")
  28021. } else {
  28022. value, err = m.Client().SopStage.Get(ctx, id)
  28023. }
  28024. })
  28025. return value, err
  28026. }
  28027. m.id = &id
  28028. }
  28029. }
  28030. // withSopStage sets the old SopStage of the mutation.
  28031. func withSopStage(node *SopStage) sopstageOption {
  28032. return func(m *SopStageMutation) {
  28033. m.oldValue = func(context.Context) (*SopStage, error) {
  28034. return node, nil
  28035. }
  28036. m.id = &node.ID
  28037. }
  28038. }
  28039. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28040. // executed in a transaction (ent.Tx), a transactional client is returned.
  28041. func (m SopStageMutation) Client() *Client {
  28042. client := &Client{config: m.config}
  28043. client.init()
  28044. return client
  28045. }
  28046. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28047. // it returns an error otherwise.
  28048. func (m SopStageMutation) Tx() (*Tx, error) {
  28049. if _, ok := m.driver.(*txDriver); !ok {
  28050. return nil, errors.New("ent: mutation is not running in a transaction")
  28051. }
  28052. tx := &Tx{config: m.config}
  28053. tx.init()
  28054. return tx, nil
  28055. }
  28056. // SetID sets the value of the id field. Note that this
  28057. // operation is only accepted on creation of SopStage entities.
  28058. func (m *SopStageMutation) SetID(id uint64) {
  28059. m.id = &id
  28060. }
  28061. // ID returns the ID value in the mutation. Note that the ID is only available
  28062. // if it was provided to the builder or after it was returned from the database.
  28063. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  28064. if m.id == nil {
  28065. return
  28066. }
  28067. return *m.id, true
  28068. }
  28069. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28070. // That means, if the mutation is applied within a transaction with an isolation level such
  28071. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28072. // or updated by the mutation.
  28073. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  28074. switch {
  28075. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28076. id, exists := m.ID()
  28077. if exists {
  28078. return []uint64{id}, nil
  28079. }
  28080. fallthrough
  28081. case m.op.Is(OpUpdate | OpDelete):
  28082. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  28083. default:
  28084. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28085. }
  28086. }
  28087. // SetCreatedAt sets the "created_at" field.
  28088. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  28089. m.created_at = &t
  28090. }
  28091. // CreatedAt returns the value of the "created_at" field in the mutation.
  28092. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  28093. v := m.created_at
  28094. if v == nil {
  28095. return
  28096. }
  28097. return *v, true
  28098. }
  28099. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  28100. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28101. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28102. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  28103. if !m.op.Is(OpUpdateOne) {
  28104. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  28105. }
  28106. if m.id == nil || m.oldValue == nil {
  28107. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  28108. }
  28109. oldValue, err := m.oldValue(ctx)
  28110. if err != nil {
  28111. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  28112. }
  28113. return oldValue.CreatedAt, nil
  28114. }
  28115. // ResetCreatedAt resets all changes to the "created_at" field.
  28116. func (m *SopStageMutation) ResetCreatedAt() {
  28117. m.created_at = nil
  28118. }
  28119. // SetUpdatedAt sets the "updated_at" field.
  28120. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  28121. m.updated_at = &t
  28122. }
  28123. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  28124. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  28125. v := m.updated_at
  28126. if v == nil {
  28127. return
  28128. }
  28129. return *v, true
  28130. }
  28131. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  28132. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28133. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28134. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  28135. if !m.op.Is(OpUpdateOne) {
  28136. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  28137. }
  28138. if m.id == nil || m.oldValue == nil {
  28139. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  28140. }
  28141. oldValue, err := m.oldValue(ctx)
  28142. if err != nil {
  28143. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  28144. }
  28145. return oldValue.UpdatedAt, nil
  28146. }
  28147. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28148. func (m *SopStageMutation) ResetUpdatedAt() {
  28149. m.updated_at = nil
  28150. }
  28151. // SetStatus sets the "status" field.
  28152. func (m *SopStageMutation) SetStatus(u uint8) {
  28153. m.status = &u
  28154. m.addstatus = nil
  28155. }
  28156. // Status returns the value of the "status" field in the mutation.
  28157. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  28158. v := m.status
  28159. if v == nil {
  28160. return
  28161. }
  28162. return *v, true
  28163. }
  28164. // OldStatus returns the old "status" field's value of the SopStage entity.
  28165. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28166. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28167. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  28168. if !m.op.Is(OpUpdateOne) {
  28169. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  28170. }
  28171. if m.id == nil || m.oldValue == nil {
  28172. return v, errors.New("OldStatus requires an ID field in the mutation")
  28173. }
  28174. oldValue, err := m.oldValue(ctx)
  28175. if err != nil {
  28176. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  28177. }
  28178. return oldValue.Status, nil
  28179. }
  28180. // AddStatus adds u to the "status" field.
  28181. func (m *SopStageMutation) AddStatus(u int8) {
  28182. if m.addstatus != nil {
  28183. *m.addstatus += u
  28184. } else {
  28185. m.addstatus = &u
  28186. }
  28187. }
  28188. // AddedStatus returns the value that was added to the "status" field in this mutation.
  28189. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  28190. v := m.addstatus
  28191. if v == nil {
  28192. return
  28193. }
  28194. return *v, true
  28195. }
  28196. // ClearStatus clears the value of the "status" field.
  28197. func (m *SopStageMutation) ClearStatus() {
  28198. m.status = nil
  28199. m.addstatus = nil
  28200. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  28201. }
  28202. // StatusCleared returns if the "status" field was cleared in this mutation.
  28203. func (m *SopStageMutation) StatusCleared() bool {
  28204. _, ok := m.clearedFields[sopstage.FieldStatus]
  28205. return ok
  28206. }
  28207. // ResetStatus resets all changes to the "status" field.
  28208. func (m *SopStageMutation) ResetStatus() {
  28209. m.status = nil
  28210. m.addstatus = nil
  28211. delete(m.clearedFields, sopstage.FieldStatus)
  28212. }
  28213. // SetDeletedAt sets the "deleted_at" field.
  28214. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  28215. m.deleted_at = &t
  28216. }
  28217. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  28218. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  28219. v := m.deleted_at
  28220. if v == nil {
  28221. return
  28222. }
  28223. return *v, true
  28224. }
  28225. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  28226. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28227. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28228. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  28229. if !m.op.Is(OpUpdateOne) {
  28230. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  28231. }
  28232. if m.id == nil || m.oldValue == nil {
  28233. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  28234. }
  28235. oldValue, err := m.oldValue(ctx)
  28236. if err != nil {
  28237. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  28238. }
  28239. return oldValue.DeletedAt, nil
  28240. }
  28241. // ClearDeletedAt clears the value of the "deleted_at" field.
  28242. func (m *SopStageMutation) ClearDeletedAt() {
  28243. m.deleted_at = nil
  28244. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  28245. }
  28246. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  28247. func (m *SopStageMutation) DeletedAtCleared() bool {
  28248. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  28249. return ok
  28250. }
  28251. // ResetDeletedAt resets all changes to the "deleted_at" field.
  28252. func (m *SopStageMutation) ResetDeletedAt() {
  28253. m.deleted_at = nil
  28254. delete(m.clearedFields, sopstage.FieldDeletedAt)
  28255. }
  28256. // SetTaskID sets the "task_id" field.
  28257. func (m *SopStageMutation) SetTaskID(u uint64) {
  28258. m.sop_task = &u
  28259. }
  28260. // TaskID returns the value of the "task_id" field in the mutation.
  28261. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  28262. v := m.sop_task
  28263. if v == nil {
  28264. return
  28265. }
  28266. return *v, true
  28267. }
  28268. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  28269. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28270. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28271. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  28272. if !m.op.Is(OpUpdateOne) {
  28273. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  28274. }
  28275. if m.id == nil || m.oldValue == nil {
  28276. return v, errors.New("OldTaskID requires an ID field in the mutation")
  28277. }
  28278. oldValue, err := m.oldValue(ctx)
  28279. if err != nil {
  28280. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  28281. }
  28282. return oldValue.TaskID, nil
  28283. }
  28284. // ResetTaskID resets all changes to the "task_id" field.
  28285. func (m *SopStageMutation) ResetTaskID() {
  28286. m.sop_task = nil
  28287. }
  28288. // SetName sets the "name" field.
  28289. func (m *SopStageMutation) SetName(s string) {
  28290. m.name = &s
  28291. }
  28292. // Name returns the value of the "name" field in the mutation.
  28293. func (m *SopStageMutation) Name() (r string, exists bool) {
  28294. v := m.name
  28295. if v == nil {
  28296. return
  28297. }
  28298. return *v, true
  28299. }
  28300. // OldName returns the old "name" field's value of the SopStage entity.
  28301. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28302. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28303. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  28304. if !m.op.Is(OpUpdateOne) {
  28305. return v, errors.New("OldName is only allowed on UpdateOne operations")
  28306. }
  28307. if m.id == nil || m.oldValue == nil {
  28308. return v, errors.New("OldName requires an ID field in the mutation")
  28309. }
  28310. oldValue, err := m.oldValue(ctx)
  28311. if err != nil {
  28312. return v, fmt.Errorf("querying old value for OldName: %w", err)
  28313. }
  28314. return oldValue.Name, nil
  28315. }
  28316. // ResetName resets all changes to the "name" field.
  28317. func (m *SopStageMutation) ResetName() {
  28318. m.name = nil
  28319. }
  28320. // SetConditionType sets the "condition_type" field.
  28321. func (m *SopStageMutation) SetConditionType(i int) {
  28322. m.condition_type = &i
  28323. m.addcondition_type = nil
  28324. }
  28325. // ConditionType returns the value of the "condition_type" field in the mutation.
  28326. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  28327. v := m.condition_type
  28328. if v == nil {
  28329. return
  28330. }
  28331. return *v, true
  28332. }
  28333. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  28334. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28335. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28336. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  28337. if !m.op.Is(OpUpdateOne) {
  28338. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  28339. }
  28340. if m.id == nil || m.oldValue == nil {
  28341. return v, errors.New("OldConditionType requires an ID field in the mutation")
  28342. }
  28343. oldValue, err := m.oldValue(ctx)
  28344. if err != nil {
  28345. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  28346. }
  28347. return oldValue.ConditionType, nil
  28348. }
  28349. // AddConditionType adds i to the "condition_type" field.
  28350. func (m *SopStageMutation) AddConditionType(i int) {
  28351. if m.addcondition_type != nil {
  28352. *m.addcondition_type += i
  28353. } else {
  28354. m.addcondition_type = &i
  28355. }
  28356. }
  28357. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  28358. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  28359. v := m.addcondition_type
  28360. if v == nil {
  28361. return
  28362. }
  28363. return *v, true
  28364. }
  28365. // ResetConditionType resets all changes to the "condition_type" field.
  28366. func (m *SopStageMutation) ResetConditionType() {
  28367. m.condition_type = nil
  28368. m.addcondition_type = nil
  28369. }
  28370. // SetConditionOperator sets the "condition_operator" field.
  28371. func (m *SopStageMutation) SetConditionOperator(i int) {
  28372. m.condition_operator = &i
  28373. m.addcondition_operator = nil
  28374. }
  28375. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  28376. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  28377. v := m.condition_operator
  28378. if v == nil {
  28379. return
  28380. }
  28381. return *v, true
  28382. }
  28383. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  28384. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28386. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  28387. if !m.op.Is(OpUpdateOne) {
  28388. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  28389. }
  28390. if m.id == nil || m.oldValue == nil {
  28391. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  28392. }
  28393. oldValue, err := m.oldValue(ctx)
  28394. if err != nil {
  28395. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  28396. }
  28397. return oldValue.ConditionOperator, nil
  28398. }
  28399. // AddConditionOperator adds i to the "condition_operator" field.
  28400. func (m *SopStageMutation) AddConditionOperator(i int) {
  28401. if m.addcondition_operator != nil {
  28402. *m.addcondition_operator += i
  28403. } else {
  28404. m.addcondition_operator = &i
  28405. }
  28406. }
  28407. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  28408. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  28409. v := m.addcondition_operator
  28410. if v == nil {
  28411. return
  28412. }
  28413. return *v, true
  28414. }
  28415. // ResetConditionOperator resets all changes to the "condition_operator" field.
  28416. func (m *SopStageMutation) ResetConditionOperator() {
  28417. m.condition_operator = nil
  28418. m.addcondition_operator = nil
  28419. }
  28420. // SetConditionList sets the "condition_list" field.
  28421. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  28422. m.condition_list = &ct
  28423. m.appendcondition_list = nil
  28424. }
  28425. // ConditionList returns the value of the "condition_list" field in the mutation.
  28426. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  28427. v := m.condition_list
  28428. if v == nil {
  28429. return
  28430. }
  28431. return *v, true
  28432. }
  28433. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  28434. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28435. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28436. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  28437. if !m.op.Is(OpUpdateOne) {
  28438. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  28439. }
  28440. if m.id == nil || m.oldValue == nil {
  28441. return v, errors.New("OldConditionList requires an ID field in the mutation")
  28442. }
  28443. oldValue, err := m.oldValue(ctx)
  28444. if err != nil {
  28445. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  28446. }
  28447. return oldValue.ConditionList, nil
  28448. }
  28449. // AppendConditionList adds ct to the "condition_list" field.
  28450. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  28451. m.appendcondition_list = append(m.appendcondition_list, ct...)
  28452. }
  28453. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  28454. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  28455. if len(m.appendcondition_list) == 0 {
  28456. return nil, false
  28457. }
  28458. return m.appendcondition_list, true
  28459. }
  28460. // ResetConditionList resets all changes to the "condition_list" field.
  28461. func (m *SopStageMutation) ResetConditionList() {
  28462. m.condition_list = nil
  28463. m.appendcondition_list = nil
  28464. }
  28465. // SetActionMessage sets the "action_message" field.
  28466. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  28467. m.action_message = &ct
  28468. m.appendaction_message = nil
  28469. }
  28470. // ActionMessage returns the value of the "action_message" field in the mutation.
  28471. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  28472. v := m.action_message
  28473. if v == nil {
  28474. return
  28475. }
  28476. return *v, true
  28477. }
  28478. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  28479. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28480. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28481. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  28482. if !m.op.Is(OpUpdateOne) {
  28483. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  28484. }
  28485. if m.id == nil || m.oldValue == nil {
  28486. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  28487. }
  28488. oldValue, err := m.oldValue(ctx)
  28489. if err != nil {
  28490. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  28491. }
  28492. return oldValue.ActionMessage, nil
  28493. }
  28494. // AppendActionMessage adds ct to the "action_message" field.
  28495. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  28496. m.appendaction_message = append(m.appendaction_message, ct...)
  28497. }
  28498. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  28499. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  28500. if len(m.appendaction_message) == 0 {
  28501. return nil, false
  28502. }
  28503. return m.appendaction_message, true
  28504. }
  28505. // ClearActionMessage clears the value of the "action_message" field.
  28506. func (m *SopStageMutation) ClearActionMessage() {
  28507. m.action_message = nil
  28508. m.appendaction_message = nil
  28509. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  28510. }
  28511. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  28512. func (m *SopStageMutation) ActionMessageCleared() bool {
  28513. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  28514. return ok
  28515. }
  28516. // ResetActionMessage resets all changes to the "action_message" field.
  28517. func (m *SopStageMutation) ResetActionMessage() {
  28518. m.action_message = nil
  28519. m.appendaction_message = nil
  28520. delete(m.clearedFields, sopstage.FieldActionMessage)
  28521. }
  28522. // SetActionLabelAdd sets the "action_label_add" field.
  28523. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  28524. m.action_label_add = &u
  28525. m.appendaction_label_add = nil
  28526. }
  28527. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  28528. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  28529. v := m.action_label_add
  28530. if v == nil {
  28531. return
  28532. }
  28533. return *v, true
  28534. }
  28535. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  28536. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28537. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28538. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  28539. if !m.op.Is(OpUpdateOne) {
  28540. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  28541. }
  28542. if m.id == nil || m.oldValue == nil {
  28543. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  28544. }
  28545. oldValue, err := m.oldValue(ctx)
  28546. if err != nil {
  28547. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  28548. }
  28549. return oldValue.ActionLabelAdd, nil
  28550. }
  28551. // AppendActionLabelAdd adds u to the "action_label_add" field.
  28552. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  28553. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  28554. }
  28555. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  28556. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  28557. if len(m.appendaction_label_add) == 0 {
  28558. return nil, false
  28559. }
  28560. return m.appendaction_label_add, true
  28561. }
  28562. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  28563. func (m *SopStageMutation) ClearActionLabelAdd() {
  28564. m.action_label_add = nil
  28565. m.appendaction_label_add = nil
  28566. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  28567. }
  28568. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  28569. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  28570. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  28571. return ok
  28572. }
  28573. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  28574. func (m *SopStageMutation) ResetActionLabelAdd() {
  28575. m.action_label_add = nil
  28576. m.appendaction_label_add = nil
  28577. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  28578. }
  28579. // SetActionLabelDel sets the "action_label_del" field.
  28580. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  28581. m.action_label_del = &u
  28582. m.appendaction_label_del = nil
  28583. }
  28584. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  28585. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  28586. v := m.action_label_del
  28587. if v == nil {
  28588. return
  28589. }
  28590. return *v, true
  28591. }
  28592. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  28593. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28594. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28595. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  28596. if !m.op.Is(OpUpdateOne) {
  28597. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  28598. }
  28599. if m.id == nil || m.oldValue == nil {
  28600. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  28601. }
  28602. oldValue, err := m.oldValue(ctx)
  28603. if err != nil {
  28604. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  28605. }
  28606. return oldValue.ActionLabelDel, nil
  28607. }
  28608. // AppendActionLabelDel adds u to the "action_label_del" field.
  28609. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  28610. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  28611. }
  28612. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  28613. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  28614. if len(m.appendaction_label_del) == 0 {
  28615. return nil, false
  28616. }
  28617. return m.appendaction_label_del, true
  28618. }
  28619. // ClearActionLabelDel clears the value of the "action_label_del" field.
  28620. func (m *SopStageMutation) ClearActionLabelDel() {
  28621. m.action_label_del = nil
  28622. m.appendaction_label_del = nil
  28623. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  28624. }
  28625. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  28626. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  28627. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  28628. return ok
  28629. }
  28630. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  28631. func (m *SopStageMutation) ResetActionLabelDel() {
  28632. m.action_label_del = nil
  28633. m.appendaction_label_del = nil
  28634. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  28635. }
  28636. // SetActionForward sets the "action_forward" field.
  28637. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  28638. m.action_forward = &ctf
  28639. }
  28640. // ActionForward returns the value of the "action_forward" field in the mutation.
  28641. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  28642. v := m.action_forward
  28643. if v == nil {
  28644. return
  28645. }
  28646. return *v, true
  28647. }
  28648. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  28649. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28650. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28651. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  28652. if !m.op.Is(OpUpdateOne) {
  28653. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  28654. }
  28655. if m.id == nil || m.oldValue == nil {
  28656. return v, errors.New("OldActionForward requires an ID field in the mutation")
  28657. }
  28658. oldValue, err := m.oldValue(ctx)
  28659. if err != nil {
  28660. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  28661. }
  28662. return oldValue.ActionForward, nil
  28663. }
  28664. // ClearActionForward clears the value of the "action_forward" field.
  28665. func (m *SopStageMutation) ClearActionForward() {
  28666. m.action_forward = nil
  28667. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  28668. }
  28669. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  28670. func (m *SopStageMutation) ActionForwardCleared() bool {
  28671. _, ok := m.clearedFields[sopstage.FieldActionForward]
  28672. return ok
  28673. }
  28674. // ResetActionForward resets all changes to the "action_forward" field.
  28675. func (m *SopStageMutation) ResetActionForward() {
  28676. m.action_forward = nil
  28677. delete(m.clearedFields, sopstage.FieldActionForward)
  28678. }
  28679. // SetIndexSort sets the "index_sort" field.
  28680. func (m *SopStageMutation) SetIndexSort(i int) {
  28681. m.index_sort = &i
  28682. m.addindex_sort = nil
  28683. }
  28684. // IndexSort returns the value of the "index_sort" field in the mutation.
  28685. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  28686. v := m.index_sort
  28687. if v == nil {
  28688. return
  28689. }
  28690. return *v, true
  28691. }
  28692. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  28693. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28694. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28695. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  28696. if !m.op.Is(OpUpdateOne) {
  28697. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  28698. }
  28699. if m.id == nil || m.oldValue == nil {
  28700. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  28701. }
  28702. oldValue, err := m.oldValue(ctx)
  28703. if err != nil {
  28704. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  28705. }
  28706. return oldValue.IndexSort, nil
  28707. }
  28708. // AddIndexSort adds i to the "index_sort" field.
  28709. func (m *SopStageMutation) AddIndexSort(i int) {
  28710. if m.addindex_sort != nil {
  28711. *m.addindex_sort += i
  28712. } else {
  28713. m.addindex_sort = &i
  28714. }
  28715. }
  28716. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  28717. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  28718. v := m.addindex_sort
  28719. if v == nil {
  28720. return
  28721. }
  28722. return *v, true
  28723. }
  28724. // ClearIndexSort clears the value of the "index_sort" field.
  28725. func (m *SopStageMutation) ClearIndexSort() {
  28726. m.index_sort = nil
  28727. m.addindex_sort = nil
  28728. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  28729. }
  28730. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  28731. func (m *SopStageMutation) IndexSortCleared() bool {
  28732. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  28733. return ok
  28734. }
  28735. // ResetIndexSort resets all changes to the "index_sort" field.
  28736. func (m *SopStageMutation) ResetIndexSort() {
  28737. m.index_sort = nil
  28738. m.addindex_sort = nil
  28739. delete(m.clearedFields, sopstage.FieldIndexSort)
  28740. }
  28741. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  28742. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  28743. m.sop_task = &id
  28744. }
  28745. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  28746. func (m *SopStageMutation) ClearSopTask() {
  28747. m.clearedsop_task = true
  28748. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  28749. }
  28750. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  28751. func (m *SopStageMutation) SopTaskCleared() bool {
  28752. return m.clearedsop_task
  28753. }
  28754. // SopTaskID returns the "sop_task" edge ID in the mutation.
  28755. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  28756. if m.sop_task != nil {
  28757. return *m.sop_task, true
  28758. }
  28759. return
  28760. }
  28761. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  28762. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  28763. // SopTaskID instead. It exists only for internal usage by the builders.
  28764. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  28765. if id := m.sop_task; id != nil {
  28766. ids = append(ids, *id)
  28767. }
  28768. return
  28769. }
  28770. // ResetSopTask resets all changes to the "sop_task" edge.
  28771. func (m *SopStageMutation) ResetSopTask() {
  28772. m.sop_task = nil
  28773. m.clearedsop_task = false
  28774. }
  28775. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  28776. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  28777. if m.stage_nodes == nil {
  28778. m.stage_nodes = make(map[uint64]struct{})
  28779. }
  28780. for i := range ids {
  28781. m.stage_nodes[ids[i]] = struct{}{}
  28782. }
  28783. }
  28784. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  28785. func (m *SopStageMutation) ClearStageNodes() {
  28786. m.clearedstage_nodes = true
  28787. }
  28788. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  28789. func (m *SopStageMutation) StageNodesCleared() bool {
  28790. return m.clearedstage_nodes
  28791. }
  28792. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  28793. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  28794. if m.removedstage_nodes == nil {
  28795. m.removedstage_nodes = make(map[uint64]struct{})
  28796. }
  28797. for i := range ids {
  28798. delete(m.stage_nodes, ids[i])
  28799. m.removedstage_nodes[ids[i]] = struct{}{}
  28800. }
  28801. }
  28802. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  28803. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  28804. for id := range m.removedstage_nodes {
  28805. ids = append(ids, id)
  28806. }
  28807. return
  28808. }
  28809. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  28810. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  28811. for id := range m.stage_nodes {
  28812. ids = append(ids, id)
  28813. }
  28814. return
  28815. }
  28816. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  28817. func (m *SopStageMutation) ResetStageNodes() {
  28818. m.stage_nodes = nil
  28819. m.clearedstage_nodes = false
  28820. m.removedstage_nodes = nil
  28821. }
  28822. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  28823. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  28824. if m.stage_messages == nil {
  28825. m.stage_messages = make(map[uint64]struct{})
  28826. }
  28827. for i := range ids {
  28828. m.stage_messages[ids[i]] = struct{}{}
  28829. }
  28830. }
  28831. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  28832. func (m *SopStageMutation) ClearStageMessages() {
  28833. m.clearedstage_messages = true
  28834. }
  28835. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  28836. func (m *SopStageMutation) StageMessagesCleared() bool {
  28837. return m.clearedstage_messages
  28838. }
  28839. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  28840. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  28841. if m.removedstage_messages == nil {
  28842. m.removedstage_messages = make(map[uint64]struct{})
  28843. }
  28844. for i := range ids {
  28845. delete(m.stage_messages, ids[i])
  28846. m.removedstage_messages[ids[i]] = struct{}{}
  28847. }
  28848. }
  28849. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  28850. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  28851. for id := range m.removedstage_messages {
  28852. ids = append(ids, id)
  28853. }
  28854. return
  28855. }
  28856. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  28857. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  28858. for id := range m.stage_messages {
  28859. ids = append(ids, id)
  28860. }
  28861. return
  28862. }
  28863. // ResetStageMessages resets all changes to the "stage_messages" edge.
  28864. func (m *SopStageMutation) ResetStageMessages() {
  28865. m.stage_messages = nil
  28866. m.clearedstage_messages = false
  28867. m.removedstage_messages = nil
  28868. }
  28869. // Where appends a list predicates to the SopStageMutation builder.
  28870. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  28871. m.predicates = append(m.predicates, ps...)
  28872. }
  28873. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  28874. // users can use type-assertion to append predicates that do not depend on any generated package.
  28875. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  28876. p := make([]predicate.SopStage, len(ps))
  28877. for i := range ps {
  28878. p[i] = ps[i]
  28879. }
  28880. m.Where(p...)
  28881. }
  28882. // Op returns the operation name.
  28883. func (m *SopStageMutation) Op() Op {
  28884. return m.op
  28885. }
  28886. // SetOp allows setting the mutation operation.
  28887. func (m *SopStageMutation) SetOp(op Op) {
  28888. m.op = op
  28889. }
  28890. // Type returns the node type of this mutation (SopStage).
  28891. func (m *SopStageMutation) Type() string {
  28892. return m.typ
  28893. }
  28894. // Fields returns all fields that were changed during this mutation. Note that in
  28895. // order to get all numeric fields that were incremented/decremented, call
  28896. // AddedFields().
  28897. func (m *SopStageMutation) Fields() []string {
  28898. fields := make([]string, 0, 14)
  28899. if m.created_at != nil {
  28900. fields = append(fields, sopstage.FieldCreatedAt)
  28901. }
  28902. if m.updated_at != nil {
  28903. fields = append(fields, sopstage.FieldUpdatedAt)
  28904. }
  28905. if m.status != nil {
  28906. fields = append(fields, sopstage.FieldStatus)
  28907. }
  28908. if m.deleted_at != nil {
  28909. fields = append(fields, sopstage.FieldDeletedAt)
  28910. }
  28911. if m.sop_task != nil {
  28912. fields = append(fields, sopstage.FieldTaskID)
  28913. }
  28914. if m.name != nil {
  28915. fields = append(fields, sopstage.FieldName)
  28916. }
  28917. if m.condition_type != nil {
  28918. fields = append(fields, sopstage.FieldConditionType)
  28919. }
  28920. if m.condition_operator != nil {
  28921. fields = append(fields, sopstage.FieldConditionOperator)
  28922. }
  28923. if m.condition_list != nil {
  28924. fields = append(fields, sopstage.FieldConditionList)
  28925. }
  28926. if m.action_message != nil {
  28927. fields = append(fields, sopstage.FieldActionMessage)
  28928. }
  28929. if m.action_label_add != nil {
  28930. fields = append(fields, sopstage.FieldActionLabelAdd)
  28931. }
  28932. if m.action_label_del != nil {
  28933. fields = append(fields, sopstage.FieldActionLabelDel)
  28934. }
  28935. if m.action_forward != nil {
  28936. fields = append(fields, sopstage.FieldActionForward)
  28937. }
  28938. if m.index_sort != nil {
  28939. fields = append(fields, sopstage.FieldIndexSort)
  28940. }
  28941. return fields
  28942. }
  28943. // Field returns the value of a field with the given name. The second boolean
  28944. // return value indicates that this field was not set, or was not defined in the
  28945. // schema.
  28946. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  28947. switch name {
  28948. case sopstage.FieldCreatedAt:
  28949. return m.CreatedAt()
  28950. case sopstage.FieldUpdatedAt:
  28951. return m.UpdatedAt()
  28952. case sopstage.FieldStatus:
  28953. return m.Status()
  28954. case sopstage.FieldDeletedAt:
  28955. return m.DeletedAt()
  28956. case sopstage.FieldTaskID:
  28957. return m.TaskID()
  28958. case sopstage.FieldName:
  28959. return m.Name()
  28960. case sopstage.FieldConditionType:
  28961. return m.ConditionType()
  28962. case sopstage.FieldConditionOperator:
  28963. return m.ConditionOperator()
  28964. case sopstage.FieldConditionList:
  28965. return m.ConditionList()
  28966. case sopstage.FieldActionMessage:
  28967. return m.ActionMessage()
  28968. case sopstage.FieldActionLabelAdd:
  28969. return m.ActionLabelAdd()
  28970. case sopstage.FieldActionLabelDel:
  28971. return m.ActionLabelDel()
  28972. case sopstage.FieldActionForward:
  28973. return m.ActionForward()
  28974. case sopstage.FieldIndexSort:
  28975. return m.IndexSort()
  28976. }
  28977. return nil, false
  28978. }
  28979. // OldField returns the old value of the field from the database. An error is
  28980. // returned if the mutation operation is not UpdateOne, or the query to the
  28981. // database failed.
  28982. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  28983. switch name {
  28984. case sopstage.FieldCreatedAt:
  28985. return m.OldCreatedAt(ctx)
  28986. case sopstage.FieldUpdatedAt:
  28987. return m.OldUpdatedAt(ctx)
  28988. case sopstage.FieldStatus:
  28989. return m.OldStatus(ctx)
  28990. case sopstage.FieldDeletedAt:
  28991. return m.OldDeletedAt(ctx)
  28992. case sopstage.FieldTaskID:
  28993. return m.OldTaskID(ctx)
  28994. case sopstage.FieldName:
  28995. return m.OldName(ctx)
  28996. case sopstage.FieldConditionType:
  28997. return m.OldConditionType(ctx)
  28998. case sopstage.FieldConditionOperator:
  28999. return m.OldConditionOperator(ctx)
  29000. case sopstage.FieldConditionList:
  29001. return m.OldConditionList(ctx)
  29002. case sopstage.FieldActionMessage:
  29003. return m.OldActionMessage(ctx)
  29004. case sopstage.FieldActionLabelAdd:
  29005. return m.OldActionLabelAdd(ctx)
  29006. case sopstage.FieldActionLabelDel:
  29007. return m.OldActionLabelDel(ctx)
  29008. case sopstage.FieldActionForward:
  29009. return m.OldActionForward(ctx)
  29010. case sopstage.FieldIndexSort:
  29011. return m.OldIndexSort(ctx)
  29012. }
  29013. return nil, fmt.Errorf("unknown SopStage field %s", name)
  29014. }
  29015. // SetField sets the value of a field with the given name. It returns an error if
  29016. // the field is not defined in the schema, or if the type mismatched the field
  29017. // type.
  29018. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  29019. switch name {
  29020. case sopstage.FieldCreatedAt:
  29021. v, ok := value.(time.Time)
  29022. if !ok {
  29023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29024. }
  29025. m.SetCreatedAt(v)
  29026. return nil
  29027. case sopstage.FieldUpdatedAt:
  29028. v, ok := value.(time.Time)
  29029. if !ok {
  29030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29031. }
  29032. m.SetUpdatedAt(v)
  29033. return nil
  29034. case sopstage.FieldStatus:
  29035. v, ok := value.(uint8)
  29036. if !ok {
  29037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29038. }
  29039. m.SetStatus(v)
  29040. return nil
  29041. case sopstage.FieldDeletedAt:
  29042. v, ok := value.(time.Time)
  29043. if !ok {
  29044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29045. }
  29046. m.SetDeletedAt(v)
  29047. return nil
  29048. case sopstage.FieldTaskID:
  29049. v, ok := value.(uint64)
  29050. if !ok {
  29051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29052. }
  29053. m.SetTaskID(v)
  29054. return nil
  29055. case sopstage.FieldName:
  29056. v, ok := value.(string)
  29057. if !ok {
  29058. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29059. }
  29060. m.SetName(v)
  29061. return nil
  29062. case sopstage.FieldConditionType:
  29063. v, ok := value.(int)
  29064. if !ok {
  29065. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29066. }
  29067. m.SetConditionType(v)
  29068. return nil
  29069. case sopstage.FieldConditionOperator:
  29070. v, ok := value.(int)
  29071. if !ok {
  29072. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29073. }
  29074. m.SetConditionOperator(v)
  29075. return nil
  29076. case sopstage.FieldConditionList:
  29077. v, ok := value.([]custom_types.Condition)
  29078. if !ok {
  29079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29080. }
  29081. m.SetConditionList(v)
  29082. return nil
  29083. case sopstage.FieldActionMessage:
  29084. v, ok := value.([]custom_types.Action)
  29085. if !ok {
  29086. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29087. }
  29088. m.SetActionMessage(v)
  29089. return nil
  29090. case sopstage.FieldActionLabelAdd:
  29091. v, ok := value.([]uint64)
  29092. if !ok {
  29093. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29094. }
  29095. m.SetActionLabelAdd(v)
  29096. return nil
  29097. case sopstage.FieldActionLabelDel:
  29098. v, ok := value.([]uint64)
  29099. if !ok {
  29100. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29101. }
  29102. m.SetActionLabelDel(v)
  29103. return nil
  29104. case sopstage.FieldActionForward:
  29105. v, ok := value.(*custom_types.ActionForward)
  29106. if !ok {
  29107. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29108. }
  29109. m.SetActionForward(v)
  29110. return nil
  29111. case sopstage.FieldIndexSort:
  29112. v, ok := value.(int)
  29113. if !ok {
  29114. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29115. }
  29116. m.SetIndexSort(v)
  29117. return nil
  29118. }
  29119. return fmt.Errorf("unknown SopStage field %s", name)
  29120. }
  29121. // AddedFields returns all numeric fields that were incremented/decremented during
  29122. // this mutation.
  29123. func (m *SopStageMutation) AddedFields() []string {
  29124. var fields []string
  29125. if m.addstatus != nil {
  29126. fields = append(fields, sopstage.FieldStatus)
  29127. }
  29128. if m.addcondition_type != nil {
  29129. fields = append(fields, sopstage.FieldConditionType)
  29130. }
  29131. if m.addcondition_operator != nil {
  29132. fields = append(fields, sopstage.FieldConditionOperator)
  29133. }
  29134. if m.addindex_sort != nil {
  29135. fields = append(fields, sopstage.FieldIndexSort)
  29136. }
  29137. return fields
  29138. }
  29139. // AddedField returns the numeric value that was incremented/decremented on a field
  29140. // with the given name. The second boolean return value indicates that this field
  29141. // was not set, or was not defined in the schema.
  29142. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  29143. switch name {
  29144. case sopstage.FieldStatus:
  29145. return m.AddedStatus()
  29146. case sopstage.FieldConditionType:
  29147. return m.AddedConditionType()
  29148. case sopstage.FieldConditionOperator:
  29149. return m.AddedConditionOperator()
  29150. case sopstage.FieldIndexSort:
  29151. return m.AddedIndexSort()
  29152. }
  29153. return nil, false
  29154. }
  29155. // AddField adds the value to the field with the given name. It returns an error if
  29156. // the field is not defined in the schema, or if the type mismatched the field
  29157. // type.
  29158. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  29159. switch name {
  29160. case sopstage.FieldStatus:
  29161. v, ok := value.(int8)
  29162. if !ok {
  29163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29164. }
  29165. m.AddStatus(v)
  29166. return nil
  29167. case sopstage.FieldConditionType:
  29168. v, ok := value.(int)
  29169. if !ok {
  29170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29171. }
  29172. m.AddConditionType(v)
  29173. return nil
  29174. case sopstage.FieldConditionOperator:
  29175. v, ok := value.(int)
  29176. if !ok {
  29177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29178. }
  29179. m.AddConditionOperator(v)
  29180. return nil
  29181. case sopstage.FieldIndexSort:
  29182. v, ok := value.(int)
  29183. if !ok {
  29184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29185. }
  29186. m.AddIndexSort(v)
  29187. return nil
  29188. }
  29189. return fmt.Errorf("unknown SopStage numeric field %s", name)
  29190. }
  29191. // ClearedFields returns all nullable fields that were cleared during this
  29192. // mutation.
  29193. func (m *SopStageMutation) ClearedFields() []string {
  29194. var fields []string
  29195. if m.FieldCleared(sopstage.FieldStatus) {
  29196. fields = append(fields, sopstage.FieldStatus)
  29197. }
  29198. if m.FieldCleared(sopstage.FieldDeletedAt) {
  29199. fields = append(fields, sopstage.FieldDeletedAt)
  29200. }
  29201. if m.FieldCleared(sopstage.FieldActionMessage) {
  29202. fields = append(fields, sopstage.FieldActionMessage)
  29203. }
  29204. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  29205. fields = append(fields, sopstage.FieldActionLabelAdd)
  29206. }
  29207. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  29208. fields = append(fields, sopstage.FieldActionLabelDel)
  29209. }
  29210. if m.FieldCleared(sopstage.FieldActionForward) {
  29211. fields = append(fields, sopstage.FieldActionForward)
  29212. }
  29213. if m.FieldCleared(sopstage.FieldIndexSort) {
  29214. fields = append(fields, sopstage.FieldIndexSort)
  29215. }
  29216. return fields
  29217. }
  29218. // FieldCleared returns a boolean indicating if a field with the given name was
  29219. // cleared in this mutation.
  29220. func (m *SopStageMutation) FieldCleared(name string) bool {
  29221. _, ok := m.clearedFields[name]
  29222. return ok
  29223. }
  29224. // ClearField clears the value of the field with the given name. It returns an
  29225. // error if the field is not defined in the schema.
  29226. func (m *SopStageMutation) ClearField(name string) error {
  29227. switch name {
  29228. case sopstage.FieldStatus:
  29229. m.ClearStatus()
  29230. return nil
  29231. case sopstage.FieldDeletedAt:
  29232. m.ClearDeletedAt()
  29233. return nil
  29234. case sopstage.FieldActionMessage:
  29235. m.ClearActionMessage()
  29236. return nil
  29237. case sopstage.FieldActionLabelAdd:
  29238. m.ClearActionLabelAdd()
  29239. return nil
  29240. case sopstage.FieldActionLabelDel:
  29241. m.ClearActionLabelDel()
  29242. return nil
  29243. case sopstage.FieldActionForward:
  29244. m.ClearActionForward()
  29245. return nil
  29246. case sopstage.FieldIndexSort:
  29247. m.ClearIndexSort()
  29248. return nil
  29249. }
  29250. return fmt.Errorf("unknown SopStage nullable field %s", name)
  29251. }
  29252. // ResetField resets all changes in the mutation for the field with the given name.
  29253. // It returns an error if the field is not defined in the schema.
  29254. func (m *SopStageMutation) ResetField(name string) error {
  29255. switch name {
  29256. case sopstage.FieldCreatedAt:
  29257. m.ResetCreatedAt()
  29258. return nil
  29259. case sopstage.FieldUpdatedAt:
  29260. m.ResetUpdatedAt()
  29261. return nil
  29262. case sopstage.FieldStatus:
  29263. m.ResetStatus()
  29264. return nil
  29265. case sopstage.FieldDeletedAt:
  29266. m.ResetDeletedAt()
  29267. return nil
  29268. case sopstage.FieldTaskID:
  29269. m.ResetTaskID()
  29270. return nil
  29271. case sopstage.FieldName:
  29272. m.ResetName()
  29273. return nil
  29274. case sopstage.FieldConditionType:
  29275. m.ResetConditionType()
  29276. return nil
  29277. case sopstage.FieldConditionOperator:
  29278. m.ResetConditionOperator()
  29279. return nil
  29280. case sopstage.FieldConditionList:
  29281. m.ResetConditionList()
  29282. return nil
  29283. case sopstage.FieldActionMessage:
  29284. m.ResetActionMessage()
  29285. return nil
  29286. case sopstage.FieldActionLabelAdd:
  29287. m.ResetActionLabelAdd()
  29288. return nil
  29289. case sopstage.FieldActionLabelDel:
  29290. m.ResetActionLabelDel()
  29291. return nil
  29292. case sopstage.FieldActionForward:
  29293. m.ResetActionForward()
  29294. return nil
  29295. case sopstage.FieldIndexSort:
  29296. m.ResetIndexSort()
  29297. return nil
  29298. }
  29299. return fmt.Errorf("unknown SopStage field %s", name)
  29300. }
  29301. // AddedEdges returns all edge names that were set/added in this mutation.
  29302. func (m *SopStageMutation) AddedEdges() []string {
  29303. edges := make([]string, 0, 3)
  29304. if m.sop_task != nil {
  29305. edges = append(edges, sopstage.EdgeSopTask)
  29306. }
  29307. if m.stage_nodes != nil {
  29308. edges = append(edges, sopstage.EdgeStageNodes)
  29309. }
  29310. if m.stage_messages != nil {
  29311. edges = append(edges, sopstage.EdgeStageMessages)
  29312. }
  29313. return edges
  29314. }
  29315. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29316. // name in this mutation.
  29317. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  29318. switch name {
  29319. case sopstage.EdgeSopTask:
  29320. if id := m.sop_task; id != nil {
  29321. return []ent.Value{*id}
  29322. }
  29323. case sopstage.EdgeStageNodes:
  29324. ids := make([]ent.Value, 0, len(m.stage_nodes))
  29325. for id := range m.stage_nodes {
  29326. ids = append(ids, id)
  29327. }
  29328. return ids
  29329. case sopstage.EdgeStageMessages:
  29330. ids := make([]ent.Value, 0, len(m.stage_messages))
  29331. for id := range m.stage_messages {
  29332. ids = append(ids, id)
  29333. }
  29334. return ids
  29335. }
  29336. return nil
  29337. }
  29338. // RemovedEdges returns all edge names that were removed in this mutation.
  29339. func (m *SopStageMutation) RemovedEdges() []string {
  29340. edges := make([]string, 0, 3)
  29341. if m.removedstage_nodes != nil {
  29342. edges = append(edges, sopstage.EdgeStageNodes)
  29343. }
  29344. if m.removedstage_messages != nil {
  29345. edges = append(edges, sopstage.EdgeStageMessages)
  29346. }
  29347. return edges
  29348. }
  29349. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29350. // the given name in this mutation.
  29351. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  29352. switch name {
  29353. case sopstage.EdgeStageNodes:
  29354. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  29355. for id := range m.removedstage_nodes {
  29356. ids = append(ids, id)
  29357. }
  29358. return ids
  29359. case sopstage.EdgeStageMessages:
  29360. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  29361. for id := range m.removedstage_messages {
  29362. ids = append(ids, id)
  29363. }
  29364. return ids
  29365. }
  29366. return nil
  29367. }
  29368. // ClearedEdges returns all edge names that were cleared in this mutation.
  29369. func (m *SopStageMutation) ClearedEdges() []string {
  29370. edges := make([]string, 0, 3)
  29371. if m.clearedsop_task {
  29372. edges = append(edges, sopstage.EdgeSopTask)
  29373. }
  29374. if m.clearedstage_nodes {
  29375. edges = append(edges, sopstage.EdgeStageNodes)
  29376. }
  29377. if m.clearedstage_messages {
  29378. edges = append(edges, sopstage.EdgeStageMessages)
  29379. }
  29380. return edges
  29381. }
  29382. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29383. // was cleared in this mutation.
  29384. func (m *SopStageMutation) EdgeCleared(name string) bool {
  29385. switch name {
  29386. case sopstage.EdgeSopTask:
  29387. return m.clearedsop_task
  29388. case sopstage.EdgeStageNodes:
  29389. return m.clearedstage_nodes
  29390. case sopstage.EdgeStageMessages:
  29391. return m.clearedstage_messages
  29392. }
  29393. return false
  29394. }
  29395. // ClearEdge clears the value of the edge with the given name. It returns an error
  29396. // if that edge is not defined in the schema.
  29397. func (m *SopStageMutation) ClearEdge(name string) error {
  29398. switch name {
  29399. case sopstage.EdgeSopTask:
  29400. m.ClearSopTask()
  29401. return nil
  29402. }
  29403. return fmt.Errorf("unknown SopStage unique edge %s", name)
  29404. }
  29405. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29406. // It returns an error if the edge is not defined in the schema.
  29407. func (m *SopStageMutation) ResetEdge(name string) error {
  29408. switch name {
  29409. case sopstage.EdgeSopTask:
  29410. m.ResetSopTask()
  29411. return nil
  29412. case sopstage.EdgeStageNodes:
  29413. m.ResetStageNodes()
  29414. return nil
  29415. case sopstage.EdgeStageMessages:
  29416. m.ResetStageMessages()
  29417. return nil
  29418. }
  29419. return fmt.Errorf("unknown SopStage edge %s", name)
  29420. }
  29421. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  29422. type SopTaskMutation struct {
  29423. config
  29424. op Op
  29425. typ string
  29426. id *uint64
  29427. created_at *time.Time
  29428. updated_at *time.Time
  29429. status *uint8
  29430. addstatus *int8
  29431. deleted_at *time.Time
  29432. name *string
  29433. bot_wxid_list *[]string
  29434. appendbot_wxid_list []string
  29435. _type *int
  29436. add_type *int
  29437. plan_start_time *time.Time
  29438. plan_end_time *time.Time
  29439. creator_id *string
  29440. organization_id *uint64
  29441. addorganization_id *int64
  29442. token *[]string
  29443. appendtoken []string
  29444. clearedFields map[string]struct{}
  29445. task_stages map[uint64]struct{}
  29446. removedtask_stages map[uint64]struct{}
  29447. clearedtask_stages bool
  29448. done bool
  29449. oldValue func(context.Context) (*SopTask, error)
  29450. predicates []predicate.SopTask
  29451. }
  29452. var _ ent.Mutation = (*SopTaskMutation)(nil)
  29453. // soptaskOption allows management of the mutation configuration using functional options.
  29454. type soptaskOption func(*SopTaskMutation)
  29455. // newSopTaskMutation creates new mutation for the SopTask entity.
  29456. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  29457. m := &SopTaskMutation{
  29458. config: c,
  29459. op: op,
  29460. typ: TypeSopTask,
  29461. clearedFields: make(map[string]struct{}),
  29462. }
  29463. for _, opt := range opts {
  29464. opt(m)
  29465. }
  29466. return m
  29467. }
  29468. // withSopTaskID sets the ID field of the mutation.
  29469. func withSopTaskID(id uint64) soptaskOption {
  29470. return func(m *SopTaskMutation) {
  29471. var (
  29472. err error
  29473. once sync.Once
  29474. value *SopTask
  29475. )
  29476. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  29477. once.Do(func() {
  29478. if m.done {
  29479. err = errors.New("querying old values post mutation is not allowed")
  29480. } else {
  29481. value, err = m.Client().SopTask.Get(ctx, id)
  29482. }
  29483. })
  29484. return value, err
  29485. }
  29486. m.id = &id
  29487. }
  29488. }
  29489. // withSopTask sets the old SopTask of the mutation.
  29490. func withSopTask(node *SopTask) soptaskOption {
  29491. return func(m *SopTaskMutation) {
  29492. m.oldValue = func(context.Context) (*SopTask, error) {
  29493. return node, nil
  29494. }
  29495. m.id = &node.ID
  29496. }
  29497. }
  29498. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29499. // executed in a transaction (ent.Tx), a transactional client is returned.
  29500. func (m SopTaskMutation) Client() *Client {
  29501. client := &Client{config: m.config}
  29502. client.init()
  29503. return client
  29504. }
  29505. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29506. // it returns an error otherwise.
  29507. func (m SopTaskMutation) Tx() (*Tx, error) {
  29508. if _, ok := m.driver.(*txDriver); !ok {
  29509. return nil, errors.New("ent: mutation is not running in a transaction")
  29510. }
  29511. tx := &Tx{config: m.config}
  29512. tx.init()
  29513. return tx, nil
  29514. }
  29515. // SetID sets the value of the id field. Note that this
  29516. // operation is only accepted on creation of SopTask entities.
  29517. func (m *SopTaskMutation) SetID(id uint64) {
  29518. m.id = &id
  29519. }
  29520. // ID returns the ID value in the mutation. Note that the ID is only available
  29521. // if it was provided to the builder or after it was returned from the database.
  29522. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  29523. if m.id == nil {
  29524. return
  29525. }
  29526. return *m.id, true
  29527. }
  29528. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29529. // That means, if the mutation is applied within a transaction with an isolation level such
  29530. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29531. // or updated by the mutation.
  29532. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  29533. switch {
  29534. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29535. id, exists := m.ID()
  29536. if exists {
  29537. return []uint64{id}, nil
  29538. }
  29539. fallthrough
  29540. case m.op.Is(OpUpdate | OpDelete):
  29541. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  29542. default:
  29543. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29544. }
  29545. }
  29546. // SetCreatedAt sets the "created_at" field.
  29547. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  29548. m.created_at = &t
  29549. }
  29550. // CreatedAt returns the value of the "created_at" field in the mutation.
  29551. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  29552. v := m.created_at
  29553. if v == nil {
  29554. return
  29555. }
  29556. return *v, true
  29557. }
  29558. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  29559. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  29560. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29561. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29562. if !m.op.Is(OpUpdateOne) {
  29563. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29564. }
  29565. if m.id == nil || m.oldValue == nil {
  29566. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29567. }
  29568. oldValue, err := m.oldValue(ctx)
  29569. if err != nil {
  29570. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29571. }
  29572. return oldValue.CreatedAt, nil
  29573. }
  29574. // ResetCreatedAt resets all changes to the "created_at" field.
  29575. func (m *SopTaskMutation) ResetCreatedAt() {
  29576. m.created_at = nil
  29577. }
  29578. // SetUpdatedAt sets the "updated_at" field.
  29579. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  29580. m.updated_at = &t
  29581. }
  29582. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29583. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  29584. v := m.updated_at
  29585. if v == nil {
  29586. return
  29587. }
  29588. return *v, true
  29589. }
  29590. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  29591. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  29592. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29593. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29594. if !m.op.Is(OpUpdateOne) {
  29595. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29596. }
  29597. if m.id == nil || m.oldValue == nil {
  29598. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29599. }
  29600. oldValue, err := m.oldValue(ctx)
  29601. if err != nil {
  29602. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29603. }
  29604. return oldValue.UpdatedAt, nil
  29605. }
  29606. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29607. func (m *SopTaskMutation) ResetUpdatedAt() {
  29608. m.updated_at = nil
  29609. }
  29610. // SetStatus sets the "status" field.
  29611. func (m *SopTaskMutation) SetStatus(u uint8) {
  29612. m.status = &u
  29613. m.addstatus = nil
  29614. }
  29615. // Status returns the value of the "status" field in the mutation.
  29616. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  29617. v := m.status
  29618. if v == nil {
  29619. return
  29620. }
  29621. return *v, true
  29622. }
  29623. // OldStatus returns the old "status" field's value of the SopTask entity.
  29624. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  29625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29626. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  29627. if !m.op.Is(OpUpdateOne) {
  29628. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  29629. }
  29630. if m.id == nil || m.oldValue == nil {
  29631. return v, errors.New("OldStatus requires an ID field in the mutation")
  29632. }
  29633. oldValue, err := m.oldValue(ctx)
  29634. if err != nil {
  29635. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  29636. }
  29637. return oldValue.Status, nil
  29638. }
  29639. // AddStatus adds u to the "status" field.
  29640. func (m *SopTaskMutation) AddStatus(u int8) {
  29641. if m.addstatus != nil {
  29642. *m.addstatus += u
  29643. } else {
  29644. m.addstatus = &u
  29645. }
  29646. }
  29647. // AddedStatus returns the value that was added to the "status" field in this mutation.
  29648. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  29649. v := m.addstatus
  29650. if v == nil {
  29651. return
  29652. }
  29653. return *v, true
  29654. }
  29655. // ClearStatus clears the value of the "status" field.
  29656. func (m *SopTaskMutation) ClearStatus() {
  29657. m.status = nil
  29658. m.addstatus = nil
  29659. m.clearedFields[soptask.FieldStatus] = struct{}{}
  29660. }
  29661. // StatusCleared returns if the "status" field was cleared in this mutation.
  29662. func (m *SopTaskMutation) StatusCleared() bool {
  29663. _, ok := m.clearedFields[soptask.FieldStatus]
  29664. return ok
  29665. }
  29666. // ResetStatus resets all changes to the "status" field.
  29667. func (m *SopTaskMutation) ResetStatus() {
  29668. m.status = nil
  29669. m.addstatus = nil
  29670. delete(m.clearedFields, soptask.FieldStatus)
  29671. }
  29672. // SetDeletedAt sets the "deleted_at" field.
  29673. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  29674. m.deleted_at = &t
  29675. }
  29676. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  29677. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  29678. v := m.deleted_at
  29679. if v == nil {
  29680. return
  29681. }
  29682. return *v, true
  29683. }
  29684. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  29685. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  29686. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29687. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  29688. if !m.op.Is(OpUpdateOne) {
  29689. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  29690. }
  29691. if m.id == nil || m.oldValue == nil {
  29692. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  29693. }
  29694. oldValue, err := m.oldValue(ctx)
  29695. if err != nil {
  29696. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  29697. }
  29698. return oldValue.DeletedAt, nil
  29699. }
  29700. // ClearDeletedAt clears the value of the "deleted_at" field.
  29701. func (m *SopTaskMutation) ClearDeletedAt() {
  29702. m.deleted_at = nil
  29703. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  29704. }
  29705. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  29706. func (m *SopTaskMutation) DeletedAtCleared() bool {
  29707. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  29708. return ok
  29709. }
  29710. // ResetDeletedAt resets all changes to the "deleted_at" field.
  29711. func (m *SopTaskMutation) ResetDeletedAt() {
  29712. m.deleted_at = nil
  29713. delete(m.clearedFields, soptask.FieldDeletedAt)
  29714. }
  29715. // SetName sets the "name" field.
  29716. func (m *SopTaskMutation) SetName(s string) {
  29717. m.name = &s
  29718. }
  29719. // Name returns the value of the "name" field in the mutation.
  29720. func (m *SopTaskMutation) Name() (r string, exists bool) {
  29721. v := m.name
  29722. if v == nil {
  29723. return
  29724. }
  29725. return *v, true
  29726. }
  29727. // OldName returns the old "name" field's value of the SopTask entity.
  29728. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  29729. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29730. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  29731. if !m.op.Is(OpUpdateOne) {
  29732. return v, errors.New("OldName is only allowed on UpdateOne operations")
  29733. }
  29734. if m.id == nil || m.oldValue == nil {
  29735. return v, errors.New("OldName requires an ID field in the mutation")
  29736. }
  29737. oldValue, err := m.oldValue(ctx)
  29738. if err != nil {
  29739. return v, fmt.Errorf("querying old value for OldName: %w", err)
  29740. }
  29741. return oldValue.Name, nil
  29742. }
  29743. // ResetName resets all changes to the "name" field.
  29744. func (m *SopTaskMutation) ResetName() {
  29745. m.name = nil
  29746. }
  29747. // SetBotWxidList sets the "bot_wxid_list" field.
  29748. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  29749. m.bot_wxid_list = &s
  29750. m.appendbot_wxid_list = nil
  29751. }
  29752. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  29753. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  29754. v := m.bot_wxid_list
  29755. if v == nil {
  29756. return
  29757. }
  29758. return *v, true
  29759. }
  29760. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  29761. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  29762. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29763. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  29764. if !m.op.Is(OpUpdateOne) {
  29765. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  29766. }
  29767. if m.id == nil || m.oldValue == nil {
  29768. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  29769. }
  29770. oldValue, err := m.oldValue(ctx)
  29771. if err != nil {
  29772. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  29773. }
  29774. return oldValue.BotWxidList, nil
  29775. }
  29776. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  29777. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  29778. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  29779. }
  29780. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  29781. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  29782. if len(m.appendbot_wxid_list) == 0 {
  29783. return nil, false
  29784. }
  29785. return m.appendbot_wxid_list, true
  29786. }
  29787. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  29788. func (m *SopTaskMutation) ClearBotWxidList() {
  29789. m.bot_wxid_list = nil
  29790. m.appendbot_wxid_list = nil
  29791. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  29792. }
  29793. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  29794. func (m *SopTaskMutation) BotWxidListCleared() bool {
  29795. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  29796. return ok
  29797. }
  29798. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  29799. func (m *SopTaskMutation) ResetBotWxidList() {
  29800. m.bot_wxid_list = nil
  29801. m.appendbot_wxid_list = nil
  29802. delete(m.clearedFields, soptask.FieldBotWxidList)
  29803. }
  29804. // SetType sets the "type" field.
  29805. func (m *SopTaskMutation) SetType(i int) {
  29806. m._type = &i
  29807. m.add_type = nil
  29808. }
  29809. // GetType returns the value of the "type" field in the mutation.
  29810. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  29811. v := m._type
  29812. if v == nil {
  29813. return
  29814. }
  29815. return *v, true
  29816. }
  29817. // OldType returns the old "type" field's value of the SopTask entity.
  29818. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  29819. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29820. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  29821. if !m.op.Is(OpUpdateOne) {
  29822. return v, errors.New("OldType is only allowed on UpdateOne operations")
  29823. }
  29824. if m.id == nil || m.oldValue == nil {
  29825. return v, errors.New("OldType requires an ID field in the mutation")
  29826. }
  29827. oldValue, err := m.oldValue(ctx)
  29828. if err != nil {
  29829. return v, fmt.Errorf("querying old value for OldType: %w", err)
  29830. }
  29831. return oldValue.Type, nil
  29832. }
  29833. // AddType adds i to the "type" field.
  29834. func (m *SopTaskMutation) AddType(i int) {
  29835. if m.add_type != nil {
  29836. *m.add_type += i
  29837. } else {
  29838. m.add_type = &i
  29839. }
  29840. }
  29841. // AddedType returns the value that was added to the "type" field in this mutation.
  29842. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  29843. v := m.add_type
  29844. if v == nil {
  29845. return
  29846. }
  29847. return *v, true
  29848. }
  29849. // ResetType resets all changes to the "type" field.
  29850. func (m *SopTaskMutation) ResetType() {
  29851. m._type = nil
  29852. m.add_type = nil
  29853. }
  29854. // SetPlanStartTime sets the "plan_start_time" field.
  29855. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  29856. m.plan_start_time = &t
  29857. }
  29858. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  29859. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  29860. v := m.plan_start_time
  29861. if v == nil {
  29862. return
  29863. }
  29864. return *v, true
  29865. }
  29866. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  29867. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  29868. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29869. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  29870. if !m.op.Is(OpUpdateOne) {
  29871. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  29872. }
  29873. if m.id == nil || m.oldValue == nil {
  29874. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  29875. }
  29876. oldValue, err := m.oldValue(ctx)
  29877. if err != nil {
  29878. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  29879. }
  29880. return oldValue.PlanStartTime, nil
  29881. }
  29882. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  29883. func (m *SopTaskMutation) ClearPlanStartTime() {
  29884. m.plan_start_time = nil
  29885. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  29886. }
  29887. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  29888. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  29889. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  29890. return ok
  29891. }
  29892. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  29893. func (m *SopTaskMutation) ResetPlanStartTime() {
  29894. m.plan_start_time = nil
  29895. delete(m.clearedFields, soptask.FieldPlanStartTime)
  29896. }
  29897. // SetPlanEndTime sets the "plan_end_time" field.
  29898. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  29899. m.plan_end_time = &t
  29900. }
  29901. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  29902. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  29903. v := m.plan_end_time
  29904. if v == nil {
  29905. return
  29906. }
  29907. return *v, true
  29908. }
  29909. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  29910. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  29911. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29912. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  29913. if !m.op.Is(OpUpdateOne) {
  29914. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  29915. }
  29916. if m.id == nil || m.oldValue == nil {
  29917. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  29918. }
  29919. oldValue, err := m.oldValue(ctx)
  29920. if err != nil {
  29921. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  29922. }
  29923. return oldValue.PlanEndTime, nil
  29924. }
  29925. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  29926. func (m *SopTaskMutation) ClearPlanEndTime() {
  29927. m.plan_end_time = nil
  29928. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  29929. }
  29930. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  29931. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  29932. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  29933. return ok
  29934. }
  29935. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  29936. func (m *SopTaskMutation) ResetPlanEndTime() {
  29937. m.plan_end_time = nil
  29938. delete(m.clearedFields, soptask.FieldPlanEndTime)
  29939. }
  29940. // SetCreatorID sets the "creator_id" field.
  29941. func (m *SopTaskMutation) SetCreatorID(s string) {
  29942. m.creator_id = &s
  29943. }
  29944. // CreatorID returns the value of the "creator_id" field in the mutation.
  29945. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  29946. v := m.creator_id
  29947. if v == nil {
  29948. return
  29949. }
  29950. return *v, true
  29951. }
  29952. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  29953. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  29954. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29955. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  29956. if !m.op.Is(OpUpdateOne) {
  29957. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  29958. }
  29959. if m.id == nil || m.oldValue == nil {
  29960. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  29961. }
  29962. oldValue, err := m.oldValue(ctx)
  29963. if err != nil {
  29964. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  29965. }
  29966. return oldValue.CreatorID, nil
  29967. }
  29968. // ClearCreatorID clears the value of the "creator_id" field.
  29969. func (m *SopTaskMutation) ClearCreatorID() {
  29970. m.creator_id = nil
  29971. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  29972. }
  29973. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  29974. func (m *SopTaskMutation) CreatorIDCleared() bool {
  29975. _, ok := m.clearedFields[soptask.FieldCreatorID]
  29976. return ok
  29977. }
  29978. // ResetCreatorID resets all changes to the "creator_id" field.
  29979. func (m *SopTaskMutation) ResetCreatorID() {
  29980. m.creator_id = nil
  29981. delete(m.clearedFields, soptask.FieldCreatorID)
  29982. }
  29983. // SetOrganizationID sets the "organization_id" field.
  29984. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  29985. m.organization_id = &u
  29986. m.addorganization_id = nil
  29987. }
  29988. // OrganizationID returns the value of the "organization_id" field in the mutation.
  29989. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  29990. v := m.organization_id
  29991. if v == nil {
  29992. return
  29993. }
  29994. return *v, true
  29995. }
  29996. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  29997. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  29998. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29999. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  30000. if !m.op.Is(OpUpdateOne) {
  30001. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  30002. }
  30003. if m.id == nil || m.oldValue == nil {
  30004. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  30005. }
  30006. oldValue, err := m.oldValue(ctx)
  30007. if err != nil {
  30008. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  30009. }
  30010. return oldValue.OrganizationID, nil
  30011. }
  30012. // AddOrganizationID adds u to the "organization_id" field.
  30013. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  30014. if m.addorganization_id != nil {
  30015. *m.addorganization_id += u
  30016. } else {
  30017. m.addorganization_id = &u
  30018. }
  30019. }
  30020. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  30021. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  30022. v := m.addorganization_id
  30023. if v == nil {
  30024. return
  30025. }
  30026. return *v, true
  30027. }
  30028. // ClearOrganizationID clears the value of the "organization_id" field.
  30029. func (m *SopTaskMutation) ClearOrganizationID() {
  30030. m.organization_id = nil
  30031. m.addorganization_id = nil
  30032. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  30033. }
  30034. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  30035. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  30036. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  30037. return ok
  30038. }
  30039. // ResetOrganizationID resets all changes to the "organization_id" field.
  30040. func (m *SopTaskMutation) ResetOrganizationID() {
  30041. m.organization_id = nil
  30042. m.addorganization_id = nil
  30043. delete(m.clearedFields, soptask.FieldOrganizationID)
  30044. }
  30045. // SetToken sets the "token" field.
  30046. func (m *SopTaskMutation) SetToken(s []string) {
  30047. m.token = &s
  30048. m.appendtoken = nil
  30049. }
  30050. // Token returns the value of the "token" field in the mutation.
  30051. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  30052. v := m.token
  30053. if v == nil {
  30054. return
  30055. }
  30056. return *v, true
  30057. }
  30058. // OldToken returns the old "token" field's value of the SopTask entity.
  30059. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  30060. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30061. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  30062. if !m.op.Is(OpUpdateOne) {
  30063. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  30064. }
  30065. if m.id == nil || m.oldValue == nil {
  30066. return v, errors.New("OldToken requires an ID field in the mutation")
  30067. }
  30068. oldValue, err := m.oldValue(ctx)
  30069. if err != nil {
  30070. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  30071. }
  30072. return oldValue.Token, nil
  30073. }
  30074. // AppendToken adds s to the "token" field.
  30075. func (m *SopTaskMutation) AppendToken(s []string) {
  30076. m.appendtoken = append(m.appendtoken, s...)
  30077. }
  30078. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  30079. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  30080. if len(m.appendtoken) == 0 {
  30081. return nil, false
  30082. }
  30083. return m.appendtoken, true
  30084. }
  30085. // ClearToken clears the value of the "token" field.
  30086. func (m *SopTaskMutation) ClearToken() {
  30087. m.token = nil
  30088. m.appendtoken = nil
  30089. m.clearedFields[soptask.FieldToken] = struct{}{}
  30090. }
  30091. // TokenCleared returns if the "token" field was cleared in this mutation.
  30092. func (m *SopTaskMutation) TokenCleared() bool {
  30093. _, ok := m.clearedFields[soptask.FieldToken]
  30094. return ok
  30095. }
  30096. // ResetToken resets all changes to the "token" field.
  30097. func (m *SopTaskMutation) ResetToken() {
  30098. m.token = nil
  30099. m.appendtoken = nil
  30100. delete(m.clearedFields, soptask.FieldToken)
  30101. }
  30102. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  30103. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  30104. if m.task_stages == nil {
  30105. m.task_stages = make(map[uint64]struct{})
  30106. }
  30107. for i := range ids {
  30108. m.task_stages[ids[i]] = struct{}{}
  30109. }
  30110. }
  30111. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  30112. func (m *SopTaskMutation) ClearTaskStages() {
  30113. m.clearedtask_stages = true
  30114. }
  30115. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  30116. func (m *SopTaskMutation) TaskStagesCleared() bool {
  30117. return m.clearedtask_stages
  30118. }
  30119. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  30120. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  30121. if m.removedtask_stages == nil {
  30122. m.removedtask_stages = make(map[uint64]struct{})
  30123. }
  30124. for i := range ids {
  30125. delete(m.task_stages, ids[i])
  30126. m.removedtask_stages[ids[i]] = struct{}{}
  30127. }
  30128. }
  30129. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  30130. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  30131. for id := range m.removedtask_stages {
  30132. ids = append(ids, id)
  30133. }
  30134. return
  30135. }
  30136. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  30137. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  30138. for id := range m.task_stages {
  30139. ids = append(ids, id)
  30140. }
  30141. return
  30142. }
  30143. // ResetTaskStages resets all changes to the "task_stages" edge.
  30144. func (m *SopTaskMutation) ResetTaskStages() {
  30145. m.task_stages = nil
  30146. m.clearedtask_stages = false
  30147. m.removedtask_stages = nil
  30148. }
  30149. // Where appends a list predicates to the SopTaskMutation builder.
  30150. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  30151. m.predicates = append(m.predicates, ps...)
  30152. }
  30153. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  30154. // users can use type-assertion to append predicates that do not depend on any generated package.
  30155. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  30156. p := make([]predicate.SopTask, len(ps))
  30157. for i := range ps {
  30158. p[i] = ps[i]
  30159. }
  30160. m.Where(p...)
  30161. }
  30162. // Op returns the operation name.
  30163. func (m *SopTaskMutation) Op() Op {
  30164. return m.op
  30165. }
  30166. // SetOp allows setting the mutation operation.
  30167. func (m *SopTaskMutation) SetOp(op Op) {
  30168. m.op = op
  30169. }
  30170. // Type returns the node type of this mutation (SopTask).
  30171. func (m *SopTaskMutation) Type() string {
  30172. return m.typ
  30173. }
  30174. // Fields returns all fields that were changed during this mutation. Note that in
  30175. // order to get all numeric fields that were incremented/decremented, call
  30176. // AddedFields().
  30177. func (m *SopTaskMutation) Fields() []string {
  30178. fields := make([]string, 0, 12)
  30179. if m.created_at != nil {
  30180. fields = append(fields, soptask.FieldCreatedAt)
  30181. }
  30182. if m.updated_at != nil {
  30183. fields = append(fields, soptask.FieldUpdatedAt)
  30184. }
  30185. if m.status != nil {
  30186. fields = append(fields, soptask.FieldStatus)
  30187. }
  30188. if m.deleted_at != nil {
  30189. fields = append(fields, soptask.FieldDeletedAt)
  30190. }
  30191. if m.name != nil {
  30192. fields = append(fields, soptask.FieldName)
  30193. }
  30194. if m.bot_wxid_list != nil {
  30195. fields = append(fields, soptask.FieldBotWxidList)
  30196. }
  30197. if m._type != nil {
  30198. fields = append(fields, soptask.FieldType)
  30199. }
  30200. if m.plan_start_time != nil {
  30201. fields = append(fields, soptask.FieldPlanStartTime)
  30202. }
  30203. if m.plan_end_time != nil {
  30204. fields = append(fields, soptask.FieldPlanEndTime)
  30205. }
  30206. if m.creator_id != nil {
  30207. fields = append(fields, soptask.FieldCreatorID)
  30208. }
  30209. if m.organization_id != nil {
  30210. fields = append(fields, soptask.FieldOrganizationID)
  30211. }
  30212. if m.token != nil {
  30213. fields = append(fields, soptask.FieldToken)
  30214. }
  30215. return fields
  30216. }
  30217. // Field returns the value of a field with the given name. The second boolean
  30218. // return value indicates that this field was not set, or was not defined in the
  30219. // schema.
  30220. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  30221. switch name {
  30222. case soptask.FieldCreatedAt:
  30223. return m.CreatedAt()
  30224. case soptask.FieldUpdatedAt:
  30225. return m.UpdatedAt()
  30226. case soptask.FieldStatus:
  30227. return m.Status()
  30228. case soptask.FieldDeletedAt:
  30229. return m.DeletedAt()
  30230. case soptask.FieldName:
  30231. return m.Name()
  30232. case soptask.FieldBotWxidList:
  30233. return m.BotWxidList()
  30234. case soptask.FieldType:
  30235. return m.GetType()
  30236. case soptask.FieldPlanStartTime:
  30237. return m.PlanStartTime()
  30238. case soptask.FieldPlanEndTime:
  30239. return m.PlanEndTime()
  30240. case soptask.FieldCreatorID:
  30241. return m.CreatorID()
  30242. case soptask.FieldOrganizationID:
  30243. return m.OrganizationID()
  30244. case soptask.FieldToken:
  30245. return m.Token()
  30246. }
  30247. return nil, false
  30248. }
  30249. // OldField returns the old value of the field from the database. An error is
  30250. // returned if the mutation operation is not UpdateOne, or the query to the
  30251. // database failed.
  30252. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30253. switch name {
  30254. case soptask.FieldCreatedAt:
  30255. return m.OldCreatedAt(ctx)
  30256. case soptask.FieldUpdatedAt:
  30257. return m.OldUpdatedAt(ctx)
  30258. case soptask.FieldStatus:
  30259. return m.OldStatus(ctx)
  30260. case soptask.FieldDeletedAt:
  30261. return m.OldDeletedAt(ctx)
  30262. case soptask.FieldName:
  30263. return m.OldName(ctx)
  30264. case soptask.FieldBotWxidList:
  30265. return m.OldBotWxidList(ctx)
  30266. case soptask.FieldType:
  30267. return m.OldType(ctx)
  30268. case soptask.FieldPlanStartTime:
  30269. return m.OldPlanStartTime(ctx)
  30270. case soptask.FieldPlanEndTime:
  30271. return m.OldPlanEndTime(ctx)
  30272. case soptask.FieldCreatorID:
  30273. return m.OldCreatorID(ctx)
  30274. case soptask.FieldOrganizationID:
  30275. return m.OldOrganizationID(ctx)
  30276. case soptask.FieldToken:
  30277. return m.OldToken(ctx)
  30278. }
  30279. return nil, fmt.Errorf("unknown SopTask field %s", name)
  30280. }
  30281. // SetField sets the value of a field with the given name. It returns an error if
  30282. // the field is not defined in the schema, or if the type mismatched the field
  30283. // type.
  30284. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  30285. switch name {
  30286. case soptask.FieldCreatedAt:
  30287. v, ok := value.(time.Time)
  30288. if !ok {
  30289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30290. }
  30291. m.SetCreatedAt(v)
  30292. return nil
  30293. case soptask.FieldUpdatedAt:
  30294. v, ok := value.(time.Time)
  30295. if !ok {
  30296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30297. }
  30298. m.SetUpdatedAt(v)
  30299. return nil
  30300. case soptask.FieldStatus:
  30301. v, ok := value.(uint8)
  30302. if !ok {
  30303. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30304. }
  30305. m.SetStatus(v)
  30306. return nil
  30307. case soptask.FieldDeletedAt:
  30308. v, ok := value.(time.Time)
  30309. if !ok {
  30310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30311. }
  30312. m.SetDeletedAt(v)
  30313. return nil
  30314. case soptask.FieldName:
  30315. v, ok := value.(string)
  30316. if !ok {
  30317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30318. }
  30319. m.SetName(v)
  30320. return nil
  30321. case soptask.FieldBotWxidList:
  30322. v, ok := value.([]string)
  30323. if !ok {
  30324. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30325. }
  30326. m.SetBotWxidList(v)
  30327. return nil
  30328. case soptask.FieldType:
  30329. v, ok := value.(int)
  30330. if !ok {
  30331. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30332. }
  30333. m.SetType(v)
  30334. return nil
  30335. case soptask.FieldPlanStartTime:
  30336. v, ok := value.(time.Time)
  30337. if !ok {
  30338. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30339. }
  30340. m.SetPlanStartTime(v)
  30341. return nil
  30342. case soptask.FieldPlanEndTime:
  30343. v, ok := value.(time.Time)
  30344. if !ok {
  30345. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30346. }
  30347. m.SetPlanEndTime(v)
  30348. return nil
  30349. case soptask.FieldCreatorID:
  30350. v, ok := value.(string)
  30351. if !ok {
  30352. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30353. }
  30354. m.SetCreatorID(v)
  30355. return nil
  30356. case soptask.FieldOrganizationID:
  30357. v, ok := value.(uint64)
  30358. if !ok {
  30359. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30360. }
  30361. m.SetOrganizationID(v)
  30362. return nil
  30363. case soptask.FieldToken:
  30364. v, ok := value.([]string)
  30365. if !ok {
  30366. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30367. }
  30368. m.SetToken(v)
  30369. return nil
  30370. }
  30371. return fmt.Errorf("unknown SopTask field %s", name)
  30372. }
  30373. // AddedFields returns all numeric fields that were incremented/decremented during
  30374. // this mutation.
  30375. func (m *SopTaskMutation) AddedFields() []string {
  30376. var fields []string
  30377. if m.addstatus != nil {
  30378. fields = append(fields, soptask.FieldStatus)
  30379. }
  30380. if m.add_type != nil {
  30381. fields = append(fields, soptask.FieldType)
  30382. }
  30383. if m.addorganization_id != nil {
  30384. fields = append(fields, soptask.FieldOrganizationID)
  30385. }
  30386. return fields
  30387. }
  30388. // AddedField returns the numeric value that was incremented/decremented on a field
  30389. // with the given name. The second boolean return value indicates that this field
  30390. // was not set, or was not defined in the schema.
  30391. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  30392. switch name {
  30393. case soptask.FieldStatus:
  30394. return m.AddedStatus()
  30395. case soptask.FieldType:
  30396. return m.AddedType()
  30397. case soptask.FieldOrganizationID:
  30398. return m.AddedOrganizationID()
  30399. }
  30400. return nil, false
  30401. }
  30402. // AddField adds the value to the field with the given name. It returns an error if
  30403. // the field is not defined in the schema, or if the type mismatched the field
  30404. // type.
  30405. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  30406. switch name {
  30407. case soptask.FieldStatus:
  30408. v, ok := value.(int8)
  30409. if !ok {
  30410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30411. }
  30412. m.AddStatus(v)
  30413. return nil
  30414. case soptask.FieldType:
  30415. v, ok := value.(int)
  30416. if !ok {
  30417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30418. }
  30419. m.AddType(v)
  30420. return nil
  30421. case soptask.FieldOrganizationID:
  30422. v, ok := value.(int64)
  30423. if !ok {
  30424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30425. }
  30426. m.AddOrganizationID(v)
  30427. return nil
  30428. }
  30429. return fmt.Errorf("unknown SopTask numeric field %s", name)
  30430. }
  30431. // ClearedFields returns all nullable fields that were cleared during this
  30432. // mutation.
  30433. func (m *SopTaskMutation) ClearedFields() []string {
  30434. var fields []string
  30435. if m.FieldCleared(soptask.FieldStatus) {
  30436. fields = append(fields, soptask.FieldStatus)
  30437. }
  30438. if m.FieldCleared(soptask.FieldDeletedAt) {
  30439. fields = append(fields, soptask.FieldDeletedAt)
  30440. }
  30441. if m.FieldCleared(soptask.FieldBotWxidList) {
  30442. fields = append(fields, soptask.FieldBotWxidList)
  30443. }
  30444. if m.FieldCleared(soptask.FieldPlanStartTime) {
  30445. fields = append(fields, soptask.FieldPlanStartTime)
  30446. }
  30447. if m.FieldCleared(soptask.FieldPlanEndTime) {
  30448. fields = append(fields, soptask.FieldPlanEndTime)
  30449. }
  30450. if m.FieldCleared(soptask.FieldCreatorID) {
  30451. fields = append(fields, soptask.FieldCreatorID)
  30452. }
  30453. if m.FieldCleared(soptask.FieldOrganizationID) {
  30454. fields = append(fields, soptask.FieldOrganizationID)
  30455. }
  30456. if m.FieldCleared(soptask.FieldToken) {
  30457. fields = append(fields, soptask.FieldToken)
  30458. }
  30459. return fields
  30460. }
  30461. // FieldCleared returns a boolean indicating if a field with the given name was
  30462. // cleared in this mutation.
  30463. func (m *SopTaskMutation) FieldCleared(name string) bool {
  30464. _, ok := m.clearedFields[name]
  30465. return ok
  30466. }
  30467. // ClearField clears the value of the field with the given name. It returns an
  30468. // error if the field is not defined in the schema.
  30469. func (m *SopTaskMutation) ClearField(name string) error {
  30470. switch name {
  30471. case soptask.FieldStatus:
  30472. m.ClearStatus()
  30473. return nil
  30474. case soptask.FieldDeletedAt:
  30475. m.ClearDeletedAt()
  30476. return nil
  30477. case soptask.FieldBotWxidList:
  30478. m.ClearBotWxidList()
  30479. return nil
  30480. case soptask.FieldPlanStartTime:
  30481. m.ClearPlanStartTime()
  30482. return nil
  30483. case soptask.FieldPlanEndTime:
  30484. m.ClearPlanEndTime()
  30485. return nil
  30486. case soptask.FieldCreatorID:
  30487. m.ClearCreatorID()
  30488. return nil
  30489. case soptask.FieldOrganizationID:
  30490. m.ClearOrganizationID()
  30491. return nil
  30492. case soptask.FieldToken:
  30493. m.ClearToken()
  30494. return nil
  30495. }
  30496. return fmt.Errorf("unknown SopTask nullable field %s", name)
  30497. }
  30498. // ResetField resets all changes in the mutation for the field with the given name.
  30499. // It returns an error if the field is not defined in the schema.
  30500. func (m *SopTaskMutation) ResetField(name string) error {
  30501. switch name {
  30502. case soptask.FieldCreatedAt:
  30503. m.ResetCreatedAt()
  30504. return nil
  30505. case soptask.FieldUpdatedAt:
  30506. m.ResetUpdatedAt()
  30507. return nil
  30508. case soptask.FieldStatus:
  30509. m.ResetStatus()
  30510. return nil
  30511. case soptask.FieldDeletedAt:
  30512. m.ResetDeletedAt()
  30513. return nil
  30514. case soptask.FieldName:
  30515. m.ResetName()
  30516. return nil
  30517. case soptask.FieldBotWxidList:
  30518. m.ResetBotWxidList()
  30519. return nil
  30520. case soptask.FieldType:
  30521. m.ResetType()
  30522. return nil
  30523. case soptask.FieldPlanStartTime:
  30524. m.ResetPlanStartTime()
  30525. return nil
  30526. case soptask.FieldPlanEndTime:
  30527. m.ResetPlanEndTime()
  30528. return nil
  30529. case soptask.FieldCreatorID:
  30530. m.ResetCreatorID()
  30531. return nil
  30532. case soptask.FieldOrganizationID:
  30533. m.ResetOrganizationID()
  30534. return nil
  30535. case soptask.FieldToken:
  30536. m.ResetToken()
  30537. return nil
  30538. }
  30539. return fmt.Errorf("unknown SopTask field %s", name)
  30540. }
  30541. // AddedEdges returns all edge names that were set/added in this mutation.
  30542. func (m *SopTaskMutation) AddedEdges() []string {
  30543. edges := make([]string, 0, 1)
  30544. if m.task_stages != nil {
  30545. edges = append(edges, soptask.EdgeTaskStages)
  30546. }
  30547. return edges
  30548. }
  30549. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  30550. // name in this mutation.
  30551. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  30552. switch name {
  30553. case soptask.EdgeTaskStages:
  30554. ids := make([]ent.Value, 0, len(m.task_stages))
  30555. for id := range m.task_stages {
  30556. ids = append(ids, id)
  30557. }
  30558. return ids
  30559. }
  30560. return nil
  30561. }
  30562. // RemovedEdges returns all edge names that were removed in this mutation.
  30563. func (m *SopTaskMutation) RemovedEdges() []string {
  30564. edges := make([]string, 0, 1)
  30565. if m.removedtask_stages != nil {
  30566. edges = append(edges, soptask.EdgeTaskStages)
  30567. }
  30568. return edges
  30569. }
  30570. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  30571. // the given name in this mutation.
  30572. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  30573. switch name {
  30574. case soptask.EdgeTaskStages:
  30575. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  30576. for id := range m.removedtask_stages {
  30577. ids = append(ids, id)
  30578. }
  30579. return ids
  30580. }
  30581. return nil
  30582. }
  30583. // ClearedEdges returns all edge names that were cleared in this mutation.
  30584. func (m *SopTaskMutation) ClearedEdges() []string {
  30585. edges := make([]string, 0, 1)
  30586. if m.clearedtask_stages {
  30587. edges = append(edges, soptask.EdgeTaskStages)
  30588. }
  30589. return edges
  30590. }
  30591. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30592. // was cleared in this mutation.
  30593. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  30594. switch name {
  30595. case soptask.EdgeTaskStages:
  30596. return m.clearedtask_stages
  30597. }
  30598. return false
  30599. }
  30600. // ClearEdge clears the value of the edge with the given name. It returns an error
  30601. // if that edge is not defined in the schema.
  30602. func (m *SopTaskMutation) ClearEdge(name string) error {
  30603. switch name {
  30604. }
  30605. return fmt.Errorf("unknown SopTask unique edge %s", name)
  30606. }
  30607. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30608. // It returns an error if the edge is not defined in the schema.
  30609. func (m *SopTaskMutation) ResetEdge(name string) error {
  30610. switch name {
  30611. case soptask.EdgeTaskStages:
  30612. m.ResetTaskStages()
  30613. return nil
  30614. }
  30615. return fmt.Errorf("unknown SopTask edge %s", name)
  30616. }
  30617. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  30618. type TokenMutation struct {
  30619. config
  30620. op Op
  30621. typ string
  30622. id *uint64
  30623. created_at *time.Time
  30624. updated_at *time.Time
  30625. deleted_at *time.Time
  30626. expire_at *time.Time
  30627. token *string
  30628. mac *string
  30629. organization_id *uint64
  30630. addorganization_id *int64
  30631. custom_agent_base *string
  30632. custom_agent_key *string
  30633. openai_base *string
  30634. openai_key *string
  30635. clearedFields map[string]struct{}
  30636. agent *uint64
  30637. clearedagent bool
  30638. done bool
  30639. oldValue func(context.Context) (*Token, error)
  30640. predicates []predicate.Token
  30641. }
  30642. var _ ent.Mutation = (*TokenMutation)(nil)
  30643. // tokenOption allows management of the mutation configuration using functional options.
  30644. type tokenOption func(*TokenMutation)
  30645. // newTokenMutation creates new mutation for the Token entity.
  30646. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  30647. m := &TokenMutation{
  30648. config: c,
  30649. op: op,
  30650. typ: TypeToken,
  30651. clearedFields: make(map[string]struct{}),
  30652. }
  30653. for _, opt := range opts {
  30654. opt(m)
  30655. }
  30656. return m
  30657. }
  30658. // withTokenID sets the ID field of the mutation.
  30659. func withTokenID(id uint64) tokenOption {
  30660. return func(m *TokenMutation) {
  30661. var (
  30662. err error
  30663. once sync.Once
  30664. value *Token
  30665. )
  30666. m.oldValue = func(ctx context.Context) (*Token, error) {
  30667. once.Do(func() {
  30668. if m.done {
  30669. err = errors.New("querying old values post mutation is not allowed")
  30670. } else {
  30671. value, err = m.Client().Token.Get(ctx, id)
  30672. }
  30673. })
  30674. return value, err
  30675. }
  30676. m.id = &id
  30677. }
  30678. }
  30679. // withToken sets the old Token of the mutation.
  30680. func withToken(node *Token) tokenOption {
  30681. return func(m *TokenMutation) {
  30682. m.oldValue = func(context.Context) (*Token, error) {
  30683. return node, nil
  30684. }
  30685. m.id = &node.ID
  30686. }
  30687. }
  30688. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30689. // executed in a transaction (ent.Tx), a transactional client is returned.
  30690. func (m TokenMutation) Client() *Client {
  30691. client := &Client{config: m.config}
  30692. client.init()
  30693. return client
  30694. }
  30695. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30696. // it returns an error otherwise.
  30697. func (m TokenMutation) Tx() (*Tx, error) {
  30698. if _, ok := m.driver.(*txDriver); !ok {
  30699. return nil, errors.New("ent: mutation is not running in a transaction")
  30700. }
  30701. tx := &Tx{config: m.config}
  30702. tx.init()
  30703. return tx, nil
  30704. }
  30705. // SetID sets the value of the id field. Note that this
  30706. // operation is only accepted on creation of Token entities.
  30707. func (m *TokenMutation) SetID(id uint64) {
  30708. m.id = &id
  30709. }
  30710. // ID returns the ID value in the mutation. Note that the ID is only available
  30711. // if it was provided to the builder or after it was returned from the database.
  30712. func (m *TokenMutation) ID() (id uint64, exists bool) {
  30713. if m.id == nil {
  30714. return
  30715. }
  30716. return *m.id, true
  30717. }
  30718. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30719. // That means, if the mutation is applied within a transaction with an isolation level such
  30720. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30721. // or updated by the mutation.
  30722. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  30723. switch {
  30724. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30725. id, exists := m.ID()
  30726. if exists {
  30727. return []uint64{id}, nil
  30728. }
  30729. fallthrough
  30730. case m.op.Is(OpUpdate | OpDelete):
  30731. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  30732. default:
  30733. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30734. }
  30735. }
  30736. // SetCreatedAt sets the "created_at" field.
  30737. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  30738. m.created_at = &t
  30739. }
  30740. // CreatedAt returns the value of the "created_at" field in the mutation.
  30741. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  30742. v := m.created_at
  30743. if v == nil {
  30744. return
  30745. }
  30746. return *v, true
  30747. }
  30748. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  30749. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  30750. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30751. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  30752. if !m.op.Is(OpUpdateOne) {
  30753. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  30754. }
  30755. if m.id == nil || m.oldValue == nil {
  30756. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  30757. }
  30758. oldValue, err := m.oldValue(ctx)
  30759. if err != nil {
  30760. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  30761. }
  30762. return oldValue.CreatedAt, nil
  30763. }
  30764. // ResetCreatedAt resets all changes to the "created_at" field.
  30765. func (m *TokenMutation) ResetCreatedAt() {
  30766. m.created_at = nil
  30767. }
  30768. // SetUpdatedAt sets the "updated_at" field.
  30769. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  30770. m.updated_at = &t
  30771. }
  30772. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  30773. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  30774. v := m.updated_at
  30775. if v == nil {
  30776. return
  30777. }
  30778. return *v, true
  30779. }
  30780. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  30781. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  30782. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30783. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  30784. if !m.op.Is(OpUpdateOne) {
  30785. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  30786. }
  30787. if m.id == nil || m.oldValue == nil {
  30788. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  30789. }
  30790. oldValue, err := m.oldValue(ctx)
  30791. if err != nil {
  30792. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  30793. }
  30794. return oldValue.UpdatedAt, nil
  30795. }
  30796. // ResetUpdatedAt resets all changes to the "updated_at" field.
  30797. func (m *TokenMutation) ResetUpdatedAt() {
  30798. m.updated_at = nil
  30799. }
  30800. // SetDeletedAt sets the "deleted_at" field.
  30801. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  30802. m.deleted_at = &t
  30803. }
  30804. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  30805. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  30806. v := m.deleted_at
  30807. if v == nil {
  30808. return
  30809. }
  30810. return *v, true
  30811. }
  30812. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  30813. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  30814. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30815. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  30816. if !m.op.Is(OpUpdateOne) {
  30817. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  30818. }
  30819. if m.id == nil || m.oldValue == nil {
  30820. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  30821. }
  30822. oldValue, err := m.oldValue(ctx)
  30823. if err != nil {
  30824. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  30825. }
  30826. return oldValue.DeletedAt, nil
  30827. }
  30828. // ClearDeletedAt clears the value of the "deleted_at" field.
  30829. func (m *TokenMutation) ClearDeletedAt() {
  30830. m.deleted_at = nil
  30831. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  30832. }
  30833. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  30834. func (m *TokenMutation) DeletedAtCleared() bool {
  30835. _, ok := m.clearedFields[token.FieldDeletedAt]
  30836. return ok
  30837. }
  30838. // ResetDeletedAt resets all changes to the "deleted_at" field.
  30839. func (m *TokenMutation) ResetDeletedAt() {
  30840. m.deleted_at = nil
  30841. delete(m.clearedFields, token.FieldDeletedAt)
  30842. }
  30843. // SetExpireAt sets the "expire_at" field.
  30844. func (m *TokenMutation) SetExpireAt(t time.Time) {
  30845. m.expire_at = &t
  30846. }
  30847. // ExpireAt returns the value of the "expire_at" field in the mutation.
  30848. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  30849. v := m.expire_at
  30850. if v == nil {
  30851. return
  30852. }
  30853. return *v, true
  30854. }
  30855. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  30856. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  30857. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30858. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  30859. if !m.op.Is(OpUpdateOne) {
  30860. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  30861. }
  30862. if m.id == nil || m.oldValue == nil {
  30863. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  30864. }
  30865. oldValue, err := m.oldValue(ctx)
  30866. if err != nil {
  30867. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  30868. }
  30869. return oldValue.ExpireAt, nil
  30870. }
  30871. // ClearExpireAt clears the value of the "expire_at" field.
  30872. func (m *TokenMutation) ClearExpireAt() {
  30873. m.expire_at = nil
  30874. m.clearedFields[token.FieldExpireAt] = struct{}{}
  30875. }
  30876. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  30877. func (m *TokenMutation) ExpireAtCleared() bool {
  30878. _, ok := m.clearedFields[token.FieldExpireAt]
  30879. return ok
  30880. }
  30881. // ResetExpireAt resets all changes to the "expire_at" field.
  30882. func (m *TokenMutation) ResetExpireAt() {
  30883. m.expire_at = nil
  30884. delete(m.clearedFields, token.FieldExpireAt)
  30885. }
  30886. // SetToken sets the "token" field.
  30887. func (m *TokenMutation) SetToken(s string) {
  30888. m.token = &s
  30889. }
  30890. // Token returns the value of the "token" field in the mutation.
  30891. func (m *TokenMutation) Token() (r string, exists bool) {
  30892. v := m.token
  30893. if v == nil {
  30894. return
  30895. }
  30896. return *v, true
  30897. }
  30898. // OldToken returns the old "token" field's value of the Token entity.
  30899. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  30900. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30901. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  30902. if !m.op.Is(OpUpdateOne) {
  30903. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  30904. }
  30905. if m.id == nil || m.oldValue == nil {
  30906. return v, errors.New("OldToken requires an ID field in the mutation")
  30907. }
  30908. oldValue, err := m.oldValue(ctx)
  30909. if err != nil {
  30910. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  30911. }
  30912. return oldValue.Token, nil
  30913. }
  30914. // ClearToken clears the value of the "token" field.
  30915. func (m *TokenMutation) ClearToken() {
  30916. m.token = nil
  30917. m.clearedFields[token.FieldToken] = struct{}{}
  30918. }
  30919. // TokenCleared returns if the "token" field was cleared in this mutation.
  30920. func (m *TokenMutation) TokenCleared() bool {
  30921. _, ok := m.clearedFields[token.FieldToken]
  30922. return ok
  30923. }
  30924. // ResetToken resets all changes to the "token" field.
  30925. func (m *TokenMutation) ResetToken() {
  30926. m.token = nil
  30927. delete(m.clearedFields, token.FieldToken)
  30928. }
  30929. // SetMAC sets the "mac" field.
  30930. func (m *TokenMutation) SetMAC(s string) {
  30931. m.mac = &s
  30932. }
  30933. // MAC returns the value of the "mac" field in the mutation.
  30934. func (m *TokenMutation) MAC() (r string, exists bool) {
  30935. v := m.mac
  30936. if v == nil {
  30937. return
  30938. }
  30939. return *v, true
  30940. }
  30941. // OldMAC returns the old "mac" field's value of the Token entity.
  30942. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  30943. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30944. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  30945. if !m.op.Is(OpUpdateOne) {
  30946. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  30947. }
  30948. if m.id == nil || m.oldValue == nil {
  30949. return v, errors.New("OldMAC requires an ID field in the mutation")
  30950. }
  30951. oldValue, err := m.oldValue(ctx)
  30952. if err != nil {
  30953. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  30954. }
  30955. return oldValue.MAC, nil
  30956. }
  30957. // ClearMAC clears the value of the "mac" field.
  30958. func (m *TokenMutation) ClearMAC() {
  30959. m.mac = nil
  30960. m.clearedFields[token.FieldMAC] = struct{}{}
  30961. }
  30962. // MACCleared returns if the "mac" field was cleared in this mutation.
  30963. func (m *TokenMutation) MACCleared() bool {
  30964. _, ok := m.clearedFields[token.FieldMAC]
  30965. return ok
  30966. }
  30967. // ResetMAC resets all changes to the "mac" field.
  30968. func (m *TokenMutation) ResetMAC() {
  30969. m.mac = nil
  30970. delete(m.clearedFields, token.FieldMAC)
  30971. }
  30972. // SetOrganizationID sets the "organization_id" field.
  30973. func (m *TokenMutation) SetOrganizationID(u uint64) {
  30974. m.organization_id = &u
  30975. m.addorganization_id = nil
  30976. }
  30977. // OrganizationID returns the value of the "organization_id" field in the mutation.
  30978. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  30979. v := m.organization_id
  30980. if v == nil {
  30981. return
  30982. }
  30983. return *v, true
  30984. }
  30985. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  30986. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  30987. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30988. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  30989. if !m.op.Is(OpUpdateOne) {
  30990. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  30991. }
  30992. if m.id == nil || m.oldValue == nil {
  30993. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  30994. }
  30995. oldValue, err := m.oldValue(ctx)
  30996. if err != nil {
  30997. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  30998. }
  30999. return oldValue.OrganizationID, nil
  31000. }
  31001. // AddOrganizationID adds u to the "organization_id" field.
  31002. func (m *TokenMutation) AddOrganizationID(u int64) {
  31003. if m.addorganization_id != nil {
  31004. *m.addorganization_id += u
  31005. } else {
  31006. m.addorganization_id = &u
  31007. }
  31008. }
  31009. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  31010. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  31011. v := m.addorganization_id
  31012. if v == nil {
  31013. return
  31014. }
  31015. return *v, true
  31016. }
  31017. // ResetOrganizationID resets all changes to the "organization_id" field.
  31018. func (m *TokenMutation) ResetOrganizationID() {
  31019. m.organization_id = nil
  31020. m.addorganization_id = nil
  31021. }
  31022. // SetAgentID sets the "agent_id" field.
  31023. func (m *TokenMutation) SetAgentID(u uint64) {
  31024. m.agent = &u
  31025. }
  31026. // AgentID returns the value of the "agent_id" field in the mutation.
  31027. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  31028. v := m.agent
  31029. if v == nil {
  31030. return
  31031. }
  31032. return *v, true
  31033. }
  31034. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  31035. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  31036. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31037. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  31038. if !m.op.Is(OpUpdateOne) {
  31039. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  31040. }
  31041. if m.id == nil || m.oldValue == nil {
  31042. return v, errors.New("OldAgentID requires an ID field in the mutation")
  31043. }
  31044. oldValue, err := m.oldValue(ctx)
  31045. if err != nil {
  31046. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  31047. }
  31048. return oldValue.AgentID, nil
  31049. }
  31050. // ResetAgentID resets all changes to the "agent_id" field.
  31051. func (m *TokenMutation) ResetAgentID() {
  31052. m.agent = nil
  31053. }
  31054. // SetCustomAgentBase sets the "custom_agent_base" field.
  31055. func (m *TokenMutation) SetCustomAgentBase(s string) {
  31056. m.custom_agent_base = &s
  31057. }
  31058. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  31059. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  31060. v := m.custom_agent_base
  31061. if v == nil {
  31062. return
  31063. }
  31064. return *v, true
  31065. }
  31066. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  31067. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  31068. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31069. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  31070. if !m.op.Is(OpUpdateOne) {
  31071. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  31072. }
  31073. if m.id == nil || m.oldValue == nil {
  31074. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  31075. }
  31076. oldValue, err := m.oldValue(ctx)
  31077. if err != nil {
  31078. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  31079. }
  31080. return oldValue.CustomAgentBase, nil
  31081. }
  31082. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  31083. func (m *TokenMutation) ClearCustomAgentBase() {
  31084. m.custom_agent_base = nil
  31085. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  31086. }
  31087. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  31088. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  31089. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  31090. return ok
  31091. }
  31092. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  31093. func (m *TokenMutation) ResetCustomAgentBase() {
  31094. m.custom_agent_base = nil
  31095. delete(m.clearedFields, token.FieldCustomAgentBase)
  31096. }
  31097. // SetCustomAgentKey sets the "custom_agent_key" field.
  31098. func (m *TokenMutation) SetCustomAgentKey(s string) {
  31099. m.custom_agent_key = &s
  31100. }
  31101. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  31102. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  31103. v := m.custom_agent_key
  31104. if v == nil {
  31105. return
  31106. }
  31107. return *v, true
  31108. }
  31109. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  31110. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  31111. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31112. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  31113. if !m.op.Is(OpUpdateOne) {
  31114. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  31115. }
  31116. if m.id == nil || m.oldValue == nil {
  31117. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  31118. }
  31119. oldValue, err := m.oldValue(ctx)
  31120. if err != nil {
  31121. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  31122. }
  31123. return oldValue.CustomAgentKey, nil
  31124. }
  31125. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  31126. func (m *TokenMutation) ClearCustomAgentKey() {
  31127. m.custom_agent_key = nil
  31128. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  31129. }
  31130. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  31131. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  31132. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  31133. return ok
  31134. }
  31135. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  31136. func (m *TokenMutation) ResetCustomAgentKey() {
  31137. m.custom_agent_key = nil
  31138. delete(m.clearedFields, token.FieldCustomAgentKey)
  31139. }
  31140. // SetOpenaiBase sets the "openai_base" field.
  31141. func (m *TokenMutation) SetOpenaiBase(s string) {
  31142. m.openai_base = &s
  31143. }
  31144. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  31145. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  31146. v := m.openai_base
  31147. if v == nil {
  31148. return
  31149. }
  31150. return *v, true
  31151. }
  31152. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  31153. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  31154. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31155. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  31156. if !m.op.Is(OpUpdateOne) {
  31157. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  31158. }
  31159. if m.id == nil || m.oldValue == nil {
  31160. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  31161. }
  31162. oldValue, err := m.oldValue(ctx)
  31163. if err != nil {
  31164. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  31165. }
  31166. return oldValue.OpenaiBase, nil
  31167. }
  31168. // ClearOpenaiBase clears the value of the "openai_base" field.
  31169. func (m *TokenMutation) ClearOpenaiBase() {
  31170. m.openai_base = nil
  31171. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  31172. }
  31173. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  31174. func (m *TokenMutation) OpenaiBaseCleared() bool {
  31175. _, ok := m.clearedFields[token.FieldOpenaiBase]
  31176. return ok
  31177. }
  31178. // ResetOpenaiBase resets all changes to the "openai_base" field.
  31179. func (m *TokenMutation) ResetOpenaiBase() {
  31180. m.openai_base = nil
  31181. delete(m.clearedFields, token.FieldOpenaiBase)
  31182. }
  31183. // SetOpenaiKey sets the "openai_key" field.
  31184. func (m *TokenMutation) SetOpenaiKey(s string) {
  31185. m.openai_key = &s
  31186. }
  31187. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  31188. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  31189. v := m.openai_key
  31190. if v == nil {
  31191. return
  31192. }
  31193. return *v, true
  31194. }
  31195. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  31196. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  31197. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31198. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  31199. if !m.op.Is(OpUpdateOne) {
  31200. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  31201. }
  31202. if m.id == nil || m.oldValue == nil {
  31203. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  31204. }
  31205. oldValue, err := m.oldValue(ctx)
  31206. if err != nil {
  31207. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  31208. }
  31209. return oldValue.OpenaiKey, nil
  31210. }
  31211. // ClearOpenaiKey clears the value of the "openai_key" field.
  31212. func (m *TokenMutation) ClearOpenaiKey() {
  31213. m.openai_key = nil
  31214. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  31215. }
  31216. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  31217. func (m *TokenMutation) OpenaiKeyCleared() bool {
  31218. _, ok := m.clearedFields[token.FieldOpenaiKey]
  31219. return ok
  31220. }
  31221. // ResetOpenaiKey resets all changes to the "openai_key" field.
  31222. func (m *TokenMutation) ResetOpenaiKey() {
  31223. m.openai_key = nil
  31224. delete(m.clearedFields, token.FieldOpenaiKey)
  31225. }
  31226. // ClearAgent clears the "agent" edge to the Agent entity.
  31227. func (m *TokenMutation) ClearAgent() {
  31228. m.clearedagent = true
  31229. m.clearedFields[token.FieldAgentID] = struct{}{}
  31230. }
  31231. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  31232. func (m *TokenMutation) AgentCleared() bool {
  31233. return m.clearedagent
  31234. }
  31235. // AgentIDs returns the "agent" edge IDs in the mutation.
  31236. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  31237. // AgentID instead. It exists only for internal usage by the builders.
  31238. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  31239. if id := m.agent; id != nil {
  31240. ids = append(ids, *id)
  31241. }
  31242. return
  31243. }
  31244. // ResetAgent resets all changes to the "agent" edge.
  31245. func (m *TokenMutation) ResetAgent() {
  31246. m.agent = nil
  31247. m.clearedagent = false
  31248. }
  31249. // Where appends a list predicates to the TokenMutation builder.
  31250. func (m *TokenMutation) Where(ps ...predicate.Token) {
  31251. m.predicates = append(m.predicates, ps...)
  31252. }
  31253. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  31254. // users can use type-assertion to append predicates that do not depend on any generated package.
  31255. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  31256. p := make([]predicate.Token, len(ps))
  31257. for i := range ps {
  31258. p[i] = ps[i]
  31259. }
  31260. m.Where(p...)
  31261. }
  31262. // Op returns the operation name.
  31263. func (m *TokenMutation) Op() Op {
  31264. return m.op
  31265. }
  31266. // SetOp allows setting the mutation operation.
  31267. func (m *TokenMutation) SetOp(op Op) {
  31268. m.op = op
  31269. }
  31270. // Type returns the node type of this mutation (Token).
  31271. func (m *TokenMutation) Type() string {
  31272. return m.typ
  31273. }
  31274. // Fields returns all fields that were changed during this mutation. Note that in
  31275. // order to get all numeric fields that were incremented/decremented, call
  31276. // AddedFields().
  31277. func (m *TokenMutation) Fields() []string {
  31278. fields := make([]string, 0, 12)
  31279. if m.created_at != nil {
  31280. fields = append(fields, token.FieldCreatedAt)
  31281. }
  31282. if m.updated_at != nil {
  31283. fields = append(fields, token.FieldUpdatedAt)
  31284. }
  31285. if m.deleted_at != nil {
  31286. fields = append(fields, token.FieldDeletedAt)
  31287. }
  31288. if m.expire_at != nil {
  31289. fields = append(fields, token.FieldExpireAt)
  31290. }
  31291. if m.token != nil {
  31292. fields = append(fields, token.FieldToken)
  31293. }
  31294. if m.mac != nil {
  31295. fields = append(fields, token.FieldMAC)
  31296. }
  31297. if m.organization_id != nil {
  31298. fields = append(fields, token.FieldOrganizationID)
  31299. }
  31300. if m.agent != nil {
  31301. fields = append(fields, token.FieldAgentID)
  31302. }
  31303. if m.custom_agent_base != nil {
  31304. fields = append(fields, token.FieldCustomAgentBase)
  31305. }
  31306. if m.custom_agent_key != nil {
  31307. fields = append(fields, token.FieldCustomAgentKey)
  31308. }
  31309. if m.openai_base != nil {
  31310. fields = append(fields, token.FieldOpenaiBase)
  31311. }
  31312. if m.openai_key != nil {
  31313. fields = append(fields, token.FieldOpenaiKey)
  31314. }
  31315. return fields
  31316. }
  31317. // Field returns the value of a field with the given name. The second boolean
  31318. // return value indicates that this field was not set, or was not defined in the
  31319. // schema.
  31320. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  31321. switch name {
  31322. case token.FieldCreatedAt:
  31323. return m.CreatedAt()
  31324. case token.FieldUpdatedAt:
  31325. return m.UpdatedAt()
  31326. case token.FieldDeletedAt:
  31327. return m.DeletedAt()
  31328. case token.FieldExpireAt:
  31329. return m.ExpireAt()
  31330. case token.FieldToken:
  31331. return m.Token()
  31332. case token.FieldMAC:
  31333. return m.MAC()
  31334. case token.FieldOrganizationID:
  31335. return m.OrganizationID()
  31336. case token.FieldAgentID:
  31337. return m.AgentID()
  31338. case token.FieldCustomAgentBase:
  31339. return m.CustomAgentBase()
  31340. case token.FieldCustomAgentKey:
  31341. return m.CustomAgentKey()
  31342. case token.FieldOpenaiBase:
  31343. return m.OpenaiBase()
  31344. case token.FieldOpenaiKey:
  31345. return m.OpenaiKey()
  31346. }
  31347. return nil, false
  31348. }
  31349. // OldField returns the old value of the field from the database. An error is
  31350. // returned if the mutation operation is not UpdateOne, or the query to the
  31351. // database failed.
  31352. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  31353. switch name {
  31354. case token.FieldCreatedAt:
  31355. return m.OldCreatedAt(ctx)
  31356. case token.FieldUpdatedAt:
  31357. return m.OldUpdatedAt(ctx)
  31358. case token.FieldDeletedAt:
  31359. return m.OldDeletedAt(ctx)
  31360. case token.FieldExpireAt:
  31361. return m.OldExpireAt(ctx)
  31362. case token.FieldToken:
  31363. return m.OldToken(ctx)
  31364. case token.FieldMAC:
  31365. return m.OldMAC(ctx)
  31366. case token.FieldOrganizationID:
  31367. return m.OldOrganizationID(ctx)
  31368. case token.FieldAgentID:
  31369. return m.OldAgentID(ctx)
  31370. case token.FieldCustomAgentBase:
  31371. return m.OldCustomAgentBase(ctx)
  31372. case token.FieldCustomAgentKey:
  31373. return m.OldCustomAgentKey(ctx)
  31374. case token.FieldOpenaiBase:
  31375. return m.OldOpenaiBase(ctx)
  31376. case token.FieldOpenaiKey:
  31377. return m.OldOpenaiKey(ctx)
  31378. }
  31379. return nil, fmt.Errorf("unknown Token field %s", name)
  31380. }
  31381. // SetField sets the value of a field with the given name. It returns an error if
  31382. // the field is not defined in the schema, or if the type mismatched the field
  31383. // type.
  31384. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  31385. switch name {
  31386. case token.FieldCreatedAt:
  31387. v, ok := value.(time.Time)
  31388. if !ok {
  31389. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31390. }
  31391. m.SetCreatedAt(v)
  31392. return nil
  31393. case token.FieldUpdatedAt:
  31394. v, ok := value.(time.Time)
  31395. if !ok {
  31396. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31397. }
  31398. m.SetUpdatedAt(v)
  31399. return nil
  31400. case token.FieldDeletedAt:
  31401. v, ok := value.(time.Time)
  31402. if !ok {
  31403. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31404. }
  31405. m.SetDeletedAt(v)
  31406. return nil
  31407. case token.FieldExpireAt:
  31408. v, ok := value.(time.Time)
  31409. if !ok {
  31410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31411. }
  31412. m.SetExpireAt(v)
  31413. return nil
  31414. case token.FieldToken:
  31415. v, ok := value.(string)
  31416. if !ok {
  31417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31418. }
  31419. m.SetToken(v)
  31420. return nil
  31421. case token.FieldMAC:
  31422. v, ok := value.(string)
  31423. if !ok {
  31424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31425. }
  31426. m.SetMAC(v)
  31427. return nil
  31428. case token.FieldOrganizationID:
  31429. v, ok := value.(uint64)
  31430. if !ok {
  31431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31432. }
  31433. m.SetOrganizationID(v)
  31434. return nil
  31435. case token.FieldAgentID:
  31436. v, ok := value.(uint64)
  31437. if !ok {
  31438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31439. }
  31440. m.SetAgentID(v)
  31441. return nil
  31442. case token.FieldCustomAgentBase:
  31443. v, ok := value.(string)
  31444. if !ok {
  31445. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31446. }
  31447. m.SetCustomAgentBase(v)
  31448. return nil
  31449. case token.FieldCustomAgentKey:
  31450. v, ok := value.(string)
  31451. if !ok {
  31452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31453. }
  31454. m.SetCustomAgentKey(v)
  31455. return nil
  31456. case token.FieldOpenaiBase:
  31457. v, ok := value.(string)
  31458. if !ok {
  31459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31460. }
  31461. m.SetOpenaiBase(v)
  31462. return nil
  31463. case token.FieldOpenaiKey:
  31464. v, ok := value.(string)
  31465. if !ok {
  31466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31467. }
  31468. m.SetOpenaiKey(v)
  31469. return nil
  31470. }
  31471. return fmt.Errorf("unknown Token field %s", name)
  31472. }
  31473. // AddedFields returns all numeric fields that were incremented/decremented during
  31474. // this mutation.
  31475. func (m *TokenMutation) AddedFields() []string {
  31476. var fields []string
  31477. if m.addorganization_id != nil {
  31478. fields = append(fields, token.FieldOrganizationID)
  31479. }
  31480. return fields
  31481. }
  31482. // AddedField returns the numeric value that was incremented/decremented on a field
  31483. // with the given name. The second boolean return value indicates that this field
  31484. // was not set, or was not defined in the schema.
  31485. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  31486. switch name {
  31487. case token.FieldOrganizationID:
  31488. return m.AddedOrganizationID()
  31489. }
  31490. return nil, false
  31491. }
  31492. // AddField adds the value to the field with the given name. It returns an error if
  31493. // the field is not defined in the schema, or if the type mismatched the field
  31494. // type.
  31495. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  31496. switch name {
  31497. case token.FieldOrganizationID:
  31498. v, ok := value.(int64)
  31499. if !ok {
  31500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31501. }
  31502. m.AddOrganizationID(v)
  31503. return nil
  31504. }
  31505. return fmt.Errorf("unknown Token numeric field %s", name)
  31506. }
  31507. // ClearedFields returns all nullable fields that were cleared during this
  31508. // mutation.
  31509. func (m *TokenMutation) ClearedFields() []string {
  31510. var fields []string
  31511. if m.FieldCleared(token.FieldDeletedAt) {
  31512. fields = append(fields, token.FieldDeletedAt)
  31513. }
  31514. if m.FieldCleared(token.FieldExpireAt) {
  31515. fields = append(fields, token.FieldExpireAt)
  31516. }
  31517. if m.FieldCleared(token.FieldToken) {
  31518. fields = append(fields, token.FieldToken)
  31519. }
  31520. if m.FieldCleared(token.FieldMAC) {
  31521. fields = append(fields, token.FieldMAC)
  31522. }
  31523. if m.FieldCleared(token.FieldCustomAgentBase) {
  31524. fields = append(fields, token.FieldCustomAgentBase)
  31525. }
  31526. if m.FieldCleared(token.FieldCustomAgentKey) {
  31527. fields = append(fields, token.FieldCustomAgentKey)
  31528. }
  31529. if m.FieldCleared(token.FieldOpenaiBase) {
  31530. fields = append(fields, token.FieldOpenaiBase)
  31531. }
  31532. if m.FieldCleared(token.FieldOpenaiKey) {
  31533. fields = append(fields, token.FieldOpenaiKey)
  31534. }
  31535. return fields
  31536. }
  31537. // FieldCleared returns a boolean indicating if a field with the given name was
  31538. // cleared in this mutation.
  31539. func (m *TokenMutation) FieldCleared(name string) bool {
  31540. _, ok := m.clearedFields[name]
  31541. return ok
  31542. }
  31543. // ClearField clears the value of the field with the given name. It returns an
  31544. // error if the field is not defined in the schema.
  31545. func (m *TokenMutation) ClearField(name string) error {
  31546. switch name {
  31547. case token.FieldDeletedAt:
  31548. m.ClearDeletedAt()
  31549. return nil
  31550. case token.FieldExpireAt:
  31551. m.ClearExpireAt()
  31552. return nil
  31553. case token.FieldToken:
  31554. m.ClearToken()
  31555. return nil
  31556. case token.FieldMAC:
  31557. m.ClearMAC()
  31558. return nil
  31559. case token.FieldCustomAgentBase:
  31560. m.ClearCustomAgentBase()
  31561. return nil
  31562. case token.FieldCustomAgentKey:
  31563. m.ClearCustomAgentKey()
  31564. return nil
  31565. case token.FieldOpenaiBase:
  31566. m.ClearOpenaiBase()
  31567. return nil
  31568. case token.FieldOpenaiKey:
  31569. m.ClearOpenaiKey()
  31570. return nil
  31571. }
  31572. return fmt.Errorf("unknown Token nullable field %s", name)
  31573. }
  31574. // ResetField resets all changes in the mutation for the field with the given name.
  31575. // It returns an error if the field is not defined in the schema.
  31576. func (m *TokenMutation) ResetField(name string) error {
  31577. switch name {
  31578. case token.FieldCreatedAt:
  31579. m.ResetCreatedAt()
  31580. return nil
  31581. case token.FieldUpdatedAt:
  31582. m.ResetUpdatedAt()
  31583. return nil
  31584. case token.FieldDeletedAt:
  31585. m.ResetDeletedAt()
  31586. return nil
  31587. case token.FieldExpireAt:
  31588. m.ResetExpireAt()
  31589. return nil
  31590. case token.FieldToken:
  31591. m.ResetToken()
  31592. return nil
  31593. case token.FieldMAC:
  31594. m.ResetMAC()
  31595. return nil
  31596. case token.FieldOrganizationID:
  31597. m.ResetOrganizationID()
  31598. return nil
  31599. case token.FieldAgentID:
  31600. m.ResetAgentID()
  31601. return nil
  31602. case token.FieldCustomAgentBase:
  31603. m.ResetCustomAgentBase()
  31604. return nil
  31605. case token.FieldCustomAgentKey:
  31606. m.ResetCustomAgentKey()
  31607. return nil
  31608. case token.FieldOpenaiBase:
  31609. m.ResetOpenaiBase()
  31610. return nil
  31611. case token.FieldOpenaiKey:
  31612. m.ResetOpenaiKey()
  31613. return nil
  31614. }
  31615. return fmt.Errorf("unknown Token field %s", name)
  31616. }
  31617. // AddedEdges returns all edge names that were set/added in this mutation.
  31618. func (m *TokenMutation) AddedEdges() []string {
  31619. edges := make([]string, 0, 1)
  31620. if m.agent != nil {
  31621. edges = append(edges, token.EdgeAgent)
  31622. }
  31623. return edges
  31624. }
  31625. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31626. // name in this mutation.
  31627. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  31628. switch name {
  31629. case token.EdgeAgent:
  31630. if id := m.agent; id != nil {
  31631. return []ent.Value{*id}
  31632. }
  31633. }
  31634. return nil
  31635. }
  31636. // RemovedEdges returns all edge names that were removed in this mutation.
  31637. func (m *TokenMutation) RemovedEdges() []string {
  31638. edges := make([]string, 0, 1)
  31639. return edges
  31640. }
  31641. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31642. // the given name in this mutation.
  31643. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  31644. return nil
  31645. }
  31646. // ClearedEdges returns all edge names that were cleared in this mutation.
  31647. func (m *TokenMutation) ClearedEdges() []string {
  31648. edges := make([]string, 0, 1)
  31649. if m.clearedagent {
  31650. edges = append(edges, token.EdgeAgent)
  31651. }
  31652. return edges
  31653. }
  31654. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31655. // was cleared in this mutation.
  31656. func (m *TokenMutation) EdgeCleared(name string) bool {
  31657. switch name {
  31658. case token.EdgeAgent:
  31659. return m.clearedagent
  31660. }
  31661. return false
  31662. }
  31663. // ClearEdge clears the value of the edge with the given name. It returns an error
  31664. // if that edge is not defined in the schema.
  31665. func (m *TokenMutation) ClearEdge(name string) error {
  31666. switch name {
  31667. case token.EdgeAgent:
  31668. m.ClearAgent()
  31669. return nil
  31670. }
  31671. return fmt.Errorf("unknown Token unique edge %s", name)
  31672. }
  31673. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31674. // It returns an error if the edge is not defined in the schema.
  31675. func (m *TokenMutation) ResetEdge(name string) error {
  31676. switch name {
  31677. case token.EdgeAgent:
  31678. m.ResetAgent()
  31679. return nil
  31680. }
  31681. return fmt.Errorf("unknown Token edge %s", name)
  31682. }
  31683. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  31684. type TutorialMutation struct {
  31685. config
  31686. op Op
  31687. typ string
  31688. id *uint64
  31689. created_at *time.Time
  31690. updated_at *time.Time
  31691. deleted_at *time.Time
  31692. index *int
  31693. addindex *int
  31694. title *string
  31695. content *string
  31696. organization_id *uint64
  31697. addorganization_id *int64
  31698. clearedFields map[string]struct{}
  31699. employee *uint64
  31700. clearedemployee bool
  31701. done bool
  31702. oldValue func(context.Context) (*Tutorial, error)
  31703. predicates []predicate.Tutorial
  31704. }
  31705. var _ ent.Mutation = (*TutorialMutation)(nil)
  31706. // tutorialOption allows management of the mutation configuration using functional options.
  31707. type tutorialOption func(*TutorialMutation)
  31708. // newTutorialMutation creates new mutation for the Tutorial entity.
  31709. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  31710. m := &TutorialMutation{
  31711. config: c,
  31712. op: op,
  31713. typ: TypeTutorial,
  31714. clearedFields: make(map[string]struct{}),
  31715. }
  31716. for _, opt := range opts {
  31717. opt(m)
  31718. }
  31719. return m
  31720. }
  31721. // withTutorialID sets the ID field of the mutation.
  31722. func withTutorialID(id uint64) tutorialOption {
  31723. return func(m *TutorialMutation) {
  31724. var (
  31725. err error
  31726. once sync.Once
  31727. value *Tutorial
  31728. )
  31729. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  31730. once.Do(func() {
  31731. if m.done {
  31732. err = errors.New("querying old values post mutation is not allowed")
  31733. } else {
  31734. value, err = m.Client().Tutorial.Get(ctx, id)
  31735. }
  31736. })
  31737. return value, err
  31738. }
  31739. m.id = &id
  31740. }
  31741. }
  31742. // withTutorial sets the old Tutorial of the mutation.
  31743. func withTutorial(node *Tutorial) tutorialOption {
  31744. return func(m *TutorialMutation) {
  31745. m.oldValue = func(context.Context) (*Tutorial, error) {
  31746. return node, nil
  31747. }
  31748. m.id = &node.ID
  31749. }
  31750. }
  31751. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31752. // executed in a transaction (ent.Tx), a transactional client is returned.
  31753. func (m TutorialMutation) Client() *Client {
  31754. client := &Client{config: m.config}
  31755. client.init()
  31756. return client
  31757. }
  31758. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31759. // it returns an error otherwise.
  31760. func (m TutorialMutation) Tx() (*Tx, error) {
  31761. if _, ok := m.driver.(*txDriver); !ok {
  31762. return nil, errors.New("ent: mutation is not running in a transaction")
  31763. }
  31764. tx := &Tx{config: m.config}
  31765. tx.init()
  31766. return tx, nil
  31767. }
  31768. // SetID sets the value of the id field. Note that this
  31769. // operation is only accepted on creation of Tutorial entities.
  31770. func (m *TutorialMutation) SetID(id uint64) {
  31771. m.id = &id
  31772. }
  31773. // ID returns the ID value in the mutation. Note that the ID is only available
  31774. // if it was provided to the builder or after it was returned from the database.
  31775. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  31776. if m.id == nil {
  31777. return
  31778. }
  31779. return *m.id, true
  31780. }
  31781. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31782. // That means, if the mutation is applied within a transaction with an isolation level such
  31783. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  31784. // or updated by the mutation.
  31785. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  31786. switch {
  31787. case m.op.Is(OpUpdateOne | OpDeleteOne):
  31788. id, exists := m.ID()
  31789. if exists {
  31790. return []uint64{id}, nil
  31791. }
  31792. fallthrough
  31793. case m.op.Is(OpUpdate | OpDelete):
  31794. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  31795. default:
  31796. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  31797. }
  31798. }
  31799. // SetCreatedAt sets the "created_at" field.
  31800. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  31801. m.created_at = &t
  31802. }
  31803. // CreatedAt returns the value of the "created_at" field in the mutation.
  31804. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  31805. v := m.created_at
  31806. if v == nil {
  31807. return
  31808. }
  31809. return *v, true
  31810. }
  31811. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  31812. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  31813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31814. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31815. if !m.op.Is(OpUpdateOne) {
  31816. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31817. }
  31818. if m.id == nil || m.oldValue == nil {
  31819. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31820. }
  31821. oldValue, err := m.oldValue(ctx)
  31822. if err != nil {
  31823. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31824. }
  31825. return oldValue.CreatedAt, nil
  31826. }
  31827. // ResetCreatedAt resets all changes to the "created_at" field.
  31828. func (m *TutorialMutation) ResetCreatedAt() {
  31829. m.created_at = nil
  31830. }
  31831. // SetUpdatedAt sets the "updated_at" field.
  31832. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  31833. m.updated_at = &t
  31834. }
  31835. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31836. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  31837. v := m.updated_at
  31838. if v == nil {
  31839. return
  31840. }
  31841. return *v, true
  31842. }
  31843. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  31844. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  31845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31846. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31847. if !m.op.Is(OpUpdateOne) {
  31848. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31849. }
  31850. if m.id == nil || m.oldValue == nil {
  31851. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31852. }
  31853. oldValue, err := m.oldValue(ctx)
  31854. if err != nil {
  31855. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31856. }
  31857. return oldValue.UpdatedAt, nil
  31858. }
  31859. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31860. func (m *TutorialMutation) ResetUpdatedAt() {
  31861. m.updated_at = nil
  31862. }
  31863. // SetDeletedAt sets the "deleted_at" field.
  31864. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  31865. m.deleted_at = &t
  31866. }
  31867. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  31868. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  31869. v := m.deleted_at
  31870. if v == nil {
  31871. return
  31872. }
  31873. return *v, true
  31874. }
  31875. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  31876. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  31877. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31878. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  31879. if !m.op.Is(OpUpdateOne) {
  31880. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  31881. }
  31882. if m.id == nil || m.oldValue == nil {
  31883. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  31884. }
  31885. oldValue, err := m.oldValue(ctx)
  31886. if err != nil {
  31887. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  31888. }
  31889. return oldValue.DeletedAt, nil
  31890. }
  31891. // ClearDeletedAt clears the value of the "deleted_at" field.
  31892. func (m *TutorialMutation) ClearDeletedAt() {
  31893. m.deleted_at = nil
  31894. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  31895. }
  31896. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  31897. func (m *TutorialMutation) DeletedAtCleared() bool {
  31898. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  31899. return ok
  31900. }
  31901. // ResetDeletedAt resets all changes to the "deleted_at" field.
  31902. func (m *TutorialMutation) ResetDeletedAt() {
  31903. m.deleted_at = nil
  31904. delete(m.clearedFields, tutorial.FieldDeletedAt)
  31905. }
  31906. // SetEmployeeID sets the "employee_id" field.
  31907. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  31908. m.employee = &u
  31909. }
  31910. // EmployeeID returns the value of the "employee_id" field in the mutation.
  31911. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  31912. v := m.employee
  31913. if v == nil {
  31914. return
  31915. }
  31916. return *v, true
  31917. }
  31918. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  31919. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  31920. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31921. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  31922. if !m.op.Is(OpUpdateOne) {
  31923. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  31924. }
  31925. if m.id == nil || m.oldValue == nil {
  31926. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  31927. }
  31928. oldValue, err := m.oldValue(ctx)
  31929. if err != nil {
  31930. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  31931. }
  31932. return oldValue.EmployeeID, nil
  31933. }
  31934. // ResetEmployeeID resets all changes to the "employee_id" field.
  31935. func (m *TutorialMutation) ResetEmployeeID() {
  31936. m.employee = nil
  31937. }
  31938. // SetIndex sets the "index" field.
  31939. func (m *TutorialMutation) SetIndex(i int) {
  31940. m.index = &i
  31941. m.addindex = nil
  31942. }
  31943. // Index returns the value of the "index" field in the mutation.
  31944. func (m *TutorialMutation) Index() (r int, exists bool) {
  31945. v := m.index
  31946. if v == nil {
  31947. return
  31948. }
  31949. return *v, true
  31950. }
  31951. // OldIndex returns the old "index" field's value of the Tutorial entity.
  31952. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  31953. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31954. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  31955. if !m.op.Is(OpUpdateOne) {
  31956. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  31957. }
  31958. if m.id == nil || m.oldValue == nil {
  31959. return v, errors.New("OldIndex requires an ID field in the mutation")
  31960. }
  31961. oldValue, err := m.oldValue(ctx)
  31962. if err != nil {
  31963. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  31964. }
  31965. return oldValue.Index, nil
  31966. }
  31967. // AddIndex adds i to the "index" field.
  31968. func (m *TutorialMutation) AddIndex(i int) {
  31969. if m.addindex != nil {
  31970. *m.addindex += i
  31971. } else {
  31972. m.addindex = &i
  31973. }
  31974. }
  31975. // AddedIndex returns the value that was added to the "index" field in this mutation.
  31976. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  31977. v := m.addindex
  31978. if v == nil {
  31979. return
  31980. }
  31981. return *v, true
  31982. }
  31983. // ResetIndex resets all changes to the "index" field.
  31984. func (m *TutorialMutation) ResetIndex() {
  31985. m.index = nil
  31986. m.addindex = nil
  31987. }
  31988. // SetTitle sets the "title" field.
  31989. func (m *TutorialMutation) SetTitle(s string) {
  31990. m.title = &s
  31991. }
  31992. // Title returns the value of the "title" field in the mutation.
  31993. func (m *TutorialMutation) Title() (r string, exists bool) {
  31994. v := m.title
  31995. if v == nil {
  31996. return
  31997. }
  31998. return *v, true
  31999. }
  32000. // OldTitle returns the old "title" field's value of the Tutorial entity.
  32001. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  32002. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32003. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  32004. if !m.op.Is(OpUpdateOne) {
  32005. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  32006. }
  32007. if m.id == nil || m.oldValue == nil {
  32008. return v, errors.New("OldTitle requires an ID field in the mutation")
  32009. }
  32010. oldValue, err := m.oldValue(ctx)
  32011. if err != nil {
  32012. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  32013. }
  32014. return oldValue.Title, nil
  32015. }
  32016. // ResetTitle resets all changes to the "title" field.
  32017. func (m *TutorialMutation) ResetTitle() {
  32018. m.title = nil
  32019. }
  32020. // SetContent sets the "content" field.
  32021. func (m *TutorialMutation) SetContent(s string) {
  32022. m.content = &s
  32023. }
  32024. // Content returns the value of the "content" field in the mutation.
  32025. func (m *TutorialMutation) Content() (r string, exists bool) {
  32026. v := m.content
  32027. if v == nil {
  32028. return
  32029. }
  32030. return *v, true
  32031. }
  32032. // OldContent returns the old "content" field's value of the Tutorial entity.
  32033. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  32034. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32035. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  32036. if !m.op.Is(OpUpdateOne) {
  32037. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  32038. }
  32039. if m.id == nil || m.oldValue == nil {
  32040. return v, errors.New("OldContent requires an ID field in the mutation")
  32041. }
  32042. oldValue, err := m.oldValue(ctx)
  32043. if err != nil {
  32044. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  32045. }
  32046. return oldValue.Content, nil
  32047. }
  32048. // ResetContent resets all changes to the "content" field.
  32049. func (m *TutorialMutation) ResetContent() {
  32050. m.content = nil
  32051. }
  32052. // SetOrganizationID sets the "organization_id" field.
  32053. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  32054. m.organization_id = &u
  32055. m.addorganization_id = nil
  32056. }
  32057. // OrganizationID returns the value of the "organization_id" field in the mutation.
  32058. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  32059. v := m.organization_id
  32060. if v == nil {
  32061. return
  32062. }
  32063. return *v, true
  32064. }
  32065. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  32066. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  32067. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32068. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  32069. if !m.op.Is(OpUpdateOne) {
  32070. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  32071. }
  32072. if m.id == nil || m.oldValue == nil {
  32073. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  32074. }
  32075. oldValue, err := m.oldValue(ctx)
  32076. if err != nil {
  32077. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  32078. }
  32079. return oldValue.OrganizationID, nil
  32080. }
  32081. // AddOrganizationID adds u to the "organization_id" field.
  32082. func (m *TutorialMutation) AddOrganizationID(u int64) {
  32083. if m.addorganization_id != nil {
  32084. *m.addorganization_id += u
  32085. } else {
  32086. m.addorganization_id = &u
  32087. }
  32088. }
  32089. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  32090. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  32091. v := m.addorganization_id
  32092. if v == nil {
  32093. return
  32094. }
  32095. return *v, true
  32096. }
  32097. // ResetOrganizationID resets all changes to the "organization_id" field.
  32098. func (m *TutorialMutation) ResetOrganizationID() {
  32099. m.organization_id = nil
  32100. m.addorganization_id = nil
  32101. }
  32102. // ClearEmployee clears the "employee" edge to the Employee entity.
  32103. func (m *TutorialMutation) ClearEmployee() {
  32104. m.clearedemployee = true
  32105. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  32106. }
  32107. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  32108. func (m *TutorialMutation) EmployeeCleared() bool {
  32109. return m.clearedemployee
  32110. }
  32111. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  32112. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  32113. // EmployeeID instead. It exists only for internal usage by the builders.
  32114. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  32115. if id := m.employee; id != nil {
  32116. ids = append(ids, *id)
  32117. }
  32118. return
  32119. }
  32120. // ResetEmployee resets all changes to the "employee" edge.
  32121. func (m *TutorialMutation) ResetEmployee() {
  32122. m.employee = nil
  32123. m.clearedemployee = false
  32124. }
  32125. // Where appends a list predicates to the TutorialMutation builder.
  32126. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  32127. m.predicates = append(m.predicates, ps...)
  32128. }
  32129. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  32130. // users can use type-assertion to append predicates that do not depend on any generated package.
  32131. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  32132. p := make([]predicate.Tutorial, len(ps))
  32133. for i := range ps {
  32134. p[i] = ps[i]
  32135. }
  32136. m.Where(p...)
  32137. }
  32138. // Op returns the operation name.
  32139. func (m *TutorialMutation) Op() Op {
  32140. return m.op
  32141. }
  32142. // SetOp allows setting the mutation operation.
  32143. func (m *TutorialMutation) SetOp(op Op) {
  32144. m.op = op
  32145. }
  32146. // Type returns the node type of this mutation (Tutorial).
  32147. func (m *TutorialMutation) Type() string {
  32148. return m.typ
  32149. }
  32150. // Fields returns all fields that were changed during this mutation. Note that in
  32151. // order to get all numeric fields that were incremented/decremented, call
  32152. // AddedFields().
  32153. func (m *TutorialMutation) Fields() []string {
  32154. fields := make([]string, 0, 8)
  32155. if m.created_at != nil {
  32156. fields = append(fields, tutorial.FieldCreatedAt)
  32157. }
  32158. if m.updated_at != nil {
  32159. fields = append(fields, tutorial.FieldUpdatedAt)
  32160. }
  32161. if m.deleted_at != nil {
  32162. fields = append(fields, tutorial.FieldDeletedAt)
  32163. }
  32164. if m.employee != nil {
  32165. fields = append(fields, tutorial.FieldEmployeeID)
  32166. }
  32167. if m.index != nil {
  32168. fields = append(fields, tutorial.FieldIndex)
  32169. }
  32170. if m.title != nil {
  32171. fields = append(fields, tutorial.FieldTitle)
  32172. }
  32173. if m.content != nil {
  32174. fields = append(fields, tutorial.FieldContent)
  32175. }
  32176. if m.organization_id != nil {
  32177. fields = append(fields, tutorial.FieldOrganizationID)
  32178. }
  32179. return fields
  32180. }
  32181. // Field returns the value of a field with the given name. The second boolean
  32182. // return value indicates that this field was not set, or was not defined in the
  32183. // schema.
  32184. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  32185. switch name {
  32186. case tutorial.FieldCreatedAt:
  32187. return m.CreatedAt()
  32188. case tutorial.FieldUpdatedAt:
  32189. return m.UpdatedAt()
  32190. case tutorial.FieldDeletedAt:
  32191. return m.DeletedAt()
  32192. case tutorial.FieldEmployeeID:
  32193. return m.EmployeeID()
  32194. case tutorial.FieldIndex:
  32195. return m.Index()
  32196. case tutorial.FieldTitle:
  32197. return m.Title()
  32198. case tutorial.FieldContent:
  32199. return m.Content()
  32200. case tutorial.FieldOrganizationID:
  32201. return m.OrganizationID()
  32202. }
  32203. return nil, false
  32204. }
  32205. // OldField returns the old value of the field from the database. An error is
  32206. // returned if the mutation operation is not UpdateOne, or the query to the
  32207. // database failed.
  32208. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  32209. switch name {
  32210. case tutorial.FieldCreatedAt:
  32211. return m.OldCreatedAt(ctx)
  32212. case tutorial.FieldUpdatedAt:
  32213. return m.OldUpdatedAt(ctx)
  32214. case tutorial.FieldDeletedAt:
  32215. return m.OldDeletedAt(ctx)
  32216. case tutorial.FieldEmployeeID:
  32217. return m.OldEmployeeID(ctx)
  32218. case tutorial.FieldIndex:
  32219. return m.OldIndex(ctx)
  32220. case tutorial.FieldTitle:
  32221. return m.OldTitle(ctx)
  32222. case tutorial.FieldContent:
  32223. return m.OldContent(ctx)
  32224. case tutorial.FieldOrganizationID:
  32225. return m.OldOrganizationID(ctx)
  32226. }
  32227. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  32228. }
  32229. // SetField sets the value of a field with the given name. It returns an error if
  32230. // the field is not defined in the schema, or if the type mismatched the field
  32231. // type.
  32232. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  32233. switch name {
  32234. case tutorial.FieldCreatedAt:
  32235. v, ok := value.(time.Time)
  32236. if !ok {
  32237. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32238. }
  32239. m.SetCreatedAt(v)
  32240. return nil
  32241. case tutorial.FieldUpdatedAt:
  32242. v, ok := value.(time.Time)
  32243. if !ok {
  32244. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32245. }
  32246. m.SetUpdatedAt(v)
  32247. return nil
  32248. case tutorial.FieldDeletedAt:
  32249. v, ok := value.(time.Time)
  32250. if !ok {
  32251. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32252. }
  32253. m.SetDeletedAt(v)
  32254. return nil
  32255. case tutorial.FieldEmployeeID:
  32256. v, ok := value.(uint64)
  32257. if !ok {
  32258. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32259. }
  32260. m.SetEmployeeID(v)
  32261. return nil
  32262. case tutorial.FieldIndex:
  32263. v, ok := value.(int)
  32264. if !ok {
  32265. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32266. }
  32267. m.SetIndex(v)
  32268. return nil
  32269. case tutorial.FieldTitle:
  32270. v, ok := value.(string)
  32271. if !ok {
  32272. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32273. }
  32274. m.SetTitle(v)
  32275. return nil
  32276. case tutorial.FieldContent:
  32277. v, ok := value.(string)
  32278. if !ok {
  32279. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32280. }
  32281. m.SetContent(v)
  32282. return nil
  32283. case tutorial.FieldOrganizationID:
  32284. v, ok := value.(uint64)
  32285. if !ok {
  32286. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32287. }
  32288. m.SetOrganizationID(v)
  32289. return nil
  32290. }
  32291. return fmt.Errorf("unknown Tutorial field %s", name)
  32292. }
  32293. // AddedFields returns all numeric fields that were incremented/decremented during
  32294. // this mutation.
  32295. func (m *TutorialMutation) AddedFields() []string {
  32296. var fields []string
  32297. if m.addindex != nil {
  32298. fields = append(fields, tutorial.FieldIndex)
  32299. }
  32300. if m.addorganization_id != nil {
  32301. fields = append(fields, tutorial.FieldOrganizationID)
  32302. }
  32303. return fields
  32304. }
  32305. // AddedField returns the numeric value that was incremented/decremented on a field
  32306. // with the given name. The second boolean return value indicates that this field
  32307. // was not set, or was not defined in the schema.
  32308. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  32309. switch name {
  32310. case tutorial.FieldIndex:
  32311. return m.AddedIndex()
  32312. case tutorial.FieldOrganizationID:
  32313. return m.AddedOrganizationID()
  32314. }
  32315. return nil, false
  32316. }
  32317. // AddField adds the value to the field with the given name. It returns an error if
  32318. // the field is not defined in the schema, or if the type mismatched the field
  32319. // type.
  32320. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  32321. switch name {
  32322. case tutorial.FieldIndex:
  32323. v, ok := value.(int)
  32324. if !ok {
  32325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32326. }
  32327. m.AddIndex(v)
  32328. return nil
  32329. case tutorial.FieldOrganizationID:
  32330. v, ok := value.(int64)
  32331. if !ok {
  32332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32333. }
  32334. m.AddOrganizationID(v)
  32335. return nil
  32336. }
  32337. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  32338. }
  32339. // ClearedFields returns all nullable fields that were cleared during this
  32340. // mutation.
  32341. func (m *TutorialMutation) ClearedFields() []string {
  32342. var fields []string
  32343. if m.FieldCleared(tutorial.FieldDeletedAt) {
  32344. fields = append(fields, tutorial.FieldDeletedAt)
  32345. }
  32346. return fields
  32347. }
  32348. // FieldCleared returns a boolean indicating if a field with the given name was
  32349. // cleared in this mutation.
  32350. func (m *TutorialMutation) FieldCleared(name string) bool {
  32351. _, ok := m.clearedFields[name]
  32352. return ok
  32353. }
  32354. // ClearField clears the value of the field with the given name. It returns an
  32355. // error if the field is not defined in the schema.
  32356. func (m *TutorialMutation) ClearField(name string) error {
  32357. switch name {
  32358. case tutorial.FieldDeletedAt:
  32359. m.ClearDeletedAt()
  32360. return nil
  32361. }
  32362. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  32363. }
  32364. // ResetField resets all changes in the mutation for the field with the given name.
  32365. // It returns an error if the field is not defined in the schema.
  32366. func (m *TutorialMutation) ResetField(name string) error {
  32367. switch name {
  32368. case tutorial.FieldCreatedAt:
  32369. m.ResetCreatedAt()
  32370. return nil
  32371. case tutorial.FieldUpdatedAt:
  32372. m.ResetUpdatedAt()
  32373. return nil
  32374. case tutorial.FieldDeletedAt:
  32375. m.ResetDeletedAt()
  32376. return nil
  32377. case tutorial.FieldEmployeeID:
  32378. m.ResetEmployeeID()
  32379. return nil
  32380. case tutorial.FieldIndex:
  32381. m.ResetIndex()
  32382. return nil
  32383. case tutorial.FieldTitle:
  32384. m.ResetTitle()
  32385. return nil
  32386. case tutorial.FieldContent:
  32387. m.ResetContent()
  32388. return nil
  32389. case tutorial.FieldOrganizationID:
  32390. m.ResetOrganizationID()
  32391. return nil
  32392. }
  32393. return fmt.Errorf("unknown Tutorial field %s", name)
  32394. }
  32395. // AddedEdges returns all edge names that were set/added in this mutation.
  32396. func (m *TutorialMutation) AddedEdges() []string {
  32397. edges := make([]string, 0, 1)
  32398. if m.employee != nil {
  32399. edges = append(edges, tutorial.EdgeEmployee)
  32400. }
  32401. return edges
  32402. }
  32403. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32404. // name in this mutation.
  32405. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  32406. switch name {
  32407. case tutorial.EdgeEmployee:
  32408. if id := m.employee; id != nil {
  32409. return []ent.Value{*id}
  32410. }
  32411. }
  32412. return nil
  32413. }
  32414. // RemovedEdges returns all edge names that were removed in this mutation.
  32415. func (m *TutorialMutation) RemovedEdges() []string {
  32416. edges := make([]string, 0, 1)
  32417. return edges
  32418. }
  32419. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32420. // the given name in this mutation.
  32421. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  32422. return nil
  32423. }
  32424. // ClearedEdges returns all edge names that were cleared in this mutation.
  32425. func (m *TutorialMutation) ClearedEdges() []string {
  32426. edges := make([]string, 0, 1)
  32427. if m.clearedemployee {
  32428. edges = append(edges, tutorial.EdgeEmployee)
  32429. }
  32430. return edges
  32431. }
  32432. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32433. // was cleared in this mutation.
  32434. func (m *TutorialMutation) EdgeCleared(name string) bool {
  32435. switch name {
  32436. case tutorial.EdgeEmployee:
  32437. return m.clearedemployee
  32438. }
  32439. return false
  32440. }
  32441. // ClearEdge clears the value of the edge with the given name. It returns an error
  32442. // if that edge is not defined in the schema.
  32443. func (m *TutorialMutation) ClearEdge(name string) error {
  32444. switch name {
  32445. case tutorial.EdgeEmployee:
  32446. m.ClearEmployee()
  32447. return nil
  32448. }
  32449. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  32450. }
  32451. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32452. // It returns an error if the edge is not defined in the schema.
  32453. func (m *TutorialMutation) ResetEdge(name string) error {
  32454. switch name {
  32455. case tutorial.EdgeEmployee:
  32456. m.ResetEmployee()
  32457. return nil
  32458. }
  32459. return fmt.Errorf("unknown Tutorial edge %s", name)
  32460. }
  32461. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  32462. type UsageDetailMutation struct {
  32463. config
  32464. op Op
  32465. typ string
  32466. id *uint64
  32467. created_at *time.Time
  32468. updated_at *time.Time
  32469. status *uint8
  32470. addstatus *int8
  32471. _type *int
  32472. add_type *int
  32473. bot_id *string
  32474. receiver_id *string
  32475. app *int
  32476. addapp *int
  32477. session_id *uint64
  32478. addsession_id *int64
  32479. request *string
  32480. response *string
  32481. original_data *custom_types.OriginalData
  32482. total_tokens *uint64
  32483. addtotal_tokens *int64
  32484. prompt_tokens *uint64
  32485. addprompt_tokens *int64
  32486. completion_tokens *uint64
  32487. addcompletion_tokens *int64
  32488. organization_id *uint64
  32489. addorganization_id *int64
  32490. model *string
  32491. clearedFields map[string]struct{}
  32492. done bool
  32493. oldValue func(context.Context) (*UsageDetail, error)
  32494. predicates []predicate.UsageDetail
  32495. }
  32496. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  32497. // usagedetailOption allows management of the mutation configuration using functional options.
  32498. type usagedetailOption func(*UsageDetailMutation)
  32499. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  32500. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  32501. m := &UsageDetailMutation{
  32502. config: c,
  32503. op: op,
  32504. typ: TypeUsageDetail,
  32505. clearedFields: make(map[string]struct{}),
  32506. }
  32507. for _, opt := range opts {
  32508. opt(m)
  32509. }
  32510. return m
  32511. }
  32512. // withUsageDetailID sets the ID field of the mutation.
  32513. func withUsageDetailID(id uint64) usagedetailOption {
  32514. return func(m *UsageDetailMutation) {
  32515. var (
  32516. err error
  32517. once sync.Once
  32518. value *UsageDetail
  32519. )
  32520. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  32521. once.Do(func() {
  32522. if m.done {
  32523. err = errors.New("querying old values post mutation is not allowed")
  32524. } else {
  32525. value, err = m.Client().UsageDetail.Get(ctx, id)
  32526. }
  32527. })
  32528. return value, err
  32529. }
  32530. m.id = &id
  32531. }
  32532. }
  32533. // withUsageDetail sets the old UsageDetail of the mutation.
  32534. func withUsageDetail(node *UsageDetail) usagedetailOption {
  32535. return func(m *UsageDetailMutation) {
  32536. m.oldValue = func(context.Context) (*UsageDetail, error) {
  32537. return node, nil
  32538. }
  32539. m.id = &node.ID
  32540. }
  32541. }
  32542. // Client returns a new `ent.Client` from the mutation. If the mutation was
  32543. // executed in a transaction (ent.Tx), a transactional client is returned.
  32544. func (m UsageDetailMutation) Client() *Client {
  32545. client := &Client{config: m.config}
  32546. client.init()
  32547. return client
  32548. }
  32549. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  32550. // it returns an error otherwise.
  32551. func (m UsageDetailMutation) Tx() (*Tx, error) {
  32552. if _, ok := m.driver.(*txDriver); !ok {
  32553. return nil, errors.New("ent: mutation is not running in a transaction")
  32554. }
  32555. tx := &Tx{config: m.config}
  32556. tx.init()
  32557. return tx, nil
  32558. }
  32559. // SetID sets the value of the id field. Note that this
  32560. // operation is only accepted on creation of UsageDetail entities.
  32561. func (m *UsageDetailMutation) SetID(id uint64) {
  32562. m.id = &id
  32563. }
  32564. // ID returns the ID value in the mutation. Note that the ID is only available
  32565. // if it was provided to the builder or after it was returned from the database.
  32566. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  32567. if m.id == nil {
  32568. return
  32569. }
  32570. return *m.id, true
  32571. }
  32572. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32573. // That means, if the mutation is applied within a transaction with an isolation level such
  32574. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32575. // or updated by the mutation.
  32576. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  32577. switch {
  32578. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32579. id, exists := m.ID()
  32580. if exists {
  32581. return []uint64{id}, nil
  32582. }
  32583. fallthrough
  32584. case m.op.Is(OpUpdate | OpDelete):
  32585. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  32586. default:
  32587. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32588. }
  32589. }
  32590. // SetCreatedAt sets the "created_at" field.
  32591. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  32592. m.created_at = &t
  32593. }
  32594. // CreatedAt returns the value of the "created_at" field in the mutation.
  32595. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  32596. v := m.created_at
  32597. if v == nil {
  32598. return
  32599. }
  32600. return *v, true
  32601. }
  32602. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  32603. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  32604. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32605. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32606. if !m.op.Is(OpUpdateOne) {
  32607. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32608. }
  32609. if m.id == nil || m.oldValue == nil {
  32610. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32611. }
  32612. oldValue, err := m.oldValue(ctx)
  32613. if err != nil {
  32614. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32615. }
  32616. return oldValue.CreatedAt, nil
  32617. }
  32618. // ResetCreatedAt resets all changes to the "created_at" field.
  32619. func (m *UsageDetailMutation) ResetCreatedAt() {
  32620. m.created_at = nil
  32621. }
  32622. // SetUpdatedAt sets the "updated_at" field.
  32623. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  32624. m.updated_at = &t
  32625. }
  32626. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32627. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  32628. v := m.updated_at
  32629. if v == nil {
  32630. return
  32631. }
  32632. return *v, true
  32633. }
  32634. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  32635. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  32636. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32637. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32638. if !m.op.Is(OpUpdateOne) {
  32639. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32640. }
  32641. if m.id == nil || m.oldValue == nil {
  32642. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32643. }
  32644. oldValue, err := m.oldValue(ctx)
  32645. if err != nil {
  32646. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32647. }
  32648. return oldValue.UpdatedAt, nil
  32649. }
  32650. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32651. func (m *UsageDetailMutation) ResetUpdatedAt() {
  32652. m.updated_at = nil
  32653. }
  32654. // SetStatus sets the "status" field.
  32655. func (m *UsageDetailMutation) SetStatus(u uint8) {
  32656. m.status = &u
  32657. m.addstatus = nil
  32658. }
  32659. // Status returns the value of the "status" field in the mutation.
  32660. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  32661. v := m.status
  32662. if v == nil {
  32663. return
  32664. }
  32665. return *v, true
  32666. }
  32667. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  32668. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  32669. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32670. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  32671. if !m.op.Is(OpUpdateOne) {
  32672. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  32673. }
  32674. if m.id == nil || m.oldValue == nil {
  32675. return v, errors.New("OldStatus requires an ID field in the mutation")
  32676. }
  32677. oldValue, err := m.oldValue(ctx)
  32678. if err != nil {
  32679. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  32680. }
  32681. return oldValue.Status, nil
  32682. }
  32683. // AddStatus adds u to the "status" field.
  32684. func (m *UsageDetailMutation) AddStatus(u int8) {
  32685. if m.addstatus != nil {
  32686. *m.addstatus += u
  32687. } else {
  32688. m.addstatus = &u
  32689. }
  32690. }
  32691. // AddedStatus returns the value that was added to the "status" field in this mutation.
  32692. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  32693. v := m.addstatus
  32694. if v == nil {
  32695. return
  32696. }
  32697. return *v, true
  32698. }
  32699. // ClearStatus clears the value of the "status" field.
  32700. func (m *UsageDetailMutation) ClearStatus() {
  32701. m.status = nil
  32702. m.addstatus = nil
  32703. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  32704. }
  32705. // StatusCleared returns if the "status" field was cleared in this mutation.
  32706. func (m *UsageDetailMutation) StatusCleared() bool {
  32707. _, ok := m.clearedFields[usagedetail.FieldStatus]
  32708. return ok
  32709. }
  32710. // ResetStatus resets all changes to the "status" field.
  32711. func (m *UsageDetailMutation) ResetStatus() {
  32712. m.status = nil
  32713. m.addstatus = nil
  32714. delete(m.clearedFields, usagedetail.FieldStatus)
  32715. }
  32716. // SetType sets the "type" field.
  32717. func (m *UsageDetailMutation) SetType(i int) {
  32718. m._type = &i
  32719. m.add_type = nil
  32720. }
  32721. // GetType returns the value of the "type" field in the mutation.
  32722. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  32723. v := m._type
  32724. if v == nil {
  32725. return
  32726. }
  32727. return *v, true
  32728. }
  32729. // OldType returns the old "type" field's value of the UsageDetail entity.
  32730. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  32731. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32732. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  32733. if !m.op.Is(OpUpdateOne) {
  32734. return v, errors.New("OldType is only allowed on UpdateOne operations")
  32735. }
  32736. if m.id == nil || m.oldValue == nil {
  32737. return v, errors.New("OldType requires an ID field in the mutation")
  32738. }
  32739. oldValue, err := m.oldValue(ctx)
  32740. if err != nil {
  32741. return v, fmt.Errorf("querying old value for OldType: %w", err)
  32742. }
  32743. return oldValue.Type, nil
  32744. }
  32745. // AddType adds i to the "type" field.
  32746. func (m *UsageDetailMutation) AddType(i int) {
  32747. if m.add_type != nil {
  32748. *m.add_type += i
  32749. } else {
  32750. m.add_type = &i
  32751. }
  32752. }
  32753. // AddedType returns the value that was added to the "type" field in this mutation.
  32754. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  32755. v := m.add_type
  32756. if v == nil {
  32757. return
  32758. }
  32759. return *v, true
  32760. }
  32761. // ClearType clears the value of the "type" field.
  32762. func (m *UsageDetailMutation) ClearType() {
  32763. m._type = nil
  32764. m.add_type = nil
  32765. m.clearedFields[usagedetail.FieldType] = struct{}{}
  32766. }
  32767. // TypeCleared returns if the "type" field was cleared in this mutation.
  32768. func (m *UsageDetailMutation) TypeCleared() bool {
  32769. _, ok := m.clearedFields[usagedetail.FieldType]
  32770. return ok
  32771. }
  32772. // ResetType resets all changes to the "type" field.
  32773. func (m *UsageDetailMutation) ResetType() {
  32774. m._type = nil
  32775. m.add_type = nil
  32776. delete(m.clearedFields, usagedetail.FieldType)
  32777. }
  32778. // SetBotID sets the "bot_id" field.
  32779. func (m *UsageDetailMutation) SetBotID(s string) {
  32780. m.bot_id = &s
  32781. }
  32782. // BotID returns the value of the "bot_id" field in the mutation.
  32783. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  32784. v := m.bot_id
  32785. if v == nil {
  32786. return
  32787. }
  32788. return *v, true
  32789. }
  32790. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  32791. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  32792. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32793. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  32794. if !m.op.Is(OpUpdateOne) {
  32795. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  32796. }
  32797. if m.id == nil || m.oldValue == nil {
  32798. return v, errors.New("OldBotID requires an ID field in the mutation")
  32799. }
  32800. oldValue, err := m.oldValue(ctx)
  32801. if err != nil {
  32802. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  32803. }
  32804. return oldValue.BotID, nil
  32805. }
  32806. // ResetBotID resets all changes to the "bot_id" field.
  32807. func (m *UsageDetailMutation) ResetBotID() {
  32808. m.bot_id = nil
  32809. }
  32810. // SetReceiverID sets the "receiver_id" field.
  32811. func (m *UsageDetailMutation) SetReceiverID(s string) {
  32812. m.receiver_id = &s
  32813. }
  32814. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  32815. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  32816. v := m.receiver_id
  32817. if v == nil {
  32818. return
  32819. }
  32820. return *v, true
  32821. }
  32822. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  32823. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  32824. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32825. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  32826. if !m.op.Is(OpUpdateOne) {
  32827. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  32828. }
  32829. if m.id == nil || m.oldValue == nil {
  32830. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  32831. }
  32832. oldValue, err := m.oldValue(ctx)
  32833. if err != nil {
  32834. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  32835. }
  32836. return oldValue.ReceiverID, nil
  32837. }
  32838. // ResetReceiverID resets all changes to the "receiver_id" field.
  32839. func (m *UsageDetailMutation) ResetReceiverID() {
  32840. m.receiver_id = nil
  32841. }
  32842. // SetApp sets the "app" field.
  32843. func (m *UsageDetailMutation) SetApp(i int) {
  32844. m.app = &i
  32845. m.addapp = nil
  32846. }
  32847. // App returns the value of the "app" field in the mutation.
  32848. func (m *UsageDetailMutation) App() (r int, exists bool) {
  32849. v := m.app
  32850. if v == nil {
  32851. return
  32852. }
  32853. return *v, true
  32854. }
  32855. // OldApp returns the old "app" field's value of the UsageDetail entity.
  32856. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  32857. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32858. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  32859. if !m.op.Is(OpUpdateOne) {
  32860. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  32861. }
  32862. if m.id == nil || m.oldValue == nil {
  32863. return v, errors.New("OldApp requires an ID field in the mutation")
  32864. }
  32865. oldValue, err := m.oldValue(ctx)
  32866. if err != nil {
  32867. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  32868. }
  32869. return oldValue.App, nil
  32870. }
  32871. // AddApp adds i to the "app" field.
  32872. func (m *UsageDetailMutation) AddApp(i int) {
  32873. if m.addapp != nil {
  32874. *m.addapp += i
  32875. } else {
  32876. m.addapp = &i
  32877. }
  32878. }
  32879. // AddedApp returns the value that was added to the "app" field in this mutation.
  32880. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  32881. v := m.addapp
  32882. if v == nil {
  32883. return
  32884. }
  32885. return *v, true
  32886. }
  32887. // ClearApp clears the value of the "app" field.
  32888. func (m *UsageDetailMutation) ClearApp() {
  32889. m.app = nil
  32890. m.addapp = nil
  32891. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  32892. }
  32893. // AppCleared returns if the "app" field was cleared in this mutation.
  32894. func (m *UsageDetailMutation) AppCleared() bool {
  32895. _, ok := m.clearedFields[usagedetail.FieldApp]
  32896. return ok
  32897. }
  32898. // ResetApp resets all changes to the "app" field.
  32899. func (m *UsageDetailMutation) ResetApp() {
  32900. m.app = nil
  32901. m.addapp = nil
  32902. delete(m.clearedFields, usagedetail.FieldApp)
  32903. }
  32904. // SetSessionID sets the "session_id" field.
  32905. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  32906. m.session_id = &u
  32907. m.addsession_id = nil
  32908. }
  32909. // SessionID returns the value of the "session_id" field in the mutation.
  32910. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  32911. v := m.session_id
  32912. if v == nil {
  32913. return
  32914. }
  32915. return *v, true
  32916. }
  32917. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  32918. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  32919. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32920. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  32921. if !m.op.Is(OpUpdateOne) {
  32922. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  32923. }
  32924. if m.id == nil || m.oldValue == nil {
  32925. return v, errors.New("OldSessionID requires an ID field in the mutation")
  32926. }
  32927. oldValue, err := m.oldValue(ctx)
  32928. if err != nil {
  32929. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  32930. }
  32931. return oldValue.SessionID, nil
  32932. }
  32933. // AddSessionID adds u to the "session_id" field.
  32934. func (m *UsageDetailMutation) AddSessionID(u int64) {
  32935. if m.addsession_id != nil {
  32936. *m.addsession_id += u
  32937. } else {
  32938. m.addsession_id = &u
  32939. }
  32940. }
  32941. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  32942. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  32943. v := m.addsession_id
  32944. if v == nil {
  32945. return
  32946. }
  32947. return *v, true
  32948. }
  32949. // ClearSessionID clears the value of the "session_id" field.
  32950. func (m *UsageDetailMutation) ClearSessionID() {
  32951. m.session_id = nil
  32952. m.addsession_id = nil
  32953. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  32954. }
  32955. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  32956. func (m *UsageDetailMutation) SessionIDCleared() bool {
  32957. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  32958. return ok
  32959. }
  32960. // ResetSessionID resets all changes to the "session_id" field.
  32961. func (m *UsageDetailMutation) ResetSessionID() {
  32962. m.session_id = nil
  32963. m.addsession_id = nil
  32964. delete(m.clearedFields, usagedetail.FieldSessionID)
  32965. }
  32966. // SetRequest sets the "request" field.
  32967. func (m *UsageDetailMutation) SetRequest(s string) {
  32968. m.request = &s
  32969. }
  32970. // Request returns the value of the "request" field in the mutation.
  32971. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  32972. v := m.request
  32973. if v == nil {
  32974. return
  32975. }
  32976. return *v, true
  32977. }
  32978. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  32979. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  32980. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32981. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  32982. if !m.op.Is(OpUpdateOne) {
  32983. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  32984. }
  32985. if m.id == nil || m.oldValue == nil {
  32986. return v, errors.New("OldRequest requires an ID field in the mutation")
  32987. }
  32988. oldValue, err := m.oldValue(ctx)
  32989. if err != nil {
  32990. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  32991. }
  32992. return oldValue.Request, nil
  32993. }
  32994. // ResetRequest resets all changes to the "request" field.
  32995. func (m *UsageDetailMutation) ResetRequest() {
  32996. m.request = nil
  32997. }
  32998. // SetResponse sets the "response" field.
  32999. func (m *UsageDetailMutation) SetResponse(s string) {
  33000. m.response = &s
  33001. }
  33002. // Response returns the value of the "response" field in the mutation.
  33003. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  33004. v := m.response
  33005. if v == nil {
  33006. return
  33007. }
  33008. return *v, true
  33009. }
  33010. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  33011. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33013. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  33014. if !m.op.Is(OpUpdateOne) {
  33015. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  33016. }
  33017. if m.id == nil || m.oldValue == nil {
  33018. return v, errors.New("OldResponse requires an ID field in the mutation")
  33019. }
  33020. oldValue, err := m.oldValue(ctx)
  33021. if err != nil {
  33022. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  33023. }
  33024. return oldValue.Response, nil
  33025. }
  33026. // ResetResponse resets all changes to the "response" field.
  33027. func (m *UsageDetailMutation) ResetResponse() {
  33028. m.response = nil
  33029. }
  33030. // SetOriginalData sets the "original_data" field.
  33031. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  33032. m.original_data = &ctd
  33033. }
  33034. // OriginalData returns the value of the "original_data" field in the mutation.
  33035. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  33036. v := m.original_data
  33037. if v == nil {
  33038. return
  33039. }
  33040. return *v, true
  33041. }
  33042. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  33043. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33045. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  33046. if !m.op.Is(OpUpdateOne) {
  33047. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  33048. }
  33049. if m.id == nil || m.oldValue == nil {
  33050. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  33051. }
  33052. oldValue, err := m.oldValue(ctx)
  33053. if err != nil {
  33054. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  33055. }
  33056. return oldValue.OriginalData, nil
  33057. }
  33058. // ResetOriginalData resets all changes to the "original_data" field.
  33059. func (m *UsageDetailMutation) ResetOriginalData() {
  33060. m.original_data = nil
  33061. }
  33062. // SetTotalTokens sets the "total_tokens" field.
  33063. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  33064. m.total_tokens = &u
  33065. m.addtotal_tokens = nil
  33066. }
  33067. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  33068. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  33069. v := m.total_tokens
  33070. if v == nil {
  33071. return
  33072. }
  33073. return *v, true
  33074. }
  33075. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  33076. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33077. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33078. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  33079. if !m.op.Is(OpUpdateOne) {
  33080. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  33081. }
  33082. if m.id == nil || m.oldValue == nil {
  33083. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  33084. }
  33085. oldValue, err := m.oldValue(ctx)
  33086. if err != nil {
  33087. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  33088. }
  33089. return oldValue.TotalTokens, nil
  33090. }
  33091. // AddTotalTokens adds u to the "total_tokens" field.
  33092. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  33093. if m.addtotal_tokens != nil {
  33094. *m.addtotal_tokens += u
  33095. } else {
  33096. m.addtotal_tokens = &u
  33097. }
  33098. }
  33099. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  33100. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  33101. v := m.addtotal_tokens
  33102. if v == nil {
  33103. return
  33104. }
  33105. return *v, true
  33106. }
  33107. // ClearTotalTokens clears the value of the "total_tokens" field.
  33108. func (m *UsageDetailMutation) ClearTotalTokens() {
  33109. m.total_tokens = nil
  33110. m.addtotal_tokens = nil
  33111. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  33112. }
  33113. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  33114. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  33115. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  33116. return ok
  33117. }
  33118. // ResetTotalTokens resets all changes to the "total_tokens" field.
  33119. func (m *UsageDetailMutation) ResetTotalTokens() {
  33120. m.total_tokens = nil
  33121. m.addtotal_tokens = nil
  33122. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  33123. }
  33124. // SetPromptTokens sets the "prompt_tokens" field.
  33125. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  33126. m.prompt_tokens = &u
  33127. m.addprompt_tokens = nil
  33128. }
  33129. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  33130. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  33131. v := m.prompt_tokens
  33132. if v == nil {
  33133. return
  33134. }
  33135. return *v, true
  33136. }
  33137. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  33138. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33139. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33140. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  33141. if !m.op.Is(OpUpdateOne) {
  33142. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  33143. }
  33144. if m.id == nil || m.oldValue == nil {
  33145. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  33146. }
  33147. oldValue, err := m.oldValue(ctx)
  33148. if err != nil {
  33149. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  33150. }
  33151. return oldValue.PromptTokens, nil
  33152. }
  33153. // AddPromptTokens adds u to the "prompt_tokens" field.
  33154. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  33155. if m.addprompt_tokens != nil {
  33156. *m.addprompt_tokens += u
  33157. } else {
  33158. m.addprompt_tokens = &u
  33159. }
  33160. }
  33161. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  33162. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  33163. v := m.addprompt_tokens
  33164. if v == nil {
  33165. return
  33166. }
  33167. return *v, true
  33168. }
  33169. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  33170. func (m *UsageDetailMutation) ClearPromptTokens() {
  33171. m.prompt_tokens = nil
  33172. m.addprompt_tokens = nil
  33173. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  33174. }
  33175. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  33176. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  33177. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  33178. return ok
  33179. }
  33180. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  33181. func (m *UsageDetailMutation) ResetPromptTokens() {
  33182. m.prompt_tokens = nil
  33183. m.addprompt_tokens = nil
  33184. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  33185. }
  33186. // SetCompletionTokens sets the "completion_tokens" field.
  33187. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  33188. m.completion_tokens = &u
  33189. m.addcompletion_tokens = nil
  33190. }
  33191. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  33192. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  33193. v := m.completion_tokens
  33194. if v == nil {
  33195. return
  33196. }
  33197. return *v, true
  33198. }
  33199. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  33200. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33201. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33202. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  33203. if !m.op.Is(OpUpdateOne) {
  33204. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  33205. }
  33206. if m.id == nil || m.oldValue == nil {
  33207. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  33208. }
  33209. oldValue, err := m.oldValue(ctx)
  33210. if err != nil {
  33211. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  33212. }
  33213. return oldValue.CompletionTokens, nil
  33214. }
  33215. // AddCompletionTokens adds u to the "completion_tokens" field.
  33216. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  33217. if m.addcompletion_tokens != nil {
  33218. *m.addcompletion_tokens += u
  33219. } else {
  33220. m.addcompletion_tokens = &u
  33221. }
  33222. }
  33223. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  33224. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  33225. v := m.addcompletion_tokens
  33226. if v == nil {
  33227. return
  33228. }
  33229. return *v, true
  33230. }
  33231. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  33232. func (m *UsageDetailMutation) ClearCompletionTokens() {
  33233. m.completion_tokens = nil
  33234. m.addcompletion_tokens = nil
  33235. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  33236. }
  33237. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  33238. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  33239. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  33240. return ok
  33241. }
  33242. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  33243. func (m *UsageDetailMutation) ResetCompletionTokens() {
  33244. m.completion_tokens = nil
  33245. m.addcompletion_tokens = nil
  33246. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  33247. }
  33248. // SetOrganizationID sets the "organization_id" field.
  33249. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  33250. m.organization_id = &u
  33251. m.addorganization_id = nil
  33252. }
  33253. // OrganizationID returns the value of the "organization_id" field in the mutation.
  33254. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  33255. v := m.organization_id
  33256. if v == nil {
  33257. return
  33258. }
  33259. return *v, true
  33260. }
  33261. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  33262. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33263. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33264. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  33265. if !m.op.Is(OpUpdateOne) {
  33266. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  33267. }
  33268. if m.id == nil || m.oldValue == nil {
  33269. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  33270. }
  33271. oldValue, err := m.oldValue(ctx)
  33272. if err != nil {
  33273. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  33274. }
  33275. return oldValue.OrganizationID, nil
  33276. }
  33277. // AddOrganizationID adds u to the "organization_id" field.
  33278. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  33279. if m.addorganization_id != nil {
  33280. *m.addorganization_id += u
  33281. } else {
  33282. m.addorganization_id = &u
  33283. }
  33284. }
  33285. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  33286. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  33287. v := m.addorganization_id
  33288. if v == nil {
  33289. return
  33290. }
  33291. return *v, true
  33292. }
  33293. // ClearOrganizationID clears the value of the "organization_id" field.
  33294. func (m *UsageDetailMutation) ClearOrganizationID() {
  33295. m.organization_id = nil
  33296. m.addorganization_id = nil
  33297. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  33298. }
  33299. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  33300. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  33301. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  33302. return ok
  33303. }
  33304. // ResetOrganizationID resets all changes to the "organization_id" field.
  33305. func (m *UsageDetailMutation) ResetOrganizationID() {
  33306. m.organization_id = nil
  33307. m.addorganization_id = nil
  33308. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  33309. }
  33310. // SetModel sets the "model" field.
  33311. func (m *UsageDetailMutation) SetModel(s string) {
  33312. m.model = &s
  33313. }
  33314. // Model returns the value of the "model" field in the mutation.
  33315. func (m *UsageDetailMutation) Model() (r string, exists bool) {
  33316. v := m.model
  33317. if v == nil {
  33318. return
  33319. }
  33320. return *v, true
  33321. }
  33322. // OldModel returns the old "model" field's value of the UsageDetail entity.
  33323. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33324. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33325. func (m *UsageDetailMutation) OldModel(ctx context.Context) (v string, err error) {
  33326. if !m.op.Is(OpUpdateOne) {
  33327. return v, errors.New("OldModel is only allowed on UpdateOne operations")
  33328. }
  33329. if m.id == nil || m.oldValue == nil {
  33330. return v, errors.New("OldModel requires an ID field in the mutation")
  33331. }
  33332. oldValue, err := m.oldValue(ctx)
  33333. if err != nil {
  33334. return v, fmt.Errorf("querying old value for OldModel: %w", err)
  33335. }
  33336. return oldValue.Model, nil
  33337. }
  33338. // ClearModel clears the value of the "model" field.
  33339. func (m *UsageDetailMutation) ClearModel() {
  33340. m.model = nil
  33341. m.clearedFields[usagedetail.FieldModel] = struct{}{}
  33342. }
  33343. // ModelCleared returns if the "model" field was cleared in this mutation.
  33344. func (m *UsageDetailMutation) ModelCleared() bool {
  33345. _, ok := m.clearedFields[usagedetail.FieldModel]
  33346. return ok
  33347. }
  33348. // ResetModel resets all changes to the "model" field.
  33349. func (m *UsageDetailMutation) ResetModel() {
  33350. m.model = nil
  33351. delete(m.clearedFields, usagedetail.FieldModel)
  33352. }
  33353. // Where appends a list predicates to the UsageDetailMutation builder.
  33354. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  33355. m.predicates = append(m.predicates, ps...)
  33356. }
  33357. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  33358. // users can use type-assertion to append predicates that do not depend on any generated package.
  33359. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  33360. p := make([]predicate.UsageDetail, len(ps))
  33361. for i := range ps {
  33362. p[i] = ps[i]
  33363. }
  33364. m.Where(p...)
  33365. }
  33366. // Op returns the operation name.
  33367. func (m *UsageDetailMutation) Op() Op {
  33368. return m.op
  33369. }
  33370. // SetOp allows setting the mutation operation.
  33371. func (m *UsageDetailMutation) SetOp(op Op) {
  33372. m.op = op
  33373. }
  33374. // Type returns the node type of this mutation (UsageDetail).
  33375. func (m *UsageDetailMutation) Type() string {
  33376. return m.typ
  33377. }
  33378. // Fields returns all fields that were changed during this mutation. Note that in
  33379. // order to get all numeric fields that were incremented/decremented, call
  33380. // AddedFields().
  33381. func (m *UsageDetailMutation) Fields() []string {
  33382. fields := make([]string, 0, 16)
  33383. if m.created_at != nil {
  33384. fields = append(fields, usagedetail.FieldCreatedAt)
  33385. }
  33386. if m.updated_at != nil {
  33387. fields = append(fields, usagedetail.FieldUpdatedAt)
  33388. }
  33389. if m.status != nil {
  33390. fields = append(fields, usagedetail.FieldStatus)
  33391. }
  33392. if m._type != nil {
  33393. fields = append(fields, usagedetail.FieldType)
  33394. }
  33395. if m.bot_id != nil {
  33396. fields = append(fields, usagedetail.FieldBotID)
  33397. }
  33398. if m.receiver_id != nil {
  33399. fields = append(fields, usagedetail.FieldReceiverID)
  33400. }
  33401. if m.app != nil {
  33402. fields = append(fields, usagedetail.FieldApp)
  33403. }
  33404. if m.session_id != nil {
  33405. fields = append(fields, usagedetail.FieldSessionID)
  33406. }
  33407. if m.request != nil {
  33408. fields = append(fields, usagedetail.FieldRequest)
  33409. }
  33410. if m.response != nil {
  33411. fields = append(fields, usagedetail.FieldResponse)
  33412. }
  33413. if m.original_data != nil {
  33414. fields = append(fields, usagedetail.FieldOriginalData)
  33415. }
  33416. if m.total_tokens != nil {
  33417. fields = append(fields, usagedetail.FieldTotalTokens)
  33418. }
  33419. if m.prompt_tokens != nil {
  33420. fields = append(fields, usagedetail.FieldPromptTokens)
  33421. }
  33422. if m.completion_tokens != nil {
  33423. fields = append(fields, usagedetail.FieldCompletionTokens)
  33424. }
  33425. if m.organization_id != nil {
  33426. fields = append(fields, usagedetail.FieldOrganizationID)
  33427. }
  33428. if m.model != nil {
  33429. fields = append(fields, usagedetail.FieldModel)
  33430. }
  33431. return fields
  33432. }
  33433. // Field returns the value of a field with the given name. The second boolean
  33434. // return value indicates that this field was not set, or was not defined in the
  33435. // schema.
  33436. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  33437. switch name {
  33438. case usagedetail.FieldCreatedAt:
  33439. return m.CreatedAt()
  33440. case usagedetail.FieldUpdatedAt:
  33441. return m.UpdatedAt()
  33442. case usagedetail.FieldStatus:
  33443. return m.Status()
  33444. case usagedetail.FieldType:
  33445. return m.GetType()
  33446. case usagedetail.FieldBotID:
  33447. return m.BotID()
  33448. case usagedetail.FieldReceiverID:
  33449. return m.ReceiverID()
  33450. case usagedetail.FieldApp:
  33451. return m.App()
  33452. case usagedetail.FieldSessionID:
  33453. return m.SessionID()
  33454. case usagedetail.FieldRequest:
  33455. return m.Request()
  33456. case usagedetail.FieldResponse:
  33457. return m.Response()
  33458. case usagedetail.FieldOriginalData:
  33459. return m.OriginalData()
  33460. case usagedetail.FieldTotalTokens:
  33461. return m.TotalTokens()
  33462. case usagedetail.FieldPromptTokens:
  33463. return m.PromptTokens()
  33464. case usagedetail.FieldCompletionTokens:
  33465. return m.CompletionTokens()
  33466. case usagedetail.FieldOrganizationID:
  33467. return m.OrganizationID()
  33468. case usagedetail.FieldModel:
  33469. return m.Model()
  33470. }
  33471. return nil, false
  33472. }
  33473. // OldField returns the old value of the field from the database. An error is
  33474. // returned if the mutation operation is not UpdateOne, or the query to the
  33475. // database failed.
  33476. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  33477. switch name {
  33478. case usagedetail.FieldCreatedAt:
  33479. return m.OldCreatedAt(ctx)
  33480. case usagedetail.FieldUpdatedAt:
  33481. return m.OldUpdatedAt(ctx)
  33482. case usagedetail.FieldStatus:
  33483. return m.OldStatus(ctx)
  33484. case usagedetail.FieldType:
  33485. return m.OldType(ctx)
  33486. case usagedetail.FieldBotID:
  33487. return m.OldBotID(ctx)
  33488. case usagedetail.FieldReceiverID:
  33489. return m.OldReceiverID(ctx)
  33490. case usagedetail.FieldApp:
  33491. return m.OldApp(ctx)
  33492. case usagedetail.FieldSessionID:
  33493. return m.OldSessionID(ctx)
  33494. case usagedetail.FieldRequest:
  33495. return m.OldRequest(ctx)
  33496. case usagedetail.FieldResponse:
  33497. return m.OldResponse(ctx)
  33498. case usagedetail.FieldOriginalData:
  33499. return m.OldOriginalData(ctx)
  33500. case usagedetail.FieldTotalTokens:
  33501. return m.OldTotalTokens(ctx)
  33502. case usagedetail.FieldPromptTokens:
  33503. return m.OldPromptTokens(ctx)
  33504. case usagedetail.FieldCompletionTokens:
  33505. return m.OldCompletionTokens(ctx)
  33506. case usagedetail.FieldOrganizationID:
  33507. return m.OldOrganizationID(ctx)
  33508. case usagedetail.FieldModel:
  33509. return m.OldModel(ctx)
  33510. }
  33511. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  33512. }
  33513. // SetField sets the value of a field with the given name. It returns an error if
  33514. // the field is not defined in the schema, or if the type mismatched the field
  33515. // type.
  33516. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  33517. switch name {
  33518. case usagedetail.FieldCreatedAt:
  33519. v, ok := value.(time.Time)
  33520. if !ok {
  33521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33522. }
  33523. m.SetCreatedAt(v)
  33524. return nil
  33525. case usagedetail.FieldUpdatedAt:
  33526. v, ok := value.(time.Time)
  33527. if !ok {
  33528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33529. }
  33530. m.SetUpdatedAt(v)
  33531. return nil
  33532. case usagedetail.FieldStatus:
  33533. v, ok := value.(uint8)
  33534. if !ok {
  33535. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33536. }
  33537. m.SetStatus(v)
  33538. return nil
  33539. case usagedetail.FieldType:
  33540. v, ok := value.(int)
  33541. if !ok {
  33542. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33543. }
  33544. m.SetType(v)
  33545. return nil
  33546. case usagedetail.FieldBotID:
  33547. v, ok := value.(string)
  33548. if !ok {
  33549. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33550. }
  33551. m.SetBotID(v)
  33552. return nil
  33553. case usagedetail.FieldReceiverID:
  33554. v, ok := value.(string)
  33555. if !ok {
  33556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33557. }
  33558. m.SetReceiverID(v)
  33559. return nil
  33560. case usagedetail.FieldApp:
  33561. v, ok := value.(int)
  33562. if !ok {
  33563. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33564. }
  33565. m.SetApp(v)
  33566. return nil
  33567. case usagedetail.FieldSessionID:
  33568. v, ok := value.(uint64)
  33569. if !ok {
  33570. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33571. }
  33572. m.SetSessionID(v)
  33573. return nil
  33574. case usagedetail.FieldRequest:
  33575. v, ok := value.(string)
  33576. if !ok {
  33577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33578. }
  33579. m.SetRequest(v)
  33580. return nil
  33581. case usagedetail.FieldResponse:
  33582. v, ok := value.(string)
  33583. if !ok {
  33584. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33585. }
  33586. m.SetResponse(v)
  33587. return nil
  33588. case usagedetail.FieldOriginalData:
  33589. v, ok := value.(custom_types.OriginalData)
  33590. if !ok {
  33591. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33592. }
  33593. m.SetOriginalData(v)
  33594. return nil
  33595. case usagedetail.FieldTotalTokens:
  33596. v, ok := value.(uint64)
  33597. if !ok {
  33598. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33599. }
  33600. m.SetTotalTokens(v)
  33601. return nil
  33602. case usagedetail.FieldPromptTokens:
  33603. v, ok := value.(uint64)
  33604. if !ok {
  33605. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33606. }
  33607. m.SetPromptTokens(v)
  33608. return nil
  33609. case usagedetail.FieldCompletionTokens:
  33610. v, ok := value.(uint64)
  33611. if !ok {
  33612. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33613. }
  33614. m.SetCompletionTokens(v)
  33615. return nil
  33616. case usagedetail.FieldOrganizationID:
  33617. v, ok := value.(uint64)
  33618. if !ok {
  33619. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33620. }
  33621. m.SetOrganizationID(v)
  33622. return nil
  33623. case usagedetail.FieldModel:
  33624. v, ok := value.(string)
  33625. if !ok {
  33626. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33627. }
  33628. m.SetModel(v)
  33629. return nil
  33630. }
  33631. return fmt.Errorf("unknown UsageDetail field %s", name)
  33632. }
  33633. // AddedFields returns all numeric fields that were incremented/decremented during
  33634. // this mutation.
  33635. func (m *UsageDetailMutation) AddedFields() []string {
  33636. var fields []string
  33637. if m.addstatus != nil {
  33638. fields = append(fields, usagedetail.FieldStatus)
  33639. }
  33640. if m.add_type != nil {
  33641. fields = append(fields, usagedetail.FieldType)
  33642. }
  33643. if m.addapp != nil {
  33644. fields = append(fields, usagedetail.FieldApp)
  33645. }
  33646. if m.addsession_id != nil {
  33647. fields = append(fields, usagedetail.FieldSessionID)
  33648. }
  33649. if m.addtotal_tokens != nil {
  33650. fields = append(fields, usagedetail.FieldTotalTokens)
  33651. }
  33652. if m.addprompt_tokens != nil {
  33653. fields = append(fields, usagedetail.FieldPromptTokens)
  33654. }
  33655. if m.addcompletion_tokens != nil {
  33656. fields = append(fields, usagedetail.FieldCompletionTokens)
  33657. }
  33658. if m.addorganization_id != nil {
  33659. fields = append(fields, usagedetail.FieldOrganizationID)
  33660. }
  33661. return fields
  33662. }
  33663. // AddedField returns the numeric value that was incremented/decremented on a field
  33664. // with the given name. The second boolean return value indicates that this field
  33665. // was not set, or was not defined in the schema.
  33666. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  33667. switch name {
  33668. case usagedetail.FieldStatus:
  33669. return m.AddedStatus()
  33670. case usagedetail.FieldType:
  33671. return m.AddedType()
  33672. case usagedetail.FieldApp:
  33673. return m.AddedApp()
  33674. case usagedetail.FieldSessionID:
  33675. return m.AddedSessionID()
  33676. case usagedetail.FieldTotalTokens:
  33677. return m.AddedTotalTokens()
  33678. case usagedetail.FieldPromptTokens:
  33679. return m.AddedPromptTokens()
  33680. case usagedetail.FieldCompletionTokens:
  33681. return m.AddedCompletionTokens()
  33682. case usagedetail.FieldOrganizationID:
  33683. return m.AddedOrganizationID()
  33684. }
  33685. return nil, false
  33686. }
  33687. // AddField adds the value to the field with the given name. It returns an error if
  33688. // the field is not defined in the schema, or if the type mismatched the field
  33689. // type.
  33690. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  33691. switch name {
  33692. case usagedetail.FieldStatus:
  33693. v, ok := value.(int8)
  33694. if !ok {
  33695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33696. }
  33697. m.AddStatus(v)
  33698. return nil
  33699. case usagedetail.FieldType:
  33700. v, ok := value.(int)
  33701. if !ok {
  33702. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33703. }
  33704. m.AddType(v)
  33705. return nil
  33706. case usagedetail.FieldApp:
  33707. v, ok := value.(int)
  33708. if !ok {
  33709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33710. }
  33711. m.AddApp(v)
  33712. return nil
  33713. case usagedetail.FieldSessionID:
  33714. v, ok := value.(int64)
  33715. if !ok {
  33716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33717. }
  33718. m.AddSessionID(v)
  33719. return nil
  33720. case usagedetail.FieldTotalTokens:
  33721. v, ok := value.(int64)
  33722. if !ok {
  33723. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33724. }
  33725. m.AddTotalTokens(v)
  33726. return nil
  33727. case usagedetail.FieldPromptTokens:
  33728. v, ok := value.(int64)
  33729. if !ok {
  33730. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33731. }
  33732. m.AddPromptTokens(v)
  33733. return nil
  33734. case usagedetail.FieldCompletionTokens:
  33735. v, ok := value.(int64)
  33736. if !ok {
  33737. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33738. }
  33739. m.AddCompletionTokens(v)
  33740. return nil
  33741. case usagedetail.FieldOrganizationID:
  33742. v, ok := value.(int64)
  33743. if !ok {
  33744. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33745. }
  33746. m.AddOrganizationID(v)
  33747. return nil
  33748. }
  33749. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  33750. }
  33751. // ClearedFields returns all nullable fields that were cleared during this
  33752. // mutation.
  33753. func (m *UsageDetailMutation) ClearedFields() []string {
  33754. var fields []string
  33755. if m.FieldCleared(usagedetail.FieldStatus) {
  33756. fields = append(fields, usagedetail.FieldStatus)
  33757. }
  33758. if m.FieldCleared(usagedetail.FieldType) {
  33759. fields = append(fields, usagedetail.FieldType)
  33760. }
  33761. if m.FieldCleared(usagedetail.FieldApp) {
  33762. fields = append(fields, usagedetail.FieldApp)
  33763. }
  33764. if m.FieldCleared(usagedetail.FieldSessionID) {
  33765. fields = append(fields, usagedetail.FieldSessionID)
  33766. }
  33767. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  33768. fields = append(fields, usagedetail.FieldTotalTokens)
  33769. }
  33770. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  33771. fields = append(fields, usagedetail.FieldPromptTokens)
  33772. }
  33773. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  33774. fields = append(fields, usagedetail.FieldCompletionTokens)
  33775. }
  33776. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  33777. fields = append(fields, usagedetail.FieldOrganizationID)
  33778. }
  33779. if m.FieldCleared(usagedetail.FieldModel) {
  33780. fields = append(fields, usagedetail.FieldModel)
  33781. }
  33782. return fields
  33783. }
  33784. // FieldCleared returns a boolean indicating if a field with the given name was
  33785. // cleared in this mutation.
  33786. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  33787. _, ok := m.clearedFields[name]
  33788. return ok
  33789. }
  33790. // ClearField clears the value of the field with the given name. It returns an
  33791. // error if the field is not defined in the schema.
  33792. func (m *UsageDetailMutation) ClearField(name string) error {
  33793. switch name {
  33794. case usagedetail.FieldStatus:
  33795. m.ClearStatus()
  33796. return nil
  33797. case usagedetail.FieldType:
  33798. m.ClearType()
  33799. return nil
  33800. case usagedetail.FieldApp:
  33801. m.ClearApp()
  33802. return nil
  33803. case usagedetail.FieldSessionID:
  33804. m.ClearSessionID()
  33805. return nil
  33806. case usagedetail.FieldTotalTokens:
  33807. m.ClearTotalTokens()
  33808. return nil
  33809. case usagedetail.FieldPromptTokens:
  33810. m.ClearPromptTokens()
  33811. return nil
  33812. case usagedetail.FieldCompletionTokens:
  33813. m.ClearCompletionTokens()
  33814. return nil
  33815. case usagedetail.FieldOrganizationID:
  33816. m.ClearOrganizationID()
  33817. return nil
  33818. case usagedetail.FieldModel:
  33819. m.ClearModel()
  33820. return nil
  33821. }
  33822. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  33823. }
  33824. // ResetField resets all changes in the mutation for the field with the given name.
  33825. // It returns an error if the field is not defined in the schema.
  33826. func (m *UsageDetailMutation) ResetField(name string) error {
  33827. switch name {
  33828. case usagedetail.FieldCreatedAt:
  33829. m.ResetCreatedAt()
  33830. return nil
  33831. case usagedetail.FieldUpdatedAt:
  33832. m.ResetUpdatedAt()
  33833. return nil
  33834. case usagedetail.FieldStatus:
  33835. m.ResetStatus()
  33836. return nil
  33837. case usagedetail.FieldType:
  33838. m.ResetType()
  33839. return nil
  33840. case usagedetail.FieldBotID:
  33841. m.ResetBotID()
  33842. return nil
  33843. case usagedetail.FieldReceiverID:
  33844. m.ResetReceiverID()
  33845. return nil
  33846. case usagedetail.FieldApp:
  33847. m.ResetApp()
  33848. return nil
  33849. case usagedetail.FieldSessionID:
  33850. m.ResetSessionID()
  33851. return nil
  33852. case usagedetail.FieldRequest:
  33853. m.ResetRequest()
  33854. return nil
  33855. case usagedetail.FieldResponse:
  33856. m.ResetResponse()
  33857. return nil
  33858. case usagedetail.FieldOriginalData:
  33859. m.ResetOriginalData()
  33860. return nil
  33861. case usagedetail.FieldTotalTokens:
  33862. m.ResetTotalTokens()
  33863. return nil
  33864. case usagedetail.FieldPromptTokens:
  33865. m.ResetPromptTokens()
  33866. return nil
  33867. case usagedetail.FieldCompletionTokens:
  33868. m.ResetCompletionTokens()
  33869. return nil
  33870. case usagedetail.FieldOrganizationID:
  33871. m.ResetOrganizationID()
  33872. return nil
  33873. case usagedetail.FieldModel:
  33874. m.ResetModel()
  33875. return nil
  33876. }
  33877. return fmt.Errorf("unknown UsageDetail field %s", name)
  33878. }
  33879. // AddedEdges returns all edge names that were set/added in this mutation.
  33880. func (m *UsageDetailMutation) AddedEdges() []string {
  33881. edges := make([]string, 0, 0)
  33882. return edges
  33883. }
  33884. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33885. // name in this mutation.
  33886. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  33887. return nil
  33888. }
  33889. // RemovedEdges returns all edge names that were removed in this mutation.
  33890. func (m *UsageDetailMutation) RemovedEdges() []string {
  33891. edges := make([]string, 0, 0)
  33892. return edges
  33893. }
  33894. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33895. // the given name in this mutation.
  33896. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  33897. return nil
  33898. }
  33899. // ClearedEdges returns all edge names that were cleared in this mutation.
  33900. func (m *UsageDetailMutation) ClearedEdges() []string {
  33901. edges := make([]string, 0, 0)
  33902. return edges
  33903. }
  33904. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33905. // was cleared in this mutation.
  33906. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  33907. return false
  33908. }
  33909. // ClearEdge clears the value of the edge with the given name. It returns an error
  33910. // if that edge is not defined in the schema.
  33911. func (m *UsageDetailMutation) ClearEdge(name string) error {
  33912. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  33913. }
  33914. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33915. // It returns an error if the edge is not defined in the schema.
  33916. func (m *UsageDetailMutation) ResetEdge(name string) error {
  33917. return fmt.Errorf("unknown UsageDetail edge %s", name)
  33918. }
  33919. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  33920. type UsageStatisticDayMutation struct {
  33921. config
  33922. op Op
  33923. typ string
  33924. id *uint64
  33925. created_at *time.Time
  33926. updated_at *time.Time
  33927. status *uint8
  33928. addstatus *int8
  33929. deleted_at *time.Time
  33930. addtime *uint64
  33931. addaddtime *int64
  33932. _type *int
  33933. add_type *int
  33934. bot_id *string
  33935. organization_id *uint64
  33936. addorganization_id *int64
  33937. ai_response *uint64
  33938. addai_response *int64
  33939. sop_run *uint64
  33940. addsop_run *int64
  33941. total_friend *uint64
  33942. addtotal_friend *int64
  33943. total_group *uint64
  33944. addtotal_group *int64
  33945. account_balance *uint64
  33946. addaccount_balance *int64
  33947. consume_token *uint64
  33948. addconsume_token *int64
  33949. active_user *uint64
  33950. addactive_user *int64
  33951. new_user *int64
  33952. addnew_user *int64
  33953. label_dist *[]custom_types.LabelDist
  33954. appendlabel_dist []custom_types.LabelDist
  33955. consume_coin *uint64
  33956. addconsume_coin *int64
  33957. clearedFields map[string]struct{}
  33958. done bool
  33959. oldValue func(context.Context) (*UsageStatisticDay, error)
  33960. predicates []predicate.UsageStatisticDay
  33961. }
  33962. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  33963. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  33964. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  33965. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  33966. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  33967. m := &UsageStatisticDayMutation{
  33968. config: c,
  33969. op: op,
  33970. typ: TypeUsageStatisticDay,
  33971. clearedFields: make(map[string]struct{}),
  33972. }
  33973. for _, opt := range opts {
  33974. opt(m)
  33975. }
  33976. return m
  33977. }
  33978. // withUsageStatisticDayID sets the ID field of the mutation.
  33979. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  33980. return func(m *UsageStatisticDayMutation) {
  33981. var (
  33982. err error
  33983. once sync.Once
  33984. value *UsageStatisticDay
  33985. )
  33986. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  33987. once.Do(func() {
  33988. if m.done {
  33989. err = errors.New("querying old values post mutation is not allowed")
  33990. } else {
  33991. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  33992. }
  33993. })
  33994. return value, err
  33995. }
  33996. m.id = &id
  33997. }
  33998. }
  33999. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  34000. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  34001. return func(m *UsageStatisticDayMutation) {
  34002. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  34003. return node, nil
  34004. }
  34005. m.id = &node.ID
  34006. }
  34007. }
  34008. // Client returns a new `ent.Client` from the mutation. If the mutation was
  34009. // executed in a transaction (ent.Tx), a transactional client is returned.
  34010. func (m UsageStatisticDayMutation) Client() *Client {
  34011. client := &Client{config: m.config}
  34012. client.init()
  34013. return client
  34014. }
  34015. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  34016. // it returns an error otherwise.
  34017. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  34018. if _, ok := m.driver.(*txDriver); !ok {
  34019. return nil, errors.New("ent: mutation is not running in a transaction")
  34020. }
  34021. tx := &Tx{config: m.config}
  34022. tx.init()
  34023. return tx, nil
  34024. }
  34025. // SetID sets the value of the id field. Note that this
  34026. // operation is only accepted on creation of UsageStatisticDay entities.
  34027. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  34028. m.id = &id
  34029. }
  34030. // ID returns the ID value in the mutation. Note that the ID is only available
  34031. // if it was provided to the builder or after it was returned from the database.
  34032. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  34033. if m.id == nil {
  34034. return
  34035. }
  34036. return *m.id, true
  34037. }
  34038. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  34039. // That means, if the mutation is applied within a transaction with an isolation level such
  34040. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  34041. // or updated by the mutation.
  34042. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  34043. switch {
  34044. case m.op.Is(OpUpdateOne | OpDeleteOne):
  34045. id, exists := m.ID()
  34046. if exists {
  34047. return []uint64{id}, nil
  34048. }
  34049. fallthrough
  34050. case m.op.Is(OpUpdate | OpDelete):
  34051. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  34052. default:
  34053. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  34054. }
  34055. }
  34056. // SetCreatedAt sets the "created_at" field.
  34057. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  34058. m.created_at = &t
  34059. }
  34060. // CreatedAt returns the value of the "created_at" field in the mutation.
  34061. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  34062. v := m.created_at
  34063. if v == nil {
  34064. return
  34065. }
  34066. return *v, true
  34067. }
  34068. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  34069. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34070. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34071. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  34072. if !m.op.Is(OpUpdateOne) {
  34073. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  34074. }
  34075. if m.id == nil || m.oldValue == nil {
  34076. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  34077. }
  34078. oldValue, err := m.oldValue(ctx)
  34079. if err != nil {
  34080. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  34081. }
  34082. return oldValue.CreatedAt, nil
  34083. }
  34084. // ResetCreatedAt resets all changes to the "created_at" field.
  34085. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  34086. m.created_at = nil
  34087. }
  34088. // SetUpdatedAt sets the "updated_at" field.
  34089. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  34090. m.updated_at = &t
  34091. }
  34092. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  34093. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  34094. v := m.updated_at
  34095. if v == nil {
  34096. return
  34097. }
  34098. return *v, true
  34099. }
  34100. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  34101. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34102. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34103. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  34104. if !m.op.Is(OpUpdateOne) {
  34105. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  34106. }
  34107. if m.id == nil || m.oldValue == nil {
  34108. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  34109. }
  34110. oldValue, err := m.oldValue(ctx)
  34111. if err != nil {
  34112. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  34113. }
  34114. return oldValue.UpdatedAt, nil
  34115. }
  34116. // ResetUpdatedAt resets all changes to the "updated_at" field.
  34117. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  34118. m.updated_at = nil
  34119. }
  34120. // SetStatus sets the "status" field.
  34121. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  34122. m.status = &u
  34123. m.addstatus = nil
  34124. }
  34125. // Status returns the value of the "status" field in the mutation.
  34126. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  34127. v := m.status
  34128. if v == nil {
  34129. return
  34130. }
  34131. return *v, true
  34132. }
  34133. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  34134. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34135. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34136. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  34137. if !m.op.Is(OpUpdateOne) {
  34138. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  34139. }
  34140. if m.id == nil || m.oldValue == nil {
  34141. return v, errors.New("OldStatus requires an ID field in the mutation")
  34142. }
  34143. oldValue, err := m.oldValue(ctx)
  34144. if err != nil {
  34145. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  34146. }
  34147. return oldValue.Status, nil
  34148. }
  34149. // AddStatus adds u to the "status" field.
  34150. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  34151. if m.addstatus != nil {
  34152. *m.addstatus += u
  34153. } else {
  34154. m.addstatus = &u
  34155. }
  34156. }
  34157. // AddedStatus returns the value that was added to the "status" field in this mutation.
  34158. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  34159. v := m.addstatus
  34160. if v == nil {
  34161. return
  34162. }
  34163. return *v, true
  34164. }
  34165. // ClearStatus clears the value of the "status" field.
  34166. func (m *UsageStatisticDayMutation) ClearStatus() {
  34167. m.status = nil
  34168. m.addstatus = nil
  34169. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  34170. }
  34171. // StatusCleared returns if the "status" field was cleared in this mutation.
  34172. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  34173. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  34174. return ok
  34175. }
  34176. // ResetStatus resets all changes to the "status" field.
  34177. func (m *UsageStatisticDayMutation) ResetStatus() {
  34178. m.status = nil
  34179. m.addstatus = nil
  34180. delete(m.clearedFields, usagestatisticday.FieldStatus)
  34181. }
  34182. // SetDeletedAt sets the "deleted_at" field.
  34183. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  34184. m.deleted_at = &t
  34185. }
  34186. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  34187. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  34188. v := m.deleted_at
  34189. if v == nil {
  34190. return
  34191. }
  34192. return *v, true
  34193. }
  34194. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  34195. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34196. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34197. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  34198. if !m.op.Is(OpUpdateOne) {
  34199. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  34200. }
  34201. if m.id == nil || m.oldValue == nil {
  34202. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  34203. }
  34204. oldValue, err := m.oldValue(ctx)
  34205. if err != nil {
  34206. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  34207. }
  34208. return oldValue.DeletedAt, nil
  34209. }
  34210. // ClearDeletedAt clears the value of the "deleted_at" field.
  34211. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  34212. m.deleted_at = nil
  34213. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  34214. }
  34215. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  34216. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  34217. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  34218. return ok
  34219. }
  34220. // ResetDeletedAt resets all changes to the "deleted_at" field.
  34221. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  34222. m.deleted_at = nil
  34223. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  34224. }
  34225. // SetAddtime sets the "addtime" field.
  34226. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  34227. m.addtime = &u
  34228. m.addaddtime = nil
  34229. }
  34230. // Addtime returns the value of the "addtime" field in the mutation.
  34231. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  34232. v := m.addtime
  34233. if v == nil {
  34234. return
  34235. }
  34236. return *v, true
  34237. }
  34238. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  34239. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34240. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34241. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  34242. if !m.op.Is(OpUpdateOne) {
  34243. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  34244. }
  34245. if m.id == nil || m.oldValue == nil {
  34246. return v, errors.New("OldAddtime requires an ID field in the mutation")
  34247. }
  34248. oldValue, err := m.oldValue(ctx)
  34249. if err != nil {
  34250. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  34251. }
  34252. return oldValue.Addtime, nil
  34253. }
  34254. // AddAddtime adds u to the "addtime" field.
  34255. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  34256. if m.addaddtime != nil {
  34257. *m.addaddtime += u
  34258. } else {
  34259. m.addaddtime = &u
  34260. }
  34261. }
  34262. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  34263. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  34264. v := m.addaddtime
  34265. if v == nil {
  34266. return
  34267. }
  34268. return *v, true
  34269. }
  34270. // ResetAddtime resets all changes to the "addtime" field.
  34271. func (m *UsageStatisticDayMutation) ResetAddtime() {
  34272. m.addtime = nil
  34273. m.addaddtime = nil
  34274. }
  34275. // SetType sets the "type" field.
  34276. func (m *UsageStatisticDayMutation) SetType(i int) {
  34277. m._type = &i
  34278. m.add_type = nil
  34279. }
  34280. // GetType returns the value of the "type" field in the mutation.
  34281. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  34282. v := m._type
  34283. if v == nil {
  34284. return
  34285. }
  34286. return *v, true
  34287. }
  34288. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  34289. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34290. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34291. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  34292. if !m.op.Is(OpUpdateOne) {
  34293. return v, errors.New("OldType is only allowed on UpdateOne operations")
  34294. }
  34295. if m.id == nil || m.oldValue == nil {
  34296. return v, errors.New("OldType requires an ID field in the mutation")
  34297. }
  34298. oldValue, err := m.oldValue(ctx)
  34299. if err != nil {
  34300. return v, fmt.Errorf("querying old value for OldType: %w", err)
  34301. }
  34302. return oldValue.Type, nil
  34303. }
  34304. // AddType adds i to the "type" field.
  34305. func (m *UsageStatisticDayMutation) AddType(i int) {
  34306. if m.add_type != nil {
  34307. *m.add_type += i
  34308. } else {
  34309. m.add_type = &i
  34310. }
  34311. }
  34312. // AddedType returns the value that was added to the "type" field in this mutation.
  34313. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  34314. v := m.add_type
  34315. if v == nil {
  34316. return
  34317. }
  34318. return *v, true
  34319. }
  34320. // ResetType resets all changes to the "type" field.
  34321. func (m *UsageStatisticDayMutation) ResetType() {
  34322. m._type = nil
  34323. m.add_type = nil
  34324. }
  34325. // SetBotID sets the "bot_id" field.
  34326. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  34327. m.bot_id = &s
  34328. }
  34329. // BotID returns the value of the "bot_id" field in the mutation.
  34330. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  34331. v := m.bot_id
  34332. if v == nil {
  34333. return
  34334. }
  34335. return *v, true
  34336. }
  34337. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  34338. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34339. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34340. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  34341. if !m.op.Is(OpUpdateOne) {
  34342. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  34343. }
  34344. if m.id == nil || m.oldValue == nil {
  34345. return v, errors.New("OldBotID requires an ID field in the mutation")
  34346. }
  34347. oldValue, err := m.oldValue(ctx)
  34348. if err != nil {
  34349. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  34350. }
  34351. return oldValue.BotID, nil
  34352. }
  34353. // ClearBotID clears the value of the "bot_id" field.
  34354. func (m *UsageStatisticDayMutation) ClearBotID() {
  34355. m.bot_id = nil
  34356. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  34357. }
  34358. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  34359. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  34360. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  34361. return ok
  34362. }
  34363. // ResetBotID resets all changes to the "bot_id" field.
  34364. func (m *UsageStatisticDayMutation) ResetBotID() {
  34365. m.bot_id = nil
  34366. delete(m.clearedFields, usagestatisticday.FieldBotID)
  34367. }
  34368. // SetOrganizationID sets the "organization_id" field.
  34369. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  34370. m.organization_id = &u
  34371. m.addorganization_id = nil
  34372. }
  34373. // OrganizationID returns the value of the "organization_id" field in the mutation.
  34374. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  34375. v := m.organization_id
  34376. if v == nil {
  34377. return
  34378. }
  34379. return *v, true
  34380. }
  34381. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  34382. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34383. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34384. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  34385. if !m.op.Is(OpUpdateOne) {
  34386. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  34387. }
  34388. if m.id == nil || m.oldValue == nil {
  34389. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  34390. }
  34391. oldValue, err := m.oldValue(ctx)
  34392. if err != nil {
  34393. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  34394. }
  34395. return oldValue.OrganizationID, nil
  34396. }
  34397. // AddOrganizationID adds u to the "organization_id" field.
  34398. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  34399. if m.addorganization_id != nil {
  34400. *m.addorganization_id += u
  34401. } else {
  34402. m.addorganization_id = &u
  34403. }
  34404. }
  34405. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  34406. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  34407. v := m.addorganization_id
  34408. if v == nil {
  34409. return
  34410. }
  34411. return *v, true
  34412. }
  34413. // ClearOrganizationID clears the value of the "organization_id" field.
  34414. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  34415. m.organization_id = nil
  34416. m.addorganization_id = nil
  34417. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  34418. }
  34419. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  34420. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  34421. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  34422. return ok
  34423. }
  34424. // ResetOrganizationID resets all changes to the "organization_id" field.
  34425. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  34426. m.organization_id = nil
  34427. m.addorganization_id = nil
  34428. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  34429. }
  34430. // SetAiResponse sets the "ai_response" field.
  34431. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  34432. m.ai_response = &u
  34433. m.addai_response = nil
  34434. }
  34435. // AiResponse returns the value of the "ai_response" field in the mutation.
  34436. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  34437. v := m.ai_response
  34438. if v == nil {
  34439. return
  34440. }
  34441. return *v, true
  34442. }
  34443. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  34444. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34445. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34446. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  34447. if !m.op.Is(OpUpdateOne) {
  34448. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  34449. }
  34450. if m.id == nil || m.oldValue == nil {
  34451. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  34452. }
  34453. oldValue, err := m.oldValue(ctx)
  34454. if err != nil {
  34455. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  34456. }
  34457. return oldValue.AiResponse, nil
  34458. }
  34459. // AddAiResponse adds u to the "ai_response" field.
  34460. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  34461. if m.addai_response != nil {
  34462. *m.addai_response += u
  34463. } else {
  34464. m.addai_response = &u
  34465. }
  34466. }
  34467. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  34468. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  34469. v := m.addai_response
  34470. if v == nil {
  34471. return
  34472. }
  34473. return *v, true
  34474. }
  34475. // ResetAiResponse resets all changes to the "ai_response" field.
  34476. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  34477. m.ai_response = nil
  34478. m.addai_response = nil
  34479. }
  34480. // SetSopRun sets the "sop_run" field.
  34481. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  34482. m.sop_run = &u
  34483. m.addsop_run = nil
  34484. }
  34485. // SopRun returns the value of the "sop_run" field in the mutation.
  34486. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  34487. v := m.sop_run
  34488. if v == nil {
  34489. return
  34490. }
  34491. return *v, true
  34492. }
  34493. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  34494. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34495. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34496. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  34497. if !m.op.Is(OpUpdateOne) {
  34498. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  34499. }
  34500. if m.id == nil || m.oldValue == nil {
  34501. return v, errors.New("OldSopRun requires an ID field in the mutation")
  34502. }
  34503. oldValue, err := m.oldValue(ctx)
  34504. if err != nil {
  34505. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  34506. }
  34507. return oldValue.SopRun, nil
  34508. }
  34509. // AddSopRun adds u to the "sop_run" field.
  34510. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  34511. if m.addsop_run != nil {
  34512. *m.addsop_run += u
  34513. } else {
  34514. m.addsop_run = &u
  34515. }
  34516. }
  34517. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  34518. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  34519. v := m.addsop_run
  34520. if v == nil {
  34521. return
  34522. }
  34523. return *v, true
  34524. }
  34525. // ResetSopRun resets all changes to the "sop_run" field.
  34526. func (m *UsageStatisticDayMutation) ResetSopRun() {
  34527. m.sop_run = nil
  34528. m.addsop_run = nil
  34529. }
  34530. // SetTotalFriend sets the "total_friend" field.
  34531. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  34532. m.total_friend = &u
  34533. m.addtotal_friend = nil
  34534. }
  34535. // TotalFriend returns the value of the "total_friend" field in the mutation.
  34536. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  34537. v := m.total_friend
  34538. if v == nil {
  34539. return
  34540. }
  34541. return *v, true
  34542. }
  34543. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  34544. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34545. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34546. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  34547. if !m.op.Is(OpUpdateOne) {
  34548. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  34549. }
  34550. if m.id == nil || m.oldValue == nil {
  34551. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  34552. }
  34553. oldValue, err := m.oldValue(ctx)
  34554. if err != nil {
  34555. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  34556. }
  34557. return oldValue.TotalFriend, nil
  34558. }
  34559. // AddTotalFriend adds u to the "total_friend" field.
  34560. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  34561. if m.addtotal_friend != nil {
  34562. *m.addtotal_friend += u
  34563. } else {
  34564. m.addtotal_friend = &u
  34565. }
  34566. }
  34567. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  34568. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  34569. v := m.addtotal_friend
  34570. if v == nil {
  34571. return
  34572. }
  34573. return *v, true
  34574. }
  34575. // ResetTotalFriend resets all changes to the "total_friend" field.
  34576. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  34577. m.total_friend = nil
  34578. m.addtotal_friend = nil
  34579. }
  34580. // SetTotalGroup sets the "total_group" field.
  34581. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  34582. m.total_group = &u
  34583. m.addtotal_group = nil
  34584. }
  34585. // TotalGroup returns the value of the "total_group" field in the mutation.
  34586. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  34587. v := m.total_group
  34588. if v == nil {
  34589. return
  34590. }
  34591. return *v, true
  34592. }
  34593. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  34594. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34595. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34596. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  34597. if !m.op.Is(OpUpdateOne) {
  34598. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  34599. }
  34600. if m.id == nil || m.oldValue == nil {
  34601. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  34602. }
  34603. oldValue, err := m.oldValue(ctx)
  34604. if err != nil {
  34605. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  34606. }
  34607. return oldValue.TotalGroup, nil
  34608. }
  34609. // AddTotalGroup adds u to the "total_group" field.
  34610. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  34611. if m.addtotal_group != nil {
  34612. *m.addtotal_group += u
  34613. } else {
  34614. m.addtotal_group = &u
  34615. }
  34616. }
  34617. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  34618. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  34619. v := m.addtotal_group
  34620. if v == nil {
  34621. return
  34622. }
  34623. return *v, true
  34624. }
  34625. // ResetTotalGroup resets all changes to the "total_group" field.
  34626. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  34627. m.total_group = nil
  34628. m.addtotal_group = nil
  34629. }
  34630. // SetAccountBalance sets the "account_balance" field.
  34631. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  34632. m.account_balance = &u
  34633. m.addaccount_balance = nil
  34634. }
  34635. // AccountBalance returns the value of the "account_balance" field in the mutation.
  34636. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  34637. v := m.account_balance
  34638. if v == nil {
  34639. return
  34640. }
  34641. return *v, true
  34642. }
  34643. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  34644. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34645. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34646. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  34647. if !m.op.Is(OpUpdateOne) {
  34648. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  34649. }
  34650. if m.id == nil || m.oldValue == nil {
  34651. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  34652. }
  34653. oldValue, err := m.oldValue(ctx)
  34654. if err != nil {
  34655. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  34656. }
  34657. return oldValue.AccountBalance, nil
  34658. }
  34659. // AddAccountBalance adds u to the "account_balance" field.
  34660. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  34661. if m.addaccount_balance != nil {
  34662. *m.addaccount_balance += u
  34663. } else {
  34664. m.addaccount_balance = &u
  34665. }
  34666. }
  34667. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  34668. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  34669. v := m.addaccount_balance
  34670. if v == nil {
  34671. return
  34672. }
  34673. return *v, true
  34674. }
  34675. // ResetAccountBalance resets all changes to the "account_balance" field.
  34676. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  34677. m.account_balance = nil
  34678. m.addaccount_balance = nil
  34679. }
  34680. // SetConsumeToken sets the "consume_token" field.
  34681. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  34682. m.consume_token = &u
  34683. m.addconsume_token = nil
  34684. }
  34685. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  34686. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  34687. v := m.consume_token
  34688. if v == nil {
  34689. return
  34690. }
  34691. return *v, true
  34692. }
  34693. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  34694. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34695. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34696. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  34697. if !m.op.Is(OpUpdateOne) {
  34698. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  34699. }
  34700. if m.id == nil || m.oldValue == nil {
  34701. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  34702. }
  34703. oldValue, err := m.oldValue(ctx)
  34704. if err != nil {
  34705. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  34706. }
  34707. return oldValue.ConsumeToken, nil
  34708. }
  34709. // AddConsumeToken adds u to the "consume_token" field.
  34710. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  34711. if m.addconsume_token != nil {
  34712. *m.addconsume_token += u
  34713. } else {
  34714. m.addconsume_token = &u
  34715. }
  34716. }
  34717. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  34718. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  34719. v := m.addconsume_token
  34720. if v == nil {
  34721. return
  34722. }
  34723. return *v, true
  34724. }
  34725. // ResetConsumeToken resets all changes to the "consume_token" field.
  34726. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  34727. m.consume_token = nil
  34728. m.addconsume_token = nil
  34729. }
  34730. // SetActiveUser sets the "active_user" field.
  34731. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  34732. m.active_user = &u
  34733. m.addactive_user = nil
  34734. }
  34735. // ActiveUser returns the value of the "active_user" field in the mutation.
  34736. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  34737. v := m.active_user
  34738. if v == nil {
  34739. return
  34740. }
  34741. return *v, true
  34742. }
  34743. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  34744. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34745. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34746. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  34747. if !m.op.Is(OpUpdateOne) {
  34748. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  34749. }
  34750. if m.id == nil || m.oldValue == nil {
  34751. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  34752. }
  34753. oldValue, err := m.oldValue(ctx)
  34754. if err != nil {
  34755. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  34756. }
  34757. return oldValue.ActiveUser, nil
  34758. }
  34759. // AddActiveUser adds u to the "active_user" field.
  34760. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  34761. if m.addactive_user != nil {
  34762. *m.addactive_user += u
  34763. } else {
  34764. m.addactive_user = &u
  34765. }
  34766. }
  34767. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  34768. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  34769. v := m.addactive_user
  34770. if v == nil {
  34771. return
  34772. }
  34773. return *v, true
  34774. }
  34775. // ResetActiveUser resets all changes to the "active_user" field.
  34776. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  34777. m.active_user = nil
  34778. m.addactive_user = nil
  34779. }
  34780. // SetNewUser sets the "new_user" field.
  34781. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  34782. m.new_user = &i
  34783. m.addnew_user = nil
  34784. }
  34785. // NewUser returns the value of the "new_user" field in the mutation.
  34786. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  34787. v := m.new_user
  34788. if v == nil {
  34789. return
  34790. }
  34791. return *v, true
  34792. }
  34793. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  34794. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34796. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  34797. if !m.op.Is(OpUpdateOne) {
  34798. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  34799. }
  34800. if m.id == nil || m.oldValue == nil {
  34801. return v, errors.New("OldNewUser requires an ID field in the mutation")
  34802. }
  34803. oldValue, err := m.oldValue(ctx)
  34804. if err != nil {
  34805. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  34806. }
  34807. return oldValue.NewUser, nil
  34808. }
  34809. // AddNewUser adds i to the "new_user" field.
  34810. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  34811. if m.addnew_user != nil {
  34812. *m.addnew_user += i
  34813. } else {
  34814. m.addnew_user = &i
  34815. }
  34816. }
  34817. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  34818. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  34819. v := m.addnew_user
  34820. if v == nil {
  34821. return
  34822. }
  34823. return *v, true
  34824. }
  34825. // ResetNewUser resets all changes to the "new_user" field.
  34826. func (m *UsageStatisticDayMutation) ResetNewUser() {
  34827. m.new_user = nil
  34828. m.addnew_user = nil
  34829. }
  34830. // SetLabelDist sets the "label_dist" field.
  34831. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  34832. m.label_dist = &ctd
  34833. m.appendlabel_dist = nil
  34834. }
  34835. // LabelDist returns the value of the "label_dist" field in the mutation.
  34836. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  34837. v := m.label_dist
  34838. if v == nil {
  34839. return
  34840. }
  34841. return *v, true
  34842. }
  34843. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  34844. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34846. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  34847. if !m.op.Is(OpUpdateOne) {
  34848. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  34849. }
  34850. if m.id == nil || m.oldValue == nil {
  34851. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  34852. }
  34853. oldValue, err := m.oldValue(ctx)
  34854. if err != nil {
  34855. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  34856. }
  34857. return oldValue.LabelDist, nil
  34858. }
  34859. // AppendLabelDist adds ctd to the "label_dist" field.
  34860. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  34861. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  34862. }
  34863. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  34864. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  34865. if len(m.appendlabel_dist) == 0 {
  34866. return nil, false
  34867. }
  34868. return m.appendlabel_dist, true
  34869. }
  34870. // ResetLabelDist resets all changes to the "label_dist" field.
  34871. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  34872. m.label_dist = nil
  34873. m.appendlabel_dist = nil
  34874. }
  34875. // SetConsumeCoin sets the "consume_coin" field.
  34876. func (m *UsageStatisticDayMutation) SetConsumeCoin(u uint64) {
  34877. m.consume_coin = &u
  34878. m.addconsume_coin = nil
  34879. }
  34880. // ConsumeCoin returns the value of the "consume_coin" field in the mutation.
  34881. func (m *UsageStatisticDayMutation) ConsumeCoin() (r uint64, exists bool) {
  34882. v := m.consume_coin
  34883. if v == nil {
  34884. return
  34885. }
  34886. return *v, true
  34887. }
  34888. // OldConsumeCoin returns the old "consume_coin" field's value of the UsageStatisticDay entity.
  34889. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34890. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34891. func (m *UsageStatisticDayMutation) OldConsumeCoin(ctx context.Context) (v uint64, err error) {
  34892. if !m.op.Is(OpUpdateOne) {
  34893. return v, errors.New("OldConsumeCoin is only allowed on UpdateOne operations")
  34894. }
  34895. if m.id == nil || m.oldValue == nil {
  34896. return v, errors.New("OldConsumeCoin requires an ID field in the mutation")
  34897. }
  34898. oldValue, err := m.oldValue(ctx)
  34899. if err != nil {
  34900. return v, fmt.Errorf("querying old value for OldConsumeCoin: %w", err)
  34901. }
  34902. return oldValue.ConsumeCoin, nil
  34903. }
  34904. // AddConsumeCoin adds u to the "consume_coin" field.
  34905. func (m *UsageStatisticDayMutation) AddConsumeCoin(u int64) {
  34906. if m.addconsume_coin != nil {
  34907. *m.addconsume_coin += u
  34908. } else {
  34909. m.addconsume_coin = &u
  34910. }
  34911. }
  34912. // AddedConsumeCoin returns the value that was added to the "consume_coin" field in this mutation.
  34913. func (m *UsageStatisticDayMutation) AddedConsumeCoin() (r int64, exists bool) {
  34914. v := m.addconsume_coin
  34915. if v == nil {
  34916. return
  34917. }
  34918. return *v, true
  34919. }
  34920. // ClearConsumeCoin clears the value of the "consume_coin" field.
  34921. func (m *UsageStatisticDayMutation) ClearConsumeCoin() {
  34922. m.consume_coin = nil
  34923. m.addconsume_coin = nil
  34924. m.clearedFields[usagestatisticday.FieldConsumeCoin] = struct{}{}
  34925. }
  34926. // ConsumeCoinCleared returns if the "consume_coin" field was cleared in this mutation.
  34927. func (m *UsageStatisticDayMutation) ConsumeCoinCleared() bool {
  34928. _, ok := m.clearedFields[usagestatisticday.FieldConsumeCoin]
  34929. return ok
  34930. }
  34931. // ResetConsumeCoin resets all changes to the "consume_coin" field.
  34932. func (m *UsageStatisticDayMutation) ResetConsumeCoin() {
  34933. m.consume_coin = nil
  34934. m.addconsume_coin = nil
  34935. delete(m.clearedFields, usagestatisticday.FieldConsumeCoin)
  34936. }
  34937. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  34938. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  34939. m.predicates = append(m.predicates, ps...)
  34940. }
  34941. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  34942. // users can use type-assertion to append predicates that do not depend on any generated package.
  34943. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  34944. p := make([]predicate.UsageStatisticDay, len(ps))
  34945. for i := range ps {
  34946. p[i] = ps[i]
  34947. }
  34948. m.Where(p...)
  34949. }
  34950. // Op returns the operation name.
  34951. func (m *UsageStatisticDayMutation) Op() Op {
  34952. return m.op
  34953. }
  34954. // SetOp allows setting the mutation operation.
  34955. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  34956. m.op = op
  34957. }
  34958. // Type returns the node type of this mutation (UsageStatisticDay).
  34959. func (m *UsageStatisticDayMutation) Type() string {
  34960. return m.typ
  34961. }
  34962. // Fields returns all fields that were changed during this mutation. Note that in
  34963. // order to get all numeric fields that were incremented/decremented, call
  34964. // AddedFields().
  34965. func (m *UsageStatisticDayMutation) Fields() []string {
  34966. fields := make([]string, 0, 18)
  34967. if m.created_at != nil {
  34968. fields = append(fields, usagestatisticday.FieldCreatedAt)
  34969. }
  34970. if m.updated_at != nil {
  34971. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  34972. }
  34973. if m.status != nil {
  34974. fields = append(fields, usagestatisticday.FieldStatus)
  34975. }
  34976. if m.deleted_at != nil {
  34977. fields = append(fields, usagestatisticday.FieldDeletedAt)
  34978. }
  34979. if m.addtime != nil {
  34980. fields = append(fields, usagestatisticday.FieldAddtime)
  34981. }
  34982. if m._type != nil {
  34983. fields = append(fields, usagestatisticday.FieldType)
  34984. }
  34985. if m.bot_id != nil {
  34986. fields = append(fields, usagestatisticday.FieldBotID)
  34987. }
  34988. if m.organization_id != nil {
  34989. fields = append(fields, usagestatisticday.FieldOrganizationID)
  34990. }
  34991. if m.ai_response != nil {
  34992. fields = append(fields, usagestatisticday.FieldAiResponse)
  34993. }
  34994. if m.sop_run != nil {
  34995. fields = append(fields, usagestatisticday.FieldSopRun)
  34996. }
  34997. if m.total_friend != nil {
  34998. fields = append(fields, usagestatisticday.FieldTotalFriend)
  34999. }
  35000. if m.total_group != nil {
  35001. fields = append(fields, usagestatisticday.FieldTotalGroup)
  35002. }
  35003. if m.account_balance != nil {
  35004. fields = append(fields, usagestatisticday.FieldAccountBalance)
  35005. }
  35006. if m.consume_token != nil {
  35007. fields = append(fields, usagestatisticday.FieldConsumeToken)
  35008. }
  35009. if m.active_user != nil {
  35010. fields = append(fields, usagestatisticday.FieldActiveUser)
  35011. }
  35012. if m.new_user != nil {
  35013. fields = append(fields, usagestatisticday.FieldNewUser)
  35014. }
  35015. if m.label_dist != nil {
  35016. fields = append(fields, usagestatisticday.FieldLabelDist)
  35017. }
  35018. if m.consume_coin != nil {
  35019. fields = append(fields, usagestatisticday.FieldConsumeCoin)
  35020. }
  35021. return fields
  35022. }
  35023. // Field returns the value of a field with the given name. The second boolean
  35024. // return value indicates that this field was not set, or was not defined in the
  35025. // schema.
  35026. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  35027. switch name {
  35028. case usagestatisticday.FieldCreatedAt:
  35029. return m.CreatedAt()
  35030. case usagestatisticday.FieldUpdatedAt:
  35031. return m.UpdatedAt()
  35032. case usagestatisticday.FieldStatus:
  35033. return m.Status()
  35034. case usagestatisticday.FieldDeletedAt:
  35035. return m.DeletedAt()
  35036. case usagestatisticday.FieldAddtime:
  35037. return m.Addtime()
  35038. case usagestatisticday.FieldType:
  35039. return m.GetType()
  35040. case usagestatisticday.FieldBotID:
  35041. return m.BotID()
  35042. case usagestatisticday.FieldOrganizationID:
  35043. return m.OrganizationID()
  35044. case usagestatisticday.FieldAiResponse:
  35045. return m.AiResponse()
  35046. case usagestatisticday.FieldSopRun:
  35047. return m.SopRun()
  35048. case usagestatisticday.FieldTotalFriend:
  35049. return m.TotalFriend()
  35050. case usagestatisticday.FieldTotalGroup:
  35051. return m.TotalGroup()
  35052. case usagestatisticday.FieldAccountBalance:
  35053. return m.AccountBalance()
  35054. case usagestatisticday.FieldConsumeToken:
  35055. return m.ConsumeToken()
  35056. case usagestatisticday.FieldActiveUser:
  35057. return m.ActiveUser()
  35058. case usagestatisticday.FieldNewUser:
  35059. return m.NewUser()
  35060. case usagestatisticday.FieldLabelDist:
  35061. return m.LabelDist()
  35062. case usagestatisticday.FieldConsumeCoin:
  35063. return m.ConsumeCoin()
  35064. }
  35065. return nil, false
  35066. }
  35067. // OldField returns the old value of the field from the database. An error is
  35068. // returned if the mutation operation is not UpdateOne, or the query to the
  35069. // database failed.
  35070. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  35071. switch name {
  35072. case usagestatisticday.FieldCreatedAt:
  35073. return m.OldCreatedAt(ctx)
  35074. case usagestatisticday.FieldUpdatedAt:
  35075. return m.OldUpdatedAt(ctx)
  35076. case usagestatisticday.FieldStatus:
  35077. return m.OldStatus(ctx)
  35078. case usagestatisticday.FieldDeletedAt:
  35079. return m.OldDeletedAt(ctx)
  35080. case usagestatisticday.FieldAddtime:
  35081. return m.OldAddtime(ctx)
  35082. case usagestatisticday.FieldType:
  35083. return m.OldType(ctx)
  35084. case usagestatisticday.FieldBotID:
  35085. return m.OldBotID(ctx)
  35086. case usagestatisticday.FieldOrganizationID:
  35087. return m.OldOrganizationID(ctx)
  35088. case usagestatisticday.FieldAiResponse:
  35089. return m.OldAiResponse(ctx)
  35090. case usagestatisticday.FieldSopRun:
  35091. return m.OldSopRun(ctx)
  35092. case usagestatisticday.FieldTotalFriend:
  35093. return m.OldTotalFriend(ctx)
  35094. case usagestatisticday.FieldTotalGroup:
  35095. return m.OldTotalGroup(ctx)
  35096. case usagestatisticday.FieldAccountBalance:
  35097. return m.OldAccountBalance(ctx)
  35098. case usagestatisticday.FieldConsumeToken:
  35099. return m.OldConsumeToken(ctx)
  35100. case usagestatisticday.FieldActiveUser:
  35101. return m.OldActiveUser(ctx)
  35102. case usagestatisticday.FieldNewUser:
  35103. return m.OldNewUser(ctx)
  35104. case usagestatisticday.FieldLabelDist:
  35105. return m.OldLabelDist(ctx)
  35106. case usagestatisticday.FieldConsumeCoin:
  35107. return m.OldConsumeCoin(ctx)
  35108. }
  35109. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  35110. }
  35111. // SetField sets the value of a field with the given name. It returns an error if
  35112. // the field is not defined in the schema, or if the type mismatched the field
  35113. // type.
  35114. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  35115. switch name {
  35116. case usagestatisticday.FieldCreatedAt:
  35117. v, ok := value.(time.Time)
  35118. if !ok {
  35119. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35120. }
  35121. m.SetCreatedAt(v)
  35122. return nil
  35123. case usagestatisticday.FieldUpdatedAt:
  35124. v, ok := value.(time.Time)
  35125. if !ok {
  35126. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35127. }
  35128. m.SetUpdatedAt(v)
  35129. return nil
  35130. case usagestatisticday.FieldStatus:
  35131. v, ok := value.(uint8)
  35132. if !ok {
  35133. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35134. }
  35135. m.SetStatus(v)
  35136. return nil
  35137. case usagestatisticday.FieldDeletedAt:
  35138. v, ok := value.(time.Time)
  35139. if !ok {
  35140. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35141. }
  35142. m.SetDeletedAt(v)
  35143. return nil
  35144. case usagestatisticday.FieldAddtime:
  35145. v, ok := value.(uint64)
  35146. if !ok {
  35147. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35148. }
  35149. m.SetAddtime(v)
  35150. return nil
  35151. case usagestatisticday.FieldType:
  35152. v, ok := value.(int)
  35153. if !ok {
  35154. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35155. }
  35156. m.SetType(v)
  35157. return nil
  35158. case usagestatisticday.FieldBotID:
  35159. v, ok := value.(string)
  35160. if !ok {
  35161. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35162. }
  35163. m.SetBotID(v)
  35164. return nil
  35165. case usagestatisticday.FieldOrganizationID:
  35166. v, ok := value.(uint64)
  35167. if !ok {
  35168. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35169. }
  35170. m.SetOrganizationID(v)
  35171. return nil
  35172. case usagestatisticday.FieldAiResponse:
  35173. v, ok := value.(uint64)
  35174. if !ok {
  35175. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35176. }
  35177. m.SetAiResponse(v)
  35178. return nil
  35179. case usagestatisticday.FieldSopRun:
  35180. v, ok := value.(uint64)
  35181. if !ok {
  35182. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35183. }
  35184. m.SetSopRun(v)
  35185. return nil
  35186. case usagestatisticday.FieldTotalFriend:
  35187. v, ok := value.(uint64)
  35188. if !ok {
  35189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35190. }
  35191. m.SetTotalFriend(v)
  35192. return nil
  35193. case usagestatisticday.FieldTotalGroup:
  35194. v, ok := value.(uint64)
  35195. if !ok {
  35196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35197. }
  35198. m.SetTotalGroup(v)
  35199. return nil
  35200. case usagestatisticday.FieldAccountBalance:
  35201. v, ok := value.(uint64)
  35202. if !ok {
  35203. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35204. }
  35205. m.SetAccountBalance(v)
  35206. return nil
  35207. case usagestatisticday.FieldConsumeToken:
  35208. v, ok := value.(uint64)
  35209. if !ok {
  35210. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35211. }
  35212. m.SetConsumeToken(v)
  35213. return nil
  35214. case usagestatisticday.FieldActiveUser:
  35215. v, ok := value.(uint64)
  35216. if !ok {
  35217. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35218. }
  35219. m.SetActiveUser(v)
  35220. return nil
  35221. case usagestatisticday.FieldNewUser:
  35222. v, ok := value.(int64)
  35223. if !ok {
  35224. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35225. }
  35226. m.SetNewUser(v)
  35227. return nil
  35228. case usagestatisticday.FieldLabelDist:
  35229. v, ok := value.([]custom_types.LabelDist)
  35230. if !ok {
  35231. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35232. }
  35233. m.SetLabelDist(v)
  35234. return nil
  35235. case usagestatisticday.FieldConsumeCoin:
  35236. v, ok := value.(uint64)
  35237. if !ok {
  35238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35239. }
  35240. m.SetConsumeCoin(v)
  35241. return nil
  35242. }
  35243. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  35244. }
  35245. // AddedFields returns all numeric fields that were incremented/decremented during
  35246. // this mutation.
  35247. func (m *UsageStatisticDayMutation) AddedFields() []string {
  35248. var fields []string
  35249. if m.addstatus != nil {
  35250. fields = append(fields, usagestatisticday.FieldStatus)
  35251. }
  35252. if m.addaddtime != nil {
  35253. fields = append(fields, usagestatisticday.FieldAddtime)
  35254. }
  35255. if m.add_type != nil {
  35256. fields = append(fields, usagestatisticday.FieldType)
  35257. }
  35258. if m.addorganization_id != nil {
  35259. fields = append(fields, usagestatisticday.FieldOrganizationID)
  35260. }
  35261. if m.addai_response != nil {
  35262. fields = append(fields, usagestatisticday.FieldAiResponse)
  35263. }
  35264. if m.addsop_run != nil {
  35265. fields = append(fields, usagestatisticday.FieldSopRun)
  35266. }
  35267. if m.addtotal_friend != nil {
  35268. fields = append(fields, usagestatisticday.FieldTotalFriend)
  35269. }
  35270. if m.addtotal_group != nil {
  35271. fields = append(fields, usagestatisticday.FieldTotalGroup)
  35272. }
  35273. if m.addaccount_balance != nil {
  35274. fields = append(fields, usagestatisticday.FieldAccountBalance)
  35275. }
  35276. if m.addconsume_token != nil {
  35277. fields = append(fields, usagestatisticday.FieldConsumeToken)
  35278. }
  35279. if m.addactive_user != nil {
  35280. fields = append(fields, usagestatisticday.FieldActiveUser)
  35281. }
  35282. if m.addnew_user != nil {
  35283. fields = append(fields, usagestatisticday.FieldNewUser)
  35284. }
  35285. if m.addconsume_coin != nil {
  35286. fields = append(fields, usagestatisticday.FieldConsumeCoin)
  35287. }
  35288. return fields
  35289. }
  35290. // AddedField returns the numeric value that was incremented/decremented on a field
  35291. // with the given name. The second boolean return value indicates that this field
  35292. // was not set, or was not defined in the schema.
  35293. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  35294. switch name {
  35295. case usagestatisticday.FieldStatus:
  35296. return m.AddedStatus()
  35297. case usagestatisticday.FieldAddtime:
  35298. return m.AddedAddtime()
  35299. case usagestatisticday.FieldType:
  35300. return m.AddedType()
  35301. case usagestatisticday.FieldOrganizationID:
  35302. return m.AddedOrganizationID()
  35303. case usagestatisticday.FieldAiResponse:
  35304. return m.AddedAiResponse()
  35305. case usagestatisticday.FieldSopRun:
  35306. return m.AddedSopRun()
  35307. case usagestatisticday.FieldTotalFriend:
  35308. return m.AddedTotalFriend()
  35309. case usagestatisticday.FieldTotalGroup:
  35310. return m.AddedTotalGroup()
  35311. case usagestatisticday.FieldAccountBalance:
  35312. return m.AddedAccountBalance()
  35313. case usagestatisticday.FieldConsumeToken:
  35314. return m.AddedConsumeToken()
  35315. case usagestatisticday.FieldActiveUser:
  35316. return m.AddedActiveUser()
  35317. case usagestatisticday.FieldNewUser:
  35318. return m.AddedNewUser()
  35319. case usagestatisticday.FieldConsumeCoin:
  35320. return m.AddedConsumeCoin()
  35321. }
  35322. return nil, false
  35323. }
  35324. // AddField adds the value to the field with the given name. It returns an error if
  35325. // the field is not defined in the schema, or if the type mismatched the field
  35326. // type.
  35327. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  35328. switch name {
  35329. case usagestatisticday.FieldStatus:
  35330. v, ok := value.(int8)
  35331. if !ok {
  35332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35333. }
  35334. m.AddStatus(v)
  35335. return nil
  35336. case usagestatisticday.FieldAddtime:
  35337. v, ok := value.(int64)
  35338. if !ok {
  35339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35340. }
  35341. m.AddAddtime(v)
  35342. return nil
  35343. case usagestatisticday.FieldType:
  35344. v, ok := value.(int)
  35345. if !ok {
  35346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35347. }
  35348. m.AddType(v)
  35349. return nil
  35350. case usagestatisticday.FieldOrganizationID:
  35351. v, ok := value.(int64)
  35352. if !ok {
  35353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35354. }
  35355. m.AddOrganizationID(v)
  35356. return nil
  35357. case usagestatisticday.FieldAiResponse:
  35358. v, ok := value.(int64)
  35359. if !ok {
  35360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35361. }
  35362. m.AddAiResponse(v)
  35363. return nil
  35364. case usagestatisticday.FieldSopRun:
  35365. v, ok := value.(int64)
  35366. if !ok {
  35367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35368. }
  35369. m.AddSopRun(v)
  35370. return nil
  35371. case usagestatisticday.FieldTotalFriend:
  35372. v, ok := value.(int64)
  35373. if !ok {
  35374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35375. }
  35376. m.AddTotalFriend(v)
  35377. return nil
  35378. case usagestatisticday.FieldTotalGroup:
  35379. v, ok := value.(int64)
  35380. if !ok {
  35381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35382. }
  35383. m.AddTotalGroup(v)
  35384. return nil
  35385. case usagestatisticday.FieldAccountBalance:
  35386. v, ok := value.(int64)
  35387. if !ok {
  35388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35389. }
  35390. m.AddAccountBalance(v)
  35391. return nil
  35392. case usagestatisticday.FieldConsumeToken:
  35393. v, ok := value.(int64)
  35394. if !ok {
  35395. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35396. }
  35397. m.AddConsumeToken(v)
  35398. return nil
  35399. case usagestatisticday.FieldActiveUser:
  35400. v, ok := value.(int64)
  35401. if !ok {
  35402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35403. }
  35404. m.AddActiveUser(v)
  35405. return nil
  35406. case usagestatisticday.FieldNewUser:
  35407. v, ok := value.(int64)
  35408. if !ok {
  35409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35410. }
  35411. m.AddNewUser(v)
  35412. return nil
  35413. case usagestatisticday.FieldConsumeCoin:
  35414. v, ok := value.(int64)
  35415. if !ok {
  35416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35417. }
  35418. m.AddConsumeCoin(v)
  35419. return nil
  35420. }
  35421. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  35422. }
  35423. // ClearedFields returns all nullable fields that were cleared during this
  35424. // mutation.
  35425. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  35426. var fields []string
  35427. if m.FieldCleared(usagestatisticday.FieldStatus) {
  35428. fields = append(fields, usagestatisticday.FieldStatus)
  35429. }
  35430. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  35431. fields = append(fields, usagestatisticday.FieldDeletedAt)
  35432. }
  35433. if m.FieldCleared(usagestatisticday.FieldBotID) {
  35434. fields = append(fields, usagestatisticday.FieldBotID)
  35435. }
  35436. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  35437. fields = append(fields, usagestatisticday.FieldOrganizationID)
  35438. }
  35439. if m.FieldCleared(usagestatisticday.FieldConsumeCoin) {
  35440. fields = append(fields, usagestatisticday.FieldConsumeCoin)
  35441. }
  35442. return fields
  35443. }
  35444. // FieldCleared returns a boolean indicating if a field with the given name was
  35445. // cleared in this mutation.
  35446. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  35447. _, ok := m.clearedFields[name]
  35448. return ok
  35449. }
  35450. // ClearField clears the value of the field with the given name. It returns an
  35451. // error if the field is not defined in the schema.
  35452. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  35453. switch name {
  35454. case usagestatisticday.FieldStatus:
  35455. m.ClearStatus()
  35456. return nil
  35457. case usagestatisticday.FieldDeletedAt:
  35458. m.ClearDeletedAt()
  35459. return nil
  35460. case usagestatisticday.FieldBotID:
  35461. m.ClearBotID()
  35462. return nil
  35463. case usagestatisticday.FieldOrganizationID:
  35464. m.ClearOrganizationID()
  35465. return nil
  35466. case usagestatisticday.FieldConsumeCoin:
  35467. m.ClearConsumeCoin()
  35468. return nil
  35469. }
  35470. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  35471. }
  35472. // ResetField resets all changes in the mutation for the field with the given name.
  35473. // It returns an error if the field is not defined in the schema.
  35474. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  35475. switch name {
  35476. case usagestatisticday.FieldCreatedAt:
  35477. m.ResetCreatedAt()
  35478. return nil
  35479. case usagestatisticday.FieldUpdatedAt:
  35480. m.ResetUpdatedAt()
  35481. return nil
  35482. case usagestatisticday.FieldStatus:
  35483. m.ResetStatus()
  35484. return nil
  35485. case usagestatisticday.FieldDeletedAt:
  35486. m.ResetDeletedAt()
  35487. return nil
  35488. case usagestatisticday.FieldAddtime:
  35489. m.ResetAddtime()
  35490. return nil
  35491. case usagestatisticday.FieldType:
  35492. m.ResetType()
  35493. return nil
  35494. case usagestatisticday.FieldBotID:
  35495. m.ResetBotID()
  35496. return nil
  35497. case usagestatisticday.FieldOrganizationID:
  35498. m.ResetOrganizationID()
  35499. return nil
  35500. case usagestatisticday.FieldAiResponse:
  35501. m.ResetAiResponse()
  35502. return nil
  35503. case usagestatisticday.FieldSopRun:
  35504. m.ResetSopRun()
  35505. return nil
  35506. case usagestatisticday.FieldTotalFriend:
  35507. m.ResetTotalFriend()
  35508. return nil
  35509. case usagestatisticday.FieldTotalGroup:
  35510. m.ResetTotalGroup()
  35511. return nil
  35512. case usagestatisticday.FieldAccountBalance:
  35513. m.ResetAccountBalance()
  35514. return nil
  35515. case usagestatisticday.FieldConsumeToken:
  35516. m.ResetConsumeToken()
  35517. return nil
  35518. case usagestatisticday.FieldActiveUser:
  35519. m.ResetActiveUser()
  35520. return nil
  35521. case usagestatisticday.FieldNewUser:
  35522. m.ResetNewUser()
  35523. return nil
  35524. case usagestatisticday.FieldLabelDist:
  35525. m.ResetLabelDist()
  35526. return nil
  35527. case usagestatisticday.FieldConsumeCoin:
  35528. m.ResetConsumeCoin()
  35529. return nil
  35530. }
  35531. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  35532. }
  35533. // AddedEdges returns all edge names that were set/added in this mutation.
  35534. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  35535. edges := make([]string, 0, 0)
  35536. return edges
  35537. }
  35538. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35539. // name in this mutation.
  35540. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  35541. return nil
  35542. }
  35543. // RemovedEdges returns all edge names that were removed in this mutation.
  35544. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  35545. edges := make([]string, 0, 0)
  35546. return edges
  35547. }
  35548. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  35549. // the given name in this mutation.
  35550. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  35551. return nil
  35552. }
  35553. // ClearedEdges returns all edge names that were cleared in this mutation.
  35554. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  35555. edges := make([]string, 0, 0)
  35556. return edges
  35557. }
  35558. // EdgeCleared returns a boolean which indicates if the edge with the given name
  35559. // was cleared in this mutation.
  35560. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  35561. return false
  35562. }
  35563. // ClearEdge clears the value of the edge with the given name. It returns an error
  35564. // if that edge is not defined in the schema.
  35565. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  35566. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  35567. }
  35568. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35569. // It returns an error if the edge is not defined in the schema.
  35570. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  35571. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  35572. }
  35573. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  35574. type UsageStatisticHourMutation struct {
  35575. config
  35576. op Op
  35577. typ string
  35578. id *uint64
  35579. created_at *time.Time
  35580. updated_at *time.Time
  35581. status *uint8
  35582. addstatus *int8
  35583. deleted_at *time.Time
  35584. addtime *uint64
  35585. addaddtime *int64
  35586. _type *int
  35587. add_type *int
  35588. bot_id *string
  35589. organization_id *uint64
  35590. addorganization_id *int64
  35591. ai_response *uint64
  35592. addai_response *int64
  35593. sop_run *uint64
  35594. addsop_run *int64
  35595. total_friend *uint64
  35596. addtotal_friend *int64
  35597. total_group *uint64
  35598. addtotal_group *int64
  35599. account_balance *uint64
  35600. addaccount_balance *int64
  35601. consume_token *uint64
  35602. addconsume_token *int64
  35603. active_user *uint64
  35604. addactive_user *int64
  35605. new_user *int64
  35606. addnew_user *int64
  35607. label_dist *[]custom_types.LabelDist
  35608. appendlabel_dist []custom_types.LabelDist
  35609. consume_coin *uint64
  35610. addconsume_coin *int64
  35611. clearedFields map[string]struct{}
  35612. done bool
  35613. oldValue func(context.Context) (*UsageStatisticHour, error)
  35614. predicates []predicate.UsageStatisticHour
  35615. }
  35616. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  35617. // usagestatistichourOption allows management of the mutation configuration using functional options.
  35618. type usagestatistichourOption func(*UsageStatisticHourMutation)
  35619. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  35620. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  35621. m := &UsageStatisticHourMutation{
  35622. config: c,
  35623. op: op,
  35624. typ: TypeUsageStatisticHour,
  35625. clearedFields: make(map[string]struct{}),
  35626. }
  35627. for _, opt := range opts {
  35628. opt(m)
  35629. }
  35630. return m
  35631. }
  35632. // withUsageStatisticHourID sets the ID field of the mutation.
  35633. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  35634. return func(m *UsageStatisticHourMutation) {
  35635. var (
  35636. err error
  35637. once sync.Once
  35638. value *UsageStatisticHour
  35639. )
  35640. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  35641. once.Do(func() {
  35642. if m.done {
  35643. err = errors.New("querying old values post mutation is not allowed")
  35644. } else {
  35645. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  35646. }
  35647. })
  35648. return value, err
  35649. }
  35650. m.id = &id
  35651. }
  35652. }
  35653. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  35654. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  35655. return func(m *UsageStatisticHourMutation) {
  35656. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  35657. return node, nil
  35658. }
  35659. m.id = &node.ID
  35660. }
  35661. }
  35662. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35663. // executed in a transaction (ent.Tx), a transactional client is returned.
  35664. func (m UsageStatisticHourMutation) Client() *Client {
  35665. client := &Client{config: m.config}
  35666. client.init()
  35667. return client
  35668. }
  35669. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35670. // it returns an error otherwise.
  35671. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  35672. if _, ok := m.driver.(*txDriver); !ok {
  35673. return nil, errors.New("ent: mutation is not running in a transaction")
  35674. }
  35675. tx := &Tx{config: m.config}
  35676. tx.init()
  35677. return tx, nil
  35678. }
  35679. // SetID sets the value of the id field. Note that this
  35680. // operation is only accepted on creation of UsageStatisticHour entities.
  35681. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  35682. m.id = &id
  35683. }
  35684. // ID returns the ID value in the mutation. Note that the ID is only available
  35685. // if it was provided to the builder or after it was returned from the database.
  35686. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  35687. if m.id == nil {
  35688. return
  35689. }
  35690. return *m.id, true
  35691. }
  35692. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35693. // That means, if the mutation is applied within a transaction with an isolation level such
  35694. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35695. // or updated by the mutation.
  35696. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  35697. switch {
  35698. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35699. id, exists := m.ID()
  35700. if exists {
  35701. return []uint64{id}, nil
  35702. }
  35703. fallthrough
  35704. case m.op.Is(OpUpdate | OpDelete):
  35705. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  35706. default:
  35707. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  35708. }
  35709. }
  35710. // SetCreatedAt sets the "created_at" field.
  35711. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  35712. m.created_at = &t
  35713. }
  35714. // CreatedAt returns the value of the "created_at" field in the mutation.
  35715. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  35716. v := m.created_at
  35717. if v == nil {
  35718. return
  35719. }
  35720. return *v, true
  35721. }
  35722. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  35723. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  35724. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35725. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  35726. if !m.op.Is(OpUpdateOne) {
  35727. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  35728. }
  35729. if m.id == nil || m.oldValue == nil {
  35730. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  35731. }
  35732. oldValue, err := m.oldValue(ctx)
  35733. if err != nil {
  35734. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  35735. }
  35736. return oldValue.CreatedAt, nil
  35737. }
  35738. // ResetCreatedAt resets all changes to the "created_at" field.
  35739. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  35740. m.created_at = nil
  35741. }
  35742. // SetUpdatedAt sets the "updated_at" field.
  35743. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  35744. m.updated_at = &t
  35745. }
  35746. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  35747. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  35748. v := m.updated_at
  35749. if v == nil {
  35750. return
  35751. }
  35752. return *v, true
  35753. }
  35754. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  35755. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  35756. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35757. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35758. if !m.op.Is(OpUpdateOne) {
  35759. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35760. }
  35761. if m.id == nil || m.oldValue == nil {
  35762. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35763. }
  35764. oldValue, err := m.oldValue(ctx)
  35765. if err != nil {
  35766. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35767. }
  35768. return oldValue.UpdatedAt, nil
  35769. }
  35770. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35771. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  35772. m.updated_at = nil
  35773. }
  35774. // SetStatus sets the "status" field.
  35775. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  35776. m.status = &u
  35777. m.addstatus = nil
  35778. }
  35779. // Status returns the value of the "status" field in the mutation.
  35780. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  35781. v := m.status
  35782. if v == nil {
  35783. return
  35784. }
  35785. return *v, true
  35786. }
  35787. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  35788. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  35789. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35790. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  35791. if !m.op.Is(OpUpdateOne) {
  35792. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  35793. }
  35794. if m.id == nil || m.oldValue == nil {
  35795. return v, errors.New("OldStatus requires an ID field in the mutation")
  35796. }
  35797. oldValue, err := m.oldValue(ctx)
  35798. if err != nil {
  35799. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  35800. }
  35801. return oldValue.Status, nil
  35802. }
  35803. // AddStatus adds u to the "status" field.
  35804. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  35805. if m.addstatus != nil {
  35806. *m.addstatus += u
  35807. } else {
  35808. m.addstatus = &u
  35809. }
  35810. }
  35811. // AddedStatus returns the value that was added to the "status" field in this mutation.
  35812. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  35813. v := m.addstatus
  35814. if v == nil {
  35815. return
  35816. }
  35817. return *v, true
  35818. }
  35819. // ClearStatus clears the value of the "status" field.
  35820. func (m *UsageStatisticHourMutation) ClearStatus() {
  35821. m.status = nil
  35822. m.addstatus = nil
  35823. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  35824. }
  35825. // StatusCleared returns if the "status" field was cleared in this mutation.
  35826. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  35827. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  35828. return ok
  35829. }
  35830. // ResetStatus resets all changes to the "status" field.
  35831. func (m *UsageStatisticHourMutation) ResetStatus() {
  35832. m.status = nil
  35833. m.addstatus = nil
  35834. delete(m.clearedFields, usagestatistichour.FieldStatus)
  35835. }
  35836. // SetDeletedAt sets the "deleted_at" field.
  35837. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  35838. m.deleted_at = &t
  35839. }
  35840. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  35841. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  35842. v := m.deleted_at
  35843. if v == nil {
  35844. return
  35845. }
  35846. return *v, true
  35847. }
  35848. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  35849. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  35850. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35851. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  35852. if !m.op.Is(OpUpdateOne) {
  35853. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  35854. }
  35855. if m.id == nil || m.oldValue == nil {
  35856. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  35857. }
  35858. oldValue, err := m.oldValue(ctx)
  35859. if err != nil {
  35860. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  35861. }
  35862. return oldValue.DeletedAt, nil
  35863. }
  35864. // ClearDeletedAt clears the value of the "deleted_at" field.
  35865. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  35866. m.deleted_at = nil
  35867. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  35868. }
  35869. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  35870. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  35871. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  35872. return ok
  35873. }
  35874. // ResetDeletedAt resets all changes to the "deleted_at" field.
  35875. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  35876. m.deleted_at = nil
  35877. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  35878. }
  35879. // SetAddtime sets the "addtime" field.
  35880. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  35881. m.addtime = &u
  35882. m.addaddtime = nil
  35883. }
  35884. // Addtime returns the value of the "addtime" field in the mutation.
  35885. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  35886. v := m.addtime
  35887. if v == nil {
  35888. return
  35889. }
  35890. return *v, true
  35891. }
  35892. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  35893. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  35894. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35895. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  35896. if !m.op.Is(OpUpdateOne) {
  35897. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  35898. }
  35899. if m.id == nil || m.oldValue == nil {
  35900. return v, errors.New("OldAddtime requires an ID field in the mutation")
  35901. }
  35902. oldValue, err := m.oldValue(ctx)
  35903. if err != nil {
  35904. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  35905. }
  35906. return oldValue.Addtime, nil
  35907. }
  35908. // AddAddtime adds u to the "addtime" field.
  35909. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  35910. if m.addaddtime != nil {
  35911. *m.addaddtime += u
  35912. } else {
  35913. m.addaddtime = &u
  35914. }
  35915. }
  35916. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  35917. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  35918. v := m.addaddtime
  35919. if v == nil {
  35920. return
  35921. }
  35922. return *v, true
  35923. }
  35924. // ResetAddtime resets all changes to the "addtime" field.
  35925. func (m *UsageStatisticHourMutation) ResetAddtime() {
  35926. m.addtime = nil
  35927. m.addaddtime = nil
  35928. }
  35929. // SetType sets the "type" field.
  35930. func (m *UsageStatisticHourMutation) SetType(i int) {
  35931. m._type = &i
  35932. m.add_type = nil
  35933. }
  35934. // GetType returns the value of the "type" field in the mutation.
  35935. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  35936. v := m._type
  35937. if v == nil {
  35938. return
  35939. }
  35940. return *v, true
  35941. }
  35942. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  35943. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  35944. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35945. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  35946. if !m.op.Is(OpUpdateOne) {
  35947. return v, errors.New("OldType is only allowed on UpdateOne operations")
  35948. }
  35949. if m.id == nil || m.oldValue == nil {
  35950. return v, errors.New("OldType requires an ID field in the mutation")
  35951. }
  35952. oldValue, err := m.oldValue(ctx)
  35953. if err != nil {
  35954. return v, fmt.Errorf("querying old value for OldType: %w", err)
  35955. }
  35956. return oldValue.Type, nil
  35957. }
  35958. // AddType adds i to the "type" field.
  35959. func (m *UsageStatisticHourMutation) AddType(i int) {
  35960. if m.add_type != nil {
  35961. *m.add_type += i
  35962. } else {
  35963. m.add_type = &i
  35964. }
  35965. }
  35966. // AddedType returns the value that was added to the "type" field in this mutation.
  35967. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  35968. v := m.add_type
  35969. if v == nil {
  35970. return
  35971. }
  35972. return *v, true
  35973. }
  35974. // ResetType resets all changes to the "type" field.
  35975. func (m *UsageStatisticHourMutation) ResetType() {
  35976. m._type = nil
  35977. m.add_type = nil
  35978. }
  35979. // SetBotID sets the "bot_id" field.
  35980. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  35981. m.bot_id = &s
  35982. }
  35983. // BotID returns the value of the "bot_id" field in the mutation.
  35984. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  35985. v := m.bot_id
  35986. if v == nil {
  35987. return
  35988. }
  35989. return *v, true
  35990. }
  35991. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  35992. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  35993. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35994. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  35995. if !m.op.Is(OpUpdateOne) {
  35996. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  35997. }
  35998. if m.id == nil || m.oldValue == nil {
  35999. return v, errors.New("OldBotID requires an ID field in the mutation")
  36000. }
  36001. oldValue, err := m.oldValue(ctx)
  36002. if err != nil {
  36003. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  36004. }
  36005. return oldValue.BotID, nil
  36006. }
  36007. // ClearBotID clears the value of the "bot_id" field.
  36008. func (m *UsageStatisticHourMutation) ClearBotID() {
  36009. m.bot_id = nil
  36010. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  36011. }
  36012. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  36013. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  36014. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  36015. return ok
  36016. }
  36017. // ResetBotID resets all changes to the "bot_id" field.
  36018. func (m *UsageStatisticHourMutation) ResetBotID() {
  36019. m.bot_id = nil
  36020. delete(m.clearedFields, usagestatistichour.FieldBotID)
  36021. }
  36022. // SetOrganizationID sets the "organization_id" field.
  36023. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  36024. m.organization_id = &u
  36025. m.addorganization_id = nil
  36026. }
  36027. // OrganizationID returns the value of the "organization_id" field in the mutation.
  36028. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  36029. v := m.organization_id
  36030. if v == nil {
  36031. return
  36032. }
  36033. return *v, true
  36034. }
  36035. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  36036. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36037. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36038. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  36039. if !m.op.Is(OpUpdateOne) {
  36040. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  36041. }
  36042. if m.id == nil || m.oldValue == nil {
  36043. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  36044. }
  36045. oldValue, err := m.oldValue(ctx)
  36046. if err != nil {
  36047. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  36048. }
  36049. return oldValue.OrganizationID, nil
  36050. }
  36051. // AddOrganizationID adds u to the "organization_id" field.
  36052. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  36053. if m.addorganization_id != nil {
  36054. *m.addorganization_id += u
  36055. } else {
  36056. m.addorganization_id = &u
  36057. }
  36058. }
  36059. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  36060. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  36061. v := m.addorganization_id
  36062. if v == nil {
  36063. return
  36064. }
  36065. return *v, true
  36066. }
  36067. // ClearOrganizationID clears the value of the "organization_id" field.
  36068. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  36069. m.organization_id = nil
  36070. m.addorganization_id = nil
  36071. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  36072. }
  36073. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  36074. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  36075. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  36076. return ok
  36077. }
  36078. // ResetOrganizationID resets all changes to the "organization_id" field.
  36079. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  36080. m.organization_id = nil
  36081. m.addorganization_id = nil
  36082. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  36083. }
  36084. // SetAiResponse sets the "ai_response" field.
  36085. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  36086. m.ai_response = &u
  36087. m.addai_response = nil
  36088. }
  36089. // AiResponse returns the value of the "ai_response" field in the mutation.
  36090. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  36091. v := m.ai_response
  36092. if v == nil {
  36093. return
  36094. }
  36095. return *v, true
  36096. }
  36097. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  36098. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36099. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36100. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  36101. if !m.op.Is(OpUpdateOne) {
  36102. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  36103. }
  36104. if m.id == nil || m.oldValue == nil {
  36105. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  36106. }
  36107. oldValue, err := m.oldValue(ctx)
  36108. if err != nil {
  36109. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  36110. }
  36111. return oldValue.AiResponse, nil
  36112. }
  36113. // AddAiResponse adds u to the "ai_response" field.
  36114. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  36115. if m.addai_response != nil {
  36116. *m.addai_response += u
  36117. } else {
  36118. m.addai_response = &u
  36119. }
  36120. }
  36121. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  36122. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  36123. v := m.addai_response
  36124. if v == nil {
  36125. return
  36126. }
  36127. return *v, true
  36128. }
  36129. // ResetAiResponse resets all changes to the "ai_response" field.
  36130. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  36131. m.ai_response = nil
  36132. m.addai_response = nil
  36133. }
  36134. // SetSopRun sets the "sop_run" field.
  36135. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  36136. m.sop_run = &u
  36137. m.addsop_run = nil
  36138. }
  36139. // SopRun returns the value of the "sop_run" field in the mutation.
  36140. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  36141. v := m.sop_run
  36142. if v == nil {
  36143. return
  36144. }
  36145. return *v, true
  36146. }
  36147. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  36148. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36149. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36150. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  36151. if !m.op.Is(OpUpdateOne) {
  36152. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  36153. }
  36154. if m.id == nil || m.oldValue == nil {
  36155. return v, errors.New("OldSopRun requires an ID field in the mutation")
  36156. }
  36157. oldValue, err := m.oldValue(ctx)
  36158. if err != nil {
  36159. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  36160. }
  36161. return oldValue.SopRun, nil
  36162. }
  36163. // AddSopRun adds u to the "sop_run" field.
  36164. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  36165. if m.addsop_run != nil {
  36166. *m.addsop_run += u
  36167. } else {
  36168. m.addsop_run = &u
  36169. }
  36170. }
  36171. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  36172. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  36173. v := m.addsop_run
  36174. if v == nil {
  36175. return
  36176. }
  36177. return *v, true
  36178. }
  36179. // ResetSopRun resets all changes to the "sop_run" field.
  36180. func (m *UsageStatisticHourMutation) ResetSopRun() {
  36181. m.sop_run = nil
  36182. m.addsop_run = nil
  36183. }
  36184. // SetTotalFriend sets the "total_friend" field.
  36185. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  36186. m.total_friend = &u
  36187. m.addtotal_friend = nil
  36188. }
  36189. // TotalFriend returns the value of the "total_friend" field in the mutation.
  36190. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  36191. v := m.total_friend
  36192. if v == nil {
  36193. return
  36194. }
  36195. return *v, true
  36196. }
  36197. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  36198. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36199. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36200. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  36201. if !m.op.Is(OpUpdateOne) {
  36202. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  36203. }
  36204. if m.id == nil || m.oldValue == nil {
  36205. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  36206. }
  36207. oldValue, err := m.oldValue(ctx)
  36208. if err != nil {
  36209. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  36210. }
  36211. return oldValue.TotalFriend, nil
  36212. }
  36213. // AddTotalFriend adds u to the "total_friend" field.
  36214. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  36215. if m.addtotal_friend != nil {
  36216. *m.addtotal_friend += u
  36217. } else {
  36218. m.addtotal_friend = &u
  36219. }
  36220. }
  36221. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  36222. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  36223. v := m.addtotal_friend
  36224. if v == nil {
  36225. return
  36226. }
  36227. return *v, true
  36228. }
  36229. // ResetTotalFriend resets all changes to the "total_friend" field.
  36230. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  36231. m.total_friend = nil
  36232. m.addtotal_friend = nil
  36233. }
  36234. // SetTotalGroup sets the "total_group" field.
  36235. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  36236. m.total_group = &u
  36237. m.addtotal_group = nil
  36238. }
  36239. // TotalGroup returns the value of the "total_group" field in the mutation.
  36240. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  36241. v := m.total_group
  36242. if v == nil {
  36243. return
  36244. }
  36245. return *v, true
  36246. }
  36247. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  36248. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36249. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36250. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  36251. if !m.op.Is(OpUpdateOne) {
  36252. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  36253. }
  36254. if m.id == nil || m.oldValue == nil {
  36255. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  36256. }
  36257. oldValue, err := m.oldValue(ctx)
  36258. if err != nil {
  36259. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  36260. }
  36261. return oldValue.TotalGroup, nil
  36262. }
  36263. // AddTotalGroup adds u to the "total_group" field.
  36264. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  36265. if m.addtotal_group != nil {
  36266. *m.addtotal_group += u
  36267. } else {
  36268. m.addtotal_group = &u
  36269. }
  36270. }
  36271. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  36272. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  36273. v := m.addtotal_group
  36274. if v == nil {
  36275. return
  36276. }
  36277. return *v, true
  36278. }
  36279. // ResetTotalGroup resets all changes to the "total_group" field.
  36280. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  36281. m.total_group = nil
  36282. m.addtotal_group = nil
  36283. }
  36284. // SetAccountBalance sets the "account_balance" field.
  36285. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  36286. m.account_balance = &u
  36287. m.addaccount_balance = nil
  36288. }
  36289. // AccountBalance returns the value of the "account_balance" field in the mutation.
  36290. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  36291. v := m.account_balance
  36292. if v == nil {
  36293. return
  36294. }
  36295. return *v, true
  36296. }
  36297. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  36298. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36299. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36300. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  36301. if !m.op.Is(OpUpdateOne) {
  36302. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  36303. }
  36304. if m.id == nil || m.oldValue == nil {
  36305. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  36306. }
  36307. oldValue, err := m.oldValue(ctx)
  36308. if err != nil {
  36309. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  36310. }
  36311. return oldValue.AccountBalance, nil
  36312. }
  36313. // AddAccountBalance adds u to the "account_balance" field.
  36314. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  36315. if m.addaccount_balance != nil {
  36316. *m.addaccount_balance += u
  36317. } else {
  36318. m.addaccount_balance = &u
  36319. }
  36320. }
  36321. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  36322. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  36323. v := m.addaccount_balance
  36324. if v == nil {
  36325. return
  36326. }
  36327. return *v, true
  36328. }
  36329. // ResetAccountBalance resets all changes to the "account_balance" field.
  36330. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  36331. m.account_balance = nil
  36332. m.addaccount_balance = nil
  36333. }
  36334. // SetConsumeToken sets the "consume_token" field.
  36335. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  36336. m.consume_token = &u
  36337. m.addconsume_token = nil
  36338. }
  36339. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  36340. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  36341. v := m.consume_token
  36342. if v == nil {
  36343. return
  36344. }
  36345. return *v, true
  36346. }
  36347. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  36348. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36349. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36350. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  36351. if !m.op.Is(OpUpdateOne) {
  36352. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  36353. }
  36354. if m.id == nil || m.oldValue == nil {
  36355. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  36356. }
  36357. oldValue, err := m.oldValue(ctx)
  36358. if err != nil {
  36359. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  36360. }
  36361. return oldValue.ConsumeToken, nil
  36362. }
  36363. // AddConsumeToken adds u to the "consume_token" field.
  36364. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  36365. if m.addconsume_token != nil {
  36366. *m.addconsume_token += u
  36367. } else {
  36368. m.addconsume_token = &u
  36369. }
  36370. }
  36371. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  36372. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  36373. v := m.addconsume_token
  36374. if v == nil {
  36375. return
  36376. }
  36377. return *v, true
  36378. }
  36379. // ResetConsumeToken resets all changes to the "consume_token" field.
  36380. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  36381. m.consume_token = nil
  36382. m.addconsume_token = nil
  36383. }
  36384. // SetActiveUser sets the "active_user" field.
  36385. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  36386. m.active_user = &u
  36387. m.addactive_user = nil
  36388. }
  36389. // ActiveUser returns the value of the "active_user" field in the mutation.
  36390. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  36391. v := m.active_user
  36392. if v == nil {
  36393. return
  36394. }
  36395. return *v, true
  36396. }
  36397. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  36398. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36400. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  36401. if !m.op.Is(OpUpdateOne) {
  36402. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  36403. }
  36404. if m.id == nil || m.oldValue == nil {
  36405. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  36406. }
  36407. oldValue, err := m.oldValue(ctx)
  36408. if err != nil {
  36409. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  36410. }
  36411. return oldValue.ActiveUser, nil
  36412. }
  36413. // AddActiveUser adds u to the "active_user" field.
  36414. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  36415. if m.addactive_user != nil {
  36416. *m.addactive_user += u
  36417. } else {
  36418. m.addactive_user = &u
  36419. }
  36420. }
  36421. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  36422. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  36423. v := m.addactive_user
  36424. if v == nil {
  36425. return
  36426. }
  36427. return *v, true
  36428. }
  36429. // ResetActiveUser resets all changes to the "active_user" field.
  36430. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  36431. m.active_user = nil
  36432. m.addactive_user = nil
  36433. }
  36434. // SetNewUser sets the "new_user" field.
  36435. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  36436. m.new_user = &i
  36437. m.addnew_user = nil
  36438. }
  36439. // NewUser returns the value of the "new_user" field in the mutation.
  36440. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  36441. v := m.new_user
  36442. if v == nil {
  36443. return
  36444. }
  36445. return *v, true
  36446. }
  36447. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  36448. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36450. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  36451. if !m.op.Is(OpUpdateOne) {
  36452. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  36453. }
  36454. if m.id == nil || m.oldValue == nil {
  36455. return v, errors.New("OldNewUser requires an ID field in the mutation")
  36456. }
  36457. oldValue, err := m.oldValue(ctx)
  36458. if err != nil {
  36459. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  36460. }
  36461. return oldValue.NewUser, nil
  36462. }
  36463. // AddNewUser adds i to the "new_user" field.
  36464. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  36465. if m.addnew_user != nil {
  36466. *m.addnew_user += i
  36467. } else {
  36468. m.addnew_user = &i
  36469. }
  36470. }
  36471. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  36472. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  36473. v := m.addnew_user
  36474. if v == nil {
  36475. return
  36476. }
  36477. return *v, true
  36478. }
  36479. // ResetNewUser resets all changes to the "new_user" field.
  36480. func (m *UsageStatisticHourMutation) ResetNewUser() {
  36481. m.new_user = nil
  36482. m.addnew_user = nil
  36483. }
  36484. // SetLabelDist sets the "label_dist" field.
  36485. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  36486. m.label_dist = &ctd
  36487. m.appendlabel_dist = nil
  36488. }
  36489. // LabelDist returns the value of the "label_dist" field in the mutation.
  36490. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  36491. v := m.label_dist
  36492. if v == nil {
  36493. return
  36494. }
  36495. return *v, true
  36496. }
  36497. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  36498. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36499. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36500. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  36501. if !m.op.Is(OpUpdateOne) {
  36502. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  36503. }
  36504. if m.id == nil || m.oldValue == nil {
  36505. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  36506. }
  36507. oldValue, err := m.oldValue(ctx)
  36508. if err != nil {
  36509. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  36510. }
  36511. return oldValue.LabelDist, nil
  36512. }
  36513. // AppendLabelDist adds ctd to the "label_dist" field.
  36514. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  36515. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  36516. }
  36517. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  36518. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  36519. if len(m.appendlabel_dist) == 0 {
  36520. return nil, false
  36521. }
  36522. return m.appendlabel_dist, true
  36523. }
  36524. // ResetLabelDist resets all changes to the "label_dist" field.
  36525. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  36526. m.label_dist = nil
  36527. m.appendlabel_dist = nil
  36528. }
  36529. // SetConsumeCoin sets the "consume_coin" field.
  36530. func (m *UsageStatisticHourMutation) SetConsumeCoin(u uint64) {
  36531. m.consume_coin = &u
  36532. m.addconsume_coin = nil
  36533. }
  36534. // ConsumeCoin returns the value of the "consume_coin" field in the mutation.
  36535. func (m *UsageStatisticHourMutation) ConsumeCoin() (r uint64, exists bool) {
  36536. v := m.consume_coin
  36537. if v == nil {
  36538. return
  36539. }
  36540. return *v, true
  36541. }
  36542. // OldConsumeCoin returns the old "consume_coin" field's value of the UsageStatisticHour entity.
  36543. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36544. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36545. func (m *UsageStatisticHourMutation) OldConsumeCoin(ctx context.Context) (v uint64, err error) {
  36546. if !m.op.Is(OpUpdateOne) {
  36547. return v, errors.New("OldConsumeCoin is only allowed on UpdateOne operations")
  36548. }
  36549. if m.id == nil || m.oldValue == nil {
  36550. return v, errors.New("OldConsumeCoin requires an ID field in the mutation")
  36551. }
  36552. oldValue, err := m.oldValue(ctx)
  36553. if err != nil {
  36554. return v, fmt.Errorf("querying old value for OldConsumeCoin: %w", err)
  36555. }
  36556. return oldValue.ConsumeCoin, nil
  36557. }
  36558. // AddConsumeCoin adds u to the "consume_coin" field.
  36559. func (m *UsageStatisticHourMutation) AddConsumeCoin(u int64) {
  36560. if m.addconsume_coin != nil {
  36561. *m.addconsume_coin += u
  36562. } else {
  36563. m.addconsume_coin = &u
  36564. }
  36565. }
  36566. // AddedConsumeCoin returns the value that was added to the "consume_coin" field in this mutation.
  36567. func (m *UsageStatisticHourMutation) AddedConsumeCoin() (r int64, exists bool) {
  36568. v := m.addconsume_coin
  36569. if v == nil {
  36570. return
  36571. }
  36572. return *v, true
  36573. }
  36574. // ClearConsumeCoin clears the value of the "consume_coin" field.
  36575. func (m *UsageStatisticHourMutation) ClearConsumeCoin() {
  36576. m.consume_coin = nil
  36577. m.addconsume_coin = nil
  36578. m.clearedFields[usagestatistichour.FieldConsumeCoin] = struct{}{}
  36579. }
  36580. // ConsumeCoinCleared returns if the "consume_coin" field was cleared in this mutation.
  36581. func (m *UsageStatisticHourMutation) ConsumeCoinCleared() bool {
  36582. _, ok := m.clearedFields[usagestatistichour.FieldConsumeCoin]
  36583. return ok
  36584. }
  36585. // ResetConsumeCoin resets all changes to the "consume_coin" field.
  36586. func (m *UsageStatisticHourMutation) ResetConsumeCoin() {
  36587. m.consume_coin = nil
  36588. m.addconsume_coin = nil
  36589. delete(m.clearedFields, usagestatistichour.FieldConsumeCoin)
  36590. }
  36591. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  36592. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  36593. m.predicates = append(m.predicates, ps...)
  36594. }
  36595. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  36596. // users can use type-assertion to append predicates that do not depend on any generated package.
  36597. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  36598. p := make([]predicate.UsageStatisticHour, len(ps))
  36599. for i := range ps {
  36600. p[i] = ps[i]
  36601. }
  36602. m.Where(p...)
  36603. }
  36604. // Op returns the operation name.
  36605. func (m *UsageStatisticHourMutation) Op() Op {
  36606. return m.op
  36607. }
  36608. // SetOp allows setting the mutation operation.
  36609. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  36610. m.op = op
  36611. }
  36612. // Type returns the node type of this mutation (UsageStatisticHour).
  36613. func (m *UsageStatisticHourMutation) Type() string {
  36614. return m.typ
  36615. }
  36616. // Fields returns all fields that were changed during this mutation. Note that in
  36617. // order to get all numeric fields that were incremented/decremented, call
  36618. // AddedFields().
  36619. func (m *UsageStatisticHourMutation) Fields() []string {
  36620. fields := make([]string, 0, 18)
  36621. if m.created_at != nil {
  36622. fields = append(fields, usagestatistichour.FieldCreatedAt)
  36623. }
  36624. if m.updated_at != nil {
  36625. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  36626. }
  36627. if m.status != nil {
  36628. fields = append(fields, usagestatistichour.FieldStatus)
  36629. }
  36630. if m.deleted_at != nil {
  36631. fields = append(fields, usagestatistichour.FieldDeletedAt)
  36632. }
  36633. if m.addtime != nil {
  36634. fields = append(fields, usagestatistichour.FieldAddtime)
  36635. }
  36636. if m._type != nil {
  36637. fields = append(fields, usagestatistichour.FieldType)
  36638. }
  36639. if m.bot_id != nil {
  36640. fields = append(fields, usagestatistichour.FieldBotID)
  36641. }
  36642. if m.organization_id != nil {
  36643. fields = append(fields, usagestatistichour.FieldOrganizationID)
  36644. }
  36645. if m.ai_response != nil {
  36646. fields = append(fields, usagestatistichour.FieldAiResponse)
  36647. }
  36648. if m.sop_run != nil {
  36649. fields = append(fields, usagestatistichour.FieldSopRun)
  36650. }
  36651. if m.total_friend != nil {
  36652. fields = append(fields, usagestatistichour.FieldTotalFriend)
  36653. }
  36654. if m.total_group != nil {
  36655. fields = append(fields, usagestatistichour.FieldTotalGroup)
  36656. }
  36657. if m.account_balance != nil {
  36658. fields = append(fields, usagestatistichour.FieldAccountBalance)
  36659. }
  36660. if m.consume_token != nil {
  36661. fields = append(fields, usagestatistichour.FieldConsumeToken)
  36662. }
  36663. if m.active_user != nil {
  36664. fields = append(fields, usagestatistichour.FieldActiveUser)
  36665. }
  36666. if m.new_user != nil {
  36667. fields = append(fields, usagestatistichour.FieldNewUser)
  36668. }
  36669. if m.label_dist != nil {
  36670. fields = append(fields, usagestatistichour.FieldLabelDist)
  36671. }
  36672. if m.consume_coin != nil {
  36673. fields = append(fields, usagestatistichour.FieldConsumeCoin)
  36674. }
  36675. return fields
  36676. }
  36677. // Field returns the value of a field with the given name. The second boolean
  36678. // return value indicates that this field was not set, or was not defined in the
  36679. // schema.
  36680. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  36681. switch name {
  36682. case usagestatistichour.FieldCreatedAt:
  36683. return m.CreatedAt()
  36684. case usagestatistichour.FieldUpdatedAt:
  36685. return m.UpdatedAt()
  36686. case usagestatistichour.FieldStatus:
  36687. return m.Status()
  36688. case usagestatistichour.FieldDeletedAt:
  36689. return m.DeletedAt()
  36690. case usagestatistichour.FieldAddtime:
  36691. return m.Addtime()
  36692. case usagestatistichour.FieldType:
  36693. return m.GetType()
  36694. case usagestatistichour.FieldBotID:
  36695. return m.BotID()
  36696. case usagestatistichour.FieldOrganizationID:
  36697. return m.OrganizationID()
  36698. case usagestatistichour.FieldAiResponse:
  36699. return m.AiResponse()
  36700. case usagestatistichour.FieldSopRun:
  36701. return m.SopRun()
  36702. case usagestatistichour.FieldTotalFriend:
  36703. return m.TotalFriend()
  36704. case usagestatistichour.FieldTotalGroup:
  36705. return m.TotalGroup()
  36706. case usagestatistichour.FieldAccountBalance:
  36707. return m.AccountBalance()
  36708. case usagestatistichour.FieldConsumeToken:
  36709. return m.ConsumeToken()
  36710. case usagestatistichour.FieldActiveUser:
  36711. return m.ActiveUser()
  36712. case usagestatistichour.FieldNewUser:
  36713. return m.NewUser()
  36714. case usagestatistichour.FieldLabelDist:
  36715. return m.LabelDist()
  36716. case usagestatistichour.FieldConsumeCoin:
  36717. return m.ConsumeCoin()
  36718. }
  36719. return nil, false
  36720. }
  36721. // OldField returns the old value of the field from the database. An error is
  36722. // returned if the mutation operation is not UpdateOne, or the query to the
  36723. // database failed.
  36724. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  36725. switch name {
  36726. case usagestatistichour.FieldCreatedAt:
  36727. return m.OldCreatedAt(ctx)
  36728. case usagestatistichour.FieldUpdatedAt:
  36729. return m.OldUpdatedAt(ctx)
  36730. case usagestatistichour.FieldStatus:
  36731. return m.OldStatus(ctx)
  36732. case usagestatistichour.FieldDeletedAt:
  36733. return m.OldDeletedAt(ctx)
  36734. case usagestatistichour.FieldAddtime:
  36735. return m.OldAddtime(ctx)
  36736. case usagestatistichour.FieldType:
  36737. return m.OldType(ctx)
  36738. case usagestatistichour.FieldBotID:
  36739. return m.OldBotID(ctx)
  36740. case usagestatistichour.FieldOrganizationID:
  36741. return m.OldOrganizationID(ctx)
  36742. case usagestatistichour.FieldAiResponse:
  36743. return m.OldAiResponse(ctx)
  36744. case usagestatistichour.FieldSopRun:
  36745. return m.OldSopRun(ctx)
  36746. case usagestatistichour.FieldTotalFriend:
  36747. return m.OldTotalFriend(ctx)
  36748. case usagestatistichour.FieldTotalGroup:
  36749. return m.OldTotalGroup(ctx)
  36750. case usagestatistichour.FieldAccountBalance:
  36751. return m.OldAccountBalance(ctx)
  36752. case usagestatistichour.FieldConsumeToken:
  36753. return m.OldConsumeToken(ctx)
  36754. case usagestatistichour.FieldActiveUser:
  36755. return m.OldActiveUser(ctx)
  36756. case usagestatistichour.FieldNewUser:
  36757. return m.OldNewUser(ctx)
  36758. case usagestatistichour.FieldLabelDist:
  36759. return m.OldLabelDist(ctx)
  36760. case usagestatistichour.FieldConsumeCoin:
  36761. return m.OldConsumeCoin(ctx)
  36762. }
  36763. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  36764. }
  36765. // SetField sets the value of a field with the given name. It returns an error if
  36766. // the field is not defined in the schema, or if the type mismatched the field
  36767. // type.
  36768. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  36769. switch name {
  36770. case usagestatistichour.FieldCreatedAt:
  36771. v, ok := value.(time.Time)
  36772. if !ok {
  36773. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36774. }
  36775. m.SetCreatedAt(v)
  36776. return nil
  36777. case usagestatistichour.FieldUpdatedAt:
  36778. v, ok := value.(time.Time)
  36779. if !ok {
  36780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36781. }
  36782. m.SetUpdatedAt(v)
  36783. return nil
  36784. case usagestatistichour.FieldStatus:
  36785. v, ok := value.(uint8)
  36786. if !ok {
  36787. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36788. }
  36789. m.SetStatus(v)
  36790. return nil
  36791. case usagestatistichour.FieldDeletedAt:
  36792. v, ok := value.(time.Time)
  36793. if !ok {
  36794. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36795. }
  36796. m.SetDeletedAt(v)
  36797. return nil
  36798. case usagestatistichour.FieldAddtime:
  36799. v, ok := value.(uint64)
  36800. if !ok {
  36801. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36802. }
  36803. m.SetAddtime(v)
  36804. return nil
  36805. case usagestatistichour.FieldType:
  36806. v, ok := value.(int)
  36807. if !ok {
  36808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36809. }
  36810. m.SetType(v)
  36811. return nil
  36812. case usagestatistichour.FieldBotID:
  36813. v, ok := value.(string)
  36814. if !ok {
  36815. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36816. }
  36817. m.SetBotID(v)
  36818. return nil
  36819. case usagestatistichour.FieldOrganizationID:
  36820. v, ok := value.(uint64)
  36821. if !ok {
  36822. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36823. }
  36824. m.SetOrganizationID(v)
  36825. return nil
  36826. case usagestatistichour.FieldAiResponse:
  36827. v, ok := value.(uint64)
  36828. if !ok {
  36829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36830. }
  36831. m.SetAiResponse(v)
  36832. return nil
  36833. case usagestatistichour.FieldSopRun:
  36834. v, ok := value.(uint64)
  36835. if !ok {
  36836. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36837. }
  36838. m.SetSopRun(v)
  36839. return nil
  36840. case usagestatistichour.FieldTotalFriend:
  36841. v, ok := value.(uint64)
  36842. if !ok {
  36843. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36844. }
  36845. m.SetTotalFriend(v)
  36846. return nil
  36847. case usagestatistichour.FieldTotalGroup:
  36848. v, ok := value.(uint64)
  36849. if !ok {
  36850. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36851. }
  36852. m.SetTotalGroup(v)
  36853. return nil
  36854. case usagestatistichour.FieldAccountBalance:
  36855. v, ok := value.(uint64)
  36856. if !ok {
  36857. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36858. }
  36859. m.SetAccountBalance(v)
  36860. return nil
  36861. case usagestatistichour.FieldConsumeToken:
  36862. v, ok := value.(uint64)
  36863. if !ok {
  36864. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36865. }
  36866. m.SetConsumeToken(v)
  36867. return nil
  36868. case usagestatistichour.FieldActiveUser:
  36869. v, ok := value.(uint64)
  36870. if !ok {
  36871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36872. }
  36873. m.SetActiveUser(v)
  36874. return nil
  36875. case usagestatistichour.FieldNewUser:
  36876. v, ok := value.(int64)
  36877. if !ok {
  36878. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36879. }
  36880. m.SetNewUser(v)
  36881. return nil
  36882. case usagestatistichour.FieldLabelDist:
  36883. v, ok := value.([]custom_types.LabelDist)
  36884. if !ok {
  36885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36886. }
  36887. m.SetLabelDist(v)
  36888. return nil
  36889. case usagestatistichour.FieldConsumeCoin:
  36890. v, ok := value.(uint64)
  36891. if !ok {
  36892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36893. }
  36894. m.SetConsumeCoin(v)
  36895. return nil
  36896. }
  36897. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  36898. }
  36899. // AddedFields returns all numeric fields that were incremented/decremented during
  36900. // this mutation.
  36901. func (m *UsageStatisticHourMutation) AddedFields() []string {
  36902. var fields []string
  36903. if m.addstatus != nil {
  36904. fields = append(fields, usagestatistichour.FieldStatus)
  36905. }
  36906. if m.addaddtime != nil {
  36907. fields = append(fields, usagestatistichour.FieldAddtime)
  36908. }
  36909. if m.add_type != nil {
  36910. fields = append(fields, usagestatistichour.FieldType)
  36911. }
  36912. if m.addorganization_id != nil {
  36913. fields = append(fields, usagestatistichour.FieldOrganizationID)
  36914. }
  36915. if m.addai_response != nil {
  36916. fields = append(fields, usagestatistichour.FieldAiResponse)
  36917. }
  36918. if m.addsop_run != nil {
  36919. fields = append(fields, usagestatistichour.FieldSopRun)
  36920. }
  36921. if m.addtotal_friend != nil {
  36922. fields = append(fields, usagestatistichour.FieldTotalFriend)
  36923. }
  36924. if m.addtotal_group != nil {
  36925. fields = append(fields, usagestatistichour.FieldTotalGroup)
  36926. }
  36927. if m.addaccount_balance != nil {
  36928. fields = append(fields, usagestatistichour.FieldAccountBalance)
  36929. }
  36930. if m.addconsume_token != nil {
  36931. fields = append(fields, usagestatistichour.FieldConsumeToken)
  36932. }
  36933. if m.addactive_user != nil {
  36934. fields = append(fields, usagestatistichour.FieldActiveUser)
  36935. }
  36936. if m.addnew_user != nil {
  36937. fields = append(fields, usagestatistichour.FieldNewUser)
  36938. }
  36939. if m.addconsume_coin != nil {
  36940. fields = append(fields, usagestatistichour.FieldConsumeCoin)
  36941. }
  36942. return fields
  36943. }
  36944. // AddedField returns the numeric value that was incremented/decremented on a field
  36945. // with the given name. The second boolean return value indicates that this field
  36946. // was not set, or was not defined in the schema.
  36947. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  36948. switch name {
  36949. case usagestatistichour.FieldStatus:
  36950. return m.AddedStatus()
  36951. case usagestatistichour.FieldAddtime:
  36952. return m.AddedAddtime()
  36953. case usagestatistichour.FieldType:
  36954. return m.AddedType()
  36955. case usagestatistichour.FieldOrganizationID:
  36956. return m.AddedOrganizationID()
  36957. case usagestatistichour.FieldAiResponse:
  36958. return m.AddedAiResponse()
  36959. case usagestatistichour.FieldSopRun:
  36960. return m.AddedSopRun()
  36961. case usagestatistichour.FieldTotalFriend:
  36962. return m.AddedTotalFriend()
  36963. case usagestatistichour.FieldTotalGroup:
  36964. return m.AddedTotalGroup()
  36965. case usagestatistichour.FieldAccountBalance:
  36966. return m.AddedAccountBalance()
  36967. case usagestatistichour.FieldConsumeToken:
  36968. return m.AddedConsumeToken()
  36969. case usagestatistichour.FieldActiveUser:
  36970. return m.AddedActiveUser()
  36971. case usagestatistichour.FieldNewUser:
  36972. return m.AddedNewUser()
  36973. case usagestatistichour.FieldConsumeCoin:
  36974. return m.AddedConsumeCoin()
  36975. }
  36976. return nil, false
  36977. }
  36978. // AddField adds the value to the field with the given name. It returns an error if
  36979. // the field is not defined in the schema, or if the type mismatched the field
  36980. // type.
  36981. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  36982. switch name {
  36983. case usagestatistichour.FieldStatus:
  36984. v, ok := value.(int8)
  36985. if !ok {
  36986. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36987. }
  36988. m.AddStatus(v)
  36989. return nil
  36990. case usagestatistichour.FieldAddtime:
  36991. v, ok := value.(int64)
  36992. if !ok {
  36993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36994. }
  36995. m.AddAddtime(v)
  36996. return nil
  36997. case usagestatistichour.FieldType:
  36998. v, ok := value.(int)
  36999. if !ok {
  37000. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37001. }
  37002. m.AddType(v)
  37003. return nil
  37004. case usagestatistichour.FieldOrganizationID:
  37005. v, ok := value.(int64)
  37006. if !ok {
  37007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37008. }
  37009. m.AddOrganizationID(v)
  37010. return nil
  37011. case usagestatistichour.FieldAiResponse:
  37012. v, ok := value.(int64)
  37013. if !ok {
  37014. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37015. }
  37016. m.AddAiResponse(v)
  37017. return nil
  37018. case usagestatistichour.FieldSopRun:
  37019. v, ok := value.(int64)
  37020. if !ok {
  37021. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37022. }
  37023. m.AddSopRun(v)
  37024. return nil
  37025. case usagestatistichour.FieldTotalFriend:
  37026. v, ok := value.(int64)
  37027. if !ok {
  37028. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37029. }
  37030. m.AddTotalFriend(v)
  37031. return nil
  37032. case usagestatistichour.FieldTotalGroup:
  37033. v, ok := value.(int64)
  37034. if !ok {
  37035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37036. }
  37037. m.AddTotalGroup(v)
  37038. return nil
  37039. case usagestatistichour.FieldAccountBalance:
  37040. v, ok := value.(int64)
  37041. if !ok {
  37042. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37043. }
  37044. m.AddAccountBalance(v)
  37045. return nil
  37046. case usagestatistichour.FieldConsumeToken:
  37047. v, ok := value.(int64)
  37048. if !ok {
  37049. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37050. }
  37051. m.AddConsumeToken(v)
  37052. return nil
  37053. case usagestatistichour.FieldActiveUser:
  37054. v, ok := value.(int64)
  37055. if !ok {
  37056. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37057. }
  37058. m.AddActiveUser(v)
  37059. return nil
  37060. case usagestatistichour.FieldNewUser:
  37061. v, ok := value.(int64)
  37062. if !ok {
  37063. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37064. }
  37065. m.AddNewUser(v)
  37066. return nil
  37067. case usagestatistichour.FieldConsumeCoin:
  37068. v, ok := value.(int64)
  37069. if !ok {
  37070. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37071. }
  37072. m.AddConsumeCoin(v)
  37073. return nil
  37074. }
  37075. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  37076. }
  37077. // ClearedFields returns all nullable fields that were cleared during this
  37078. // mutation.
  37079. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  37080. var fields []string
  37081. if m.FieldCleared(usagestatistichour.FieldStatus) {
  37082. fields = append(fields, usagestatistichour.FieldStatus)
  37083. }
  37084. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  37085. fields = append(fields, usagestatistichour.FieldDeletedAt)
  37086. }
  37087. if m.FieldCleared(usagestatistichour.FieldBotID) {
  37088. fields = append(fields, usagestatistichour.FieldBotID)
  37089. }
  37090. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  37091. fields = append(fields, usagestatistichour.FieldOrganizationID)
  37092. }
  37093. if m.FieldCleared(usagestatistichour.FieldConsumeCoin) {
  37094. fields = append(fields, usagestatistichour.FieldConsumeCoin)
  37095. }
  37096. return fields
  37097. }
  37098. // FieldCleared returns a boolean indicating if a field with the given name was
  37099. // cleared in this mutation.
  37100. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  37101. _, ok := m.clearedFields[name]
  37102. return ok
  37103. }
  37104. // ClearField clears the value of the field with the given name. It returns an
  37105. // error if the field is not defined in the schema.
  37106. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  37107. switch name {
  37108. case usagestatistichour.FieldStatus:
  37109. m.ClearStatus()
  37110. return nil
  37111. case usagestatistichour.FieldDeletedAt:
  37112. m.ClearDeletedAt()
  37113. return nil
  37114. case usagestatistichour.FieldBotID:
  37115. m.ClearBotID()
  37116. return nil
  37117. case usagestatistichour.FieldOrganizationID:
  37118. m.ClearOrganizationID()
  37119. return nil
  37120. case usagestatistichour.FieldConsumeCoin:
  37121. m.ClearConsumeCoin()
  37122. return nil
  37123. }
  37124. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  37125. }
  37126. // ResetField resets all changes in the mutation for the field with the given name.
  37127. // It returns an error if the field is not defined in the schema.
  37128. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  37129. switch name {
  37130. case usagestatistichour.FieldCreatedAt:
  37131. m.ResetCreatedAt()
  37132. return nil
  37133. case usagestatistichour.FieldUpdatedAt:
  37134. m.ResetUpdatedAt()
  37135. return nil
  37136. case usagestatistichour.FieldStatus:
  37137. m.ResetStatus()
  37138. return nil
  37139. case usagestatistichour.FieldDeletedAt:
  37140. m.ResetDeletedAt()
  37141. return nil
  37142. case usagestatistichour.FieldAddtime:
  37143. m.ResetAddtime()
  37144. return nil
  37145. case usagestatistichour.FieldType:
  37146. m.ResetType()
  37147. return nil
  37148. case usagestatistichour.FieldBotID:
  37149. m.ResetBotID()
  37150. return nil
  37151. case usagestatistichour.FieldOrganizationID:
  37152. m.ResetOrganizationID()
  37153. return nil
  37154. case usagestatistichour.FieldAiResponse:
  37155. m.ResetAiResponse()
  37156. return nil
  37157. case usagestatistichour.FieldSopRun:
  37158. m.ResetSopRun()
  37159. return nil
  37160. case usagestatistichour.FieldTotalFriend:
  37161. m.ResetTotalFriend()
  37162. return nil
  37163. case usagestatistichour.FieldTotalGroup:
  37164. m.ResetTotalGroup()
  37165. return nil
  37166. case usagestatistichour.FieldAccountBalance:
  37167. m.ResetAccountBalance()
  37168. return nil
  37169. case usagestatistichour.FieldConsumeToken:
  37170. m.ResetConsumeToken()
  37171. return nil
  37172. case usagestatistichour.FieldActiveUser:
  37173. m.ResetActiveUser()
  37174. return nil
  37175. case usagestatistichour.FieldNewUser:
  37176. m.ResetNewUser()
  37177. return nil
  37178. case usagestatistichour.FieldLabelDist:
  37179. m.ResetLabelDist()
  37180. return nil
  37181. case usagestatistichour.FieldConsumeCoin:
  37182. m.ResetConsumeCoin()
  37183. return nil
  37184. }
  37185. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  37186. }
  37187. // AddedEdges returns all edge names that were set/added in this mutation.
  37188. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  37189. edges := make([]string, 0, 0)
  37190. return edges
  37191. }
  37192. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37193. // name in this mutation.
  37194. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  37195. return nil
  37196. }
  37197. // RemovedEdges returns all edge names that were removed in this mutation.
  37198. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  37199. edges := make([]string, 0, 0)
  37200. return edges
  37201. }
  37202. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37203. // the given name in this mutation.
  37204. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  37205. return nil
  37206. }
  37207. // ClearedEdges returns all edge names that were cleared in this mutation.
  37208. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  37209. edges := make([]string, 0, 0)
  37210. return edges
  37211. }
  37212. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37213. // was cleared in this mutation.
  37214. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  37215. return false
  37216. }
  37217. // ClearEdge clears the value of the edge with the given name. It returns an error
  37218. // if that edge is not defined in the schema.
  37219. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  37220. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  37221. }
  37222. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37223. // It returns an error if the edge is not defined in the schema.
  37224. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  37225. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  37226. }
  37227. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  37228. type UsageStatisticMonthMutation struct {
  37229. config
  37230. op Op
  37231. typ string
  37232. id *uint64
  37233. created_at *time.Time
  37234. updated_at *time.Time
  37235. status *uint8
  37236. addstatus *int8
  37237. deleted_at *time.Time
  37238. addtime *uint64
  37239. addaddtime *int64
  37240. _type *int
  37241. add_type *int
  37242. bot_id *string
  37243. organization_id *uint64
  37244. addorganization_id *int64
  37245. ai_response *uint64
  37246. addai_response *int64
  37247. sop_run *uint64
  37248. addsop_run *int64
  37249. total_friend *uint64
  37250. addtotal_friend *int64
  37251. total_group *uint64
  37252. addtotal_group *int64
  37253. account_balance *uint64
  37254. addaccount_balance *int64
  37255. consume_token *uint64
  37256. addconsume_token *int64
  37257. active_user *uint64
  37258. addactive_user *int64
  37259. new_user *int64
  37260. addnew_user *int64
  37261. label_dist *[]custom_types.LabelDist
  37262. appendlabel_dist []custom_types.LabelDist
  37263. consume_coin *uint64
  37264. addconsume_coin *int64
  37265. clearedFields map[string]struct{}
  37266. done bool
  37267. oldValue func(context.Context) (*UsageStatisticMonth, error)
  37268. predicates []predicate.UsageStatisticMonth
  37269. }
  37270. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  37271. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  37272. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  37273. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  37274. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  37275. m := &UsageStatisticMonthMutation{
  37276. config: c,
  37277. op: op,
  37278. typ: TypeUsageStatisticMonth,
  37279. clearedFields: make(map[string]struct{}),
  37280. }
  37281. for _, opt := range opts {
  37282. opt(m)
  37283. }
  37284. return m
  37285. }
  37286. // withUsageStatisticMonthID sets the ID field of the mutation.
  37287. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  37288. return func(m *UsageStatisticMonthMutation) {
  37289. var (
  37290. err error
  37291. once sync.Once
  37292. value *UsageStatisticMonth
  37293. )
  37294. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  37295. once.Do(func() {
  37296. if m.done {
  37297. err = errors.New("querying old values post mutation is not allowed")
  37298. } else {
  37299. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  37300. }
  37301. })
  37302. return value, err
  37303. }
  37304. m.id = &id
  37305. }
  37306. }
  37307. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  37308. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  37309. return func(m *UsageStatisticMonthMutation) {
  37310. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  37311. return node, nil
  37312. }
  37313. m.id = &node.ID
  37314. }
  37315. }
  37316. // Client returns a new `ent.Client` from the mutation. If the mutation was
  37317. // executed in a transaction (ent.Tx), a transactional client is returned.
  37318. func (m UsageStatisticMonthMutation) Client() *Client {
  37319. client := &Client{config: m.config}
  37320. client.init()
  37321. return client
  37322. }
  37323. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  37324. // it returns an error otherwise.
  37325. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  37326. if _, ok := m.driver.(*txDriver); !ok {
  37327. return nil, errors.New("ent: mutation is not running in a transaction")
  37328. }
  37329. tx := &Tx{config: m.config}
  37330. tx.init()
  37331. return tx, nil
  37332. }
  37333. // SetID sets the value of the id field. Note that this
  37334. // operation is only accepted on creation of UsageStatisticMonth entities.
  37335. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  37336. m.id = &id
  37337. }
  37338. // ID returns the ID value in the mutation. Note that the ID is only available
  37339. // if it was provided to the builder or after it was returned from the database.
  37340. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  37341. if m.id == nil {
  37342. return
  37343. }
  37344. return *m.id, true
  37345. }
  37346. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  37347. // That means, if the mutation is applied within a transaction with an isolation level such
  37348. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  37349. // or updated by the mutation.
  37350. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  37351. switch {
  37352. case m.op.Is(OpUpdateOne | OpDeleteOne):
  37353. id, exists := m.ID()
  37354. if exists {
  37355. return []uint64{id}, nil
  37356. }
  37357. fallthrough
  37358. case m.op.Is(OpUpdate | OpDelete):
  37359. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  37360. default:
  37361. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  37362. }
  37363. }
  37364. // SetCreatedAt sets the "created_at" field.
  37365. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  37366. m.created_at = &t
  37367. }
  37368. // CreatedAt returns the value of the "created_at" field in the mutation.
  37369. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  37370. v := m.created_at
  37371. if v == nil {
  37372. return
  37373. }
  37374. return *v, true
  37375. }
  37376. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  37377. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37378. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37379. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  37380. if !m.op.Is(OpUpdateOne) {
  37381. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  37382. }
  37383. if m.id == nil || m.oldValue == nil {
  37384. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  37385. }
  37386. oldValue, err := m.oldValue(ctx)
  37387. if err != nil {
  37388. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  37389. }
  37390. return oldValue.CreatedAt, nil
  37391. }
  37392. // ResetCreatedAt resets all changes to the "created_at" field.
  37393. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  37394. m.created_at = nil
  37395. }
  37396. // SetUpdatedAt sets the "updated_at" field.
  37397. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  37398. m.updated_at = &t
  37399. }
  37400. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  37401. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  37402. v := m.updated_at
  37403. if v == nil {
  37404. return
  37405. }
  37406. return *v, true
  37407. }
  37408. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  37409. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37410. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37411. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  37412. if !m.op.Is(OpUpdateOne) {
  37413. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  37414. }
  37415. if m.id == nil || m.oldValue == nil {
  37416. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  37417. }
  37418. oldValue, err := m.oldValue(ctx)
  37419. if err != nil {
  37420. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  37421. }
  37422. return oldValue.UpdatedAt, nil
  37423. }
  37424. // ResetUpdatedAt resets all changes to the "updated_at" field.
  37425. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  37426. m.updated_at = nil
  37427. }
  37428. // SetStatus sets the "status" field.
  37429. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  37430. m.status = &u
  37431. m.addstatus = nil
  37432. }
  37433. // Status returns the value of the "status" field in the mutation.
  37434. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  37435. v := m.status
  37436. if v == nil {
  37437. return
  37438. }
  37439. return *v, true
  37440. }
  37441. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  37442. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37443. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37444. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  37445. if !m.op.Is(OpUpdateOne) {
  37446. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  37447. }
  37448. if m.id == nil || m.oldValue == nil {
  37449. return v, errors.New("OldStatus requires an ID field in the mutation")
  37450. }
  37451. oldValue, err := m.oldValue(ctx)
  37452. if err != nil {
  37453. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  37454. }
  37455. return oldValue.Status, nil
  37456. }
  37457. // AddStatus adds u to the "status" field.
  37458. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  37459. if m.addstatus != nil {
  37460. *m.addstatus += u
  37461. } else {
  37462. m.addstatus = &u
  37463. }
  37464. }
  37465. // AddedStatus returns the value that was added to the "status" field in this mutation.
  37466. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  37467. v := m.addstatus
  37468. if v == nil {
  37469. return
  37470. }
  37471. return *v, true
  37472. }
  37473. // ClearStatus clears the value of the "status" field.
  37474. func (m *UsageStatisticMonthMutation) ClearStatus() {
  37475. m.status = nil
  37476. m.addstatus = nil
  37477. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  37478. }
  37479. // StatusCleared returns if the "status" field was cleared in this mutation.
  37480. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  37481. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  37482. return ok
  37483. }
  37484. // ResetStatus resets all changes to the "status" field.
  37485. func (m *UsageStatisticMonthMutation) ResetStatus() {
  37486. m.status = nil
  37487. m.addstatus = nil
  37488. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  37489. }
  37490. // SetDeletedAt sets the "deleted_at" field.
  37491. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  37492. m.deleted_at = &t
  37493. }
  37494. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  37495. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  37496. v := m.deleted_at
  37497. if v == nil {
  37498. return
  37499. }
  37500. return *v, true
  37501. }
  37502. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  37503. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37505. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  37506. if !m.op.Is(OpUpdateOne) {
  37507. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  37508. }
  37509. if m.id == nil || m.oldValue == nil {
  37510. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  37511. }
  37512. oldValue, err := m.oldValue(ctx)
  37513. if err != nil {
  37514. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  37515. }
  37516. return oldValue.DeletedAt, nil
  37517. }
  37518. // ClearDeletedAt clears the value of the "deleted_at" field.
  37519. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  37520. m.deleted_at = nil
  37521. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  37522. }
  37523. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  37524. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  37525. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  37526. return ok
  37527. }
  37528. // ResetDeletedAt resets all changes to the "deleted_at" field.
  37529. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  37530. m.deleted_at = nil
  37531. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  37532. }
  37533. // SetAddtime sets the "addtime" field.
  37534. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  37535. m.addtime = &u
  37536. m.addaddtime = nil
  37537. }
  37538. // Addtime returns the value of the "addtime" field in the mutation.
  37539. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  37540. v := m.addtime
  37541. if v == nil {
  37542. return
  37543. }
  37544. return *v, true
  37545. }
  37546. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  37547. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37548. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37549. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  37550. if !m.op.Is(OpUpdateOne) {
  37551. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  37552. }
  37553. if m.id == nil || m.oldValue == nil {
  37554. return v, errors.New("OldAddtime requires an ID field in the mutation")
  37555. }
  37556. oldValue, err := m.oldValue(ctx)
  37557. if err != nil {
  37558. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  37559. }
  37560. return oldValue.Addtime, nil
  37561. }
  37562. // AddAddtime adds u to the "addtime" field.
  37563. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  37564. if m.addaddtime != nil {
  37565. *m.addaddtime += u
  37566. } else {
  37567. m.addaddtime = &u
  37568. }
  37569. }
  37570. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  37571. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  37572. v := m.addaddtime
  37573. if v == nil {
  37574. return
  37575. }
  37576. return *v, true
  37577. }
  37578. // ResetAddtime resets all changes to the "addtime" field.
  37579. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  37580. m.addtime = nil
  37581. m.addaddtime = nil
  37582. }
  37583. // SetType sets the "type" field.
  37584. func (m *UsageStatisticMonthMutation) SetType(i int) {
  37585. m._type = &i
  37586. m.add_type = nil
  37587. }
  37588. // GetType returns the value of the "type" field in the mutation.
  37589. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  37590. v := m._type
  37591. if v == nil {
  37592. return
  37593. }
  37594. return *v, true
  37595. }
  37596. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  37597. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37598. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37599. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  37600. if !m.op.Is(OpUpdateOne) {
  37601. return v, errors.New("OldType is only allowed on UpdateOne operations")
  37602. }
  37603. if m.id == nil || m.oldValue == nil {
  37604. return v, errors.New("OldType requires an ID field in the mutation")
  37605. }
  37606. oldValue, err := m.oldValue(ctx)
  37607. if err != nil {
  37608. return v, fmt.Errorf("querying old value for OldType: %w", err)
  37609. }
  37610. return oldValue.Type, nil
  37611. }
  37612. // AddType adds i to the "type" field.
  37613. func (m *UsageStatisticMonthMutation) AddType(i int) {
  37614. if m.add_type != nil {
  37615. *m.add_type += i
  37616. } else {
  37617. m.add_type = &i
  37618. }
  37619. }
  37620. // AddedType returns the value that was added to the "type" field in this mutation.
  37621. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  37622. v := m.add_type
  37623. if v == nil {
  37624. return
  37625. }
  37626. return *v, true
  37627. }
  37628. // ResetType resets all changes to the "type" field.
  37629. func (m *UsageStatisticMonthMutation) ResetType() {
  37630. m._type = nil
  37631. m.add_type = nil
  37632. }
  37633. // SetBotID sets the "bot_id" field.
  37634. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  37635. m.bot_id = &s
  37636. }
  37637. // BotID returns the value of the "bot_id" field in the mutation.
  37638. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  37639. v := m.bot_id
  37640. if v == nil {
  37641. return
  37642. }
  37643. return *v, true
  37644. }
  37645. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  37646. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37647. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37648. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  37649. if !m.op.Is(OpUpdateOne) {
  37650. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  37651. }
  37652. if m.id == nil || m.oldValue == nil {
  37653. return v, errors.New("OldBotID requires an ID field in the mutation")
  37654. }
  37655. oldValue, err := m.oldValue(ctx)
  37656. if err != nil {
  37657. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  37658. }
  37659. return oldValue.BotID, nil
  37660. }
  37661. // ClearBotID clears the value of the "bot_id" field.
  37662. func (m *UsageStatisticMonthMutation) ClearBotID() {
  37663. m.bot_id = nil
  37664. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  37665. }
  37666. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  37667. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  37668. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  37669. return ok
  37670. }
  37671. // ResetBotID resets all changes to the "bot_id" field.
  37672. func (m *UsageStatisticMonthMutation) ResetBotID() {
  37673. m.bot_id = nil
  37674. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  37675. }
  37676. // SetOrganizationID sets the "organization_id" field.
  37677. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  37678. m.organization_id = &u
  37679. m.addorganization_id = nil
  37680. }
  37681. // OrganizationID returns the value of the "organization_id" field in the mutation.
  37682. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  37683. v := m.organization_id
  37684. if v == nil {
  37685. return
  37686. }
  37687. return *v, true
  37688. }
  37689. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  37690. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37691. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37692. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  37693. if !m.op.Is(OpUpdateOne) {
  37694. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  37695. }
  37696. if m.id == nil || m.oldValue == nil {
  37697. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  37698. }
  37699. oldValue, err := m.oldValue(ctx)
  37700. if err != nil {
  37701. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  37702. }
  37703. return oldValue.OrganizationID, nil
  37704. }
  37705. // AddOrganizationID adds u to the "organization_id" field.
  37706. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  37707. if m.addorganization_id != nil {
  37708. *m.addorganization_id += u
  37709. } else {
  37710. m.addorganization_id = &u
  37711. }
  37712. }
  37713. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  37714. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  37715. v := m.addorganization_id
  37716. if v == nil {
  37717. return
  37718. }
  37719. return *v, true
  37720. }
  37721. // ClearOrganizationID clears the value of the "organization_id" field.
  37722. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  37723. m.organization_id = nil
  37724. m.addorganization_id = nil
  37725. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  37726. }
  37727. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  37728. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  37729. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  37730. return ok
  37731. }
  37732. // ResetOrganizationID resets all changes to the "organization_id" field.
  37733. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  37734. m.organization_id = nil
  37735. m.addorganization_id = nil
  37736. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  37737. }
  37738. // SetAiResponse sets the "ai_response" field.
  37739. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  37740. m.ai_response = &u
  37741. m.addai_response = nil
  37742. }
  37743. // AiResponse returns the value of the "ai_response" field in the mutation.
  37744. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  37745. v := m.ai_response
  37746. if v == nil {
  37747. return
  37748. }
  37749. return *v, true
  37750. }
  37751. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  37752. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37753. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37754. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  37755. if !m.op.Is(OpUpdateOne) {
  37756. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  37757. }
  37758. if m.id == nil || m.oldValue == nil {
  37759. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  37760. }
  37761. oldValue, err := m.oldValue(ctx)
  37762. if err != nil {
  37763. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  37764. }
  37765. return oldValue.AiResponse, nil
  37766. }
  37767. // AddAiResponse adds u to the "ai_response" field.
  37768. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  37769. if m.addai_response != nil {
  37770. *m.addai_response += u
  37771. } else {
  37772. m.addai_response = &u
  37773. }
  37774. }
  37775. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  37776. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  37777. v := m.addai_response
  37778. if v == nil {
  37779. return
  37780. }
  37781. return *v, true
  37782. }
  37783. // ResetAiResponse resets all changes to the "ai_response" field.
  37784. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  37785. m.ai_response = nil
  37786. m.addai_response = nil
  37787. }
  37788. // SetSopRun sets the "sop_run" field.
  37789. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  37790. m.sop_run = &u
  37791. m.addsop_run = nil
  37792. }
  37793. // SopRun returns the value of the "sop_run" field in the mutation.
  37794. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  37795. v := m.sop_run
  37796. if v == nil {
  37797. return
  37798. }
  37799. return *v, true
  37800. }
  37801. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  37802. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37803. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37804. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  37805. if !m.op.Is(OpUpdateOne) {
  37806. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  37807. }
  37808. if m.id == nil || m.oldValue == nil {
  37809. return v, errors.New("OldSopRun requires an ID field in the mutation")
  37810. }
  37811. oldValue, err := m.oldValue(ctx)
  37812. if err != nil {
  37813. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  37814. }
  37815. return oldValue.SopRun, nil
  37816. }
  37817. // AddSopRun adds u to the "sop_run" field.
  37818. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  37819. if m.addsop_run != nil {
  37820. *m.addsop_run += u
  37821. } else {
  37822. m.addsop_run = &u
  37823. }
  37824. }
  37825. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  37826. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  37827. v := m.addsop_run
  37828. if v == nil {
  37829. return
  37830. }
  37831. return *v, true
  37832. }
  37833. // ResetSopRun resets all changes to the "sop_run" field.
  37834. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  37835. m.sop_run = nil
  37836. m.addsop_run = nil
  37837. }
  37838. // SetTotalFriend sets the "total_friend" field.
  37839. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  37840. m.total_friend = &u
  37841. m.addtotal_friend = nil
  37842. }
  37843. // TotalFriend returns the value of the "total_friend" field in the mutation.
  37844. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  37845. v := m.total_friend
  37846. if v == nil {
  37847. return
  37848. }
  37849. return *v, true
  37850. }
  37851. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  37852. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37853. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37854. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  37855. if !m.op.Is(OpUpdateOne) {
  37856. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  37857. }
  37858. if m.id == nil || m.oldValue == nil {
  37859. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  37860. }
  37861. oldValue, err := m.oldValue(ctx)
  37862. if err != nil {
  37863. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  37864. }
  37865. return oldValue.TotalFriend, nil
  37866. }
  37867. // AddTotalFriend adds u to the "total_friend" field.
  37868. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  37869. if m.addtotal_friend != nil {
  37870. *m.addtotal_friend += u
  37871. } else {
  37872. m.addtotal_friend = &u
  37873. }
  37874. }
  37875. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  37876. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  37877. v := m.addtotal_friend
  37878. if v == nil {
  37879. return
  37880. }
  37881. return *v, true
  37882. }
  37883. // ResetTotalFriend resets all changes to the "total_friend" field.
  37884. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  37885. m.total_friend = nil
  37886. m.addtotal_friend = nil
  37887. }
  37888. // SetTotalGroup sets the "total_group" field.
  37889. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  37890. m.total_group = &u
  37891. m.addtotal_group = nil
  37892. }
  37893. // TotalGroup returns the value of the "total_group" field in the mutation.
  37894. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  37895. v := m.total_group
  37896. if v == nil {
  37897. return
  37898. }
  37899. return *v, true
  37900. }
  37901. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  37902. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37903. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37904. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  37905. if !m.op.Is(OpUpdateOne) {
  37906. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  37907. }
  37908. if m.id == nil || m.oldValue == nil {
  37909. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  37910. }
  37911. oldValue, err := m.oldValue(ctx)
  37912. if err != nil {
  37913. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  37914. }
  37915. return oldValue.TotalGroup, nil
  37916. }
  37917. // AddTotalGroup adds u to the "total_group" field.
  37918. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  37919. if m.addtotal_group != nil {
  37920. *m.addtotal_group += u
  37921. } else {
  37922. m.addtotal_group = &u
  37923. }
  37924. }
  37925. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  37926. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  37927. v := m.addtotal_group
  37928. if v == nil {
  37929. return
  37930. }
  37931. return *v, true
  37932. }
  37933. // ResetTotalGroup resets all changes to the "total_group" field.
  37934. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  37935. m.total_group = nil
  37936. m.addtotal_group = nil
  37937. }
  37938. // SetAccountBalance sets the "account_balance" field.
  37939. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  37940. m.account_balance = &u
  37941. m.addaccount_balance = nil
  37942. }
  37943. // AccountBalance returns the value of the "account_balance" field in the mutation.
  37944. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  37945. v := m.account_balance
  37946. if v == nil {
  37947. return
  37948. }
  37949. return *v, true
  37950. }
  37951. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  37952. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37953. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37954. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  37955. if !m.op.Is(OpUpdateOne) {
  37956. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  37957. }
  37958. if m.id == nil || m.oldValue == nil {
  37959. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  37960. }
  37961. oldValue, err := m.oldValue(ctx)
  37962. if err != nil {
  37963. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  37964. }
  37965. return oldValue.AccountBalance, nil
  37966. }
  37967. // AddAccountBalance adds u to the "account_balance" field.
  37968. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  37969. if m.addaccount_balance != nil {
  37970. *m.addaccount_balance += u
  37971. } else {
  37972. m.addaccount_balance = &u
  37973. }
  37974. }
  37975. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  37976. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  37977. v := m.addaccount_balance
  37978. if v == nil {
  37979. return
  37980. }
  37981. return *v, true
  37982. }
  37983. // ResetAccountBalance resets all changes to the "account_balance" field.
  37984. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  37985. m.account_balance = nil
  37986. m.addaccount_balance = nil
  37987. }
  37988. // SetConsumeToken sets the "consume_token" field.
  37989. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  37990. m.consume_token = &u
  37991. m.addconsume_token = nil
  37992. }
  37993. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  37994. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  37995. v := m.consume_token
  37996. if v == nil {
  37997. return
  37998. }
  37999. return *v, true
  38000. }
  38001. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  38002. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  38003. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38004. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  38005. if !m.op.Is(OpUpdateOne) {
  38006. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  38007. }
  38008. if m.id == nil || m.oldValue == nil {
  38009. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  38010. }
  38011. oldValue, err := m.oldValue(ctx)
  38012. if err != nil {
  38013. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  38014. }
  38015. return oldValue.ConsumeToken, nil
  38016. }
  38017. // AddConsumeToken adds u to the "consume_token" field.
  38018. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  38019. if m.addconsume_token != nil {
  38020. *m.addconsume_token += u
  38021. } else {
  38022. m.addconsume_token = &u
  38023. }
  38024. }
  38025. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  38026. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  38027. v := m.addconsume_token
  38028. if v == nil {
  38029. return
  38030. }
  38031. return *v, true
  38032. }
  38033. // ResetConsumeToken resets all changes to the "consume_token" field.
  38034. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  38035. m.consume_token = nil
  38036. m.addconsume_token = nil
  38037. }
  38038. // SetActiveUser sets the "active_user" field.
  38039. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  38040. m.active_user = &u
  38041. m.addactive_user = nil
  38042. }
  38043. // ActiveUser returns the value of the "active_user" field in the mutation.
  38044. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  38045. v := m.active_user
  38046. if v == nil {
  38047. return
  38048. }
  38049. return *v, true
  38050. }
  38051. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  38052. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  38053. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38054. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  38055. if !m.op.Is(OpUpdateOne) {
  38056. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  38057. }
  38058. if m.id == nil || m.oldValue == nil {
  38059. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  38060. }
  38061. oldValue, err := m.oldValue(ctx)
  38062. if err != nil {
  38063. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  38064. }
  38065. return oldValue.ActiveUser, nil
  38066. }
  38067. // AddActiveUser adds u to the "active_user" field.
  38068. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  38069. if m.addactive_user != nil {
  38070. *m.addactive_user += u
  38071. } else {
  38072. m.addactive_user = &u
  38073. }
  38074. }
  38075. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  38076. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  38077. v := m.addactive_user
  38078. if v == nil {
  38079. return
  38080. }
  38081. return *v, true
  38082. }
  38083. // ResetActiveUser resets all changes to the "active_user" field.
  38084. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  38085. m.active_user = nil
  38086. m.addactive_user = nil
  38087. }
  38088. // SetNewUser sets the "new_user" field.
  38089. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  38090. m.new_user = &i
  38091. m.addnew_user = nil
  38092. }
  38093. // NewUser returns the value of the "new_user" field in the mutation.
  38094. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  38095. v := m.new_user
  38096. if v == nil {
  38097. return
  38098. }
  38099. return *v, true
  38100. }
  38101. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  38102. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  38103. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38104. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  38105. if !m.op.Is(OpUpdateOne) {
  38106. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  38107. }
  38108. if m.id == nil || m.oldValue == nil {
  38109. return v, errors.New("OldNewUser requires an ID field in the mutation")
  38110. }
  38111. oldValue, err := m.oldValue(ctx)
  38112. if err != nil {
  38113. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  38114. }
  38115. return oldValue.NewUser, nil
  38116. }
  38117. // AddNewUser adds i to the "new_user" field.
  38118. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  38119. if m.addnew_user != nil {
  38120. *m.addnew_user += i
  38121. } else {
  38122. m.addnew_user = &i
  38123. }
  38124. }
  38125. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  38126. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  38127. v := m.addnew_user
  38128. if v == nil {
  38129. return
  38130. }
  38131. return *v, true
  38132. }
  38133. // ResetNewUser resets all changes to the "new_user" field.
  38134. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  38135. m.new_user = nil
  38136. m.addnew_user = nil
  38137. }
  38138. // SetLabelDist sets the "label_dist" field.
  38139. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  38140. m.label_dist = &ctd
  38141. m.appendlabel_dist = nil
  38142. }
  38143. // LabelDist returns the value of the "label_dist" field in the mutation.
  38144. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  38145. v := m.label_dist
  38146. if v == nil {
  38147. return
  38148. }
  38149. return *v, true
  38150. }
  38151. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  38152. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  38153. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38154. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  38155. if !m.op.Is(OpUpdateOne) {
  38156. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  38157. }
  38158. if m.id == nil || m.oldValue == nil {
  38159. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  38160. }
  38161. oldValue, err := m.oldValue(ctx)
  38162. if err != nil {
  38163. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  38164. }
  38165. return oldValue.LabelDist, nil
  38166. }
  38167. // AppendLabelDist adds ctd to the "label_dist" field.
  38168. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  38169. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  38170. }
  38171. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  38172. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  38173. if len(m.appendlabel_dist) == 0 {
  38174. return nil, false
  38175. }
  38176. return m.appendlabel_dist, true
  38177. }
  38178. // ResetLabelDist resets all changes to the "label_dist" field.
  38179. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  38180. m.label_dist = nil
  38181. m.appendlabel_dist = nil
  38182. }
  38183. // SetConsumeCoin sets the "consume_coin" field.
  38184. func (m *UsageStatisticMonthMutation) SetConsumeCoin(u uint64) {
  38185. m.consume_coin = &u
  38186. m.addconsume_coin = nil
  38187. }
  38188. // ConsumeCoin returns the value of the "consume_coin" field in the mutation.
  38189. func (m *UsageStatisticMonthMutation) ConsumeCoin() (r uint64, exists bool) {
  38190. v := m.consume_coin
  38191. if v == nil {
  38192. return
  38193. }
  38194. return *v, true
  38195. }
  38196. // OldConsumeCoin returns the old "consume_coin" field's value of the UsageStatisticMonth entity.
  38197. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  38198. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38199. func (m *UsageStatisticMonthMutation) OldConsumeCoin(ctx context.Context) (v uint64, err error) {
  38200. if !m.op.Is(OpUpdateOne) {
  38201. return v, errors.New("OldConsumeCoin is only allowed on UpdateOne operations")
  38202. }
  38203. if m.id == nil || m.oldValue == nil {
  38204. return v, errors.New("OldConsumeCoin requires an ID field in the mutation")
  38205. }
  38206. oldValue, err := m.oldValue(ctx)
  38207. if err != nil {
  38208. return v, fmt.Errorf("querying old value for OldConsumeCoin: %w", err)
  38209. }
  38210. return oldValue.ConsumeCoin, nil
  38211. }
  38212. // AddConsumeCoin adds u to the "consume_coin" field.
  38213. func (m *UsageStatisticMonthMutation) AddConsumeCoin(u int64) {
  38214. if m.addconsume_coin != nil {
  38215. *m.addconsume_coin += u
  38216. } else {
  38217. m.addconsume_coin = &u
  38218. }
  38219. }
  38220. // AddedConsumeCoin returns the value that was added to the "consume_coin" field in this mutation.
  38221. func (m *UsageStatisticMonthMutation) AddedConsumeCoin() (r int64, exists bool) {
  38222. v := m.addconsume_coin
  38223. if v == nil {
  38224. return
  38225. }
  38226. return *v, true
  38227. }
  38228. // ClearConsumeCoin clears the value of the "consume_coin" field.
  38229. func (m *UsageStatisticMonthMutation) ClearConsumeCoin() {
  38230. m.consume_coin = nil
  38231. m.addconsume_coin = nil
  38232. m.clearedFields[usagestatisticmonth.FieldConsumeCoin] = struct{}{}
  38233. }
  38234. // ConsumeCoinCleared returns if the "consume_coin" field was cleared in this mutation.
  38235. func (m *UsageStatisticMonthMutation) ConsumeCoinCleared() bool {
  38236. _, ok := m.clearedFields[usagestatisticmonth.FieldConsumeCoin]
  38237. return ok
  38238. }
  38239. // ResetConsumeCoin resets all changes to the "consume_coin" field.
  38240. func (m *UsageStatisticMonthMutation) ResetConsumeCoin() {
  38241. m.consume_coin = nil
  38242. m.addconsume_coin = nil
  38243. delete(m.clearedFields, usagestatisticmonth.FieldConsumeCoin)
  38244. }
  38245. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  38246. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  38247. m.predicates = append(m.predicates, ps...)
  38248. }
  38249. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  38250. // users can use type-assertion to append predicates that do not depend on any generated package.
  38251. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  38252. p := make([]predicate.UsageStatisticMonth, len(ps))
  38253. for i := range ps {
  38254. p[i] = ps[i]
  38255. }
  38256. m.Where(p...)
  38257. }
  38258. // Op returns the operation name.
  38259. func (m *UsageStatisticMonthMutation) Op() Op {
  38260. return m.op
  38261. }
  38262. // SetOp allows setting the mutation operation.
  38263. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  38264. m.op = op
  38265. }
  38266. // Type returns the node type of this mutation (UsageStatisticMonth).
  38267. func (m *UsageStatisticMonthMutation) Type() string {
  38268. return m.typ
  38269. }
  38270. // Fields returns all fields that were changed during this mutation. Note that in
  38271. // order to get all numeric fields that were incremented/decremented, call
  38272. // AddedFields().
  38273. func (m *UsageStatisticMonthMutation) Fields() []string {
  38274. fields := make([]string, 0, 18)
  38275. if m.created_at != nil {
  38276. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  38277. }
  38278. if m.updated_at != nil {
  38279. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  38280. }
  38281. if m.status != nil {
  38282. fields = append(fields, usagestatisticmonth.FieldStatus)
  38283. }
  38284. if m.deleted_at != nil {
  38285. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  38286. }
  38287. if m.addtime != nil {
  38288. fields = append(fields, usagestatisticmonth.FieldAddtime)
  38289. }
  38290. if m._type != nil {
  38291. fields = append(fields, usagestatisticmonth.FieldType)
  38292. }
  38293. if m.bot_id != nil {
  38294. fields = append(fields, usagestatisticmonth.FieldBotID)
  38295. }
  38296. if m.organization_id != nil {
  38297. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  38298. }
  38299. if m.ai_response != nil {
  38300. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  38301. }
  38302. if m.sop_run != nil {
  38303. fields = append(fields, usagestatisticmonth.FieldSopRun)
  38304. }
  38305. if m.total_friend != nil {
  38306. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  38307. }
  38308. if m.total_group != nil {
  38309. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  38310. }
  38311. if m.account_balance != nil {
  38312. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  38313. }
  38314. if m.consume_token != nil {
  38315. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  38316. }
  38317. if m.active_user != nil {
  38318. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  38319. }
  38320. if m.new_user != nil {
  38321. fields = append(fields, usagestatisticmonth.FieldNewUser)
  38322. }
  38323. if m.label_dist != nil {
  38324. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  38325. }
  38326. if m.consume_coin != nil {
  38327. fields = append(fields, usagestatisticmonth.FieldConsumeCoin)
  38328. }
  38329. return fields
  38330. }
  38331. // Field returns the value of a field with the given name. The second boolean
  38332. // return value indicates that this field was not set, or was not defined in the
  38333. // schema.
  38334. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  38335. switch name {
  38336. case usagestatisticmonth.FieldCreatedAt:
  38337. return m.CreatedAt()
  38338. case usagestatisticmonth.FieldUpdatedAt:
  38339. return m.UpdatedAt()
  38340. case usagestatisticmonth.FieldStatus:
  38341. return m.Status()
  38342. case usagestatisticmonth.FieldDeletedAt:
  38343. return m.DeletedAt()
  38344. case usagestatisticmonth.FieldAddtime:
  38345. return m.Addtime()
  38346. case usagestatisticmonth.FieldType:
  38347. return m.GetType()
  38348. case usagestatisticmonth.FieldBotID:
  38349. return m.BotID()
  38350. case usagestatisticmonth.FieldOrganizationID:
  38351. return m.OrganizationID()
  38352. case usagestatisticmonth.FieldAiResponse:
  38353. return m.AiResponse()
  38354. case usagestatisticmonth.FieldSopRun:
  38355. return m.SopRun()
  38356. case usagestatisticmonth.FieldTotalFriend:
  38357. return m.TotalFriend()
  38358. case usagestatisticmonth.FieldTotalGroup:
  38359. return m.TotalGroup()
  38360. case usagestatisticmonth.FieldAccountBalance:
  38361. return m.AccountBalance()
  38362. case usagestatisticmonth.FieldConsumeToken:
  38363. return m.ConsumeToken()
  38364. case usagestatisticmonth.FieldActiveUser:
  38365. return m.ActiveUser()
  38366. case usagestatisticmonth.FieldNewUser:
  38367. return m.NewUser()
  38368. case usagestatisticmonth.FieldLabelDist:
  38369. return m.LabelDist()
  38370. case usagestatisticmonth.FieldConsumeCoin:
  38371. return m.ConsumeCoin()
  38372. }
  38373. return nil, false
  38374. }
  38375. // OldField returns the old value of the field from the database. An error is
  38376. // returned if the mutation operation is not UpdateOne, or the query to the
  38377. // database failed.
  38378. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  38379. switch name {
  38380. case usagestatisticmonth.FieldCreatedAt:
  38381. return m.OldCreatedAt(ctx)
  38382. case usagestatisticmonth.FieldUpdatedAt:
  38383. return m.OldUpdatedAt(ctx)
  38384. case usagestatisticmonth.FieldStatus:
  38385. return m.OldStatus(ctx)
  38386. case usagestatisticmonth.FieldDeletedAt:
  38387. return m.OldDeletedAt(ctx)
  38388. case usagestatisticmonth.FieldAddtime:
  38389. return m.OldAddtime(ctx)
  38390. case usagestatisticmonth.FieldType:
  38391. return m.OldType(ctx)
  38392. case usagestatisticmonth.FieldBotID:
  38393. return m.OldBotID(ctx)
  38394. case usagestatisticmonth.FieldOrganizationID:
  38395. return m.OldOrganizationID(ctx)
  38396. case usagestatisticmonth.FieldAiResponse:
  38397. return m.OldAiResponse(ctx)
  38398. case usagestatisticmonth.FieldSopRun:
  38399. return m.OldSopRun(ctx)
  38400. case usagestatisticmonth.FieldTotalFriend:
  38401. return m.OldTotalFriend(ctx)
  38402. case usagestatisticmonth.FieldTotalGroup:
  38403. return m.OldTotalGroup(ctx)
  38404. case usagestatisticmonth.FieldAccountBalance:
  38405. return m.OldAccountBalance(ctx)
  38406. case usagestatisticmonth.FieldConsumeToken:
  38407. return m.OldConsumeToken(ctx)
  38408. case usagestatisticmonth.FieldActiveUser:
  38409. return m.OldActiveUser(ctx)
  38410. case usagestatisticmonth.FieldNewUser:
  38411. return m.OldNewUser(ctx)
  38412. case usagestatisticmonth.FieldLabelDist:
  38413. return m.OldLabelDist(ctx)
  38414. case usagestatisticmonth.FieldConsumeCoin:
  38415. return m.OldConsumeCoin(ctx)
  38416. }
  38417. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  38418. }
  38419. // SetField sets the value of a field with the given name. It returns an error if
  38420. // the field is not defined in the schema, or if the type mismatched the field
  38421. // type.
  38422. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  38423. switch name {
  38424. case usagestatisticmonth.FieldCreatedAt:
  38425. v, ok := value.(time.Time)
  38426. if !ok {
  38427. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38428. }
  38429. m.SetCreatedAt(v)
  38430. return nil
  38431. case usagestatisticmonth.FieldUpdatedAt:
  38432. v, ok := value.(time.Time)
  38433. if !ok {
  38434. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38435. }
  38436. m.SetUpdatedAt(v)
  38437. return nil
  38438. case usagestatisticmonth.FieldStatus:
  38439. v, ok := value.(uint8)
  38440. if !ok {
  38441. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38442. }
  38443. m.SetStatus(v)
  38444. return nil
  38445. case usagestatisticmonth.FieldDeletedAt:
  38446. v, ok := value.(time.Time)
  38447. if !ok {
  38448. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38449. }
  38450. m.SetDeletedAt(v)
  38451. return nil
  38452. case usagestatisticmonth.FieldAddtime:
  38453. v, ok := value.(uint64)
  38454. if !ok {
  38455. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38456. }
  38457. m.SetAddtime(v)
  38458. return nil
  38459. case usagestatisticmonth.FieldType:
  38460. v, ok := value.(int)
  38461. if !ok {
  38462. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38463. }
  38464. m.SetType(v)
  38465. return nil
  38466. case usagestatisticmonth.FieldBotID:
  38467. v, ok := value.(string)
  38468. if !ok {
  38469. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38470. }
  38471. m.SetBotID(v)
  38472. return nil
  38473. case usagestatisticmonth.FieldOrganizationID:
  38474. v, ok := value.(uint64)
  38475. if !ok {
  38476. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38477. }
  38478. m.SetOrganizationID(v)
  38479. return nil
  38480. case usagestatisticmonth.FieldAiResponse:
  38481. v, ok := value.(uint64)
  38482. if !ok {
  38483. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38484. }
  38485. m.SetAiResponse(v)
  38486. return nil
  38487. case usagestatisticmonth.FieldSopRun:
  38488. v, ok := value.(uint64)
  38489. if !ok {
  38490. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38491. }
  38492. m.SetSopRun(v)
  38493. return nil
  38494. case usagestatisticmonth.FieldTotalFriend:
  38495. v, ok := value.(uint64)
  38496. if !ok {
  38497. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38498. }
  38499. m.SetTotalFriend(v)
  38500. return nil
  38501. case usagestatisticmonth.FieldTotalGroup:
  38502. v, ok := value.(uint64)
  38503. if !ok {
  38504. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38505. }
  38506. m.SetTotalGroup(v)
  38507. return nil
  38508. case usagestatisticmonth.FieldAccountBalance:
  38509. v, ok := value.(uint64)
  38510. if !ok {
  38511. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38512. }
  38513. m.SetAccountBalance(v)
  38514. return nil
  38515. case usagestatisticmonth.FieldConsumeToken:
  38516. v, ok := value.(uint64)
  38517. if !ok {
  38518. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38519. }
  38520. m.SetConsumeToken(v)
  38521. return nil
  38522. case usagestatisticmonth.FieldActiveUser:
  38523. v, ok := value.(uint64)
  38524. if !ok {
  38525. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38526. }
  38527. m.SetActiveUser(v)
  38528. return nil
  38529. case usagestatisticmonth.FieldNewUser:
  38530. v, ok := value.(int64)
  38531. if !ok {
  38532. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38533. }
  38534. m.SetNewUser(v)
  38535. return nil
  38536. case usagestatisticmonth.FieldLabelDist:
  38537. v, ok := value.([]custom_types.LabelDist)
  38538. if !ok {
  38539. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38540. }
  38541. m.SetLabelDist(v)
  38542. return nil
  38543. case usagestatisticmonth.FieldConsumeCoin:
  38544. v, ok := value.(uint64)
  38545. if !ok {
  38546. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38547. }
  38548. m.SetConsumeCoin(v)
  38549. return nil
  38550. }
  38551. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  38552. }
  38553. // AddedFields returns all numeric fields that were incremented/decremented during
  38554. // this mutation.
  38555. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  38556. var fields []string
  38557. if m.addstatus != nil {
  38558. fields = append(fields, usagestatisticmonth.FieldStatus)
  38559. }
  38560. if m.addaddtime != nil {
  38561. fields = append(fields, usagestatisticmonth.FieldAddtime)
  38562. }
  38563. if m.add_type != nil {
  38564. fields = append(fields, usagestatisticmonth.FieldType)
  38565. }
  38566. if m.addorganization_id != nil {
  38567. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  38568. }
  38569. if m.addai_response != nil {
  38570. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  38571. }
  38572. if m.addsop_run != nil {
  38573. fields = append(fields, usagestatisticmonth.FieldSopRun)
  38574. }
  38575. if m.addtotal_friend != nil {
  38576. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  38577. }
  38578. if m.addtotal_group != nil {
  38579. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  38580. }
  38581. if m.addaccount_balance != nil {
  38582. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  38583. }
  38584. if m.addconsume_token != nil {
  38585. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  38586. }
  38587. if m.addactive_user != nil {
  38588. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  38589. }
  38590. if m.addnew_user != nil {
  38591. fields = append(fields, usagestatisticmonth.FieldNewUser)
  38592. }
  38593. if m.addconsume_coin != nil {
  38594. fields = append(fields, usagestatisticmonth.FieldConsumeCoin)
  38595. }
  38596. return fields
  38597. }
  38598. // AddedField returns the numeric value that was incremented/decremented on a field
  38599. // with the given name. The second boolean return value indicates that this field
  38600. // was not set, or was not defined in the schema.
  38601. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  38602. switch name {
  38603. case usagestatisticmonth.FieldStatus:
  38604. return m.AddedStatus()
  38605. case usagestatisticmonth.FieldAddtime:
  38606. return m.AddedAddtime()
  38607. case usagestatisticmonth.FieldType:
  38608. return m.AddedType()
  38609. case usagestatisticmonth.FieldOrganizationID:
  38610. return m.AddedOrganizationID()
  38611. case usagestatisticmonth.FieldAiResponse:
  38612. return m.AddedAiResponse()
  38613. case usagestatisticmonth.FieldSopRun:
  38614. return m.AddedSopRun()
  38615. case usagestatisticmonth.FieldTotalFriend:
  38616. return m.AddedTotalFriend()
  38617. case usagestatisticmonth.FieldTotalGroup:
  38618. return m.AddedTotalGroup()
  38619. case usagestatisticmonth.FieldAccountBalance:
  38620. return m.AddedAccountBalance()
  38621. case usagestatisticmonth.FieldConsumeToken:
  38622. return m.AddedConsumeToken()
  38623. case usagestatisticmonth.FieldActiveUser:
  38624. return m.AddedActiveUser()
  38625. case usagestatisticmonth.FieldNewUser:
  38626. return m.AddedNewUser()
  38627. case usagestatisticmonth.FieldConsumeCoin:
  38628. return m.AddedConsumeCoin()
  38629. }
  38630. return nil, false
  38631. }
  38632. // AddField adds the value to the field with the given name. It returns an error if
  38633. // the field is not defined in the schema, or if the type mismatched the field
  38634. // type.
  38635. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  38636. switch name {
  38637. case usagestatisticmonth.FieldStatus:
  38638. v, ok := value.(int8)
  38639. if !ok {
  38640. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38641. }
  38642. m.AddStatus(v)
  38643. return nil
  38644. case usagestatisticmonth.FieldAddtime:
  38645. v, ok := value.(int64)
  38646. if !ok {
  38647. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38648. }
  38649. m.AddAddtime(v)
  38650. return nil
  38651. case usagestatisticmonth.FieldType:
  38652. v, ok := value.(int)
  38653. if !ok {
  38654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38655. }
  38656. m.AddType(v)
  38657. return nil
  38658. case usagestatisticmonth.FieldOrganizationID:
  38659. v, ok := value.(int64)
  38660. if !ok {
  38661. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38662. }
  38663. m.AddOrganizationID(v)
  38664. return nil
  38665. case usagestatisticmonth.FieldAiResponse:
  38666. v, ok := value.(int64)
  38667. if !ok {
  38668. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38669. }
  38670. m.AddAiResponse(v)
  38671. return nil
  38672. case usagestatisticmonth.FieldSopRun:
  38673. v, ok := value.(int64)
  38674. if !ok {
  38675. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38676. }
  38677. m.AddSopRun(v)
  38678. return nil
  38679. case usagestatisticmonth.FieldTotalFriend:
  38680. v, ok := value.(int64)
  38681. if !ok {
  38682. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38683. }
  38684. m.AddTotalFriend(v)
  38685. return nil
  38686. case usagestatisticmonth.FieldTotalGroup:
  38687. v, ok := value.(int64)
  38688. if !ok {
  38689. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38690. }
  38691. m.AddTotalGroup(v)
  38692. return nil
  38693. case usagestatisticmonth.FieldAccountBalance:
  38694. v, ok := value.(int64)
  38695. if !ok {
  38696. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38697. }
  38698. m.AddAccountBalance(v)
  38699. return nil
  38700. case usagestatisticmonth.FieldConsumeToken:
  38701. v, ok := value.(int64)
  38702. if !ok {
  38703. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38704. }
  38705. m.AddConsumeToken(v)
  38706. return nil
  38707. case usagestatisticmonth.FieldActiveUser:
  38708. v, ok := value.(int64)
  38709. if !ok {
  38710. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38711. }
  38712. m.AddActiveUser(v)
  38713. return nil
  38714. case usagestatisticmonth.FieldNewUser:
  38715. v, ok := value.(int64)
  38716. if !ok {
  38717. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38718. }
  38719. m.AddNewUser(v)
  38720. return nil
  38721. case usagestatisticmonth.FieldConsumeCoin:
  38722. v, ok := value.(int64)
  38723. if !ok {
  38724. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38725. }
  38726. m.AddConsumeCoin(v)
  38727. return nil
  38728. }
  38729. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  38730. }
  38731. // ClearedFields returns all nullable fields that were cleared during this
  38732. // mutation.
  38733. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  38734. var fields []string
  38735. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  38736. fields = append(fields, usagestatisticmonth.FieldStatus)
  38737. }
  38738. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  38739. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  38740. }
  38741. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  38742. fields = append(fields, usagestatisticmonth.FieldBotID)
  38743. }
  38744. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  38745. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  38746. }
  38747. if m.FieldCleared(usagestatisticmonth.FieldConsumeCoin) {
  38748. fields = append(fields, usagestatisticmonth.FieldConsumeCoin)
  38749. }
  38750. return fields
  38751. }
  38752. // FieldCleared returns a boolean indicating if a field with the given name was
  38753. // cleared in this mutation.
  38754. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  38755. _, ok := m.clearedFields[name]
  38756. return ok
  38757. }
  38758. // ClearField clears the value of the field with the given name. It returns an
  38759. // error if the field is not defined in the schema.
  38760. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  38761. switch name {
  38762. case usagestatisticmonth.FieldStatus:
  38763. m.ClearStatus()
  38764. return nil
  38765. case usagestatisticmonth.FieldDeletedAt:
  38766. m.ClearDeletedAt()
  38767. return nil
  38768. case usagestatisticmonth.FieldBotID:
  38769. m.ClearBotID()
  38770. return nil
  38771. case usagestatisticmonth.FieldOrganizationID:
  38772. m.ClearOrganizationID()
  38773. return nil
  38774. case usagestatisticmonth.FieldConsumeCoin:
  38775. m.ClearConsumeCoin()
  38776. return nil
  38777. }
  38778. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  38779. }
  38780. // ResetField resets all changes in the mutation for the field with the given name.
  38781. // It returns an error if the field is not defined in the schema.
  38782. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  38783. switch name {
  38784. case usagestatisticmonth.FieldCreatedAt:
  38785. m.ResetCreatedAt()
  38786. return nil
  38787. case usagestatisticmonth.FieldUpdatedAt:
  38788. m.ResetUpdatedAt()
  38789. return nil
  38790. case usagestatisticmonth.FieldStatus:
  38791. m.ResetStatus()
  38792. return nil
  38793. case usagestatisticmonth.FieldDeletedAt:
  38794. m.ResetDeletedAt()
  38795. return nil
  38796. case usagestatisticmonth.FieldAddtime:
  38797. m.ResetAddtime()
  38798. return nil
  38799. case usagestatisticmonth.FieldType:
  38800. m.ResetType()
  38801. return nil
  38802. case usagestatisticmonth.FieldBotID:
  38803. m.ResetBotID()
  38804. return nil
  38805. case usagestatisticmonth.FieldOrganizationID:
  38806. m.ResetOrganizationID()
  38807. return nil
  38808. case usagestatisticmonth.FieldAiResponse:
  38809. m.ResetAiResponse()
  38810. return nil
  38811. case usagestatisticmonth.FieldSopRun:
  38812. m.ResetSopRun()
  38813. return nil
  38814. case usagestatisticmonth.FieldTotalFriend:
  38815. m.ResetTotalFriend()
  38816. return nil
  38817. case usagestatisticmonth.FieldTotalGroup:
  38818. m.ResetTotalGroup()
  38819. return nil
  38820. case usagestatisticmonth.FieldAccountBalance:
  38821. m.ResetAccountBalance()
  38822. return nil
  38823. case usagestatisticmonth.FieldConsumeToken:
  38824. m.ResetConsumeToken()
  38825. return nil
  38826. case usagestatisticmonth.FieldActiveUser:
  38827. m.ResetActiveUser()
  38828. return nil
  38829. case usagestatisticmonth.FieldNewUser:
  38830. m.ResetNewUser()
  38831. return nil
  38832. case usagestatisticmonth.FieldLabelDist:
  38833. m.ResetLabelDist()
  38834. return nil
  38835. case usagestatisticmonth.FieldConsumeCoin:
  38836. m.ResetConsumeCoin()
  38837. return nil
  38838. }
  38839. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  38840. }
  38841. // AddedEdges returns all edge names that were set/added in this mutation.
  38842. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  38843. edges := make([]string, 0, 0)
  38844. return edges
  38845. }
  38846. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  38847. // name in this mutation.
  38848. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  38849. return nil
  38850. }
  38851. // RemovedEdges returns all edge names that were removed in this mutation.
  38852. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  38853. edges := make([]string, 0, 0)
  38854. return edges
  38855. }
  38856. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  38857. // the given name in this mutation.
  38858. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  38859. return nil
  38860. }
  38861. // ClearedEdges returns all edge names that were cleared in this mutation.
  38862. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  38863. edges := make([]string, 0, 0)
  38864. return edges
  38865. }
  38866. // EdgeCleared returns a boolean which indicates if the edge with the given name
  38867. // was cleared in this mutation.
  38868. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  38869. return false
  38870. }
  38871. // ClearEdge clears the value of the edge with the given name. It returns an error
  38872. // if that edge is not defined in the schema.
  38873. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  38874. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  38875. }
  38876. // ResetEdge resets all changes to the edge with the given name in this mutation.
  38877. // It returns an error if the edge is not defined in the schema.
  38878. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  38879. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  38880. }
  38881. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  38882. type UsageTotalMutation struct {
  38883. config
  38884. op Op
  38885. typ string
  38886. id *uint64
  38887. created_at *time.Time
  38888. updated_at *time.Time
  38889. status *uint8
  38890. addstatus *int8
  38891. _type *int
  38892. add_type *int
  38893. bot_id *string
  38894. total_tokens *uint64
  38895. addtotal_tokens *int64
  38896. start_index *uint64
  38897. addstart_index *int64
  38898. end_index *uint64
  38899. addend_index *int64
  38900. organization_id *uint64
  38901. addorganization_id *int64
  38902. clearedFields map[string]struct{}
  38903. done bool
  38904. oldValue func(context.Context) (*UsageTotal, error)
  38905. predicates []predicate.UsageTotal
  38906. }
  38907. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  38908. // usagetotalOption allows management of the mutation configuration using functional options.
  38909. type usagetotalOption func(*UsageTotalMutation)
  38910. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  38911. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  38912. m := &UsageTotalMutation{
  38913. config: c,
  38914. op: op,
  38915. typ: TypeUsageTotal,
  38916. clearedFields: make(map[string]struct{}),
  38917. }
  38918. for _, opt := range opts {
  38919. opt(m)
  38920. }
  38921. return m
  38922. }
  38923. // withUsageTotalID sets the ID field of the mutation.
  38924. func withUsageTotalID(id uint64) usagetotalOption {
  38925. return func(m *UsageTotalMutation) {
  38926. var (
  38927. err error
  38928. once sync.Once
  38929. value *UsageTotal
  38930. )
  38931. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  38932. once.Do(func() {
  38933. if m.done {
  38934. err = errors.New("querying old values post mutation is not allowed")
  38935. } else {
  38936. value, err = m.Client().UsageTotal.Get(ctx, id)
  38937. }
  38938. })
  38939. return value, err
  38940. }
  38941. m.id = &id
  38942. }
  38943. }
  38944. // withUsageTotal sets the old UsageTotal of the mutation.
  38945. func withUsageTotal(node *UsageTotal) usagetotalOption {
  38946. return func(m *UsageTotalMutation) {
  38947. m.oldValue = func(context.Context) (*UsageTotal, error) {
  38948. return node, nil
  38949. }
  38950. m.id = &node.ID
  38951. }
  38952. }
  38953. // Client returns a new `ent.Client` from the mutation. If the mutation was
  38954. // executed in a transaction (ent.Tx), a transactional client is returned.
  38955. func (m UsageTotalMutation) Client() *Client {
  38956. client := &Client{config: m.config}
  38957. client.init()
  38958. return client
  38959. }
  38960. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  38961. // it returns an error otherwise.
  38962. func (m UsageTotalMutation) Tx() (*Tx, error) {
  38963. if _, ok := m.driver.(*txDriver); !ok {
  38964. return nil, errors.New("ent: mutation is not running in a transaction")
  38965. }
  38966. tx := &Tx{config: m.config}
  38967. tx.init()
  38968. return tx, nil
  38969. }
  38970. // SetID sets the value of the id field. Note that this
  38971. // operation is only accepted on creation of UsageTotal entities.
  38972. func (m *UsageTotalMutation) SetID(id uint64) {
  38973. m.id = &id
  38974. }
  38975. // ID returns the ID value in the mutation. Note that the ID is only available
  38976. // if it was provided to the builder or after it was returned from the database.
  38977. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  38978. if m.id == nil {
  38979. return
  38980. }
  38981. return *m.id, true
  38982. }
  38983. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  38984. // That means, if the mutation is applied within a transaction with an isolation level such
  38985. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  38986. // or updated by the mutation.
  38987. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  38988. switch {
  38989. case m.op.Is(OpUpdateOne | OpDeleteOne):
  38990. id, exists := m.ID()
  38991. if exists {
  38992. return []uint64{id}, nil
  38993. }
  38994. fallthrough
  38995. case m.op.Is(OpUpdate | OpDelete):
  38996. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  38997. default:
  38998. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  38999. }
  39000. }
  39001. // SetCreatedAt sets the "created_at" field.
  39002. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  39003. m.created_at = &t
  39004. }
  39005. // CreatedAt returns the value of the "created_at" field in the mutation.
  39006. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  39007. v := m.created_at
  39008. if v == nil {
  39009. return
  39010. }
  39011. return *v, true
  39012. }
  39013. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  39014. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  39015. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39016. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39017. if !m.op.Is(OpUpdateOne) {
  39018. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39019. }
  39020. if m.id == nil || m.oldValue == nil {
  39021. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39022. }
  39023. oldValue, err := m.oldValue(ctx)
  39024. if err != nil {
  39025. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39026. }
  39027. return oldValue.CreatedAt, nil
  39028. }
  39029. // ResetCreatedAt resets all changes to the "created_at" field.
  39030. func (m *UsageTotalMutation) ResetCreatedAt() {
  39031. m.created_at = nil
  39032. }
  39033. // SetUpdatedAt sets the "updated_at" field.
  39034. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  39035. m.updated_at = &t
  39036. }
  39037. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  39038. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  39039. v := m.updated_at
  39040. if v == nil {
  39041. return
  39042. }
  39043. return *v, true
  39044. }
  39045. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  39046. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  39047. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39048. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  39049. if !m.op.Is(OpUpdateOne) {
  39050. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  39051. }
  39052. if m.id == nil || m.oldValue == nil {
  39053. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  39054. }
  39055. oldValue, err := m.oldValue(ctx)
  39056. if err != nil {
  39057. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  39058. }
  39059. return oldValue.UpdatedAt, nil
  39060. }
  39061. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39062. func (m *UsageTotalMutation) ResetUpdatedAt() {
  39063. m.updated_at = nil
  39064. }
  39065. // SetStatus sets the "status" field.
  39066. func (m *UsageTotalMutation) SetStatus(u uint8) {
  39067. m.status = &u
  39068. m.addstatus = nil
  39069. }
  39070. // Status returns the value of the "status" field in the mutation.
  39071. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  39072. v := m.status
  39073. if v == nil {
  39074. return
  39075. }
  39076. return *v, true
  39077. }
  39078. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  39079. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  39080. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39081. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  39082. if !m.op.Is(OpUpdateOne) {
  39083. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  39084. }
  39085. if m.id == nil || m.oldValue == nil {
  39086. return v, errors.New("OldStatus requires an ID field in the mutation")
  39087. }
  39088. oldValue, err := m.oldValue(ctx)
  39089. if err != nil {
  39090. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  39091. }
  39092. return oldValue.Status, nil
  39093. }
  39094. // AddStatus adds u to the "status" field.
  39095. func (m *UsageTotalMutation) AddStatus(u int8) {
  39096. if m.addstatus != nil {
  39097. *m.addstatus += u
  39098. } else {
  39099. m.addstatus = &u
  39100. }
  39101. }
  39102. // AddedStatus returns the value that was added to the "status" field in this mutation.
  39103. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  39104. v := m.addstatus
  39105. if v == nil {
  39106. return
  39107. }
  39108. return *v, true
  39109. }
  39110. // ClearStatus clears the value of the "status" field.
  39111. func (m *UsageTotalMutation) ClearStatus() {
  39112. m.status = nil
  39113. m.addstatus = nil
  39114. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  39115. }
  39116. // StatusCleared returns if the "status" field was cleared in this mutation.
  39117. func (m *UsageTotalMutation) StatusCleared() bool {
  39118. _, ok := m.clearedFields[usagetotal.FieldStatus]
  39119. return ok
  39120. }
  39121. // ResetStatus resets all changes to the "status" field.
  39122. func (m *UsageTotalMutation) ResetStatus() {
  39123. m.status = nil
  39124. m.addstatus = nil
  39125. delete(m.clearedFields, usagetotal.FieldStatus)
  39126. }
  39127. // SetType sets the "type" field.
  39128. func (m *UsageTotalMutation) SetType(i int) {
  39129. m._type = &i
  39130. m.add_type = nil
  39131. }
  39132. // GetType returns the value of the "type" field in the mutation.
  39133. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  39134. v := m._type
  39135. if v == nil {
  39136. return
  39137. }
  39138. return *v, true
  39139. }
  39140. // OldType returns the old "type" field's value of the UsageTotal entity.
  39141. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  39142. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39143. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  39144. if !m.op.Is(OpUpdateOne) {
  39145. return v, errors.New("OldType is only allowed on UpdateOne operations")
  39146. }
  39147. if m.id == nil || m.oldValue == nil {
  39148. return v, errors.New("OldType requires an ID field in the mutation")
  39149. }
  39150. oldValue, err := m.oldValue(ctx)
  39151. if err != nil {
  39152. return v, fmt.Errorf("querying old value for OldType: %w", err)
  39153. }
  39154. return oldValue.Type, nil
  39155. }
  39156. // AddType adds i to the "type" field.
  39157. func (m *UsageTotalMutation) AddType(i int) {
  39158. if m.add_type != nil {
  39159. *m.add_type += i
  39160. } else {
  39161. m.add_type = &i
  39162. }
  39163. }
  39164. // AddedType returns the value that was added to the "type" field in this mutation.
  39165. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  39166. v := m.add_type
  39167. if v == nil {
  39168. return
  39169. }
  39170. return *v, true
  39171. }
  39172. // ClearType clears the value of the "type" field.
  39173. func (m *UsageTotalMutation) ClearType() {
  39174. m._type = nil
  39175. m.add_type = nil
  39176. m.clearedFields[usagetotal.FieldType] = struct{}{}
  39177. }
  39178. // TypeCleared returns if the "type" field was cleared in this mutation.
  39179. func (m *UsageTotalMutation) TypeCleared() bool {
  39180. _, ok := m.clearedFields[usagetotal.FieldType]
  39181. return ok
  39182. }
  39183. // ResetType resets all changes to the "type" field.
  39184. func (m *UsageTotalMutation) ResetType() {
  39185. m._type = nil
  39186. m.add_type = nil
  39187. delete(m.clearedFields, usagetotal.FieldType)
  39188. }
  39189. // SetBotID sets the "bot_id" field.
  39190. func (m *UsageTotalMutation) SetBotID(s string) {
  39191. m.bot_id = &s
  39192. }
  39193. // BotID returns the value of the "bot_id" field in the mutation.
  39194. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  39195. v := m.bot_id
  39196. if v == nil {
  39197. return
  39198. }
  39199. return *v, true
  39200. }
  39201. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  39202. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  39203. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39204. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  39205. if !m.op.Is(OpUpdateOne) {
  39206. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  39207. }
  39208. if m.id == nil || m.oldValue == nil {
  39209. return v, errors.New("OldBotID requires an ID field in the mutation")
  39210. }
  39211. oldValue, err := m.oldValue(ctx)
  39212. if err != nil {
  39213. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  39214. }
  39215. return oldValue.BotID, nil
  39216. }
  39217. // ResetBotID resets all changes to the "bot_id" field.
  39218. func (m *UsageTotalMutation) ResetBotID() {
  39219. m.bot_id = nil
  39220. }
  39221. // SetTotalTokens sets the "total_tokens" field.
  39222. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  39223. m.total_tokens = &u
  39224. m.addtotal_tokens = nil
  39225. }
  39226. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  39227. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  39228. v := m.total_tokens
  39229. if v == nil {
  39230. return
  39231. }
  39232. return *v, true
  39233. }
  39234. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  39235. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  39236. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39237. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  39238. if !m.op.Is(OpUpdateOne) {
  39239. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  39240. }
  39241. if m.id == nil || m.oldValue == nil {
  39242. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  39243. }
  39244. oldValue, err := m.oldValue(ctx)
  39245. if err != nil {
  39246. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  39247. }
  39248. return oldValue.TotalTokens, nil
  39249. }
  39250. // AddTotalTokens adds u to the "total_tokens" field.
  39251. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  39252. if m.addtotal_tokens != nil {
  39253. *m.addtotal_tokens += u
  39254. } else {
  39255. m.addtotal_tokens = &u
  39256. }
  39257. }
  39258. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  39259. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  39260. v := m.addtotal_tokens
  39261. if v == nil {
  39262. return
  39263. }
  39264. return *v, true
  39265. }
  39266. // ClearTotalTokens clears the value of the "total_tokens" field.
  39267. func (m *UsageTotalMutation) ClearTotalTokens() {
  39268. m.total_tokens = nil
  39269. m.addtotal_tokens = nil
  39270. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  39271. }
  39272. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  39273. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  39274. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  39275. return ok
  39276. }
  39277. // ResetTotalTokens resets all changes to the "total_tokens" field.
  39278. func (m *UsageTotalMutation) ResetTotalTokens() {
  39279. m.total_tokens = nil
  39280. m.addtotal_tokens = nil
  39281. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  39282. }
  39283. // SetStartIndex sets the "start_index" field.
  39284. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  39285. m.start_index = &u
  39286. m.addstart_index = nil
  39287. }
  39288. // StartIndex returns the value of the "start_index" field in the mutation.
  39289. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  39290. v := m.start_index
  39291. if v == nil {
  39292. return
  39293. }
  39294. return *v, true
  39295. }
  39296. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  39297. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  39298. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39299. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  39300. if !m.op.Is(OpUpdateOne) {
  39301. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  39302. }
  39303. if m.id == nil || m.oldValue == nil {
  39304. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  39305. }
  39306. oldValue, err := m.oldValue(ctx)
  39307. if err != nil {
  39308. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  39309. }
  39310. return oldValue.StartIndex, nil
  39311. }
  39312. // AddStartIndex adds u to the "start_index" field.
  39313. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  39314. if m.addstart_index != nil {
  39315. *m.addstart_index += u
  39316. } else {
  39317. m.addstart_index = &u
  39318. }
  39319. }
  39320. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  39321. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  39322. v := m.addstart_index
  39323. if v == nil {
  39324. return
  39325. }
  39326. return *v, true
  39327. }
  39328. // ClearStartIndex clears the value of the "start_index" field.
  39329. func (m *UsageTotalMutation) ClearStartIndex() {
  39330. m.start_index = nil
  39331. m.addstart_index = nil
  39332. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  39333. }
  39334. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  39335. func (m *UsageTotalMutation) StartIndexCleared() bool {
  39336. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  39337. return ok
  39338. }
  39339. // ResetStartIndex resets all changes to the "start_index" field.
  39340. func (m *UsageTotalMutation) ResetStartIndex() {
  39341. m.start_index = nil
  39342. m.addstart_index = nil
  39343. delete(m.clearedFields, usagetotal.FieldStartIndex)
  39344. }
  39345. // SetEndIndex sets the "end_index" field.
  39346. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  39347. m.end_index = &u
  39348. m.addend_index = nil
  39349. }
  39350. // EndIndex returns the value of the "end_index" field in the mutation.
  39351. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  39352. v := m.end_index
  39353. if v == nil {
  39354. return
  39355. }
  39356. return *v, true
  39357. }
  39358. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  39359. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  39360. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39361. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  39362. if !m.op.Is(OpUpdateOne) {
  39363. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  39364. }
  39365. if m.id == nil || m.oldValue == nil {
  39366. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  39367. }
  39368. oldValue, err := m.oldValue(ctx)
  39369. if err != nil {
  39370. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  39371. }
  39372. return oldValue.EndIndex, nil
  39373. }
  39374. // AddEndIndex adds u to the "end_index" field.
  39375. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  39376. if m.addend_index != nil {
  39377. *m.addend_index += u
  39378. } else {
  39379. m.addend_index = &u
  39380. }
  39381. }
  39382. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  39383. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  39384. v := m.addend_index
  39385. if v == nil {
  39386. return
  39387. }
  39388. return *v, true
  39389. }
  39390. // ClearEndIndex clears the value of the "end_index" field.
  39391. func (m *UsageTotalMutation) ClearEndIndex() {
  39392. m.end_index = nil
  39393. m.addend_index = nil
  39394. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  39395. }
  39396. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  39397. func (m *UsageTotalMutation) EndIndexCleared() bool {
  39398. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  39399. return ok
  39400. }
  39401. // ResetEndIndex resets all changes to the "end_index" field.
  39402. func (m *UsageTotalMutation) ResetEndIndex() {
  39403. m.end_index = nil
  39404. m.addend_index = nil
  39405. delete(m.clearedFields, usagetotal.FieldEndIndex)
  39406. }
  39407. // SetOrganizationID sets the "organization_id" field.
  39408. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  39409. m.organization_id = &u
  39410. m.addorganization_id = nil
  39411. }
  39412. // OrganizationID returns the value of the "organization_id" field in the mutation.
  39413. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  39414. v := m.organization_id
  39415. if v == nil {
  39416. return
  39417. }
  39418. return *v, true
  39419. }
  39420. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  39421. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  39422. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39423. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  39424. if !m.op.Is(OpUpdateOne) {
  39425. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  39426. }
  39427. if m.id == nil || m.oldValue == nil {
  39428. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  39429. }
  39430. oldValue, err := m.oldValue(ctx)
  39431. if err != nil {
  39432. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  39433. }
  39434. return oldValue.OrganizationID, nil
  39435. }
  39436. // AddOrganizationID adds u to the "organization_id" field.
  39437. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  39438. if m.addorganization_id != nil {
  39439. *m.addorganization_id += u
  39440. } else {
  39441. m.addorganization_id = &u
  39442. }
  39443. }
  39444. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  39445. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  39446. v := m.addorganization_id
  39447. if v == nil {
  39448. return
  39449. }
  39450. return *v, true
  39451. }
  39452. // ClearOrganizationID clears the value of the "organization_id" field.
  39453. func (m *UsageTotalMutation) ClearOrganizationID() {
  39454. m.organization_id = nil
  39455. m.addorganization_id = nil
  39456. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  39457. }
  39458. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  39459. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  39460. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  39461. return ok
  39462. }
  39463. // ResetOrganizationID resets all changes to the "organization_id" field.
  39464. func (m *UsageTotalMutation) ResetOrganizationID() {
  39465. m.organization_id = nil
  39466. m.addorganization_id = nil
  39467. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  39468. }
  39469. // Where appends a list predicates to the UsageTotalMutation builder.
  39470. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  39471. m.predicates = append(m.predicates, ps...)
  39472. }
  39473. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  39474. // users can use type-assertion to append predicates that do not depend on any generated package.
  39475. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  39476. p := make([]predicate.UsageTotal, len(ps))
  39477. for i := range ps {
  39478. p[i] = ps[i]
  39479. }
  39480. m.Where(p...)
  39481. }
  39482. // Op returns the operation name.
  39483. func (m *UsageTotalMutation) Op() Op {
  39484. return m.op
  39485. }
  39486. // SetOp allows setting the mutation operation.
  39487. func (m *UsageTotalMutation) SetOp(op Op) {
  39488. m.op = op
  39489. }
  39490. // Type returns the node type of this mutation (UsageTotal).
  39491. func (m *UsageTotalMutation) Type() string {
  39492. return m.typ
  39493. }
  39494. // Fields returns all fields that were changed during this mutation. Note that in
  39495. // order to get all numeric fields that were incremented/decremented, call
  39496. // AddedFields().
  39497. func (m *UsageTotalMutation) Fields() []string {
  39498. fields := make([]string, 0, 9)
  39499. if m.created_at != nil {
  39500. fields = append(fields, usagetotal.FieldCreatedAt)
  39501. }
  39502. if m.updated_at != nil {
  39503. fields = append(fields, usagetotal.FieldUpdatedAt)
  39504. }
  39505. if m.status != nil {
  39506. fields = append(fields, usagetotal.FieldStatus)
  39507. }
  39508. if m._type != nil {
  39509. fields = append(fields, usagetotal.FieldType)
  39510. }
  39511. if m.bot_id != nil {
  39512. fields = append(fields, usagetotal.FieldBotID)
  39513. }
  39514. if m.total_tokens != nil {
  39515. fields = append(fields, usagetotal.FieldTotalTokens)
  39516. }
  39517. if m.start_index != nil {
  39518. fields = append(fields, usagetotal.FieldStartIndex)
  39519. }
  39520. if m.end_index != nil {
  39521. fields = append(fields, usagetotal.FieldEndIndex)
  39522. }
  39523. if m.organization_id != nil {
  39524. fields = append(fields, usagetotal.FieldOrganizationID)
  39525. }
  39526. return fields
  39527. }
  39528. // Field returns the value of a field with the given name. The second boolean
  39529. // return value indicates that this field was not set, or was not defined in the
  39530. // schema.
  39531. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  39532. switch name {
  39533. case usagetotal.FieldCreatedAt:
  39534. return m.CreatedAt()
  39535. case usagetotal.FieldUpdatedAt:
  39536. return m.UpdatedAt()
  39537. case usagetotal.FieldStatus:
  39538. return m.Status()
  39539. case usagetotal.FieldType:
  39540. return m.GetType()
  39541. case usagetotal.FieldBotID:
  39542. return m.BotID()
  39543. case usagetotal.FieldTotalTokens:
  39544. return m.TotalTokens()
  39545. case usagetotal.FieldStartIndex:
  39546. return m.StartIndex()
  39547. case usagetotal.FieldEndIndex:
  39548. return m.EndIndex()
  39549. case usagetotal.FieldOrganizationID:
  39550. return m.OrganizationID()
  39551. }
  39552. return nil, false
  39553. }
  39554. // OldField returns the old value of the field from the database. An error is
  39555. // returned if the mutation operation is not UpdateOne, or the query to the
  39556. // database failed.
  39557. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  39558. switch name {
  39559. case usagetotal.FieldCreatedAt:
  39560. return m.OldCreatedAt(ctx)
  39561. case usagetotal.FieldUpdatedAt:
  39562. return m.OldUpdatedAt(ctx)
  39563. case usagetotal.FieldStatus:
  39564. return m.OldStatus(ctx)
  39565. case usagetotal.FieldType:
  39566. return m.OldType(ctx)
  39567. case usagetotal.FieldBotID:
  39568. return m.OldBotID(ctx)
  39569. case usagetotal.FieldTotalTokens:
  39570. return m.OldTotalTokens(ctx)
  39571. case usagetotal.FieldStartIndex:
  39572. return m.OldStartIndex(ctx)
  39573. case usagetotal.FieldEndIndex:
  39574. return m.OldEndIndex(ctx)
  39575. case usagetotal.FieldOrganizationID:
  39576. return m.OldOrganizationID(ctx)
  39577. }
  39578. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  39579. }
  39580. // SetField sets the value of a field with the given name. It returns an error if
  39581. // the field is not defined in the schema, or if the type mismatched the field
  39582. // type.
  39583. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  39584. switch name {
  39585. case usagetotal.FieldCreatedAt:
  39586. v, ok := value.(time.Time)
  39587. if !ok {
  39588. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39589. }
  39590. m.SetCreatedAt(v)
  39591. return nil
  39592. case usagetotal.FieldUpdatedAt:
  39593. v, ok := value.(time.Time)
  39594. if !ok {
  39595. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39596. }
  39597. m.SetUpdatedAt(v)
  39598. return nil
  39599. case usagetotal.FieldStatus:
  39600. v, ok := value.(uint8)
  39601. if !ok {
  39602. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39603. }
  39604. m.SetStatus(v)
  39605. return nil
  39606. case usagetotal.FieldType:
  39607. v, ok := value.(int)
  39608. if !ok {
  39609. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39610. }
  39611. m.SetType(v)
  39612. return nil
  39613. case usagetotal.FieldBotID:
  39614. v, ok := value.(string)
  39615. if !ok {
  39616. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39617. }
  39618. m.SetBotID(v)
  39619. return nil
  39620. case usagetotal.FieldTotalTokens:
  39621. v, ok := value.(uint64)
  39622. if !ok {
  39623. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39624. }
  39625. m.SetTotalTokens(v)
  39626. return nil
  39627. case usagetotal.FieldStartIndex:
  39628. v, ok := value.(uint64)
  39629. if !ok {
  39630. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39631. }
  39632. m.SetStartIndex(v)
  39633. return nil
  39634. case usagetotal.FieldEndIndex:
  39635. v, ok := value.(uint64)
  39636. if !ok {
  39637. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39638. }
  39639. m.SetEndIndex(v)
  39640. return nil
  39641. case usagetotal.FieldOrganizationID:
  39642. v, ok := value.(uint64)
  39643. if !ok {
  39644. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39645. }
  39646. m.SetOrganizationID(v)
  39647. return nil
  39648. }
  39649. return fmt.Errorf("unknown UsageTotal field %s", name)
  39650. }
  39651. // AddedFields returns all numeric fields that were incremented/decremented during
  39652. // this mutation.
  39653. func (m *UsageTotalMutation) AddedFields() []string {
  39654. var fields []string
  39655. if m.addstatus != nil {
  39656. fields = append(fields, usagetotal.FieldStatus)
  39657. }
  39658. if m.add_type != nil {
  39659. fields = append(fields, usagetotal.FieldType)
  39660. }
  39661. if m.addtotal_tokens != nil {
  39662. fields = append(fields, usagetotal.FieldTotalTokens)
  39663. }
  39664. if m.addstart_index != nil {
  39665. fields = append(fields, usagetotal.FieldStartIndex)
  39666. }
  39667. if m.addend_index != nil {
  39668. fields = append(fields, usagetotal.FieldEndIndex)
  39669. }
  39670. if m.addorganization_id != nil {
  39671. fields = append(fields, usagetotal.FieldOrganizationID)
  39672. }
  39673. return fields
  39674. }
  39675. // AddedField returns the numeric value that was incremented/decremented on a field
  39676. // with the given name. The second boolean return value indicates that this field
  39677. // was not set, or was not defined in the schema.
  39678. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  39679. switch name {
  39680. case usagetotal.FieldStatus:
  39681. return m.AddedStatus()
  39682. case usagetotal.FieldType:
  39683. return m.AddedType()
  39684. case usagetotal.FieldTotalTokens:
  39685. return m.AddedTotalTokens()
  39686. case usagetotal.FieldStartIndex:
  39687. return m.AddedStartIndex()
  39688. case usagetotal.FieldEndIndex:
  39689. return m.AddedEndIndex()
  39690. case usagetotal.FieldOrganizationID:
  39691. return m.AddedOrganizationID()
  39692. }
  39693. return nil, false
  39694. }
  39695. // AddField adds the value to the field with the given name. It returns an error if
  39696. // the field is not defined in the schema, or if the type mismatched the field
  39697. // type.
  39698. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  39699. switch name {
  39700. case usagetotal.FieldStatus:
  39701. v, ok := value.(int8)
  39702. if !ok {
  39703. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39704. }
  39705. m.AddStatus(v)
  39706. return nil
  39707. case usagetotal.FieldType:
  39708. v, ok := value.(int)
  39709. if !ok {
  39710. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39711. }
  39712. m.AddType(v)
  39713. return nil
  39714. case usagetotal.FieldTotalTokens:
  39715. v, ok := value.(int64)
  39716. if !ok {
  39717. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39718. }
  39719. m.AddTotalTokens(v)
  39720. return nil
  39721. case usagetotal.FieldStartIndex:
  39722. v, ok := value.(int64)
  39723. if !ok {
  39724. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39725. }
  39726. m.AddStartIndex(v)
  39727. return nil
  39728. case usagetotal.FieldEndIndex:
  39729. v, ok := value.(int64)
  39730. if !ok {
  39731. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39732. }
  39733. m.AddEndIndex(v)
  39734. return nil
  39735. case usagetotal.FieldOrganizationID:
  39736. v, ok := value.(int64)
  39737. if !ok {
  39738. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39739. }
  39740. m.AddOrganizationID(v)
  39741. return nil
  39742. }
  39743. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  39744. }
  39745. // ClearedFields returns all nullable fields that were cleared during this
  39746. // mutation.
  39747. func (m *UsageTotalMutation) ClearedFields() []string {
  39748. var fields []string
  39749. if m.FieldCleared(usagetotal.FieldStatus) {
  39750. fields = append(fields, usagetotal.FieldStatus)
  39751. }
  39752. if m.FieldCleared(usagetotal.FieldType) {
  39753. fields = append(fields, usagetotal.FieldType)
  39754. }
  39755. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  39756. fields = append(fields, usagetotal.FieldTotalTokens)
  39757. }
  39758. if m.FieldCleared(usagetotal.FieldStartIndex) {
  39759. fields = append(fields, usagetotal.FieldStartIndex)
  39760. }
  39761. if m.FieldCleared(usagetotal.FieldEndIndex) {
  39762. fields = append(fields, usagetotal.FieldEndIndex)
  39763. }
  39764. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  39765. fields = append(fields, usagetotal.FieldOrganizationID)
  39766. }
  39767. return fields
  39768. }
  39769. // FieldCleared returns a boolean indicating if a field with the given name was
  39770. // cleared in this mutation.
  39771. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  39772. _, ok := m.clearedFields[name]
  39773. return ok
  39774. }
  39775. // ClearField clears the value of the field with the given name. It returns an
  39776. // error if the field is not defined in the schema.
  39777. func (m *UsageTotalMutation) ClearField(name string) error {
  39778. switch name {
  39779. case usagetotal.FieldStatus:
  39780. m.ClearStatus()
  39781. return nil
  39782. case usagetotal.FieldType:
  39783. m.ClearType()
  39784. return nil
  39785. case usagetotal.FieldTotalTokens:
  39786. m.ClearTotalTokens()
  39787. return nil
  39788. case usagetotal.FieldStartIndex:
  39789. m.ClearStartIndex()
  39790. return nil
  39791. case usagetotal.FieldEndIndex:
  39792. m.ClearEndIndex()
  39793. return nil
  39794. case usagetotal.FieldOrganizationID:
  39795. m.ClearOrganizationID()
  39796. return nil
  39797. }
  39798. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  39799. }
  39800. // ResetField resets all changes in the mutation for the field with the given name.
  39801. // It returns an error if the field is not defined in the schema.
  39802. func (m *UsageTotalMutation) ResetField(name string) error {
  39803. switch name {
  39804. case usagetotal.FieldCreatedAt:
  39805. m.ResetCreatedAt()
  39806. return nil
  39807. case usagetotal.FieldUpdatedAt:
  39808. m.ResetUpdatedAt()
  39809. return nil
  39810. case usagetotal.FieldStatus:
  39811. m.ResetStatus()
  39812. return nil
  39813. case usagetotal.FieldType:
  39814. m.ResetType()
  39815. return nil
  39816. case usagetotal.FieldBotID:
  39817. m.ResetBotID()
  39818. return nil
  39819. case usagetotal.FieldTotalTokens:
  39820. m.ResetTotalTokens()
  39821. return nil
  39822. case usagetotal.FieldStartIndex:
  39823. m.ResetStartIndex()
  39824. return nil
  39825. case usagetotal.FieldEndIndex:
  39826. m.ResetEndIndex()
  39827. return nil
  39828. case usagetotal.FieldOrganizationID:
  39829. m.ResetOrganizationID()
  39830. return nil
  39831. }
  39832. return fmt.Errorf("unknown UsageTotal field %s", name)
  39833. }
  39834. // AddedEdges returns all edge names that were set/added in this mutation.
  39835. func (m *UsageTotalMutation) AddedEdges() []string {
  39836. edges := make([]string, 0, 0)
  39837. return edges
  39838. }
  39839. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  39840. // name in this mutation.
  39841. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  39842. return nil
  39843. }
  39844. // RemovedEdges returns all edge names that were removed in this mutation.
  39845. func (m *UsageTotalMutation) RemovedEdges() []string {
  39846. edges := make([]string, 0, 0)
  39847. return edges
  39848. }
  39849. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39850. // the given name in this mutation.
  39851. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  39852. return nil
  39853. }
  39854. // ClearedEdges returns all edge names that were cleared in this mutation.
  39855. func (m *UsageTotalMutation) ClearedEdges() []string {
  39856. edges := make([]string, 0, 0)
  39857. return edges
  39858. }
  39859. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39860. // was cleared in this mutation.
  39861. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  39862. return false
  39863. }
  39864. // ClearEdge clears the value of the edge with the given name. It returns an error
  39865. // if that edge is not defined in the schema.
  39866. func (m *UsageTotalMutation) ClearEdge(name string) error {
  39867. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  39868. }
  39869. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39870. // It returns an error if the edge is not defined in the schema.
  39871. func (m *UsageTotalMutation) ResetEdge(name string) error {
  39872. return fmt.Errorf("unknown UsageTotal edge %s", name)
  39873. }
  39874. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  39875. type WhatsappMutation struct {
  39876. config
  39877. op Op
  39878. typ string
  39879. id *uint64
  39880. created_at *time.Time
  39881. updated_at *time.Time
  39882. status *uint8
  39883. addstatus *int8
  39884. deleted_at *time.Time
  39885. wa_id *string
  39886. wa_name *string
  39887. callback *string
  39888. account *string
  39889. cc *string
  39890. phone *string
  39891. cc_phone *string
  39892. phone_name *string
  39893. phone_status *int8
  39894. addphone_status *int8
  39895. organization_id *uint64
  39896. addorganization_id *int64
  39897. api_base *string
  39898. api_key *string
  39899. allow_list *[]string
  39900. appendallow_list []string
  39901. group_allow_list *[]string
  39902. appendgroup_allow_list []string
  39903. block_list *[]string
  39904. appendblock_list []string
  39905. group_block_list *[]string
  39906. appendgroup_block_list []string
  39907. clearedFields map[string]struct{}
  39908. agent *uint64
  39909. clearedagent bool
  39910. done bool
  39911. oldValue func(context.Context) (*Whatsapp, error)
  39912. predicates []predicate.Whatsapp
  39913. }
  39914. var _ ent.Mutation = (*WhatsappMutation)(nil)
  39915. // whatsappOption allows management of the mutation configuration using functional options.
  39916. type whatsappOption func(*WhatsappMutation)
  39917. // newWhatsappMutation creates new mutation for the Whatsapp entity.
  39918. func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
  39919. m := &WhatsappMutation{
  39920. config: c,
  39921. op: op,
  39922. typ: TypeWhatsapp,
  39923. clearedFields: make(map[string]struct{}),
  39924. }
  39925. for _, opt := range opts {
  39926. opt(m)
  39927. }
  39928. return m
  39929. }
  39930. // withWhatsappID sets the ID field of the mutation.
  39931. func withWhatsappID(id uint64) whatsappOption {
  39932. return func(m *WhatsappMutation) {
  39933. var (
  39934. err error
  39935. once sync.Once
  39936. value *Whatsapp
  39937. )
  39938. m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
  39939. once.Do(func() {
  39940. if m.done {
  39941. err = errors.New("querying old values post mutation is not allowed")
  39942. } else {
  39943. value, err = m.Client().Whatsapp.Get(ctx, id)
  39944. }
  39945. })
  39946. return value, err
  39947. }
  39948. m.id = &id
  39949. }
  39950. }
  39951. // withWhatsapp sets the old Whatsapp of the mutation.
  39952. func withWhatsapp(node *Whatsapp) whatsappOption {
  39953. return func(m *WhatsappMutation) {
  39954. m.oldValue = func(context.Context) (*Whatsapp, error) {
  39955. return node, nil
  39956. }
  39957. m.id = &node.ID
  39958. }
  39959. }
  39960. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39961. // executed in a transaction (ent.Tx), a transactional client is returned.
  39962. func (m WhatsappMutation) Client() *Client {
  39963. client := &Client{config: m.config}
  39964. client.init()
  39965. return client
  39966. }
  39967. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39968. // it returns an error otherwise.
  39969. func (m WhatsappMutation) Tx() (*Tx, error) {
  39970. if _, ok := m.driver.(*txDriver); !ok {
  39971. return nil, errors.New("ent: mutation is not running in a transaction")
  39972. }
  39973. tx := &Tx{config: m.config}
  39974. tx.init()
  39975. return tx, nil
  39976. }
  39977. // SetID sets the value of the id field. Note that this
  39978. // operation is only accepted on creation of Whatsapp entities.
  39979. func (m *WhatsappMutation) SetID(id uint64) {
  39980. m.id = &id
  39981. }
  39982. // ID returns the ID value in the mutation. Note that the ID is only available
  39983. // if it was provided to the builder or after it was returned from the database.
  39984. func (m *WhatsappMutation) ID() (id uint64, exists bool) {
  39985. if m.id == nil {
  39986. return
  39987. }
  39988. return *m.id, true
  39989. }
  39990. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39991. // That means, if the mutation is applied within a transaction with an isolation level such
  39992. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39993. // or updated by the mutation.
  39994. func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
  39995. switch {
  39996. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39997. id, exists := m.ID()
  39998. if exists {
  39999. return []uint64{id}, nil
  40000. }
  40001. fallthrough
  40002. case m.op.Is(OpUpdate | OpDelete):
  40003. return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
  40004. default:
  40005. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  40006. }
  40007. }
  40008. // SetCreatedAt sets the "created_at" field.
  40009. func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
  40010. m.created_at = &t
  40011. }
  40012. // CreatedAt returns the value of the "created_at" field in the mutation.
  40013. func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
  40014. v := m.created_at
  40015. if v == nil {
  40016. return
  40017. }
  40018. return *v, true
  40019. }
  40020. // OldCreatedAt returns the old "created_at" field's value of the Whatsapp entity.
  40021. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40022. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40023. func (m *WhatsappMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  40024. if !m.op.Is(OpUpdateOne) {
  40025. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  40026. }
  40027. if m.id == nil || m.oldValue == nil {
  40028. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  40029. }
  40030. oldValue, err := m.oldValue(ctx)
  40031. if err != nil {
  40032. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  40033. }
  40034. return oldValue.CreatedAt, nil
  40035. }
  40036. // ResetCreatedAt resets all changes to the "created_at" field.
  40037. func (m *WhatsappMutation) ResetCreatedAt() {
  40038. m.created_at = nil
  40039. }
  40040. // SetUpdatedAt sets the "updated_at" field.
  40041. func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
  40042. m.updated_at = &t
  40043. }
  40044. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  40045. func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
  40046. v := m.updated_at
  40047. if v == nil {
  40048. return
  40049. }
  40050. return *v, true
  40051. }
  40052. // OldUpdatedAt returns the old "updated_at" field's value of the Whatsapp entity.
  40053. // If the Whatsapp 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 *WhatsappMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  40056. if !m.op.Is(OpUpdateOne) {
  40057. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  40058. }
  40059. if m.id == nil || m.oldValue == nil {
  40060. return v, errors.New("OldUpdatedAt 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 OldUpdatedAt: %w", err)
  40065. }
  40066. return oldValue.UpdatedAt, nil
  40067. }
  40068. // ResetUpdatedAt resets all changes to the "updated_at" field.
  40069. func (m *WhatsappMutation) ResetUpdatedAt() {
  40070. m.updated_at = nil
  40071. }
  40072. // SetStatus sets the "status" field.
  40073. func (m *WhatsappMutation) SetStatus(u uint8) {
  40074. m.status = &u
  40075. m.addstatus = nil
  40076. }
  40077. // Status returns the value of the "status" field in the mutation.
  40078. func (m *WhatsappMutation) Status() (r uint8, exists bool) {
  40079. v := m.status
  40080. if v == nil {
  40081. return
  40082. }
  40083. return *v, true
  40084. }
  40085. // OldStatus returns the old "status" field's value of the Whatsapp entity.
  40086. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40087. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40088. func (m *WhatsappMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  40089. if !m.op.Is(OpUpdateOne) {
  40090. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  40091. }
  40092. if m.id == nil || m.oldValue == nil {
  40093. return v, errors.New("OldStatus requires an ID field in the mutation")
  40094. }
  40095. oldValue, err := m.oldValue(ctx)
  40096. if err != nil {
  40097. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  40098. }
  40099. return oldValue.Status, nil
  40100. }
  40101. // AddStatus adds u to the "status" field.
  40102. func (m *WhatsappMutation) AddStatus(u int8) {
  40103. if m.addstatus != nil {
  40104. *m.addstatus += u
  40105. } else {
  40106. m.addstatus = &u
  40107. }
  40108. }
  40109. // AddedStatus returns the value that was added to the "status" field in this mutation.
  40110. func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
  40111. v := m.addstatus
  40112. if v == nil {
  40113. return
  40114. }
  40115. return *v, true
  40116. }
  40117. // ClearStatus clears the value of the "status" field.
  40118. func (m *WhatsappMutation) ClearStatus() {
  40119. m.status = nil
  40120. m.addstatus = nil
  40121. m.clearedFields[whatsapp.FieldStatus] = struct{}{}
  40122. }
  40123. // StatusCleared returns if the "status" field was cleared in this mutation.
  40124. func (m *WhatsappMutation) StatusCleared() bool {
  40125. _, ok := m.clearedFields[whatsapp.FieldStatus]
  40126. return ok
  40127. }
  40128. // ResetStatus resets all changes to the "status" field.
  40129. func (m *WhatsappMutation) ResetStatus() {
  40130. m.status = nil
  40131. m.addstatus = nil
  40132. delete(m.clearedFields, whatsapp.FieldStatus)
  40133. }
  40134. // SetDeletedAt sets the "deleted_at" field.
  40135. func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
  40136. m.deleted_at = &t
  40137. }
  40138. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  40139. func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
  40140. v := m.deleted_at
  40141. if v == nil {
  40142. return
  40143. }
  40144. return *v, true
  40145. }
  40146. // OldDeletedAt returns the old "deleted_at" field's value of the Whatsapp entity.
  40147. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40148. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40149. func (m *WhatsappMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  40150. if !m.op.Is(OpUpdateOne) {
  40151. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  40152. }
  40153. if m.id == nil || m.oldValue == nil {
  40154. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  40155. }
  40156. oldValue, err := m.oldValue(ctx)
  40157. if err != nil {
  40158. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  40159. }
  40160. return oldValue.DeletedAt, nil
  40161. }
  40162. // ClearDeletedAt clears the value of the "deleted_at" field.
  40163. func (m *WhatsappMutation) ClearDeletedAt() {
  40164. m.deleted_at = nil
  40165. m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
  40166. }
  40167. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  40168. func (m *WhatsappMutation) DeletedAtCleared() bool {
  40169. _, ok := m.clearedFields[whatsapp.FieldDeletedAt]
  40170. return ok
  40171. }
  40172. // ResetDeletedAt resets all changes to the "deleted_at" field.
  40173. func (m *WhatsappMutation) ResetDeletedAt() {
  40174. m.deleted_at = nil
  40175. delete(m.clearedFields, whatsapp.FieldDeletedAt)
  40176. }
  40177. // SetWaID sets the "wa_id" field.
  40178. func (m *WhatsappMutation) SetWaID(s string) {
  40179. m.wa_id = &s
  40180. }
  40181. // WaID returns the value of the "wa_id" field in the mutation.
  40182. func (m *WhatsappMutation) WaID() (r string, exists bool) {
  40183. v := m.wa_id
  40184. if v == nil {
  40185. return
  40186. }
  40187. return *v, true
  40188. }
  40189. // OldWaID returns the old "wa_id" field's value of the Whatsapp entity.
  40190. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40191. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40192. func (m *WhatsappMutation) OldWaID(ctx context.Context) (v string, err error) {
  40193. if !m.op.Is(OpUpdateOne) {
  40194. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  40195. }
  40196. if m.id == nil || m.oldValue == nil {
  40197. return v, errors.New("OldWaID requires an ID field in the mutation")
  40198. }
  40199. oldValue, err := m.oldValue(ctx)
  40200. if err != nil {
  40201. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  40202. }
  40203. return oldValue.WaID, nil
  40204. }
  40205. // ClearWaID clears the value of the "wa_id" field.
  40206. func (m *WhatsappMutation) ClearWaID() {
  40207. m.wa_id = nil
  40208. m.clearedFields[whatsapp.FieldWaID] = struct{}{}
  40209. }
  40210. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  40211. func (m *WhatsappMutation) WaIDCleared() bool {
  40212. _, ok := m.clearedFields[whatsapp.FieldWaID]
  40213. return ok
  40214. }
  40215. // ResetWaID resets all changes to the "wa_id" field.
  40216. func (m *WhatsappMutation) ResetWaID() {
  40217. m.wa_id = nil
  40218. delete(m.clearedFields, whatsapp.FieldWaID)
  40219. }
  40220. // SetWaName sets the "wa_name" field.
  40221. func (m *WhatsappMutation) SetWaName(s string) {
  40222. m.wa_name = &s
  40223. }
  40224. // WaName returns the value of the "wa_name" field in the mutation.
  40225. func (m *WhatsappMutation) WaName() (r string, exists bool) {
  40226. v := m.wa_name
  40227. if v == nil {
  40228. return
  40229. }
  40230. return *v, true
  40231. }
  40232. // OldWaName returns the old "wa_name" field's value of the Whatsapp entity.
  40233. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40234. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40235. func (m *WhatsappMutation) OldWaName(ctx context.Context) (v string, err error) {
  40236. if !m.op.Is(OpUpdateOne) {
  40237. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  40238. }
  40239. if m.id == nil || m.oldValue == nil {
  40240. return v, errors.New("OldWaName requires an ID field in the mutation")
  40241. }
  40242. oldValue, err := m.oldValue(ctx)
  40243. if err != nil {
  40244. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  40245. }
  40246. return oldValue.WaName, nil
  40247. }
  40248. // ClearWaName clears the value of the "wa_name" field.
  40249. func (m *WhatsappMutation) ClearWaName() {
  40250. m.wa_name = nil
  40251. m.clearedFields[whatsapp.FieldWaName] = struct{}{}
  40252. }
  40253. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  40254. func (m *WhatsappMutation) WaNameCleared() bool {
  40255. _, ok := m.clearedFields[whatsapp.FieldWaName]
  40256. return ok
  40257. }
  40258. // ResetWaName resets all changes to the "wa_name" field.
  40259. func (m *WhatsappMutation) ResetWaName() {
  40260. m.wa_name = nil
  40261. delete(m.clearedFields, whatsapp.FieldWaName)
  40262. }
  40263. // SetCallback sets the "callback" field.
  40264. func (m *WhatsappMutation) SetCallback(s string) {
  40265. m.callback = &s
  40266. }
  40267. // Callback returns the value of the "callback" field in the mutation.
  40268. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  40269. v := m.callback
  40270. if v == nil {
  40271. return
  40272. }
  40273. return *v, true
  40274. }
  40275. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  40276. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40277. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40278. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  40279. if !m.op.Is(OpUpdateOne) {
  40280. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  40281. }
  40282. if m.id == nil || m.oldValue == nil {
  40283. return v, errors.New("OldCallback requires an ID field in the mutation")
  40284. }
  40285. oldValue, err := m.oldValue(ctx)
  40286. if err != nil {
  40287. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  40288. }
  40289. return oldValue.Callback, nil
  40290. }
  40291. // ClearCallback clears the value of the "callback" field.
  40292. func (m *WhatsappMutation) ClearCallback() {
  40293. m.callback = nil
  40294. m.clearedFields[whatsapp.FieldCallback] = struct{}{}
  40295. }
  40296. // CallbackCleared returns if the "callback" field was cleared in this mutation.
  40297. func (m *WhatsappMutation) CallbackCleared() bool {
  40298. _, ok := m.clearedFields[whatsapp.FieldCallback]
  40299. return ok
  40300. }
  40301. // ResetCallback resets all changes to the "callback" field.
  40302. func (m *WhatsappMutation) ResetCallback() {
  40303. m.callback = nil
  40304. delete(m.clearedFields, whatsapp.FieldCallback)
  40305. }
  40306. // SetAgentID sets the "agent_id" field.
  40307. func (m *WhatsappMutation) SetAgentID(u uint64) {
  40308. m.agent = &u
  40309. }
  40310. // AgentID returns the value of the "agent_id" field in the mutation.
  40311. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  40312. v := m.agent
  40313. if v == nil {
  40314. return
  40315. }
  40316. return *v, true
  40317. }
  40318. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  40319. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40320. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40321. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  40322. if !m.op.Is(OpUpdateOne) {
  40323. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  40324. }
  40325. if m.id == nil || m.oldValue == nil {
  40326. return v, errors.New("OldAgentID requires an ID field in the mutation")
  40327. }
  40328. oldValue, err := m.oldValue(ctx)
  40329. if err != nil {
  40330. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  40331. }
  40332. return oldValue.AgentID, nil
  40333. }
  40334. // ResetAgentID resets all changes to the "agent_id" field.
  40335. func (m *WhatsappMutation) ResetAgentID() {
  40336. m.agent = nil
  40337. }
  40338. // SetAccount sets the "account" field.
  40339. func (m *WhatsappMutation) SetAccount(s string) {
  40340. m.account = &s
  40341. }
  40342. // Account returns the value of the "account" field in the mutation.
  40343. func (m *WhatsappMutation) Account() (r string, exists bool) {
  40344. v := m.account
  40345. if v == nil {
  40346. return
  40347. }
  40348. return *v, true
  40349. }
  40350. // OldAccount returns the old "account" field's value of the Whatsapp entity.
  40351. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40352. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40353. func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error) {
  40354. if !m.op.Is(OpUpdateOne) {
  40355. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  40356. }
  40357. if m.id == nil || m.oldValue == nil {
  40358. return v, errors.New("OldAccount requires an ID field in the mutation")
  40359. }
  40360. oldValue, err := m.oldValue(ctx)
  40361. if err != nil {
  40362. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  40363. }
  40364. return oldValue.Account, nil
  40365. }
  40366. // ClearAccount clears the value of the "account" field.
  40367. func (m *WhatsappMutation) ClearAccount() {
  40368. m.account = nil
  40369. m.clearedFields[whatsapp.FieldAccount] = struct{}{}
  40370. }
  40371. // AccountCleared returns if the "account" field was cleared in this mutation.
  40372. func (m *WhatsappMutation) AccountCleared() bool {
  40373. _, ok := m.clearedFields[whatsapp.FieldAccount]
  40374. return ok
  40375. }
  40376. // ResetAccount resets all changes to the "account" field.
  40377. func (m *WhatsappMutation) ResetAccount() {
  40378. m.account = nil
  40379. delete(m.clearedFields, whatsapp.FieldAccount)
  40380. }
  40381. // SetCc sets the "cc" field.
  40382. func (m *WhatsappMutation) SetCc(s string) {
  40383. m.cc = &s
  40384. }
  40385. // Cc returns the value of the "cc" field in the mutation.
  40386. func (m *WhatsappMutation) Cc() (r string, exists bool) {
  40387. v := m.cc
  40388. if v == nil {
  40389. return
  40390. }
  40391. return *v, true
  40392. }
  40393. // OldCc returns the old "cc" field's value of the Whatsapp entity.
  40394. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40395. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40396. func (m *WhatsappMutation) OldCc(ctx context.Context) (v string, err error) {
  40397. if !m.op.Is(OpUpdateOne) {
  40398. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  40399. }
  40400. if m.id == nil || m.oldValue == nil {
  40401. return v, errors.New("OldCc requires an ID field in the mutation")
  40402. }
  40403. oldValue, err := m.oldValue(ctx)
  40404. if err != nil {
  40405. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  40406. }
  40407. return oldValue.Cc, nil
  40408. }
  40409. // ResetCc resets all changes to the "cc" field.
  40410. func (m *WhatsappMutation) ResetCc() {
  40411. m.cc = nil
  40412. }
  40413. // SetPhone sets the "phone" field.
  40414. func (m *WhatsappMutation) SetPhone(s string) {
  40415. m.phone = &s
  40416. }
  40417. // Phone returns the value of the "phone" field in the mutation.
  40418. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  40419. v := m.phone
  40420. if v == nil {
  40421. return
  40422. }
  40423. return *v, true
  40424. }
  40425. // OldPhone returns the old "phone" field's value of the Whatsapp entity.
  40426. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40427. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40428. func (m *WhatsappMutation) OldPhone(ctx context.Context) (v string, err error) {
  40429. if !m.op.Is(OpUpdateOne) {
  40430. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  40431. }
  40432. if m.id == nil || m.oldValue == nil {
  40433. return v, errors.New("OldPhone requires an ID field in the mutation")
  40434. }
  40435. oldValue, err := m.oldValue(ctx)
  40436. if err != nil {
  40437. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  40438. }
  40439. return oldValue.Phone, nil
  40440. }
  40441. // ResetPhone resets all changes to the "phone" field.
  40442. func (m *WhatsappMutation) ResetPhone() {
  40443. m.phone = nil
  40444. }
  40445. // SetCcPhone sets the "cc_phone" field.
  40446. func (m *WhatsappMutation) SetCcPhone(s string) {
  40447. m.cc_phone = &s
  40448. }
  40449. // CcPhone returns the value of the "cc_phone" field in the mutation.
  40450. func (m *WhatsappMutation) CcPhone() (r string, exists bool) {
  40451. v := m.cc_phone
  40452. if v == nil {
  40453. return
  40454. }
  40455. return *v, true
  40456. }
  40457. // OldCcPhone returns the old "cc_phone" field's value of the Whatsapp entity.
  40458. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40459. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40460. func (m *WhatsappMutation) OldCcPhone(ctx context.Context) (v string, err error) {
  40461. if !m.op.Is(OpUpdateOne) {
  40462. return v, errors.New("OldCcPhone is only allowed on UpdateOne operations")
  40463. }
  40464. if m.id == nil || m.oldValue == nil {
  40465. return v, errors.New("OldCcPhone requires an ID field in the mutation")
  40466. }
  40467. oldValue, err := m.oldValue(ctx)
  40468. if err != nil {
  40469. return v, fmt.Errorf("querying old value for OldCcPhone: %w", err)
  40470. }
  40471. return oldValue.CcPhone, nil
  40472. }
  40473. // ResetCcPhone resets all changes to the "cc_phone" field.
  40474. func (m *WhatsappMutation) ResetCcPhone() {
  40475. m.cc_phone = nil
  40476. }
  40477. // SetPhoneName sets the "phone_name" field.
  40478. func (m *WhatsappMutation) SetPhoneName(s string) {
  40479. m.phone_name = &s
  40480. }
  40481. // PhoneName returns the value of the "phone_name" field in the mutation.
  40482. func (m *WhatsappMutation) PhoneName() (r string, exists bool) {
  40483. v := m.phone_name
  40484. if v == nil {
  40485. return
  40486. }
  40487. return *v, true
  40488. }
  40489. // OldPhoneName returns the old "phone_name" field's value of the Whatsapp entity.
  40490. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40491. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40492. func (m *WhatsappMutation) OldPhoneName(ctx context.Context) (v string, err error) {
  40493. if !m.op.Is(OpUpdateOne) {
  40494. return v, errors.New("OldPhoneName is only allowed on UpdateOne operations")
  40495. }
  40496. if m.id == nil || m.oldValue == nil {
  40497. return v, errors.New("OldPhoneName requires an ID field in the mutation")
  40498. }
  40499. oldValue, err := m.oldValue(ctx)
  40500. if err != nil {
  40501. return v, fmt.Errorf("querying old value for OldPhoneName: %w", err)
  40502. }
  40503. return oldValue.PhoneName, nil
  40504. }
  40505. // ResetPhoneName resets all changes to the "phone_name" field.
  40506. func (m *WhatsappMutation) ResetPhoneName() {
  40507. m.phone_name = nil
  40508. }
  40509. // SetPhoneStatus sets the "phone_status" field.
  40510. func (m *WhatsappMutation) SetPhoneStatus(i int8) {
  40511. m.phone_status = &i
  40512. m.addphone_status = nil
  40513. }
  40514. // PhoneStatus returns the value of the "phone_status" field in the mutation.
  40515. func (m *WhatsappMutation) PhoneStatus() (r int8, exists bool) {
  40516. v := m.phone_status
  40517. if v == nil {
  40518. return
  40519. }
  40520. return *v, true
  40521. }
  40522. // OldPhoneStatus returns the old "phone_status" field's value of the Whatsapp entity.
  40523. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40524. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40525. func (m *WhatsappMutation) OldPhoneStatus(ctx context.Context) (v int8, err error) {
  40526. if !m.op.Is(OpUpdateOne) {
  40527. return v, errors.New("OldPhoneStatus is only allowed on UpdateOne operations")
  40528. }
  40529. if m.id == nil || m.oldValue == nil {
  40530. return v, errors.New("OldPhoneStatus requires an ID field in the mutation")
  40531. }
  40532. oldValue, err := m.oldValue(ctx)
  40533. if err != nil {
  40534. return v, fmt.Errorf("querying old value for OldPhoneStatus: %w", err)
  40535. }
  40536. return oldValue.PhoneStatus, nil
  40537. }
  40538. // AddPhoneStatus adds i to the "phone_status" field.
  40539. func (m *WhatsappMutation) AddPhoneStatus(i int8) {
  40540. if m.addphone_status != nil {
  40541. *m.addphone_status += i
  40542. } else {
  40543. m.addphone_status = &i
  40544. }
  40545. }
  40546. // AddedPhoneStatus returns the value that was added to the "phone_status" field in this mutation.
  40547. func (m *WhatsappMutation) AddedPhoneStatus() (r int8, exists bool) {
  40548. v := m.addphone_status
  40549. if v == nil {
  40550. return
  40551. }
  40552. return *v, true
  40553. }
  40554. // ResetPhoneStatus resets all changes to the "phone_status" field.
  40555. func (m *WhatsappMutation) ResetPhoneStatus() {
  40556. m.phone_status = nil
  40557. m.addphone_status = nil
  40558. }
  40559. // SetOrganizationID sets the "organization_id" field.
  40560. func (m *WhatsappMutation) SetOrganizationID(u uint64) {
  40561. m.organization_id = &u
  40562. m.addorganization_id = nil
  40563. }
  40564. // OrganizationID returns the value of the "organization_id" field in the mutation.
  40565. func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
  40566. v := m.organization_id
  40567. if v == nil {
  40568. return
  40569. }
  40570. return *v, true
  40571. }
  40572. // OldOrganizationID returns the old "organization_id" field's value of the Whatsapp entity.
  40573. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40574. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40575. func (m *WhatsappMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  40576. if !m.op.Is(OpUpdateOne) {
  40577. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  40578. }
  40579. if m.id == nil || m.oldValue == nil {
  40580. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  40581. }
  40582. oldValue, err := m.oldValue(ctx)
  40583. if err != nil {
  40584. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  40585. }
  40586. return oldValue.OrganizationID, nil
  40587. }
  40588. // AddOrganizationID adds u to the "organization_id" field.
  40589. func (m *WhatsappMutation) AddOrganizationID(u int64) {
  40590. if m.addorganization_id != nil {
  40591. *m.addorganization_id += u
  40592. } else {
  40593. m.addorganization_id = &u
  40594. }
  40595. }
  40596. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  40597. func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
  40598. v := m.addorganization_id
  40599. if v == nil {
  40600. return
  40601. }
  40602. return *v, true
  40603. }
  40604. // ClearOrganizationID clears the value of the "organization_id" field.
  40605. func (m *WhatsappMutation) ClearOrganizationID() {
  40606. m.organization_id = nil
  40607. m.addorganization_id = nil
  40608. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  40609. }
  40610. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  40611. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  40612. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  40613. return ok
  40614. }
  40615. // ResetOrganizationID resets all changes to the "organization_id" field.
  40616. func (m *WhatsappMutation) ResetOrganizationID() {
  40617. m.organization_id = nil
  40618. m.addorganization_id = nil
  40619. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  40620. }
  40621. // SetAPIBase sets the "api_base" field.
  40622. func (m *WhatsappMutation) SetAPIBase(s string) {
  40623. m.api_base = &s
  40624. }
  40625. // APIBase returns the value of the "api_base" field in the mutation.
  40626. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  40627. v := m.api_base
  40628. if v == nil {
  40629. return
  40630. }
  40631. return *v, true
  40632. }
  40633. // OldAPIBase returns the old "api_base" field's value of the Whatsapp entity.
  40634. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40636. func (m *WhatsappMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  40637. if !m.op.Is(OpUpdateOne) {
  40638. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  40639. }
  40640. if m.id == nil || m.oldValue == nil {
  40641. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  40642. }
  40643. oldValue, err := m.oldValue(ctx)
  40644. if err != nil {
  40645. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  40646. }
  40647. return oldValue.APIBase, nil
  40648. }
  40649. // ClearAPIBase clears the value of the "api_base" field.
  40650. func (m *WhatsappMutation) ClearAPIBase() {
  40651. m.api_base = nil
  40652. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  40653. }
  40654. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  40655. func (m *WhatsappMutation) APIBaseCleared() bool {
  40656. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  40657. return ok
  40658. }
  40659. // ResetAPIBase resets all changes to the "api_base" field.
  40660. func (m *WhatsappMutation) ResetAPIBase() {
  40661. m.api_base = nil
  40662. delete(m.clearedFields, whatsapp.FieldAPIBase)
  40663. }
  40664. // SetAPIKey sets the "api_key" field.
  40665. func (m *WhatsappMutation) SetAPIKey(s string) {
  40666. m.api_key = &s
  40667. }
  40668. // APIKey returns the value of the "api_key" field in the mutation.
  40669. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  40670. v := m.api_key
  40671. if v == nil {
  40672. return
  40673. }
  40674. return *v, true
  40675. }
  40676. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  40677. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40678. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40679. func (m *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  40680. if !m.op.Is(OpUpdateOne) {
  40681. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  40682. }
  40683. if m.id == nil || m.oldValue == nil {
  40684. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  40685. }
  40686. oldValue, err := m.oldValue(ctx)
  40687. if err != nil {
  40688. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  40689. }
  40690. return oldValue.APIKey, nil
  40691. }
  40692. // ClearAPIKey clears the value of the "api_key" field.
  40693. func (m *WhatsappMutation) ClearAPIKey() {
  40694. m.api_key = nil
  40695. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  40696. }
  40697. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  40698. func (m *WhatsappMutation) APIKeyCleared() bool {
  40699. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  40700. return ok
  40701. }
  40702. // ResetAPIKey resets all changes to the "api_key" field.
  40703. func (m *WhatsappMutation) ResetAPIKey() {
  40704. m.api_key = nil
  40705. delete(m.clearedFields, whatsapp.FieldAPIKey)
  40706. }
  40707. // SetAllowList sets the "allow_list" field.
  40708. func (m *WhatsappMutation) SetAllowList(s []string) {
  40709. m.allow_list = &s
  40710. m.appendallow_list = nil
  40711. }
  40712. // AllowList returns the value of the "allow_list" field in the mutation.
  40713. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  40714. v := m.allow_list
  40715. if v == nil {
  40716. return
  40717. }
  40718. return *v, true
  40719. }
  40720. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  40721. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40722. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40723. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  40724. if !m.op.Is(OpUpdateOne) {
  40725. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  40726. }
  40727. if m.id == nil || m.oldValue == nil {
  40728. return v, errors.New("OldAllowList requires an ID field in the mutation")
  40729. }
  40730. oldValue, err := m.oldValue(ctx)
  40731. if err != nil {
  40732. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  40733. }
  40734. return oldValue.AllowList, nil
  40735. }
  40736. // AppendAllowList adds s to the "allow_list" field.
  40737. func (m *WhatsappMutation) AppendAllowList(s []string) {
  40738. m.appendallow_list = append(m.appendallow_list, s...)
  40739. }
  40740. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  40741. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  40742. if len(m.appendallow_list) == 0 {
  40743. return nil, false
  40744. }
  40745. return m.appendallow_list, true
  40746. }
  40747. // ClearAllowList clears the value of the "allow_list" field.
  40748. func (m *WhatsappMutation) ClearAllowList() {
  40749. m.allow_list = nil
  40750. m.appendallow_list = nil
  40751. m.clearedFields[whatsapp.FieldAllowList] = struct{}{}
  40752. }
  40753. // AllowListCleared returns if the "allow_list" field was cleared in this mutation.
  40754. func (m *WhatsappMutation) AllowListCleared() bool {
  40755. _, ok := m.clearedFields[whatsapp.FieldAllowList]
  40756. return ok
  40757. }
  40758. // ResetAllowList resets all changes to the "allow_list" field.
  40759. func (m *WhatsappMutation) ResetAllowList() {
  40760. m.allow_list = nil
  40761. m.appendallow_list = nil
  40762. delete(m.clearedFields, whatsapp.FieldAllowList)
  40763. }
  40764. // SetGroupAllowList sets the "group_allow_list" field.
  40765. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  40766. m.group_allow_list = &s
  40767. m.appendgroup_allow_list = nil
  40768. }
  40769. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  40770. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  40771. v := m.group_allow_list
  40772. if v == nil {
  40773. return
  40774. }
  40775. return *v, true
  40776. }
  40777. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  40778. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40780. func (m *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  40781. if !m.op.Is(OpUpdateOne) {
  40782. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  40783. }
  40784. if m.id == nil || m.oldValue == nil {
  40785. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  40786. }
  40787. oldValue, err := m.oldValue(ctx)
  40788. if err != nil {
  40789. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  40790. }
  40791. return oldValue.GroupAllowList, nil
  40792. }
  40793. // AppendGroupAllowList adds s to the "group_allow_list" field.
  40794. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  40795. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  40796. }
  40797. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  40798. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  40799. if len(m.appendgroup_allow_list) == 0 {
  40800. return nil, false
  40801. }
  40802. return m.appendgroup_allow_list, true
  40803. }
  40804. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  40805. func (m *WhatsappMutation) ClearGroupAllowList() {
  40806. m.group_allow_list = nil
  40807. m.appendgroup_allow_list = nil
  40808. m.clearedFields[whatsapp.FieldGroupAllowList] = struct{}{}
  40809. }
  40810. // GroupAllowListCleared returns if the "group_allow_list" field was cleared in this mutation.
  40811. func (m *WhatsappMutation) GroupAllowListCleared() bool {
  40812. _, ok := m.clearedFields[whatsapp.FieldGroupAllowList]
  40813. return ok
  40814. }
  40815. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  40816. func (m *WhatsappMutation) ResetGroupAllowList() {
  40817. m.group_allow_list = nil
  40818. m.appendgroup_allow_list = nil
  40819. delete(m.clearedFields, whatsapp.FieldGroupAllowList)
  40820. }
  40821. // SetBlockList sets the "block_list" field.
  40822. func (m *WhatsappMutation) SetBlockList(s []string) {
  40823. m.block_list = &s
  40824. m.appendblock_list = nil
  40825. }
  40826. // BlockList returns the value of the "block_list" field in the mutation.
  40827. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  40828. v := m.block_list
  40829. if v == nil {
  40830. return
  40831. }
  40832. return *v, true
  40833. }
  40834. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  40835. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40836. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40837. func (m *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  40838. if !m.op.Is(OpUpdateOne) {
  40839. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  40840. }
  40841. if m.id == nil || m.oldValue == nil {
  40842. return v, errors.New("OldBlockList requires an ID field in the mutation")
  40843. }
  40844. oldValue, err := m.oldValue(ctx)
  40845. if err != nil {
  40846. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  40847. }
  40848. return oldValue.BlockList, nil
  40849. }
  40850. // AppendBlockList adds s to the "block_list" field.
  40851. func (m *WhatsappMutation) AppendBlockList(s []string) {
  40852. m.appendblock_list = append(m.appendblock_list, s...)
  40853. }
  40854. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  40855. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  40856. if len(m.appendblock_list) == 0 {
  40857. return nil, false
  40858. }
  40859. return m.appendblock_list, true
  40860. }
  40861. // ClearBlockList clears the value of the "block_list" field.
  40862. func (m *WhatsappMutation) ClearBlockList() {
  40863. m.block_list = nil
  40864. m.appendblock_list = nil
  40865. m.clearedFields[whatsapp.FieldBlockList] = struct{}{}
  40866. }
  40867. // BlockListCleared returns if the "block_list" field was cleared in this mutation.
  40868. func (m *WhatsappMutation) BlockListCleared() bool {
  40869. _, ok := m.clearedFields[whatsapp.FieldBlockList]
  40870. return ok
  40871. }
  40872. // ResetBlockList resets all changes to the "block_list" field.
  40873. func (m *WhatsappMutation) ResetBlockList() {
  40874. m.block_list = nil
  40875. m.appendblock_list = nil
  40876. delete(m.clearedFields, whatsapp.FieldBlockList)
  40877. }
  40878. // SetGroupBlockList sets the "group_block_list" field.
  40879. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  40880. m.group_block_list = &s
  40881. m.appendgroup_block_list = nil
  40882. }
  40883. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  40884. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  40885. v := m.group_block_list
  40886. if v == nil {
  40887. return
  40888. }
  40889. return *v, true
  40890. }
  40891. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  40892. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40893. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40894. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  40895. if !m.op.Is(OpUpdateOne) {
  40896. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  40897. }
  40898. if m.id == nil || m.oldValue == nil {
  40899. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  40900. }
  40901. oldValue, err := m.oldValue(ctx)
  40902. if err != nil {
  40903. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  40904. }
  40905. return oldValue.GroupBlockList, nil
  40906. }
  40907. // AppendGroupBlockList adds s to the "group_block_list" field.
  40908. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  40909. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  40910. }
  40911. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  40912. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  40913. if len(m.appendgroup_block_list) == 0 {
  40914. return nil, false
  40915. }
  40916. return m.appendgroup_block_list, true
  40917. }
  40918. // ClearGroupBlockList clears the value of the "group_block_list" field.
  40919. func (m *WhatsappMutation) ClearGroupBlockList() {
  40920. m.group_block_list = nil
  40921. m.appendgroup_block_list = nil
  40922. m.clearedFields[whatsapp.FieldGroupBlockList] = struct{}{}
  40923. }
  40924. // GroupBlockListCleared returns if the "group_block_list" field was cleared in this mutation.
  40925. func (m *WhatsappMutation) GroupBlockListCleared() bool {
  40926. _, ok := m.clearedFields[whatsapp.FieldGroupBlockList]
  40927. return ok
  40928. }
  40929. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  40930. func (m *WhatsappMutation) ResetGroupBlockList() {
  40931. m.group_block_list = nil
  40932. m.appendgroup_block_list = nil
  40933. delete(m.clearedFields, whatsapp.FieldGroupBlockList)
  40934. }
  40935. // ClearAgent clears the "agent" edge to the Agent entity.
  40936. func (m *WhatsappMutation) ClearAgent() {
  40937. m.clearedagent = true
  40938. m.clearedFields[whatsapp.FieldAgentID] = struct{}{}
  40939. }
  40940. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  40941. func (m *WhatsappMutation) AgentCleared() bool {
  40942. return m.clearedagent
  40943. }
  40944. // AgentIDs returns the "agent" edge IDs in the mutation.
  40945. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  40946. // AgentID instead. It exists only for internal usage by the builders.
  40947. func (m *WhatsappMutation) AgentIDs() (ids []uint64) {
  40948. if id := m.agent; id != nil {
  40949. ids = append(ids, *id)
  40950. }
  40951. return
  40952. }
  40953. // ResetAgent resets all changes to the "agent" edge.
  40954. func (m *WhatsappMutation) ResetAgent() {
  40955. m.agent = nil
  40956. m.clearedagent = false
  40957. }
  40958. // Where appends a list predicates to the WhatsappMutation builder.
  40959. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  40960. m.predicates = append(m.predicates, ps...)
  40961. }
  40962. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  40963. // users can use type-assertion to append predicates that do not depend on any generated package.
  40964. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  40965. p := make([]predicate.Whatsapp, len(ps))
  40966. for i := range ps {
  40967. p[i] = ps[i]
  40968. }
  40969. m.Where(p...)
  40970. }
  40971. // Op returns the operation name.
  40972. func (m *WhatsappMutation) Op() Op {
  40973. return m.op
  40974. }
  40975. // SetOp allows setting the mutation operation.
  40976. func (m *WhatsappMutation) SetOp(op Op) {
  40977. m.op = op
  40978. }
  40979. // Type returns the node type of this mutation (Whatsapp).
  40980. func (m *WhatsappMutation) Type() string {
  40981. return m.typ
  40982. }
  40983. // Fields returns all fields that were changed during this mutation. Note that in
  40984. // order to get all numeric fields that were incremented/decremented, call
  40985. // AddedFields().
  40986. func (m *WhatsappMutation) Fields() []string {
  40987. fields := make([]string, 0, 21)
  40988. if m.created_at != nil {
  40989. fields = append(fields, whatsapp.FieldCreatedAt)
  40990. }
  40991. if m.updated_at != nil {
  40992. fields = append(fields, whatsapp.FieldUpdatedAt)
  40993. }
  40994. if m.status != nil {
  40995. fields = append(fields, whatsapp.FieldStatus)
  40996. }
  40997. if m.deleted_at != nil {
  40998. fields = append(fields, whatsapp.FieldDeletedAt)
  40999. }
  41000. if m.wa_id != nil {
  41001. fields = append(fields, whatsapp.FieldWaID)
  41002. }
  41003. if m.wa_name != nil {
  41004. fields = append(fields, whatsapp.FieldWaName)
  41005. }
  41006. if m.callback != nil {
  41007. fields = append(fields, whatsapp.FieldCallback)
  41008. }
  41009. if m.agent != nil {
  41010. fields = append(fields, whatsapp.FieldAgentID)
  41011. }
  41012. if m.account != nil {
  41013. fields = append(fields, whatsapp.FieldAccount)
  41014. }
  41015. if m.cc != nil {
  41016. fields = append(fields, whatsapp.FieldCc)
  41017. }
  41018. if m.phone != nil {
  41019. fields = append(fields, whatsapp.FieldPhone)
  41020. }
  41021. if m.cc_phone != nil {
  41022. fields = append(fields, whatsapp.FieldCcPhone)
  41023. }
  41024. if m.phone_name != nil {
  41025. fields = append(fields, whatsapp.FieldPhoneName)
  41026. }
  41027. if m.phone_status != nil {
  41028. fields = append(fields, whatsapp.FieldPhoneStatus)
  41029. }
  41030. if m.organization_id != nil {
  41031. fields = append(fields, whatsapp.FieldOrganizationID)
  41032. }
  41033. if m.api_base != nil {
  41034. fields = append(fields, whatsapp.FieldAPIBase)
  41035. }
  41036. if m.api_key != nil {
  41037. fields = append(fields, whatsapp.FieldAPIKey)
  41038. }
  41039. if m.allow_list != nil {
  41040. fields = append(fields, whatsapp.FieldAllowList)
  41041. }
  41042. if m.group_allow_list != nil {
  41043. fields = append(fields, whatsapp.FieldGroupAllowList)
  41044. }
  41045. if m.block_list != nil {
  41046. fields = append(fields, whatsapp.FieldBlockList)
  41047. }
  41048. if m.group_block_list != nil {
  41049. fields = append(fields, whatsapp.FieldGroupBlockList)
  41050. }
  41051. return fields
  41052. }
  41053. // Field returns the value of a field with the given name. The second boolean
  41054. // return value indicates that this field was not set, or was not defined in the
  41055. // schema.
  41056. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  41057. switch name {
  41058. case whatsapp.FieldCreatedAt:
  41059. return m.CreatedAt()
  41060. case whatsapp.FieldUpdatedAt:
  41061. return m.UpdatedAt()
  41062. case whatsapp.FieldStatus:
  41063. return m.Status()
  41064. case whatsapp.FieldDeletedAt:
  41065. return m.DeletedAt()
  41066. case whatsapp.FieldWaID:
  41067. return m.WaID()
  41068. case whatsapp.FieldWaName:
  41069. return m.WaName()
  41070. case whatsapp.FieldCallback:
  41071. return m.Callback()
  41072. case whatsapp.FieldAgentID:
  41073. return m.AgentID()
  41074. case whatsapp.FieldAccount:
  41075. return m.Account()
  41076. case whatsapp.FieldCc:
  41077. return m.Cc()
  41078. case whatsapp.FieldPhone:
  41079. return m.Phone()
  41080. case whatsapp.FieldCcPhone:
  41081. return m.CcPhone()
  41082. case whatsapp.FieldPhoneName:
  41083. return m.PhoneName()
  41084. case whatsapp.FieldPhoneStatus:
  41085. return m.PhoneStatus()
  41086. case whatsapp.FieldOrganizationID:
  41087. return m.OrganizationID()
  41088. case whatsapp.FieldAPIBase:
  41089. return m.APIBase()
  41090. case whatsapp.FieldAPIKey:
  41091. return m.APIKey()
  41092. case whatsapp.FieldAllowList:
  41093. return m.AllowList()
  41094. case whatsapp.FieldGroupAllowList:
  41095. return m.GroupAllowList()
  41096. case whatsapp.FieldBlockList:
  41097. return m.BlockList()
  41098. case whatsapp.FieldGroupBlockList:
  41099. return m.GroupBlockList()
  41100. }
  41101. return nil, false
  41102. }
  41103. // OldField returns the old value of the field from the database. An error is
  41104. // returned if the mutation operation is not UpdateOne, or the query to the
  41105. // database failed.
  41106. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  41107. switch name {
  41108. case whatsapp.FieldCreatedAt:
  41109. return m.OldCreatedAt(ctx)
  41110. case whatsapp.FieldUpdatedAt:
  41111. return m.OldUpdatedAt(ctx)
  41112. case whatsapp.FieldStatus:
  41113. return m.OldStatus(ctx)
  41114. case whatsapp.FieldDeletedAt:
  41115. return m.OldDeletedAt(ctx)
  41116. case whatsapp.FieldWaID:
  41117. return m.OldWaID(ctx)
  41118. case whatsapp.FieldWaName:
  41119. return m.OldWaName(ctx)
  41120. case whatsapp.FieldCallback:
  41121. return m.OldCallback(ctx)
  41122. case whatsapp.FieldAgentID:
  41123. return m.OldAgentID(ctx)
  41124. case whatsapp.FieldAccount:
  41125. return m.OldAccount(ctx)
  41126. case whatsapp.FieldCc:
  41127. return m.OldCc(ctx)
  41128. case whatsapp.FieldPhone:
  41129. return m.OldPhone(ctx)
  41130. case whatsapp.FieldCcPhone:
  41131. return m.OldCcPhone(ctx)
  41132. case whatsapp.FieldPhoneName:
  41133. return m.OldPhoneName(ctx)
  41134. case whatsapp.FieldPhoneStatus:
  41135. return m.OldPhoneStatus(ctx)
  41136. case whatsapp.FieldOrganizationID:
  41137. return m.OldOrganizationID(ctx)
  41138. case whatsapp.FieldAPIBase:
  41139. return m.OldAPIBase(ctx)
  41140. case whatsapp.FieldAPIKey:
  41141. return m.OldAPIKey(ctx)
  41142. case whatsapp.FieldAllowList:
  41143. return m.OldAllowList(ctx)
  41144. case whatsapp.FieldGroupAllowList:
  41145. return m.OldGroupAllowList(ctx)
  41146. case whatsapp.FieldBlockList:
  41147. return m.OldBlockList(ctx)
  41148. case whatsapp.FieldGroupBlockList:
  41149. return m.OldGroupBlockList(ctx)
  41150. }
  41151. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  41152. }
  41153. // SetField sets the value of a field with the given name. It returns an error if
  41154. // the field is not defined in the schema, or if the type mismatched the field
  41155. // type.
  41156. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  41157. switch name {
  41158. case whatsapp.FieldCreatedAt:
  41159. v, ok := value.(time.Time)
  41160. if !ok {
  41161. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41162. }
  41163. m.SetCreatedAt(v)
  41164. return nil
  41165. case whatsapp.FieldUpdatedAt:
  41166. v, ok := value.(time.Time)
  41167. if !ok {
  41168. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41169. }
  41170. m.SetUpdatedAt(v)
  41171. return nil
  41172. case whatsapp.FieldStatus:
  41173. v, ok := value.(uint8)
  41174. if !ok {
  41175. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41176. }
  41177. m.SetStatus(v)
  41178. return nil
  41179. case whatsapp.FieldDeletedAt:
  41180. v, ok := value.(time.Time)
  41181. if !ok {
  41182. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41183. }
  41184. m.SetDeletedAt(v)
  41185. return nil
  41186. case whatsapp.FieldWaID:
  41187. v, ok := value.(string)
  41188. if !ok {
  41189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41190. }
  41191. m.SetWaID(v)
  41192. return nil
  41193. case whatsapp.FieldWaName:
  41194. v, ok := value.(string)
  41195. if !ok {
  41196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41197. }
  41198. m.SetWaName(v)
  41199. return nil
  41200. case whatsapp.FieldCallback:
  41201. v, ok := value.(string)
  41202. if !ok {
  41203. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41204. }
  41205. m.SetCallback(v)
  41206. return nil
  41207. case whatsapp.FieldAgentID:
  41208. v, ok := value.(uint64)
  41209. if !ok {
  41210. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41211. }
  41212. m.SetAgentID(v)
  41213. return nil
  41214. case whatsapp.FieldAccount:
  41215. v, ok := value.(string)
  41216. if !ok {
  41217. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41218. }
  41219. m.SetAccount(v)
  41220. return nil
  41221. case whatsapp.FieldCc:
  41222. v, ok := value.(string)
  41223. if !ok {
  41224. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41225. }
  41226. m.SetCc(v)
  41227. return nil
  41228. case whatsapp.FieldPhone:
  41229. v, ok := value.(string)
  41230. if !ok {
  41231. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41232. }
  41233. m.SetPhone(v)
  41234. return nil
  41235. case whatsapp.FieldCcPhone:
  41236. v, ok := value.(string)
  41237. if !ok {
  41238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41239. }
  41240. m.SetCcPhone(v)
  41241. return nil
  41242. case whatsapp.FieldPhoneName:
  41243. v, ok := value.(string)
  41244. if !ok {
  41245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41246. }
  41247. m.SetPhoneName(v)
  41248. return nil
  41249. case whatsapp.FieldPhoneStatus:
  41250. v, ok := value.(int8)
  41251. if !ok {
  41252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41253. }
  41254. m.SetPhoneStatus(v)
  41255. return nil
  41256. case whatsapp.FieldOrganizationID:
  41257. v, ok := value.(uint64)
  41258. if !ok {
  41259. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41260. }
  41261. m.SetOrganizationID(v)
  41262. return nil
  41263. case whatsapp.FieldAPIBase:
  41264. v, ok := value.(string)
  41265. if !ok {
  41266. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41267. }
  41268. m.SetAPIBase(v)
  41269. return nil
  41270. case whatsapp.FieldAPIKey:
  41271. v, ok := value.(string)
  41272. if !ok {
  41273. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41274. }
  41275. m.SetAPIKey(v)
  41276. return nil
  41277. case whatsapp.FieldAllowList:
  41278. v, ok := value.([]string)
  41279. if !ok {
  41280. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41281. }
  41282. m.SetAllowList(v)
  41283. return nil
  41284. case whatsapp.FieldGroupAllowList:
  41285. v, ok := value.([]string)
  41286. if !ok {
  41287. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41288. }
  41289. m.SetGroupAllowList(v)
  41290. return nil
  41291. case whatsapp.FieldBlockList:
  41292. v, ok := value.([]string)
  41293. if !ok {
  41294. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41295. }
  41296. m.SetBlockList(v)
  41297. return nil
  41298. case whatsapp.FieldGroupBlockList:
  41299. v, ok := value.([]string)
  41300. if !ok {
  41301. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41302. }
  41303. m.SetGroupBlockList(v)
  41304. return nil
  41305. }
  41306. return fmt.Errorf("unknown Whatsapp field %s", name)
  41307. }
  41308. // AddedFields returns all numeric fields that were incremented/decremented during
  41309. // this mutation.
  41310. func (m *WhatsappMutation) AddedFields() []string {
  41311. var fields []string
  41312. if m.addstatus != nil {
  41313. fields = append(fields, whatsapp.FieldStatus)
  41314. }
  41315. if m.addphone_status != nil {
  41316. fields = append(fields, whatsapp.FieldPhoneStatus)
  41317. }
  41318. if m.addorganization_id != nil {
  41319. fields = append(fields, whatsapp.FieldOrganizationID)
  41320. }
  41321. return fields
  41322. }
  41323. // AddedField returns the numeric value that was incremented/decremented on a field
  41324. // with the given name. The second boolean return value indicates that this field
  41325. // was not set, or was not defined in the schema.
  41326. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  41327. switch name {
  41328. case whatsapp.FieldStatus:
  41329. return m.AddedStatus()
  41330. case whatsapp.FieldPhoneStatus:
  41331. return m.AddedPhoneStatus()
  41332. case whatsapp.FieldOrganizationID:
  41333. return m.AddedOrganizationID()
  41334. }
  41335. return nil, false
  41336. }
  41337. // AddField adds the value to the field with the given name. It returns an error if
  41338. // the field is not defined in the schema, or if the type mismatched the field
  41339. // type.
  41340. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  41341. switch name {
  41342. case whatsapp.FieldStatus:
  41343. v, ok := value.(int8)
  41344. if !ok {
  41345. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41346. }
  41347. m.AddStatus(v)
  41348. return nil
  41349. case whatsapp.FieldPhoneStatus:
  41350. v, ok := value.(int8)
  41351. if !ok {
  41352. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41353. }
  41354. m.AddPhoneStatus(v)
  41355. return nil
  41356. case whatsapp.FieldOrganizationID:
  41357. v, ok := value.(int64)
  41358. if !ok {
  41359. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41360. }
  41361. m.AddOrganizationID(v)
  41362. return nil
  41363. }
  41364. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  41365. }
  41366. // ClearedFields returns all nullable fields that were cleared during this
  41367. // mutation.
  41368. func (m *WhatsappMutation) ClearedFields() []string {
  41369. var fields []string
  41370. if m.FieldCleared(whatsapp.FieldStatus) {
  41371. fields = append(fields, whatsapp.FieldStatus)
  41372. }
  41373. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  41374. fields = append(fields, whatsapp.FieldDeletedAt)
  41375. }
  41376. if m.FieldCleared(whatsapp.FieldWaID) {
  41377. fields = append(fields, whatsapp.FieldWaID)
  41378. }
  41379. if m.FieldCleared(whatsapp.FieldWaName) {
  41380. fields = append(fields, whatsapp.FieldWaName)
  41381. }
  41382. if m.FieldCleared(whatsapp.FieldCallback) {
  41383. fields = append(fields, whatsapp.FieldCallback)
  41384. }
  41385. if m.FieldCleared(whatsapp.FieldAccount) {
  41386. fields = append(fields, whatsapp.FieldAccount)
  41387. }
  41388. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  41389. fields = append(fields, whatsapp.FieldOrganizationID)
  41390. }
  41391. if m.FieldCleared(whatsapp.FieldAPIBase) {
  41392. fields = append(fields, whatsapp.FieldAPIBase)
  41393. }
  41394. if m.FieldCleared(whatsapp.FieldAPIKey) {
  41395. fields = append(fields, whatsapp.FieldAPIKey)
  41396. }
  41397. if m.FieldCleared(whatsapp.FieldAllowList) {
  41398. fields = append(fields, whatsapp.FieldAllowList)
  41399. }
  41400. if m.FieldCleared(whatsapp.FieldGroupAllowList) {
  41401. fields = append(fields, whatsapp.FieldGroupAllowList)
  41402. }
  41403. if m.FieldCleared(whatsapp.FieldBlockList) {
  41404. fields = append(fields, whatsapp.FieldBlockList)
  41405. }
  41406. if m.FieldCleared(whatsapp.FieldGroupBlockList) {
  41407. fields = append(fields, whatsapp.FieldGroupBlockList)
  41408. }
  41409. return fields
  41410. }
  41411. // FieldCleared returns a boolean indicating if a field with the given name was
  41412. // cleared in this mutation.
  41413. func (m *WhatsappMutation) FieldCleared(name string) bool {
  41414. _, ok := m.clearedFields[name]
  41415. return ok
  41416. }
  41417. // ClearField clears the value of the field with the given name. It returns an
  41418. // error if the field is not defined in the schema.
  41419. func (m *WhatsappMutation) ClearField(name string) error {
  41420. switch name {
  41421. case whatsapp.FieldStatus:
  41422. m.ClearStatus()
  41423. return nil
  41424. case whatsapp.FieldDeletedAt:
  41425. m.ClearDeletedAt()
  41426. return nil
  41427. case whatsapp.FieldWaID:
  41428. m.ClearWaID()
  41429. return nil
  41430. case whatsapp.FieldWaName:
  41431. m.ClearWaName()
  41432. return nil
  41433. case whatsapp.FieldCallback:
  41434. m.ClearCallback()
  41435. return nil
  41436. case whatsapp.FieldAccount:
  41437. m.ClearAccount()
  41438. return nil
  41439. case whatsapp.FieldOrganizationID:
  41440. m.ClearOrganizationID()
  41441. return nil
  41442. case whatsapp.FieldAPIBase:
  41443. m.ClearAPIBase()
  41444. return nil
  41445. case whatsapp.FieldAPIKey:
  41446. m.ClearAPIKey()
  41447. return nil
  41448. case whatsapp.FieldAllowList:
  41449. m.ClearAllowList()
  41450. return nil
  41451. case whatsapp.FieldGroupAllowList:
  41452. m.ClearGroupAllowList()
  41453. return nil
  41454. case whatsapp.FieldBlockList:
  41455. m.ClearBlockList()
  41456. return nil
  41457. case whatsapp.FieldGroupBlockList:
  41458. m.ClearGroupBlockList()
  41459. return nil
  41460. }
  41461. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  41462. }
  41463. // ResetField resets all changes in the mutation for the field with the given name.
  41464. // It returns an error if the field is not defined in the schema.
  41465. func (m *WhatsappMutation) ResetField(name string) error {
  41466. switch name {
  41467. case whatsapp.FieldCreatedAt:
  41468. m.ResetCreatedAt()
  41469. return nil
  41470. case whatsapp.FieldUpdatedAt:
  41471. m.ResetUpdatedAt()
  41472. return nil
  41473. case whatsapp.FieldStatus:
  41474. m.ResetStatus()
  41475. return nil
  41476. case whatsapp.FieldDeletedAt:
  41477. m.ResetDeletedAt()
  41478. return nil
  41479. case whatsapp.FieldWaID:
  41480. m.ResetWaID()
  41481. return nil
  41482. case whatsapp.FieldWaName:
  41483. m.ResetWaName()
  41484. return nil
  41485. case whatsapp.FieldCallback:
  41486. m.ResetCallback()
  41487. return nil
  41488. case whatsapp.FieldAgentID:
  41489. m.ResetAgentID()
  41490. return nil
  41491. case whatsapp.FieldAccount:
  41492. m.ResetAccount()
  41493. return nil
  41494. case whatsapp.FieldCc:
  41495. m.ResetCc()
  41496. return nil
  41497. case whatsapp.FieldPhone:
  41498. m.ResetPhone()
  41499. return nil
  41500. case whatsapp.FieldCcPhone:
  41501. m.ResetCcPhone()
  41502. return nil
  41503. case whatsapp.FieldPhoneName:
  41504. m.ResetPhoneName()
  41505. return nil
  41506. case whatsapp.FieldPhoneStatus:
  41507. m.ResetPhoneStatus()
  41508. return nil
  41509. case whatsapp.FieldOrganizationID:
  41510. m.ResetOrganizationID()
  41511. return nil
  41512. case whatsapp.FieldAPIBase:
  41513. m.ResetAPIBase()
  41514. return nil
  41515. case whatsapp.FieldAPIKey:
  41516. m.ResetAPIKey()
  41517. return nil
  41518. case whatsapp.FieldAllowList:
  41519. m.ResetAllowList()
  41520. return nil
  41521. case whatsapp.FieldGroupAllowList:
  41522. m.ResetGroupAllowList()
  41523. return nil
  41524. case whatsapp.FieldBlockList:
  41525. m.ResetBlockList()
  41526. return nil
  41527. case whatsapp.FieldGroupBlockList:
  41528. m.ResetGroupBlockList()
  41529. return nil
  41530. }
  41531. return fmt.Errorf("unknown Whatsapp field %s", name)
  41532. }
  41533. // AddedEdges returns all edge names that were set/added in this mutation.
  41534. func (m *WhatsappMutation) AddedEdges() []string {
  41535. edges := make([]string, 0, 1)
  41536. if m.agent != nil {
  41537. edges = append(edges, whatsapp.EdgeAgent)
  41538. }
  41539. return edges
  41540. }
  41541. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  41542. // name in this mutation.
  41543. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  41544. switch name {
  41545. case whatsapp.EdgeAgent:
  41546. if id := m.agent; id != nil {
  41547. return []ent.Value{*id}
  41548. }
  41549. }
  41550. return nil
  41551. }
  41552. // RemovedEdges returns all edge names that were removed in this mutation.
  41553. func (m *WhatsappMutation) RemovedEdges() []string {
  41554. edges := make([]string, 0, 1)
  41555. return edges
  41556. }
  41557. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  41558. // the given name in this mutation.
  41559. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  41560. return nil
  41561. }
  41562. // ClearedEdges returns all edge names that were cleared in this mutation.
  41563. func (m *WhatsappMutation) ClearedEdges() []string {
  41564. edges := make([]string, 0, 1)
  41565. if m.clearedagent {
  41566. edges = append(edges, whatsapp.EdgeAgent)
  41567. }
  41568. return edges
  41569. }
  41570. // EdgeCleared returns a boolean which indicates if the edge with the given name
  41571. // was cleared in this mutation.
  41572. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  41573. switch name {
  41574. case whatsapp.EdgeAgent:
  41575. return m.clearedagent
  41576. }
  41577. return false
  41578. }
  41579. // ClearEdge clears the value of the edge with the given name. It returns an error
  41580. // if that edge is not defined in the schema.
  41581. func (m *WhatsappMutation) ClearEdge(name string) error {
  41582. switch name {
  41583. case whatsapp.EdgeAgent:
  41584. m.ClearAgent()
  41585. return nil
  41586. }
  41587. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  41588. }
  41589. // ResetEdge resets all changes to the edge with the given name in this mutation.
  41590. // It returns an error if the edge is not defined in the schema.
  41591. func (m *WhatsappMutation) ResetEdge(name string) error {
  41592. switch name {
  41593. case whatsapp.EdgeAgent:
  41594. m.ResetAgent()
  41595. return nil
  41596. }
  41597. return fmt.Errorf("unknown Whatsapp edge %s", name)
  41598. }
  41599. // WhatsappChannelMutation represents an operation that mutates the WhatsappChannel nodes in the graph.
  41600. type WhatsappChannelMutation struct {
  41601. config
  41602. op Op
  41603. typ string
  41604. id *uint64
  41605. created_at *time.Time
  41606. updated_at *time.Time
  41607. status *uint8
  41608. addstatus *int8
  41609. deleted_at *time.Time
  41610. ak *string
  41611. sk *string
  41612. wa_id *string
  41613. wa_name *string
  41614. waba_id *uint64
  41615. addwaba_id *int64
  41616. business_id *uint64
  41617. addbusiness_id *int64
  41618. organization_id *uint64
  41619. addorganization_id *int64
  41620. verify_account *string
  41621. clearedFields map[string]struct{}
  41622. done bool
  41623. oldValue func(context.Context) (*WhatsappChannel, error)
  41624. predicates []predicate.WhatsappChannel
  41625. }
  41626. var _ ent.Mutation = (*WhatsappChannelMutation)(nil)
  41627. // whatsappchannelOption allows management of the mutation configuration using functional options.
  41628. type whatsappchannelOption func(*WhatsappChannelMutation)
  41629. // newWhatsappChannelMutation creates new mutation for the WhatsappChannel entity.
  41630. func newWhatsappChannelMutation(c config, op Op, opts ...whatsappchannelOption) *WhatsappChannelMutation {
  41631. m := &WhatsappChannelMutation{
  41632. config: c,
  41633. op: op,
  41634. typ: TypeWhatsappChannel,
  41635. clearedFields: make(map[string]struct{}),
  41636. }
  41637. for _, opt := range opts {
  41638. opt(m)
  41639. }
  41640. return m
  41641. }
  41642. // withWhatsappChannelID sets the ID field of the mutation.
  41643. func withWhatsappChannelID(id uint64) whatsappchannelOption {
  41644. return func(m *WhatsappChannelMutation) {
  41645. var (
  41646. err error
  41647. once sync.Once
  41648. value *WhatsappChannel
  41649. )
  41650. m.oldValue = func(ctx context.Context) (*WhatsappChannel, error) {
  41651. once.Do(func() {
  41652. if m.done {
  41653. err = errors.New("querying old values post mutation is not allowed")
  41654. } else {
  41655. value, err = m.Client().WhatsappChannel.Get(ctx, id)
  41656. }
  41657. })
  41658. return value, err
  41659. }
  41660. m.id = &id
  41661. }
  41662. }
  41663. // withWhatsappChannel sets the old WhatsappChannel of the mutation.
  41664. func withWhatsappChannel(node *WhatsappChannel) whatsappchannelOption {
  41665. return func(m *WhatsappChannelMutation) {
  41666. m.oldValue = func(context.Context) (*WhatsappChannel, error) {
  41667. return node, nil
  41668. }
  41669. m.id = &node.ID
  41670. }
  41671. }
  41672. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41673. // executed in a transaction (ent.Tx), a transactional client is returned.
  41674. func (m WhatsappChannelMutation) Client() *Client {
  41675. client := &Client{config: m.config}
  41676. client.init()
  41677. return client
  41678. }
  41679. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41680. // it returns an error otherwise.
  41681. func (m WhatsappChannelMutation) Tx() (*Tx, error) {
  41682. if _, ok := m.driver.(*txDriver); !ok {
  41683. return nil, errors.New("ent: mutation is not running in a transaction")
  41684. }
  41685. tx := &Tx{config: m.config}
  41686. tx.init()
  41687. return tx, nil
  41688. }
  41689. // SetID sets the value of the id field. Note that this
  41690. // operation is only accepted on creation of WhatsappChannel entities.
  41691. func (m *WhatsappChannelMutation) SetID(id uint64) {
  41692. m.id = &id
  41693. }
  41694. // ID returns the ID value in the mutation. Note that the ID is only available
  41695. // if it was provided to the builder or after it was returned from the database.
  41696. func (m *WhatsappChannelMutation) ID() (id uint64, exists bool) {
  41697. if m.id == nil {
  41698. return
  41699. }
  41700. return *m.id, true
  41701. }
  41702. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41703. // That means, if the mutation is applied within a transaction with an isolation level such
  41704. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41705. // or updated by the mutation.
  41706. func (m *WhatsappChannelMutation) IDs(ctx context.Context) ([]uint64, error) {
  41707. switch {
  41708. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41709. id, exists := m.ID()
  41710. if exists {
  41711. return []uint64{id}, nil
  41712. }
  41713. fallthrough
  41714. case m.op.Is(OpUpdate | OpDelete):
  41715. return m.Client().WhatsappChannel.Query().Where(m.predicates...).IDs(ctx)
  41716. default:
  41717. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41718. }
  41719. }
  41720. // SetCreatedAt sets the "created_at" field.
  41721. func (m *WhatsappChannelMutation) SetCreatedAt(t time.Time) {
  41722. m.created_at = &t
  41723. }
  41724. // CreatedAt returns the value of the "created_at" field in the mutation.
  41725. func (m *WhatsappChannelMutation) CreatedAt() (r time.Time, exists bool) {
  41726. v := m.created_at
  41727. if v == nil {
  41728. return
  41729. }
  41730. return *v, true
  41731. }
  41732. // OldCreatedAt returns the old "created_at" field's value of the WhatsappChannel entity.
  41733. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  41734. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41735. func (m *WhatsappChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  41736. if !m.op.Is(OpUpdateOne) {
  41737. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  41738. }
  41739. if m.id == nil || m.oldValue == nil {
  41740. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  41741. }
  41742. oldValue, err := m.oldValue(ctx)
  41743. if err != nil {
  41744. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  41745. }
  41746. return oldValue.CreatedAt, nil
  41747. }
  41748. // ResetCreatedAt resets all changes to the "created_at" field.
  41749. func (m *WhatsappChannelMutation) ResetCreatedAt() {
  41750. m.created_at = nil
  41751. }
  41752. // SetUpdatedAt sets the "updated_at" field.
  41753. func (m *WhatsappChannelMutation) SetUpdatedAt(t time.Time) {
  41754. m.updated_at = &t
  41755. }
  41756. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  41757. func (m *WhatsappChannelMutation) UpdatedAt() (r time.Time, exists bool) {
  41758. v := m.updated_at
  41759. if v == nil {
  41760. return
  41761. }
  41762. return *v, true
  41763. }
  41764. // OldUpdatedAt returns the old "updated_at" field's value of the WhatsappChannel entity.
  41765. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  41766. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41767. func (m *WhatsappChannelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  41768. if !m.op.Is(OpUpdateOne) {
  41769. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  41770. }
  41771. if m.id == nil || m.oldValue == nil {
  41772. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  41773. }
  41774. oldValue, err := m.oldValue(ctx)
  41775. if err != nil {
  41776. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  41777. }
  41778. return oldValue.UpdatedAt, nil
  41779. }
  41780. // ResetUpdatedAt resets all changes to the "updated_at" field.
  41781. func (m *WhatsappChannelMutation) ResetUpdatedAt() {
  41782. m.updated_at = nil
  41783. }
  41784. // SetStatus sets the "status" field.
  41785. func (m *WhatsappChannelMutation) SetStatus(u uint8) {
  41786. m.status = &u
  41787. m.addstatus = nil
  41788. }
  41789. // Status returns the value of the "status" field in the mutation.
  41790. func (m *WhatsappChannelMutation) Status() (r uint8, exists bool) {
  41791. v := m.status
  41792. if v == nil {
  41793. return
  41794. }
  41795. return *v, true
  41796. }
  41797. // OldStatus returns the old "status" field's value of the WhatsappChannel entity.
  41798. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  41799. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41800. func (m *WhatsappChannelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  41801. if !m.op.Is(OpUpdateOne) {
  41802. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  41803. }
  41804. if m.id == nil || m.oldValue == nil {
  41805. return v, errors.New("OldStatus requires an ID field in the mutation")
  41806. }
  41807. oldValue, err := m.oldValue(ctx)
  41808. if err != nil {
  41809. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  41810. }
  41811. return oldValue.Status, nil
  41812. }
  41813. // AddStatus adds u to the "status" field.
  41814. func (m *WhatsappChannelMutation) AddStatus(u int8) {
  41815. if m.addstatus != nil {
  41816. *m.addstatus += u
  41817. } else {
  41818. m.addstatus = &u
  41819. }
  41820. }
  41821. // AddedStatus returns the value that was added to the "status" field in this mutation.
  41822. func (m *WhatsappChannelMutation) AddedStatus() (r int8, exists bool) {
  41823. v := m.addstatus
  41824. if v == nil {
  41825. return
  41826. }
  41827. return *v, true
  41828. }
  41829. // ClearStatus clears the value of the "status" field.
  41830. func (m *WhatsappChannelMutation) ClearStatus() {
  41831. m.status = nil
  41832. m.addstatus = nil
  41833. m.clearedFields[whatsappchannel.FieldStatus] = struct{}{}
  41834. }
  41835. // StatusCleared returns if the "status" field was cleared in this mutation.
  41836. func (m *WhatsappChannelMutation) StatusCleared() bool {
  41837. _, ok := m.clearedFields[whatsappchannel.FieldStatus]
  41838. return ok
  41839. }
  41840. // ResetStatus resets all changes to the "status" field.
  41841. func (m *WhatsappChannelMutation) ResetStatus() {
  41842. m.status = nil
  41843. m.addstatus = nil
  41844. delete(m.clearedFields, whatsappchannel.FieldStatus)
  41845. }
  41846. // SetDeletedAt sets the "deleted_at" field.
  41847. func (m *WhatsappChannelMutation) SetDeletedAt(t time.Time) {
  41848. m.deleted_at = &t
  41849. }
  41850. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  41851. func (m *WhatsappChannelMutation) DeletedAt() (r time.Time, exists bool) {
  41852. v := m.deleted_at
  41853. if v == nil {
  41854. return
  41855. }
  41856. return *v, true
  41857. }
  41858. // OldDeletedAt returns the old "deleted_at" field's value of the WhatsappChannel entity.
  41859. // If the WhatsappChannel 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 *WhatsappChannelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  41862. if !m.op.Is(OpUpdateOne) {
  41863. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  41864. }
  41865. if m.id == nil || m.oldValue == nil {
  41866. return v, errors.New("OldDeletedAt 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 OldDeletedAt: %w", err)
  41871. }
  41872. return oldValue.DeletedAt, nil
  41873. }
  41874. // ClearDeletedAt clears the value of the "deleted_at" field.
  41875. func (m *WhatsappChannelMutation) ClearDeletedAt() {
  41876. m.deleted_at = nil
  41877. m.clearedFields[whatsappchannel.FieldDeletedAt] = struct{}{}
  41878. }
  41879. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  41880. func (m *WhatsappChannelMutation) DeletedAtCleared() bool {
  41881. _, ok := m.clearedFields[whatsappchannel.FieldDeletedAt]
  41882. return ok
  41883. }
  41884. // ResetDeletedAt resets all changes to the "deleted_at" field.
  41885. func (m *WhatsappChannelMutation) ResetDeletedAt() {
  41886. m.deleted_at = nil
  41887. delete(m.clearedFields, whatsappchannel.FieldDeletedAt)
  41888. }
  41889. // SetAk sets the "ak" field.
  41890. func (m *WhatsappChannelMutation) SetAk(s string) {
  41891. m.ak = &s
  41892. }
  41893. // Ak returns the value of the "ak" field in the mutation.
  41894. func (m *WhatsappChannelMutation) Ak() (r string, exists bool) {
  41895. v := m.ak
  41896. if v == nil {
  41897. return
  41898. }
  41899. return *v, true
  41900. }
  41901. // OldAk returns the old "ak" field's value of the WhatsappChannel entity.
  41902. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  41903. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41904. func (m *WhatsappChannelMutation) OldAk(ctx context.Context) (v string, err error) {
  41905. if !m.op.Is(OpUpdateOne) {
  41906. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  41907. }
  41908. if m.id == nil || m.oldValue == nil {
  41909. return v, errors.New("OldAk requires an ID field in the mutation")
  41910. }
  41911. oldValue, err := m.oldValue(ctx)
  41912. if err != nil {
  41913. return v, fmt.Errorf("querying old value for OldAk: %w", err)
  41914. }
  41915. return oldValue.Ak, nil
  41916. }
  41917. // ClearAk clears the value of the "ak" field.
  41918. func (m *WhatsappChannelMutation) ClearAk() {
  41919. m.ak = nil
  41920. m.clearedFields[whatsappchannel.FieldAk] = struct{}{}
  41921. }
  41922. // AkCleared returns if the "ak" field was cleared in this mutation.
  41923. func (m *WhatsappChannelMutation) AkCleared() bool {
  41924. _, ok := m.clearedFields[whatsappchannel.FieldAk]
  41925. return ok
  41926. }
  41927. // ResetAk resets all changes to the "ak" field.
  41928. func (m *WhatsappChannelMutation) ResetAk() {
  41929. m.ak = nil
  41930. delete(m.clearedFields, whatsappchannel.FieldAk)
  41931. }
  41932. // SetSk sets the "sk" field.
  41933. func (m *WhatsappChannelMutation) SetSk(s string) {
  41934. m.sk = &s
  41935. }
  41936. // Sk returns the value of the "sk" field in the mutation.
  41937. func (m *WhatsappChannelMutation) Sk() (r string, exists bool) {
  41938. v := m.sk
  41939. if v == nil {
  41940. return
  41941. }
  41942. return *v, true
  41943. }
  41944. // OldSk returns the old "sk" field's value of the WhatsappChannel entity.
  41945. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  41946. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41947. func (m *WhatsappChannelMutation) OldSk(ctx context.Context) (v string, err error) {
  41948. if !m.op.Is(OpUpdateOne) {
  41949. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  41950. }
  41951. if m.id == nil || m.oldValue == nil {
  41952. return v, errors.New("OldSk requires an ID field in the mutation")
  41953. }
  41954. oldValue, err := m.oldValue(ctx)
  41955. if err != nil {
  41956. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  41957. }
  41958. return oldValue.Sk, nil
  41959. }
  41960. // ResetSk resets all changes to the "sk" field.
  41961. func (m *WhatsappChannelMutation) ResetSk() {
  41962. m.sk = nil
  41963. }
  41964. // SetWaID sets the "wa_id" field.
  41965. func (m *WhatsappChannelMutation) SetWaID(s string) {
  41966. m.wa_id = &s
  41967. }
  41968. // WaID returns the value of the "wa_id" field in the mutation.
  41969. func (m *WhatsappChannelMutation) WaID() (r string, exists bool) {
  41970. v := m.wa_id
  41971. if v == nil {
  41972. return
  41973. }
  41974. return *v, true
  41975. }
  41976. // OldWaID returns the old "wa_id" field's value of the WhatsappChannel entity.
  41977. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  41978. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41979. func (m *WhatsappChannelMutation) OldWaID(ctx context.Context) (v string, err error) {
  41980. if !m.op.Is(OpUpdateOne) {
  41981. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  41982. }
  41983. if m.id == nil || m.oldValue == nil {
  41984. return v, errors.New("OldWaID requires an ID field in the mutation")
  41985. }
  41986. oldValue, err := m.oldValue(ctx)
  41987. if err != nil {
  41988. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  41989. }
  41990. return oldValue.WaID, nil
  41991. }
  41992. // ClearWaID clears the value of the "wa_id" field.
  41993. func (m *WhatsappChannelMutation) ClearWaID() {
  41994. m.wa_id = nil
  41995. m.clearedFields[whatsappchannel.FieldWaID] = struct{}{}
  41996. }
  41997. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  41998. func (m *WhatsappChannelMutation) WaIDCleared() bool {
  41999. _, ok := m.clearedFields[whatsappchannel.FieldWaID]
  42000. return ok
  42001. }
  42002. // ResetWaID resets all changes to the "wa_id" field.
  42003. func (m *WhatsappChannelMutation) ResetWaID() {
  42004. m.wa_id = nil
  42005. delete(m.clearedFields, whatsappchannel.FieldWaID)
  42006. }
  42007. // SetWaName sets the "wa_name" field.
  42008. func (m *WhatsappChannelMutation) SetWaName(s string) {
  42009. m.wa_name = &s
  42010. }
  42011. // WaName returns the value of the "wa_name" field in the mutation.
  42012. func (m *WhatsappChannelMutation) WaName() (r string, exists bool) {
  42013. v := m.wa_name
  42014. if v == nil {
  42015. return
  42016. }
  42017. return *v, true
  42018. }
  42019. // OldWaName returns the old "wa_name" field's value of the WhatsappChannel entity.
  42020. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  42021. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42022. func (m *WhatsappChannelMutation) OldWaName(ctx context.Context) (v string, err error) {
  42023. if !m.op.Is(OpUpdateOne) {
  42024. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  42025. }
  42026. if m.id == nil || m.oldValue == nil {
  42027. return v, errors.New("OldWaName requires an ID field in the mutation")
  42028. }
  42029. oldValue, err := m.oldValue(ctx)
  42030. if err != nil {
  42031. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  42032. }
  42033. return oldValue.WaName, nil
  42034. }
  42035. // ClearWaName clears the value of the "wa_name" field.
  42036. func (m *WhatsappChannelMutation) ClearWaName() {
  42037. m.wa_name = nil
  42038. m.clearedFields[whatsappchannel.FieldWaName] = struct{}{}
  42039. }
  42040. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  42041. func (m *WhatsappChannelMutation) WaNameCleared() bool {
  42042. _, ok := m.clearedFields[whatsappchannel.FieldWaName]
  42043. return ok
  42044. }
  42045. // ResetWaName resets all changes to the "wa_name" field.
  42046. func (m *WhatsappChannelMutation) ResetWaName() {
  42047. m.wa_name = nil
  42048. delete(m.clearedFields, whatsappchannel.FieldWaName)
  42049. }
  42050. // SetWabaID sets the "waba_id" field.
  42051. func (m *WhatsappChannelMutation) SetWabaID(u uint64) {
  42052. m.waba_id = &u
  42053. m.addwaba_id = nil
  42054. }
  42055. // WabaID returns the value of the "waba_id" field in the mutation.
  42056. func (m *WhatsappChannelMutation) WabaID() (r uint64, exists bool) {
  42057. v := m.waba_id
  42058. if v == nil {
  42059. return
  42060. }
  42061. return *v, true
  42062. }
  42063. // OldWabaID returns the old "waba_id" field's value of the WhatsappChannel entity.
  42064. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  42065. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42066. func (m *WhatsappChannelMutation) OldWabaID(ctx context.Context) (v uint64, err error) {
  42067. if !m.op.Is(OpUpdateOne) {
  42068. return v, errors.New("OldWabaID is only allowed on UpdateOne operations")
  42069. }
  42070. if m.id == nil || m.oldValue == nil {
  42071. return v, errors.New("OldWabaID requires an ID field in the mutation")
  42072. }
  42073. oldValue, err := m.oldValue(ctx)
  42074. if err != nil {
  42075. return v, fmt.Errorf("querying old value for OldWabaID: %w", err)
  42076. }
  42077. return oldValue.WabaID, nil
  42078. }
  42079. // AddWabaID adds u to the "waba_id" field.
  42080. func (m *WhatsappChannelMutation) AddWabaID(u int64) {
  42081. if m.addwaba_id != nil {
  42082. *m.addwaba_id += u
  42083. } else {
  42084. m.addwaba_id = &u
  42085. }
  42086. }
  42087. // AddedWabaID returns the value that was added to the "waba_id" field in this mutation.
  42088. func (m *WhatsappChannelMutation) AddedWabaID() (r int64, exists bool) {
  42089. v := m.addwaba_id
  42090. if v == nil {
  42091. return
  42092. }
  42093. return *v, true
  42094. }
  42095. // ResetWabaID resets all changes to the "waba_id" field.
  42096. func (m *WhatsappChannelMutation) ResetWabaID() {
  42097. m.waba_id = nil
  42098. m.addwaba_id = nil
  42099. }
  42100. // SetBusinessID sets the "business_id" field.
  42101. func (m *WhatsappChannelMutation) SetBusinessID(u uint64) {
  42102. m.business_id = &u
  42103. m.addbusiness_id = nil
  42104. }
  42105. // BusinessID returns the value of the "business_id" field in the mutation.
  42106. func (m *WhatsappChannelMutation) BusinessID() (r uint64, exists bool) {
  42107. v := m.business_id
  42108. if v == nil {
  42109. return
  42110. }
  42111. return *v, true
  42112. }
  42113. // OldBusinessID returns the old "business_id" field's value of the WhatsappChannel entity.
  42114. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  42115. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42116. func (m *WhatsappChannelMutation) OldBusinessID(ctx context.Context) (v uint64, err error) {
  42117. if !m.op.Is(OpUpdateOne) {
  42118. return v, errors.New("OldBusinessID is only allowed on UpdateOne operations")
  42119. }
  42120. if m.id == nil || m.oldValue == nil {
  42121. return v, errors.New("OldBusinessID requires an ID field in the mutation")
  42122. }
  42123. oldValue, err := m.oldValue(ctx)
  42124. if err != nil {
  42125. return v, fmt.Errorf("querying old value for OldBusinessID: %w", err)
  42126. }
  42127. return oldValue.BusinessID, nil
  42128. }
  42129. // AddBusinessID adds u to the "business_id" field.
  42130. func (m *WhatsappChannelMutation) AddBusinessID(u int64) {
  42131. if m.addbusiness_id != nil {
  42132. *m.addbusiness_id += u
  42133. } else {
  42134. m.addbusiness_id = &u
  42135. }
  42136. }
  42137. // AddedBusinessID returns the value that was added to the "business_id" field in this mutation.
  42138. func (m *WhatsappChannelMutation) AddedBusinessID() (r int64, exists bool) {
  42139. v := m.addbusiness_id
  42140. if v == nil {
  42141. return
  42142. }
  42143. return *v, true
  42144. }
  42145. // ResetBusinessID resets all changes to the "business_id" field.
  42146. func (m *WhatsappChannelMutation) ResetBusinessID() {
  42147. m.business_id = nil
  42148. m.addbusiness_id = nil
  42149. }
  42150. // SetOrganizationID sets the "organization_id" field.
  42151. func (m *WhatsappChannelMutation) SetOrganizationID(u uint64) {
  42152. m.organization_id = &u
  42153. m.addorganization_id = nil
  42154. }
  42155. // OrganizationID returns the value of the "organization_id" field in the mutation.
  42156. func (m *WhatsappChannelMutation) OrganizationID() (r uint64, exists bool) {
  42157. v := m.organization_id
  42158. if v == nil {
  42159. return
  42160. }
  42161. return *v, true
  42162. }
  42163. // OldOrganizationID returns the old "organization_id" field's value of the WhatsappChannel entity.
  42164. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  42165. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42166. func (m *WhatsappChannelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  42167. if !m.op.Is(OpUpdateOne) {
  42168. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  42169. }
  42170. if m.id == nil || m.oldValue == nil {
  42171. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  42172. }
  42173. oldValue, err := m.oldValue(ctx)
  42174. if err != nil {
  42175. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  42176. }
  42177. return oldValue.OrganizationID, nil
  42178. }
  42179. // AddOrganizationID adds u to the "organization_id" field.
  42180. func (m *WhatsappChannelMutation) AddOrganizationID(u int64) {
  42181. if m.addorganization_id != nil {
  42182. *m.addorganization_id += u
  42183. } else {
  42184. m.addorganization_id = &u
  42185. }
  42186. }
  42187. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  42188. func (m *WhatsappChannelMutation) AddedOrganizationID() (r int64, exists bool) {
  42189. v := m.addorganization_id
  42190. if v == nil {
  42191. return
  42192. }
  42193. return *v, true
  42194. }
  42195. // ClearOrganizationID clears the value of the "organization_id" field.
  42196. func (m *WhatsappChannelMutation) ClearOrganizationID() {
  42197. m.organization_id = nil
  42198. m.addorganization_id = nil
  42199. m.clearedFields[whatsappchannel.FieldOrganizationID] = struct{}{}
  42200. }
  42201. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  42202. func (m *WhatsappChannelMutation) OrganizationIDCleared() bool {
  42203. _, ok := m.clearedFields[whatsappchannel.FieldOrganizationID]
  42204. return ok
  42205. }
  42206. // ResetOrganizationID resets all changes to the "organization_id" field.
  42207. func (m *WhatsappChannelMutation) ResetOrganizationID() {
  42208. m.organization_id = nil
  42209. m.addorganization_id = nil
  42210. delete(m.clearedFields, whatsappchannel.FieldOrganizationID)
  42211. }
  42212. // SetVerifyAccount sets the "verify_account" field.
  42213. func (m *WhatsappChannelMutation) SetVerifyAccount(s string) {
  42214. m.verify_account = &s
  42215. }
  42216. // VerifyAccount returns the value of the "verify_account" field in the mutation.
  42217. func (m *WhatsappChannelMutation) VerifyAccount() (r string, exists bool) {
  42218. v := m.verify_account
  42219. if v == nil {
  42220. return
  42221. }
  42222. return *v, true
  42223. }
  42224. // OldVerifyAccount returns the old "verify_account" field's value of the WhatsappChannel entity.
  42225. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  42226. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42227. func (m *WhatsappChannelMutation) OldVerifyAccount(ctx context.Context) (v string, err error) {
  42228. if !m.op.Is(OpUpdateOne) {
  42229. return v, errors.New("OldVerifyAccount is only allowed on UpdateOne operations")
  42230. }
  42231. if m.id == nil || m.oldValue == nil {
  42232. return v, errors.New("OldVerifyAccount requires an ID field in the mutation")
  42233. }
  42234. oldValue, err := m.oldValue(ctx)
  42235. if err != nil {
  42236. return v, fmt.Errorf("querying old value for OldVerifyAccount: %w", err)
  42237. }
  42238. return oldValue.VerifyAccount, nil
  42239. }
  42240. // ResetVerifyAccount resets all changes to the "verify_account" field.
  42241. func (m *WhatsappChannelMutation) ResetVerifyAccount() {
  42242. m.verify_account = nil
  42243. }
  42244. // Where appends a list predicates to the WhatsappChannelMutation builder.
  42245. func (m *WhatsappChannelMutation) Where(ps ...predicate.WhatsappChannel) {
  42246. m.predicates = append(m.predicates, ps...)
  42247. }
  42248. // WhereP appends storage-level predicates to the WhatsappChannelMutation builder. Using this method,
  42249. // users can use type-assertion to append predicates that do not depend on any generated package.
  42250. func (m *WhatsappChannelMutation) WhereP(ps ...func(*sql.Selector)) {
  42251. p := make([]predicate.WhatsappChannel, len(ps))
  42252. for i := range ps {
  42253. p[i] = ps[i]
  42254. }
  42255. m.Where(p...)
  42256. }
  42257. // Op returns the operation name.
  42258. func (m *WhatsappChannelMutation) Op() Op {
  42259. return m.op
  42260. }
  42261. // SetOp allows setting the mutation operation.
  42262. func (m *WhatsappChannelMutation) SetOp(op Op) {
  42263. m.op = op
  42264. }
  42265. // Type returns the node type of this mutation (WhatsappChannel).
  42266. func (m *WhatsappChannelMutation) Type() string {
  42267. return m.typ
  42268. }
  42269. // Fields returns all fields that were changed during this mutation. Note that in
  42270. // order to get all numeric fields that were incremented/decremented, call
  42271. // AddedFields().
  42272. func (m *WhatsappChannelMutation) Fields() []string {
  42273. fields := make([]string, 0, 12)
  42274. if m.created_at != nil {
  42275. fields = append(fields, whatsappchannel.FieldCreatedAt)
  42276. }
  42277. if m.updated_at != nil {
  42278. fields = append(fields, whatsappchannel.FieldUpdatedAt)
  42279. }
  42280. if m.status != nil {
  42281. fields = append(fields, whatsappchannel.FieldStatus)
  42282. }
  42283. if m.deleted_at != nil {
  42284. fields = append(fields, whatsappchannel.FieldDeletedAt)
  42285. }
  42286. if m.ak != nil {
  42287. fields = append(fields, whatsappchannel.FieldAk)
  42288. }
  42289. if m.sk != nil {
  42290. fields = append(fields, whatsappchannel.FieldSk)
  42291. }
  42292. if m.wa_id != nil {
  42293. fields = append(fields, whatsappchannel.FieldWaID)
  42294. }
  42295. if m.wa_name != nil {
  42296. fields = append(fields, whatsappchannel.FieldWaName)
  42297. }
  42298. if m.waba_id != nil {
  42299. fields = append(fields, whatsappchannel.FieldWabaID)
  42300. }
  42301. if m.business_id != nil {
  42302. fields = append(fields, whatsappchannel.FieldBusinessID)
  42303. }
  42304. if m.organization_id != nil {
  42305. fields = append(fields, whatsappchannel.FieldOrganizationID)
  42306. }
  42307. if m.verify_account != nil {
  42308. fields = append(fields, whatsappchannel.FieldVerifyAccount)
  42309. }
  42310. return fields
  42311. }
  42312. // Field returns the value of a field with the given name. The second boolean
  42313. // return value indicates that this field was not set, or was not defined in the
  42314. // schema.
  42315. func (m *WhatsappChannelMutation) Field(name string) (ent.Value, bool) {
  42316. switch name {
  42317. case whatsappchannel.FieldCreatedAt:
  42318. return m.CreatedAt()
  42319. case whatsappchannel.FieldUpdatedAt:
  42320. return m.UpdatedAt()
  42321. case whatsappchannel.FieldStatus:
  42322. return m.Status()
  42323. case whatsappchannel.FieldDeletedAt:
  42324. return m.DeletedAt()
  42325. case whatsappchannel.FieldAk:
  42326. return m.Ak()
  42327. case whatsappchannel.FieldSk:
  42328. return m.Sk()
  42329. case whatsappchannel.FieldWaID:
  42330. return m.WaID()
  42331. case whatsappchannel.FieldWaName:
  42332. return m.WaName()
  42333. case whatsappchannel.FieldWabaID:
  42334. return m.WabaID()
  42335. case whatsappchannel.FieldBusinessID:
  42336. return m.BusinessID()
  42337. case whatsappchannel.FieldOrganizationID:
  42338. return m.OrganizationID()
  42339. case whatsappchannel.FieldVerifyAccount:
  42340. return m.VerifyAccount()
  42341. }
  42342. return nil, false
  42343. }
  42344. // OldField returns the old value of the field from the database. An error is
  42345. // returned if the mutation operation is not UpdateOne, or the query to the
  42346. // database failed.
  42347. func (m *WhatsappChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  42348. switch name {
  42349. case whatsappchannel.FieldCreatedAt:
  42350. return m.OldCreatedAt(ctx)
  42351. case whatsappchannel.FieldUpdatedAt:
  42352. return m.OldUpdatedAt(ctx)
  42353. case whatsappchannel.FieldStatus:
  42354. return m.OldStatus(ctx)
  42355. case whatsappchannel.FieldDeletedAt:
  42356. return m.OldDeletedAt(ctx)
  42357. case whatsappchannel.FieldAk:
  42358. return m.OldAk(ctx)
  42359. case whatsappchannel.FieldSk:
  42360. return m.OldSk(ctx)
  42361. case whatsappchannel.FieldWaID:
  42362. return m.OldWaID(ctx)
  42363. case whatsappchannel.FieldWaName:
  42364. return m.OldWaName(ctx)
  42365. case whatsappchannel.FieldWabaID:
  42366. return m.OldWabaID(ctx)
  42367. case whatsappchannel.FieldBusinessID:
  42368. return m.OldBusinessID(ctx)
  42369. case whatsappchannel.FieldOrganizationID:
  42370. return m.OldOrganizationID(ctx)
  42371. case whatsappchannel.FieldVerifyAccount:
  42372. return m.OldVerifyAccount(ctx)
  42373. }
  42374. return nil, fmt.Errorf("unknown WhatsappChannel field %s", name)
  42375. }
  42376. // SetField sets the value of a field with the given name. It returns an error if
  42377. // the field is not defined in the schema, or if the type mismatched the field
  42378. // type.
  42379. func (m *WhatsappChannelMutation) SetField(name string, value ent.Value) error {
  42380. switch name {
  42381. case whatsappchannel.FieldCreatedAt:
  42382. v, ok := value.(time.Time)
  42383. if !ok {
  42384. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42385. }
  42386. m.SetCreatedAt(v)
  42387. return nil
  42388. case whatsappchannel.FieldUpdatedAt:
  42389. v, ok := value.(time.Time)
  42390. if !ok {
  42391. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42392. }
  42393. m.SetUpdatedAt(v)
  42394. return nil
  42395. case whatsappchannel.FieldStatus:
  42396. v, ok := value.(uint8)
  42397. if !ok {
  42398. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42399. }
  42400. m.SetStatus(v)
  42401. return nil
  42402. case whatsappchannel.FieldDeletedAt:
  42403. v, ok := value.(time.Time)
  42404. if !ok {
  42405. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42406. }
  42407. m.SetDeletedAt(v)
  42408. return nil
  42409. case whatsappchannel.FieldAk:
  42410. v, ok := value.(string)
  42411. if !ok {
  42412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42413. }
  42414. m.SetAk(v)
  42415. return nil
  42416. case whatsappchannel.FieldSk:
  42417. v, ok := value.(string)
  42418. if !ok {
  42419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42420. }
  42421. m.SetSk(v)
  42422. return nil
  42423. case whatsappchannel.FieldWaID:
  42424. v, ok := value.(string)
  42425. if !ok {
  42426. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42427. }
  42428. m.SetWaID(v)
  42429. return nil
  42430. case whatsappchannel.FieldWaName:
  42431. v, ok := value.(string)
  42432. if !ok {
  42433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42434. }
  42435. m.SetWaName(v)
  42436. return nil
  42437. case whatsappchannel.FieldWabaID:
  42438. v, ok := value.(uint64)
  42439. if !ok {
  42440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42441. }
  42442. m.SetWabaID(v)
  42443. return nil
  42444. case whatsappchannel.FieldBusinessID:
  42445. v, ok := value.(uint64)
  42446. if !ok {
  42447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42448. }
  42449. m.SetBusinessID(v)
  42450. return nil
  42451. case whatsappchannel.FieldOrganizationID:
  42452. v, ok := value.(uint64)
  42453. if !ok {
  42454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42455. }
  42456. m.SetOrganizationID(v)
  42457. return nil
  42458. case whatsappchannel.FieldVerifyAccount:
  42459. v, ok := value.(string)
  42460. if !ok {
  42461. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42462. }
  42463. m.SetVerifyAccount(v)
  42464. return nil
  42465. }
  42466. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  42467. }
  42468. // AddedFields returns all numeric fields that were incremented/decremented during
  42469. // this mutation.
  42470. func (m *WhatsappChannelMutation) AddedFields() []string {
  42471. var fields []string
  42472. if m.addstatus != nil {
  42473. fields = append(fields, whatsappchannel.FieldStatus)
  42474. }
  42475. if m.addwaba_id != nil {
  42476. fields = append(fields, whatsappchannel.FieldWabaID)
  42477. }
  42478. if m.addbusiness_id != nil {
  42479. fields = append(fields, whatsappchannel.FieldBusinessID)
  42480. }
  42481. if m.addorganization_id != nil {
  42482. fields = append(fields, whatsappchannel.FieldOrganizationID)
  42483. }
  42484. return fields
  42485. }
  42486. // AddedField returns the numeric value that was incremented/decremented on a field
  42487. // with the given name. The second boolean return value indicates that this field
  42488. // was not set, or was not defined in the schema.
  42489. func (m *WhatsappChannelMutation) AddedField(name string) (ent.Value, bool) {
  42490. switch name {
  42491. case whatsappchannel.FieldStatus:
  42492. return m.AddedStatus()
  42493. case whatsappchannel.FieldWabaID:
  42494. return m.AddedWabaID()
  42495. case whatsappchannel.FieldBusinessID:
  42496. return m.AddedBusinessID()
  42497. case whatsappchannel.FieldOrganizationID:
  42498. return m.AddedOrganizationID()
  42499. }
  42500. return nil, false
  42501. }
  42502. // AddField adds the value to the field with the given name. It returns an error if
  42503. // the field is not defined in the schema, or if the type mismatched the field
  42504. // type.
  42505. func (m *WhatsappChannelMutation) AddField(name string, value ent.Value) error {
  42506. switch name {
  42507. case whatsappchannel.FieldStatus:
  42508. v, ok := value.(int8)
  42509. if !ok {
  42510. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42511. }
  42512. m.AddStatus(v)
  42513. return nil
  42514. case whatsappchannel.FieldWabaID:
  42515. v, ok := value.(int64)
  42516. if !ok {
  42517. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42518. }
  42519. m.AddWabaID(v)
  42520. return nil
  42521. case whatsappchannel.FieldBusinessID:
  42522. v, ok := value.(int64)
  42523. if !ok {
  42524. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42525. }
  42526. m.AddBusinessID(v)
  42527. return nil
  42528. case whatsappchannel.FieldOrganizationID:
  42529. v, ok := value.(int64)
  42530. if !ok {
  42531. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42532. }
  42533. m.AddOrganizationID(v)
  42534. return nil
  42535. }
  42536. return fmt.Errorf("unknown WhatsappChannel numeric field %s", name)
  42537. }
  42538. // ClearedFields returns all nullable fields that were cleared during this
  42539. // mutation.
  42540. func (m *WhatsappChannelMutation) ClearedFields() []string {
  42541. var fields []string
  42542. if m.FieldCleared(whatsappchannel.FieldStatus) {
  42543. fields = append(fields, whatsappchannel.FieldStatus)
  42544. }
  42545. if m.FieldCleared(whatsappchannel.FieldDeletedAt) {
  42546. fields = append(fields, whatsappchannel.FieldDeletedAt)
  42547. }
  42548. if m.FieldCleared(whatsappchannel.FieldAk) {
  42549. fields = append(fields, whatsappchannel.FieldAk)
  42550. }
  42551. if m.FieldCleared(whatsappchannel.FieldWaID) {
  42552. fields = append(fields, whatsappchannel.FieldWaID)
  42553. }
  42554. if m.FieldCleared(whatsappchannel.FieldWaName) {
  42555. fields = append(fields, whatsappchannel.FieldWaName)
  42556. }
  42557. if m.FieldCleared(whatsappchannel.FieldOrganizationID) {
  42558. fields = append(fields, whatsappchannel.FieldOrganizationID)
  42559. }
  42560. return fields
  42561. }
  42562. // FieldCleared returns a boolean indicating if a field with the given name was
  42563. // cleared in this mutation.
  42564. func (m *WhatsappChannelMutation) FieldCleared(name string) bool {
  42565. _, ok := m.clearedFields[name]
  42566. return ok
  42567. }
  42568. // ClearField clears the value of the field with the given name. It returns an
  42569. // error if the field is not defined in the schema.
  42570. func (m *WhatsappChannelMutation) ClearField(name string) error {
  42571. switch name {
  42572. case whatsappchannel.FieldStatus:
  42573. m.ClearStatus()
  42574. return nil
  42575. case whatsappchannel.FieldDeletedAt:
  42576. m.ClearDeletedAt()
  42577. return nil
  42578. case whatsappchannel.FieldAk:
  42579. m.ClearAk()
  42580. return nil
  42581. case whatsappchannel.FieldWaID:
  42582. m.ClearWaID()
  42583. return nil
  42584. case whatsappchannel.FieldWaName:
  42585. m.ClearWaName()
  42586. return nil
  42587. case whatsappchannel.FieldOrganizationID:
  42588. m.ClearOrganizationID()
  42589. return nil
  42590. }
  42591. return fmt.Errorf("unknown WhatsappChannel nullable field %s", name)
  42592. }
  42593. // ResetField resets all changes in the mutation for the field with the given name.
  42594. // It returns an error if the field is not defined in the schema.
  42595. func (m *WhatsappChannelMutation) ResetField(name string) error {
  42596. switch name {
  42597. case whatsappchannel.FieldCreatedAt:
  42598. m.ResetCreatedAt()
  42599. return nil
  42600. case whatsappchannel.FieldUpdatedAt:
  42601. m.ResetUpdatedAt()
  42602. return nil
  42603. case whatsappchannel.FieldStatus:
  42604. m.ResetStatus()
  42605. return nil
  42606. case whatsappchannel.FieldDeletedAt:
  42607. m.ResetDeletedAt()
  42608. return nil
  42609. case whatsappchannel.FieldAk:
  42610. m.ResetAk()
  42611. return nil
  42612. case whatsappchannel.FieldSk:
  42613. m.ResetSk()
  42614. return nil
  42615. case whatsappchannel.FieldWaID:
  42616. m.ResetWaID()
  42617. return nil
  42618. case whatsappchannel.FieldWaName:
  42619. m.ResetWaName()
  42620. return nil
  42621. case whatsappchannel.FieldWabaID:
  42622. m.ResetWabaID()
  42623. return nil
  42624. case whatsappchannel.FieldBusinessID:
  42625. m.ResetBusinessID()
  42626. return nil
  42627. case whatsappchannel.FieldOrganizationID:
  42628. m.ResetOrganizationID()
  42629. return nil
  42630. case whatsappchannel.FieldVerifyAccount:
  42631. m.ResetVerifyAccount()
  42632. return nil
  42633. }
  42634. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  42635. }
  42636. // AddedEdges returns all edge names that were set/added in this mutation.
  42637. func (m *WhatsappChannelMutation) AddedEdges() []string {
  42638. edges := make([]string, 0, 0)
  42639. return edges
  42640. }
  42641. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  42642. // name in this mutation.
  42643. func (m *WhatsappChannelMutation) AddedIDs(name string) []ent.Value {
  42644. return nil
  42645. }
  42646. // RemovedEdges returns all edge names that were removed in this mutation.
  42647. func (m *WhatsappChannelMutation) RemovedEdges() []string {
  42648. edges := make([]string, 0, 0)
  42649. return edges
  42650. }
  42651. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  42652. // the given name in this mutation.
  42653. func (m *WhatsappChannelMutation) RemovedIDs(name string) []ent.Value {
  42654. return nil
  42655. }
  42656. // ClearedEdges returns all edge names that were cleared in this mutation.
  42657. func (m *WhatsappChannelMutation) ClearedEdges() []string {
  42658. edges := make([]string, 0, 0)
  42659. return edges
  42660. }
  42661. // EdgeCleared returns a boolean which indicates if the edge with the given name
  42662. // was cleared in this mutation.
  42663. func (m *WhatsappChannelMutation) EdgeCleared(name string) bool {
  42664. return false
  42665. }
  42666. // ClearEdge clears the value of the edge with the given name. It returns an error
  42667. // if that edge is not defined in the schema.
  42668. func (m *WhatsappChannelMutation) ClearEdge(name string) error {
  42669. return fmt.Errorf("unknown WhatsappChannel unique edge %s", name)
  42670. }
  42671. // ResetEdge resets all changes to the edge with the given name in this mutation.
  42672. // It returns an error if the edge is not defined in the schema.
  42673. func (m *WhatsappChannelMutation) ResetEdge(name string) error {
  42674. return fmt.Errorf("unknown WhatsappChannel edge %s", name)
  42675. }
  42676. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  42677. type WorkExperienceMutation struct {
  42678. config
  42679. op Op
  42680. typ string
  42681. id *uint64
  42682. created_at *time.Time
  42683. updated_at *time.Time
  42684. deleted_at *time.Time
  42685. start_date *time.Time
  42686. end_date *time.Time
  42687. company *string
  42688. experience *string
  42689. organization_id *uint64
  42690. addorganization_id *int64
  42691. clearedFields map[string]struct{}
  42692. employee *uint64
  42693. clearedemployee bool
  42694. done bool
  42695. oldValue func(context.Context) (*WorkExperience, error)
  42696. predicates []predicate.WorkExperience
  42697. }
  42698. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  42699. // workexperienceOption allows management of the mutation configuration using functional options.
  42700. type workexperienceOption func(*WorkExperienceMutation)
  42701. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  42702. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  42703. m := &WorkExperienceMutation{
  42704. config: c,
  42705. op: op,
  42706. typ: TypeWorkExperience,
  42707. clearedFields: make(map[string]struct{}),
  42708. }
  42709. for _, opt := range opts {
  42710. opt(m)
  42711. }
  42712. return m
  42713. }
  42714. // withWorkExperienceID sets the ID field of the mutation.
  42715. func withWorkExperienceID(id uint64) workexperienceOption {
  42716. return func(m *WorkExperienceMutation) {
  42717. var (
  42718. err error
  42719. once sync.Once
  42720. value *WorkExperience
  42721. )
  42722. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  42723. once.Do(func() {
  42724. if m.done {
  42725. err = errors.New("querying old values post mutation is not allowed")
  42726. } else {
  42727. value, err = m.Client().WorkExperience.Get(ctx, id)
  42728. }
  42729. })
  42730. return value, err
  42731. }
  42732. m.id = &id
  42733. }
  42734. }
  42735. // withWorkExperience sets the old WorkExperience of the mutation.
  42736. func withWorkExperience(node *WorkExperience) workexperienceOption {
  42737. return func(m *WorkExperienceMutation) {
  42738. m.oldValue = func(context.Context) (*WorkExperience, error) {
  42739. return node, nil
  42740. }
  42741. m.id = &node.ID
  42742. }
  42743. }
  42744. // Client returns a new `ent.Client` from the mutation. If the mutation was
  42745. // executed in a transaction (ent.Tx), a transactional client is returned.
  42746. func (m WorkExperienceMutation) Client() *Client {
  42747. client := &Client{config: m.config}
  42748. client.init()
  42749. return client
  42750. }
  42751. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  42752. // it returns an error otherwise.
  42753. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  42754. if _, ok := m.driver.(*txDriver); !ok {
  42755. return nil, errors.New("ent: mutation is not running in a transaction")
  42756. }
  42757. tx := &Tx{config: m.config}
  42758. tx.init()
  42759. return tx, nil
  42760. }
  42761. // SetID sets the value of the id field. Note that this
  42762. // operation is only accepted on creation of WorkExperience entities.
  42763. func (m *WorkExperienceMutation) SetID(id uint64) {
  42764. m.id = &id
  42765. }
  42766. // ID returns the ID value in the mutation. Note that the ID is only available
  42767. // if it was provided to the builder or after it was returned from the database.
  42768. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  42769. if m.id == nil {
  42770. return
  42771. }
  42772. return *m.id, true
  42773. }
  42774. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  42775. // That means, if the mutation is applied within a transaction with an isolation level such
  42776. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  42777. // or updated by the mutation.
  42778. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  42779. switch {
  42780. case m.op.Is(OpUpdateOne | OpDeleteOne):
  42781. id, exists := m.ID()
  42782. if exists {
  42783. return []uint64{id}, nil
  42784. }
  42785. fallthrough
  42786. case m.op.Is(OpUpdate | OpDelete):
  42787. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  42788. default:
  42789. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  42790. }
  42791. }
  42792. // SetCreatedAt sets the "created_at" field.
  42793. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  42794. m.created_at = &t
  42795. }
  42796. // CreatedAt returns the value of the "created_at" field in the mutation.
  42797. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  42798. v := m.created_at
  42799. if v == nil {
  42800. return
  42801. }
  42802. return *v, true
  42803. }
  42804. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  42805. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  42806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42807. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  42808. if !m.op.Is(OpUpdateOne) {
  42809. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  42810. }
  42811. if m.id == nil || m.oldValue == nil {
  42812. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  42813. }
  42814. oldValue, err := m.oldValue(ctx)
  42815. if err != nil {
  42816. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  42817. }
  42818. return oldValue.CreatedAt, nil
  42819. }
  42820. // ResetCreatedAt resets all changes to the "created_at" field.
  42821. func (m *WorkExperienceMutation) ResetCreatedAt() {
  42822. m.created_at = nil
  42823. }
  42824. // SetUpdatedAt sets the "updated_at" field.
  42825. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  42826. m.updated_at = &t
  42827. }
  42828. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  42829. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  42830. v := m.updated_at
  42831. if v == nil {
  42832. return
  42833. }
  42834. return *v, true
  42835. }
  42836. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  42837. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  42838. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42839. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  42840. if !m.op.Is(OpUpdateOne) {
  42841. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  42842. }
  42843. if m.id == nil || m.oldValue == nil {
  42844. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  42845. }
  42846. oldValue, err := m.oldValue(ctx)
  42847. if err != nil {
  42848. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  42849. }
  42850. return oldValue.UpdatedAt, nil
  42851. }
  42852. // ResetUpdatedAt resets all changes to the "updated_at" field.
  42853. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  42854. m.updated_at = nil
  42855. }
  42856. // SetDeletedAt sets the "deleted_at" field.
  42857. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  42858. m.deleted_at = &t
  42859. }
  42860. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  42861. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  42862. v := m.deleted_at
  42863. if v == nil {
  42864. return
  42865. }
  42866. return *v, true
  42867. }
  42868. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  42869. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  42870. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42871. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  42872. if !m.op.Is(OpUpdateOne) {
  42873. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  42874. }
  42875. if m.id == nil || m.oldValue == nil {
  42876. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  42877. }
  42878. oldValue, err := m.oldValue(ctx)
  42879. if err != nil {
  42880. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  42881. }
  42882. return oldValue.DeletedAt, nil
  42883. }
  42884. // ClearDeletedAt clears the value of the "deleted_at" field.
  42885. func (m *WorkExperienceMutation) ClearDeletedAt() {
  42886. m.deleted_at = nil
  42887. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  42888. }
  42889. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  42890. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  42891. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  42892. return ok
  42893. }
  42894. // ResetDeletedAt resets all changes to the "deleted_at" field.
  42895. func (m *WorkExperienceMutation) ResetDeletedAt() {
  42896. m.deleted_at = nil
  42897. delete(m.clearedFields, workexperience.FieldDeletedAt)
  42898. }
  42899. // SetEmployeeID sets the "employee_id" field.
  42900. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  42901. m.employee = &u
  42902. }
  42903. // EmployeeID returns the value of the "employee_id" field in the mutation.
  42904. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  42905. v := m.employee
  42906. if v == nil {
  42907. return
  42908. }
  42909. return *v, true
  42910. }
  42911. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  42912. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  42913. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42914. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  42915. if !m.op.Is(OpUpdateOne) {
  42916. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  42917. }
  42918. if m.id == nil || m.oldValue == nil {
  42919. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  42920. }
  42921. oldValue, err := m.oldValue(ctx)
  42922. if err != nil {
  42923. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  42924. }
  42925. return oldValue.EmployeeID, nil
  42926. }
  42927. // ResetEmployeeID resets all changes to the "employee_id" field.
  42928. func (m *WorkExperienceMutation) ResetEmployeeID() {
  42929. m.employee = nil
  42930. }
  42931. // SetStartDate sets the "start_date" field.
  42932. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  42933. m.start_date = &t
  42934. }
  42935. // StartDate returns the value of the "start_date" field in the mutation.
  42936. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  42937. v := m.start_date
  42938. if v == nil {
  42939. return
  42940. }
  42941. return *v, true
  42942. }
  42943. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  42944. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  42945. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42946. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  42947. if !m.op.Is(OpUpdateOne) {
  42948. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  42949. }
  42950. if m.id == nil || m.oldValue == nil {
  42951. return v, errors.New("OldStartDate requires an ID field in the mutation")
  42952. }
  42953. oldValue, err := m.oldValue(ctx)
  42954. if err != nil {
  42955. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  42956. }
  42957. return oldValue.StartDate, nil
  42958. }
  42959. // ResetStartDate resets all changes to the "start_date" field.
  42960. func (m *WorkExperienceMutation) ResetStartDate() {
  42961. m.start_date = nil
  42962. }
  42963. // SetEndDate sets the "end_date" field.
  42964. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  42965. m.end_date = &t
  42966. }
  42967. // EndDate returns the value of the "end_date" field in the mutation.
  42968. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  42969. v := m.end_date
  42970. if v == nil {
  42971. return
  42972. }
  42973. return *v, true
  42974. }
  42975. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  42976. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  42977. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42978. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  42979. if !m.op.Is(OpUpdateOne) {
  42980. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  42981. }
  42982. if m.id == nil || m.oldValue == nil {
  42983. return v, errors.New("OldEndDate requires an ID field in the mutation")
  42984. }
  42985. oldValue, err := m.oldValue(ctx)
  42986. if err != nil {
  42987. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  42988. }
  42989. return oldValue.EndDate, nil
  42990. }
  42991. // ResetEndDate resets all changes to the "end_date" field.
  42992. func (m *WorkExperienceMutation) ResetEndDate() {
  42993. m.end_date = nil
  42994. }
  42995. // SetCompany sets the "company" field.
  42996. func (m *WorkExperienceMutation) SetCompany(s string) {
  42997. m.company = &s
  42998. }
  42999. // Company returns the value of the "company" field in the mutation.
  43000. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  43001. v := m.company
  43002. if v == nil {
  43003. return
  43004. }
  43005. return *v, true
  43006. }
  43007. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  43008. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  43009. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43010. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  43011. if !m.op.Is(OpUpdateOne) {
  43012. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  43013. }
  43014. if m.id == nil || m.oldValue == nil {
  43015. return v, errors.New("OldCompany requires an ID field in the mutation")
  43016. }
  43017. oldValue, err := m.oldValue(ctx)
  43018. if err != nil {
  43019. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  43020. }
  43021. return oldValue.Company, nil
  43022. }
  43023. // ResetCompany resets all changes to the "company" field.
  43024. func (m *WorkExperienceMutation) ResetCompany() {
  43025. m.company = nil
  43026. }
  43027. // SetExperience sets the "experience" field.
  43028. func (m *WorkExperienceMutation) SetExperience(s string) {
  43029. m.experience = &s
  43030. }
  43031. // Experience returns the value of the "experience" field in the mutation.
  43032. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  43033. v := m.experience
  43034. if v == nil {
  43035. return
  43036. }
  43037. return *v, true
  43038. }
  43039. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  43040. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  43041. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43042. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  43043. if !m.op.Is(OpUpdateOne) {
  43044. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  43045. }
  43046. if m.id == nil || m.oldValue == nil {
  43047. return v, errors.New("OldExperience requires an ID field in the mutation")
  43048. }
  43049. oldValue, err := m.oldValue(ctx)
  43050. if err != nil {
  43051. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  43052. }
  43053. return oldValue.Experience, nil
  43054. }
  43055. // ResetExperience resets all changes to the "experience" field.
  43056. func (m *WorkExperienceMutation) ResetExperience() {
  43057. m.experience = nil
  43058. }
  43059. // SetOrganizationID sets the "organization_id" field.
  43060. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  43061. m.organization_id = &u
  43062. m.addorganization_id = nil
  43063. }
  43064. // OrganizationID returns the value of the "organization_id" field in the mutation.
  43065. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  43066. v := m.organization_id
  43067. if v == nil {
  43068. return
  43069. }
  43070. return *v, true
  43071. }
  43072. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  43073. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  43074. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43075. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  43076. if !m.op.Is(OpUpdateOne) {
  43077. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  43078. }
  43079. if m.id == nil || m.oldValue == nil {
  43080. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  43081. }
  43082. oldValue, err := m.oldValue(ctx)
  43083. if err != nil {
  43084. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  43085. }
  43086. return oldValue.OrganizationID, nil
  43087. }
  43088. // AddOrganizationID adds u to the "organization_id" field.
  43089. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  43090. if m.addorganization_id != nil {
  43091. *m.addorganization_id += u
  43092. } else {
  43093. m.addorganization_id = &u
  43094. }
  43095. }
  43096. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  43097. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  43098. v := m.addorganization_id
  43099. if v == nil {
  43100. return
  43101. }
  43102. return *v, true
  43103. }
  43104. // ResetOrganizationID resets all changes to the "organization_id" field.
  43105. func (m *WorkExperienceMutation) ResetOrganizationID() {
  43106. m.organization_id = nil
  43107. m.addorganization_id = nil
  43108. }
  43109. // ClearEmployee clears the "employee" edge to the Employee entity.
  43110. func (m *WorkExperienceMutation) ClearEmployee() {
  43111. m.clearedemployee = true
  43112. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  43113. }
  43114. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  43115. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  43116. return m.clearedemployee
  43117. }
  43118. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  43119. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  43120. // EmployeeID instead. It exists only for internal usage by the builders.
  43121. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  43122. if id := m.employee; id != nil {
  43123. ids = append(ids, *id)
  43124. }
  43125. return
  43126. }
  43127. // ResetEmployee resets all changes to the "employee" edge.
  43128. func (m *WorkExperienceMutation) ResetEmployee() {
  43129. m.employee = nil
  43130. m.clearedemployee = false
  43131. }
  43132. // Where appends a list predicates to the WorkExperienceMutation builder.
  43133. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  43134. m.predicates = append(m.predicates, ps...)
  43135. }
  43136. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  43137. // users can use type-assertion to append predicates that do not depend on any generated package.
  43138. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  43139. p := make([]predicate.WorkExperience, len(ps))
  43140. for i := range ps {
  43141. p[i] = ps[i]
  43142. }
  43143. m.Where(p...)
  43144. }
  43145. // Op returns the operation name.
  43146. func (m *WorkExperienceMutation) Op() Op {
  43147. return m.op
  43148. }
  43149. // SetOp allows setting the mutation operation.
  43150. func (m *WorkExperienceMutation) SetOp(op Op) {
  43151. m.op = op
  43152. }
  43153. // Type returns the node type of this mutation (WorkExperience).
  43154. func (m *WorkExperienceMutation) Type() string {
  43155. return m.typ
  43156. }
  43157. // Fields returns all fields that were changed during this mutation. Note that in
  43158. // order to get all numeric fields that were incremented/decremented, call
  43159. // AddedFields().
  43160. func (m *WorkExperienceMutation) Fields() []string {
  43161. fields := make([]string, 0, 9)
  43162. if m.created_at != nil {
  43163. fields = append(fields, workexperience.FieldCreatedAt)
  43164. }
  43165. if m.updated_at != nil {
  43166. fields = append(fields, workexperience.FieldUpdatedAt)
  43167. }
  43168. if m.deleted_at != nil {
  43169. fields = append(fields, workexperience.FieldDeletedAt)
  43170. }
  43171. if m.employee != nil {
  43172. fields = append(fields, workexperience.FieldEmployeeID)
  43173. }
  43174. if m.start_date != nil {
  43175. fields = append(fields, workexperience.FieldStartDate)
  43176. }
  43177. if m.end_date != nil {
  43178. fields = append(fields, workexperience.FieldEndDate)
  43179. }
  43180. if m.company != nil {
  43181. fields = append(fields, workexperience.FieldCompany)
  43182. }
  43183. if m.experience != nil {
  43184. fields = append(fields, workexperience.FieldExperience)
  43185. }
  43186. if m.organization_id != nil {
  43187. fields = append(fields, workexperience.FieldOrganizationID)
  43188. }
  43189. return fields
  43190. }
  43191. // Field returns the value of a field with the given name. The second boolean
  43192. // return value indicates that this field was not set, or was not defined in the
  43193. // schema.
  43194. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  43195. switch name {
  43196. case workexperience.FieldCreatedAt:
  43197. return m.CreatedAt()
  43198. case workexperience.FieldUpdatedAt:
  43199. return m.UpdatedAt()
  43200. case workexperience.FieldDeletedAt:
  43201. return m.DeletedAt()
  43202. case workexperience.FieldEmployeeID:
  43203. return m.EmployeeID()
  43204. case workexperience.FieldStartDate:
  43205. return m.StartDate()
  43206. case workexperience.FieldEndDate:
  43207. return m.EndDate()
  43208. case workexperience.FieldCompany:
  43209. return m.Company()
  43210. case workexperience.FieldExperience:
  43211. return m.Experience()
  43212. case workexperience.FieldOrganizationID:
  43213. return m.OrganizationID()
  43214. }
  43215. return nil, false
  43216. }
  43217. // OldField returns the old value of the field from the database. An error is
  43218. // returned if the mutation operation is not UpdateOne, or the query to the
  43219. // database failed.
  43220. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  43221. switch name {
  43222. case workexperience.FieldCreatedAt:
  43223. return m.OldCreatedAt(ctx)
  43224. case workexperience.FieldUpdatedAt:
  43225. return m.OldUpdatedAt(ctx)
  43226. case workexperience.FieldDeletedAt:
  43227. return m.OldDeletedAt(ctx)
  43228. case workexperience.FieldEmployeeID:
  43229. return m.OldEmployeeID(ctx)
  43230. case workexperience.FieldStartDate:
  43231. return m.OldStartDate(ctx)
  43232. case workexperience.FieldEndDate:
  43233. return m.OldEndDate(ctx)
  43234. case workexperience.FieldCompany:
  43235. return m.OldCompany(ctx)
  43236. case workexperience.FieldExperience:
  43237. return m.OldExperience(ctx)
  43238. case workexperience.FieldOrganizationID:
  43239. return m.OldOrganizationID(ctx)
  43240. }
  43241. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  43242. }
  43243. // SetField sets the value of a field with the given name. It returns an error if
  43244. // the field is not defined in the schema, or if the type mismatched the field
  43245. // type.
  43246. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  43247. switch name {
  43248. case workexperience.FieldCreatedAt:
  43249. v, ok := value.(time.Time)
  43250. if !ok {
  43251. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43252. }
  43253. m.SetCreatedAt(v)
  43254. return nil
  43255. case workexperience.FieldUpdatedAt:
  43256. v, ok := value.(time.Time)
  43257. if !ok {
  43258. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43259. }
  43260. m.SetUpdatedAt(v)
  43261. return nil
  43262. case workexperience.FieldDeletedAt:
  43263. v, ok := value.(time.Time)
  43264. if !ok {
  43265. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43266. }
  43267. m.SetDeletedAt(v)
  43268. return nil
  43269. case workexperience.FieldEmployeeID:
  43270. v, ok := value.(uint64)
  43271. if !ok {
  43272. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43273. }
  43274. m.SetEmployeeID(v)
  43275. return nil
  43276. case workexperience.FieldStartDate:
  43277. v, ok := value.(time.Time)
  43278. if !ok {
  43279. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43280. }
  43281. m.SetStartDate(v)
  43282. return nil
  43283. case workexperience.FieldEndDate:
  43284. v, ok := value.(time.Time)
  43285. if !ok {
  43286. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43287. }
  43288. m.SetEndDate(v)
  43289. return nil
  43290. case workexperience.FieldCompany:
  43291. v, ok := value.(string)
  43292. if !ok {
  43293. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43294. }
  43295. m.SetCompany(v)
  43296. return nil
  43297. case workexperience.FieldExperience:
  43298. v, ok := value.(string)
  43299. if !ok {
  43300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43301. }
  43302. m.SetExperience(v)
  43303. return nil
  43304. case workexperience.FieldOrganizationID:
  43305. v, ok := value.(uint64)
  43306. if !ok {
  43307. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43308. }
  43309. m.SetOrganizationID(v)
  43310. return nil
  43311. }
  43312. return fmt.Errorf("unknown WorkExperience field %s", name)
  43313. }
  43314. // AddedFields returns all numeric fields that were incremented/decremented during
  43315. // this mutation.
  43316. func (m *WorkExperienceMutation) AddedFields() []string {
  43317. var fields []string
  43318. if m.addorganization_id != nil {
  43319. fields = append(fields, workexperience.FieldOrganizationID)
  43320. }
  43321. return fields
  43322. }
  43323. // AddedField returns the numeric value that was incremented/decremented on a field
  43324. // with the given name. The second boolean return value indicates that this field
  43325. // was not set, or was not defined in the schema.
  43326. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  43327. switch name {
  43328. case workexperience.FieldOrganizationID:
  43329. return m.AddedOrganizationID()
  43330. }
  43331. return nil, false
  43332. }
  43333. // AddField adds the value to the field with the given name. It returns an error if
  43334. // the field is not defined in the schema, or if the type mismatched the field
  43335. // type.
  43336. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  43337. switch name {
  43338. case workexperience.FieldOrganizationID:
  43339. v, ok := value.(int64)
  43340. if !ok {
  43341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43342. }
  43343. m.AddOrganizationID(v)
  43344. return nil
  43345. }
  43346. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  43347. }
  43348. // ClearedFields returns all nullable fields that were cleared during this
  43349. // mutation.
  43350. func (m *WorkExperienceMutation) ClearedFields() []string {
  43351. var fields []string
  43352. if m.FieldCleared(workexperience.FieldDeletedAt) {
  43353. fields = append(fields, workexperience.FieldDeletedAt)
  43354. }
  43355. return fields
  43356. }
  43357. // FieldCleared returns a boolean indicating if a field with the given name was
  43358. // cleared in this mutation.
  43359. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  43360. _, ok := m.clearedFields[name]
  43361. return ok
  43362. }
  43363. // ClearField clears the value of the field with the given name. It returns an
  43364. // error if the field is not defined in the schema.
  43365. func (m *WorkExperienceMutation) ClearField(name string) error {
  43366. switch name {
  43367. case workexperience.FieldDeletedAt:
  43368. m.ClearDeletedAt()
  43369. return nil
  43370. }
  43371. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  43372. }
  43373. // ResetField resets all changes in the mutation for the field with the given name.
  43374. // It returns an error if the field is not defined in the schema.
  43375. func (m *WorkExperienceMutation) ResetField(name string) error {
  43376. switch name {
  43377. case workexperience.FieldCreatedAt:
  43378. m.ResetCreatedAt()
  43379. return nil
  43380. case workexperience.FieldUpdatedAt:
  43381. m.ResetUpdatedAt()
  43382. return nil
  43383. case workexperience.FieldDeletedAt:
  43384. m.ResetDeletedAt()
  43385. return nil
  43386. case workexperience.FieldEmployeeID:
  43387. m.ResetEmployeeID()
  43388. return nil
  43389. case workexperience.FieldStartDate:
  43390. m.ResetStartDate()
  43391. return nil
  43392. case workexperience.FieldEndDate:
  43393. m.ResetEndDate()
  43394. return nil
  43395. case workexperience.FieldCompany:
  43396. m.ResetCompany()
  43397. return nil
  43398. case workexperience.FieldExperience:
  43399. m.ResetExperience()
  43400. return nil
  43401. case workexperience.FieldOrganizationID:
  43402. m.ResetOrganizationID()
  43403. return nil
  43404. }
  43405. return fmt.Errorf("unknown WorkExperience field %s", name)
  43406. }
  43407. // AddedEdges returns all edge names that were set/added in this mutation.
  43408. func (m *WorkExperienceMutation) AddedEdges() []string {
  43409. edges := make([]string, 0, 1)
  43410. if m.employee != nil {
  43411. edges = append(edges, workexperience.EdgeEmployee)
  43412. }
  43413. return edges
  43414. }
  43415. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  43416. // name in this mutation.
  43417. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  43418. switch name {
  43419. case workexperience.EdgeEmployee:
  43420. if id := m.employee; id != nil {
  43421. return []ent.Value{*id}
  43422. }
  43423. }
  43424. return nil
  43425. }
  43426. // RemovedEdges returns all edge names that were removed in this mutation.
  43427. func (m *WorkExperienceMutation) RemovedEdges() []string {
  43428. edges := make([]string, 0, 1)
  43429. return edges
  43430. }
  43431. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  43432. // the given name in this mutation.
  43433. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  43434. return nil
  43435. }
  43436. // ClearedEdges returns all edge names that were cleared in this mutation.
  43437. func (m *WorkExperienceMutation) ClearedEdges() []string {
  43438. edges := make([]string, 0, 1)
  43439. if m.clearedemployee {
  43440. edges = append(edges, workexperience.EdgeEmployee)
  43441. }
  43442. return edges
  43443. }
  43444. // EdgeCleared returns a boolean which indicates if the edge with the given name
  43445. // was cleared in this mutation.
  43446. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  43447. switch name {
  43448. case workexperience.EdgeEmployee:
  43449. return m.clearedemployee
  43450. }
  43451. return false
  43452. }
  43453. // ClearEdge clears the value of the edge with the given name. It returns an error
  43454. // if that edge is not defined in the schema.
  43455. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  43456. switch name {
  43457. case workexperience.EdgeEmployee:
  43458. m.ClearEmployee()
  43459. return nil
  43460. }
  43461. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  43462. }
  43463. // ResetEdge resets all changes to the edge with the given name in this mutation.
  43464. // It returns an error if the edge is not defined in the schema.
  43465. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  43466. switch name {
  43467. case workexperience.EdgeEmployee:
  43468. m.ResetEmployee()
  43469. return nil
  43470. }
  43471. return fmt.Errorf("unknown WorkExperience edge %s", name)
  43472. }
  43473. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  43474. type WpChatroomMutation struct {
  43475. config
  43476. op Op
  43477. typ string
  43478. id *uint64
  43479. created_at *time.Time
  43480. updated_at *time.Time
  43481. status *uint8
  43482. addstatus *int8
  43483. wx_wxid *string
  43484. chatroom_id *string
  43485. nickname *string
  43486. owner *string
  43487. avatar *string
  43488. member_list *[]string
  43489. appendmember_list []string
  43490. clearedFields map[string]struct{}
  43491. done bool
  43492. oldValue func(context.Context) (*WpChatroom, error)
  43493. predicates []predicate.WpChatroom
  43494. }
  43495. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  43496. // wpchatroomOption allows management of the mutation configuration using functional options.
  43497. type wpchatroomOption func(*WpChatroomMutation)
  43498. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  43499. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  43500. m := &WpChatroomMutation{
  43501. config: c,
  43502. op: op,
  43503. typ: TypeWpChatroom,
  43504. clearedFields: make(map[string]struct{}),
  43505. }
  43506. for _, opt := range opts {
  43507. opt(m)
  43508. }
  43509. return m
  43510. }
  43511. // withWpChatroomID sets the ID field of the mutation.
  43512. func withWpChatroomID(id uint64) wpchatroomOption {
  43513. return func(m *WpChatroomMutation) {
  43514. var (
  43515. err error
  43516. once sync.Once
  43517. value *WpChatroom
  43518. )
  43519. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  43520. once.Do(func() {
  43521. if m.done {
  43522. err = errors.New("querying old values post mutation is not allowed")
  43523. } else {
  43524. value, err = m.Client().WpChatroom.Get(ctx, id)
  43525. }
  43526. })
  43527. return value, err
  43528. }
  43529. m.id = &id
  43530. }
  43531. }
  43532. // withWpChatroom sets the old WpChatroom of the mutation.
  43533. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  43534. return func(m *WpChatroomMutation) {
  43535. m.oldValue = func(context.Context) (*WpChatroom, error) {
  43536. return node, nil
  43537. }
  43538. m.id = &node.ID
  43539. }
  43540. }
  43541. // Client returns a new `ent.Client` from the mutation. If the mutation was
  43542. // executed in a transaction (ent.Tx), a transactional client is returned.
  43543. func (m WpChatroomMutation) Client() *Client {
  43544. client := &Client{config: m.config}
  43545. client.init()
  43546. return client
  43547. }
  43548. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  43549. // it returns an error otherwise.
  43550. func (m WpChatroomMutation) Tx() (*Tx, error) {
  43551. if _, ok := m.driver.(*txDriver); !ok {
  43552. return nil, errors.New("ent: mutation is not running in a transaction")
  43553. }
  43554. tx := &Tx{config: m.config}
  43555. tx.init()
  43556. return tx, nil
  43557. }
  43558. // SetID sets the value of the id field. Note that this
  43559. // operation is only accepted on creation of WpChatroom entities.
  43560. func (m *WpChatroomMutation) SetID(id uint64) {
  43561. m.id = &id
  43562. }
  43563. // ID returns the ID value in the mutation. Note that the ID is only available
  43564. // if it was provided to the builder or after it was returned from the database.
  43565. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  43566. if m.id == nil {
  43567. return
  43568. }
  43569. return *m.id, true
  43570. }
  43571. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  43572. // That means, if the mutation is applied within a transaction with an isolation level such
  43573. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  43574. // or updated by the mutation.
  43575. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  43576. switch {
  43577. case m.op.Is(OpUpdateOne | OpDeleteOne):
  43578. id, exists := m.ID()
  43579. if exists {
  43580. return []uint64{id}, nil
  43581. }
  43582. fallthrough
  43583. case m.op.Is(OpUpdate | OpDelete):
  43584. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  43585. default:
  43586. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  43587. }
  43588. }
  43589. // SetCreatedAt sets the "created_at" field.
  43590. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  43591. m.created_at = &t
  43592. }
  43593. // CreatedAt returns the value of the "created_at" field in the mutation.
  43594. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  43595. v := m.created_at
  43596. if v == nil {
  43597. return
  43598. }
  43599. return *v, true
  43600. }
  43601. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  43602. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  43603. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43604. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  43605. if !m.op.Is(OpUpdateOne) {
  43606. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  43607. }
  43608. if m.id == nil || m.oldValue == nil {
  43609. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  43610. }
  43611. oldValue, err := m.oldValue(ctx)
  43612. if err != nil {
  43613. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  43614. }
  43615. return oldValue.CreatedAt, nil
  43616. }
  43617. // ResetCreatedAt resets all changes to the "created_at" field.
  43618. func (m *WpChatroomMutation) ResetCreatedAt() {
  43619. m.created_at = nil
  43620. }
  43621. // SetUpdatedAt sets the "updated_at" field.
  43622. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  43623. m.updated_at = &t
  43624. }
  43625. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  43626. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  43627. v := m.updated_at
  43628. if v == nil {
  43629. return
  43630. }
  43631. return *v, true
  43632. }
  43633. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  43634. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  43635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43636. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  43637. if !m.op.Is(OpUpdateOne) {
  43638. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  43639. }
  43640. if m.id == nil || m.oldValue == nil {
  43641. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  43642. }
  43643. oldValue, err := m.oldValue(ctx)
  43644. if err != nil {
  43645. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  43646. }
  43647. return oldValue.UpdatedAt, nil
  43648. }
  43649. // ResetUpdatedAt resets all changes to the "updated_at" field.
  43650. func (m *WpChatroomMutation) ResetUpdatedAt() {
  43651. m.updated_at = nil
  43652. }
  43653. // SetStatus sets the "status" field.
  43654. func (m *WpChatroomMutation) SetStatus(u uint8) {
  43655. m.status = &u
  43656. m.addstatus = nil
  43657. }
  43658. // Status returns the value of the "status" field in the mutation.
  43659. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  43660. v := m.status
  43661. if v == nil {
  43662. return
  43663. }
  43664. return *v, true
  43665. }
  43666. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  43667. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  43668. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43669. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  43670. if !m.op.Is(OpUpdateOne) {
  43671. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  43672. }
  43673. if m.id == nil || m.oldValue == nil {
  43674. return v, errors.New("OldStatus requires an ID field in the mutation")
  43675. }
  43676. oldValue, err := m.oldValue(ctx)
  43677. if err != nil {
  43678. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  43679. }
  43680. return oldValue.Status, nil
  43681. }
  43682. // AddStatus adds u to the "status" field.
  43683. func (m *WpChatroomMutation) AddStatus(u int8) {
  43684. if m.addstatus != nil {
  43685. *m.addstatus += u
  43686. } else {
  43687. m.addstatus = &u
  43688. }
  43689. }
  43690. // AddedStatus returns the value that was added to the "status" field in this mutation.
  43691. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  43692. v := m.addstatus
  43693. if v == nil {
  43694. return
  43695. }
  43696. return *v, true
  43697. }
  43698. // ClearStatus clears the value of the "status" field.
  43699. func (m *WpChatroomMutation) ClearStatus() {
  43700. m.status = nil
  43701. m.addstatus = nil
  43702. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  43703. }
  43704. // StatusCleared returns if the "status" field was cleared in this mutation.
  43705. func (m *WpChatroomMutation) StatusCleared() bool {
  43706. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  43707. return ok
  43708. }
  43709. // ResetStatus resets all changes to the "status" field.
  43710. func (m *WpChatroomMutation) ResetStatus() {
  43711. m.status = nil
  43712. m.addstatus = nil
  43713. delete(m.clearedFields, wpchatroom.FieldStatus)
  43714. }
  43715. // SetWxWxid sets the "wx_wxid" field.
  43716. func (m *WpChatroomMutation) SetWxWxid(s string) {
  43717. m.wx_wxid = &s
  43718. }
  43719. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  43720. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  43721. v := m.wx_wxid
  43722. if v == nil {
  43723. return
  43724. }
  43725. return *v, true
  43726. }
  43727. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  43728. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  43729. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43730. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  43731. if !m.op.Is(OpUpdateOne) {
  43732. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  43733. }
  43734. if m.id == nil || m.oldValue == nil {
  43735. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  43736. }
  43737. oldValue, err := m.oldValue(ctx)
  43738. if err != nil {
  43739. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  43740. }
  43741. return oldValue.WxWxid, nil
  43742. }
  43743. // ResetWxWxid resets all changes to the "wx_wxid" field.
  43744. func (m *WpChatroomMutation) ResetWxWxid() {
  43745. m.wx_wxid = nil
  43746. }
  43747. // SetChatroomID sets the "chatroom_id" field.
  43748. func (m *WpChatroomMutation) SetChatroomID(s string) {
  43749. m.chatroom_id = &s
  43750. }
  43751. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  43752. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  43753. v := m.chatroom_id
  43754. if v == nil {
  43755. return
  43756. }
  43757. return *v, true
  43758. }
  43759. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  43760. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  43761. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43762. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  43763. if !m.op.Is(OpUpdateOne) {
  43764. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  43765. }
  43766. if m.id == nil || m.oldValue == nil {
  43767. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  43768. }
  43769. oldValue, err := m.oldValue(ctx)
  43770. if err != nil {
  43771. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  43772. }
  43773. return oldValue.ChatroomID, nil
  43774. }
  43775. // ResetChatroomID resets all changes to the "chatroom_id" field.
  43776. func (m *WpChatroomMutation) ResetChatroomID() {
  43777. m.chatroom_id = nil
  43778. }
  43779. // SetNickname sets the "nickname" field.
  43780. func (m *WpChatroomMutation) SetNickname(s string) {
  43781. m.nickname = &s
  43782. }
  43783. // Nickname returns the value of the "nickname" field in the mutation.
  43784. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  43785. v := m.nickname
  43786. if v == nil {
  43787. return
  43788. }
  43789. return *v, true
  43790. }
  43791. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  43792. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  43793. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43794. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  43795. if !m.op.Is(OpUpdateOne) {
  43796. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  43797. }
  43798. if m.id == nil || m.oldValue == nil {
  43799. return v, errors.New("OldNickname requires an ID field in the mutation")
  43800. }
  43801. oldValue, err := m.oldValue(ctx)
  43802. if err != nil {
  43803. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  43804. }
  43805. return oldValue.Nickname, nil
  43806. }
  43807. // ResetNickname resets all changes to the "nickname" field.
  43808. func (m *WpChatroomMutation) ResetNickname() {
  43809. m.nickname = nil
  43810. }
  43811. // SetOwner sets the "owner" field.
  43812. func (m *WpChatroomMutation) SetOwner(s string) {
  43813. m.owner = &s
  43814. }
  43815. // Owner returns the value of the "owner" field in the mutation.
  43816. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  43817. v := m.owner
  43818. if v == nil {
  43819. return
  43820. }
  43821. return *v, true
  43822. }
  43823. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  43824. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  43825. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43826. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  43827. if !m.op.Is(OpUpdateOne) {
  43828. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  43829. }
  43830. if m.id == nil || m.oldValue == nil {
  43831. return v, errors.New("OldOwner requires an ID field in the mutation")
  43832. }
  43833. oldValue, err := m.oldValue(ctx)
  43834. if err != nil {
  43835. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  43836. }
  43837. return oldValue.Owner, nil
  43838. }
  43839. // ResetOwner resets all changes to the "owner" field.
  43840. func (m *WpChatroomMutation) ResetOwner() {
  43841. m.owner = nil
  43842. }
  43843. // SetAvatar sets the "avatar" field.
  43844. func (m *WpChatroomMutation) SetAvatar(s string) {
  43845. m.avatar = &s
  43846. }
  43847. // Avatar returns the value of the "avatar" field in the mutation.
  43848. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  43849. v := m.avatar
  43850. if v == nil {
  43851. return
  43852. }
  43853. return *v, true
  43854. }
  43855. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  43856. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  43857. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43858. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  43859. if !m.op.Is(OpUpdateOne) {
  43860. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  43861. }
  43862. if m.id == nil || m.oldValue == nil {
  43863. return v, errors.New("OldAvatar requires an ID field in the mutation")
  43864. }
  43865. oldValue, err := m.oldValue(ctx)
  43866. if err != nil {
  43867. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  43868. }
  43869. return oldValue.Avatar, nil
  43870. }
  43871. // ResetAvatar resets all changes to the "avatar" field.
  43872. func (m *WpChatroomMutation) ResetAvatar() {
  43873. m.avatar = nil
  43874. }
  43875. // SetMemberList sets the "member_list" field.
  43876. func (m *WpChatroomMutation) SetMemberList(s []string) {
  43877. m.member_list = &s
  43878. m.appendmember_list = nil
  43879. }
  43880. // MemberList returns the value of the "member_list" field in the mutation.
  43881. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  43882. v := m.member_list
  43883. if v == nil {
  43884. return
  43885. }
  43886. return *v, true
  43887. }
  43888. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  43889. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  43890. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43891. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  43892. if !m.op.Is(OpUpdateOne) {
  43893. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  43894. }
  43895. if m.id == nil || m.oldValue == nil {
  43896. return v, errors.New("OldMemberList requires an ID field in the mutation")
  43897. }
  43898. oldValue, err := m.oldValue(ctx)
  43899. if err != nil {
  43900. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  43901. }
  43902. return oldValue.MemberList, nil
  43903. }
  43904. // AppendMemberList adds s to the "member_list" field.
  43905. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  43906. m.appendmember_list = append(m.appendmember_list, s...)
  43907. }
  43908. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  43909. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  43910. if len(m.appendmember_list) == 0 {
  43911. return nil, false
  43912. }
  43913. return m.appendmember_list, true
  43914. }
  43915. // ResetMemberList resets all changes to the "member_list" field.
  43916. func (m *WpChatroomMutation) ResetMemberList() {
  43917. m.member_list = nil
  43918. m.appendmember_list = nil
  43919. }
  43920. // Where appends a list predicates to the WpChatroomMutation builder.
  43921. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  43922. m.predicates = append(m.predicates, ps...)
  43923. }
  43924. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  43925. // users can use type-assertion to append predicates that do not depend on any generated package.
  43926. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  43927. p := make([]predicate.WpChatroom, len(ps))
  43928. for i := range ps {
  43929. p[i] = ps[i]
  43930. }
  43931. m.Where(p...)
  43932. }
  43933. // Op returns the operation name.
  43934. func (m *WpChatroomMutation) Op() Op {
  43935. return m.op
  43936. }
  43937. // SetOp allows setting the mutation operation.
  43938. func (m *WpChatroomMutation) SetOp(op Op) {
  43939. m.op = op
  43940. }
  43941. // Type returns the node type of this mutation (WpChatroom).
  43942. func (m *WpChatroomMutation) Type() string {
  43943. return m.typ
  43944. }
  43945. // Fields returns all fields that were changed during this mutation. Note that in
  43946. // order to get all numeric fields that were incremented/decremented, call
  43947. // AddedFields().
  43948. func (m *WpChatroomMutation) Fields() []string {
  43949. fields := make([]string, 0, 9)
  43950. if m.created_at != nil {
  43951. fields = append(fields, wpchatroom.FieldCreatedAt)
  43952. }
  43953. if m.updated_at != nil {
  43954. fields = append(fields, wpchatroom.FieldUpdatedAt)
  43955. }
  43956. if m.status != nil {
  43957. fields = append(fields, wpchatroom.FieldStatus)
  43958. }
  43959. if m.wx_wxid != nil {
  43960. fields = append(fields, wpchatroom.FieldWxWxid)
  43961. }
  43962. if m.chatroom_id != nil {
  43963. fields = append(fields, wpchatroom.FieldChatroomID)
  43964. }
  43965. if m.nickname != nil {
  43966. fields = append(fields, wpchatroom.FieldNickname)
  43967. }
  43968. if m.owner != nil {
  43969. fields = append(fields, wpchatroom.FieldOwner)
  43970. }
  43971. if m.avatar != nil {
  43972. fields = append(fields, wpchatroom.FieldAvatar)
  43973. }
  43974. if m.member_list != nil {
  43975. fields = append(fields, wpchatroom.FieldMemberList)
  43976. }
  43977. return fields
  43978. }
  43979. // Field returns the value of a field with the given name. The second boolean
  43980. // return value indicates that this field was not set, or was not defined in the
  43981. // schema.
  43982. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  43983. switch name {
  43984. case wpchatroom.FieldCreatedAt:
  43985. return m.CreatedAt()
  43986. case wpchatroom.FieldUpdatedAt:
  43987. return m.UpdatedAt()
  43988. case wpchatroom.FieldStatus:
  43989. return m.Status()
  43990. case wpchatroom.FieldWxWxid:
  43991. return m.WxWxid()
  43992. case wpchatroom.FieldChatroomID:
  43993. return m.ChatroomID()
  43994. case wpchatroom.FieldNickname:
  43995. return m.Nickname()
  43996. case wpchatroom.FieldOwner:
  43997. return m.Owner()
  43998. case wpchatroom.FieldAvatar:
  43999. return m.Avatar()
  44000. case wpchatroom.FieldMemberList:
  44001. return m.MemberList()
  44002. }
  44003. return nil, false
  44004. }
  44005. // OldField returns the old value of the field from the database. An error is
  44006. // returned if the mutation operation is not UpdateOne, or the query to the
  44007. // database failed.
  44008. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  44009. switch name {
  44010. case wpchatroom.FieldCreatedAt:
  44011. return m.OldCreatedAt(ctx)
  44012. case wpchatroom.FieldUpdatedAt:
  44013. return m.OldUpdatedAt(ctx)
  44014. case wpchatroom.FieldStatus:
  44015. return m.OldStatus(ctx)
  44016. case wpchatroom.FieldWxWxid:
  44017. return m.OldWxWxid(ctx)
  44018. case wpchatroom.FieldChatroomID:
  44019. return m.OldChatroomID(ctx)
  44020. case wpchatroom.FieldNickname:
  44021. return m.OldNickname(ctx)
  44022. case wpchatroom.FieldOwner:
  44023. return m.OldOwner(ctx)
  44024. case wpchatroom.FieldAvatar:
  44025. return m.OldAvatar(ctx)
  44026. case wpchatroom.FieldMemberList:
  44027. return m.OldMemberList(ctx)
  44028. }
  44029. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  44030. }
  44031. // SetField sets the value of a field with the given name. It returns an error if
  44032. // the field is not defined in the schema, or if the type mismatched the field
  44033. // type.
  44034. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  44035. switch name {
  44036. case wpchatroom.FieldCreatedAt:
  44037. v, ok := value.(time.Time)
  44038. if !ok {
  44039. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44040. }
  44041. m.SetCreatedAt(v)
  44042. return nil
  44043. case wpchatroom.FieldUpdatedAt:
  44044. v, ok := value.(time.Time)
  44045. if !ok {
  44046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44047. }
  44048. m.SetUpdatedAt(v)
  44049. return nil
  44050. case wpchatroom.FieldStatus:
  44051. v, ok := value.(uint8)
  44052. if !ok {
  44053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44054. }
  44055. m.SetStatus(v)
  44056. return nil
  44057. case wpchatroom.FieldWxWxid:
  44058. v, ok := value.(string)
  44059. if !ok {
  44060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44061. }
  44062. m.SetWxWxid(v)
  44063. return nil
  44064. case wpchatroom.FieldChatroomID:
  44065. v, ok := value.(string)
  44066. if !ok {
  44067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44068. }
  44069. m.SetChatroomID(v)
  44070. return nil
  44071. case wpchatroom.FieldNickname:
  44072. v, ok := value.(string)
  44073. if !ok {
  44074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44075. }
  44076. m.SetNickname(v)
  44077. return nil
  44078. case wpchatroom.FieldOwner:
  44079. v, ok := value.(string)
  44080. if !ok {
  44081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44082. }
  44083. m.SetOwner(v)
  44084. return nil
  44085. case wpchatroom.FieldAvatar:
  44086. v, ok := value.(string)
  44087. if !ok {
  44088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44089. }
  44090. m.SetAvatar(v)
  44091. return nil
  44092. case wpchatroom.FieldMemberList:
  44093. v, ok := value.([]string)
  44094. if !ok {
  44095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44096. }
  44097. m.SetMemberList(v)
  44098. return nil
  44099. }
  44100. return fmt.Errorf("unknown WpChatroom field %s", name)
  44101. }
  44102. // AddedFields returns all numeric fields that were incremented/decremented during
  44103. // this mutation.
  44104. func (m *WpChatroomMutation) AddedFields() []string {
  44105. var fields []string
  44106. if m.addstatus != nil {
  44107. fields = append(fields, wpchatroom.FieldStatus)
  44108. }
  44109. return fields
  44110. }
  44111. // AddedField returns the numeric value that was incremented/decremented on a field
  44112. // with the given name. The second boolean return value indicates that this field
  44113. // was not set, or was not defined in the schema.
  44114. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  44115. switch name {
  44116. case wpchatroom.FieldStatus:
  44117. return m.AddedStatus()
  44118. }
  44119. return nil, false
  44120. }
  44121. // AddField adds the value to the field with the given name. It returns an error if
  44122. // the field is not defined in the schema, or if the type mismatched the field
  44123. // type.
  44124. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  44125. switch name {
  44126. case wpchatroom.FieldStatus:
  44127. v, ok := value.(int8)
  44128. if !ok {
  44129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44130. }
  44131. m.AddStatus(v)
  44132. return nil
  44133. }
  44134. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  44135. }
  44136. // ClearedFields returns all nullable fields that were cleared during this
  44137. // mutation.
  44138. func (m *WpChatroomMutation) ClearedFields() []string {
  44139. var fields []string
  44140. if m.FieldCleared(wpchatroom.FieldStatus) {
  44141. fields = append(fields, wpchatroom.FieldStatus)
  44142. }
  44143. return fields
  44144. }
  44145. // FieldCleared returns a boolean indicating if a field with the given name was
  44146. // cleared in this mutation.
  44147. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  44148. _, ok := m.clearedFields[name]
  44149. return ok
  44150. }
  44151. // ClearField clears the value of the field with the given name. It returns an
  44152. // error if the field is not defined in the schema.
  44153. func (m *WpChatroomMutation) ClearField(name string) error {
  44154. switch name {
  44155. case wpchatroom.FieldStatus:
  44156. m.ClearStatus()
  44157. return nil
  44158. }
  44159. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  44160. }
  44161. // ResetField resets all changes in the mutation for the field with the given name.
  44162. // It returns an error if the field is not defined in the schema.
  44163. func (m *WpChatroomMutation) ResetField(name string) error {
  44164. switch name {
  44165. case wpchatroom.FieldCreatedAt:
  44166. m.ResetCreatedAt()
  44167. return nil
  44168. case wpchatroom.FieldUpdatedAt:
  44169. m.ResetUpdatedAt()
  44170. return nil
  44171. case wpchatroom.FieldStatus:
  44172. m.ResetStatus()
  44173. return nil
  44174. case wpchatroom.FieldWxWxid:
  44175. m.ResetWxWxid()
  44176. return nil
  44177. case wpchatroom.FieldChatroomID:
  44178. m.ResetChatroomID()
  44179. return nil
  44180. case wpchatroom.FieldNickname:
  44181. m.ResetNickname()
  44182. return nil
  44183. case wpchatroom.FieldOwner:
  44184. m.ResetOwner()
  44185. return nil
  44186. case wpchatroom.FieldAvatar:
  44187. m.ResetAvatar()
  44188. return nil
  44189. case wpchatroom.FieldMemberList:
  44190. m.ResetMemberList()
  44191. return nil
  44192. }
  44193. return fmt.Errorf("unknown WpChatroom field %s", name)
  44194. }
  44195. // AddedEdges returns all edge names that were set/added in this mutation.
  44196. func (m *WpChatroomMutation) AddedEdges() []string {
  44197. edges := make([]string, 0, 0)
  44198. return edges
  44199. }
  44200. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  44201. // name in this mutation.
  44202. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  44203. return nil
  44204. }
  44205. // RemovedEdges returns all edge names that were removed in this mutation.
  44206. func (m *WpChatroomMutation) RemovedEdges() []string {
  44207. edges := make([]string, 0, 0)
  44208. return edges
  44209. }
  44210. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  44211. // the given name in this mutation.
  44212. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  44213. return nil
  44214. }
  44215. // ClearedEdges returns all edge names that were cleared in this mutation.
  44216. func (m *WpChatroomMutation) ClearedEdges() []string {
  44217. edges := make([]string, 0, 0)
  44218. return edges
  44219. }
  44220. // EdgeCleared returns a boolean which indicates if the edge with the given name
  44221. // was cleared in this mutation.
  44222. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  44223. return false
  44224. }
  44225. // ClearEdge clears the value of the edge with the given name. It returns an error
  44226. // if that edge is not defined in the schema.
  44227. func (m *WpChatroomMutation) ClearEdge(name string) error {
  44228. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  44229. }
  44230. // ResetEdge resets all changes to the edge with the given name in this mutation.
  44231. // It returns an error if the edge is not defined in the schema.
  44232. func (m *WpChatroomMutation) ResetEdge(name string) error {
  44233. return fmt.Errorf("unknown WpChatroom edge %s", name)
  44234. }
  44235. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  44236. type WpChatroomMemberMutation struct {
  44237. config
  44238. op Op
  44239. typ string
  44240. id *uint64
  44241. created_at *time.Time
  44242. updated_at *time.Time
  44243. status *uint8
  44244. addstatus *int8
  44245. wx_wxid *string
  44246. wxid *string
  44247. nickname *string
  44248. avatar *string
  44249. clearedFields map[string]struct{}
  44250. done bool
  44251. oldValue func(context.Context) (*WpChatroomMember, error)
  44252. predicates []predicate.WpChatroomMember
  44253. }
  44254. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  44255. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  44256. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  44257. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  44258. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  44259. m := &WpChatroomMemberMutation{
  44260. config: c,
  44261. op: op,
  44262. typ: TypeWpChatroomMember,
  44263. clearedFields: make(map[string]struct{}),
  44264. }
  44265. for _, opt := range opts {
  44266. opt(m)
  44267. }
  44268. return m
  44269. }
  44270. // withWpChatroomMemberID sets the ID field of the mutation.
  44271. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  44272. return func(m *WpChatroomMemberMutation) {
  44273. var (
  44274. err error
  44275. once sync.Once
  44276. value *WpChatroomMember
  44277. )
  44278. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  44279. once.Do(func() {
  44280. if m.done {
  44281. err = errors.New("querying old values post mutation is not allowed")
  44282. } else {
  44283. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  44284. }
  44285. })
  44286. return value, err
  44287. }
  44288. m.id = &id
  44289. }
  44290. }
  44291. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  44292. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  44293. return func(m *WpChatroomMemberMutation) {
  44294. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  44295. return node, nil
  44296. }
  44297. m.id = &node.ID
  44298. }
  44299. }
  44300. // Client returns a new `ent.Client` from the mutation. If the mutation was
  44301. // executed in a transaction (ent.Tx), a transactional client is returned.
  44302. func (m WpChatroomMemberMutation) Client() *Client {
  44303. client := &Client{config: m.config}
  44304. client.init()
  44305. return client
  44306. }
  44307. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  44308. // it returns an error otherwise.
  44309. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  44310. if _, ok := m.driver.(*txDriver); !ok {
  44311. return nil, errors.New("ent: mutation is not running in a transaction")
  44312. }
  44313. tx := &Tx{config: m.config}
  44314. tx.init()
  44315. return tx, nil
  44316. }
  44317. // SetID sets the value of the id field. Note that this
  44318. // operation is only accepted on creation of WpChatroomMember entities.
  44319. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  44320. m.id = &id
  44321. }
  44322. // ID returns the ID value in the mutation. Note that the ID is only available
  44323. // if it was provided to the builder or after it was returned from the database.
  44324. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  44325. if m.id == nil {
  44326. return
  44327. }
  44328. return *m.id, true
  44329. }
  44330. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  44331. // That means, if the mutation is applied within a transaction with an isolation level such
  44332. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  44333. // or updated by the mutation.
  44334. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  44335. switch {
  44336. case m.op.Is(OpUpdateOne | OpDeleteOne):
  44337. id, exists := m.ID()
  44338. if exists {
  44339. return []uint64{id}, nil
  44340. }
  44341. fallthrough
  44342. case m.op.Is(OpUpdate | OpDelete):
  44343. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  44344. default:
  44345. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  44346. }
  44347. }
  44348. // SetCreatedAt sets the "created_at" field.
  44349. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  44350. m.created_at = &t
  44351. }
  44352. // CreatedAt returns the value of the "created_at" field in the mutation.
  44353. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  44354. v := m.created_at
  44355. if v == nil {
  44356. return
  44357. }
  44358. return *v, true
  44359. }
  44360. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  44361. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  44362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44363. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  44364. if !m.op.Is(OpUpdateOne) {
  44365. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  44366. }
  44367. if m.id == nil || m.oldValue == nil {
  44368. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  44369. }
  44370. oldValue, err := m.oldValue(ctx)
  44371. if err != nil {
  44372. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  44373. }
  44374. return oldValue.CreatedAt, nil
  44375. }
  44376. // ResetCreatedAt resets all changes to the "created_at" field.
  44377. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  44378. m.created_at = nil
  44379. }
  44380. // SetUpdatedAt sets the "updated_at" field.
  44381. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  44382. m.updated_at = &t
  44383. }
  44384. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  44385. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  44386. v := m.updated_at
  44387. if v == nil {
  44388. return
  44389. }
  44390. return *v, true
  44391. }
  44392. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  44393. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  44394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44395. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  44396. if !m.op.Is(OpUpdateOne) {
  44397. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  44398. }
  44399. if m.id == nil || m.oldValue == nil {
  44400. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  44401. }
  44402. oldValue, err := m.oldValue(ctx)
  44403. if err != nil {
  44404. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  44405. }
  44406. return oldValue.UpdatedAt, nil
  44407. }
  44408. // ResetUpdatedAt resets all changes to the "updated_at" field.
  44409. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  44410. m.updated_at = nil
  44411. }
  44412. // SetStatus sets the "status" field.
  44413. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  44414. m.status = &u
  44415. m.addstatus = nil
  44416. }
  44417. // Status returns the value of the "status" field in the mutation.
  44418. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  44419. v := m.status
  44420. if v == nil {
  44421. return
  44422. }
  44423. return *v, true
  44424. }
  44425. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  44426. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  44427. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44428. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  44429. if !m.op.Is(OpUpdateOne) {
  44430. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  44431. }
  44432. if m.id == nil || m.oldValue == nil {
  44433. return v, errors.New("OldStatus requires an ID field in the mutation")
  44434. }
  44435. oldValue, err := m.oldValue(ctx)
  44436. if err != nil {
  44437. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  44438. }
  44439. return oldValue.Status, nil
  44440. }
  44441. // AddStatus adds u to the "status" field.
  44442. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  44443. if m.addstatus != nil {
  44444. *m.addstatus += u
  44445. } else {
  44446. m.addstatus = &u
  44447. }
  44448. }
  44449. // AddedStatus returns the value that was added to the "status" field in this mutation.
  44450. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  44451. v := m.addstatus
  44452. if v == nil {
  44453. return
  44454. }
  44455. return *v, true
  44456. }
  44457. // ClearStatus clears the value of the "status" field.
  44458. func (m *WpChatroomMemberMutation) ClearStatus() {
  44459. m.status = nil
  44460. m.addstatus = nil
  44461. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  44462. }
  44463. // StatusCleared returns if the "status" field was cleared in this mutation.
  44464. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  44465. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  44466. return ok
  44467. }
  44468. // ResetStatus resets all changes to the "status" field.
  44469. func (m *WpChatroomMemberMutation) ResetStatus() {
  44470. m.status = nil
  44471. m.addstatus = nil
  44472. delete(m.clearedFields, wpchatroommember.FieldStatus)
  44473. }
  44474. // SetWxWxid sets the "wx_wxid" field.
  44475. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  44476. m.wx_wxid = &s
  44477. }
  44478. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  44479. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  44480. v := m.wx_wxid
  44481. if v == nil {
  44482. return
  44483. }
  44484. return *v, true
  44485. }
  44486. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  44487. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  44488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44489. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  44490. if !m.op.Is(OpUpdateOne) {
  44491. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  44492. }
  44493. if m.id == nil || m.oldValue == nil {
  44494. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  44495. }
  44496. oldValue, err := m.oldValue(ctx)
  44497. if err != nil {
  44498. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  44499. }
  44500. return oldValue.WxWxid, nil
  44501. }
  44502. // ResetWxWxid resets all changes to the "wx_wxid" field.
  44503. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  44504. m.wx_wxid = nil
  44505. }
  44506. // SetWxid sets the "wxid" field.
  44507. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  44508. m.wxid = &s
  44509. }
  44510. // Wxid returns the value of the "wxid" field in the mutation.
  44511. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  44512. v := m.wxid
  44513. if v == nil {
  44514. return
  44515. }
  44516. return *v, true
  44517. }
  44518. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  44519. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  44520. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44521. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  44522. if !m.op.Is(OpUpdateOne) {
  44523. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  44524. }
  44525. if m.id == nil || m.oldValue == nil {
  44526. return v, errors.New("OldWxid requires an ID field in the mutation")
  44527. }
  44528. oldValue, err := m.oldValue(ctx)
  44529. if err != nil {
  44530. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  44531. }
  44532. return oldValue.Wxid, nil
  44533. }
  44534. // ResetWxid resets all changes to the "wxid" field.
  44535. func (m *WpChatroomMemberMutation) ResetWxid() {
  44536. m.wxid = nil
  44537. }
  44538. // SetNickname sets the "nickname" field.
  44539. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  44540. m.nickname = &s
  44541. }
  44542. // Nickname returns the value of the "nickname" field in the mutation.
  44543. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  44544. v := m.nickname
  44545. if v == nil {
  44546. return
  44547. }
  44548. return *v, true
  44549. }
  44550. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  44551. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  44552. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44553. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  44554. if !m.op.Is(OpUpdateOne) {
  44555. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  44556. }
  44557. if m.id == nil || m.oldValue == nil {
  44558. return v, errors.New("OldNickname requires an ID field in the mutation")
  44559. }
  44560. oldValue, err := m.oldValue(ctx)
  44561. if err != nil {
  44562. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  44563. }
  44564. return oldValue.Nickname, nil
  44565. }
  44566. // ResetNickname resets all changes to the "nickname" field.
  44567. func (m *WpChatroomMemberMutation) ResetNickname() {
  44568. m.nickname = nil
  44569. }
  44570. // SetAvatar sets the "avatar" field.
  44571. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  44572. m.avatar = &s
  44573. }
  44574. // Avatar returns the value of the "avatar" field in the mutation.
  44575. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  44576. v := m.avatar
  44577. if v == nil {
  44578. return
  44579. }
  44580. return *v, true
  44581. }
  44582. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  44583. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  44584. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44585. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  44586. if !m.op.Is(OpUpdateOne) {
  44587. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  44588. }
  44589. if m.id == nil || m.oldValue == nil {
  44590. return v, errors.New("OldAvatar requires an ID field in the mutation")
  44591. }
  44592. oldValue, err := m.oldValue(ctx)
  44593. if err != nil {
  44594. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  44595. }
  44596. return oldValue.Avatar, nil
  44597. }
  44598. // ResetAvatar resets all changes to the "avatar" field.
  44599. func (m *WpChatroomMemberMutation) ResetAvatar() {
  44600. m.avatar = nil
  44601. }
  44602. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  44603. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  44604. m.predicates = append(m.predicates, ps...)
  44605. }
  44606. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  44607. // users can use type-assertion to append predicates that do not depend on any generated package.
  44608. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  44609. p := make([]predicate.WpChatroomMember, len(ps))
  44610. for i := range ps {
  44611. p[i] = ps[i]
  44612. }
  44613. m.Where(p...)
  44614. }
  44615. // Op returns the operation name.
  44616. func (m *WpChatroomMemberMutation) Op() Op {
  44617. return m.op
  44618. }
  44619. // SetOp allows setting the mutation operation.
  44620. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  44621. m.op = op
  44622. }
  44623. // Type returns the node type of this mutation (WpChatroomMember).
  44624. func (m *WpChatroomMemberMutation) Type() string {
  44625. return m.typ
  44626. }
  44627. // Fields returns all fields that were changed during this mutation. Note that in
  44628. // order to get all numeric fields that were incremented/decremented, call
  44629. // AddedFields().
  44630. func (m *WpChatroomMemberMutation) Fields() []string {
  44631. fields := make([]string, 0, 7)
  44632. if m.created_at != nil {
  44633. fields = append(fields, wpchatroommember.FieldCreatedAt)
  44634. }
  44635. if m.updated_at != nil {
  44636. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  44637. }
  44638. if m.status != nil {
  44639. fields = append(fields, wpchatroommember.FieldStatus)
  44640. }
  44641. if m.wx_wxid != nil {
  44642. fields = append(fields, wpchatroommember.FieldWxWxid)
  44643. }
  44644. if m.wxid != nil {
  44645. fields = append(fields, wpchatroommember.FieldWxid)
  44646. }
  44647. if m.nickname != nil {
  44648. fields = append(fields, wpchatroommember.FieldNickname)
  44649. }
  44650. if m.avatar != nil {
  44651. fields = append(fields, wpchatroommember.FieldAvatar)
  44652. }
  44653. return fields
  44654. }
  44655. // Field returns the value of a field with the given name. The second boolean
  44656. // return value indicates that this field was not set, or was not defined in the
  44657. // schema.
  44658. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  44659. switch name {
  44660. case wpchatroommember.FieldCreatedAt:
  44661. return m.CreatedAt()
  44662. case wpchatroommember.FieldUpdatedAt:
  44663. return m.UpdatedAt()
  44664. case wpchatroommember.FieldStatus:
  44665. return m.Status()
  44666. case wpchatroommember.FieldWxWxid:
  44667. return m.WxWxid()
  44668. case wpchatroommember.FieldWxid:
  44669. return m.Wxid()
  44670. case wpchatroommember.FieldNickname:
  44671. return m.Nickname()
  44672. case wpchatroommember.FieldAvatar:
  44673. return m.Avatar()
  44674. }
  44675. return nil, false
  44676. }
  44677. // OldField returns the old value of the field from the database. An error is
  44678. // returned if the mutation operation is not UpdateOne, or the query to the
  44679. // database failed.
  44680. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  44681. switch name {
  44682. case wpchatroommember.FieldCreatedAt:
  44683. return m.OldCreatedAt(ctx)
  44684. case wpchatroommember.FieldUpdatedAt:
  44685. return m.OldUpdatedAt(ctx)
  44686. case wpchatroommember.FieldStatus:
  44687. return m.OldStatus(ctx)
  44688. case wpchatroommember.FieldWxWxid:
  44689. return m.OldWxWxid(ctx)
  44690. case wpchatroommember.FieldWxid:
  44691. return m.OldWxid(ctx)
  44692. case wpchatroommember.FieldNickname:
  44693. return m.OldNickname(ctx)
  44694. case wpchatroommember.FieldAvatar:
  44695. return m.OldAvatar(ctx)
  44696. }
  44697. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  44698. }
  44699. // SetField sets the value of a field with the given name. It returns an error if
  44700. // the field is not defined in the schema, or if the type mismatched the field
  44701. // type.
  44702. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  44703. switch name {
  44704. case wpchatroommember.FieldCreatedAt:
  44705. v, ok := value.(time.Time)
  44706. if !ok {
  44707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44708. }
  44709. m.SetCreatedAt(v)
  44710. return nil
  44711. case wpchatroommember.FieldUpdatedAt:
  44712. v, ok := value.(time.Time)
  44713. if !ok {
  44714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44715. }
  44716. m.SetUpdatedAt(v)
  44717. return nil
  44718. case wpchatroommember.FieldStatus:
  44719. v, ok := value.(uint8)
  44720. if !ok {
  44721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44722. }
  44723. m.SetStatus(v)
  44724. return nil
  44725. case wpchatroommember.FieldWxWxid:
  44726. v, ok := value.(string)
  44727. if !ok {
  44728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44729. }
  44730. m.SetWxWxid(v)
  44731. return nil
  44732. case wpchatroommember.FieldWxid:
  44733. v, ok := value.(string)
  44734. if !ok {
  44735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44736. }
  44737. m.SetWxid(v)
  44738. return nil
  44739. case wpchatroommember.FieldNickname:
  44740. v, ok := value.(string)
  44741. if !ok {
  44742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44743. }
  44744. m.SetNickname(v)
  44745. return nil
  44746. case wpchatroommember.FieldAvatar:
  44747. v, ok := value.(string)
  44748. if !ok {
  44749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44750. }
  44751. m.SetAvatar(v)
  44752. return nil
  44753. }
  44754. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  44755. }
  44756. // AddedFields returns all numeric fields that were incremented/decremented during
  44757. // this mutation.
  44758. func (m *WpChatroomMemberMutation) AddedFields() []string {
  44759. var fields []string
  44760. if m.addstatus != nil {
  44761. fields = append(fields, wpchatroommember.FieldStatus)
  44762. }
  44763. return fields
  44764. }
  44765. // AddedField returns the numeric value that was incremented/decremented on a field
  44766. // with the given name. The second boolean return value indicates that this field
  44767. // was not set, or was not defined in the schema.
  44768. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  44769. switch name {
  44770. case wpchatroommember.FieldStatus:
  44771. return m.AddedStatus()
  44772. }
  44773. return nil, false
  44774. }
  44775. // AddField adds the value to the field with the given name. It returns an error if
  44776. // the field is not defined in the schema, or if the type mismatched the field
  44777. // type.
  44778. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  44779. switch name {
  44780. case wpchatroommember.FieldStatus:
  44781. v, ok := value.(int8)
  44782. if !ok {
  44783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44784. }
  44785. m.AddStatus(v)
  44786. return nil
  44787. }
  44788. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  44789. }
  44790. // ClearedFields returns all nullable fields that were cleared during this
  44791. // mutation.
  44792. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  44793. var fields []string
  44794. if m.FieldCleared(wpchatroommember.FieldStatus) {
  44795. fields = append(fields, wpchatroommember.FieldStatus)
  44796. }
  44797. return fields
  44798. }
  44799. // FieldCleared returns a boolean indicating if a field with the given name was
  44800. // cleared in this mutation.
  44801. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  44802. _, ok := m.clearedFields[name]
  44803. return ok
  44804. }
  44805. // ClearField clears the value of the field with the given name. It returns an
  44806. // error if the field is not defined in the schema.
  44807. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  44808. switch name {
  44809. case wpchatroommember.FieldStatus:
  44810. m.ClearStatus()
  44811. return nil
  44812. }
  44813. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  44814. }
  44815. // ResetField resets all changes in the mutation for the field with the given name.
  44816. // It returns an error if the field is not defined in the schema.
  44817. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  44818. switch name {
  44819. case wpchatroommember.FieldCreatedAt:
  44820. m.ResetCreatedAt()
  44821. return nil
  44822. case wpchatroommember.FieldUpdatedAt:
  44823. m.ResetUpdatedAt()
  44824. return nil
  44825. case wpchatroommember.FieldStatus:
  44826. m.ResetStatus()
  44827. return nil
  44828. case wpchatroommember.FieldWxWxid:
  44829. m.ResetWxWxid()
  44830. return nil
  44831. case wpchatroommember.FieldWxid:
  44832. m.ResetWxid()
  44833. return nil
  44834. case wpchatroommember.FieldNickname:
  44835. m.ResetNickname()
  44836. return nil
  44837. case wpchatroommember.FieldAvatar:
  44838. m.ResetAvatar()
  44839. return nil
  44840. }
  44841. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  44842. }
  44843. // AddedEdges returns all edge names that were set/added in this mutation.
  44844. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  44845. edges := make([]string, 0, 0)
  44846. return edges
  44847. }
  44848. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  44849. // name in this mutation.
  44850. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  44851. return nil
  44852. }
  44853. // RemovedEdges returns all edge names that were removed in this mutation.
  44854. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  44855. edges := make([]string, 0, 0)
  44856. return edges
  44857. }
  44858. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  44859. // the given name in this mutation.
  44860. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  44861. return nil
  44862. }
  44863. // ClearedEdges returns all edge names that were cleared in this mutation.
  44864. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  44865. edges := make([]string, 0, 0)
  44866. return edges
  44867. }
  44868. // EdgeCleared returns a boolean which indicates if the edge with the given name
  44869. // was cleared in this mutation.
  44870. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  44871. return false
  44872. }
  44873. // ClearEdge clears the value of the edge with the given name. It returns an error
  44874. // if that edge is not defined in the schema.
  44875. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  44876. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  44877. }
  44878. // ResetEdge resets all changes to the edge with the given name in this mutation.
  44879. // It returns an error if the edge is not defined in the schema.
  44880. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  44881. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  44882. }
  44883. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  44884. type WxMutation struct {
  44885. config
  44886. op Op
  44887. typ string
  44888. id *uint64
  44889. created_at *time.Time
  44890. updated_at *time.Time
  44891. status *uint8
  44892. addstatus *int8
  44893. deleted_at *time.Time
  44894. port *string
  44895. process_id *string
  44896. callback *string
  44897. wxid *string
  44898. account *string
  44899. nickname *string
  44900. tel *string
  44901. head_big *string
  44902. organization_id *uint64
  44903. addorganization_id *int64
  44904. api_base *string
  44905. api_key *string
  44906. allow_list *[]string
  44907. appendallow_list []string
  44908. group_allow_list *[]string
  44909. appendgroup_allow_list []string
  44910. block_list *[]string
  44911. appendblock_list []string
  44912. group_block_list *[]string
  44913. appendgroup_block_list []string
  44914. ctype *uint64
  44915. addctype *int64
  44916. clearedFields map[string]struct{}
  44917. server *uint64
  44918. clearedserver bool
  44919. agent *uint64
  44920. clearedagent bool
  44921. done bool
  44922. oldValue func(context.Context) (*Wx, error)
  44923. predicates []predicate.Wx
  44924. }
  44925. var _ ent.Mutation = (*WxMutation)(nil)
  44926. // wxOption allows management of the mutation configuration using functional options.
  44927. type wxOption func(*WxMutation)
  44928. // newWxMutation creates new mutation for the Wx entity.
  44929. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  44930. m := &WxMutation{
  44931. config: c,
  44932. op: op,
  44933. typ: TypeWx,
  44934. clearedFields: make(map[string]struct{}),
  44935. }
  44936. for _, opt := range opts {
  44937. opt(m)
  44938. }
  44939. return m
  44940. }
  44941. // withWxID sets the ID field of the mutation.
  44942. func withWxID(id uint64) wxOption {
  44943. return func(m *WxMutation) {
  44944. var (
  44945. err error
  44946. once sync.Once
  44947. value *Wx
  44948. )
  44949. m.oldValue = func(ctx context.Context) (*Wx, error) {
  44950. once.Do(func() {
  44951. if m.done {
  44952. err = errors.New("querying old values post mutation is not allowed")
  44953. } else {
  44954. value, err = m.Client().Wx.Get(ctx, id)
  44955. }
  44956. })
  44957. return value, err
  44958. }
  44959. m.id = &id
  44960. }
  44961. }
  44962. // withWx sets the old Wx of the mutation.
  44963. func withWx(node *Wx) wxOption {
  44964. return func(m *WxMutation) {
  44965. m.oldValue = func(context.Context) (*Wx, error) {
  44966. return node, nil
  44967. }
  44968. m.id = &node.ID
  44969. }
  44970. }
  44971. // Client returns a new `ent.Client` from the mutation. If the mutation was
  44972. // executed in a transaction (ent.Tx), a transactional client is returned.
  44973. func (m WxMutation) Client() *Client {
  44974. client := &Client{config: m.config}
  44975. client.init()
  44976. return client
  44977. }
  44978. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  44979. // it returns an error otherwise.
  44980. func (m WxMutation) Tx() (*Tx, error) {
  44981. if _, ok := m.driver.(*txDriver); !ok {
  44982. return nil, errors.New("ent: mutation is not running in a transaction")
  44983. }
  44984. tx := &Tx{config: m.config}
  44985. tx.init()
  44986. return tx, nil
  44987. }
  44988. // SetID sets the value of the id field. Note that this
  44989. // operation is only accepted on creation of Wx entities.
  44990. func (m *WxMutation) SetID(id uint64) {
  44991. m.id = &id
  44992. }
  44993. // ID returns the ID value in the mutation. Note that the ID is only available
  44994. // if it was provided to the builder or after it was returned from the database.
  44995. func (m *WxMutation) ID() (id uint64, exists bool) {
  44996. if m.id == nil {
  44997. return
  44998. }
  44999. return *m.id, true
  45000. }
  45001. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  45002. // That means, if the mutation is applied within a transaction with an isolation level such
  45003. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  45004. // or updated by the mutation.
  45005. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  45006. switch {
  45007. case m.op.Is(OpUpdateOne | OpDeleteOne):
  45008. id, exists := m.ID()
  45009. if exists {
  45010. return []uint64{id}, nil
  45011. }
  45012. fallthrough
  45013. case m.op.Is(OpUpdate | OpDelete):
  45014. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  45015. default:
  45016. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  45017. }
  45018. }
  45019. // SetCreatedAt sets the "created_at" field.
  45020. func (m *WxMutation) SetCreatedAt(t time.Time) {
  45021. m.created_at = &t
  45022. }
  45023. // CreatedAt returns the value of the "created_at" field in the mutation.
  45024. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  45025. v := m.created_at
  45026. if v == nil {
  45027. return
  45028. }
  45029. return *v, true
  45030. }
  45031. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  45032. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45033. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45034. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  45035. if !m.op.Is(OpUpdateOne) {
  45036. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  45037. }
  45038. if m.id == nil || m.oldValue == nil {
  45039. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  45040. }
  45041. oldValue, err := m.oldValue(ctx)
  45042. if err != nil {
  45043. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  45044. }
  45045. return oldValue.CreatedAt, nil
  45046. }
  45047. // ResetCreatedAt resets all changes to the "created_at" field.
  45048. func (m *WxMutation) ResetCreatedAt() {
  45049. m.created_at = nil
  45050. }
  45051. // SetUpdatedAt sets the "updated_at" field.
  45052. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  45053. m.updated_at = &t
  45054. }
  45055. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  45056. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  45057. v := m.updated_at
  45058. if v == nil {
  45059. return
  45060. }
  45061. return *v, true
  45062. }
  45063. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  45064. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45065. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45066. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  45067. if !m.op.Is(OpUpdateOne) {
  45068. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  45069. }
  45070. if m.id == nil || m.oldValue == nil {
  45071. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  45072. }
  45073. oldValue, err := m.oldValue(ctx)
  45074. if err != nil {
  45075. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  45076. }
  45077. return oldValue.UpdatedAt, nil
  45078. }
  45079. // ResetUpdatedAt resets all changes to the "updated_at" field.
  45080. func (m *WxMutation) ResetUpdatedAt() {
  45081. m.updated_at = nil
  45082. }
  45083. // SetStatus sets the "status" field.
  45084. func (m *WxMutation) SetStatus(u uint8) {
  45085. m.status = &u
  45086. m.addstatus = nil
  45087. }
  45088. // Status returns the value of the "status" field in the mutation.
  45089. func (m *WxMutation) Status() (r uint8, exists bool) {
  45090. v := m.status
  45091. if v == nil {
  45092. return
  45093. }
  45094. return *v, true
  45095. }
  45096. // OldStatus returns the old "status" field's value of the Wx entity.
  45097. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45098. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45099. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  45100. if !m.op.Is(OpUpdateOne) {
  45101. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  45102. }
  45103. if m.id == nil || m.oldValue == nil {
  45104. return v, errors.New("OldStatus requires an ID field in the mutation")
  45105. }
  45106. oldValue, err := m.oldValue(ctx)
  45107. if err != nil {
  45108. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  45109. }
  45110. return oldValue.Status, nil
  45111. }
  45112. // AddStatus adds u to the "status" field.
  45113. func (m *WxMutation) AddStatus(u int8) {
  45114. if m.addstatus != nil {
  45115. *m.addstatus += u
  45116. } else {
  45117. m.addstatus = &u
  45118. }
  45119. }
  45120. // AddedStatus returns the value that was added to the "status" field in this mutation.
  45121. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  45122. v := m.addstatus
  45123. if v == nil {
  45124. return
  45125. }
  45126. return *v, true
  45127. }
  45128. // ClearStatus clears the value of the "status" field.
  45129. func (m *WxMutation) ClearStatus() {
  45130. m.status = nil
  45131. m.addstatus = nil
  45132. m.clearedFields[wx.FieldStatus] = struct{}{}
  45133. }
  45134. // StatusCleared returns if the "status" field was cleared in this mutation.
  45135. func (m *WxMutation) StatusCleared() bool {
  45136. _, ok := m.clearedFields[wx.FieldStatus]
  45137. return ok
  45138. }
  45139. // ResetStatus resets all changes to the "status" field.
  45140. func (m *WxMutation) ResetStatus() {
  45141. m.status = nil
  45142. m.addstatus = nil
  45143. delete(m.clearedFields, wx.FieldStatus)
  45144. }
  45145. // SetDeletedAt sets the "deleted_at" field.
  45146. func (m *WxMutation) SetDeletedAt(t time.Time) {
  45147. m.deleted_at = &t
  45148. }
  45149. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  45150. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  45151. v := m.deleted_at
  45152. if v == nil {
  45153. return
  45154. }
  45155. return *v, true
  45156. }
  45157. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  45158. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45159. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45160. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  45161. if !m.op.Is(OpUpdateOne) {
  45162. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  45163. }
  45164. if m.id == nil || m.oldValue == nil {
  45165. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  45166. }
  45167. oldValue, err := m.oldValue(ctx)
  45168. if err != nil {
  45169. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  45170. }
  45171. return oldValue.DeletedAt, nil
  45172. }
  45173. // ClearDeletedAt clears the value of the "deleted_at" field.
  45174. func (m *WxMutation) ClearDeletedAt() {
  45175. m.deleted_at = nil
  45176. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  45177. }
  45178. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  45179. func (m *WxMutation) DeletedAtCleared() bool {
  45180. _, ok := m.clearedFields[wx.FieldDeletedAt]
  45181. return ok
  45182. }
  45183. // ResetDeletedAt resets all changes to the "deleted_at" field.
  45184. func (m *WxMutation) ResetDeletedAt() {
  45185. m.deleted_at = nil
  45186. delete(m.clearedFields, wx.FieldDeletedAt)
  45187. }
  45188. // SetServerID sets the "server_id" field.
  45189. func (m *WxMutation) SetServerID(u uint64) {
  45190. m.server = &u
  45191. }
  45192. // ServerID returns the value of the "server_id" field in the mutation.
  45193. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  45194. v := m.server
  45195. if v == nil {
  45196. return
  45197. }
  45198. return *v, true
  45199. }
  45200. // OldServerID returns the old "server_id" field's value of the Wx entity.
  45201. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45202. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45203. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  45204. if !m.op.Is(OpUpdateOne) {
  45205. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  45206. }
  45207. if m.id == nil || m.oldValue == nil {
  45208. return v, errors.New("OldServerID requires an ID field in the mutation")
  45209. }
  45210. oldValue, err := m.oldValue(ctx)
  45211. if err != nil {
  45212. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  45213. }
  45214. return oldValue.ServerID, nil
  45215. }
  45216. // ClearServerID clears the value of the "server_id" field.
  45217. func (m *WxMutation) ClearServerID() {
  45218. m.server = nil
  45219. m.clearedFields[wx.FieldServerID] = struct{}{}
  45220. }
  45221. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  45222. func (m *WxMutation) ServerIDCleared() bool {
  45223. _, ok := m.clearedFields[wx.FieldServerID]
  45224. return ok
  45225. }
  45226. // ResetServerID resets all changes to the "server_id" field.
  45227. func (m *WxMutation) ResetServerID() {
  45228. m.server = nil
  45229. delete(m.clearedFields, wx.FieldServerID)
  45230. }
  45231. // SetPort sets the "port" field.
  45232. func (m *WxMutation) SetPort(s string) {
  45233. m.port = &s
  45234. }
  45235. // Port returns the value of the "port" field in the mutation.
  45236. func (m *WxMutation) Port() (r string, exists bool) {
  45237. v := m.port
  45238. if v == nil {
  45239. return
  45240. }
  45241. return *v, true
  45242. }
  45243. // OldPort returns the old "port" field's value of the Wx entity.
  45244. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45245. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45246. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  45247. if !m.op.Is(OpUpdateOne) {
  45248. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  45249. }
  45250. if m.id == nil || m.oldValue == nil {
  45251. return v, errors.New("OldPort requires an ID field in the mutation")
  45252. }
  45253. oldValue, err := m.oldValue(ctx)
  45254. if err != nil {
  45255. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  45256. }
  45257. return oldValue.Port, nil
  45258. }
  45259. // ResetPort resets all changes to the "port" field.
  45260. func (m *WxMutation) ResetPort() {
  45261. m.port = nil
  45262. }
  45263. // SetProcessID sets the "process_id" field.
  45264. func (m *WxMutation) SetProcessID(s string) {
  45265. m.process_id = &s
  45266. }
  45267. // ProcessID returns the value of the "process_id" field in the mutation.
  45268. func (m *WxMutation) ProcessID() (r string, exists bool) {
  45269. v := m.process_id
  45270. if v == nil {
  45271. return
  45272. }
  45273. return *v, true
  45274. }
  45275. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  45276. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45277. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45278. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  45279. if !m.op.Is(OpUpdateOne) {
  45280. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  45281. }
  45282. if m.id == nil || m.oldValue == nil {
  45283. return v, errors.New("OldProcessID requires an ID field in the mutation")
  45284. }
  45285. oldValue, err := m.oldValue(ctx)
  45286. if err != nil {
  45287. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  45288. }
  45289. return oldValue.ProcessID, nil
  45290. }
  45291. // ResetProcessID resets all changes to the "process_id" field.
  45292. func (m *WxMutation) ResetProcessID() {
  45293. m.process_id = nil
  45294. }
  45295. // SetCallback sets the "callback" field.
  45296. func (m *WxMutation) SetCallback(s string) {
  45297. m.callback = &s
  45298. }
  45299. // Callback returns the value of the "callback" field in the mutation.
  45300. func (m *WxMutation) Callback() (r string, exists bool) {
  45301. v := m.callback
  45302. if v == nil {
  45303. return
  45304. }
  45305. return *v, true
  45306. }
  45307. // OldCallback returns the old "callback" field's value of the Wx entity.
  45308. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45309. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45310. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  45311. if !m.op.Is(OpUpdateOne) {
  45312. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  45313. }
  45314. if m.id == nil || m.oldValue == nil {
  45315. return v, errors.New("OldCallback requires an ID field in the mutation")
  45316. }
  45317. oldValue, err := m.oldValue(ctx)
  45318. if err != nil {
  45319. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  45320. }
  45321. return oldValue.Callback, nil
  45322. }
  45323. // ResetCallback resets all changes to the "callback" field.
  45324. func (m *WxMutation) ResetCallback() {
  45325. m.callback = nil
  45326. }
  45327. // SetWxid sets the "wxid" field.
  45328. func (m *WxMutation) SetWxid(s string) {
  45329. m.wxid = &s
  45330. }
  45331. // Wxid returns the value of the "wxid" field in the mutation.
  45332. func (m *WxMutation) Wxid() (r string, exists bool) {
  45333. v := m.wxid
  45334. if v == nil {
  45335. return
  45336. }
  45337. return *v, true
  45338. }
  45339. // OldWxid returns the old "wxid" field's value of the Wx entity.
  45340. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45341. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45342. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  45343. if !m.op.Is(OpUpdateOne) {
  45344. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  45345. }
  45346. if m.id == nil || m.oldValue == nil {
  45347. return v, errors.New("OldWxid requires an ID field in the mutation")
  45348. }
  45349. oldValue, err := m.oldValue(ctx)
  45350. if err != nil {
  45351. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  45352. }
  45353. return oldValue.Wxid, nil
  45354. }
  45355. // ResetWxid resets all changes to the "wxid" field.
  45356. func (m *WxMutation) ResetWxid() {
  45357. m.wxid = nil
  45358. }
  45359. // SetAccount sets the "account" field.
  45360. func (m *WxMutation) SetAccount(s string) {
  45361. m.account = &s
  45362. }
  45363. // Account returns the value of the "account" field in the mutation.
  45364. func (m *WxMutation) Account() (r string, exists bool) {
  45365. v := m.account
  45366. if v == nil {
  45367. return
  45368. }
  45369. return *v, true
  45370. }
  45371. // OldAccount returns the old "account" field's value of the Wx entity.
  45372. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45373. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45374. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  45375. if !m.op.Is(OpUpdateOne) {
  45376. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  45377. }
  45378. if m.id == nil || m.oldValue == nil {
  45379. return v, errors.New("OldAccount requires an ID field in the mutation")
  45380. }
  45381. oldValue, err := m.oldValue(ctx)
  45382. if err != nil {
  45383. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  45384. }
  45385. return oldValue.Account, nil
  45386. }
  45387. // ResetAccount resets all changes to the "account" field.
  45388. func (m *WxMutation) ResetAccount() {
  45389. m.account = nil
  45390. }
  45391. // SetNickname sets the "nickname" field.
  45392. func (m *WxMutation) SetNickname(s string) {
  45393. m.nickname = &s
  45394. }
  45395. // Nickname returns the value of the "nickname" field in the mutation.
  45396. func (m *WxMutation) Nickname() (r string, exists bool) {
  45397. v := m.nickname
  45398. if v == nil {
  45399. return
  45400. }
  45401. return *v, true
  45402. }
  45403. // OldNickname returns the old "nickname" field's value of the Wx entity.
  45404. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45405. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45406. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  45407. if !m.op.Is(OpUpdateOne) {
  45408. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  45409. }
  45410. if m.id == nil || m.oldValue == nil {
  45411. return v, errors.New("OldNickname requires an ID field in the mutation")
  45412. }
  45413. oldValue, err := m.oldValue(ctx)
  45414. if err != nil {
  45415. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  45416. }
  45417. return oldValue.Nickname, nil
  45418. }
  45419. // ResetNickname resets all changes to the "nickname" field.
  45420. func (m *WxMutation) ResetNickname() {
  45421. m.nickname = nil
  45422. }
  45423. // SetTel sets the "tel" field.
  45424. func (m *WxMutation) SetTel(s string) {
  45425. m.tel = &s
  45426. }
  45427. // Tel returns the value of the "tel" field in the mutation.
  45428. func (m *WxMutation) Tel() (r string, exists bool) {
  45429. v := m.tel
  45430. if v == nil {
  45431. return
  45432. }
  45433. return *v, true
  45434. }
  45435. // OldTel returns the old "tel" field's value of the Wx entity.
  45436. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45437. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45438. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  45439. if !m.op.Is(OpUpdateOne) {
  45440. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  45441. }
  45442. if m.id == nil || m.oldValue == nil {
  45443. return v, errors.New("OldTel requires an ID field in the mutation")
  45444. }
  45445. oldValue, err := m.oldValue(ctx)
  45446. if err != nil {
  45447. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  45448. }
  45449. return oldValue.Tel, nil
  45450. }
  45451. // ResetTel resets all changes to the "tel" field.
  45452. func (m *WxMutation) ResetTel() {
  45453. m.tel = nil
  45454. }
  45455. // SetHeadBig sets the "head_big" field.
  45456. func (m *WxMutation) SetHeadBig(s string) {
  45457. m.head_big = &s
  45458. }
  45459. // HeadBig returns the value of the "head_big" field in the mutation.
  45460. func (m *WxMutation) HeadBig() (r string, exists bool) {
  45461. v := m.head_big
  45462. if v == nil {
  45463. return
  45464. }
  45465. return *v, true
  45466. }
  45467. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  45468. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45469. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45470. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  45471. if !m.op.Is(OpUpdateOne) {
  45472. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  45473. }
  45474. if m.id == nil || m.oldValue == nil {
  45475. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  45476. }
  45477. oldValue, err := m.oldValue(ctx)
  45478. if err != nil {
  45479. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  45480. }
  45481. return oldValue.HeadBig, nil
  45482. }
  45483. // ResetHeadBig resets all changes to the "head_big" field.
  45484. func (m *WxMutation) ResetHeadBig() {
  45485. m.head_big = nil
  45486. }
  45487. // SetOrganizationID sets the "organization_id" field.
  45488. func (m *WxMutation) SetOrganizationID(u uint64) {
  45489. m.organization_id = &u
  45490. m.addorganization_id = nil
  45491. }
  45492. // OrganizationID returns the value of the "organization_id" field in the mutation.
  45493. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  45494. v := m.organization_id
  45495. if v == nil {
  45496. return
  45497. }
  45498. return *v, true
  45499. }
  45500. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  45501. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45502. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45503. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  45504. if !m.op.Is(OpUpdateOne) {
  45505. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  45506. }
  45507. if m.id == nil || m.oldValue == nil {
  45508. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  45509. }
  45510. oldValue, err := m.oldValue(ctx)
  45511. if err != nil {
  45512. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  45513. }
  45514. return oldValue.OrganizationID, nil
  45515. }
  45516. // AddOrganizationID adds u to the "organization_id" field.
  45517. func (m *WxMutation) AddOrganizationID(u int64) {
  45518. if m.addorganization_id != nil {
  45519. *m.addorganization_id += u
  45520. } else {
  45521. m.addorganization_id = &u
  45522. }
  45523. }
  45524. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  45525. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  45526. v := m.addorganization_id
  45527. if v == nil {
  45528. return
  45529. }
  45530. return *v, true
  45531. }
  45532. // ClearOrganizationID clears the value of the "organization_id" field.
  45533. func (m *WxMutation) ClearOrganizationID() {
  45534. m.organization_id = nil
  45535. m.addorganization_id = nil
  45536. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  45537. }
  45538. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  45539. func (m *WxMutation) OrganizationIDCleared() bool {
  45540. _, ok := m.clearedFields[wx.FieldOrganizationID]
  45541. return ok
  45542. }
  45543. // ResetOrganizationID resets all changes to the "organization_id" field.
  45544. func (m *WxMutation) ResetOrganizationID() {
  45545. m.organization_id = nil
  45546. m.addorganization_id = nil
  45547. delete(m.clearedFields, wx.FieldOrganizationID)
  45548. }
  45549. // SetAgentID sets the "agent_id" field.
  45550. func (m *WxMutation) SetAgentID(u uint64) {
  45551. m.agent = &u
  45552. }
  45553. // AgentID returns the value of the "agent_id" field in the mutation.
  45554. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  45555. v := m.agent
  45556. if v == nil {
  45557. return
  45558. }
  45559. return *v, true
  45560. }
  45561. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  45562. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45563. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45564. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  45565. if !m.op.Is(OpUpdateOne) {
  45566. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  45567. }
  45568. if m.id == nil || m.oldValue == nil {
  45569. return v, errors.New("OldAgentID requires an ID field in the mutation")
  45570. }
  45571. oldValue, err := m.oldValue(ctx)
  45572. if err != nil {
  45573. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  45574. }
  45575. return oldValue.AgentID, nil
  45576. }
  45577. // ResetAgentID resets all changes to the "agent_id" field.
  45578. func (m *WxMutation) ResetAgentID() {
  45579. m.agent = nil
  45580. }
  45581. // SetAPIBase sets the "api_base" field.
  45582. func (m *WxMutation) SetAPIBase(s string) {
  45583. m.api_base = &s
  45584. }
  45585. // APIBase returns the value of the "api_base" field in the mutation.
  45586. func (m *WxMutation) APIBase() (r string, exists bool) {
  45587. v := m.api_base
  45588. if v == nil {
  45589. return
  45590. }
  45591. return *v, true
  45592. }
  45593. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  45594. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45595. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45596. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  45597. if !m.op.Is(OpUpdateOne) {
  45598. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  45599. }
  45600. if m.id == nil || m.oldValue == nil {
  45601. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  45602. }
  45603. oldValue, err := m.oldValue(ctx)
  45604. if err != nil {
  45605. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  45606. }
  45607. return oldValue.APIBase, nil
  45608. }
  45609. // ClearAPIBase clears the value of the "api_base" field.
  45610. func (m *WxMutation) ClearAPIBase() {
  45611. m.api_base = nil
  45612. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  45613. }
  45614. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  45615. func (m *WxMutation) APIBaseCleared() bool {
  45616. _, ok := m.clearedFields[wx.FieldAPIBase]
  45617. return ok
  45618. }
  45619. // ResetAPIBase resets all changes to the "api_base" field.
  45620. func (m *WxMutation) ResetAPIBase() {
  45621. m.api_base = nil
  45622. delete(m.clearedFields, wx.FieldAPIBase)
  45623. }
  45624. // SetAPIKey sets the "api_key" field.
  45625. func (m *WxMutation) SetAPIKey(s string) {
  45626. m.api_key = &s
  45627. }
  45628. // APIKey returns the value of the "api_key" field in the mutation.
  45629. func (m *WxMutation) APIKey() (r string, exists bool) {
  45630. v := m.api_key
  45631. if v == nil {
  45632. return
  45633. }
  45634. return *v, true
  45635. }
  45636. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  45637. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45638. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45639. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  45640. if !m.op.Is(OpUpdateOne) {
  45641. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  45642. }
  45643. if m.id == nil || m.oldValue == nil {
  45644. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  45645. }
  45646. oldValue, err := m.oldValue(ctx)
  45647. if err != nil {
  45648. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  45649. }
  45650. return oldValue.APIKey, nil
  45651. }
  45652. // ClearAPIKey clears the value of the "api_key" field.
  45653. func (m *WxMutation) ClearAPIKey() {
  45654. m.api_key = nil
  45655. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  45656. }
  45657. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  45658. func (m *WxMutation) APIKeyCleared() bool {
  45659. _, ok := m.clearedFields[wx.FieldAPIKey]
  45660. return ok
  45661. }
  45662. // ResetAPIKey resets all changes to the "api_key" field.
  45663. func (m *WxMutation) ResetAPIKey() {
  45664. m.api_key = nil
  45665. delete(m.clearedFields, wx.FieldAPIKey)
  45666. }
  45667. // SetAllowList sets the "allow_list" field.
  45668. func (m *WxMutation) SetAllowList(s []string) {
  45669. m.allow_list = &s
  45670. m.appendallow_list = nil
  45671. }
  45672. // AllowList returns the value of the "allow_list" field in the mutation.
  45673. func (m *WxMutation) AllowList() (r []string, exists bool) {
  45674. v := m.allow_list
  45675. if v == nil {
  45676. return
  45677. }
  45678. return *v, true
  45679. }
  45680. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  45681. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45682. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45683. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  45684. if !m.op.Is(OpUpdateOne) {
  45685. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  45686. }
  45687. if m.id == nil || m.oldValue == nil {
  45688. return v, errors.New("OldAllowList requires an ID field in the mutation")
  45689. }
  45690. oldValue, err := m.oldValue(ctx)
  45691. if err != nil {
  45692. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  45693. }
  45694. return oldValue.AllowList, nil
  45695. }
  45696. // AppendAllowList adds s to the "allow_list" field.
  45697. func (m *WxMutation) AppendAllowList(s []string) {
  45698. m.appendallow_list = append(m.appendallow_list, s...)
  45699. }
  45700. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  45701. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  45702. if len(m.appendallow_list) == 0 {
  45703. return nil, false
  45704. }
  45705. return m.appendallow_list, true
  45706. }
  45707. // ResetAllowList resets all changes to the "allow_list" field.
  45708. func (m *WxMutation) ResetAllowList() {
  45709. m.allow_list = nil
  45710. m.appendallow_list = nil
  45711. }
  45712. // SetGroupAllowList sets the "group_allow_list" field.
  45713. func (m *WxMutation) SetGroupAllowList(s []string) {
  45714. m.group_allow_list = &s
  45715. m.appendgroup_allow_list = nil
  45716. }
  45717. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  45718. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  45719. v := m.group_allow_list
  45720. if v == nil {
  45721. return
  45722. }
  45723. return *v, true
  45724. }
  45725. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  45726. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45727. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45728. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  45729. if !m.op.Is(OpUpdateOne) {
  45730. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  45731. }
  45732. if m.id == nil || m.oldValue == nil {
  45733. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  45734. }
  45735. oldValue, err := m.oldValue(ctx)
  45736. if err != nil {
  45737. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  45738. }
  45739. return oldValue.GroupAllowList, nil
  45740. }
  45741. // AppendGroupAllowList adds s to the "group_allow_list" field.
  45742. func (m *WxMutation) AppendGroupAllowList(s []string) {
  45743. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  45744. }
  45745. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  45746. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  45747. if len(m.appendgroup_allow_list) == 0 {
  45748. return nil, false
  45749. }
  45750. return m.appendgroup_allow_list, true
  45751. }
  45752. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  45753. func (m *WxMutation) ResetGroupAllowList() {
  45754. m.group_allow_list = nil
  45755. m.appendgroup_allow_list = nil
  45756. }
  45757. // SetBlockList sets the "block_list" field.
  45758. func (m *WxMutation) SetBlockList(s []string) {
  45759. m.block_list = &s
  45760. m.appendblock_list = nil
  45761. }
  45762. // BlockList returns the value of the "block_list" field in the mutation.
  45763. func (m *WxMutation) BlockList() (r []string, exists bool) {
  45764. v := m.block_list
  45765. if v == nil {
  45766. return
  45767. }
  45768. return *v, true
  45769. }
  45770. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  45771. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45772. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45773. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  45774. if !m.op.Is(OpUpdateOne) {
  45775. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  45776. }
  45777. if m.id == nil || m.oldValue == nil {
  45778. return v, errors.New("OldBlockList requires an ID field in the mutation")
  45779. }
  45780. oldValue, err := m.oldValue(ctx)
  45781. if err != nil {
  45782. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  45783. }
  45784. return oldValue.BlockList, nil
  45785. }
  45786. // AppendBlockList adds s to the "block_list" field.
  45787. func (m *WxMutation) AppendBlockList(s []string) {
  45788. m.appendblock_list = append(m.appendblock_list, s...)
  45789. }
  45790. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  45791. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  45792. if len(m.appendblock_list) == 0 {
  45793. return nil, false
  45794. }
  45795. return m.appendblock_list, true
  45796. }
  45797. // ResetBlockList resets all changes to the "block_list" field.
  45798. func (m *WxMutation) ResetBlockList() {
  45799. m.block_list = nil
  45800. m.appendblock_list = nil
  45801. }
  45802. // SetGroupBlockList sets the "group_block_list" field.
  45803. func (m *WxMutation) SetGroupBlockList(s []string) {
  45804. m.group_block_list = &s
  45805. m.appendgroup_block_list = nil
  45806. }
  45807. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  45808. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  45809. v := m.group_block_list
  45810. if v == nil {
  45811. return
  45812. }
  45813. return *v, true
  45814. }
  45815. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  45816. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45817. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45818. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  45819. if !m.op.Is(OpUpdateOne) {
  45820. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  45821. }
  45822. if m.id == nil || m.oldValue == nil {
  45823. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  45824. }
  45825. oldValue, err := m.oldValue(ctx)
  45826. if err != nil {
  45827. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  45828. }
  45829. return oldValue.GroupBlockList, nil
  45830. }
  45831. // AppendGroupBlockList adds s to the "group_block_list" field.
  45832. func (m *WxMutation) AppendGroupBlockList(s []string) {
  45833. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  45834. }
  45835. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  45836. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  45837. if len(m.appendgroup_block_list) == 0 {
  45838. return nil, false
  45839. }
  45840. return m.appendgroup_block_list, true
  45841. }
  45842. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  45843. func (m *WxMutation) ResetGroupBlockList() {
  45844. m.group_block_list = nil
  45845. m.appendgroup_block_list = nil
  45846. }
  45847. // SetCtype sets the "ctype" field.
  45848. func (m *WxMutation) SetCtype(u uint64) {
  45849. m.ctype = &u
  45850. m.addctype = nil
  45851. }
  45852. // Ctype returns the value of the "ctype" field in the mutation.
  45853. func (m *WxMutation) Ctype() (r uint64, exists bool) {
  45854. v := m.ctype
  45855. if v == nil {
  45856. return
  45857. }
  45858. return *v, true
  45859. }
  45860. // OldCtype returns the old "ctype" field's value of the Wx entity.
  45861. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45862. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45863. func (m *WxMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  45864. if !m.op.Is(OpUpdateOne) {
  45865. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  45866. }
  45867. if m.id == nil || m.oldValue == nil {
  45868. return v, errors.New("OldCtype requires an ID field in the mutation")
  45869. }
  45870. oldValue, err := m.oldValue(ctx)
  45871. if err != nil {
  45872. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  45873. }
  45874. return oldValue.Ctype, nil
  45875. }
  45876. // AddCtype adds u to the "ctype" field.
  45877. func (m *WxMutation) AddCtype(u int64) {
  45878. if m.addctype != nil {
  45879. *m.addctype += u
  45880. } else {
  45881. m.addctype = &u
  45882. }
  45883. }
  45884. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  45885. func (m *WxMutation) AddedCtype() (r int64, exists bool) {
  45886. v := m.addctype
  45887. if v == nil {
  45888. return
  45889. }
  45890. return *v, true
  45891. }
  45892. // ClearCtype clears the value of the "ctype" field.
  45893. func (m *WxMutation) ClearCtype() {
  45894. m.ctype = nil
  45895. m.addctype = nil
  45896. m.clearedFields[wx.FieldCtype] = struct{}{}
  45897. }
  45898. // CtypeCleared returns if the "ctype" field was cleared in this mutation.
  45899. func (m *WxMutation) CtypeCleared() bool {
  45900. _, ok := m.clearedFields[wx.FieldCtype]
  45901. return ok
  45902. }
  45903. // ResetCtype resets all changes to the "ctype" field.
  45904. func (m *WxMutation) ResetCtype() {
  45905. m.ctype = nil
  45906. m.addctype = nil
  45907. delete(m.clearedFields, wx.FieldCtype)
  45908. }
  45909. // ClearServer clears the "server" edge to the Server entity.
  45910. func (m *WxMutation) ClearServer() {
  45911. m.clearedserver = true
  45912. m.clearedFields[wx.FieldServerID] = struct{}{}
  45913. }
  45914. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  45915. func (m *WxMutation) ServerCleared() bool {
  45916. return m.ServerIDCleared() || m.clearedserver
  45917. }
  45918. // ServerIDs returns the "server" edge IDs in the mutation.
  45919. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  45920. // ServerID instead. It exists only for internal usage by the builders.
  45921. func (m *WxMutation) ServerIDs() (ids []uint64) {
  45922. if id := m.server; id != nil {
  45923. ids = append(ids, *id)
  45924. }
  45925. return
  45926. }
  45927. // ResetServer resets all changes to the "server" edge.
  45928. func (m *WxMutation) ResetServer() {
  45929. m.server = nil
  45930. m.clearedserver = false
  45931. }
  45932. // ClearAgent clears the "agent" edge to the Agent entity.
  45933. func (m *WxMutation) ClearAgent() {
  45934. m.clearedagent = true
  45935. m.clearedFields[wx.FieldAgentID] = struct{}{}
  45936. }
  45937. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  45938. func (m *WxMutation) AgentCleared() bool {
  45939. return m.clearedagent
  45940. }
  45941. // AgentIDs returns the "agent" edge IDs in the mutation.
  45942. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  45943. // AgentID instead. It exists only for internal usage by the builders.
  45944. func (m *WxMutation) AgentIDs() (ids []uint64) {
  45945. if id := m.agent; id != nil {
  45946. ids = append(ids, *id)
  45947. }
  45948. return
  45949. }
  45950. // ResetAgent resets all changes to the "agent" edge.
  45951. func (m *WxMutation) ResetAgent() {
  45952. m.agent = nil
  45953. m.clearedagent = false
  45954. }
  45955. // Where appends a list predicates to the WxMutation builder.
  45956. func (m *WxMutation) Where(ps ...predicate.Wx) {
  45957. m.predicates = append(m.predicates, ps...)
  45958. }
  45959. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  45960. // users can use type-assertion to append predicates that do not depend on any generated package.
  45961. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  45962. p := make([]predicate.Wx, len(ps))
  45963. for i := range ps {
  45964. p[i] = ps[i]
  45965. }
  45966. m.Where(p...)
  45967. }
  45968. // Op returns the operation name.
  45969. func (m *WxMutation) Op() Op {
  45970. return m.op
  45971. }
  45972. // SetOp allows setting the mutation operation.
  45973. func (m *WxMutation) SetOp(op Op) {
  45974. m.op = op
  45975. }
  45976. // Type returns the node type of this mutation (Wx).
  45977. func (m *WxMutation) Type() string {
  45978. return m.typ
  45979. }
  45980. // Fields returns all fields that were changed during this mutation. Note that in
  45981. // order to get all numeric fields that were incremented/decremented, call
  45982. // AddedFields().
  45983. func (m *WxMutation) Fields() []string {
  45984. fields := make([]string, 0, 22)
  45985. if m.created_at != nil {
  45986. fields = append(fields, wx.FieldCreatedAt)
  45987. }
  45988. if m.updated_at != nil {
  45989. fields = append(fields, wx.FieldUpdatedAt)
  45990. }
  45991. if m.status != nil {
  45992. fields = append(fields, wx.FieldStatus)
  45993. }
  45994. if m.deleted_at != nil {
  45995. fields = append(fields, wx.FieldDeletedAt)
  45996. }
  45997. if m.server != nil {
  45998. fields = append(fields, wx.FieldServerID)
  45999. }
  46000. if m.port != nil {
  46001. fields = append(fields, wx.FieldPort)
  46002. }
  46003. if m.process_id != nil {
  46004. fields = append(fields, wx.FieldProcessID)
  46005. }
  46006. if m.callback != nil {
  46007. fields = append(fields, wx.FieldCallback)
  46008. }
  46009. if m.wxid != nil {
  46010. fields = append(fields, wx.FieldWxid)
  46011. }
  46012. if m.account != nil {
  46013. fields = append(fields, wx.FieldAccount)
  46014. }
  46015. if m.nickname != nil {
  46016. fields = append(fields, wx.FieldNickname)
  46017. }
  46018. if m.tel != nil {
  46019. fields = append(fields, wx.FieldTel)
  46020. }
  46021. if m.head_big != nil {
  46022. fields = append(fields, wx.FieldHeadBig)
  46023. }
  46024. if m.organization_id != nil {
  46025. fields = append(fields, wx.FieldOrganizationID)
  46026. }
  46027. if m.agent != nil {
  46028. fields = append(fields, wx.FieldAgentID)
  46029. }
  46030. if m.api_base != nil {
  46031. fields = append(fields, wx.FieldAPIBase)
  46032. }
  46033. if m.api_key != nil {
  46034. fields = append(fields, wx.FieldAPIKey)
  46035. }
  46036. if m.allow_list != nil {
  46037. fields = append(fields, wx.FieldAllowList)
  46038. }
  46039. if m.group_allow_list != nil {
  46040. fields = append(fields, wx.FieldGroupAllowList)
  46041. }
  46042. if m.block_list != nil {
  46043. fields = append(fields, wx.FieldBlockList)
  46044. }
  46045. if m.group_block_list != nil {
  46046. fields = append(fields, wx.FieldGroupBlockList)
  46047. }
  46048. if m.ctype != nil {
  46049. fields = append(fields, wx.FieldCtype)
  46050. }
  46051. return fields
  46052. }
  46053. // Field returns the value of a field with the given name. The second boolean
  46054. // return value indicates that this field was not set, or was not defined in the
  46055. // schema.
  46056. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  46057. switch name {
  46058. case wx.FieldCreatedAt:
  46059. return m.CreatedAt()
  46060. case wx.FieldUpdatedAt:
  46061. return m.UpdatedAt()
  46062. case wx.FieldStatus:
  46063. return m.Status()
  46064. case wx.FieldDeletedAt:
  46065. return m.DeletedAt()
  46066. case wx.FieldServerID:
  46067. return m.ServerID()
  46068. case wx.FieldPort:
  46069. return m.Port()
  46070. case wx.FieldProcessID:
  46071. return m.ProcessID()
  46072. case wx.FieldCallback:
  46073. return m.Callback()
  46074. case wx.FieldWxid:
  46075. return m.Wxid()
  46076. case wx.FieldAccount:
  46077. return m.Account()
  46078. case wx.FieldNickname:
  46079. return m.Nickname()
  46080. case wx.FieldTel:
  46081. return m.Tel()
  46082. case wx.FieldHeadBig:
  46083. return m.HeadBig()
  46084. case wx.FieldOrganizationID:
  46085. return m.OrganizationID()
  46086. case wx.FieldAgentID:
  46087. return m.AgentID()
  46088. case wx.FieldAPIBase:
  46089. return m.APIBase()
  46090. case wx.FieldAPIKey:
  46091. return m.APIKey()
  46092. case wx.FieldAllowList:
  46093. return m.AllowList()
  46094. case wx.FieldGroupAllowList:
  46095. return m.GroupAllowList()
  46096. case wx.FieldBlockList:
  46097. return m.BlockList()
  46098. case wx.FieldGroupBlockList:
  46099. return m.GroupBlockList()
  46100. case wx.FieldCtype:
  46101. return m.Ctype()
  46102. }
  46103. return nil, false
  46104. }
  46105. // OldField returns the old value of the field from the database. An error is
  46106. // returned if the mutation operation is not UpdateOne, or the query to the
  46107. // database failed.
  46108. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  46109. switch name {
  46110. case wx.FieldCreatedAt:
  46111. return m.OldCreatedAt(ctx)
  46112. case wx.FieldUpdatedAt:
  46113. return m.OldUpdatedAt(ctx)
  46114. case wx.FieldStatus:
  46115. return m.OldStatus(ctx)
  46116. case wx.FieldDeletedAt:
  46117. return m.OldDeletedAt(ctx)
  46118. case wx.FieldServerID:
  46119. return m.OldServerID(ctx)
  46120. case wx.FieldPort:
  46121. return m.OldPort(ctx)
  46122. case wx.FieldProcessID:
  46123. return m.OldProcessID(ctx)
  46124. case wx.FieldCallback:
  46125. return m.OldCallback(ctx)
  46126. case wx.FieldWxid:
  46127. return m.OldWxid(ctx)
  46128. case wx.FieldAccount:
  46129. return m.OldAccount(ctx)
  46130. case wx.FieldNickname:
  46131. return m.OldNickname(ctx)
  46132. case wx.FieldTel:
  46133. return m.OldTel(ctx)
  46134. case wx.FieldHeadBig:
  46135. return m.OldHeadBig(ctx)
  46136. case wx.FieldOrganizationID:
  46137. return m.OldOrganizationID(ctx)
  46138. case wx.FieldAgentID:
  46139. return m.OldAgentID(ctx)
  46140. case wx.FieldAPIBase:
  46141. return m.OldAPIBase(ctx)
  46142. case wx.FieldAPIKey:
  46143. return m.OldAPIKey(ctx)
  46144. case wx.FieldAllowList:
  46145. return m.OldAllowList(ctx)
  46146. case wx.FieldGroupAllowList:
  46147. return m.OldGroupAllowList(ctx)
  46148. case wx.FieldBlockList:
  46149. return m.OldBlockList(ctx)
  46150. case wx.FieldGroupBlockList:
  46151. return m.OldGroupBlockList(ctx)
  46152. case wx.FieldCtype:
  46153. return m.OldCtype(ctx)
  46154. }
  46155. return nil, fmt.Errorf("unknown Wx field %s", name)
  46156. }
  46157. // SetField sets the value of a field with the given name. It returns an error if
  46158. // the field is not defined in the schema, or if the type mismatched the field
  46159. // type.
  46160. func (m *WxMutation) SetField(name string, value ent.Value) error {
  46161. switch name {
  46162. case wx.FieldCreatedAt:
  46163. v, ok := value.(time.Time)
  46164. if !ok {
  46165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46166. }
  46167. m.SetCreatedAt(v)
  46168. return nil
  46169. case wx.FieldUpdatedAt:
  46170. v, ok := value.(time.Time)
  46171. if !ok {
  46172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46173. }
  46174. m.SetUpdatedAt(v)
  46175. return nil
  46176. case wx.FieldStatus:
  46177. v, ok := value.(uint8)
  46178. if !ok {
  46179. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46180. }
  46181. m.SetStatus(v)
  46182. return nil
  46183. case wx.FieldDeletedAt:
  46184. v, ok := value.(time.Time)
  46185. if !ok {
  46186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46187. }
  46188. m.SetDeletedAt(v)
  46189. return nil
  46190. case wx.FieldServerID:
  46191. v, ok := value.(uint64)
  46192. if !ok {
  46193. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46194. }
  46195. m.SetServerID(v)
  46196. return nil
  46197. case wx.FieldPort:
  46198. v, ok := value.(string)
  46199. if !ok {
  46200. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46201. }
  46202. m.SetPort(v)
  46203. return nil
  46204. case wx.FieldProcessID:
  46205. v, ok := value.(string)
  46206. if !ok {
  46207. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46208. }
  46209. m.SetProcessID(v)
  46210. return nil
  46211. case wx.FieldCallback:
  46212. v, ok := value.(string)
  46213. if !ok {
  46214. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46215. }
  46216. m.SetCallback(v)
  46217. return nil
  46218. case wx.FieldWxid:
  46219. v, ok := value.(string)
  46220. if !ok {
  46221. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46222. }
  46223. m.SetWxid(v)
  46224. return nil
  46225. case wx.FieldAccount:
  46226. v, ok := value.(string)
  46227. if !ok {
  46228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46229. }
  46230. m.SetAccount(v)
  46231. return nil
  46232. case wx.FieldNickname:
  46233. v, ok := value.(string)
  46234. if !ok {
  46235. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46236. }
  46237. m.SetNickname(v)
  46238. return nil
  46239. case wx.FieldTel:
  46240. v, ok := value.(string)
  46241. if !ok {
  46242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46243. }
  46244. m.SetTel(v)
  46245. return nil
  46246. case wx.FieldHeadBig:
  46247. v, ok := value.(string)
  46248. if !ok {
  46249. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46250. }
  46251. m.SetHeadBig(v)
  46252. return nil
  46253. case wx.FieldOrganizationID:
  46254. v, ok := value.(uint64)
  46255. if !ok {
  46256. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46257. }
  46258. m.SetOrganizationID(v)
  46259. return nil
  46260. case wx.FieldAgentID:
  46261. v, ok := value.(uint64)
  46262. if !ok {
  46263. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46264. }
  46265. m.SetAgentID(v)
  46266. return nil
  46267. case wx.FieldAPIBase:
  46268. v, ok := value.(string)
  46269. if !ok {
  46270. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46271. }
  46272. m.SetAPIBase(v)
  46273. return nil
  46274. case wx.FieldAPIKey:
  46275. v, ok := value.(string)
  46276. if !ok {
  46277. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46278. }
  46279. m.SetAPIKey(v)
  46280. return nil
  46281. case wx.FieldAllowList:
  46282. v, ok := value.([]string)
  46283. if !ok {
  46284. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46285. }
  46286. m.SetAllowList(v)
  46287. return nil
  46288. case wx.FieldGroupAllowList:
  46289. v, ok := value.([]string)
  46290. if !ok {
  46291. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46292. }
  46293. m.SetGroupAllowList(v)
  46294. return nil
  46295. case wx.FieldBlockList:
  46296. v, ok := value.([]string)
  46297. if !ok {
  46298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46299. }
  46300. m.SetBlockList(v)
  46301. return nil
  46302. case wx.FieldGroupBlockList:
  46303. v, ok := value.([]string)
  46304. if !ok {
  46305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46306. }
  46307. m.SetGroupBlockList(v)
  46308. return nil
  46309. case wx.FieldCtype:
  46310. v, ok := value.(uint64)
  46311. if !ok {
  46312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46313. }
  46314. m.SetCtype(v)
  46315. return nil
  46316. }
  46317. return fmt.Errorf("unknown Wx field %s", name)
  46318. }
  46319. // AddedFields returns all numeric fields that were incremented/decremented during
  46320. // this mutation.
  46321. func (m *WxMutation) AddedFields() []string {
  46322. var fields []string
  46323. if m.addstatus != nil {
  46324. fields = append(fields, wx.FieldStatus)
  46325. }
  46326. if m.addorganization_id != nil {
  46327. fields = append(fields, wx.FieldOrganizationID)
  46328. }
  46329. if m.addctype != nil {
  46330. fields = append(fields, wx.FieldCtype)
  46331. }
  46332. return fields
  46333. }
  46334. // AddedField returns the numeric value that was incremented/decremented on a field
  46335. // with the given name. The second boolean return value indicates that this field
  46336. // was not set, or was not defined in the schema.
  46337. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  46338. switch name {
  46339. case wx.FieldStatus:
  46340. return m.AddedStatus()
  46341. case wx.FieldOrganizationID:
  46342. return m.AddedOrganizationID()
  46343. case wx.FieldCtype:
  46344. return m.AddedCtype()
  46345. }
  46346. return nil, false
  46347. }
  46348. // AddField adds the value to the field with the given name. It returns an error if
  46349. // the field is not defined in the schema, or if the type mismatched the field
  46350. // type.
  46351. func (m *WxMutation) AddField(name string, value ent.Value) error {
  46352. switch name {
  46353. case wx.FieldStatus:
  46354. v, ok := value.(int8)
  46355. if !ok {
  46356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46357. }
  46358. m.AddStatus(v)
  46359. return nil
  46360. case wx.FieldOrganizationID:
  46361. v, ok := value.(int64)
  46362. if !ok {
  46363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46364. }
  46365. m.AddOrganizationID(v)
  46366. return nil
  46367. case wx.FieldCtype:
  46368. v, ok := value.(int64)
  46369. if !ok {
  46370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46371. }
  46372. m.AddCtype(v)
  46373. return nil
  46374. }
  46375. return fmt.Errorf("unknown Wx numeric field %s", name)
  46376. }
  46377. // ClearedFields returns all nullable fields that were cleared during this
  46378. // mutation.
  46379. func (m *WxMutation) ClearedFields() []string {
  46380. var fields []string
  46381. if m.FieldCleared(wx.FieldStatus) {
  46382. fields = append(fields, wx.FieldStatus)
  46383. }
  46384. if m.FieldCleared(wx.FieldDeletedAt) {
  46385. fields = append(fields, wx.FieldDeletedAt)
  46386. }
  46387. if m.FieldCleared(wx.FieldServerID) {
  46388. fields = append(fields, wx.FieldServerID)
  46389. }
  46390. if m.FieldCleared(wx.FieldOrganizationID) {
  46391. fields = append(fields, wx.FieldOrganizationID)
  46392. }
  46393. if m.FieldCleared(wx.FieldAPIBase) {
  46394. fields = append(fields, wx.FieldAPIBase)
  46395. }
  46396. if m.FieldCleared(wx.FieldAPIKey) {
  46397. fields = append(fields, wx.FieldAPIKey)
  46398. }
  46399. if m.FieldCleared(wx.FieldCtype) {
  46400. fields = append(fields, wx.FieldCtype)
  46401. }
  46402. return fields
  46403. }
  46404. // FieldCleared returns a boolean indicating if a field with the given name was
  46405. // cleared in this mutation.
  46406. func (m *WxMutation) FieldCleared(name string) bool {
  46407. _, ok := m.clearedFields[name]
  46408. return ok
  46409. }
  46410. // ClearField clears the value of the field with the given name. It returns an
  46411. // error if the field is not defined in the schema.
  46412. func (m *WxMutation) ClearField(name string) error {
  46413. switch name {
  46414. case wx.FieldStatus:
  46415. m.ClearStatus()
  46416. return nil
  46417. case wx.FieldDeletedAt:
  46418. m.ClearDeletedAt()
  46419. return nil
  46420. case wx.FieldServerID:
  46421. m.ClearServerID()
  46422. return nil
  46423. case wx.FieldOrganizationID:
  46424. m.ClearOrganizationID()
  46425. return nil
  46426. case wx.FieldAPIBase:
  46427. m.ClearAPIBase()
  46428. return nil
  46429. case wx.FieldAPIKey:
  46430. m.ClearAPIKey()
  46431. return nil
  46432. case wx.FieldCtype:
  46433. m.ClearCtype()
  46434. return nil
  46435. }
  46436. return fmt.Errorf("unknown Wx nullable field %s", name)
  46437. }
  46438. // ResetField resets all changes in the mutation for the field with the given name.
  46439. // It returns an error if the field is not defined in the schema.
  46440. func (m *WxMutation) ResetField(name string) error {
  46441. switch name {
  46442. case wx.FieldCreatedAt:
  46443. m.ResetCreatedAt()
  46444. return nil
  46445. case wx.FieldUpdatedAt:
  46446. m.ResetUpdatedAt()
  46447. return nil
  46448. case wx.FieldStatus:
  46449. m.ResetStatus()
  46450. return nil
  46451. case wx.FieldDeletedAt:
  46452. m.ResetDeletedAt()
  46453. return nil
  46454. case wx.FieldServerID:
  46455. m.ResetServerID()
  46456. return nil
  46457. case wx.FieldPort:
  46458. m.ResetPort()
  46459. return nil
  46460. case wx.FieldProcessID:
  46461. m.ResetProcessID()
  46462. return nil
  46463. case wx.FieldCallback:
  46464. m.ResetCallback()
  46465. return nil
  46466. case wx.FieldWxid:
  46467. m.ResetWxid()
  46468. return nil
  46469. case wx.FieldAccount:
  46470. m.ResetAccount()
  46471. return nil
  46472. case wx.FieldNickname:
  46473. m.ResetNickname()
  46474. return nil
  46475. case wx.FieldTel:
  46476. m.ResetTel()
  46477. return nil
  46478. case wx.FieldHeadBig:
  46479. m.ResetHeadBig()
  46480. return nil
  46481. case wx.FieldOrganizationID:
  46482. m.ResetOrganizationID()
  46483. return nil
  46484. case wx.FieldAgentID:
  46485. m.ResetAgentID()
  46486. return nil
  46487. case wx.FieldAPIBase:
  46488. m.ResetAPIBase()
  46489. return nil
  46490. case wx.FieldAPIKey:
  46491. m.ResetAPIKey()
  46492. return nil
  46493. case wx.FieldAllowList:
  46494. m.ResetAllowList()
  46495. return nil
  46496. case wx.FieldGroupAllowList:
  46497. m.ResetGroupAllowList()
  46498. return nil
  46499. case wx.FieldBlockList:
  46500. m.ResetBlockList()
  46501. return nil
  46502. case wx.FieldGroupBlockList:
  46503. m.ResetGroupBlockList()
  46504. return nil
  46505. case wx.FieldCtype:
  46506. m.ResetCtype()
  46507. return nil
  46508. }
  46509. return fmt.Errorf("unknown Wx field %s", name)
  46510. }
  46511. // AddedEdges returns all edge names that were set/added in this mutation.
  46512. func (m *WxMutation) AddedEdges() []string {
  46513. edges := make([]string, 0, 2)
  46514. if m.server != nil {
  46515. edges = append(edges, wx.EdgeServer)
  46516. }
  46517. if m.agent != nil {
  46518. edges = append(edges, wx.EdgeAgent)
  46519. }
  46520. return edges
  46521. }
  46522. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  46523. // name in this mutation.
  46524. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  46525. switch name {
  46526. case wx.EdgeServer:
  46527. if id := m.server; id != nil {
  46528. return []ent.Value{*id}
  46529. }
  46530. case wx.EdgeAgent:
  46531. if id := m.agent; id != nil {
  46532. return []ent.Value{*id}
  46533. }
  46534. }
  46535. return nil
  46536. }
  46537. // RemovedEdges returns all edge names that were removed in this mutation.
  46538. func (m *WxMutation) RemovedEdges() []string {
  46539. edges := make([]string, 0, 2)
  46540. return edges
  46541. }
  46542. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  46543. // the given name in this mutation.
  46544. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  46545. return nil
  46546. }
  46547. // ClearedEdges returns all edge names that were cleared in this mutation.
  46548. func (m *WxMutation) ClearedEdges() []string {
  46549. edges := make([]string, 0, 2)
  46550. if m.clearedserver {
  46551. edges = append(edges, wx.EdgeServer)
  46552. }
  46553. if m.clearedagent {
  46554. edges = append(edges, wx.EdgeAgent)
  46555. }
  46556. return edges
  46557. }
  46558. // EdgeCleared returns a boolean which indicates if the edge with the given name
  46559. // was cleared in this mutation.
  46560. func (m *WxMutation) EdgeCleared(name string) bool {
  46561. switch name {
  46562. case wx.EdgeServer:
  46563. return m.clearedserver
  46564. case wx.EdgeAgent:
  46565. return m.clearedagent
  46566. }
  46567. return false
  46568. }
  46569. // ClearEdge clears the value of the edge with the given name. It returns an error
  46570. // if that edge is not defined in the schema.
  46571. func (m *WxMutation) ClearEdge(name string) error {
  46572. switch name {
  46573. case wx.EdgeServer:
  46574. m.ClearServer()
  46575. return nil
  46576. case wx.EdgeAgent:
  46577. m.ClearAgent()
  46578. return nil
  46579. }
  46580. return fmt.Errorf("unknown Wx unique edge %s", name)
  46581. }
  46582. // ResetEdge resets all changes to the edge with the given name in this mutation.
  46583. // It returns an error if the edge is not defined in the schema.
  46584. func (m *WxMutation) ResetEdge(name string) error {
  46585. switch name {
  46586. case wx.EdgeServer:
  46587. m.ResetServer()
  46588. return nil
  46589. case wx.EdgeAgent:
  46590. m.ResetAgent()
  46591. return nil
  46592. }
  46593. return fmt.Errorf("unknown Wx edge %s", name)
  46594. }
  46595. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  46596. type WxCardMutation struct {
  46597. config
  46598. op Op
  46599. typ string
  46600. id *uint64
  46601. created_at *time.Time
  46602. updated_at *time.Time
  46603. deleted_at *time.Time
  46604. user_id *uint64
  46605. adduser_id *int64
  46606. wx_user_id *uint64
  46607. addwx_user_id *int64
  46608. avatar *string
  46609. logo *string
  46610. name *string
  46611. company *string
  46612. address *string
  46613. phone *string
  46614. official_account *string
  46615. wechat_account *string
  46616. email *string
  46617. api_base *string
  46618. api_key *string
  46619. ai_info *string
  46620. intro *string
  46621. clearedFields map[string]struct{}
  46622. done bool
  46623. oldValue func(context.Context) (*WxCard, error)
  46624. predicates []predicate.WxCard
  46625. }
  46626. var _ ent.Mutation = (*WxCardMutation)(nil)
  46627. // wxcardOption allows management of the mutation configuration using functional options.
  46628. type wxcardOption func(*WxCardMutation)
  46629. // newWxCardMutation creates new mutation for the WxCard entity.
  46630. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  46631. m := &WxCardMutation{
  46632. config: c,
  46633. op: op,
  46634. typ: TypeWxCard,
  46635. clearedFields: make(map[string]struct{}),
  46636. }
  46637. for _, opt := range opts {
  46638. opt(m)
  46639. }
  46640. return m
  46641. }
  46642. // withWxCardID sets the ID field of the mutation.
  46643. func withWxCardID(id uint64) wxcardOption {
  46644. return func(m *WxCardMutation) {
  46645. var (
  46646. err error
  46647. once sync.Once
  46648. value *WxCard
  46649. )
  46650. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  46651. once.Do(func() {
  46652. if m.done {
  46653. err = errors.New("querying old values post mutation is not allowed")
  46654. } else {
  46655. value, err = m.Client().WxCard.Get(ctx, id)
  46656. }
  46657. })
  46658. return value, err
  46659. }
  46660. m.id = &id
  46661. }
  46662. }
  46663. // withWxCard sets the old WxCard of the mutation.
  46664. func withWxCard(node *WxCard) wxcardOption {
  46665. return func(m *WxCardMutation) {
  46666. m.oldValue = func(context.Context) (*WxCard, error) {
  46667. return node, nil
  46668. }
  46669. m.id = &node.ID
  46670. }
  46671. }
  46672. // Client returns a new `ent.Client` from the mutation. If the mutation was
  46673. // executed in a transaction (ent.Tx), a transactional client is returned.
  46674. func (m WxCardMutation) Client() *Client {
  46675. client := &Client{config: m.config}
  46676. client.init()
  46677. return client
  46678. }
  46679. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  46680. // it returns an error otherwise.
  46681. func (m WxCardMutation) Tx() (*Tx, error) {
  46682. if _, ok := m.driver.(*txDriver); !ok {
  46683. return nil, errors.New("ent: mutation is not running in a transaction")
  46684. }
  46685. tx := &Tx{config: m.config}
  46686. tx.init()
  46687. return tx, nil
  46688. }
  46689. // SetID sets the value of the id field. Note that this
  46690. // operation is only accepted on creation of WxCard entities.
  46691. func (m *WxCardMutation) SetID(id uint64) {
  46692. m.id = &id
  46693. }
  46694. // ID returns the ID value in the mutation. Note that the ID is only available
  46695. // if it was provided to the builder or after it was returned from the database.
  46696. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  46697. if m.id == nil {
  46698. return
  46699. }
  46700. return *m.id, true
  46701. }
  46702. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  46703. // That means, if the mutation is applied within a transaction with an isolation level such
  46704. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  46705. // or updated by the mutation.
  46706. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  46707. switch {
  46708. case m.op.Is(OpUpdateOne | OpDeleteOne):
  46709. id, exists := m.ID()
  46710. if exists {
  46711. return []uint64{id}, nil
  46712. }
  46713. fallthrough
  46714. case m.op.Is(OpUpdate | OpDelete):
  46715. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  46716. default:
  46717. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  46718. }
  46719. }
  46720. // SetCreatedAt sets the "created_at" field.
  46721. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  46722. m.created_at = &t
  46723. }
  46724. // CreatedAt returns the value of the "created_at" field in the mutation.
  46725. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  46726. v := m.created_at
  46727. if v == nil {
  46728. return
  46729. }
  46730. return *v, true
  46731. }
  46732. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  46733. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46734. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46735. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  46736. if !m.op.Is(OpUpdateOne) {
  46737. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  46738. }
  46739. if m.id == nil || m.oldValue == nil {
  46740. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  46741. }
  46742. oldValue, err := m.oldValue(ctx)
  46743. if err != nil {
  46744. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  46745. }
  46746. return oldValue.CreatedAt, nil
  46747. }
  46748. // ResetCreatedAt resets all changes to the "created_at" field.
  46749. func (m *WxCardMutation) ResetCreatedAt() {
  46750. m.created_at = nil
  46751. }
  46752. // SetUpdatedAt sets the "updated_at" field.
  46753. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  46754. m.updated_at = &t
  46755. }
  46756. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  46757. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  46758. v := m.updated_at
  46759. if v == nil {
  46760. return
  46761. }
  46762. return *v, true
  46763. }
  46764. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  46765. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46766. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46767. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  46768. if !m.op.Is(OpUpdateOne) {
  46769. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  46770. }
  46771. if m.id == nil || m.oldValue == nil {
  46772. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  46773. }
  46774. oldValue, err := m.oldValue(ctx)
  46775. if err != nil {
  46776. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  46777. }
  46778. return oldValue.UpdatedAt, nil
  46779. }
  46780. // ResetUpdatedAt resets all changes to the "updated_at" field.
  46781. func (m *WxCardMutation) ResetUpdatedAt() {
  46782. m.updated_at = nil
  46783. }
  46784. // SetDeletedAt sets the "deleted_at" field.
  46785. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  46786. m.deleted_at = &t
  46787. }
  46788. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  46789. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  46790. v := m.deleted_at
  46791. if v == nil {
  46792. return
  46793. }
  46794. return *v, true
  46795. }
  46796. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  46797. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46798. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46799. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  46800. if !m.op.Is(OpUpdateOne) {
  46801. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  46802. }
  46803. if m.id == nil || m.oldValue == nil {
  46804. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  46805. }
  46806. oldValue, err := m.oldValue(ctx)
  46807. if err != nil {
  46808. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  46809. }
  46810. return oldValue.DeletedAt, nil
  46811. }
  46812. // ClearDeletedAt clears the value of the "deleted_at" field.
  46813. func (m *WxCardMutation) ClearDeletedAt() {
  46814. m.deleted_at = nil
  46815. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  46816. }
  46817. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  46818. func (m *WxCardMutation) DeletedAtCleared() bool {
  46819. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  46820. return ok
  46821. }
  46822. // ResetDeletedAt resets all changes to the "deleted_at" field.
  46823. func (m *WxCardMutation) ResetDeletedAt() {
  46824. m.deleted_at = nil
  46825. delete(m.clearedFields, wxcard.FieldDeletedAt)
  46826. }
  46827. // SetUserID sets the "user_id" field.
  46828. func (m *WxCardMutation) SetUserID(u uint64) {
  46829. m.user_id = &u
  46830. m.adduser_id = nil
  46831. }
  46832. // UserID returns the value of the "user_id" field in the mutation.
  46833. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  46834. v := m.user_id
  46835. if v == nil {
  46836. return
  46837. }
  46838. return *v, true
  46839. }
  46840. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  46841. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46842. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46843. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  46844. if !m.op.Is(OpUpdateOne) {
  46845. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  46846. }
  46847. if m.id == nil || m.oldValue == nil {
  46848. return v, errors.New("OldUserID requires an ID field in the mutation")
  46849. }
  46850. oldValue, err := m.oldValue(ctx)
  46851. if err != nil {
  46852. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  46853. }
  46854. return oldValue.UserID, nil
  46855. }
  46856. // AddUserID adds u to the "user_id" field.
  46857. func (m *WxCardMutation) AddUserID(u int64) {
  46858. if m.adduser_id != nil {
  46859. *m.adduser_id += u
  46860. } else {
  46861. m.adduser_id = &u
  46862. }
  46863. }
  46864. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  46865. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  46866. v := m.adduser_id
  46867. if v == nil {
  46868. return
  46869. }
  46870. return *v, true
  46871. }
  46872. // ClearUserID clears the value of the "user_id" field.
  46873. func (m *WxCardMutation) ClearUserID() {
  46874. m.user_id = nil
  46875. m.adduser_id = nil
  46876. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  46877. }
  46878. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  46879. func (m *WxCardMutation) UserIDCleared() bool {
  46880. _, ok := m.clearedFields[wxcard.FieldUserID]
  46881. return ok
  46882. }
  46883. // ResetUserID resets all changes to the "user_id" field.
  46884. func (m *WxCardMutation) ResetUserID() {
  46885. m.user_id = nil
  46886. m.adduser_id = nil
  46887. delete(m.clearedFields, wxcard.FieldUserID)
  46888. }
  46889. // SetWxUserID sets the "wx_user_id" field.
  46890. func (m *WxCardMutation) SetWxUserID(u uint64) {
  46891. m.wx_user_id = &u
  46892. m.addwx_user_id = nil
  46893. }
  46894. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  46895. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  46896. v := m.wx_user_id
  46897. if v == nil {
  46898. return
  46899. }
  46900. return *v, true
  46901. }
  46902. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  46903. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46904. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46905. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  46906. if !m.op.Is(OpUpdateOne) {
  46907. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  46908. }
  46909. if m.id == nil || m.oldValue == nil {
  46910. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  46911. }
  46912. oldValue, err := m.oldValue(ctx)
  46913. if err != nil {
  46914. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  46915. }
  46916. return oldValue.WxUserID, nil
  46917. }
  46918. // AddWxUserID adds u to the "wx_user_id" field.
  46919. func (m *WxCardMutation) AddWxUserID(u int64) {
  46920. if m.addwx_user_id != nil {
  46921. *m.addwx_user_id += u
  46922. } else {
  46923. m.addwx_user_id = &u
  46924. }
  46925. }
  46926. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  46927. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  46928. v := m.addwx_user_id
  46929. if v == nil {
  46930. return
  46931. }
  46932. return *v, true
  46933. }
  46934. // ClearWxUserID clears the value of the "wx_user_id" field.
  46935. func (m *WxCardMutation) ClearWxUserID() {
  46936. m.wx_user_id = nil
  46937. m.addwx_user_id = nil
  46938. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  46939. }
  46940. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  46941. func (m *WxCardMutation) WxUserIDCleared() bool {
  46942. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  46943. return ok
  46944. }
  46945. // ResetWxUserID resets all changes to the "wx_user_id" field.
  46946. func (m *WxCardMutation) ResetWxUserID() {
  46947. m.wx_user_id = nil
  46948. m.addwx_user_id = nil
  46949. delete(m.clearedFields, wxcard.FieldWxUserID)
  46950. }
  46951. // SetAvatar sets the "avatar" field.
  46952. func (m *WxCardMutation) SetAvatar(s string) {
  46953. m.avatar = &s
  46954. }
  46955. // Avatar returns the value of the "avatar" field in the mutation.
  46956. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  46957. v := m.avatar
  46958. if v == nil {
  46959. return
  46960. }
  46961. return *v, true
  46962. }
  46963. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  46964. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46965. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46966. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  46967. if !m.op.Is(OpUpdateOne) {
  46968. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  46969. }
  46970. if m.id == nil || m.oldValue == nil {
  46971. return v, errors.New("OldAvatar requires an ID field in the mutation")
  46972. }
  46973. oldValue, err := m.oldValue(ctx)
  46974. if err != nil {
  46975. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  46976. }
  46977. return oldValue.Avatar, nil
  46978. }
  46979. // ResetAvatar resets all changes to the "avatar" field.
  46980. func (m *WxCardMutation) ResetAvatar() {
  46981. m.avatar = nil
  46982. }
  46983. // SetLogo sets the "logo" field.
  46984. func (m *WxCardMutation) SetLogo(s string) {
  46985. m.logo = &s
  46986. }
  46987. // Logo returns the value of the "logo" field in the mutation.
  46988. func (m *WxCardMutation) Logo() (r string, exists bool) {
  46989. v := m.logo
  46990. if v == nil {
  46991. return
  46992. }
  46993. return *v, true
  46994. }
  46995. // OldLogo returns the old "logo" field's value of the WxCard entity.
  46996. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46997. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46998. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  46999. if !m.op.Is(OpUpdateOne) {
  47000. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  47001. }
  47002. if m.id == nil || m.oldValue == nil {
  47003. return v, errors.New("OldLogo requires an ID field in the mutation")
  47004. }
  47005. oldValue, err := m.oldValue(ctx)
  47006. if err != nil {
  47007. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  47008. }
  47009. return oldValue.Logo, nil
  47010. }
  47011. // ResetLogo resets all changes to the "logo" field.
  47012. func (m *WxCardMutation) ResetLogo() {
  47013. m.logo = nil
  47014. }
  47015. // SetName sets the "name" field.
  47016. func (m *WxCardMutation) SetName(s string) {
  47017. m.name = &s
  47018. }
  47019. // Name returns the value of the "name" field in the mutation.
  47020. func (m *WxCardMutation) Name() (r string, exists bool) {
  47021. v := m.name
  47022. if v == nil {
  47023. return
  47024. }
  47025. return *v, true
  47026. }
  47027. // OldName returns the old "name" field's value of the WxCard entity.
  47028. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47029. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47030. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  47031. if !m.op.Is(OpUpdateOne) {
  47032. return v, errors.New("OldName is only allowed on UpdateOne operations")
  47033. }
  47034. if m.id == nil || m.oldValue == nil {
  47035. return v, errors.New("OldName requires an ID field in the mutation")
  47036. }
  47037. oldValue, err := m.oldValue(ctx)
  47038. if err != nil {
  47039. return v, fmt.Errorf("querying old value for OldName: %w", err)
  47040. }
  47041. return oldValue.Name, nil
  47042. }
  47043. // ResetName resets all changes to the "name" field.
  47044. func (m *WxCardMutation) ResetName() {
  47045. m.name = nil
  47046. }
  47047. // SetCompany sets the "company" field.
  47048. func (m *WxCardMutation) SetCompany(s string) {
  47049. m.company = &s
  47050. }
  47051. // Company returns the value of the "company" field in the mutation.
  47052. func (m *WxCardMutation) Company() (r string, exists bool) {
  47053. v := m.company
  47054. if v == nil {
  47055. return
  47056. }
  47057. return *v, true
  47058. }
  47059. // OldCompany returns the old "company" field's value of the WxCard entity.
  47060. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47061. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47062. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  47063. if !m.op.Is(OpUpdateOne) {
  47064. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  47065. }
  47066. if m.id == nil || m.oldValue == nil {
  47067. return v, errors.New("OldCompany requires an ID field in the mutation")
  47068. }
  47069. oldValue, err := m.oldValue(ctx)
  47070. if err != nil {
  47071. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  47072. }
  47073. return oldValue.Company, nil
  47074. }
  47075. // ResetCompany resets all changes to the "company" field.
  47076. func (m *WxCardMutation) ResetCompany() {
  47077. m.company = nil
  47078. }
  47079. // SetAddress sets the "address" field.
  47080. func (m *WxCardMutation) SetAddress(s string) {
  47081. m.address = &s
  47082. }
  47083. // Address returns the value of the "address" field in the mutation.
  47084. func (m *WxCardMutation) Address() (r string, exists bool) {
  47085. v := m.address
  47086. if v == nil {
  47087. return
  47088. }
  47089. return *v, true
  47090. }
  47091. // OldAddress returns the old "address" field's value of the WxCard entity.
  47092. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47093. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47094. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  47095. if !m.op.Is(OpUpdateOne) {
  47096. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  47097. }
  47098. if m.id == nil || m.oldValue == nil {
  47099. return v, errors.New("OldAddress requires an ID field in the mutation")
  47100. }
  47101. oldValue, err := m.oldValue(ctx)
  47102. if err != nil {
  47103. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  47104. }
  47105. return oldValue.Address, nil
  47106. }
  47107. // ResetAddress resets all changes to the "address" field.
  47108. func (m *WxCardMutation) ResetAddress() {
  47109. m.address = nil
  47110. }
  47111. // SetPhone sets the "phone" field.
  47112. func (m *WxCardMutation) SetPhone(s string) {
  47113. m.phone = &s
  47114. }
  47115. // Phone returns the value of the "phone" field in the mutation.
  47116. func (m *WxCardMutation) Phone() (r string, exists bool) {
  47117. v := m.phone
  47118. if v == nil {
  47119. return
  47120. }
  47121. return *v, true
  47122. }
  47123. // OldPhone returns the old "phone" field's value of the WxCard entity.
  47124. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47125. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47126. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  47127. if !m.op.Is(OpUpdateOne) {
  47128. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  47129. }
  47130. if m.id == nil || m.oldValue == nil {
  47131. return v, errors.New("OldPhone requires an ID field in the mutation")
  47132. }
  47133. oldValue, err := m.oldValue(ctx)
  47134. if err != nil {
  47135. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  47136. }
  47137. return oldValue.Phone, nil
  47138. }
  47139. // ResetPhone resets all changes to the "phone" field.
  47140. func (m *WxCardMutation) ResetPhone() {
  47141. m.phone = nil
  47142. }
  47143. // SetOfficialAccount sets the "official_account" field.
  47144. func (m *WxCardMutation) SetOfficialAccount(s string) {
  47145. m.official_account = &s
  47146. }
  47147. // OfficialAccount returns the value of the "official_account" field in the mutation.
  47148. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  47149. v := m.official_account
  47150. if v == nil {
  47151. return
  47152. }
  47153. return *v, true
  47154. }
  47155. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  47156. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47157. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47158. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  47159. if !m.op.Is(OpUpdateOne) {
  47160. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  47161. }
  47162. if m.id == nil || m.oldValue == nil {
  47163. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  47164. }
  47165. oldValue, err := m.oldValue(ctx)
  47166. if err != nil {
  47167. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  47168. }
  47169. return oldValue.OfficialAccount, nil
  47170. }
  47171. // ResetOfficialAccount resets all changes to the "official_account" field.
  47172. func (m *WxCardMutation) ResetOfficialAccount() {
  47173. m.official_account = nil
  47174. }
  47175. // SetWechatAccount sets the "wechat_account" field.
  47176. func (m *WxCardMutation) SetWechatAccount(s string) {
  47177. m.wechat_account = &s
  47178. }
  47179. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  47180. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  47181. v := m.wechat_account
  47182. if v == nil {
  47183. return
  47184. }
  47185. return *v, true
  47186. }
  47187. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  47188. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47189. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47190. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  47191. if !m.op.Is(OpUpdateOne) {
  47192. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  47193. }
  47194. if m.id == nil || m.oldValue == nil {
  47195. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  47196. }
  47197. oldValue, err := m.oldValue(ctx)
  47198. if err != nil {
  47199. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  47200. }
  47201. return oldValue.WechatAccount, nil
  47202. }
  47203. // ResetWechatAccount resets all changes to the "wechat_account" field.
  47204. func (m *WxCardMutation) ResetWechatAccount() {
  47205. m.wechat_account = nil
  47206. }
  47207. // SetEmail sets the "email" field.
  47208. func (m *WxCardMutation) SetEmail(s string) {
  47209. m.email = &s
  47210. }
  47211. // Email returns the value of the "email" field in the mutation.
  47212. func (m *WxCardMutation) Email() (r string, exists bool) {
  47213. v := m.email
  47214. if v == nil {
  47215. return
  47216. }
  47217. return *v, true
  47218. }
  47219. // OldEmail returns the old "email" field's value of the WxCard entity.
  47220. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47221. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47222. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  47223. if !m.op.Is(OpUpdateOne) {
  47224. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  47225. }
  47226. if m.id == nil || m.oldValue == nil {
  47227. return v, errors.New("OldEmail requires an ID field in the mutation")
  47228. }
  47229. oldValue, err := m.oldValue(ctx)
  47230. if err != nil {
  47231. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  47232. }
  47233. return oldValue.Email, nil
  47234. }
  47235. // ClearEmail clears the value of the "email" field.
  47236. func (m *WxCardMutation) ClearEmail() {
  47237. m.email = nil
  47238. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  47239. }
  47240. // EmailCleared returns if the "email" field was cleared in this mutation.
  47241. func (m *WxCardMutation) EmailCleared() bool {
  47242. _, ok := m.clearedFields[wxcard.FieldEmail]
  47243. return ok
  47244. }
  47245. // ResetEmail resets all changes to the "email" field.
  47246. func (m *WxCardMutation) ResetEmail() {
  47247. m.email = nil
  47248. delete(m.clearedFields, wxcard.FieldEmail)
  47249. }
  47250. // SetAPIBase sets the "api_base" field.
  47251. func (m *WxCardMutation) SetAPIBase(s string) {
  47252. m.api_base = &s
  47253. }
  47254. // APIBase returns the value of the "api_base" field in the mutation.
  47255. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  47256. v := m.api_base
  47257. if v == nil {
  47258. return
  47259. }
  47260. return *v, true
  47261. }
  47262. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  47263. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47264. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47265. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  47266. if !m.op.Is(OpUpdateOne) {
  47267. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  47268. }
  47269. if m.id == nil || m.oldValue == nil {
  47270. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  47271. }
  47272. oldValue, err := m.oldValue(ctx)
  47273. if err != nil {
  47274. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  47275. }
  47276. return oldValue.APIBase, nil
  47277. }
  47278. // ClearAPIBase clears the value of the "api_base" field.
  47279. func (m *WxCardMutation) ClearAPIBase() {
  47280. m.api_base = nil
  47281. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  47282. }
  47283. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  47284. func (m *WxCardMutation) APIBaseCleared() bool {
  47285. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  47286. return ok
  47287. }
  47288. // ResetAPIBase resets all changes to the "api_base" field.
  47289. func (m *WxCardMutation) ResetAPIBase() {
  47290. m.api_base = nil
  47291. delete(m.clearedFields, wxcard.FieldAPIBase)
  47292. }
  47293. // SetAPIKey sets the "api_key" field.
  47294. func (m *WxCardMutation) SetAPIKey(s string) {
  47295. m.api_key = &s
  47296. }
  47297. // APIKey returns the value of the "api_key" field in the mutation.
  47298. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  47299. v := m.api_key
  47300. if v == nil {
  47301. return
  47302. }
  47303. return *v, true
  47304. }
  47305. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  47306. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47307. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47308. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  47309. if !m.op.Is(OpUpdateOne) {
  47310. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  47311. }
  47312. if m.id == nil || m.oldValue == nil {
  47313. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  47314. }
  47315. oldValue, err := m.oldValue(ctx)
  47316. if err != nil {
  47317. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  47318. }
  47319. return oldValue.APIKey, nil
  47320. }
  47321. // ClearAPIKey clears the value of the "api_key" field.
  47322. func (m *WxCardMutation) ClearAPIKey() {
  47323. m.api_key = nil
  47324. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  47325. }
  47326. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  47327. func (m *WxCardMutation) APIKeyCleared() bool {
  47328. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  47329. return ok
  47330. }
  47331. // ResetAPIKey resets all changes to the "api_key" field.
  47332. func (m *WxCardMutation) ResetAPIKey() {
  47333. m.api_key = nil
  47334. delete(m.clearedFields, wxcard.FieldAPIKey)
  47335. }
  47336. // SetAiInfo sets the "ai_info" field.
  47337. func (m *WxCardMutation) SetAiInfo(s string) {
  47338. m.ai_info = &s
  47339. }
  47340. // AiInfo returns the value of the "ai_info" field in the mutation.
  47341. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  47342. v := m.ai_info
  47343. if v == nil {
  47344. return
  47345. }
  47346. return *v, true
  47347. }
  47348. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  47349. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47350. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47351. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  47352. if !m.op.Is(OpUpdateOne) {
  47353. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  47354. }
  47355. if m.id == nil || m.oldValue == nil {
  47356. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  47357. }
  47358. oldValue, err := m.oldValue(ctx)
  47359. if err != nil {
  47360. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  47361. }
  47362. return oldValue.AiInfo, nil
  47363. }
  47364. // ClearAiInfo clears the value of the "ai_info" field.
  47365. func (m *WxCardMutation) ClearAiInfo() {
  47366. m.ai_info = nil
  47367. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  47368. }
  47369. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  47370. func (m *WxCardMutation) AiInfoCleared() bool {
  47371. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  47372. return ok
  47373. }
  47374. // ResetAiInfo resets all changes to the "ai_info" field.
  47375. func (m *WxCardMutation) ResetAiInfo() {
  47376. m.ai_info = nil
  47377. delete(m.clearedFields, wxcard.FieldAiInfo)
  47378. }
  47379. // SetIntro sets the "intro" field.
  47380. func (m *WxCardMutation) SetIntro(s string) {
  47381. m.intro = &s
  47382. }
  47383. // Intro returns the value of the "intro" field in the mutation.
  47384. func (m *WxCardMutation) Intro() (r string, exists bool) {
  47385. v := m.intro
  47386. if v == nil {
  47387. return
  47388. }
  47389. return *v, true
  47390. }
  47391. // OldIntro returns the old "intro" field's value of the WxCard entity.
  47392. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47393. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47394. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  47395. if !m.op.Is(OpUpdateOne) {
  47396. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  47397. }
  47398. if m.id == nil || m.oldValue == nil {
  47399. return v, errors.New("OldIntro requires an ID field in the mutation")
  47400. }
  47401. oldValue, err := m.oldValue(ctx)
  47402. if err != nil {
  47403. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  47404. }
  47405. return oldValue.Intro, nil
  47406. }
  47407. // ClearIntro clears the value of the "intro" field.
  47408. func (m *WxCardMutation) ClearIntro() {
  47409. m.intro = nil
  47410. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  47411. }
  47412. // IntroCleared returns if the "intro" field was cleared in this mutation.
  47413. func (m *WxCardMutation) IntroCleared() bool {
  47414. _, ok := m.clearedFields[wxcard.FieldIntro]
  47415. return ok
  47416. }
  47417. // ResetIntro resets all changes to the "intro" field.
  47418. func (m *WxCardMutation) ResetIntro() {
  47419. m.intro = nil
  47420. delete(m.clearedFields, wxcard.FieldIntro)
  47421. }
  47422. // Where appends a list predicates to the WxCardMutation builder.
  47423. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  47424. m.predicates = append(m.predicates, ps...)
  47425. }
  47426. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  47427. // users can use type-assertion to append predicates that do not depend on any generated package.
  47428. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  47429. p := make([]predicate.WxCard, len(ps))
  47430. for i := range ps {
  47431. p[i] = ps[i]
  47432. }
  47433. m.Where(p...)
  47434. }
  47435. // Op returns the operation name.
  47436. func (m *WxCardMutation) Op() Op {
  47437. return m.op
  47438. }
  47439. // SetOp allows setting the mutation operation.
  47440. func (m *WxCardMutation) SetOp(op Op) {
  47441. m.op = op
  47442. }
  47443. // Type returns the node type of this mutation (WxCard).
  47444. func (m *WxCardMutation) Type() string {
  47445. return m.typ
  47446. }
  47447. // Fields returns all fields that were changed during this mutation. Note that in
  47448. // order to get all numeric fields that were incremented/decremented, call
  47449. // AddedFields().
  47450. func (m *WxCardMutation) Fields() []string {
  47451. fields := make([]string, 0, 18)
  47452. if m.created_at != nil {
  47453. fields = append(fields, wxcard.FieldCreatedAt)
  47454. }
  47455. if m.updated_at != nil {
  47456. fields = append(fields, wxcard.FieldUpdatedAt)
  47457. }
  47458. if m.deleted_at != nil {
  47459. fields = append(fields, wxcard.FieldDeletedAt)
  47460. }
  47461. if m.user_id != nil {
  47462. fields = append(fields, wxcard.FieldUserID)
  47463. }
  47464. if m.wx_user_id != nil {
  47465. fields = append(fields, wxcard.FieldWxUserID)
  47466. }
  47467. if m.avatar != nil {
  47468. fields = append(fields, wxcard.FieldAvatar)
  47469. }
  47470. if m.logo != nil {
  47471. fields = append(fields, wxcard.FieldLogo)
  47472. }
  47473. if m.name != nil {
  47474. fields = append(fields, wxcard.FieldName)
  47475. }
  47476. if m.company != nil {
  47477. fields = append(fields, wxcard.FieldCompany)
  47478. }
  47479. if m.address != nil {
  47480. fields = append(fields, wxcard.FieldAddress)
  47481. }
  47482. if m.phone != nil {
  47483. fields = append(fields, wxcard.FieldPhone)
  47484. }
  47485. if m.official_account != nil {
  47486. fields = append(fields, wxcard.FieldOfficialAccount)
  47487. }
  47488. if m.wechat_account != nil {
  47489. fields = append(fields, wxcard.FieldWechatAccount)
  47490. }
  47491. if m.email != nil {
  47492. fields = append(fields, wxcard.FieldEmail)
  47493. }
  47494. if m.api_base != nil {
  47495. fields = append(fields, wxcard.FieldAPIBase)
  47496. }
  47497. if m.api_key != nil {
  47498. fields = append(fields, wxcard.FieldAPIKey)
  47499. }
  47500. if m.ai_info != nil {
  47501. fields = append(fields, wxcard.FieldAiInfo)
  47502. }
  47503. if m.intro != nil {
  47504. fields = append(fields, wxcard.FieldIntro)
  47505. }
  47506. return fields
  47507. }
  47508. // Field returns the value of a field with the given name. The second boolean
  47509. // return value indicates that this field was not set, or was not defined in the
  47510. // schema.
  47511. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  47512. switch name {
  47513. case wxcard.FieldCreatedAt:
  47514. return m.CreatedAt()
  47515. case wxcard.FieldUpdatedAt:
  47516. return m.UpdatedAt()
  47517. case wxcard.FieldDeletedAt:
  47518. return m.DeletedAt()
  47519. case wxcard.FieldUserID:
  47520. return m.UserID()
  47521. case wxcard.FieldWxUserID:
  47522. return m.WxUserID()
  47523. case wxcard.FieldAvatar:
  47524. return m.Avatar()
  47525. case wxcard.FieldLogo:
  47526. return m.Logo()
  47527. case wxcard.FieldName:
  47528. return m.Name()
  47529. case wxcard.FieldCompany:
  47530. return m.Company()
  47531. case wxcard.FieldAddress:
  47532. return m.Address()
  47533. case wxcard.FieldPhone:
  47534. return m.Phone()
  47535. case wxcard.FieldOfficialAccount:
  47536. return m.OfficialAccount()
  47537. case wxcard.FieldWechatAccount:
  47538. return m.WechatAccount()
  47539. case wxcard.FieldEmail:
  47540. return m.Email()
  47541. case wxcard.FieldAPIBase:
  47542. return m.APIBase()
  47543. case wxcard.FieldAPIKey:
  47544. return m.APIKey()
  47545. case wxcard.FieldAiInfo:
  47546. return m.AiInfo()
  47547. case wxcard.FieldIntro:
  47548. return m.Intro()
  47549. }
  47550. return nil, false
  47551. }
  47552. // OldField returns the old value of the field from the database. An error is
  47553. // returned if the mutation operation is not UpdateOne, or the query to the
  47554. // database failed.
  47555. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  47556. switch name {
  47557. case wxcard.FieldCreatedAt:
  47558. return m.OldCreatedAt(ctx)
  47559. case wxcard.FieldUpdatedAt:
  47560. return m.OldUpdatedAt(ctx)
  47561. case wxcard.FieldDeletedAt:
  47562. return m.OldDeletedAt(ctx)
  47563. case wxcard.FieldUserID:
  47564. return m.OldUserID(ctx)
  47565. case wxcard.FieldWxUserID:
  47566. return m.OldWxUserID(ctx)
  47567. case wxcard.FieldAvatar:
  47568. return m.OldAvatar(ctx)
  47569. case wxcard.FieldLogo:
  47570. return m.OldLogo(ctx)
  47571. case wxcard.FieldName:
  47572. return m.OldName(ctx)
  47573. case wxcard.FieldCompany:
  47574. return m.OldCompany(ctx)
  47575. case wxcard.FieldAddress:
  47576. return m.OldAddress(ctx)
  47577. case wxcard.FieldPhone:
  47578. return m.OldPhone(ctx)
  47579. case wxcard.FieldOfficialAccount:
  47580. return m.OldOfficialAccount(ctx)
  47581. case wxcard.FieldWechatAccount:
  47582. return m.OldWechatAccount(ctx)
  47583. case wxcard.FieldEmail:
  47584. return m.OldEmail(ctx)
  47585. case wxcard.FieldAPIBase:
  47586. return m.OldAPIBase(ctx)
  47587. case wxcard.FieldAPIKey:
  47588. return m.OldAPIKey(ctx)
  47589. case wxcard.FieldAiInfo:
  47590. return m.OldAiInfo(ctx)
  47591. case wxcard.FieldIntro:
  47592. return m.OldIntro(ctx)
  47593. }
  47594. return nil, fmt.Errorf("unknown WxCard field %s", name)
  47595. }
  47596. // SetField sets the value of a field with the given name. It returns an error if
  47597. // the field is not defined in the schema, or if the type mismatched the field
  47598. // type.
  47599. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  47600. switch name {
  47601. case wxcard.FieldCreatedAt:
  47602. v, ok := value.(time.Time)
  47603. if !ok {
  47604. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47605. }
  47606. m.SetCreatedAt(v)
  47607. return nil
  47608. case wxcard.FieldUpdatedAt:
  47609. v, ok := value.(time.Time)
  47610. if !ok {
  47611. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47612. }
  47613. m.SetUpdatedAt(v)
  47614. return nil
  47615. case wxcard.FieldDeletedAt:
  47616. v, ok := value.(time.Time)
  47617. if !ok {
  47618. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47619. }
  47620. m.SetDeletedAt(v)
  47621. return nil
  47622. case wxcard.FieldUserID:
  47623. v, ok := value.(uint64)
  47624. if !ok {
  47625. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47626. }
  47627. m.SetUserID(v)
  47628. return nil
  47629. case wxcard.FieldWxUserID:
  47630. v, ok := value.(uint64)
  47631. if !ok {
  47632. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47633. }
  47634. m.SetWxUserID(v)
  47635. return nil
  47636. case wxcard.FieldAvatar:
  47637. v, ok := value.(string)
  47638. if !ok {
  47639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47640. }
  47641. m.SetAvatar(v)
  47642. return nil
  47643. case wxcard.FieldLogo:
  47644. v, ok := value.(string)
  47645. if !ok {
  47646. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47647. }
  47648. m.SetLogo(v)
  47649. return nil
  47650. case wxcard.FieldName:
  47651. v, ok := value.(string)
  47652. if !ok {
  47653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47654. }
  47655. m.SetName(v)
  47656. return nil
  47657. case wxcard.FieldCompany:
  47658. v, ok := value.(string)
  47659. if !ok {
  47660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47661. }
  47662. m.SetCompany(v)
  47663. return nil
  47664. case wxcard.FieldAddress:
  47665. v, ok := value.(string)
  47666. if !ok {
  47667. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47668. }
  47669. m.SetAddress(v)
  47670. return nil
  47671. case wxcard.FieldPhone:
  47672. v, ok := value.(string)
  47673. if !ok {
  47674. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47675. }
  47676. m.SetPhone(v)
  47677. return nil
  47678. case wxcard.FieldOfficialAccount:
  47679. v, ok := value.(string)
  47680. if !ok {
  47681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47682. }
  47683. m.SetOfficialAccount(v)
  47684. return nil
  47685. case wxcard.FieldWechatAccount:
  47686. v, ok := value.(string)
  47687. if !ok {
  47688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47689. }
  47690. m.SetWechatAccount(v)
  47691. return nil
  47692. case wxcard.FieldEmail:
  47693. v, ok := value.(string)
  47694. if !ok {
  47695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47696. }
  47697. m.SetEmail(v)
  47698. return nil
  47699. case wxcard.FieldAPIBase:
  47700. v, ok := value.(string)
  47701. if !ok {
  47702. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47703. }
  47704. m.SetAPIBase(v)
  47705. return nil
  47706. case wxcard.FieldAPIKey:
  47707. v, ok := value.(string)
  47708. if !ok {
  47709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47710. }
  47711. m.SetAPIKey(v)
  47712. return nil
  47713. case wxcard.FieldAiInfo:
  47714. v, ok := value.(string)
  47715. if !ok {
  47716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47717. }
  47718. m.SetAiInfo(v)
  47719. return nil
  47720. case wxcard.FieldIntro:
  47721. v, ok := value.(string)
  47722. if !ok {
  47723. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47724. }
  47725. m.SetIntro(v)
  47726. return nil
  47727. }
  47728. return fmt.Errorf("unknown WxCard field %s", name)
  47729. }
  47730. // AddedFields returns all numeric fields that were incremented/decremented during
  47731. // this mutation.
  47732. func (m *WxCardMutation) AddedFields() []string {
  47733. var fields []string
  47734. if m.adduser_id != nil {
  47735. fields = append(fields, wxcard.FieldUserID)
  47736. }
  47737. if m.addwx_user_id != nil {
  47738. fields = append(fields, wxcard.FieldWxUserID)
  47739. }
  47740. return fields
  47741. }
  47742. // AddedField returns the numeric value that was incremented/decremented on a field
  47743. // with the given name. The second boolean return value indicates that this field
  47744. // was not set, or was not defined in the schema.
  47745. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  47746. switch name {
  47747. case wxcard.FieldUserID:
  47748. return m.AddedUserID()
  47749. case wxcard.FieldWxUserID:
  47750. return m.AddedWxUserID()
  47751. }
  47752. return nil, false
  47753. }
  47754. // AddField adds the value to the field with the given name. It returns an error if
  47755. // the field is not defined in the schema, or if the type mismatched the field
  47756. // type.
  47757. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  47758. switch name {
  47759. case wxcard.FieldUserID:
  47760. v, ok := value.(int64)
  47761. if !ok {
  47762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47763. }
  47764. m.AddUserID(v)
  47765. return nil
  47766. case wxcard.FieldWxUserID:
  47767. v, ok := value.(int64)
  47768. if !ok {
  47769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47770. }
  47771. m.AddWxUserID(v)
  47772. return nil
  47773. }
  47774. return fmt.Errorf("unknown WxCard numeric field %s", name)
  47775. }
  47776. // ClearedFields returns all nullable fields that were cleared during this
  47777. // mutation.
  47778. func (m *WxCardMutation) ClearedFields() []string {
  47779. var fields []string
  47780. if m.FieldCleared(wxcard.FieldDeletedAt) {
  47781. fields = append(fields, wxcard.FieldDeletedAt)
  47782. }
  47783. if m.FieldCleared(wxcard.FieldUserID) {
  47784. fields = append(fields, wxcard.FieldUserID)
  47785. }
  47786. if m.FieldCleared(wxcard.FieldWxUserID) {
  47787. fields = append(fields, wxcard.FieldWxUserID)
  47788. }
  47789. if m.FieldCleared(wxcard.FieldEmail) {
  47790. fields = append(fields, wxcard.FieldEmail)
  47791. }
  47792. if m.FieldCleared(wxcard.FieldAPIBase) {
  47793. fields = append(fields, wxcard.FieldAPIBase)
  47794. }
  47795. if m.FieldCleared(wxcard.FieldAPIKey) {
  47796. fields = append(fields, wxcard.FieldAPIKey)
  47797. }
  47798. if m.FieldCleared(wxcard.FieldAiInfo) {
  47799. fields = append(fields, wxcard.FieldAiInfo)
  47800. }
  47801. if m.FieldCleared(wxcard.FieldIntro) {
  47802. fields = append(fields, wxcard.FieldIntro)
  47803. }
  47804. return fields
  47805. }
  47806. // FieldCleared returns a boolean indicating if a field with the given name was
  47807. // cleared in this mutation.
  47808. func (m *WxCardMutation) FieldCleared(name string) bool {
  47809. _, ok := m.clearedFields[name]
  47810. return ok
  47811. }
  47812. // ClearField clears the value of the field with the given name. It returns an
  47813. // error if the field is not defined in the schema.
  47814. func (m *WxCardMutation) ClearField(name string) error {
  47815. switch name {
  47816. case wxcard.FieldDeletedAt:
  47817. m.ClearDeletedAt()
  47818. return nil
  47819. case wxcard.FieldUserID:
  47820. m.ClearUserID()
  47821. return nil
  47822. case wxcard.FieldWxUserID:
  47823. m.ClearWxUserID()
  47824. return nil
  47825. case wxcard.FieldEmail:
  47826. m.ClearEmail()
  47827. return nil
  47828. case wxcard.FieldAPIBase:
  47829. m.ClearAPIBase()
  47830. return nil
  47831. case wxcard.FieldAPIKey:
  47832. m.ClearAPIKey()
  47833. return nil
  47834. case wxcard.FieldAiInfo:
  47835. m.ClearAiInfo()
  47836. return nil
  47837. case wxcard.FieldIntro:
  47838. m.ClearIntro()
  47839. return nil
  47840. }
  47841. return fmt.Errorf("unknown WxCard nullable field %s", name)
  47842. }
  47843. // ResetField resets all changes in the mutation for the field with the given name.
  47844. // It returns an error if the field is not defined in the schema.
  47845. func (m *WxCardMutation) ResetField(name string) error {
  47846. switch name {
  47847. case wxcard.FieldCreatedAt:
  47848. m.ResetCreatedAt()
  47849. return nil
  47850. case wxcard.FieldUpdatedAt:
  47851. m.ResetUpdatedAt()
  47852. return nil
  47853. case wxcard.FieldDeletedAt:
  47854. m.ResetDeletedAt()
  47855. return nil
  47856. case wxcard.FieldUserID:
  47857. m.ResetUserID()
  47858. return nil
  47859. case wxcard.FieldWxUserID:
  47860. m.ResetWxUserID()
  47861. return nil
  47862. case wxcard.FieldAvatar:
  47863. m.ResetAvatar()
  47864. return nil
  47865. case wxcard.FieldLogo:
  47866. m.ResetLogo()
  47867. return nil
  47868. case wxcard.FieldName:
  47869. m.ResetName()
  47870. return nil
  47871. case wxcard.FieldCompany:
  47872. m.ResetCompany()
  47873. return nil
  47874. case wxcard.FieldAddress:
  47875. m.ResetAddress()
  47876. return nil
  47877. case wxcard.FieldPhone:
  47878. m.ResetPhone()
  47879. return nil
  47880. case wxcard.FieldOfficialAccount:
  47881. m.ResetOfficialAccount()
  47882. return nil
  47883. case wxcard.FieldWechatAccount:
  47884. m.ResetWechatAccount()
  47885. return nil
  47886. case wxcard.FieldEmail:
  47887. m.ResetEmail()
  47888. return nil
  47889. case wxcard.FieldAPIBase:
  47890. m.ResetAPIBase()
  47891. return nil
  47892. case wxcard.FieldAPIKey:
  47893. m.ResetAPIKey()
  47894. return nil
  47895. case wxcard.FieldAiInfo:
  47896. m.ResetAiInfo()
  47897. return nil
  47898. case wxcard.FieldIntro:
  47899. m.ResetIntro()
  47900. return nil
  47901. }
  47902. return fmt.Errorf("unknown WxCard field %s", name)
  47903. }
  47904. // AddedEdges returns all edge names that were set/added in this mutation.
  47905. func (m *WxCardMutation) AddedEdges() []string {
  47906. edges := make([]string, 0, 0)
  47907. return edges
  47908. }
  47909. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  47910. // name in this mutation.
  47911. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  47912. return nil
  47913. }
  47914. // RemovedEdges returns all edge names that were removed in this mutation.
  47915. func (m *WxCardMutation) RemovedEdges() []string {
  47916. edges := make([]string, 0, 0)
  47917. return edges
  47918. }
  47919. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  47920. // the given name in this mutation.
  47921. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  47922. return nil
  47923. }
  47924. // ClearedEdges returns all edge names that were cleared in this mutation.
  47925. func (m *WxCardMutation) ClearedEdges() []string {
  47926. edges := make([]string, 0, 0)
  47927. return edges
  47928. }
  47929. // EdgeCleared returns a boolean which indicates if the edge with the given name
  47930. // was cleared in this mutation.
  47931. func (m *WxCardMutation) EdgeCleared(name string) bool {
  47932. return false
  47933. }
  47934. // ClearEdge clears the value of the edge with the given name. It returns an error
  47935. // if that edge is not defined in the schema.
  47936. func (m *WxCardMutation) ClearEdge(name string) error {
  47937. return fmt.Errorf("unknown WxCard unique edge %s", name)
  47938. }
  47939. // ResetEdge resets all changes to the edge with the given name in this mutation.
  47940. // It returns an error if the edge is not defined in the schema.
  47941. func (m *WxCardMutation) ResetEdge(name string) error {
  47942. return fmt.Errorf("unknown WxCard edge %s", name)
  47943. }
  47944. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  47945. type WxCardUserMutation struct {
  47946. config
  47947. op Op
  47948. typ string
  47949. id *uint64
  47950. created_at *time.Time
  47951. updated_at *time.Time
  47952. deleted_at *time.Time
  47953. wxid *string
  47954. account *string
  47955. avatar *string
  47956. nickname *string
  47957. remark *string
  47958. phone *string
  47959. open_id *string
  47960. union_id *string
  47961. session_key *string
  47962. is_vip *int
  47963. addis_vip *int
  47964. clearedFields map[string]struct{}
  47965. done bool
  47966. oldValue func(context.Context) (*WxCardUser, error)
  47967. predicates []predicate.WxCardUser
  47968. }
  47969. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  47970. // wxcarduserOption allows management of the mutation configuration using functional options.
  47971. type wxcarduserOption func(*WxCardUserMutation)
  47972. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  47973. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  47974. m := &WxCardUserMutation{
  47975. config: c,
  47976. op: op,
  47977. typ: TypeWxCardUser,
  47978. clearedFields: make(map[string]struct{}),
  47979. }
  47980. for _, opt := range opts {
  47981. opt(m)
  47982. }
  47983. return m
  47984. }
  47985. // withWxCardUserID sets the ID field of the mutation.
  47986. func withWxCardUserID(id uint64) wxcarduserOption {
  47987. return func(m *WxCardUserMutation) {
  47988. var (
  47989. err error
  47990. once sync.Once
  47991. value *WxCardUser
  47992. )
  47993. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  47994. once.Do(func() {
  47995. if m.done {
  47996. err = errors.New("querying old values post mutation is not allowed")
  47997. } else {
  47998. value, err = m.Client().WxCardUser.Get(ctx, id)
  47999. }
  48000. })
  48001. return value, err
  48002. }
  48003. m.id = &id
  48004. }
  48005. }
  48006. // withWxCardUser sets the old WxCardUser of the mutation.
  48007. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  48008. return func(m *WxCardUserMutation) {
  48009. m.oldValue = func(context.Context) (*WxCardUser, error) {
  48010. return node, nil
  48011. }
  48012. m.id = &node.ID
  48013. }
  48014. }
  48015. // Client returns a new `ent.Client` from the mutation. If the mutation was
  48016. // executed in a transaction (ent.Tx), a transactional client is returned.
  48017. func (m WxCardUserMutation) Client() *Client {
  48018. client := &Client{config: m.config}
  48019. client.init()
  48020. return client
  48021. }
  48022. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  48023. // it returns an error otherwise.
  48024. func (m WxCardUserMutation) Tx() (*Tx, error) {
  48025. if _, ok := m.driver.(*txDriver); !ok {
  48026. return nil, errors.New("ent: mutation is not running in a transaction")
  48027. }
  48028. tx := &Tx{config: m.config}
  48029. tx.init()
  48030. return tx, nil
  48031. }
  48032. // SetID sets the value of the id field. Note that this
  48033. // operation is only accepted on creation of WxCardUser entities.
  48034. func (m *WxCardUserMutation) SetID(id uint64) {
  48035. m.id = &id
  48036. }
  48037. // ID returns the ID value in the mutation. Note that the ID is only available
  48038. // if it was provided to the builder or after it was returned from the database.
  48039. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  48040. if m.id == nil {
  48041. return
  48042. }
  48043. return *m.id, true
  48044. }
  48045. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  48046. // That means, if the mutation is applied within a transaction with an isolation level such
  48047. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  48048. // or updated by the mutation.
  48049. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  48050. switch {
  48051. case m.op.Is(OpUpdateOne | OpDeleteOne):
  48052. id, exists := m.ID()
  48053. if exists {
  48054. return []uint64{id}, nil
  48055. }
  48056. fallthrough
  48057. case m.op.Is(OpUpdate | OpDelete):
  48058. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  48059. default:
  48060. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  48061. }
  48062. }
  48063. // SetCreatedAt sets the "created_at" field.
  48064. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  48065. m.created_at = &t
  48066. }
  48067. // CreatedAt returns the value of the "created_at" field in the mutation.
  48068. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  48069. v := m.created_at
  48070. if v == nil {
  48071. return
  48072. }
  48073. return *v, true
  48074. }
  48075. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  48076. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  48077. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48078. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  48079. if !m.op.Is(OpUpdateOne) {
  48080. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  48081. }
  48082. if m.id == nil || m.oldValue == nil {
  48083. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  48084. }
  48085. oldValue, err := m.oldValue(ctx)
  48086. if err != nil {
  48087. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  48088. }
  48089. return oldValue.CreatedAt, nil
  48090. }
  48091. // ResetCreatedAt resets all changes to the "created_at" field.
  48092. func (m *WxCardUserMutation) ResetCreatedAt() {
  48093. m.created_at = nil
  48094. }
  48095. // SetUpdatedAt sets the "updated_at" field.
  48096. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  48097. m.updated_at = &t
  48098. }
  48099. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  48100. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  48101. v := m.updated_at
  48102. if v == nil {
  48103. return
  48104. }
  48105. return *v, true
  48106. }
  48107. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  48108. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  48109. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48110. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  48111. if !m.op.Is(OpUpdateOne) {
  48112. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  48113. }
  48114. if m.id == nil || m.oldValue == nil {
  48115. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  48116. }
  48117. oldValue, err := m.oldValue(ctx)
  48118. if err != nil {
  48119. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  48120. }
  48121. return oldValue.UpdatedAt, nil
  48122. }
  48123. // ResetUpdatedAt resets all changes to the "updated_at" field.
  48124. func (m *WxCardUserMutation) ResetUpdatedAt() {
  48125. m.updated_at = nil
  48126. }
  48127. // SetDeletedAt sets the "deleted_at" field.
  48128. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  48129. m.deleted_at = &t
  48130. }
  48131. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  48132. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  48133. v := m.deleted_at
  48134. if v == nil {
  48135. return
  48136. }
  48137. return *v, true
  48138. }
  48139. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  48140. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  48141. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48142. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  48143. if !m.op.Is(OpUpdateOne) {
  48144. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  48145. }
  48146. if m.id == nil || m.oldValue == nil {
  48147. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  48148. }
  48149. oldValue, err := m.oldValue(ctx)
  48150. if err != nil {
  48151. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  48152. }
  48153. return oldValue.DeletedAt, nil
  48154. }
  48155. // ClearDeletedAt clears the value of the "deleted_at" field.
  48156. func (m *WxCardUserMutation) ClearDeletedAt() {
  48157. m.deleted_at = nil
  48158. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  48159. }
  48160. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  48161. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  48162. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  48163. return ok
  48164. }
  48165. // ResetDeletedAt resets all changes to the "deleted_at" field.
  48166. func (m *WxCardUserMutation) ResetDeletedAt() {
  48167. m.deleted_at = nil
  48168. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  48169. }
  48170. // SetWxid sets the "wxid" field.
  48171. func (m *WxCardUserMutation) SetWxid(s string) {
  48172. m.wxid = &s
  48173. }
  48174. // Wxid returns the value of the "wxid" field in the mutation.
  48175. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  48176. v := m.wxid
  48177. if v == nil {
  48178. return
  48179. }
  48180. return *v, true
  48181. }
  48182. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  48183. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  48184. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48185. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  48186. if !m.op.Is(OpUpdateOne) {
  48187. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  48188. }
  48189. if m.id == nil || m.oldValue == nil {
  48190. return v, errors.New("OldWxid requires an ID field in the mutation")
  48191. }
  48192. oldValue, err := m.oldValue(ctx)
  48193. if err != nil {
  48194. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  48195. }
  48196. return oldValue.Wxid, nil
  48197. }
  48198. // ResetWxid resets all changes to the "wxid" field.
  48199. func (m *WxCardUserMutation) ResetWxid() {
  48200. m.wxid = nil
  48201. }
  48202. // SetAccount sets the "account" field.
  48203. func (m *WxCardUserMutation) SetAccount(s string) {
  48204. m.account = &s
  48205. }
  48206. // Account returns the value of the "account" field in the mutation.
  48207. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  48208. v := m.account
  48209. if v == nil {
  48210. return
  48211. }
  48212. return *v, true
  48213. }
  48214. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  48215. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  48216. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48217. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  48218. if !m.op.Is(OpUpdateOne) {
  48219. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  48220. }
  48221. if m.id == nil || m.oldValue == nil {
  48222. return v, errors.New("OldAccount requires an ID field in the mutation")
  48223. }
  48224. oldValue, err := m.oldValue(ctx)
  48225. if err != nil {
  48226. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  48227. }
  48228. return oldValue.Account, nil
  48229. }
  48230. // ResetAccount resets all changes to the "account" field.
  48231. func (m *WxCardUserMutation) ResetAccount() {
  48232. m.account = nil
  48233. }
  48234. // SetAvatar sets the "avatar" field.
  48235. func (m *WxCardUserMutation) SetAvatar(s string) {
  48236. m.avatar = &s
  48237. }
  48238. // Avatar returns the value of the "avatar" field in the mutation.
  48239. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  48240. v := m.avatar
  48241. if v == nil {
  48242. return
  48243. }
  48244. return *v, true
  48245. }
  48246. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  48247. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  48248. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48249. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  48250. if !m.op.Is(OpUpdateOne) {
  48251. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  48252. }
  48253. if m.id == nil || m.oldValue == nil {
  48254. return v, errors.New("OldAvatar requires an ID field in the mutation")
  48255. }
  48256. oldValue, err := m.oldValue(ctx)
  48257. if err != nil {
  48258. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  48259. }
  48260. return oldValue.Avatar, nil
  48261. }
  48262. // ResetAvatar resets all changes to the "avatar" field.
  48263. func (m *WxCardUserMutation) ResetAvatar() {
  48264. m.avatar = nil
  48265. }
  48266. // SetNickname sets the "nickname" field.
  48267. func (m *WxCardUserMutation) SetNickname(s string) {
  48268. m.nickname = &s
  48269. }
  48270. // Nickname returns the value of the "nickname" field in the mutation.
  48271. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  48272. v := m.nickname
  48273. if v == nil {
  48274. return
  48275. }
  48276. return *v, true
  48277. }
  48278. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  48279. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  48280. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48281. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  48282. if !m.op.Is(OpUpdateOne) {
  48283. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  48284. }
  48285. if m.id == nil || m.oldValue == nil {
  48286. return v, errors.New("OldNickname requires an ID field in the mutation")
  48287. }
  48288. oldValue, err := m.oldValue(ctx)
  48289. if err != nil {
  48290. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  48291. }
  48292. return oldValue.Nickname, nil
  48293. }
  48294. // ResetNickname resets all changes to the "nickname" field.
  48295. func (m *WxCardUserMutation) ResetNickname() {
  48296. m.nickname = nil
  48297. }
  48298. // SetRemark sets the "remark" field.
  48299. func (m *WxCardUserMutation) SetRemark(s string) {
  48300. m.remark = &s
  48301. }
  48302. // Remark returns the value of the "remark" field in the mutation.
  48303. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  48304. v := m.remark
  48305. if v == nil {
  48306. return
  48307. }
  48308. return *v, true
  48309. }
  48310. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  48311. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  48312. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48313. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  48314. if !m.op.Is(OpUpdateOne) {
  48315. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  48316. }
  48317. if m.id == nil || m.oldValue == nil {
  48318. return v, errors.New("OldRemark requires an ID field in the mutation")
  48319. }
  48320. oldValue, err := m.oldValue(ctx)
  48321. if err != nil {
  48322. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  48323. }
  48324. return oldValue.Remark, nil
  48325. }
  48326. // ResetRemark resets all changes to the "remark" field.
  48327. func (m *WxCardUserMutation) ResetRemark() {
  48328. m.remark = nil
  48329. }
  48330. // SetPhone sets the "phone" field.
  48331. func (m *WxCardUserMutation) SetPhone(s string) {
  48332. m.phone = &s
  48333. }
  48334. // Phone returns the value of the "phone" field in the mutation.
  48335. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  48336. v := m.phone
  48337. if v == nil {
  48338. return
  48339. }
  48340. return *v, true
  48341. }
  48342. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  48343. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  48344. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48345. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  48346. if !m.op.Is(OpUpdateOne) {
  48347. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  48348. }
  48349. if m.id == nil || m.oldValue == nil {
  48350. return v, errors.New("OldPhone requires an ID field in the mutation")
  48351. }
  48352. oldValue, err := m.oldValue(ctx)
  48353. if err != nil {
  48354. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  48355. }
  48356. return oldValue.Phone, nil
  48357. }
  48358. // ResetPhone resets all changes to the "phone" field.
  48359. func (m *WxCardUserMutation) ResetPhone() {
  48360. m.phone = nil
  48361. }
  48362. // SetOpenID sets the "open_id" field.
  48363. func (m *WxCardUserMutation) SetOpenID(s string) {
  48364. m.open_id = &s
  48365. }
  48366. // OpenID returns the value of the "open_id" field in the mutation.
  48367. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  48368. v := m.open_id
  48369. if v == nil {
  48370. return
  48371. }
  48372. return *v, true
  48373. }
  48374. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  48375. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  48376. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48377. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  48378. if !m.op.Is(OpUpdateOne) {
  48379. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  48380. }
  48381. if m.id == nil || m.oldValue == nil {
  48382. return v, errors.New("OldOpenID requires an ID field in the mutation")
  48383. }
  48384. oldValue, err := m.oldValue(ctx)
  48385. if err != nil {
  48386. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  48387. }
  48388. return oldValue.OpenID, nil
  48389. }
  48390. // ResetOpenID resets all changes to the "open_id" field.
  48391. func (m *WxCardUserMutation) ResetOpenID() {
  48392. m.open_id = nil
  48393. }
  48394. // SetUnionID sets the "union_id" field.
  48395. func (m *WxCardUserMutation) SetUnionID(s string) {
  48396. m.union_id = &s
  48397. }
  48398. // UnionID returns the value of the "union_id" field in the mutation.
  48399. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  48400. v := m.union_id
  48401. if v == nil {
  48402. return
  48403. }
  48404. return *v, true
  48405. }
  48406. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  48407. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  48408. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48409. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  48410. if !m.op.Is(OpUpdateOne) {
  48411. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  48412. }
  48413. if m.id == nil || m.oldValue == nil {
  48414. return v, errors.New("OldUnionID requires an ID field in the mutation")
  48415. }
  48416. oldValue, err := m.oldValue(ctx)
  48417. if err != nil {
  48418. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  48419. }
  48420. return oldValue.UnionID, nil
  48421. }
  48422. // ResetUnionID resets all changes to the "union_id" field.
  48423. func (m *WxCardUserMutation) ResetUnionID() {
  48424. m.union_id = nil
  48425. }
  48426. // SetSessionKey sets the "session_key" field.
  48427. func (m *WxCardUserMutation) SetSessionKey(s string) {
  48428. m.session_key = &s
  48429. }
  48430. // SessionKey returns the value of the "session_key" field in the mutation.
  48431. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  48432. v := m.session_key
  48433. if v == nil {
  48434. return
  48435. }
  48436. return *v, true
  48437. }
  48438. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  48439. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  48440. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48441. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  48442. if !m.op.Is(OpUpdateOne) {
  48443. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  48444. }
  48445. if m.id == nil || m.oldValue == nil {
  48446. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  48447. }
  48448. oldValue, err := m.oldValue(ctx)
  48449. if err != nil {
  48450. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  48451. }
  48452. return oldValue.SessionKey, nil
  48453. }
  48454. // ResetSessionKey resets all changes to the "session_key" field.
  48455. func (m *WxCardUserMutation) ResetSessionKey() {
  48456. m.session_key = nil
  48457. }
  48458. // SetIsVip sets the "is_vip" field.
  48459. func (m *WxCardUserMutation) SetIsVip(i int) {
  48460. m.is_vip = &i
  48461. m.addis_vip = nil
  48462. }
  48463. // IsVip returns the value of the "is_vip" field in the mutation.
  48464. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  48465. v := m.is_vip
  48466. if v == nil {
  48467. return
  48468. }
  48469. return *v, true
  48470. }
  48471. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  48472. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  48473. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48474. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  48475. if !m.op.Is(OpUpdateOne) {
  48476. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  48477. }
  48478. if m.id == nil || m.oldValue == nil {
  48479. return v, errors.New("OldIsVip requires an ID field in the mutation")
  48480. }
  48481. oldValue, err := m.oldValue(ctx)
  48482. if err != nil {
  48483. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  48484. }
  48485. return oldValue.IsVip, nil
  48486. }
  48487. // AddIsVip adds i to the "is_vip" field.
  48488. func (m *WxCardUserMutation) AddIsVip(i int) {
  48489. if m.addis_vip != nil {
  48490. *m.addis_vip += i
  48491. } else {
  48492. m.addis_vip = &i
  48493. }
  48494. }
  48495. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  48496. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  48497. v := m.addis_vip
  48498. if v == nil {
  48499. return
  48500. }
  48501. return *v, true
  48502. }
  48503. // ResetIsVip resets all changes to the "is_vip" field.
  48504. func (m *WxCardUserMutation) ResetIsVip() {
  48505. m.is_vip = nil
  48506. m.addis_vip = nil
  48507. }
  48508. // Where appends a list predicates to the WxCardUserMutation builder.
  48509. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  48510. m.predicates = append(m.predicates, ps...)
  48511. }
  48512. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  48513. // users can use type-assertion to append predicates that do not depend on any generated package.
  48514. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  48515. p := make([]predicate.WxCardUser, len(ps))
  48516. for i := range ps {
  48517. p[i] = ps[i]
  48518. }
  48519. m.Where(p...)
  48520. }
  48521. // Op returns the operation name.
  48522. func (m *WxCardUserMutation) Op() Op {
  48523. return m.op
  48524. }
  48525. // SetOp allows setting the mutation operation.
  48526. func (m *WxCardUserMutation) SetOp(op Op) {
  48527. m.op = op
  48528. }
  48529. // Type returns the node type of this mutation (WxCardUser).
  48530. func (m *WxCardUserMutation) Type() string {
  48531. return m.typ
  48532. }
  48533. // Fields returns all fields that were changed during this mutation. Note that in
  48534. // order to get all numeric fields that were incremented/decremented, call
  48535. // AddedFields().
  48536. func (m *WxCardUserMutation) Fields() []string {
  48537. fields := make([]string, 0, 13)
  48538. if m.created_at != nil {
  48539. fields = append(fields, wxcarduser.FieldCreatedAt)
  48540. }
  48541. if m.updated_at != nil {
  48542. fields = append(fields, wxcarduser.FieldUpdatedAt)
  48543. }
  48544. if m.deleted_at != nil {
  48545. fields = append(fields, wxcarduser.FieldDeletedAt)
  48546. }
  48547. if m.wxid != nil {
  48548. fields = append(fields, wxcarduser.FieldWxid)
  48549. }
  48550. if m.account != nil {
  48551. fields = append(fields, wxcarduser.FieldAccount)
  48552. }
  48553. if m.avatar != nil {
  48554. fields = append(fields, wxcarduser.FieldAvatar)
  48555. }
  48556. if m.nickname != nil {
  48557. fields = append(fields, wxcarduser.FieldNickname)
  48558. }
  48559. if m.remark != nil {
  48560. fields = append(fields, wxcarduser.FieldRemark)
  48561. }
  48562. if m.phone != nil {
  48563. fields = append(fields, wxcarduser.FieldPhone)
  48564. }
  48565. if m.open_id != nil {
  48566. fields = append(fields, wxcarduser.FieldOpenID)
  48567. }
  48568. if m.union_id != nil {
  48569. fields = append(fields, wxcarduser.FieldUnionID)
  48570. }
  48571. if m.session_key != nil {
  48572. fields = append(fields, wxcarduser.FieldSessionKey)
  48573. }
  48574. if m.is_vip != nil {
  48575. fields = append(fields, wxcarduser.FieldIsVip)
  48576. }
  48577. return fields
  48578. }
  48579. // Field returns the value of a field with the given name. The second boolean
  48580. // return value indicates that this field was not set, or was not defined in the
  48581. // schema.
  48582. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  48583. switch name {
  48584. case wxcarduser.FieldCreatedAt:
  48585. return m.CreatedAt()
  48586. case wxcarduser.FieldUpdatedAt:
  48587. return m.UpdatedAt()
  48588. case wxcarduser.FieldDeletedAt:
  48589. return m.DeletedAt()
  48590. case wxcarduser.FieldWxid:
  48591. return m.Wxid()
  48592. case wxcarduser.FieldAccount:
  48593. return m.Account()
  48594. case wxcarduser.FieldAvatar:
  48595. return m.Avatar()
  48596. case wxcarduser.FieldNickname:
  48597. return m.Nickname()
  48598. case wxcarduser.FieldRemark:
  48599. return m.Remark()
  48600. case wxcarduser.FieldPhone:
  48601. return m.Phone()
  48602. case wxcarduser.FieldOpenID:
  48603. return m.OpenID()
  48604. case wxcarduser.FieldUnionID:
  48605. return m.UnionID()
  48606. case wxcarduser.FieldSessionKey:
  48607. return m.SessionKey()
  48608. case wxcarduser.FieldIsVip:
  48609. return m.IsVip()
  48610. }
  48611. return nil, false
  48612. }
  48613. // OldField returns the old value of the field from the database. An error is
  48614. // returned if the mutation operation is not UpdateOne, or the query to the
  48615. // database failed.
  48616. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  48617. switch name {
  48618. case wxcarduser.FieldCreatedAt:
  48619. return m.OldCreatedAt(ctx)
  48620. case wxcarduser.FieldUpdatedAt:
  48621. return m.OldUpdatedAt(ctx)
  48622. case wxcarduser.FieldDeletedAt:
  48623. return m.OldDeletedAt(ctx)
  48624. case wxcarduser.FieldWxid:
  48625. return m.OldWxid(ctx)
  48626. case wxcarduser.FieldAccount:
  48627. return m.OldAccount(ctx)
  48628. case wxcarduser.FieldAvatar:
  48629. return m.OldAvatar(ctx)
  48630. case wxcarduser.FieldNickname:
  48631. return m.OldNickname(ctx)
  48632. case wxcarduser.FieldRemark:
  48633. return m.OldRemark(ctx)
  48634. case wxcarduser.FieldPhone:
  48635. return m.OldPhone(ctx)
  48636. case wxcarduser.FieldOpenID:
  48637. return m.OldOpenID(ctx)
  48638. case wxcarduser.FieldUnionID:
  48639. return m.OldUnionID(ctx)
  48640. case wxcarduser.FieldSessionKey:
  48641. return m.OldSessionKey(ctx)
  48642. case wxcarduser.FieldIsVip:
  48643. return m.OldIsVip(ctx)
  48644. }
  48645. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  48646. }
  48647. // SetField sets the value of a field with the given name. It returns an error if
  48648. // the field is not defined in the schema, or if the type mismatched the field
  48649. // type.
  48650. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  48651. switch name {
  48652. case wxcarduser.FieldCreatedAt:
  48653. v, ok := value.(time.Time)
  48654. if !ok {
  48655. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48656. }
  48657. m.SetCreatedAt(v)
  48658. return nil
  48659. case wxcarduser.FieldUpdatedAt:
  48660. v, ok := value.(time.Time)
  48661. if !ok {
  48662. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48663. }
  48664. m.SetUpdatedAt(v)
  48665. return nil
  48666. case wxcarduser.FieldDeletedAt:
  48667. v, ok := value.(time.Time)
  48668. if !ok {
  48669. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48670. }
  48671. m.SetDeletedAt(v)
  48672. return nil
  48673. case wxcarduser.FieldWxid:
  48674. v, ok := value.(string)
  48675. if !ok {
  48676. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48677. }
  48678. m.SetWxid(v)
  48679. return nil
  48680. case wxcarduser.FieldAccount:
  48681. v, ok := value.(string)
  48682. if !ok {
  48683. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48684. }
  48685. m.SetAccount(v)
  48686. return nil
  48687. case wxcarduser.FieldAvatar:
  48688. v, ok := value.(string)
  48689. if !ok {
  48690. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48691. }
  48692. m.SetAvatar(v)
  48693. return nil
  48694. case wxcarduser.FieldNickname:
  48695. v, ok := value.(string)
  48696. if !ok {
  48697. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48698. }
  48699. m.SetNickname(v)
  48700. return nil
  48701. case wxcarduser.FieldRemark:
  48702. v, ok := value.(string)
  48703. if !ok {
  48704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48705. }
  48706. m.SetRemark(v)
  48707. return nil
  48708. case wxcarduser.FieldPhone:
  48709. v, ok := value.(string)
  48710. if !ok {
  48711. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48712. }
  48713. m.SetPhone(v)
  48714. return nil
  48715. case wxcarduser.FieldOpenID:
  48716. v, ok := value.(string)
  48717. if !ok {
  48718. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48719. }
  48720. m.SetOpenID(v)
  48721. return nil
  48722. case wxcarduser.FieldUnionID:
  48723. v, ok := value.(string)
  48724. if !ok {
  48725. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48726. }
  48727. m.SetUnionID(v)
  48728. return nil
  48729. case wxcarduser.FieldSessionKey:
  48730. v, ok := value.(string)
  48731. if !ok {
  48732. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48733. }
  48734. m.SetSessionKey(v)
  48735. return nil
  48736. case wxcarduser.FieldIsVip:
  48737. v, ok := value.(int)
  48738. if !ok {
  48739. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48740. }
  48741. m.SetIsVip(v)
  48742. return nil
  48743. }
  48744. return fmt.Errorf("unknown WxCardUser field %s", name)
  48745. }
  48746. // AddedFields returns all numeric fields that were incremented/decremented during
  48747. // this mutation.
  48748. func (m *WxCardUserMutation) AddedFields() []string {
  48749. var fields []string
  48750. if m.addis_vip != nil {
  48751. fields = append(fields, wxcarduser.FieldIsVip)
  48752. }
  48753. return fields
  48754. }
  48755. // AddedField returns the numeric value that was incremented/decremented on a field
  48756. // with the given name. The second boolean return value indicates that this field
  48757. // was not set, or was not defined in the schema.
  48758. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  48759. switch name {
  48760. case wxcarduser.FieldIsVip:
  48761. return m.AddedIsVip()
  48762. }
  48763. return nil, false
  48764. }
  48765. // AddField adds the value to the field with the given name. It returns an error if
  48766. // the field is not defined in the schema, or if the type mismatched the field
  48767. // type.
  48768. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  48769. switch name {
  48770. case wxcarduser.FieldIsVip:
  48771. v, ok := value.(int)
  48772. if !ok {
  48773. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48774. }
  48775. m.AddIsVip(v)
  48776. return nil
  48777. }
  48778. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  48779. }
  48780. // ClearedFields returns all nullable fields that were cleared during this
  48781. // mutation.
  48782. func (m *WxCardUserMutation) ClearedFields() []string {
  48783. var fields []string
  48784. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  48785. fields = append(fields, wxcarduser.FieldDeletedAt)
  48786. }
  48787. return fields
  48788. }
  48789. // FieldCleared returns a boolean indicating if a field with the given name was
  48790. // cleared in this mutation.
  48791. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  48792. _, ok := m.clearedFields[name]
  48793. return ok
  48794. }
  48795. // ClearField clears the value of the field with the given name. It returns an
  48796. // error if the field is not defined in the schema.
  48797. func (m *WxCardUserMutation) ClearField(name string) error {
  48798. switch name {
  48799. case wxcarduser.FieldDeletedAt:
  48800. m.ClearDeletedAt()
  48801. return nil
  48802. }
  48803. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  48804. }
  48805. // ResetField resets all changes in the mutation for the field with the given name.
  48806. // It returns an error if the field is not defined in the schema.
  48807. func (m *WxCardUserMutation) ResetField(name string) error {
  48808. switch name {
  48809. case wxcarduser.FieldCreatedAt:
  48810. m.ResetCreatedAt()
  48811. return nil
  48812. case wxcarduser.FieldUpdatedAt:
  48813. m.ResetUpdatedAt()
  48814. return nil
  48815. case wxcarduser.FieldDeletedAt:
  48816. m.ResetDeletedAt()
  48817. return nil
  48818. case wxcarduser.FieldWxid:
  48819. m.ResetWxid()
  48820. return nil
  48821. case wxcarduser.FieldAccount:
  48822. m.ResetAccount()
  48823. return nil
  48824. case wxcarduser.FieldAvatar:
  48825. m.ResetAvatar()
  48826. return nil
  48827. case wxcarduser.FieldNickname:
  48828. m.ResetNickname()
  48829. return nil
  48830. case wxcarduser.FieldRemark:
  48831. m.ResetRemark()
  48832. return nil
  48833. case wxcarduser.FieldPhone:
  48834. m.ResetPhone()
  48835. return nil
  48836. case wxcarduser.FieldOpenID:
  48837. m.ResetOpenID()
  48838. return nil
  48839. case wxcarduser.FieldUnionID:
  48840. m.ResetUnionID()
  48841. return nil
  48842. case wxcarduser.FieldSessionKey:
  48843. m.ResetSessionKey()
  48844. return nil
  48845. case wxcarduser.FieldIsVip:
  48846. m.ResetIsVip()
  48847. return nil
  48848. }
  48849. return fmt.Errorf("unknown WxCardUser field %s", name)
  48850. }
  48851. // AddedEdges returns all edge names that were set/added in this mutation.
  48852. func (m *WxCardUserMutation) AddedEdges() []string {
  48853. edges := make([]string, 0, 0)
  48854. return edges
  48855. }
  48856. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  48857. // name in this mutation.
  48858. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  48859. return nil
  48860. }
  48861. // RemovedEdges returns all edge names that were removed in this mutation.
  48862. func (m *WxCardUserMutation) RemovedEdges() []string {
  48863. edges := make([]string, 0, 0)
  48864. return edges
  48865. }
  48866. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  48867. // the given name in this mutation.
  48868. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  48869. return nil
  48870. }
  48871. // ClearedEdges returns all edge names that were cleared in this mutation.
  48872. func (m *WxCardUserMutation) ClearedEdges() []string {
  48873. edges := make([]string, 0, 0)
  48874. return edges
  48875. }
  48876. // EdgeCleared returns a boolean which indicates if the edge with the given name
  48877. // was cleared in this mutation.
  48878. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  48879. return false
  48880. }
  48881. // ClearEdge clears the value of the edge with the given name. It returns an error
  48882. // if that edge is not defined in the schema.
  48883. func (m *WxCardUserMutation) ClearEdge(name string) error {
  48884. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  48885. }
  48886. // ResetEdge resets all changes to the edge with the given name in this mutation.
  48887. // It returns an error if the edge is not defined in the schema.
  48888. func (m *WxCardUserMutation) ResetEdge(name string) error {
  48889. return fmt.Errorf("unknown WxCardUser edge %s", name)
  48890. }
  48891. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  48892. type WxCardVisitMutation struct {
  48893. config
  48894. op Op
  48895. typ string
  48896. id *uint64
  48897. created_at *time.Time
  48898. updated_at *time.Time
  48899. deleted_at *time.Time
  48900. user_id *uint64
  48901. adduser_id *int64
  48902. bot_id *uint64
  48903. addbot_id *int64
  48904. bot_type *uint8
  48905. addbot_type *int8
  48906. clearedFields map[string]struct{}
  48907. done bool
  48908. oldValue func(context.Context) (*WxCardVisit, error)
  48909. predicates []predicate.WxCardVisit
  48910. }
  48911. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  48912. // wxcardvisitOption allows management of the mutation configuration using functional options.
  48913. type wxcardvisitOption func(*WxCardVisitMutation)
  48914. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  48915. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  48916. m := &WxCardVisitMutation{
  48917. config: c,
  48918. op: op,
  48919. typ: TypeWxCardVisit,
  48920. clearedFields: make(map[string]struct{}),
  48921. }
  48922. for _, opt := range opts {
  48923. opt(m)
  48924. }
  48925. return m
  48926. }
  48927. // withWxCardVisitID sets the ID field of the mutation.
  48928. func withWxCardVisitID(id uint64) wxcardvisitOption {
  48929. return func(m *WxCardVisitMutation) {
  48930. var (
  48931. err error
  48932. once sync.Once
  48933. value *WxCardVisit
  48934. )
  48935. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  48936. once.Do(func() {
  48937. if m.done {
  48938. err = errors.New("querying old values post mutation is not allowed")
  48939. } else {
  48940. value, err = m.Client().WxCardVisit.Get(ctx, id)
  48941. }
  48942. })
  48943. return value, err
  48944. }
  48945. m.id = &id
  48946. }
  48947. }
  48948. // withWxCardVisit sets the old WxCardVisit of the mutation.
  48949. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  48950. return func(m *WxCardVisitMutation) {
  48951. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  48952. return node, nil
  48953. }
  48954. m.id = &node.ID
  48955. }
  48956. }
  48957. // Client returns a new `ent.Client` from the mutation. If the mutation was
  48958. // executed in a transaction (ent.Tx), a transactional client is returned.
  48959. func (m WxCardVisitMutation) Client() *Client {
  48960. client := &Client{config: m.config}
  48961. client.init()
  48962. return client
  48963. }
  48964. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  48965. // it returns an error otherwise.
  48966. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  48967. if _, ok := m.driver.(*txDriver); !ok {
  48968. return nil, errors.New("ent: mutation is not running in a transaction")
  48969. }
  48970. tx := &Tx{config: m.config}
  48971. tx.init()
  48972. return tx, nil
  48973. }
  48974. // SetID sets the value of the id field. Note that this
  48975. // operation is only accepted on creation of WxCardVisit entities.
  48976. func (m *WxCardVisitMutation) SetID(id uint64) {
  48977. m.id = &id
  48978. }
  48979. // ID returns the ID value in the mutation. Note that the ID is only available
  48980. // if it was provided to the builder or after it was returned from the database.
  48981. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  48982. if m.id == nil {
  48983. return
  48984. }
  48985. return *m.id, true
  48986. }
  48987. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  48988. // That means, if the mutation is applied within a transaction with an isolation level such
  48989. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  48990. // or updated by the mutation.
  48991. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  48992. switch {
  48993. case m.op.Is(OpUpdateOne | OpDeleteOne):
  48994. id, exists := m.ID()
  48995. if exists {
  48996. return []uint64{id}, nil
  48997. }
  48998. fallthrough
  48999. case m.op.Is(OpUpdate | OpDelete):
  49000. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  49001. default:
  49002. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  49003. }
  49004. }
  49005. // SetCreatedAt sets the "created_at" field.
  49006. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  49007. m.created_at = &t
  49008. }
  49009. // CreatedAt returns the value of the "created_at" field in the mutation.
  49010. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  49011. v := m.created_at
  49012. if v == nil {
  49013. return
  49014. }
  49015. return *v, true
  49016. }
  49017. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  49018. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  49019. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49020. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  49021. if !m.op.Is(OpUpdateOne) {
  49022. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  49023. }
  49024. if m.id == nil || m.oldValue == nil {
  49025. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  49026. }
  49027. oldValue, err := m.oldValue(ctx)
  49028. if err != nil {
  49029. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  49030. }
  49031. return oldValue.CreatedAt, nil
  49032. }
  49033. // ResetCreatedAt resets all changes to the "created_at" field.
  49034. func (m *WxCardVisitMutation) ResetCreatedAt() {
  49035. m.created_at = nil
  49036. }
  49037. // SetUpdatedAt sets the "updated_at" field.
  49038. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  49039. m.updated_at = &t
  49040. }
  49041. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  49042. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  49043. v := m.updated_at
  49044. if v == nil {
  49045. return
  49046. }
  49047. return *v, true
  49048. }
  49049. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  49050. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  49051. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49052. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  49053. if !m.op.Is(OpUpdateOne) {
  49054. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  49055. }
  49056. if m.id == nil || m.oldValue == nil {
  49057. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  49058. }
  49059. oldValue, err := m.oldValue(ctx)
  49060. if err != nil {
  49061. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  49062. }
  49063. return oldValue.UpdatedAt, nil
  49064. }
  49065. // ResetUpdatedAt resets all changes to the "updated_at" field.
  49066. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  49067. m.updated_at = nil
  49068. }
  49069. // SetDeletedAt sets the "deleted_at" field.
  49070. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  49071. m.deleted_at = &t
  49072. }
  49073. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  49074. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  49075. v := m.deleted_at
  49076. if v == nil {
  49077. return
  49078. }
  49079. return *v, true
  49080. }
  49081. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  49082. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  49083. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49084. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  49085. if !m.op.Is(OpUpdateOne) {
  49086. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  49087. }
  49088. if m.id == nil || m.oldValue == nil {
  49089. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  49090. }
  49091. oldValue, err := m.oldValue(ctx)
  49092. if err != nil {
  49093. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  49094. }
  49095. return oldValue.DeletedAt, nil
  49096. }
  49097. // ClearDeletedAt clears the value of the "deleted_at" field.
  49098. func (m *WxCardVisitMutation) ClearDeletedAt() {
  49099. m.deleted_at = nil
  49100. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  49101. }
  49102. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  49103. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  49104. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  49105. return ok
  49106. }
  49107. // ResetDeletedAt resets all changes to the "deleted_at" field.
  49108. func (m *WxCardVisitMutation) ResetDeletedAt() {
  49109. m.deleted_at = nil
  49110. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  49111. }
  49112. // SetUserID sets the "user_id" field.
  49113. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  49114. m.user_id = &u
  49115. m.adduser_id = nil
  49116. }
  49117. // UserID returns the value of the "user_id" field in the mutation.
  49118. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  49119. v := m.user_id
  49120. if v == nil {
  49121. return
  49122. }
  49123. return *v, true
  49124. }
  49125. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  49126. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  49127. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49128. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  49129. if !m.op.Is(OpUpdateOne) {
  49130. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  49131. }
  49132. if m.id == nil || m.oldValue == nil {
  49133. return v, errors.New("OldUserID requires an ID field in the mutation")
  49134. }
  49135. oldValue, err := m.oldValue(ctx)
  49136. if err != nil {
  49137. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  49138. }
  49139. return oldValue.UserID, nil
  49140. }
  49141. // AddUserID adds u to the "user_id" field.
  49142. func (m *WxCardVisitMutation) AddUserID(u int64) {
  49143. if m.adduser_id != nil {
  49144. *m.adduser_id += u
  49145. } else {
  49146. m.adduser_id = &u
  49147. }
  49148. }
  49149. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  49150. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  49151. v := m.adduser_id
  49152. if v == nil {
  49153. return
  49154. }
  49155. return *v, true
  49156. }
  49157. // ClearUserID clears the value of the "user_id" field.
  49158. func (m *WxCardVisitMutation) ClearUserID() {
  49159. m.user_id = nil
  49160. m.adduser_id = nil
  49161. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  49162. }
  49163. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  49164. func (m *WxCardVisitMutation) UserIDCleared() bool {
  49165. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  49166. return ok
  49167. }
  49168. // ResetUserID resets all changes to the "user_id" field.
  49169. func (m *WxCardVisitMutation) ResetUserID() {
  49170. m.user_id = nil
  49171. m.adduser_id = nil
  49172. delete(m.clearedFields, wxcardvisit.FieldUserID)
  49173. }
  49174. // SetBotID sets the "bot_id" field.
  49175. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  49176. m.bot_id = &u
  49177. m.addbot_id = nil
  49178. }
  49179. // BotID returns the value of the "bot_id" field in the mutation.
  49180. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  49181. v := m.bot_id
  49182. if v == nil {
  49183. return
  49184. }
  49185. return *v, true
  49186. }
  49187. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  49188. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  49189. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49190. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  49191. if !m.op.Is(OpUpdateOne) {
  49192. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  49193. }
  49194. if m.id == nil || m.oldValue == nil {
  49195. return v, errors.New("OldBotID requires an ID field in the mutation")
  49196. }
  49197. oldValue, err := m.oldValue(ctx)
  49198. if err != nil {
  49199. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  49200. }
  49201. return oldValue.BotID, nil
  49202. }
  49203. // AddBotID adds u to the "bot_id" field.
  49204. func (m *WxCardVisitMutation) AddBotID(u int64) {
  49205. if m.addbot_id != nil {
  49206. *m.addbot_id += u
  49207. } else {
  49208. m.addbot_id = &u
  49209. }
  49210. }
  49211. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  49212. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  49213. v := m.addbot_id
  49214. if v == nil {
  49215. return
  49216. }
  49217. return *v, true
  49218. }
  49219. // ResetBotID resets all changes to the "bot_id" field.
  49220. func (m *WxCardVisitMutation) ResetBotID() {
  49221. m.bot_id = nil
  49222. m.addbot_id = nil
  49223. }
  49224. // SetBotType sets the "bot_type" field.
  49225. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  49226. m.bot_type = &u
  49227. m.addbot_type = nil
  49228. }
  49229. // BotType returns the value of the "bot_type" field in the mutation.
  49230. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  49231. v := m.bot_type
  49232. if v == nil {
  49233. return
  49234. }
  49235. return *v, true
  49236. }
  49237. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  49238. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  49239. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49240. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  49241. if !m.op.Is(OpUpdateOne) {
  49242. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  49243. }
  49244. if m.id == nil || m.oldValue == nil {
  49245. return v, errors.New("OldBotType requires an ID field in the mutation")
  49246. }
  49247. oldValue, err := m.oldValue(ctx)
  49248. if err != nil {
  49249. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  49250. }
  49251. return oldValue.BotType, nil
  49252. }
  49253. // AddBotType adds u to the "bot_type" field.
  49254. func (m *WxCardVisitMutation) AddBotType(u int8) {
  49255. if m.addbot_type != nil {
  49256. *m.addbot_type += u
  49257. } else {
  49258. m.addbot_type = &u
  49259. }
  49260. }
  49261. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  49262. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  49263. v := m.addbot_type
  49264. if v == nil {
  49265. return
  49266. }
  49267. return *v, true
  49268. }
  49269. // ResetBotType resets all changes to the "bot_type" field.
  49270. func (m *WxCardVisitMutation) ResetBotType() {
  49271. m.bot_type = nil
  49272. m.addbot_type = nil
  49273. }
  49274. // Where appends a list predicates to the WxCardVisitMutation builder.
  49275. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  49276. m.predicates = append(m.predicates, ps...)
  49277. }
  49278. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  49279. // users can use type-assertion to append predicates that do not depend on any generated package.
  49280. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  49281. p := make([]predicate.WxCardVisit, len(ps))
  49282. for i := range ps {
  49283. p[i] = ps[i]
  49284. }
  49285. m.Where(p...)
  49286. }
  49287. // Op returns the operation name.
  49288. func (m *WxCardVisitMutation) Op() Op {
  49289. return m.op
  49290. }
  49291. // SetOp allows setting the mutation operation.
  49292. func (m *WxCardVisitMutation) SetOp(op Op) {
  49293. m.op = op
  49294. }
  49295. // Type returns the node type of this mutation (WxCardVisit).
  49296. func (m *WxCardVisitMutation) Type() string {
  49297. return m.typ
  49298. }
  49299. // Fields returns all fields that were changed during this mutation. Note that in
  49300. // order to get all numeric fields that were incremented/decremented, call
  49301. // AddedFields().
  49302. func (m *WxCardVisitMutation) Fields() []string {
  49303. fields := make([]string, 0, 6)
  49304. if m.created_at != nil {
  49305. fields = append(fields, wxcardvisit.FieldCreatedAt)
  49306. }
  49307. if m.updated_at != nil {
  49308. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  49309. }
  49310. if m.deleted_at != nil {
  49311. fields = append(fields, wxcardvisit.FieldDeletedAt)
  49312. }
  49313. if m.user_id != nil {
  49314. fields = append(fields, wxcardvisit.FieldUserID)
  49315. }
  49316. if m.bot_id != nil {
  49317. fields = append(fields, wxcardvisit.FieldBotID)
  49318. }
  49319. if m.bot_type != nil {
  49320. fields = append(fields, wxcardvisit.FieldBotType)
  49321. }
  49322. return fields
  49323. }
  49324. // Field returns the value of a field with the given name. The second boolean
  49325. // return value indicates that this field was not set, or was not defined in the
  49326. // schema.
  49327. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  49328. switch name {
  49329. case wxcardvisit.FieldCreatedAt:
  49330. return m.CreatedAt()
  49331. case wxcardvisit.FieldUpdatedAt:
  49332. return m.UpdatedAt()
  49333. case wxcardvisit.FieldDeletedAt:
  49334. return m.DeletedAt()
  49335. case wxcardvisit.FieldUserID:
  49336. return m.UserID()
  49337. case wxcardvisit.FieldBotID:
  49338. return m.BotID()
  49339. case wxcardvisit.FieldBotType:
  49340. return m.BotType()
  49341. }
  49342. return nil, false
  49343. }
  49344. // OldField returns the old value of the field from the database. An error is
  49345. // returned if the mutation operation is not UpdateOne, or the query to the
  49346. // database failed.
  49347. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  49348. switch name {
  49349. case wxcardvisit.FieldCreatedAt:
  49350. return m.OldCreatedAt(ctx)
  49351. case wxcardvisit.FieldUpdatedAt:
  49352. return m.OldUpdatedAt(ctx)
  49353. case wxcardvisit.FieldDeletedAt:
  49354. return m.OldDeletedAt(ctx)
  49355. case wxcardvisit.FieldUserID:
  49356. return m.OldUserID(ctx)
  49357. case wxcardvisit.FieldBotID:
  49358. return m.OldBotID(ctx)
  49359. case wxcardvisit.FieldBotType:
  49360. return m.OldBotType(ctx)
  49361. }
  49362. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  49363. }
  49364. // SetField sets the value of a field with the given name. It returns an error if
  49365. // the field is not defined in the schema, or if the type mismatched the field
  49366. // type.
  49367. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  49368. switch name {
  49369. case wxcardvisit.FieldCreatedAt:
  49370. v, ok := value.(time.Time)
  49371. if !ok {
  49372. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49373. }
  49374. m.SetCreatedAt(v)
  49375. return nil
  49376. case wxcardvisit.FieldUpdatedAt:
  49377. v, ok := value.(time.Time)
  49378. if !ok {
  49379. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49380. }
  49381. m.SetUpdatedAt(v)
  49382. return nil
  49383. case wxcardvisit.FieldDeletedAt:
  49384. v, ok := value.(time.Time)
  49385. if !ok {
  49386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49387. }
  49388. m.SetDeletedAt(v)
  49389. return nil
  49390. case wxcardvisit.FieldUserID:
  49391. v, ok := value.(uint64)
  49392. if !ok {
  49393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49394. }
  49395. m.SetUserID(v)
  49396. return nil
  49397. case wxcardvisit.FieldBotID:
  49398. v, ok := value.(uint64)
  49399. if !ok {
  49400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49401. }
  49402. m.SetBotID(v)
  49403. return nil
  49404. case wxcardvisit.FieldBotType:
  49405. v, ok := value.(uint8)
  49406. if !ok {
  49407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49408. }
  49409. m.SetBotType(v)
  49410. return nil
  49411. }
  49412. return fmt.Errorf("unknown WxCardVisit field %s", name)
  49413. }
  49414. // AddedFields returns all numeric fields that were incremented/decremented during
  49415. // this mutation.
  49416. func (m *WxCardVisitMutation) AddedFields() []string {
  49417. var fields []string
  49418. if m.adduser_id != nil {
  49419. fields = append(fields, wxcardvisit.FieldUserID)
  49420. }
  49421. if m.addbot_id != nil {
  49422. fields = append(fields, wxcardvisit.FieldBotID)
  49423. }
  49424. if m.addbot_type != nil {
  49425. fields = append(fields, wxcardvisit.FieldBotType)
  49426. }
  49427. return fields
  49428. }
  49429. // AddedField returns the numeric value that was incremented/decremented on a field
  49430. // with the given name. The second boolean return value indicates that this field
  49431. // was not set, or was not defined in the schema.
  49432. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  49433. switch name {
  49434. case wxcardvisit.FieldUserID:
  49435. return m.AddedUserID()
  49436. case wxcardvisit.FieldBotID:
  49437. return m.AddedBotID()
  49438. case wxcardvisit.FieldBotType:
  49439. return m.AddedBotType()
  49440. }
  49441. return nil, false
  49442. }
  49443. // AddField adds the value to the field with the given name. It returns an error if
  49444. // the field is not defined in the schema, or if the type mismatched the field
  49445. // type.
  49446. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  49447. switch name {
  49448. case wxcardvisit.FieldUserID:
  49449. v, ok := value.(int64)
  49450. if !ok {
  49451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49452. }
  49453. m.AddUserID(v)
  49454. return nil
  49455. case wxcardvisit.FieldBotID:
  49456. v, ok := value.(int64)
  49457. if !ok {
  49458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49459. }
  49460. m.AddBotID(v)
  49461. return nil
  49462. case wxcardvisit.FieldBotType:
  49463. v, ok := value.(int8)
  49464. if !ok {
  49465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49466. }
  49467. m.AddBotType(v)
  49468. return nil
  49469. }
  49470. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  49471. }
  49472. // ClearedFields returns all nullable fields that were cleared during this
  49473. // mutation.
  49474. func (m *WxCardVisitMutation) ClearedFields() []string {
  49475. var fields []string
  49476. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  49477. fields = append(fields, wxcardvisit.FieldDeletedAt)
  49478. }
  49479. if m.FieldCleared(wxcardvisit.FieldUserID) {
  49480. fields = append(fields, wxcardvisit.FieldUserID)
  49481. }
  49482. return fields
  49483. }
  49484. // FieldCleared returns a boolean indicating if a field with the given name was
  49485. // cleared in this mutation.
  49486. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  49487. _, ok := m.clearedFields[name]
  49488. return ok
  49489. }
  49490. // ClearField clears the value of the field with the given name. It returns an
  49491. // error if the field is not defined in the schema.
  49492. func (m *WxCardVisitMutation) ClearField(name string) error {
  49493. switch name {
  49494. case wxcardvisit.FieldDeletedAt:
  49495. m.ClearDeletedAt()
  49496. return nil
  49497. case wxcardvisit.FieldUserID:
  49498. m.ClearUserID()
  49499. return nil
  49500. }
  49501. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  49502. }
  49503. // ResetField resets all changes in the mutation for the field with the given name.
  49504. // It returns an error if the field is not defined in the schema.
  49505. func (m *WxCardVisitMutation) ResetField(name string) error {
  49506. switch name {
  49507. case wxcardvisit.FieldCreatedAt:
  49508. m.ResetCreatedAt()
  49509. return nil
  49510. case wxcardvisit.FieldUpdatedAt:
  49511. m.ResetUpdatedAt()
  49512. return nil
  49513. case wxcardvisit.FieldDeletedAt:
  49514. m.ResetDeletedAt()
  49515. return nil
  49516. case wxcardvisit.FieldUserID:
  49517. m.ResetUserID()
  49518. return nil
  49519. case wxcardvisit.FieldBotID:
  49520. m.ResetBotID()
  49521. return nil
  49522. case wxcardvisit.FieldBotType:
  49523. m.ResetBotType()
  49524. return nil
  49525. }
  49526. return fmt.Errorf("unknown WxCardVisit field %s", name)
  49527. }
  49528. // AddedEdges returns all edge names that were set/added in this mutation.
  49529. func (m *WxCardVisitMutation) AddedEdges() []string {
  49530. edges := make([]string, 0, 0)
  49531. return edges
  49532. }
  49533. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  49534. // name in this mutation.
  49535. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  49536. return nil
  49537. }
  49538. // RemovedEdges returns all edge names that were removed in this mutation.
  49539. func (m *WxCardVisitMutation) RemovedEdges() []string {
  49540. edges := make([]string, 0, 0)
  49541. return edges
  49542. }
  49543. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  49544. // the given name in this mutation.
  49545. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  49546. return nil
  49547. }
  49548. // ClearedEdges returns all edge names that were cleared in this mutation.
  49549. func (m *WxCardVisitMutation) ClearedEdges() []string {
  49550. edges := make([]string, 0, 0)
  49551. return edges
  49552. }
  49553. // EdgeCleared returns a boolean which indicates if the edge with the given name
  49554. // was cleared in this mutation.
  49555. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  49556. return false
  49557. }
  49558. // ClearEdge clears the value of the edge with the given name. It returns an error
  49559. // if that edge is not defined in the schema.
  49560. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  49561. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  49562. }
  49563. // ResetEdge resets all changes to the edge with the given name in this mutation.
  49564. // It returns an error if the edge is not defined in the schema.
  49565. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  49566. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  49567. }
  49568. // XunjiMutation represents an operation that mutates the Xunji nodes in the graph.
  49569. type XunjiMutation struct {
  49570. config
  49571. op Op
  49572. typ string
  49573. id *uint64
  49574. created_at *time.Time
  49575. updated_at *time.Time
  49576. status *uint8
  49577. addstatus *int8
  49578. deleted_at *time.Time
  49579. app_key *string
  49580. app_secret *string
  49581. token *string
  49582. encoding_key *string
  49583. organization_id *uint64
  49584. addorganization_id *int64
  49585. clearedFields map[string]struct{}
  49586. done bool
  49587. oldValue func(context.Context) (*Xunji, error)
  49588. predicates []predicate.Xunji
  49589. }
  49590. var _ ent.Mutation = (*XunjiMutation)(nil)
  49591. // xunjiOption allows management of the mutation configuration using functional options.
  49592. type xunjiOption func(*XunjiMutation)
  49593. // newXunjiMutation creates new mutation for the Xunji entity.
  49594. func newXunjiMutation(c config, op Op, opts ...xunjiOption) *XunjiMutation {
  49595. m := &XunjiMutation{
  49596. config: c,
  49597. op: op,
  49598. typ: TypeXunji,
  49599. clearedFields: make(map[string]struct{}),
  49600. }
  49601. for _, opt := range opts {
  49602. opt(m)
  49603. }
  49604. return m
  49605. }
  49606. // withXunjiID sets the ID field of the mutation.
  49607. func withXunjiID(id uint64) xunjiOption {
  49608. return func(m *XunjiMutation) {
  49609. var (
  49610. err error
  49611. once sync.Once
  49612. value *Xunji
  49613. )
  49614. m.oldValue = func(ctx context.Context) (*Xunji, error) {
  49615. once.Do(func() {
  49616. if m.done {
  49617. err = errors.New("querying old values post mutation is not allowed")
  49618. } else {
  49619. value, err = m.Client().Xunji.Get(ctx, id)
  49620. }
  49621. })
  49622. return value, err
  49623. }
  49624. m.id = &id
  49625. }
  49626. }
  49627. // withXunji sets the old Xunji of the mutation.
  49628. func withXunji(node *Xunji) xunjiOption {
  49629. return func(m *XunjiMutation) {
  49630. m.oldValue = func(context.Context) (*Xunji, error) {
  49631. return node, nil
  49632. }
  49633. m.id = &node.ID
  49634. }
  49635. }
  49636. // Client returns a new `ent.Client` from the mutation. If the mutation was
  49637. // executed in a transaction (ent.Tx), a transactional client is returned.
  49638. func (m XunjiMutation) Client() *Client {
  49639. client := &Client{config: m.config}
  49640. client.init()
  49641. return client
  49642. }
  49643. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  49644. // it returns an error otherwise.
  49645. func (m XunjiMutation) Tx() (*Tx, error) {
  49646. if _, ok := m.driver.(*txDriver); !ok {
  49647. return nil, errors.New("ent: mutation is not running in a transaction")
  49648. }
  49649. tx := &Tx{config: m.config}
  49650. tx.init()
  49651. return tx, nil
  49652. }
  49653. // SetID sets the value of the id field. Note that this
  49654. // operation is only accepted on creation of Xunji entities.
  49655. func (m *XunjiMutation) SetID(id uint64) {
  49656. m.id = &id
  49657. }
  49658. // ID returns the ID value in the mutation. Note that the ID is only available
  49659. // if it was provided to the builder or after it was returned from the database.
  49660. func (m *XunjiMutation) ID() (id uint64, exists bool) {
  49661. if m.id == nil {
  49662. return
  49663. }
  49664. return *m.id, true
  49665. }
  49666. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  49667. // That means, if the mutation is applied within a transaction with an isolation level such
  49668. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  49669. // or updated by the mutation.
  49670. func (m *XunjiMutation) IDs(ctx context.Context) ([]uint64, error) {
  49671. switch {
  49672. case m.op.Is(OpUpdateOne | OpDeleteOne):
  49673. id, exists := m.ID()
  49674. if exists {
  49675. return []uint64{id}, nil
  49676. }
  49677. fallthrough
  49678. case m.op.Is(OpUpdate | OpDelete):
  49679. return m.Client().Xunji.Query().Where(m.predicates...).IDs(ctx)
  49680. default:
  49681. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  49682. }
  49683. }
  49684. // SetCreatedAt sets the "created_at" field.
  49685. func (m *XunjiMutation) SetCreatedAt(t time.Time) {
  49686. m.created_at = &t
  49687. }
  49688. // CreatedAt returns the value of the "created_at" field in the mutation.
  49689. func (m *XunjiMutation) CreatedAt() (r time.Time, exists bool) {
  49690. v := m.created_at
  49691. if v == nil {
  49692. return
  49693. }
  49694. return *v, true
  49695. }
  49696. // OldCreatedAt returns the old "created_at" field's value of the Xunji entity.
  49697. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  49698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49699. func (m *XunjiMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  49700. if !m.op.Is(OpUpdateOne) {
  49701. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  49702. }
  49703. if m.id == nil || m.oldValue == nil {
  49704. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  49705. }
  49706. oldValue, err := m.oldValue(ctx)
  49707. if err != nil {
  49708. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  49709. }
  49710. return oldValue.CreatedAt, nil
  49711. }
  49712. // ResetCreatedAt resets all changes to the "created_at" field.
  49713. func (m *XunjiMutation) ResetCreatedAt() {
  49714. m.created_at = nil
  49715. }
  49716. // SetUpdatedAt sets the "updated_at" field.
  49717. func (m *XunjiMutation) SetUpdatedAt(t time.Time) {
  49718. m.updated_at = &t
  49719. }
  49720. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  49721. func (m *XunjiMutation) UpdatedAt() (r time.Time, exists bool) {
  49722. v := m.updated_at
  49723. if v == nil {
  49724. return
  49725. }
  49726. return *v, true
  49727. }
  49728. // OldUpdatedAt returns the old "updated_at" field's value of the Xunji entity.
  49729. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  49730. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49731. func (m *XunjiMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  49732. if !m.op.Is(OpUpdateOne) {
  49733. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  49734. }
  49735. if m.id == nil || m.oldValue == nil {
  49736. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  49737. }
  49738. oldValue, err := m.oldValue(ctx)
  49739. if err != nil {
  49740. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  49741. }
  49742. return oldValue.UpdatedAt, nil
  49743. }
  49744. // ResetUpdatedAt resets all changes to the "updated_at" field.
  49745. func (m *XunjiMutation) ResetUpdatedAt() {
  49746. m.updated_at = nil
  49747. }
  49748. // SetStatus sets the "status" field.
  49749. func (m *XunjiMutation) SetStatus(u uint8) {
  49750. m.status = &u
  49751. m.addstatus = nil
  49752. }
  49753. // Status returns the value of the "status" field in the mutation.
  49754. func (m *XunjiMutation) Status() (r uint8, exists bool) {
  49755. v := m.status
  49756. if v == nil {
  49757. return
  49758. }
  49759. return *v, true
  49760. }
  49761. // OldStatus returns the old "status" field's value of the Xunji entity.
  49762. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  49763. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49764. func (m *XunjiMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  49765. if !m.op.Is(OpUpdateOne) {
  49766. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  49767. }
  49768. if m.id == nil || m.oldValue == nil {
  49769. return v, errors.New("OldStatus requires an ID field in the mutation")
  49770. }
  49771. oldValue, err := m.oldValue(ctx)
  49772. if err != nil {
  49773. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  49774. }
  49775. return oldValue.Status, nil
  49776. }
  49777. // AddStatus adds u to the "status" field.
  49778. func (m *XunjiMutation) AddStatus(u int8) {
  49779. if m.addstatus != nil {
  49780. *m.addstatus += u
  49781. } else {
  49782. m.addstatus = &u
  49783. }
  49784. }
  49785. // AddedStatus returns the value that was added to the "status" field in this mutation.
  49786. func (m *XunjiMutation) AddedStatus() (r int8, exists bool) {
  49787. v := m.addstatus
  49788. if v == nil {
  49789. return
  49790. }
  49791. return *v, true
  49792. }
  49793. // ClearStatus clears the value of the "status" field.
  49794. func (m *XunjiMutation) ClearStatus() {
  49795. m.status = nil
  49796. m.addstatus = nil
  49797. m.clearedFields[xunji.FieldStatus] = struct{}{}
  49798. }
  49799. // StatusCleared returns if the "status" field was cleared in this mutation.
  49800. func (m *XunjiMutation) StatusCleared() bool {
  49801. _, ok := m.clearedFields[xunji.FieldStatus]
  49802. return ok
  49803. }
  49804. // ResetStatus resets all changes to the "status" field.
  49805. func (m *XunjiMutation) ResetStatus() {
  49806. m.status = nil
  49807. m.addstatus = nil
  49808. delete(m.clearedFields, xunji.FieldStatus)
  49809. }
  49810. // SetDeletedAt sets the "deleted_at" field.
  49811. func (m *XunjiMutation) SetDeletedAt(t time.Time) {
  49812. m.deleted_at = &t
  49813. }
  49814. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  49815. func (m *XunjiMutation) DeletedAt() (r time.Time, exists bool) {
  49816. v := m.deleted_at
  49817. if v == nil {
  49818. return
  49819. }
  49820. return *v, true
  49821. }
  49822. // OldDeletedAt returns the old "deleted_at" field's value of the Xunji entity.
  49823. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  49824. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49825. func (m *XunjiMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  49826. if !m.op.Is(OpUpdateOne) {
  49827. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  49828. }
  49829. if m.id == nil || m.oldValue == nil {
  49830. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  49831. }
  49832. oldValue, err := m.oldValue(ctx)
  49833. if err != nil {
  49834. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  49835. }
  49836. return oldValue.DeletedAt, nil
  49837. }
  49838. // ClearDeletedAt clears the value of the "deleted_at" field.
  49839. func (m *XunjiMutation) ClearDeletedAt() {
  49840. m.deleted_at = nil
  49841. m.clearedFields[xunji.FieldDeletedAt] = struct{}{}
  49842. }
  49843. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  49844. func (m *XunjiMutation) DeletedAtCleared() bool {
  49845. _, ok := m.clearedFields[xunji.FieldDeletedAt]
  49846. return ok
  49847. }
  49848. // ResetDeletedAt resets all changes to the "deleted_at" field.
  49849. func (m *XunjiMutation) ResetDeletedAt() {
  49850. m.deleted_at = nil
  49851. delete(m.clearedFields, xunji.FieldDeletedAt)
  49852. }
  49853. // SetAppKey sets the "app_key" field.
  49854. func (m *XunjiMutation) SetAppKey(s string) {
  49855. m.app_key = &s
  49856. }
  49857. // AppKey returns the value of the "app_key" field in the mutation.
  49858. func (m *XunjiMutation) AppKey() (r string, exists bool) {
  49859. v := m.app_key
  49860. if v == nil {
  49861. return
  49862. }
  49863. return *v, true
  49864. }
  49865. // OldAppKey returns the old "app_key" field's value of the Xunji entity.
  49866. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  49867. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49868. func (m *XunjiMutation) OldAppKey(ctx context.Context) (v string, err error) {
  49869. if !m.op.Is(OpUpdateOne) {
  49870. return v, errors.New("OldAppKey is only allowed on UpdateOne operations")
  49871. }
  49872. if m.id == nil || m.oldValue == nil {
  49873. return v, errors.New("OldAppKey requires an ID field in the mutation")
  49874. }
  49875. oldValue, err := m.oldValue(ctx)
  49876. if err != nil {
  49877. return v, fmt.Errorf("querying old value for OldAppKey: %w", err)
  49878. }
  49879. return oldValue.AppKey, nil
  49880. }
  49881. // ClearAppKey clears the value of the "app_key" field.
  49882. func (m *XunjiMutation) ClearAppKey() {
  49883. m.app_key = nil
  49884. m.clearedFields[xunji.FieldAppKey] = struct{}{}
  49885. }
  49886. // AppKeyCleared returns if the "app_key" field was cleared in this mutation.
  49887. func (m *XunjiMutation) AppKeyCleared() bool {
  49888. _, ok := m.clearedFields[xunji.FieldAppKey]
  49889. return ok
  49890. }
  49891. // ResetAppKey resets all changes to the "app_key" field.
  49892. func (m *XunjiMutation) ResetAppKey() {
  49893. m.app_key = nil
  49894. delete(m.clearedFields, xunji.FieldAppKey)
  49895. }
  49896. // SetAppSecret sets the "app_secret" field.
  49897. func (m *XunjiMutation) SetAppSecret(s string) {
  49898. m.app_secret = &s
  49899. }
  49900. // AppSecret returns the value of the "app_secret" field in the mutation.
  49901. func (m *XunjiMutation) AppSecret() (r string, exists bool) {
  49902. v := m.app_secret
  49903. if v == nil {
  49904. return
  49905. }
  49906. return *v, true
  49907. }
  49908. // OldAppSecret returns the old "app_secret" field's value of the Xunji entity.
  49909. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  49910. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49911. func (m *XunjiMutation) OldAppSecret(ctx context.Context) (v string, err error) {
  49912. if !m.op.Is(OpUpdateOne) {
  49913. return v, errors.New("OldAppSecret is only allowed on UpdateOne operations")
  49914. }
  49915. if m.id == nil || m.oldValue == nil {
  49916. return v, errors.New("OldAppSecret requires an ID field in the mutation")
  49917. }
  49918. oldValue, err := m.oldValue(ctx)
  49919. if err != nil {
  49920. return v, fmt.Errorf("querying old value for OldAppSecret: %w", err)
  49921. }
  49922. return oldValue.AppSecret, nil
  49923. }
  49924. // ClearAppSecret clears the value of the "app_secret" field.
  49925. func (m *XunjiMutation) ClearAppSecret() {
  49926. m.app_secret = nil
  49927. m.clearedFields[xunji.FieldAppSecret] = struct{}{}
  49928. }
  49929. // AppSecretCleared returns if the "app_secret" field was cleared in this mutation.
  49930. func (m *XunjiMutation) AppSecretCleared() bool {
  49931. _, ok := m.clearedFields[xunji.FieldAppSecret]
  49932. return ok
  49933. }
  49934. // ResetAppSecret resets all changes to the "app_secret" field.
  49935. func (m *XunjiMutation) ResetAppSecret() {
  49936. m.app_secret = nil
  49937. delete(m.clearedFields, xunji.FieldAppSecret)
  49938. }
  49939. // SetToken sets the "token" field.
  49940. func (m *XunjiMutation) SetToken(s string) {
  49941. m.token = &s
  49942. }
  49943. // Token returns the value of the "token" field in the mutation.
  49944. func (m *XunjiMutation) Token() (r string, exists bool) {
  49945. v := m.token
  49946. if v == nil {
  49947. return
  49948. }
  49949. return *v, true
  49950. }
  49951. // OldToken returns the old "token" field's value of the Xunji entity.
  49952. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  49953. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49954. func (m *XunjiMutation) OldToken(ctx context.Context) (v string, err error) {
  49955. if !m.op.Is(OpUpdateOne) {
  49956. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  49957. }
  49958. if m.id == nil || m.oldValue == nil {
  49959. return v, errors.New("OldToken requires an ID field in the mutation")
  49960. }
  49961. oldValue, err := m.oldValue(ctx)
  49962. if err != nil {
  49963. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  49964. }
  49965. return oldValue.Token, nil
  49966. }
  49967. // ClearToken clears the value of the "token" field.
  49968. func (m *XunjiMutation) ClearToken() {
  49969. m.token = nil
  49970. m.clearedFields[xunji.FieldToken] = struct{}{}
  49971. }
  49972. // TokenCleared returns if the "token" field was cleared in this mutation.
  49973. func (m *XunjiMutation) TokenCleared() bool {
  49974. _, ok := m.clearedFields[xunji.FieldToken]
  49975. return ok
  49976. }
  49977. // ResetToken resets all changes to the "token" field.
  49978. func (m *XunjiMutation) ResetToken() {
  49979. m.token = nil
  49980. delete(m.clearedFields, xunji.FieldToken)
  49981. }
  49982. // SetEncodingKey sets the "encoding_key" field.
  49983. func (m *XunjiMutation) SetEncodingKey(s string) {
  49984. m.encoding_key = &s
  49985. }
  49986. // EncodingKey returns the value of the "encoding_key" field in the mutation.
  49987. func (m *XunjiMutation) EncodingKey() (r string, exists bool) {
  49988. v := m.encoding_key
  49989. if v == nil {
  49990. return
  49991. }
  49992. return *v, true
  49993. }
  49994. // OldEncodingKey returns the old "encoding_key" field's value of the Xunji entity.
  49995. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  49996. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49997. func (m *XunjiMutation) OldEncodingKey(ctx context.Context) (v string, err error) {
  49998. if !m.op.Is(OpUpdateOne) {
  49999. return v, errors.New("OldEncodingKey is only allowed on UpdateOne operations")
  50000. }
  50001. if m.id == nil || m.oldValue == nil {
  50002. return v, errors.New("OldEncodingKey requires an ID field in the mutation")
  50003. }
  50004. oldValue, err := m.oldValue(ctx)
  50005. if err != nil {
  50006. return v, fmt.Errorf("querying old value for OldEncodingKey: %w", err)
  50007. }
  50008. return oldValue.EncodingKey, nil
  50009. }
  50010. // ClearEncodingKey clears the value of the "encoding_key" field.
  50011. func (m *XunjiMutation) ClearEncodingKey() {
  50012. m.encoding_key = nil
  50013. m.clearedFields[xunji.FieldEncodingKey] = struct{}{}
  50014. }
  50015. // EncodingKeyCleared returns if the "encoding_key" field was cleared in this mutation.
  50016. func (m *XunjiMutation) EncodingKeyCleared() bool {
  50017. _, ok := m.clearedFields[xunji.FieldEncodingKey]
  50018. return ok
  50019. }
  50020. // ResetEncodingKey resets all changes to the "encoding_key" field.
  50021. func (m *XunjiMutation) ResetEncodingKey() {
  50022. m.encoding_key = nil
  50023. delete(m.clearedFields, xunji.FieldEncodingKey)
  50024. }
  50025. // SetOrganizationID sets the "organization_id" field.
  50026. func (m *XunjiMutation) SetOrganizationID(u uint64) {
  50027. m.organization_id = &u
  50028. m.addorganization_id = nil
  50029. }
  50030. // OrganizationID returns the value of the "organization_id" field in the mutation.
  50031. func (m *XunjiMutation) OrganizationID() (r uint64, exists bool) {
  50032. v := m.organization_id
  50033. if v == nil {
  50034. return
  50035. }
  50036. return *v, true
  50037. }
  50038. // OldOrganizationID returns the old "organization_id" field's value of the Xunji entity.
  50039. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  50040. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50041. func (m *XunjiMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  50042. if !m.op.Is(OpUpdateOne) {
  50043. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  50044. }
  50045. if m.id == nil || m.oldValue == nil {
  50046. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  50047. }
  50048. oldValue, err := m.oldValue(ctx)
  50049. if err != nil {
  50050. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  50051. }
  50052. return oldValue.OrganizationID, nil
  50053. }
  50054. // AddOrganizationID adds u to the "organization_id" field.
  50055. func (m *XunjiMutation) AddOrganizationID(u int64) {
  50056. if m.addorganization_id != nil {
  50057. *m.addorganization_id += u
  50058. } else {
  50059. m.addorganization_id = &u
  50060. }
  50061. }
  50062. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  50063. func (m *XunjiMutation) AddedOrganizationID() (r int64, exists bool) {
  50064. v := m.addorganization_id
  50065. if v == nil {
  50066. return
  50067. }
  50068. return *v, true
  50069. }
  50070. // ResetOrganizationID resets all changes to the "organization_id" field.
  50071. func (m *XunjiMutation) ResetOrganizationID() {
  50072. m.organization_id = nil
  50073. m.addorganization_id = nil
  50074. }
  50075. // Where appends a list predicates to the XunjiMutation builder.
  50076. func (m *XunjiMutation) Where(ps ...predicate.Xunji) {
  50077. m.predicates = append(m.predicates, ps...)
  50078. }
  50079. // WhereP appends storage-level predicates to the XunjiMutation builder. Using this method,
  50080. // users can use type-assertion to append predicates that do not depend on any generated package.
  50081. func (m *XunjiMutation) WhereP(ps ...func(*sql.Selector)) {
  50082. p := make([]predicate.Xunji, len(ps))
  50083. for i := range ps {
  50084. p[i] = ps[i]
  50085. }
  50086. m.Where(p...)
  50087. }
  50088. // Op returns the operation name.
  50089. func (m *XunjiMutation) Op() Op {
  50090. return m.op
  50091. }
  50092. // SetOp allows setting the mutation operation.
  50093. func (m *XunjiMutation) SetOp(op Op) {
  50094. m.op = op
  50095. }
  50096. // Type returns the node type of this mutation (Xunji).
  50097. func (m *XunjiMutation) Type() string {
  50098. return m.typ
  50099. }
  50100. // Fields returns all fields that were changed during this mutation. Note that in
  50101. // order to get all numeric fields that were incremented/decremented, call
  50102. // AddedFields().
  50103. func (m *XunjiMutation) Fields() []string {
  50104. fields := make([]string, 0, 9)
  50105. if m.created_at != nil {
  50106. fields = append(fields, xunji.FieldCreatedAt)
  50107. }
  50108. if m.updated_at != nil {
  50109. fields = append(fields, xunji.FieldUpdatedAt)
  50110. }
  50111. if m.status != nil {
  50112. fields = append(fields, xunji.FieldStatus)
  50113. }
  50114. if m.deleted_at != nil {
  50115. fields = append(fields, xunji.FieldDeletedAt)
  50116. }
  50117. if m.app_key != nil {
  50118. fields = append(fields, xunji.FieldAppKey)
  50119. }
  50120. if m.app_secret != nil {
  50121. fields = append(fields, xunji.FieldAppSecret)
  50122. }
  50123. if m.token != nil {
  50124. fields = append(fields, xunji.FieldToken)
  50125. }
  50126. if m.encoding_key != nil {
  50127. fields = append(fields, xunji.FieldEncodingKey)
  50128. }
  50129. if m.organization_id != nil {
  50130. fields = append(fields, xunji.FieldOrganizationID)
  50131. }
  50132. return fields
  50133. }
  50134. // Field returns the value of a field with the given name. The second boolean
  50135. // return value indicates that this field was not set, or was not defined in the
  50136. // schema.
  50137. func (m *XunjiMutation) Field(name string) (ent.Value, bool) {
  50138. switch name {
  50139. case xunji.FieldCreatedAt:
  50140. return m.CreatedAt()
  50141. case xunji.FieldUpdatedAt:
  50142. return m.UpdatedAt()
  50143. case xunji.FieldStatus:
  50144. return m.Status()
  50145. case xunji.FieldDeletedAt:
  50146. return m.DeletedAt()
  50147. case xunji.FieldAppKey:
  50148. return m.AppKey()
  50149. case xunji.FieldAppSecret:
  50150. return m.AppSecret()
  50151. case xunji.FieldToken:
  50152. return m.Token()
  50153. case xunji.FieldEncodingKey:
  50154. return m.EncodingKey()
  50155. case xunji.FieldOrganizationID:
  50156. return m.OrganizationID()
  50157. }
  50158. return nil, false
  50159. }
  50160. // OldField returns the old value of the field from the database. An error is
  50161. // returned if the mutation operation is not UpdateOne, or the query to the
  50162. // database failed.
  50163. func (m *XunjiMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  50164. switch name {
  50165. case xunji.FieldCreatedAt:
  50166. return m.OldCreatedAt(ctx)
  50167. case xunji.FieldUpdatedAt:
  50168. return m.OldUpdatedAt(ctx)
  50169. case xunji.FieldStatus:
  50170. return m.OldStatus(ctx)
  50171. case xunji.FieldDeletedAt:
  50172. return m.OldDeletedAt(ctx)
  50173. case xunji.FieldAppKey:
  50174. return m.OldAppKey(ctx)
  50175. case xunji.FieldAppSecret:
  50176. return m.OldAppSecret(ctx)
  50177. case xunji.FieldToken:
  50178. return m.OldToken(ctx)
  50179. case xunji.FieldEncodingKey:
  50180. return m.OldEncodingKey(ctx)
  50181. case xunji.FieldOrganizationID:
  50182. return m.OldOrganizationID(ctx)
  50183. }
  50184. return nil, fmt.Errorf("unknown Xunji field %s", name)
  50185. }
  50186. // SetField sets the value of a field with the given name. It returns an error if
  50187. // the field is not defined in the schema, or if the type mismatched the field
  50188. // type.
  50189. func (m *XunjiMutation) SetField(name string, value ent.Value) error {
  50190. switch name {
  50191. case xunji.FieldCreatedAt:
  50192. v, ok := value.(time.Time)
  50193. if !ok {
  50194. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50195. }
  50196. m.SetCreatedAt(v)
  50197. return nil
  50198. case xunji.FieldUpdatedAt:
  50199. v, ok := value.(time.Time)
  50200. if !ok {
  50201. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50202. }
  50203. m.SetUpdatedAt(v)
  50204. return nil
  50205. case xunji.FieldStatus:
  50206. v, ok := value.(uint8)
  50207. if !ok {
  50208. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50209. }
  50210. m.SetStatus(v)
  50211. return nil
  50212. case xunji.FieldDeletedAt:
  50213. v, ok := value.(time.Time)
  50214. if !ok {
  50215. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50216. }
  50217. m.SetDeletedAt(v)
  50218. return nil
  50219. case xunji.FieldAppKey:
  50220. v, ok := value.(string)
  50221. if !ok {
  50222. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50223. }
  50224. m.SetAppKey(v)
  50225. return nil
  50226. case xunji.FieldAppSecret:
  50227. v, ok := value.(string)
  50228. if !ok {
  50229. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50230. }
  50231. m.SetAppSecret(v)
  50232. return nil
  50233. case xunji.FieldToken:
  50234. v, ok := value.(string)
  50235. if !ok {
  50236. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50237. }
  50238. m.SetToken(v)
  50239. return nil
  50240. case xunji.FieldEncodingKey:
  50241. v, ok := value.(string)
  50242. if !ok {
  50243. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50244. }
  50245. m.SetEncodingKey(v)
  50246. return nil
  50247. case xunji.FieldOrganizationID:
  50248. v, ok := value.(uint64)
  50249. if !ok {
  50250. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50251. }
  50252. m.SetOrganizationID(v)
  50253. return nil
  50254. }
  50255. return fmt.Errorf("unknown Xunji field %s", name)
  50256. }
  50257. // AddedFields returns all numeric fields that were incremented/decremented during
  50258. // this mutation.
  50259. func (m *XunjiMutation) AddedFields() []string {
  50260. var fields []string
  50261. if m.addstatus != nil {
  50262. fields = append(fields, xunji.FieldStatus)
  50263. }
  50264. if m.addorganization_id != nil {
  50265. fields = append(fields, xunji.FieldOrganizationID)
  50266. }
  50267. return fields
  50268. }
  50269. // AddedField returns the numeric value that was incremented/decremented on a field
  50270. // with the given name. The second boolean return value indicates that this field
  50271. // was not set, or was not defined in the schema.
  50272. func (m *XunjiMutation) AddedField(name string) (ent.Value, bool) {
  50273. switch name {
  50274. case xunji.FieldStatus:
  50275. return m.AddedStatus()
  50276. case xunji.FieldOrganizationID:
  50277. return m.AddedOrganizationID()
  50278. }
  50279. return nil, false
  50280. }
  50281. // AddField adds the value to the field with the given name. It returns an error if
  50282. // the field is not defined in the schema, or if the type mismatched the field
  50283. // type.
  50284. func (m *XunjiMutation) AddField(name string, value ent.Value) error {
  50285. switch name {
  50286. case xunji.FieldStatus:
  50287. v, ok := value.(int8)
  50288. if !ok {
  50289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50290. }
  50291. m.AddStatus(v)
  50292. return nil
  50293. case xunji.FieldOrganizationID:
  50294. v, ok := value.(int64)
  50295. if !ok {
  50296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50297. }
  50298. m.AddOrganizationID(v)
  50299. return nil
  50300. }
  50301. return fmt.Errorf("unknown Xunji numeric field %s", name)
  50302. }
  50303. // ClearedFields returns all nullable fields that were cleared during this
  50304. // mutation.
  50305. func (m *XunjiMutation) ClearedFields() []string {
  50306. var fields []string
  50307. if m.FieldCleared(xunji.FieldStatus) {
  50308. fields = append(fields, xunji.FieldStatus)
  50309. }
  50310. if m.FieldCleared(xunji.FieldDeletedAt) {
  50311. fields = append(fields, xunji.FieldDeletedAt)
  50312. }
  50313. if m.FieldCleared(xunji.FieldAppKey) {
  50314. fields = append(fields, xunji.FieldAppKey)
  50315. }
  50316. if m.FieldCleared(xunji.FieldAppSecret) {
  50317. fields = append(fields, xunji.FieldAppSecret)
  50318. }
  50319. if m.FieldCleared(xunji.FieldToken) {
  50320. fields = append(fields, xunji.FieldToken)
  50321. }
  50322. if m.FieldCleared(xunji.FieldEncodingKey) {
  50323. fields = append(fields, xunji.FieldEncodingKey)
  50324. }
  50325. return fields
  50326. }
  50327. // FieldCleared returns a boolean indicating if a field with the given name was
  50328. // cleared in this mutation.
  50329. func (m *XunjiMutation) FieldCleared(name string) bool {
  50330. _, ok := m.clearedFields[name]
  50331. return ok
  50332. }
  50333. // ClearField clears the value of the field with the given name. It returns an
  50334. // error if the field is not defined in the schema.
  50335. func (m *XunjiMutation) ClearField(name string) error {
  50336. switch name {
  50337. case xunji.FieldStatus:
  50338. m.ClearStatus()
  50339. return nil
  50340. case xunji.FieldDeletedAt:
  50341. m.ClearDeletedAt()
  50342. return nil
  50343. case xunji.FieldAppKey:
  50344. m.ClearAppKey()
  50345. return nil
  50346. case xunji.FieldAppSecret:
  50347. m.ClearAppSecret()
  50348. return nil
  50349. case xunji.FieldToken:
  50350. m.ClearToken()
  50351. return nil
  50352. case xunji.FieldEncodingKey:
  50353. m.ClearEncodingKey()
  50354. return nil
  50355. }
  50356. return fmt.Errorf("unknown Xunji nullable field %s", name)
  50357. }
  50358. // ResetField resets all changes in the mutation for the field with the given name.
  50359. // It returns an error if the field is not defined in the schema.
  50360. func (m *XunjiMutation) ResetField(name string) error {
  50361. switch name {
  50362. case xunji.FieldCreatedAt:
  50363. m.ResetCreatedAt()
  50364. return nil
  50365. case xunji.FieldUpdatedAt:
  50366. m.ResetUpdatedAt()
  50367. return nil
  50368. case xunji.FieldStatus:
  50369. m.ResetStatus()
  50370. return nil
  50371. case xunji.FieldDeletedAt:
  50372. m.ResetDeletedAt()
  50373. return nil
  50374. case xunji.FieldAppKey:
  50375. m.ResetAppKey()
  50376. return nil
  50377. case xunji.FieldAppSecret:
  50378. m.ResetAppSecret()
  50379. return nil
  50380. case xunji.FieldToken:
  50381. m.ResetToken()
  50382. return nil
  50383. case xunji.FieldEncodingKey:
  50384. m.ResetEncodingKey()
  50385. return nil
  50386. case xunji.FieldOrganizationID:
  50387. m.ResetOrganizationID()
  50388. return nil
  50389. }
  50390. return fmt.Errorf("unknown Xunji field %s", name)
  50391. }
  50392. // AddedEdges returns all edge names that were set/added in this mutation.
  50393. func (m *XunjiMutation) AddedEdges() []string {
  50394. edges := make([]string, 0, 0)
  50395. return edges
  50396. }
  50397. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  50398. // name in this mutation.
  50399. func (m *XunjiMutation) AddedIDs(name string) []ent.Value {
  50400. return nil
  50401. }
  50402. // RemovedEdges returns all edge names that were removed in this mutation.
  50403. func (m *XunjiMutation) RemovedEdges() []string {
  50404. edges := make([]string, 0, 0)
  50405. return edges
  50406. }
  50407. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  50408. // the given name in this mutation.
  50409. func (m *XunjiMutation) RemovedIDs(name string) []ent.Value {
  50410. return nil
  50411. }
  50412. // ClearedEdges returns all edge names that were cleared in this mutation.
  50413. func (m *XunjiMutation) ClearedEdges() []string {
  50414. edges := make([]string, 0, 0)
  50415. return edges
  50416. }
  50417. // EdgeCleared returns a boolean which indicates if the edge with the given name
  50418. // was cleared in this mutation.
  50419. func (m *XunjiMutation) EdgeCleared(name string) bool {
  50420. return false
  50421. }
  50422. // ClearEdge clears the value of the edge with the given name. It returns an error
  50423. // if that edge is not defined in the schema.
  50424. func (m *XunjiMutation) ClearEdge(name string) error {
  50425. return fmt.Errorf("unknown Xunji unique edge %s", name)
  50426. }
  50427. // ResetEdge resets all changes to the edge with the given name in this mutation.
  50428. // It returns an error if the edge is not defined in the schema.
  50429. func (m *XunjiMutation) ResetEdge(name string) error {
  50430. return fmt.Errorf("unknown Xunji edge %s", name)
  50431. }
  50432. // XunjiServiceMutation represents an operation that mutates the XunjiService nodes in the graph.
  50433. type XunjiServiceMutation struct {
  50434. config
  50435. op Op
  50436. typ string
  50437. id *uint64
  50438. created_at *time.Time
  50439. updated_at *time.Time
  50440. status *uint8
  50441. addstatus *int8
  50442. deleted_at *time.Time
  50443. xunji_id *uint64
  50444. addxunji_id *int64
  50445. organization_id *uint64
  50446. addorganization_id *int64
  50447. wxid *string
  50448. api_base *string
  50449. api_key *string
  50450. clearedFields map[string]struct{}
  50451. agent *uint64
  50452. clearedagent bool
  50453. done bool
  50454. oldValue func(context.Context) (*XunjiService, error)
  50455. predicates []predicate.XunjiService
  50456. }
  50457. var _ ent.Mutation = (*XunjiServiceMutation)(nil)
  50458. // xunjiserviceOption allows management of the mutation configuration using functional options.
  50459. type xunjiserviceOption func(*XunjiServiceMutation)
  50460. // newXunjiServiceMutation creates new mutation for the XunjiService entity.
  50461. func newXunjiServiceMutation(c config, op Op, opts ...xunjiserviceOption) *XunjiServiceMutation {
  50462. m := &XunjiServiceMutation{
  50463. config: c,
  50464. op: op,
  50465. typ: TypeXunjiService,
  50466. clearedFields: make(map[string]struct{}),
  50467. }
  50468. for _, opt := range opts {
  50469. opt(m)
  50470. }
  50471. return m
  50472. }
  50473. // withXunjiServiceID sets the ID field of the mutation.
  50474. func withXunjiServiceID(id uint64) xunjiserviceOption {
  50475. return func(m *XunjiServiceMutation) {
  50476. var (
  50477. err error
  50478. once sync.Once
  50479. value *XunjiService
  50480. )
  50481. m.oldValue = func(ctx context.Context) (*XunjiService, error) {
  50482. once.Do(func() {
  50483. if m.done {
  50484. err = errors.New("querying old values post mutation is not allowed")
  50485. } else {
  50486. value, err = m.Client().XunjiService.Get(ctx, id)
  50487. }
  50488. })
  50489. return value, err
  50490. }
  50491. m.id = &id
  50492. }
  50493. }
  50494. // withXunjiService sets the old XunjiService of the mutation.
  50495. func withXunjiService(node *XunjiService) xunjiserviceOption {
  50496. return func(m *XunjiServiceMutation) {
  50497. m.oldValue = func(context.Context) (*XunjiService, error) {
  50498. return node, nil
  50499. }
  50500. m.id = &node.ID
  50501. }
  50502. }
  50503. // Client returns a new `ent.Client` from the mutation. If the mutation was
  50504. // executed in a transaction (ent.Tx), a transactional client is returned.
  50505. func (m XunjiServiceMutation) Client() *Client {
  50506. client := &Client{config: m.config}
  50507. client.init()
  50508. return client
  50509. }
  50510. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  50511. // it returns an error otherwise.
  50512. func (m XunjiServiceMutation) Tx() (*Tx, error) {
  50513. if _, ok := m.driver.(*txDriver); !ok {
  50514. return nil, errors.New("ent: mutation is not running in a transaction")
  50515. }
  50516. tx := &Tx{config: m.config}
  50517. tx.init()
  50518. return tx, nil
  50519. }
  50520. // SetID sets the value of the id field. Note that this
  50521. // operation is only accepted on creation of XunjiService entities.
  50522. func (m *XunjiServiceMutation) SetID(id uint64) {
  50523. m.id = &id
  50524. }
  50525. // ID returns the ID value in the mutation. Note that the ID is only available
  50526. // if it was provided to the builder or after it was returned from the database.
  50527. func (m *XunjiServiceMutation) ID() (id uint64, exists bool) {
  50528. if m.id == nil {
  50529. return
  50530. }
  50531. return *m.id, true
  50532. }
  50533. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  50534. // That means, if the mutation is applied within a transaction with an isolation level such
  50535. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  50536. // or updated by the mutation.
  50537. func (m *XunjiServiceMutation) IDs(ctx context.Context) ([]uint64, error) {
  50538. switch {
  50539. case m.op.Is(OpUpdateOne | OpDeleteOne):
  50540. id, exists := m.ID()
  50541. if exists {
  50542. return []uint64{id}, nil
  50543. }
  50544. fallthrough
  50545. case m.op.Is(OpUpdate | OpDelete):
  50546. return m.Client().XunjiService.Query().Where(m.predicates...).IDs(ctx)
  50547. default:
  50548. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  50549. }
  50550. }
  50551. // SetCreatedAt sets the "created_at" field.
  50552. func (m *XunjiServiceMutation) SetCreatedAt(t time.Time) {
  50553. m.created_at = &t
  50554. }
  50555. // CreatedAt returns the value of the "created_at" field in the mutation.
  50556. func (m *XunjiServiceMutation) CreatedAt() (r time.Time, exists bool) {
  50557. v := m.created_at
  50558. if v == nil {
  50559. return
  50560. }
  50561. return *v, true
  50562. }
  50563. // OldCreatedAt returns the old "created_at" field's value of the XunjiService entity.
  50564. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  50565. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50566. func (m *XunjiServiceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  50567. if !m.op.Is(OpUpdateOne) {
  50568. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  50569. }
  50570. if m.id == nil || m.oldValue == nil {
  50571. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  50572. }
  50573. oldValue, err := m.oldValue(ctx)
  50574. if err != nil {
  50575. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  50576. }
  50577. return oldValue.CreatedAt, nil
  50578. }
  50579. // ResetCreatedAt resets all changes to the "created_at" field.
  50580. func (m *XunjiServiceMutation) ResetCreatedAt() {
  50581. m.created_at = nil
  50582. }
  50583. // SetUpdatedAt sets the "updated_at" field.
  50584. func (m *XunjiServiceMutation) SetUpdatedAt(t time.Time) {
  50585. m.updated_at = &t
  50586. }
  50587. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  50588. func (m *XunjiServiceMutation) UpdatedAt() (r time.Time, exists bool) {
  50589. v := m.updated_at
  50590. if v == nil {
  50591. return
  50592. }
  50593. return *v, true
  50594. }
  50595. // OldUpdatedAt returns the old "updated_at" field's value of the XunjiService entity.
  50596. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  50597. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50598. func (m *XunjiServiceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  50599. if !m.op.Is(OpUpdateOne) {
  50600. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  50601. }
  50602. if m.id == nil || m.oldValue == nil {
  50603. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  50604. }
  50605. oldValue, err := m.oldValue(ctx)
  50606. if err != nil {
  50607. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  50608. }
  50609. return oldValue.UpdatedAt, nil
  50610. }
  50611. // ResetUpdatedAt resets all changes to the "updated_at" field.
  50612. func (m *XunjiServiceMutation) ResetUpdatedAt() {
  50613. m.updated_at = nil
  50614. }
  50615. // SetStatus sets the "status" field.
  50616. func (m *XunjiServiceMutation) SetStatus(u uint8) {
  50617. m.status = &u
  50618. m.addstatus = nil
  50619. }
  50620. // Status returns the value of the "status" field in the mutation.
  50621. func (m *XunjiServiceMutation) Status() (r uint8, exists bool) {
  50622. v := m.status
  50623. if v == nil {
  50624. return
  50625. }
  50626. return *v, true
  50627. }
  50628. // OldStatus returns the old "status" field's value of the XunjiService entity.
  50629. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  50630. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50631. func (m *XunjiServiceMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  50632. if !m.op.Is(OpUpdateOne) {
  50633. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  50634. }
  50635. if m.id == nil || m.oldValue == nil {
  50636. return v, errors.New("OldStatus requires an ID field in the mutation")
  50637. }
  50638. oldValue, err := m.oldValue(ctx)
  50639. if err != nil {
  50640. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  50641. }
  50642. return oldValue.Status, nil
  50643. }
  50644. // AddStatus adds u to the "status" field.
  50645. func (m *XunjiServiceMutation) AddStatus(u int8) {
  50646. if m.addstatus != nil {
  50647. *m.addstatus += u
  50648. } else {
  50649. m.addstatus = &u
  50650. }
  50651. }
  50652. // AddedStatus returns the value that was added to the "status" field in this mutation.
  50653. func (m *XunjiServiceMutation) AddedStatus() (r int8, exists bool) {
  50654. v := m.addstatus
  50655. if v == nil {
  50656. return
  50657. }
  50658. return *v, true
  50659. }
  50660. // ClearStatus clears the value of the "status" field.
  50661. func (m *XunjiServiceMutation) ClearStatus() {
  50662. m.status = nil
  50663. m.addstatus = nil
  50664. m.clearedFields[xunjiservice.FieldStatus] = struct{}{}
  50665. }
  50666. // StatusCleared returns if the "status" field was cleared in this mutation.
  50667. func (m *XunjiServiceMutation) StatusCleared() bool {
  50668. _, ok := m.clearedFields[xunjiservice.FieldStatus]
  50669. return ok
  50670. }
  50671. // ResetStatus resets all changes to the "status" field.
  50672. func (m *XunjiServiceMutation) ResetStatus() {
  50673. m.status = nil
  50674. m.addstatus = nil
  50675. delete(m.clearedFields, xunjiservice.FieldStatus)
  50676. }
  50677. // SetDeletedAt sets the "deleted_at" field.
  50678. func (m *XunjiServiceMutation) SetDeletedAt(t time.Time) {
  50679. m.deleted_at = &t
  50680. }
  50681. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  50682. func (m *XunjiServiceMutation) DeletedAt() (r time.Time, exists bool) {
  50683. v := m.deleted_at
  50684. if v == nil {
  50685. return
  50686. }
  50687. return *v, true
  50688. }
  50689. // OldDeletedAt returns the old "deleted_at" field's value of the XunjiService entity.
  50690. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  50691. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50692. func (m *XunjiServiceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  50693. if !m.op.Is(OpUpdateOne) {
  50694. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  50695. }
  50696. if m.id == nil || m.oldValue == nil {
  50697. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  50698. }
  50699. oldValue, err := m.oldValue(ctx)
  50700. if err != nil {
  50701. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  50702. }
  50703. return oldValue.DeletedAt, nil
  50704. }
  50705. // ClearDeletedAt clears the value of the "deleted_at" field.
  50706. func (m *XunjiServiceMutation) ClearDeletedAt() {
  50707. m.deleted_at = nil
  50708. m.clearedFields[xunjiservice.FieldDeletedAt] = struct{}{}
  50709. }
  50710. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  50711. func (m *XunjiServiceMutation) DeletedAtCleared() bool {
  50712. _, ok := m.clearedFields[xunjiservice.FieldDeletedAt]
  50713. return ok
  50714. }
  50715. // ResetDeletedAt resets all changes to the "deleted_at" field.
  50716. func (m *XunjiServiceMutation) ResetDeletedAt() {
  50717. m.deleted_at = nil
  50718. delete(m.clearedFields, xunjiservice.FieldDeletedAt)
  50719. }
  50720. // SetXunjiID sets the "xunji_id" field.
  50721. func (m *XunjiServiceMutation) SetXunjiID(u uint64) {
  50722. m.xunji_id = &u
  50723. m.addxunji_id = nil
  50724. }
  50725. // XunjiID returns the value of the "xunji_id" field in the mutation.
  50726. func (m *XunjiServiceMutation) XunjiID() (r uint64, exists bool) {
  50727. v := m.xunji_id
  50728. if v == nil {
  50729. return
  50730. }
  50731. return *v, true
  50732. }
  50733. // OldXunjiID returns the old "xunji_id" field's value of the XunjiService entity.
  50734. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  50735. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50736. func (m *XunjiServiceMutation) OldXunjiID(ctx context.Context) (v uint64, err error) {
  50737. if !m.op.Is(OpUpdateOne) {
  50738. return v, errors.New("OldXunjiID is only allowed on UpdateOne operations")
  50739. }
  50740. if m.id == nil || m.oldValue == nil {
  50741. return v, errors.New("OldXunjiID requires an ID field in the mutation")
  50742. }
  50743. oldValue, err := m.oldValue(ctx)
  50744. if err != nil {
  50745. return v, fmt.Errorf("querying old value for OldXunjiID: %w", err)
  50746. }
  50747. return oldValue.XunjiID, nil
  50748. }
  50749. // AddXunjiID adds u to the "xunji_id" field.
  50750. func (m *XunjiServiceMutation) AddXunjiID(u int64) {
  50751. if m.addxunji_id != nil {
  50752. *m.addxunji_id += u
  50753. } else {
  50754. m.addxunji_id = &u
  50755. }
  50756. }
  50757. // AddedXunjiID returns the value that was added to the "xunji_id" field in this mutation.
  50758. func (m *XunjiServiceMutation) AddedXunjiID() (r int64, exists bool) {
  50759. v := m.addxunji_id
  50760. if v == nil {
  50761. return
  50762. }
  50763. return *v, true
  50764. }
  50765. // ResetXunjiID resets all changes to the "xunji_id" field.
  50766. func (m *XunjiServiceMutation) ResetXunjiID() {
  50767. m.xunji_id = nil
  50768. m.addxunji_id = nil
  50769. }
  50770. // SetAgentID sets the "agent_id" field.
  50771. func (m *XunjiServiceMutation) SetAgentID(u uint64) {
  50772. m.agent = &u
  50773. }
  50774. // AgentID returns the value of the "agent_id" field in the mutation.
  50775. func (m *XunjiServiceMutation) AgentID() (r uint64, exists bool) {
  50776. v := m.agent
  50777. if v == nil {
  50778. return
  50779. }
  50780. return *v, true
  50781. }
  50782. // OldAgentID returns the old "agent_id" field's value of the XunjiService entity.
  50783. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  50784. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50785. func (m *XunjiServiceMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  50786. if !m.op.Is(OpUpdateOne) {
  50787. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  50788. }
  50789. if m.id == nil || m.oldValue == nil {
  50790. return v, errors.New("OldAgentID requires an ID field in the mutation")
  50791. }
  50792. oldValue, err := m.oldValue(ctx)
  50793. if err != nil {
  50794. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  50795. }
  50796. return oldValue.AgentID, nil
  50797. }
  50798. // ResetAgentID resets all changes to the "agent_id" field.
  50799. func (m *XunjiServiceMutation) ResetAgentID() {
  50800. m.agent = nil
  50801. }
  50802. // SetOrganizationID sets the "organization_id" field.
  50803. func (m *XunjiServiceMutation) SetOrganizationID(u uint64) {
  50804. m.organization_id = &u
  50805. m.addorganization_id = nil
  50806. }
  50807. // OrganizationID returns the value of the "organization_id" field in the mutation.
  50808. func (m *XunjiServiceMutation) OrganizationID() (r uint64, exists bool) {
  50809. v := m.organization_id
  50810. if v == nil {
  50811. return
  50812. }
  50813. return *v, true
  50814. }
  50815. // OldOrganizationID returns the old "organization_id" field's value of the XunjiService entity.
  50816. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  50817. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50818. func (m *XunjiServiceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  50819. if !m.op.Is(OpUpdateOne) {
  50820. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  50821. }
  50822. if m.id == nil || m.oldValue == nil {
  50823. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  50824. }
  50825. oldValue, err := m.oldValue(ctx)
  50826. if err != nil {
  50827. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  50828. }
  50829. return oldValue.OrganizationID, nil
  50830. }
  50831. // AddOrganizationID adds u to the "organization_id" field.
  50832. func (m *XunjiServiceMutation) AddOrganizationID(u int64) {
  50833. if m.addorganization_id != nil {
  50834. *m.addorganization_id += u
  50835. } else {
  50836. m.addorganization_id = &u
  50837. }
  50838. }
  50839. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  50840. func (m *XunjiServiceMutation) AddedOrganizationID() (r int64, exists bool) {
  50841. v := m.addorganization_id
  50842. if v == nil {
  50843. return
  50844. }
  50845. return *v, true
  50846. }
  50847. // ResetOrganizationID resets all changes to the "organization_id" field.
  50848. func (m *XunjiServiceMutation) ResetOrganizationID() {
  50849. m.organization_id = nil
  50850. m.addorganization_id = nil
  50851. }
  50852. // SetWxid sets the "wxid" field.
  50853. func (m *XunjiServiceMutation) SetWxid(s string) {
  50854. m.wxid = &s
  50855. }
  50856. // Wxid returns the value of the "wxid" field in the mutation.
  50857. func (m *XunjiServiceMutation) Wxid() (r string, exists bool) {
  50858. v := m.wxid
  50859. if v == nil {
  50860. return
  50861. }
  50862. return *v, true
  50863. }
  50864. // OldWxid returns the old "wxid" field's value of the XunjiService entity.
  50865. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  50866. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50867. func (m *XunjiServiceMutation) OldWxid(ctx context.Context) (v string, err error) {
  50868. if !m.op.Is(OpUpdateOne) {
  50869. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  50870. }
  50871. if m.id == nil || m.oldValue == nil {
  50872. return v, errors.New("OldWxid requires an ID field in the mutation")
  50873. }
  50874. oldValue, err := m.oldValue(ctx)
  50875. if err != nil {
  50876. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  50877. }
  50878. return oldValue.Wxid, nil
  50879. }
  50880. // ResetWxid resets all changes to the "wxid" field.
  50881. func (m *XunjiServiceMutation) ResetWxid() {
  50882. m.wxid = nil
  50883. }
  50884. // SetAPIBase sets the "api_base" field.
  50885. func (m *XunjiServiceMutation) SetAPIBase(s string) {
  50886. m.api_base = &s
  50887. }
  50888. // APIBase returns the value of the "api_base" field in the mutation.
  50889. func (m *XunjiServiceMutation) APIBase() (r string, exists bool) {
  50890. v := m.api_base
  50891. if v == nil {
  50892. return
  50893. }
  50894. return *v, true
  50895. }
  50896. // OldAPIBase returns the old "api_base" field's value of the XunjiService entity.
  50897. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  50898. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50899. func (m *XunjiServiceMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  50900. if !m.op.Is(OpUpdateOne) {
  50901. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  50902. }
  50903. if m.id == nil || m.oldValue == nil {
  50904. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  50905. }
  50906. oldValue, err := m.oldValue(ctx)
  50907. if err != nil {
  50908. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  50909. }
  50910. return oldValue.APIBase, nil
  50911. }
  50912. // ClearAPIBase clears the value of the "api_base" field.
  50913. func (m *XunjiServiceMutation) ClearAPIBase() {
  50914. m.api_base = nil
  50915. m.clearedFields[xunjiservice.FieldAPIBase] = struct{}{}
  50916. }
  50917. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  50918. func (m *XunjiServiceMutation) APIBaseCleared() bool {
  50919. _, ok := m.clearedFields[xunjiservice.FieldAPIBase]
  50920. return ok
  50921. }
  50922. // ResetAPIBase resets all changes to the "api_base" field.
  50923. func (m *XunjiServiceMutation) ResetAPIBase() {
  50924. m.api_base = nil
  50925. delete(m.clearedFields, xunjiservice.FieldAPIBase)
  50926. }
  50927. // SetAPIKey sets the "api_key" field.
  50928. func (m *XunjiServiceMutation) SetAPIKey(s string) {
  50929. m.api_key = &s
  50930. }
  50931. // APIKey returns the value of the "api_key" field in the mutation.
  50932. func (m *XunjiServiceMutation) APIKey() (r string, exists bool) {
  50933. v := m.api_key
  50934. if v == nil {
  50935. return
  50936. }
  50937. return *v, true
  50938. }
  50939. // OldAPIKey returns the old "api_key" field's value of the XunjiService entity.
  50940. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  50941. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50942. func (m *XunjiServiceMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  50943. if !m.op.Is(OpUpdateOne) {
  50944. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  50945. }
  50946. if m.id == nil || m.oldValue == nil {
  50947. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  50948. }
  50949. oldValue, err := m.oldValue(ctx)
  50950. if err != nil {
  50951. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  50952. }
  50953. return oldValue.APIKey, nil
  50954. }
  50955. // ClearAPIKey clears the value of the "api_key" field.
  50956. func (m *XunjiServiceMutation) ClearAPIKey() {
  50957. m.api_key = nil
  50958. m.clearedFields[xunjiservice.FieldAPIKey] = struct{}{}
  50959. }
  50960. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  50961. func (m *XunjiServiceMutation) APIKeyCleared() bool {
  50962. _, ok := m.clearedFields[xunjiservice.FieldAPIKey]
  50963. return ok
  50964. }
  50965. // ResetAPIKey resets all changes to the "api_key" field.
  50966. func (m *XunjiServiceMutation) ResetAPIKey() {
  50967. m.api_key = nil
  50968. delete(m.clearedFields, xunjiservice.FieldAPIKey)
  50969. }
  50970. // ClearAgent clears the "agent" edge to the Agent entity.
  50971. func (m *XunjiServiceMutation) ClearAgent() {
  50972. m.clearedagent = true
  50973. m.clearedFields[xunjiservice.FieldAgentID] = struct{}{}
  50974. }
  50975. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  50976. func (m *XunjiServiceMutation) AgentCleared() bool {
  50977. return m.clearedagent
  50978. }
  50979. // AgentIDs returns the "agent" edge IDs in the mutation.
  50980. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  50981. // AgentID instead. It exists only for internal usage by the builders.
  50982. func (m *XunjiServiceMutation) AgentIDs() (ids []uint64) {
  50983. if id := m.agent; id != nil {
  50984. ids = append(ids, *id)
  50985. }
  50986. return
  50987. }
  50988. // ResetAgent resets all changes to the "agent" edge.
  50989. func (m *XunjiServiceMutation) ResetAgent() {
  50990. m.agent = nil
  50991. m.clearedagent = false
  50992. }
  50993. // Where appends a list predicates to the XunjiServiceMutation builder.
  50994. func (m *XunjiServiceMutation) Where(ps ...predicate.XunjiService) {
  50995. m.predicates = append(m.predicates, ps...)
  50996. }
  50997. // WhereP appends storage-level predicates to the XunjiServiceMutation builder. Using this method,
  50998. // users can use type-assertion to append predicates that do not depend on any generated package.
  50999. func (m *XunjiServiceMutation) WhereP(ps ...func(*sql.Selector)) {
  51000. p := make([]predicate.XunjiService, len(ps))
  51001. for i := range ps {
  51002. p[i] = ps[i]
  51003. }
  51004. m.Where(p...)
  51005. }
  51006. // Op returns the operation name.
  51007. func (m *XunjiServiceMutation) Op() Op {
  51008. return m.op
  51009. }
  51010. // SetOp allows setting the mutation operation.
  51011. func (m *XunjiServiceMutation) SetOp(op Op) {
  51012. m.op = op
  51013. }
  51014. // Type returns the node type of this mutation (XunjiService).
  51015. func (m *XunjiServiceMutation) Type() string {
  51016. return m.typ
  51017. }
  51018. // Fields returns all fields that were changed during this mutation. Note that in
  51019. // order to get all numeric fields that were incremented/decremented, call
  51020. // AddedFields().
  51021. func (m *XunjiServiceMutation) Fields() []string {
  51022. fields := make([]string, 0, 10)
  51023. if m.created_at != nil {
  51024. fields = append(fields, xunjiservice.FieldCreatedAt)
  51025. }
  51026. if m.updated_at != nil {
  51027. fields = append(fields, xunjiservice.FieldUpdatedAt)
  51028. }
  51029. if m.status != nil {
  51030. fields = append(fields, xunjiservice.FieldStatus)
  51031. }
  51032. if m.deleted_at != nil {
  51033. fields = append(fields, xunjiservice.FieldDeletedAt)
  51034. }
  51035. if m.xunji_id != nil {
  51036. fields = append(fields, xunjiservice.FieldXunjiID)
  51037. }
  51038. if m.agent != nil {
  51039. fields = append(fields, xunjiservice.FieldAgentID)
  51040. }
  51041. if m.organization_id != nil {
  51042. fields = append(fields, xunjiservice.FieldOrganizationID)
  51043. }
  51044. if m.wxid != nil {
  51045. fields = append(fields, xunjiservice.FieldWxid)
  51046. }
  51047. if m.api_base != nil {
  51048. fields = append(fields, xunjiservice.FieldAPIBase)
  51049. }
  51050. if m.api_key != nil {
  51051. fields = append(fields, xunjiservice.FieldAPIKey)
  51052. }
  51053. return fields
  51054. }
  51055. // Field returns the value of a field with the given name. The second boolean
  51056. // return value indicates that this field was not set, or was not defined in the
  51057. // schema.
  51058. func (m *XunjiServiceMutation) Field(name string) (ent.Value, bool) {
  51059. switch name {
  51060. case xunjiservice.FieldCreatedAt:
  51061. return m.CreatedAt()
  51062. case xunjiservice.FieldUpdatedAt:
  51063. return m.UpdatedAt()
  51064. case xunjiservice.FieldStatus:
  51065. return m.Status()
  51066. case xunjiservice.FieldDeletedAt:
  51067. return m.DeletedAt()
  51068. case xunjiservice.FieldXunjiID:
  51069. return m.XunjiID()
  51070. case xunjiservice.FieldAgentID:
  51071. return m.AgentID()
  51072. case xunjiservice.FieldOrganizationID:
  51073. return m.OrganizationID()
  51074. case xunjiservice.FieldWxid:
  51075. return m.Wxid()
  51076. case xunjiservice.FieldAPIBase:
  51077. return m.APIBase()
  51078. case xunjiservice.FieldAPIKey:
  51079. return m.APIKey()
  51080. }
  51081. return nil, false
  51082. }
  51083. // OldField returns the old value of the field from the database. An error is
  51084. // returned if the mutation operation is not UpdateOne, or the query to the
  51085. // database failed.
  51086. func (m *XunjiServiceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  51087. switch name {
  51088. case xunjiservice.FieldCreatedAt:
  51089. return m.OldCreatedAt(ctx)
  51090. case xunjiservice.FieldUpdatedAt:
  51091. return m.OldUpdatedAt(ctx)
  51092. case xunjiservice.FieldStatus:
  51093. return m.OldStatus(ctx)
  51094. case xunjiservice.FieldDeletedAt:
  51095. return m.OldDeletedAt(ctx)
  51096. case xunjiservice.FieldXunjiID:
  51097. return m.OldXunjiID(ctx)
  51098. case xunjiservice.FieldAgentID:
  51099. return m.OldAgentID(ctx)
  51100. case xunjiservice.FieldOrganizationID:
  51101. return m.OldOrganizationID(ctx)
  51102. case xunjiservice.FieldWxid:
  51103. return m.OldWxid(ctx)
  51104. case xunjiservice.FieldAPIBase:
  51105. return m.OldAPIBase(ctx)
  51106. case xunjiservice.FieldAPIKey:
  51107. return m.OldAPIKey(ctx)
  51108. }
  51109. return nil, fmt.Errorf("unknown XunjiService field %s", name)
  51110. }
  51111. // SetField sets the value of a field with the given name. It returns an error if
  51112. // the field is not defined in the schema, or if the type mismatched the field
  51113. // type.
  51114. func (m *XunjiServiceMutation) SetField(name string, value ent.Value) error {
  51115. switch name {
  51116. case xunjiservice.FieldCreatedAt:
  51117. v, ok := value.(time.Time)
  51118. if !ok {
  51119. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51120. }
  51121. m.SetCreatedAt(v)
  51122. return nil
  51123. case xunjiservice.FieldUpdatedAt:
  51124. v, ok := value.(time.Time)
  51125. if !ok {
  51126. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51127. }
  51128. m.SetUpdatedAt(v)
  51129. return nil
  51130. case xunjiservice.FieldStatus:
  51131. v, ok := value.(uint8)
  51132. if !ok {
  51133. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51134. }
  51135. m.SetStatus(v)
  51136. return nil
  51137. case xunjiservice.FieldDeletedAt:
  51138. v, ok := value.(time.Time)
  51139. if !ok {
  51140. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51141. }
  51142. m.SetDeletedAt(v)
  51143. return nil
  51144. case xunjiservice.FieldXunjiID:
  51145. v, ok := value.(uint64)
  51146. if !ok {
  51147. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51148. }
  51149. m.SetXunjiID(v)
  51150. return nil
  51151. case xunjiservice.FieldAgentID:
  51152. v, ok := value.(uint64)
  51153. if !ok {
  51154. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51155. }
  51156. m.SetAgentID(v)
  51157. return nil
  51158. case xunjiservice.FieldOrganizationID:
  51159. v, ok := value.(uint64)
  51160. if !ok {
  51161. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51162. }
  51163. m.SetOrganizationID(v)
  51164. return nil
  51165. case xunjiservice.FieldWxid:
  51166. v, ok := value.(string)
  51167. if !ok {
  51168. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51169. }
  51170. m.SetWxid(v)
  51171. return nil
  51172. case xunjiservice.FieldAPIBase:
  51173. v, ok := value.(string)
  51174. if !ok {
  51175. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51176. }
  51177. m.SetAPIBase(v)
  51178. return nil
  51179. case xunjiservice.FieldAPIKey:
  51180. v, ok := value.(string)
  51181. if !ok {
  51182. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51183. }
  51184. m.SetAPIKey(v)
  51185. return nil
  51186. }
  51187. return fmt.Errorf("unknown XunjiService field %s", name)
  51188. }
  51189. // AddedFields returns all numeric fields that were incremented/decremented during
  51190. // this mutation.
  51191. func (m *XunjiServiceMutation) AddedFields() []string {
  51192. var fields []string
  51193. if m.addstatus != nil {
  51194. fields = append(fields, xunjiservice.FieldStatus)
  51195. }
  51196. if m.addxunji_id != nil {
  51197. fields = append(fields, xunjiservice.FieldXunjiID)
  51198. }
  51199. if m.addorganization_id != nil {
  51200. fields = append(fields, xunjiservice.FieldOrganizationID)
  51201. }
  51202. return fields
  51203. }
  51204. // AddedField returns the numeric value that was incremented/decremented on a field
  51205. // with the given name. The second boolean return value indicates that this field
  51206. // was not set, or was not defined in the schema.
  51207. func (m *XunjiServiceMutation) AddedField(name string) (ent.Value, bool) {
  51208. switch name {
  51209. case xunjiservice.FieldStatus:
  51210. return m.AddedStatus()
  51211. case xunjiservice.FieldXunjiID:
  51212. return m.AddedXunjiID()
  51213. case xunjiservice.FieldOrganizationID:
  51214. return m.AddedOrganizationID()
  51215. }
  51216. return nil, false
  51217. }
  51218. // AddField adds the value to the field with the given name. It returns an error if
  51219. // the field is not defined in the schema, or if the type mismatched the field
  51220. // type.
  51221. func (m *XunjiServiceMutation) AddField(name string, value ent.Value) error {
  51222. switch name {
  51223. case xunjiservice.FieldStatus:
  51224. v, ok := value.(int8)
  51225. if !ok {
  51226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51227. }
  51228. m.AddStatus(v)
  51229. return nil
  51230. case xunjiservice.FieldXunjiID:
  51231. v, ok := value.(int64)
  51232. if !ok {
  51233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51234. }
  51235. m.AddXunjiID(v)
  51236. return nil
  51237. case xunjiservice.FieldOrganizationID:
  51238. v, ok := value.(int64)
  51239. if !ok {
  51240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51241. }
  51242. m.AddOrganizationID(v)
  51243. return nil
  51244. }
  51245. return fmt.Errorf("unknown XunjiService numeric field %s", name)
  51246. }
  51247. // ClearedFields returns all nullable fields that were cleared during this
  51248. // mutation.
  51249. func (m *XunjiServiceMutation) ClearedFields() []string {
  51250. var fields []string
  51251. if m.FieldCleared(xunjiservice.FieldStatus) {
  51252. fields = append(fields, xunjiservice.FieldStatus)
  51253. }
  51254. if m.FieldCleared(xunjiservice.FieldDeletedAt) {
  51255. fields = append(fields, xunjiservice.FieldDeletedAt)
  51256. }
  51257. if m.FieldCleared(xunjiservice.FieldAPIBase) {
  51258. fields = append(fields, xunjiservice.FieldAPIBase)
  51259. }
  51260. if m.FieldCleared(xunjiservice.FieldAPIKey) {
  51261. fields = append(fields, xunjiservice.FieldAPIKey)
  51262. }
  51263. return fields
  51264. }
  51265. // FieldCleared returns a boolean indicating if a field with the given name was
  51266. // cleared in this mutation.
  51267. func (m *XunjiServiceMutation) FieldCleared(name string) bool {
  51268. _, ok := m.clearedFields[name]
  51269. return ok
  51270. }
  51271. // ClearField clears the value of the field with the given name. It returns an
  51272. // error if the field is not defined in the schema.
  51273. func (m *XunjiServiceMutation) ClearField(name string) error {
  51274. switch name {
  51275. case xunjiservice.FieldStatus:
  51276. m.ClearStatus()
  51277. return nil
  51278. case xunjiservice.FieldDeletedAt:
  51279. m.ClearDeletedAt()
  51280. return nil
  51281. case xunjiservice.FieldAPIBase:
  51282. m.ClearAPIBase()
  51283. return nil
  51284. case xunjiservice.FieldAPIKey:
  51285. m.ClearAPIKey()
  51286. return nil
  51287. }
  51288. return fmt.Errorf("unknown XunjiService nullable field %s", name)
  51289. }
  51290. // ResetField resets all changes in the mutation for the field with the given name.
  51291. // It returns an error if the field is not defined in the schema.
  51292. func (m *XunjiServiceMutation) ResetField(name string) error {
  51293. switch name {
  51294. case xunjiservice.FieldCreatedAt:
  51295. m.ResetCreatedAt()
  51296. return nil
  51297. case xunjiservice.FieldUpdatedAt:
  51298. m.ResetUpdatedAt()
  51299. return nil
  51300. case xunjiservice.FieldStatus:
  51301. m.ResetStatus()
  51302. return nil
  51303. case xunjiservice.FieldDeletedAt:
  51304. m.ResetDeletedAt()
  51305. return nil
  51306. case xunjiservice.FieldXunjiID:
  51307. m.ResetXunjiID()
  51308. return nil
  51309. case xunjiservice.FieldAgentID:
  51310. m.ResetAgentID()
  51311. return nil
  51312. case xunjiservice.FieldOrganizationID:
  51313. m.ResetOrganizationID()
  51314. return nil
  51315. case xunjiservice.FieldWxid:
  51316. m.ResetWxid()
  51317. return nil
  51318. case xunjiservice.FieldAPIBase:
  51319. m.ResetAPIBase()
  51320. return nil
  51321. case xunjiservice.FieldAPIKey:
  51322. m.ResetAPIKey()
  51323. return nil
  51324. }
  51325. return fmt.Errorf("unknown XunjiService field %s", name)
  51326. }
  51327. // AddedEdges returns all edge names that were set/added in this mutation.
  51328. func (m *XunjiServiceMutation) AddedEdges() []string {
  51329. edges := make([]string, 0, 1)
  51330. if m.agent != nil {
  51331. edges = append(edges, xunjiservice.EdgeAgent)
  51332. }
  51333. return edges
  51334. }
  51335. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  51336. // name in this mutation.
  51337. func (m *XunjiServiceMutation) AddedIDs(name string) []ent.Value {
  51338. switch name {
  51339. case xunjiservice.EdgeAgent:
  51340. if id := m.agent; id != nil {
  51341. return []ent.Value{*id}
  51342. }
  51343. }
  51344. return nil
  51345. }
  51346. // RemovedEdges returns all edge names that were removed in this mutation.
  51347. func (m *XunjiServiceMutation) RemovedEdges() []string {
  51348. edges := make([]string, 0, 1)
  51349. return edges
  51350. }
  51351. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  51352. // the given name in this mutation.
  51353. func (m *XunjiServiceMutation) RemovedIDs(name string) []ent.Value {
  51354. return nil
  51355. }
  51356. // ClearedEdges returns all edge names that were cleared in this mutation.
  51357. func (m *XunjiServiceMutation) ClearedEdges() []string {
  51358. edges := make([]string, 0, 1)
  51359. if m.clearedagent {
  51360. edges = append(edges, xunjiservice.EdgeAgent)
  51361. }
  51362. return edges
  51363. }
  51364. // EdgeCleared returns a boolean which indicates if the edge with the given name
  51365. // was cleared in this mutation.
  51366. func (m *XunjiServiceMutation) EdgeCleared(name string) bool {
  51367. switch name {
  51368. case xunjiservice.EdgeAgent:
  51369. return m.clearedagent
  51370. }
  51371. return false
  51372. }
  51373. // ClearEdge clears the value of the edge with the given name. It returns an error
  51374. // if that edge is not defined in the schema.
  51375. func (m *XunjiServiceMutation) ClearEdge(name string) error {
  51376. switch name {
  51377. case xunjiservice.EdgeAgent:
  51378. m.ClearAgent()
  51379. return nil
  51380. }
  51381. return fmt.Errorf("unknown XunjiService unique edge %s", name)
  51382. }
  51383. // ResetEdge resets all changes to the edge with the given name in this mutation.
  51384. // It returns an error if the edge is not defined in the schema.
  51385. func (m *XunjiServiceMutation) ResetEdge(name string) error {
  51386. switch name {
  51387. case xunjiservice.EdgeAgent:
  51388. m.ResetAgent()
  51389. return nil
  51390. }
  51391. return fmt.Errorf("unknown XunjiService edge %s", name)
  51392. }