mutation.go 1.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351
  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/labellog"
  29. "wechat-api/ent/labelrelationship"
  30. "wechat-api/ent/labeltagging"
  31. "wechat-api/ent/message"
  32. "wechat-api/ent/messagerecords"
  33. "wechat-api/ent/msg"
  34. "wechat-api/ent/payrecharge"
  35. "wechat-api/ent/predicate"
  36. "wechat-api/ent/server"
  37. "wechat-api/ent/sopnode"
  38. "wechat-api/ent/sopstage"
  39. "wechat-api/ent/soptask"
  40. "wechat-api/ent/token"
  41. "wechat-api/ent/tutorial"
  42. "wechat-api/ent/usagedetail"
  43. "wechat-api/ent/usagestatisticday"
  44. "wechat-api/ent/usagestatistichour"
  45. "wechat-api/ent/usagestatisticmonth"
  46. "wechat-api/ent/usagetotal"
  47. "wechat-api/ent/whatsapp"
  48. "wechat-api/ent/whatsappchannel"
  49. "wechat-api/ent/workexperience"
  50. "wechat-api/ent/wpchatroom"
  51. "wechat-api/ent/wpchatroommember"
  52. "wechat-api/ent/wx"
  53. "wechat-api/ent/wxcard"
  54. "wechat-api/ent/wxcarduser"
  55. "wechat-api/ent/wxcardvisit"
  56. "wechat-api/ent/xunji"
  57. "wechat-api/ent/xunjiservice"
  58. "entgo.io/ent"
  59. "entgo.io/ent/dialect/sql"
  60. )
  61. const (
  62. // Operation types.
  63. OpCreate = ent.OpCreate
  64. OpDelete = ent.OpDelete
  65. OpDeleteOne = ent.OpDeleteOne
  66. OpUpdate = ent.OpUpdate
  67. OpUpdateOne = ent.OpUpdateOne
  68. // Node types.
  69. TypeAgent = "Agent"
  70. TypeAgentBase = "AgentBase"
  71. TypeAliyunAvatar = "AliyunAvatar"
  72. TypeAllocAgent = "AllocAgent"
  73. TypeApiKey = "ApiKey"
  74. TypeBatchMsg = "BatchMsg"
  75. TypeCategory = "Category"
  76. TypeChatRecords = "ChatRecords"
  77. TypeChatSession = "ChatSession"
  78. TypeCompapiAsynctask = "CompapiAsynctask"
  79. TypeContact = "Contact"
  80. TypeContactField = "ContactField"
  81. TypeContactFieldTemplate = "ContactFieldTemplate"
  82. TypeCreditBalance = "CreditBalance"
  83. TypeCreditUsage = "CreditUsage"
  84. TypeEmployee = "Employee"
  85. TypeEmployeeConfig = "EmployeeConfig"
  86. TypeLabel = "Label"
  87. TypeLabelLog = "LabelLog"
  88. TypeLabelRelationship = "LabelRelationship"
  89. TypeLabelTagging = "LabelTagging"
  90. TypeMessage = "Message"
  91. TypeMessageRecords = "MessageRecords"
  92. TypeMsg = "Msg"
  93. TypePayRecharge = "PayRecharge"
  94. TypeServer = "Server"
  95. TypeSopNode = "SopNode"
  96. TypeSopStage = "SopStage"
  97. TypeSopTask = "SopTask"
  98. TypeToken = "Token"
  99. TypeTutorial = "Tutorial"
  100. TypeUsageDetail = "UsageDetail"
  101. TypeUsageStatisticDay = "UsageStatisticDay"
  102. TypeUsageStatisticHour = "UsageStatisticHour"
  103. TypeUsageStatisticMonth = "UsageStatisticMonth"
  104. TypeUsageTotal = "UsageTotal"
  105. TypeWhatsapp = "Whatsapp"
  106. TypeWhatsappChannel = "WhatsappChannel"
  107. TypeWorkExperience = "WorkExperience"
  108. TypeWpChatroom = "WpChatroom"
  109. TypeWpChatroomMember = "WpChatroomMember"
  110. TypeWx = "Wx"
  111. TypeWxCard = "WxCard"
  112. TypeWxCardUser = "WxCardUser"
  113. TypeWxCardVisit = "WxCardVisit"
  114. TypeXunji = "Xunji"
  115. TypeXunjiService = "XunjiService"
  116. )
  117. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  118. type AgentMutation struct {
  119. config
  120. op Op
  121. typ string
  122. id *uint64
  123. created_at *time.Time
  124. updated_at *time.Time
  125. deleted_at *time.Time
  126. name *string
  127. role *string
  128. status *int
  129. addstatus *int
  130. background *string
  131. examples *string
  132. organization_id *uint64
  133. addorganization_id *int64
  134. dataset_id *string
  135. collection_id *string
  136. model *string
  137. api_base *string
  138. api_key *string
  139. _type *int
  140. add_type *int
  141. clearedFields map[string]struct{}
  142. wx_agent map[uint64]struct{}
  143. removedwx_agent map[uint64]struct{}
  144. clearedwx_agent bool
  145. token_agent map[uint64]struct{}
  146. removedtoken_agent map[uint64]struct{}
  147. clearedtoken_agent bool
  148. wa_agent map[uint64]struct{}
  149. removedwa_agent map[uint64]struct{}
  150. clearedwa_agent bool
  151. xjs_agent map[uint64]struct{}
  152. removedxjs_agent map[uint64]struct{}
  153. clearedxjs_agent bool
  154. key_agent map[uint64]struct{}
  155. removedkey_agent map[uint64]struct{}
  156. clearedkey_agent bool
  157. done bool
  158. oldValue func(context.Context) (*Agent, error)
  159. predicates []predicate.Agent
  160. }
  161. var _ ent.Mutation = (*AgentMutation)(nil)
  162. // agentOption allows management of the mutation configuration using functional options.
  163. type agentOption func(*AgentMutation)
  164. // newAgentMutation creates new mutation for the Agent entity.
  165. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  166. m := &AgentMutation{
  167. config: c,
  168. op: op,
  169. typ: TypeAgent,
  170. clearedFields: make(map[string]struct{}),
  171. }
  172. for _, opt := range opts {
  173. opt(m)
  174. }
  175. return m
  176. }
  177. // withAgentID sets the ID field of the mutation.
  178. func withAgentID(id uint64) agentOption {
  179. return func(m *AgentMutation) {
  180. var (
  181. err error
  182. once sync.Once
  183. value *Agent
  184. )
  185. m.oldValue = func(ctx context.Context) (*Agent, error) {
  186. once.Do(func() {
  187. if m.done {
  188. err = errors.New("querying old values post mutation is not allowed")
  189. } else {
  190. value, err = m.Client().Agent.Get(ctx, id)
  191. }
  192. })
  193. return value, err
  194. }
  195. m.id = &id
  196. }
  197. }
  198. // withAgent sets the old Agent of the mutation.
  199. func withAgent(node *Agent) agentOption {
  200. return func(m *AgentMutation) {
  201. m.oldValue = func(context.Context) (*Agent, error) {
  202. return node, nil
  203. }
  204. m.id = &node.ID
  205. }
  206. }
  207. // Client returns a new `ent.Client` from the mutation. If the mutation was
  208. // executed in a transaction (ent.Tx), a transactional client is returned.
  209. func (m AgentMutation) Client() *Client {
  210. client := &Client{config: m.config}
  211. client.init()
  212. return client
  213. }
  214. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  215. // it returns an error otherwise.
  216. func (m AgentMutation) Tx() (*Tx, error) {
  217. if _, ok := m.driver.(*txDriver); !ok {
  218. return nil, errors.New("ent: mutation is not running in a transaction")
  219. }
  220. tx := &Tx{config: m.config}
  221. tx.init()
  222. return tx, nil
  223. }
  224. // SetID sets the value of the id field. Note that this
  225. // operation is only accepted on creation of Agent entities.
  226. func (m *AgentMutation) SetID(id uint64) {
  227. m.id = &id
  228. }
  229. // ID returns the ID value in the mutation. Note that the ID is only available
  230. // if it was provided to the builder or after it was returned from the database.
  231. func (m *AgentMutation) ID() (id uint64, exists bool) {
  232. if m.id == nil {
  233. return
  234. }
  235. return *m.id, true
  236. }
  237. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  238. // That means, if the mutation is applied within a transaction with an isolation level such
  239. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  240. // or updated by the mutation.
  241. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  242. switch {
  243. case m.op.Is(OpUpdateOne | OpDeleteOne):
  244. id, exists := m.ID()
  245. if exists {
  246. return []uint64{id}, nil
  247. }
  248. fallthrough
  249. case m.op.Is(OpUpdate | OpDelete):
  250. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  251. default:
  252. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  253. }
  254. }
  255. // SetCreatedAt sets the "created_at" field.
  256. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  257. m.created_at = &t
  258. }
  259. // CreatedAt returns the value of the "created_at" field in the mutation.
  260. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  261. v := m.created_at
  262. if v == nil {
  263. return
  264. }
  265. return *v, true
  266. }
  267. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  268. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  269. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  270. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  271. if !m.op.Is(OpUpdateOne) {
  272. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  273. }
  274. if m.id == nil || m.oldValue == nil {
  275. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  276. }
  277. oldValue, err := m.oldValue(ctx)
  278. if err != nil {
  279. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  280. }
  281. return oldValue.CreatedAt, nil
  282. }
  283. // ResetCreatedAt resets all changes to the "created_at" field.
  284. func (m *AgentMutation) ResetCreatedAt() {
  285. m.created_at = nil
  286. }
  287. // SetUpdatedAt sets the "updated_at" field.
  288. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  289. m.updated_at = &t
  290. }
  291. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  292. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  293. v := m.updated_at
  294. if v == nil {
  295. return
  296. }
  297. return *v, true
  298. }
  299. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  300. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  301. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  302. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  303. if !m.op.Is(OpUpdateOne) {
  304. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  305. }
  306. if m.id == nil || m.oldValue == nil {
  307. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  308. }
  309. oldValue, err := m.oldValue(ctx)
  310. if err != nil {
  311. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  312. }
  313. return oldValue.UpdatedAt, nil
  314. }
  315. // ResetUpdatedAt resets all changes to the "updated_at" field.
  316. func (m *AgentMutation) ResetUpdatedAt() {
  317. m.updated_at = nil
  318. }
  319. // SetDeletedAt sets the "deleted_at" field.
  320. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  321. m.deleted_at = &t
  322. }
  323. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  324. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  325. v := m.deleted_at
  326. if v == nil {
  327. return
  328. }
  329. return *v, true
  330. }
  331. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  332. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  333. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  334. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  335. if !m.op.Is(OpUpdateOne) {
  336. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  337. }
  338. if m.id == nil || m.oldValue == nil {
  339. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  340. }
  341. oldValue, err := m.oldValue(ctx)
  342. if err != nil {
  343. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  344. }
  345. return oldValue.DeletedAt, nil
  346. }
  347. // ClearDeletedAt clears the value of the "deleted_at" field.
  348. func (m *AgentMutation) ClearDeletedAt() {
  349. m.deleted_at = nil
  350. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  351. }
  352. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  353. func (m *AgentMutation) DeletedAtCleared() bool {
  354. _, ok := m.clearedFields[agent.FieldDeletedAt]
  355. return ok
  356. }
  357. // ResetDeletedAt resets all changes to the "deleted_at" field.
  358. func (m *AgentMutation) ResetDeletedAt() {
  359. m.deleted_at = nil
  360. delete(m.clearedFields, agent.FieldDeletedAt)
  361. }
  362. // SetName sets the "name" field.
  363. func (m *AgentMutation) SetName(s string) {
  364. m.name = &s
  365. }
  366. // Name returns the value of the "name" field in the mutation.
  367. func (m *AgentMutation) Name() (r string, exists bool) {
  368. v := m.name
  369. if v == nil {
  370. return
  371. }
  372. return *v, true
  373. }
  374. // OldName returns the old "name" field's value of the Agent entity.
  375. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  376. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  377. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  378. if !m.op.Is(OpUpdateOne) {
  379. return v, errors.New("OldName is only allowed on UpdateOne operations")
  380. }
  381. if m.id == nil || m.oldValue == nil {
  382. return v, errors.New("OldName requires an ID field in the mutation")
  383. }
  384. oldValue, err := m.oldValue(ctx)
  385. if err != nil {
  386. return v, fmt.Errorf("querying old value for OldName: %w", err)
  387. }
  388. return oldValue.Name, nil
  389. }
  390. // ResetName resets all changes to the "name" field.
  391. func (m *AgentMutation) ResetName() {
  392. m.name = nil
  393. }
  394. // SetRole sets the "role" field.
  395. func (m *AgentMutation) SetRole(s string) {
  396. m.role = &s
  397. }
  398. // Role returns the value of the "role" field in the mutation.
  399. func (m *AgentMutation) Role() (r string, exists bool) {
  400. v := m.role
  401. if v == nil {
  402. return
  403. }
  404. return *v, true
  405. }
  406. // OldRole returns the old "role" field's value of the Agent entity.
  407. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  408. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  409. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  410. if !m.op.Is(OpUpdateOne) {
  411. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  412. }
  413. if m.id == nil || m.oldValue == nil {
  414. return v, errors.New("OldRole requires an ID field in the mutation")
  415. }
  416. oldValue, err := m.oldValue(ctx)
  417. if err != nil {
  418. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  419. }
  420. return oldValue.Role, nil
  421. }
  422. // ClearRole clears the value of the "role" field.
  423. func (m *AgentMutation) ClearRole() {
  424. m.role = nil
  425. m.clearedFields[agent.FieldRole] = struct{}{}
  426. }
  427. // RoleCleared returns if the "role" field was cleared in this mutation.
  428. func (m *AgentMutation) RoleCleared() bool {
  429. _, ok := m.clearedFields[agent.FieldRole]
  430. return ok
  431. }
  432. // ResetRole resets all changes to the "role" field.
  433. func (m *AgentMutation) ResetRole() {
  434. m.role = nil
  435. delete(m.clearedFields, agent.FieldRole)
  436. }
  437. // SetStatus sets the "status" field.
  438. func (m *AgentMutation) SetStatus(i int) {
  439. m.status = &i
  440. m.addstatus = nil
  441. }
  442. // Status returns the value of the "status" field in the mutation.
  443. func (m *AgentMutation) Status() (r int, exists bool) {
  444. v := m.status
  445. if v == nil {
  446. return
  447. }
  448. return *v, true
  449. }
  450. // OldStatus returns the old "status" field's value of the Agent entity.
  451. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  452. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  453. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  454. if !m.op.Is(OpUpdateOne) {
  455. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  456. }
  457. if m.id == nil || m.oldValue == nil {
  458. return v, errors.New("OldStatus requires an ID field in the mutation")
  459. }
  460. oldValue, err := m.oldValue(ctx)
  461. if err != nil {
  462. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  463. }
  464. return oldValue.Status, nil
  465. }
  466. // AddStatus adds i to the "status" field.
  467. func (m *AgentMutation) AddStatus(i int) {
  468. if m.addstatus != nil {
  469. *m.addstatus += i
  470. } else {
  471. m.addstatus = &i
  472. }
  473. }
  474. // AddedStatus returns the value that was added to the "status" field in this mutation.
  475. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  476. v := m.addstatus
  477. if v == nil {
  478. return
  479. }
  480. return *v, true
  481. }
  482. // ClearStatus clears the value of the "status" field.
  483. func (m *AgentMutation) ClearStatus() {
  484. m.status = nil
  485. m.addstatus = nil
  486. m.clearedFields[agent.FieldStatus] = struct{}{}
  487. }
  488. // StatusCleared returns if the "status" field was cleared in this mutation.
  489. func (m *AgentMutation) StatusCleared() bool {
  490. _, ok := m.clearedFields[agent.FieldStatus]
  491. return ok
  492. }
  493. // ResetStatus resets all changes to the "status" field.
  494. func (m *AgentMutation) ResetStatus() {
  495. m.status = nil
  496. m.addstatus = nil
  497. delete(m.clearedFields, agent.FieldStatus)
  498. }
  499. // SetBackground sets the "background" field.
  500. func (m *AgentMutation) SetBackground(s string) {
  501. m.background = &s
  502. }
  503. // Background returns the value of the "background" field in the mutation.
  504. func (m *AgentMutation) Background() (r string, exists bool) {
  505. v := m.background
  506. if v == nil {
  507. return
  508. }
  509. return *v, true
  510. }
  511. // OldBackground returns the old "background" field's value of the Agent entity.
  512. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  513. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  514. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  515. if !m.op.Is(OpUpdateOne) {
  516. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  517. }
  518. if m.id == nil || m.oldValue == nil {
  519. return v, errors.New("OldBackground requires an ID field in the mutation")
  520. }
  521. oldValue, err := m.oldValue(ctx)
  522. if err != nil {
  523. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  524. }
  525. return oldValue.Background, nil
  526. }
  527. // ClearBackground clears the value of the "background" field.
  528. func (m *AgentMutation) ClearBackground() {
  529. m.background = nil
  530. m.clearedFields[agent.FieldBackground] = struct{}{}
  531. }
  532. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  533. func (m *AgentMutation) BackgroundCleared() bool {
  534. _, ok := m.clearedFields[agent.FieldBackground]
  535. return ok
  536. }
  537. // ResetBackground resets all changes to the "background" field.
  538. func (m *AgentMutation) ResetBackground() {
  539. m.background = nil
  540. delete(m.clearedFields, agent.FieldBackground)
  541. }
  542. // SetExamples sets the "examples" field.
  543. func (m *AgentMutation) SetExamples(s string) {
  544. m.examples = &s
  545. }
  546. // Examples returns the value of the "examples" field in the mutation.
  547. func (m *AgentMutation) Examples() (r string, exists bool) {
  548. v := m.examples
  549. if v == nil {
  550. return
  551. }
  552. return *v, true
  553. }
  554. // OldExamples returns the old "examples" field's value of the Agent entity.
  555. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  556. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  557. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  558. if !m.op.Is(OpUpdateOne) {
  559. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  560. }
  561. if m.id == nil || m.oldValue == nil {
  562. return v, errors.New("OldExamples requires an ID field in the mutation")
  563. }
  564. oldValue, err := m.oldValue(ctx)
  565. if err != nil {
  566. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  567. }
  568. return oldValue.Examples, nil
  569. }
  570. // ClearExamples clears the value of the "examples" field.
  571. func (m *AgentMutation) ClearExamples() {
  572. m.examples = nil
  573. m.clearedFields[agent.FieldExamples] = struct{}{}
  574. }
  575. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  576. func (m *AgentMutation) ExamplesCleared() bool {
  577. _, ok := m.clearedFields[agent.FieldExamples]
  578. return ok
  579. }
  580. // ResetExamples resets all changes to the "examples" field.
  581. func (m *AgentMutation) ResetExamples() {
  582. m.examples = nil
  583. delete(m.clearedFields, agent.FieldExamples)
  584. }
  585. // SetOrganizationID sets the "organization_id" field.
  586. func (m *AgentMutation) SetOrganizationID(u uint64) {
  587. m.organization_id = &u
  588. m.addorganization_id = nil
  589. }
  590. // OrganizationID returns the value of the "organization_id" field in the mutation.
  591. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  592. v := m.organization_id
  593. if v == nil {
  594. return
  595. }
  596. return *v, true
  597. }
  598. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  599. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  601. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  602. if !m.op.Is(OpUpdateOne) {
  603. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  604. }
  605. if m.id == nil || m.oldValue == nil {
  606. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  607. }
  608. oldValue, err := m.oldValue(ctx)
  609. if err != nil {
  610. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  611. }
  612. return oldValue.OrganizationID, nil
  613. }
  614. // AddOrganizationID adds u to the "organization_id" field.
  615. func (m *AgentMutation) AddOrganizationID(u int64) {
  616. if m.addorganization_id != nil {
  617. *m.addorganization_id += u
  618. } else {
  619. m.addorganization_id = &u
  620. }
  621. }
  622. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  623. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  624. v := m.addorganization_id
  625. if v == nil {
  626. return
  627. }
  628. return *v, true
  629. }
  630. // ResetOrganizationID resets all changes to the "organization_id" field.
  631. func (m *AgentMutation) ResetOrganizationID() {
  632. m.organization_id = nil
  633. m.addorganization_id = nil
  634. }
  635. // SetDatasetID sets the "dataset_id" field.
  636. func (m *AgentMutation) SetDatasetID(s string) {
  637. m.dataset_id = &s
  638. }
  639. // DatasetID returns the value of the "dataset_id" field in the mutation.
  640. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  641. v := m.dataset_id
  642. if v == nil {
  643. return
  644. }
  645. return *v, true
  646. }
  647. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  648. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  650. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  651. if !m.op.Is(OpUpdateOne) {
  652. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  653. }
  654. if m.id == nil || m.oldValue == nil {
  655. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  656. }
  657. oldValue, err := m.oldValue(ctx)
  658. if err != nil {
  659. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  660. }
  661. return oldValue.DatasetID, nil
  662. }
  663. // ResetDatasetID resets all changes to the "dataset_id" field.
  664. func (m *AgentMutation) ResetDatasetID() {
  665. m.dataset_id = nil
  666. }
  667. // SetCollectionID sets the "collection_id" field.
  668. func (m *AgentMutation) SetCollectionID(s string) {
  669. m.collection_id = &s
  670. }
  671. // CollectionID returns the value of the "collection_id" field in the mutation.
  672. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  673. v := m.collection_id
  674. if v == nil {
  675. return
  676. }
  677. return *v, true
  678. }
  679. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  680. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  681. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  682. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  683. if !m.op.Is(OpUpdateOne) {
  684. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  685. }
  686. if m.id == nil || m.oldValue == nil {
  687. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  688. }
  689. oldValue, err := m.oldValue(ctx)
  690. if err != nil {
  691. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  692. }
  693. return oldValue.CollectionID, nil
  694. }
  695. // ResetCollectionID resets all changes to the "collection_id" field.
  696. func (m *AgentMutation) ResetCollectionID() {
  697. m.collection_id = nil
  698. }
  699. // SetModel sets the "model" field.
  700. func (m *AgentMutation) SetModel(s string) {
  701. m.model = &s
  702. }
  703. // Model returns the value of the "model" field in the mutation.
  704. func (m *AgentMutation) Model() (r string, exists bool) {
  705. v := m.model
  706. if v == nil {
  707. return
  708. }
  709. return *v, true
  710. }
  711. // OldModel returns the old "model" field's value of the Agent entity.
  712. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  713. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  714. func (m *AgentMutation) OldModel(ctx context.Context) (v string, err error) {
  715. if !m.op.Is(OpUpdateOne) {
  716. return v, errors.New("OldModel is only allowed on UpdateOne operations")
  717. }
  718. if m.id == nil || m.oldValue == nil {
  719. return v, errors.New("OldModel requires an ID field in the mutation")
  720. }
  721. oldValue, err := m.oldValue(ctx)
  722. if err != nil {
  723. return v, fmt.Errorf("querying old value for OldModel: %w", err)
  724. }
  725. return oldValue.Model, nil
  726. }
  727. // ClearModel clears the value of the "model" field.
  728. func (m *AgentMutation) ClearModel() {
  729. m.model = nil
  730. m.clearedFields[agent.FieldModel] = struct{}{}
  731. }
  732. // ModelCleared returns if the "model" field was cleared in this mutation.
  733. func (m *AgentMutation) ModelCleared() bool {
  734. _, ok := m.clearedFields[agent.FieldModel]
  735. return ok
  736. }
  737. // ResetModel resets all changes to the "model" field.
  738. func (m *AgentMutation) ResetModel() {
  739. m.model = nil
  740. delete(m.clearedFields, agent.FieldModel)
  741. }
  742. // SetAPIBase sets the "api_base" field.
  743. func (m *AgentMutation) SetAPIBase(s string) {
  744. m.api_base = &s
  745. }
  746. // APIBase returns the value of the "api_base" field in the mutation.
  747. func (m *AgentMutation) APIBase() (r string, exists bool) {
  748. v := m.api_base
  749. if v == nil {
  750. return
  751. }
  752. return *v, true
  753. }
  754. // OldAPIBase returns the old "api_base" field's value of the Agent entity.
  755. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  756. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  757. func (m *AgentMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  758. if !m.op.Is(OpUpdateOne) {
  759. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  760. }
  761. if m.id == nil || m.oldValue == nil {
  762. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  763. }
  764. oldValue, err := m.oldValue(ctx)
  765. if err != nil {
  766. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  767. }
  768. return oldValue.APIBase, nil
  769. }
  770. // ClearAPIBase clears the value of the "api_base" field.
  771. func (m *AgentMutation) ClearAPIBase() {
  772. m.api_base = nil
  773. m.clearedFields[agent.FieldAPIBase] = struct{}{}
  774. }
  775. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  776. func (m *AgentMutation) APIBaseCleared() bool {
  777. _, ok := m.clearedFields[agent.FieldAPIBase]
  778. return ok
  779. }
  780. // ResetAPIBase resets all changes to the "api_base" field.
  781. func (m *AgentMutation) ResetAPIBase() {
  782. m.api_base = nil
  783. delete(m.clearedFields, agent.FieldAPIBase)
  784. }
  785. // SetAPIKey sets the "api_key" field.
  786. func (m *AgentMutation) SetAPIKey(s string) {
  787. m.api_key = &s
  788. }
  789. // APIKey returns the value of the "api_key" field in the mutation.
  790. func (m *AgentMutation) APIKey() (r string, exists bool) {
  791. v := m.api_key
  792. if v == nil {
  793. return
  794. }
  795. return *v, true
  796. }
  797. // OldAPIKey returns the old "api_key" field's value of the Agent entity.
  798. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  799. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  800. func (m *AgentMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  801. if !m.op.Is(OpUpdateOne) {
  802. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  803. }
  804. if m.id == nil || m.oldValue == nil {
  805. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  806. }
  807. oldValue, err := m.oldValue(ctx)
  808. if err != nil {
  809. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  810. }
  811. return oldValue.APIKey, nil
  812. }
  813. // ClearAPIKey clears the value of the "api_key" field.
  814. func (m *AgentMutation) ClearAPIKey() {
  815. m.api_key = nil
  816. m.clearedFields[agent.FieldAPIKey] = struct{}{}
  817. }
  818. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  819. func (m *AgentMutation) APIKeyCleared() bool {
  820. _, ok := m.clearedFields[agent.FieldAPIKey]
  821. return ok
  822. }
  823. // ResetAPIKey resets all changes to the "api_key" field.
  824. func (m *AgentMutation) ResetAPIKey() {
  825. m.api_key = nil
  826. delete(m.clearedFields, agent.FieldAPIKey)
  827. }
  828. // SetType sets the "type" field.
  829. func (m *AgentMutation) SetType(i int) {
  830. m._type = &i
  831. m.add_type = nil
  832. }
  833. // GetType returns the value of the "type" field in the mutation.
  834. func (m *AgentMutation) GetType() (r int, exists bool) {
  835. v := m._type
  836. if v == nil {
  837. return
  838. }
  839. return *v, true
  840. }
  841. // OldType returns the old "type" field's value of the Agent entity.
  842. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  843. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  844. func (m *AgentMutation) OldType(ctx context.Context) (v int, err error) {
  845. if !m.op.Is(OpUpdateOne) {
  846. return v, errors.New("OldType is only allowed on UpdateOne operations")
  847. }
  848. if m.id == nil || m.oldValue == nil {
  849. return v, errors.New("OldType requires an ID field in the mutation")
  850. }
  851. oldValue, err := m.oldValue(ctx)
  852. if err != nil {
  853. return v, fmt.Errorf("querying old value for OldType: %w", err)
  854. }
  855. return oldValue.Type, nil
  856. }
  857. // AddType adds i to the "type" field.
  858. func (m *AgentMutation) AddType(i int) {
  859. if m.add_type != nil {
  860. *m.add_type += i
  861. } else {
  862. m.add_type = &i
  863. }
  864. }
  865. // AddedType returns the value that was added to the "type" field in this mutation.
  866. func (m *AgentMutation) AddedType() (r int, exists bool) {
  867. v := m.add_type
  868. if v == nil {
  869. return
  870. }
  871. return *v, true
  872. }
  873. // ClearType clears the value of the "type" field.
  874. func (m *AgentMutation) ClearType() {
  875. m._type = nil
  876. m.add_type = nil
  877. m.clearedFields[agent.FieldType] = struct{}{}
  878. }
  879. // TypeCleared returns if the "type" field was cleared in this mutation.
  880. func (m *AgentMutation) TypeCleared() bool {
  881. _, ok := m.clearedFields[agent.FieldType]
  882. return ok
  883. }
  884. // ResetType resets all changes to the "type" field.
  885. func (m *AgentMutation) ResetType() {
  886. m._type = nil
  887. m.add_type = nil
  888. delete(m.clearedFields, agent.FieldType)
  889. }
  890. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  891. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  892. if m.wx_agent == nil {
  893. m.wx_agent = make(map[uint64]struct{})
  894. }
  895. for i := range ids {
  896. m.wx_agent[ids[i]] = struct{}{}
  897. }
  898. }
  899. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  900. func (m *AgentMutation) ClearWxAgent() {
  901. m.clearedwx_agent = true
  902. }
  903. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  904. func (m *AgentMutation) WxAgentCleared() bool {
  905. return m.clearedwx_agent
  906. }
  907. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  908. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  909. if m.removedwx_agent == nil {
  910. m.removedwx_agent = make(map[uint64]struct{})
  911. }
  912. for i := range ids {
  913. delete(m.wx_agent, ids[i])
  914. m.removedwx_agent[ids[i]] = struct{}{}
  915. }
  916. }
  917. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  918. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  919. for id := range m.removedwx_agent {
  920. ids = append(ids, id)
  921. }
  922. return
  923. }
  924. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  925. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  926. for id := range m.wx_agent {
  927. ids = append(ids, id)
  928. }
  929. return
  930. }
  931. // ResetWxAgent resets all changes to the "wx_agent" edge.
  932. func (m *AgentMutation) ResetWxAgent() {
  933. m.wx_agent = nil
  934. m.clearedwx_agent = false
  935. m.removedwx_agent = nil
  936. }
  937. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  938. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  939. if m.token_agent == nil {
  940. m.token_agent = make(map[uint64]struct{})
  941. }
  942. for i := range ids {
  943. m.token_agent[ids[i]] = struct{}{}
  944. }
  945. }
  946. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  947. func (m *AgentMutation) ClearTokenAgent() {
  948. m.clearedtoken_agent = true
  949. }
  950. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  951. func (m *AgentMutation) TokenAgentCleared() bool {
  952. return m.clearedtoken_agent
  953. }
  954. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  955. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  956. if m.removedtoken_agent == nil {
  957. m.removedtoken_agent = make(map[uint64]struct{})
  958. }
  959. for i := range ids {
  960. delete(m.token_agent, ids[i])
  961. m.removedtoken_agent[ids[i]] = struct{}{}
  962. }
  963. }
  964. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  965. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  966. for id := range m.removedtoken_agent {
  967. ids = append(ids, id)
  968. }
  969. return
  970. }
  971. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  972. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  973. for id := range m.token_agent {
  974. ids = append(ids, id)
  975. }
  976. return
  977. }
  978. // ResetTokenAgent resets all changes to the "token_agent" edge.
  979. func (m *AgentMutation) ResetTokenAgent() {
  980. m.token_agent = nil
  981. m.clearedtoken_agent = false
  982. m.removedtoken_agent = nil
  983. }
  984. // AddWaAgentIDs adds the "wa_agent" edge to the Whatsapp entity by ids.
  985. func (m *AgentMutation) AddWaAgentIDs(ids ...uint64) {
  986. if m.wa_agent == nil {
  987. m.wa_agent = make(map[uint64]struct{})
  988. }
  989. for i := range ids {
  990. m.wa_agent[ids[i]] = struct{}{}
  991. }
  992. }
  993. // ClearWaAgent clears the "wa_agent" edge to the Whatsapp entity.
  994. func (m *AgentMutation) ClearWaAgent() {
  995. m.clearedwa_agent = true
  996. }
  997. // WaAgentCleared reports if the "wa_agent" edge to the Whatsapp entity was cleared.
  998. func (m *AgentMutation) WaAgentCleared() bool {
  999. return m.clearedwa_agent
  1000. }
  1001. // RemoveWaAgentIDs removes the "wa_agent" edge to the Whatsapp entity by IDs.
  1002. func (m *AgentMutation) RemoveWaAgentIDs(ids ...uint64) {
  1003. if m.removedwa_agent == nil {
  1004. m.removedwa_agent = make(map[uint64]struct{})
  1005. }
  1006. for i := range ids {
  1007. delete(m.wa_agent, ids[i])
  1008. m.removedwa_agent[ids[i]] = struct{}{}
  1009. }
  1010. }
  1011. // RemovedWaAgent returns the removed IDs of the "wa_agent" edge to the Whatsapp entity.
  1012. func (m *AgentMutation) RemovedWaAgentIDs() (ids []uint64) {
  1013. for id := range m.removedwa_agent {
  1014. ids = append(ids, id)
  1015. }
  1016. return
  1017. }
  1018. // WaAgentIDs returns the "wa_agent" edge IDs in the mutation.
  1019. func (m *AgentMutation) WaAgentIDs() (ids []uint64) {
  1020. for id := range m.wa_agent {
  1021. ids = append(ids, id)
  1022. }
  1023. return
  1024. }
  1025. // ResetWaAgent resets all changes to the "wa_agent" edge.
  1026. func (m *AgentMutation) ResetWaAgent() {
  1027. m.wa_agent = nil
  1028. m.clearedwa_agent = false
  1029. m.removedwa_agent = nil
  1030. }
  1031. // AddXjsAgentIDs adds the "xjs_agent" edge to the XunjiService entity by ids.
  1032. func (m *AgentMutation) AddXjsAgentIDs(ids ...uint64) {
  1033. if m.xjs_agent == nil {
  1034. m.xjs_agent = make(map[uint64]struct{})
  1035. }
  1036. for i := range ids {
  1037. m.xjs_agent[ids[i]] = struct{}{}
  1038. }
  1039. }
  1040. // ClearXjsAgent clears the "xjs_agent" edge to the XunjiService entity.
  1041. func (m *AgentMutation) ClearXjsAgent() {
  1042. m.clearedxjs_agent = true
  1043. }
  1044. // XjsAgentCleared reports if the "xjs_agent" edge to the XunjiService entity was cleared.
  1045. func (m *AgentMutation) XjsAgentCleared() bool {
  1046. return m.clearedxjs_agent
  1047. }
  1048. // RemoveXjsAgentIDs removes the "xjs_agent" edge to the XunjiService entity by IDs.
  1049. func (m *AgentMutation) RemoveXjsAgentIDs(ids ...uint64) {
  1050. if m.removedxjs_agent == nil {
  1051. m.removedxjs_agent = make(map[uint64]struct{})
  1052. }
  1053. for i := range ids {
  1054. delete(m.xjs_agent, ids[i])
  1055. m.removedxjs_agent[ids[i]] = struct{}{}
  1056. }
  1057. }
  1058. // RemovedXjsAgent returns the removed IDs of the "xjs_agent" edge to the XunjiService entity.
  1059. func (m *AgentMutation) RemovedXjsAgentIDs() (ids []uint64) {
  1060. for id := range m.removedxjs_agent {
  1061. ids = append(ids, id)
  1062. }
  1063. return
  1064. }
  1065. // XjsAgentIDs returns the "xjs_agent" edge IDs in the mutation.
  1066. func (m *AgentMutation) XjsAgentIDs() (ids []uint64) {
  1067. for id := range m.xjs_agent {
  1068. ids = append(ids, id)
  1069. }
  1070. return
  1071. }
  1072. // ResetXjsAgent resets all changes to the "xjs_agent" edge.
  1073. func (m *AgentMutation) ResetXjsAgent() {
  1074. m.xjs_agent = nil
  1075. m.clearedxjs_agent = false
  1076. m.removedxjs_agent = nil
  1077. }
  1078. // AddKeyAgentIDs adds the "key_agent" edge to the ApiKey entity by ids.
  1079. func (m *AgentMutation) AddKeyAgentIDs(ids ...uint64) {
  1080. if m.key_agent == nil {
  1081. m.key_agent = make(map[uint64]struct{})
  1082. }
  1083. for i := range ids {
  1084. m.key_agent[ids[i]] = struct{}{}
  1085. }
  1086. }
  1087. // ClearKeyAgent clears the "key_agent" edge to the ApiKey entity.
  1088. func (m *AgentMutation) ClearKeyAgent() {
  1089. m.clearedkey_agent = true
  1090. }
  1091. // KeyAgentCleared reports if the "key_agent" edge to the ApiKey entity was cleared.
  1092. func (m *AgentMutation) KeyAgentCleared() bool {
  1093. return m.clearedkey_agent
  1094. }
  1095. // RemoveKeyAgentIDs removes the "key_agent" edge to the ApiKey entity by IDs.
  1096. func (m *AgentMutation) RemoveKeyAgentIDs(ids ...uint64) {
  1097. if m.removedkey_agent == nil {
  1098. m.removedkey_agent = make(map[uint64]struct{})
  1099. }
  1100. for i := range ids {
  1101. delete(m.key_agent, ids[i])
  1102. m.removedkey_agent[ids[i]] = struct{}{}
  1103. }
  1104. }
  1105. // RemovedKeyAgent returns the removed IDs of the "key_agent" edge to the ApiKey entity.
  1106. func (m *AgentMutation) RemovedKeyAgentIDs() (ids []uint64) {
  1107. for id := range m.removedkey_agent {
  1108. ids = append(ids, id)
  1109. }
  1110. return
  1111. }
  1112. // KeyAgentIDs returns the "key_agent" edge IDs in the mutation.
  1113. func (m *AgentMutation) KeyAgentIDs() (ids []uint64) {
  1114. for id := range m.key_agent {
  1115. ids = append(ids, id)
  1116. }
  1117. return
  1118. }
  1119. // ResetKeyAgent resets all changes to the "key_agent" edge.
  1120. func (m *AgentMutation) ResetKeyAgent() {
  1121. m.key_agent = nil
  1122. m.clearedkey_agent = false
  1123. m.removedkey_agent = nil
  1124. }
  1125. // Where appends a list predicates to the AgentMutation builder.
  1126. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  1127. m.predicates = append(m.predicates, ps...)
  1128. }
  1129. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  1130. // users can use type-assertion to append predicates that do not depend on any generated package.
  1131. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  1132. p := make([]predicate.Agent, len(ps))
  1133. for i := range ps {
  1134. p[i] = ps[i]
  1135. }
  1136. m.Where(p...)
  1137. }
  1138. // Op returns the operation name.
  1139. func (m *AgentMutation) Op() Op {
  1140. return m.op
  1141. }
  1142. // SetOp allows setting the mutation operation.
  1143. func (m *AgentMutation) SetOp(op Op) {
  1144. m.op = op
  1145. }
  1146. // Type returns the node type of this mutation (Agent).
  1147. func (m *AgentMutation) Type() string {
  1148. return m.typ
  1149. }
  1150. // Fields returns all fields that were changed during this mutation. Note that in
  1151. // order to get all numeric fields that were incremented/decremented, call
  1152. // AddedFields().
  1153. func (m *AgentMutation) Fields() []string {
  1154. fields := make([]string, 0, 15)
  1155. if m.created_at != nil {
  1156. fields = append(fields, agent.FieldCreatedAt)
  1157. }
  1158. if m.updated_at != nil {
  1159. fields = append(fields, agent.FieldUpdatedAt)
  1160. }
  1161. if m.deleted_at != nil {
  1162. fields = append(fields, agent.FieldDeletedAt)
  1163. }
  1164. if m.name != nil {
  1165. fields = append(fields, agent.FieldName)
  1166. }
  1167. if m.role != nil {
  1168. fields = append(fields, agent.FieldRole)
  1169. }
  1170. if m.status != nil {
  1171. fields = append(fields, agent.FieldStatus)
  1172. }
  1173. if m.background != nil {
  1174. fields = append(fields, agent.FieldBackground)
  1175. }
  1176. if m.examples != nil {
  1177. fields = append(fields, agent.FieldExamples)
  1178. }
  1179. if m.organization_id != nil {
  1180. fields = append(fields, agent.FieldOrganizationID)
  1181. }
  1182. if m.dataset_id != nil {
  1183. fields = append(fields, agent.FieldDatasetID)
  1184. }
  1185. if m.collection_id != nil {
  1186. fields = append(fields, agent.FieldCollectionID)
  1187. }
  1188. if m.model != nil {
  1189. fields = append(fields, agent.FieldModel)
  1190. }
  1191. if m.api_base != nil {
  1192. fields = append(fields, agent.FieldAPIBase)
  1193. }
  1194. if m.api_key != nil {
  1195. fields = append(fields, agent.FieldAPIKey)
  1196. }
  1197. if m._type != nil {
  1198. fields = append(fields, agent.FieldType)
  1199. }
  1200. return fields
  1201. }
  1202. // Field returns the value of a field with the given name. The second boolean
  1203. // return value indicates that this field was not set, or was not defined in the
  1204. // schema.
  1205. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  1206. switch name {
  1207. case agent.FieldCreatedAt:
  1208. return m.CreatedAt()
  1209. case agent.FieldUpdatedAt:
  1210. return m.UpdatedAt()
  1211. case agent.FieldDeletedAt:
  1212. return m.DeletedAt()
  1213. case agent.FieldName:
  1214. return m.Name()
  1215. case agent.FieldRole:
  1216. return m.Role()
  1217. case agent.FieldStatus:
  1218. return m.Status()
  1219. case agent.FieldBackground:
  1220. return m.Background()
  1221. case agent.FieldExamples:
  1222. return m.Examples()
  1223. case agent.FieldOrganizationID:
  1224. return m.OrganizationID()
  1225. case agent.FieldDatasetID:
  1226. return m.DatasetID()
  1227. case agent.FieldCollectionID:
  1228. return m.CollectionID()
  1229. case agent.FieldModel:
  1230. return m.Model()
  1231. case agent.FieldAPIBase:
  1232. return m.APIBase()
  1233. case agent.FieldAPIKey:
  1234. return m.APIKey()
  1235. case agent.FieldType:
  1236. return m.GetType()
  1237. }
  1238. return nil, false
  1239. }
  1240. // OldField returns the old value of the field from the database. An error is
  1241. // returned if the mutation operation is not UpdateOne, or the query to the
  1242. // database failed.
  1243. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1244. switch name {
  1245. case agent.FieldCreatedAt:
  1246. return m.OldCreatedAt(ctx)
  1247. case agent.FieldUpdatedAt:
  1248. return m.OldUpdatedAt(ctx)
  1249. case agent.FieldDeletedAt:
  1250. return m.OldDeletedAt(ctx)
  1251. case agent.FieldName:
  1252. return m.OldName(ctx)
  1253. case agent.FieldRole:
  1254. return m.OldRole(ctx)
  1255. case agent.FieldStatus:
  1256. return m.OldStatus(ctx)
  1257. case agent.FieldBackground:
  1258. return m.OldBackground(ctx)
  1259. case agent.FieldExamples:
  1260. return m.OldExamples(ctx)
  1261. case agent.FieldOrganizationID:
  1262. return m.OldOrganizationID(ctx)
  1263. case agent.FieldDatasetID:
  1264. return m.OldDatasetID(ctx)
  1265. case agent.FieldCollectionID:
  1266. return m.OldCollectionID(ctx)
  1267. case agent.FieldModel:
  1268. return m.OldModel(ctx)
  1269. case agent.FieldAPIBase:
  1270. return m.OldAPIBase(ctx)
  1271. case agent.FieldAPIKey:
  1272. return m.OldAPIKey(ctx)
  1273. case agent.FieldType:
  1274. return m.OldType(ctx)
  1275. }
  1276. return nil, fmt.Errorf("unknown Agent field %s", name)
  1277. }
  1278. // SetField sets the value of a field with the given name. It returns an error if
  1279. // the field is not defined in the schema, or if the type mismatched the field
  1280. // type.
  1281. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  1282. switch name {
  1283. case agent.FieldCreatedAt:
  1284. v, ok := value.(time.Time)
  1285. if !ok {
  1286. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1287. }
  1288. m.SetCreatedAt(v)
  1289. return nil
  1290. case agent.FieldUpdatedAt:
  1291. v, ok := value.(time.Time)
  1292. if !ok {
  1293. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1294. }
  1295. m.SetUpdatedAt(v)
  1296. return nil
  1297. case agent.FieldDeletedAt:
  1298. v, ok := value.(time.Time)
  1299. if !ok {
  1300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1301. }
  1302. m.SetDeletedAt(v)
  1303. return nil
  1304. case agent.FieldName:
  1305. v, ok := value.(string)
  1306. if !ok {
  1307. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1308. }
  1309. m.SetName(v)
  1310. return nil
  1311. case agent.FieldRole:
  1312. v, ok := value.(string)
  1313. if !ok {
  1314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1315. }
  1316. m.SetRole(v)
  1317. return nil
  1318. case agent.FieldStatus:
  1319. v, ok := value.(int)
  1320. if !ok {
  1321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1322. }
  1323. m.SetStatus(v)
  1324. return nil
  1325. case agent.FieldBackground:
  1326. v, ok := value.(string)
  1327. if !ok {
  1328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1329. }
  1330. m.SetBackground(v)
  1331. return nil
  1332. case agent.FieldExamples:
  1333. v, ok := value.(string)
  1334. if !ok {
  1335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1336. }
  1337. m.SetExamples(v)
  1338. return nil
  1339. case agent.FieldOrganizationID:
  1340. v, ok := value.(uint64)
  1341. if !ok {
  1342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1343. }
  1344. m.SetOrganizationID(v)
  1345. return nil
  1346. case agent.FieldDatasetID:
  1347. v, ok := value.(string)
  1348. if !ok {
  1349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1350. }
  1351. m.SetDatasetID(v)
  1352. return nil
  1353. case agent.FieldCollectionID:
  1354. v, ok := value.(string)
  1355. if !ok {
  1356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1357. }
  1358. m.SetCollectionID(v)
  1359. return nil
  1360. case agent.FieldModel:
  1361. v, ok := value.(string)
  1362. if !ok {
  1363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1364. }
  1365. m.SetModel(v)
  1366. return nil
  1367. case agent.FieldAPIBase:
  1368. v, ok := value.(string)
  1369. if !ok {
  1370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1371. }
  1372. m.SetAPIBase(v)
  1373. return nil
  1374. case agent.FieldAPIKey:
  1375. v, ok := value.(string)
  1376. if !ok {
  1377. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1378. }
  1379. m.SetAPIKey(v)
  1380. return nil
  1381. case agent.FieldType:
  1382. v, ok := value.(int)
  1383. if !ok {
  1384. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1385. }
  1386. m.SetType(v)
  1387. return nil
  1388. }
  1389. return fmt.Errorf("unknown Agent field %s", name)
  1390. }
  1391. // AddedFields returns all numeric fields that were incremented/decremented during
  1392. // this mutation.
  1393. func (m *AgentMutation) AddedFields() []string {
  1394. var fields []string
  1395. if m.addstatus != nil {
  1396. fields = append(fields, agent.FieldStatus)
  1397. }
  1398. if m.addorganization_id != nil {
  1399. fields = append(fields, agent.FieldOrganizationID)
  1400. }
  1401. if m.add_type != nil {
  1402. fields = append(fields, agent.FieldType)
  1403. }
  1404. return fields
  1405. }
  1406. // AddedField returns the numeric value that was incremented/decremented on a field
  1407. // with the given name. The second boolean return value indicates that this field
  1408. // was not set, or was not defined in the schema.
  1409. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  1410. switch name {
  1411. case agent.FieldStatus:
  1412. return m.AddedStatus()
  1413. case agent.FieldOrganizationID:
  1414. return m.AddedOrganizationID()
  1415. case agent.FieldType:
  1416. return m.AddedType()
  1417. }
  1418. return nil, false
  1419. }
  1420. // AddField adds the value to the field with the given name. It returns an error if
  1421. // the field is not defined in the schema, or if the type mismatched the field
  1422. // type.
  1423. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  1424. switch name {
  1425. case agent.FieldStatus:
  1426. v, ok := value.(int)
  1427. if !ok {
  1428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1429. }
  1430. m.AddStatus(v)
  1431. return nil
  1432. case agent.FieldOrganizationID:
  1433. v, ok := value.(int64)
  1434. if !ok {
  1435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1436. }
  1437. m.AddOrganizationID(v)
  1438. return nil
  1439. case agent.FieldType:
  1440. v, ok := value.(int)
  1441. if !ok {
  1442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1443. }
  1444. m.AddType(v)
  1445. return nil
  1446. }
  1447. return fmt.Errorf("unknown Agent numeric field %s", name)
  1448. }
  1449. // ClearedFields returns all nullable fields that were cleared during this
  1450. // mutation.
  1451. func (m *AgentMutation) ClearedFields() []string {
  1452. var fields []string
  1453. if m.FieldCleared(agent.FieldDeletedAt) {
  1454. fields = append(fields, agent.FieldDeletedAt)
  1455. }
  1456. if m.FieldCleared(agent.FieldRole) {
  1457. fields = append(fields, agent.FieldRole)
  1458. }
  1459. if m.FieldCleared(agent.FieldStatus) {
  1460. fields = append(fields, agent.FieldStatus)
  1461. }
  1462. if m.FieldCleared(agent.FieldBackground) {
  1463. fields = append(fields, agent.FieldBackground)
  1464. }
  1465. if m.FieldCleared(agent.FieldExamples) {
  1466. fields = append(fields, agent.FieldExamples)
  1467. }
  1468. if m.FieldCleared(agent.FieldModel) {
  1469. fields = append(fields, agent.FieldModel)
  1470. }
  1471. if m.FieldCleared(agent.FieldAPIBase) {
  1472. fields = append(fields, agent.FieldAPIBase)
  1473. }
  1474. if m.FieldCleared(agent.FieldAPIKey) {
  1475. fields = append(fields, agent.FieldAPIKey)
  1476. }
  1477. if m.FieldCleared(agent.FieldType) {
  1478. fields = append(fields, agent.FieldType)
  1479. }
  1480. return fields
  1481. }
  1482. // FieldCleared returns a boolean indicating if a field with the given name was
  1483. // cleared in this mutation.
  1484. func (m *AgentMutation) FieldCleared(name string) bool {
  1485. _, ok := m.clearedFields[name]
  1486. return ok
  1487. }
  1488. // ClearField clears the value of the field with the given name. It returns an
  1489. // error if the field is not defined in the schema.
  1490. func (m *AgentMutation) ClearField(name string) error {
  1491. switch name {
  1492. case agent.FieldDeletedAt:
  1493. m.ClearDeletedAt()
  1494. return nil
  1495. case agent.FieldRole:
  1496. m.ClearRole()
  1497. return nil
  1498. case agent.FieldStatus:
  1499. m.ClearStatus()
  1500. return nil
  1501. case agent.FieldBackground:
  1502. m.ClearBackground()
  1503. return nil
  1504. case agent.FieldExamples:
  1505. m.ClearExamples()
  1506. return nil
  1507. case agent.FieldModel:
  1508. m.ClearModel()
  1509. return nil
  1510. case agent.FieldAPIBase:
  1511. m.ClearAPIBase()
  1512. return nil
  1513. case agent.FieldAPIKey:
  1514. m.ClearAPIKey()
  1515. return nil
  1516. case agent.FieldType:
  1517. m.ClearType()
  1518. return nil
  1519. }
  1520. return fmt.Errorf("unknown Agent nullable field %s", name)
  1521. }
  1522. // ResetField resets all changes in the mutation for the field with the given name.
  1523. // It returns an error if the field is not defined in the schema.
  1524. func (m *AgentMutation) ResetField(name string) error {
  1525. switch name {
  1526. case agent.FieldCreatedAt:
  1527. m.ResetCreatedAt()
  1528. return nil
  1529. case agent.FieldUpdatedAt:
  1530. m.ResetUpdatedAt()
  1531. return nil
  1532. case agent.FieldDeletedAt:
  1533. m.ResetDeletedAt()
  1534. return nil
  1535. case agent.FieldName:
  1536. m.ResetName()
  1537. return nil
  1538. case agent.FieldRole:
  1539. m.ResetRole()
  1540. return nil
  1541. case agent.FieldStatus:
  1542. m.ResetStatus()
  1543. return nil
  1544. case agent.FieldBackground:
  1545. m.ResetBackground()
  1546. return nil
  1547. case agent.FieldExamples:
  1548. m.ResetExamples()
  1549. return nil
  1550. case agent.FieldOrganizationID:
  1551. m.ResetOrganizationID()
  1552. return nil
  1553. case agent.FieldDatasetID:
  1554. m.ResetDatasetID()
  1555. return nil
  1556. case agent.FieldCollectionID:
  1557. m.ResetCollectionID()
  1558. return nil
  1559. case agent.FieldModel:
  1560. m.ResetModel()
  1561. return nil
  1562. case agent.FieldAPIBase:
  1563. m.ResetAPIBase()
  1564. return nil
  1565. case agent.FieldAPIKey:
  1566. m.ResetAPIKey()
  1567. return nil
  1568. case agent.FieldType:
  1569. m.ResetType()
  1570. return nil
  1571. }
  1572. return fmt.Errorf("unknown Agent field %s", name)
  1573. }
  1574. // AddedEdges returns all edge names that were set/added in this mutation.
  1575. func (m *AgentMutation) AddedEdges() []string {
  1576. edges := make([]string, 0, 5)
  1577. if m.wx_agent != nil {
  1578. edges = append(edges, agent.EdgeWxAgent)
  1579. }
  1580. if m.token_agent != nil {
  1581. edges = append(edges, agent.EdgeTokenAgent)
  1582. }
  1583. if m.wa_agent != nil {
  1584. edges = append(edges, agent.EdgeWaAgent)
  1585. }
  1586. if m.xjs_agent != nil {
  1587. edges = append(edges, agent.EdgeXjsAgent)
  1588. }
  1589. if m.key_agent != nil {
  1590. edges = append(edges, agent.EdgeKeyAgent)
  1591. }
  1592. return edges
  1593. }
  1594. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1595. // name in this mutation.
  1596. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1597. switch name {
  1598. case agent.EdgeWxAgent:
  1599. ids := make([]ent.Value, 0, len(m.wx_agent))
  1600. for id := range m.wx_agent {
  1601. ids = append(ids, id)
  1602. }
  1603. return ids
  1604. case agent.EdgeTokenAgent:
  1605. ids := make([]ent.Value, 0, len(m.token_agent))
  1606. for id := range m.token_agent {
  1607. ids = append(ids, id)
  1608. }
  1609. return ids
  1610. case agent.EdgeWaAgent:
  1611. ids := make([]ent.Value, 0, len(m.wa_agent))
  1612. for id := range m.wa_agent {
  1613. ids = append(ids, id)
  1614. }
  1615. return ids
  1616. case agent.EdgeXjsAgent:
  1617. ids := make([]ent.Value, 0, len(m.xjs_agent))
  1618. for id := range m.xjs_agent {
  1619. ids = append(ids, id)
  1620. }
  1621. return ids
  1622. case agent.EdgeKeyAgent:
  1623. ids := make([]ent.Value, 0, len(m.key_agent))
  1624. for id := range m.key_agent {
  1625. ids = append(ids, id)
  1626. }
  1627. return ids
  1628. }
  1629. return nil
  1630. }
  1631. // RemovedEdges returns all edge names that were removed in this mutation.
  1632. func (m *AgentMutation) RemovedEdges() []string {
  1633. edges := make([]string, 0, 5)
  1634. if m.removedwx_agent != nil {
  1635. edges = append(edges, agent.EdgeWxAgent)
  1636. }
  1637. if m.removedtoken_agent != nil {
  1638. edges = append(edges, agent.EdgeTokenAgent)
  1639. }
  1640. if m.removedwa_agent != nil {
  1641. edges = append(edges, agent.EdgeWaAgent)
  1642. }
  1643. if m.removedxjs_agent != nil {
  1644. edges = append(edges, agent.EdgeXjsAgent)
  1645. }
  1646. if m.removedkey_agent != nil {
  1647. edges = append(edges, agent.EdgeKeyAgent)
  1648. }
  1649. return edges
  1650. }
  1651. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1652. // the given name in this mutation.
  1653. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1654. switch name {
  1655. case agent.EdgeWxAgent:
  1656. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1657. for id := range m.removedwx_agent {
  1658. ids = append(ids, id)
  1659. }
  1660. return ids
  1661. case agent.EdgeTokenAgent:
  1662. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1663. for id := range m.removedtoken_agent {
  1664. ids = append(ids, id)
  1665. }
  1666. return ids
  1667. case agent.EdgeWaAgent:
  1668. ids := make([]ent.Value, 0, len(m.removedwa_agent))
  1669. for id := range m.removedwa_agent {
  1670. ids = append(ids, id)
  1671. }
  1672. return ids
  1673. case agent.EdgeXjsAgent:
  1674. ids := make([]ent.Value, 0, len(m.removedxjs_agent))
  1675. for id := range m.removedxjs_agent {
  1676. ids = append(ids, id)
  1677. }
  1678. return ids
  1679. case agent.EdgeKeyAgent:
  1680. ids := make([]ent.Value, 0, len(m.removedkey_agent))
  1681. for id := range m.removedkey_agent {
  1682. ids = append(ids, id)
  1683. }
  1684. return ids
  1685. }
  1686. return nil
  1687. }
  1688. // ClearedEdges returns all edge names that were cleared in this mutation.
  1689. func (m *AgentMutation) ClearedEdges() []string {
  1690. edges := make([]string, 0, 5)
  1691. if m.clearedwx_agent {
  1692. edges = append(edges, agent.EdgeWxAgent)
  1693. }
  1694. if m.clearedtoken_agent {
  1695. edges = append(edges, agent.EdgeTokenAgent)
  1696. }
  1697. if m.clearedwa_agent {
  1698. edges = append(edges, agent.EdgeWaAgent)
  1699. }
  1700. if m.clearedxjs_agent {
  1701. edges = append(edges, agent.EdgeXjsAgent)
  1702. }
  1703. if m.clearedkey_agent {
  1704. edges = append(edges, agent.EdgeKeyAgent)
  1705. }
  1706. return edges
  1707. }
  1708. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1709. // was cleared in this mutation.
  1710. func (m *AgentMutation) EdgeCleared(name string) bool {
  1711. switch name {
  1712. case agent.EdgeWxAgent:
  1713. return m.clearedwx_agent
  1714. case agent.EdgeTokenAgent:
  1715. return m.clearedtoken_agent
  1716. case agent.EdgeWaAgent:
  1717. return m.clearedwa_agent
  1718. case agent.EdgeXjsAgent:
  1719. return m.clearedxjs_agent
  1720. case agent.EdgeKeyAgent:
  1721. return m.clearedkey_agent
  1722. }
  1723. return false
  1724. }
  1725. // ClearEdge clears the value of the edge with the given name. It returns an error
  1726. // if that edge is not defined in the schema.
  1727. func (m *AgentMutation) ClearEdge(name string) error {
  1728. switch name {
  1729. }
  1730. return fmt.Errorf("unknown Agent unique edge %s", name)
  1731. }
  1732. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1733. // It returns an error if the edge is not defined in the schema.
  1734. func (m *AgentMutation) ResetEdge(name string) error {
  1735. switch name {
  1736. case agent.EdgeWxAgent:
  1737. m.ResetWxAgent()
  1738. return nil
  1739. case agent.EdgeTokenAgent:
  1740. m.ResetTokenAgent()
  1741. return nil
  1742. case agent.EdgeWaAgent:
  1743. m.ResetWaAgent()
  1744. return nil
  1745. case agent.EdgeXjsAgent:
  1746. m.ResetXjsAgent()
  1747. return nil
  1748. case agent.EdgeKeyAgent:
  1749. m.ResetKeyAgent()
  1750. return nil
  1751. }
  1752. return fmt.Errorf("unknown Agent edge %s", name)
  1753. }
  1754. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1755. type AgentBaseMutation struct {
  1756. config
  1757. op Op
  1758. typ string
  1759. id *string
  1760. q *string
  1761. a *string
  1762. chunk_index *uint64
  1763. addchunk_index *int64
  1764. indexes *[]string
  1765. appendindexes []string
  1766. dataset_id *string
  1767. collection_id *string
  1768. source_name *string
  1769. can_write *[]bool
  1770. appendcan_write []bool
  1771. is_owner *[]bool
  1772. appendis_owner []bool
  1773. clearedFields map[string]struct{}
  1774. wx_agent map[uint64]struct{}
  1775. removedwx_agent map[uint64]struct{}
  1776. clearedwx_agent bool
  1777. done bool
  1778. oldValue func(context.Context) (*AgentBase, error)
  1779. predicates []predicate.AgentBase
  1780. }
  1781. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1782. // agentbaseOption allows management of the mutation configuration using functional options.
  1783. type agentbaseOption func(*AgentBaseMutation)
  1784. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1785. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1786. m := &AgentBaseMutation{
  1787. config: c,
  1788. op: op,
  1789. typ: TypeAgentBase,
  1790. clearedFields: make(map[string]struct{}),
  1791. }
  1792. for _, opt := range opts {
  1793. opt(m)
  1794. }
  1795. return m
  1796. }
  1797. // withAgentBaseID sets the ID field of the mutation.
  1798. func withAgentBaseID(id string) agentbaseOption {
  1799. return func(m *AgentBaseMutation) {
  1800. var (
  1801. err error
  1802. once sync.Once
  1803. value *AgentBase
  1804. )
  1805. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1806. once.Do(func() {
  1807. if m.done {
  1808. err = errors.New("querying old values post mutation is not allowed")
  1809. } else {
  1810. value, err = m.Client().AgentBase.Get(ctx, id)
  1811. }
  1812. })
  1813. return value, err
  1814. }
  1815. m.id = &id
  1816. }
  1817. }
  1818. // withAgentBase sets the old AgentBase of the mutation.
  1819. func withAgentBase(node *AgentBase) agentbaseOption {
  1820. return func(m *AgentBaseMutation) {
  1821. m.oldValue = func(context.Context) (*AgentBase, error) {
  1822. return node, nil
  1823. }
  1824. m.id = &node.ID
  1825. }
  1826. }
  1827. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1828. // executed in a transaction (ent.Tx), a transactional client is returned.
  1829. func (m AgentBaseMutation) Client() *Client {
  1830. client := &Client{config: m.config}
  1831. client.init()
  1832. return client
  1833. }
  1834. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1835. // it returns an error otherwise.
  1836. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1837. if _, ok := m.driver.(*txDriver); !ok {
  1838. return nil, errors.New("ent: mutation is not running in a transaction")
  1839. }
  1840. tx := &Tx{config: m.config}
  1841. tx.init()
  1842. return tx, nil
  1843. }
  1844. // SetID sets the value of the id field. Note that this
  1845. // operation is only accepted on creation of AgentBase entities.
  1846. func (m *AgentBaseMutation) SetID(id string) {
  1847. m.id = &id
  1848. }
  1849. // ID returns the ID value in the mutation. Note that the ID is only available
  1850. // if it was provided to the builder or after it was returned from the database.
  1851. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1852. if m.id == nil {
  1853. return
  1854. }
  1855. return *m.id, true
  1856. }
  1857. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1858. // That means, if the mutation is applied within a transaction with an isolation level such
  1859. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1860. // or updated by the mutation.
  1861. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1862. switch {
  1863. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1864. id, exists := m.ID()
  1865. if exists {
  1866. return []string{id}, nil
  1867. }
  1868. fallthrough
  1869. case m.op.Is(OpUpdate | OpDelete):
  1870. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1871. default:
  1872. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1873. }
  1874. }
  1875. // SetQ sets the "q" field.
  1876. func (m *AgentBaseMutation) SetQ(s string) {
  1877. m.q = &s
  1878. }
  1879. // Q returns the value of the "q" field in the mutation.
  1880. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1881. v := m.q
  1882. if v == nil {
  1883. return
  1884. }
  1885. return *v, true
  1886. }
  1887. // OldQ returns the old "q" field's value of the AgentBase entity.
  1888. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1889. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1890. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1891. if !m.op.Is(OpUpdateOne) {
  1892. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1893. }
  1894. if m.id == nil || m.oldValue == nil {
  1895. return v, errors.New("OldQ requires an ID field in the mutation")
  1896. }
  1897. oldValue, err := m.oldValue(ctx)
  1898. if err != nil {
  1899. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1900. }
  1901. return oldValue.Q, nil
  1902. }
  1903. // ClearQ clears the value of the "q" field.
  1904. func (m *AgentBaseMutation) ClearQ() {
  1905. m.q = nil
  1906. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1907. }
  1908. // QCleared returns if the "q" field was cleared in this mutation.
  1909. func (m *AgentBaseMutation) QCleared() bool {
  1910. _, ok := m.clearedFields[agentbase.FieldQ]
  1911. return ok
  1912. }
  1913. // ResetQ resets all changes to the "q" field.
  1914. func (m *AgentBaseMutation) ResetQ() {
  1915. m.q = nil
  1916. delete(m.clearedFields, agentbase.FieldQ)
  1917. }
  1918. // SetA sets the "a" field.
  1919. func (m *AgentBaseMutation) SetA(s string) {
  1920. m.a = &s
  1921. }
  1922. // A returns the value of the "a" field in the mutation.
  1923. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1924. v := m.a
  1925. if v == nil {
  1926. return
  1927. }
  1928. return *v, true
  1929. }
  1930. // OldA returns the old "a" field's value of the AgentBase entity.
  1931. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1932. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1933. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1934. if !m.op.Is(OpUpdateOne) {
  1935. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1936. }
  1937. if m.id == nil || m.oldValue == nil {
  1938. return v, errors.New("OldA requires an ID field in the mutation")
  1939. }
  1940. oldValue, err := m.oldValue(ctx)
  1941. if err != nil {
  1942. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1943. }
  1944. return oldValue.A, nil
  1945. }
  1946. // ClearA clears the value of the "a" field.
  1947. func (m *AgentBaseMutation) ClearA() {
  1948. m.a = nil
  1949. m.clearedFields[agentbase.FieldA] = struct{}{}
  1950. }
  1951. // ACleared returns if the "a" field was cleared in this mutation.
  1952. func (m *AgentBaseMutation) ACleared() bool {
  1953. _, ok := m.clearedFields[agentbase.FieldA]
  1954. return ok
  1955. }
  1956. // ResetA resets all changes to the "a" field.
  1957. func (m *AgentBaseMutation) ResetA() {
  1958. m.a = nil
  1959. delete(m.clearedFields, agentbase.FieldA)
  1960. }
  1961. // SetChunkIndex sets the "chunk_index" field.
  1962. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1963. m.chunk_index = &u
  1964. m.addchunk_index = nil
  1965. }
  1966. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1967. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1968. v := m.chunk_index
  1969. if v == nil {
  1970. return
  1971. }
  1972. return *v, true
  1973. }
  1974. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1975. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1976. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1977. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1978. if !m.op.Is(OpUpdateOne) {
  1979. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1980. }
  1981. if m.id == nil || m.oldValue == nil {
  1982. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1983. }
  1984. oldValue, err := m.oldValue(ctx)
  1985. if err != nil {
  1986. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1987. }
  1988. return oldValue.ChunkIndex, nil
  1989. }
  1990. // AddChunkIndex adds u to the "chunk_index" field.
  1991. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1992. if m.addchunk_index != nil {
  1993. *m.addchunk_index += u
  1994. } else {
  1995. m.addchunk_index = &u
  1996. }
  1997. }
  1998. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1999. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  2000. v := m.addchunk_index
  2001. if v == nil {
  2002. return
  2003. }
  2004. return *v, true
  2005. }
  2006. // ResetChunkIndex resets all changes to the "chunk_index" field.
  2007. func (m *AgentBaseMutation) ResetChunkIndex() {
  2008. m.chunk_index = nil
  2009. m.addchunk_index = nil
  2010. }
  2011. // SetIndexes sets the "indexes" field.
  2012. func (m *AgentBaseMutation) SetIndexes(s []string) {
  2013. m.indexes = &s
  2014. m.appendindexes = nil
  2015. }
  2016. // Indexes returns the value of the "indexes" field in the mutation.
  2017. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  2018. v := m.indexes
  2019. if v == nil {
  2020. return
  2021. }
  2022. return *v, true
  2023. }
  2024. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  2025. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2026. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2027. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  2028. if !m.op.Is(OpUpdateOne) {
  2029. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  2030. }
  2031. if m.id == nil || m.oldValue == nil {
  2032. return v, errors.New("OldIndexes requires an ID field in the mutation")
  2033. }
  2034. oldValue, err := m.oldValue(ctx)
  2035. if err != nil {
  2036. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  2037. }
  2038. return oldValue.Indexes, nil
  2039. }
  2040. // AppendIndexes adds s to the "indexes" field.
  2041. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  2042. m.appendindexes = append(m.appendindexes, s...)
  2043. }
  2044. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  2045. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  2046. if len(m.appendindexes) == 0 {
  2047. return nil, false
  2048. }
  2049. return m.appendindexes, true
  2050. }
  2051. // ClearIndexes clears the value of the "indexes" field.
  2052. func (m *AgentBaseMutation) ClearIndexes() {
  2053. m.indexes = nil
  2054. m.appendindexes = nil
  2055. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  2056. }
  2057. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  2058. func (m *AgentBaseMutation) IndexesCleared() bool {
  2059. _, ok := m.clearedFields[agentbase.FieldIndexes]
  2060. return ok
  2061. }
  2062. // ResetIndexes resets all changes to the "indexes" field.
  2063. func (m *AgentBaseMutation) ResetIndexes() {
  2064. m.indexes = nil
  2065. m.appendindexes = nil
  2066. delete(m.clearedFields, agentbase.FieldIndexes)
  2067. }
  2068. // SetDatasetID sets the "dataset_id" field.
  2069. func (m *AgentBaseMutation) SetDatasetID(s string) {
  2070. m.dataset_id = &s
  2071. }
  2072. // DatasetID returns the value of the "dataset_id" field in the mutation.
  2073. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  2074. v := m.dataset_id
  2075. if v == nil {
  2076. return
  2077. }
  2078. return *v, true
  2079. }
  2080. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  2081. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2082. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2083. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  2084. if !m.op.Is(OpUpdateOne) {
  2085. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  2086. }
  2087. if m.id == nil || m.oldValue == nil {
  2088. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  2089. }
  2090. oldValue, err := m.oldValue(ctx)
  2091. if err != nil {
  2092. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  2093. }
  2094. return oldValue.DatasetID, nil
  2095. }
  2096. // ClearDatasetID clears the value of the "dataset_id" field.
  2097. func (m *AgentBaseMutation) ClearDatasetID() {
  2098. m.dataset_id = nil
  2099. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  2100. }
  2101. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  2102. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  2103. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  2104. return ok
  2105. }
  2106. // ResetDatasetID resets all changes to the "dataset_id" field.
  2107. func (m *AgentBaseMutation) ResetDatasetID() {
  2108. m.dataset_id = nil
  2109. delete(m.clearedFields, agentbase.FieldDatasetID)
  2110. }
  2111. // SetCollectionID sets the "collection_id" field.
  2112. func (m *AgentBaseMutation) SetCollectionID(s string) {
  2113. m.collection_id = &s
  2114. }
  2115. // CollectionID returns the value of the "collection_id" field in the mutation.
  2116. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  2117. v := m.collection_id
  2118. if v == nil {
  2119. return
  2120. }
  2121. return *v, true
  2122. }
  2123. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  2124. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2125. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2126. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  2127. if !m.op.Is(OpUpdateOne) {
  2128. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  2129. }
  2130. if m.id == nil || m.oldValue == nil {
  2131. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  2132. }
  2133. oldValue, err := m.oldValue(ctx)
  2134. if err != nil {
  2135. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  2136. }
  2137. return oldValue.CollectionID, nil
  2138. }
  2139. // ClearCollectionID clears the value of the "collection_id" field.
  2140. func (m *AgentBaseMutation) ClearCollectionID() {
  2141. m.collection_id = nil
  2142. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  2143. }
  2144. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  2145. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  2146. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  2147. return ok
  2148. }
  2149. // ResetCollectionID resets all changes to the "collection_id" field.
  2150. func (m *AgentBaseMutation) ResetCollectionID() {
  2151. m.collection_id = nil
  2152. delete(m.clearedFields, agentbase.FieldCollectionID)
  2153. }
  2154. // SetSourceName sets the "source_name" field.
  2155. func (m *AgentBaseMutation) SetSourceName(s string) {
  2156. m.source_name = &s
  2157. }
  2158. // SourceName returns the value of the "source_name" field in the mutation.
  2159. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  2160. v := m.source_name
  2161. if v == nil {
  2162. return
  2163. }
  2164. return *v, true
  2165. }
  2166. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  2167. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2168. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2169. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  2170. if !m.op.Is(OpUpdateOne) {
  2171. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  2172. }
  2173. if m.id == nil || m.oldValue == nil {
  2174. return v, errors.New("OldSourceName requires an ID field in the mutation")
  2175. }
  2176. oldValue, err := m.oldValue(ctx)
  2177. if err != nil {
  2178. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  2179. }
  2180. return oldValue.SourceName, nil
  2181. }
  2182. // ClearSourceName clears the value of the "source_name" field.
  2183. func (m *AgentBaseMutation) ClearSourceName() {
  2184. m.source_name = nil
  2185. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  2186. }
  2187. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  2188. func (m *AgentBaseMutation) SourceNameCleared() bool {
  2189. _, ok := m.clearedFields[agentbase.FieldSourceName]
  2190. return ok
  2191. }
  2192. // ResetSourceName resets all changes to the "source_name" field.
  2193. func (m *AgentBaseMutation) ResetSourceName() {
  2194. m.source_name = nil
  2195. delete(m.clearedFields, agentbase.FieldSourceName)
  2196. }
  2197. // SetCanWrite sets the "can_write" field.
  2198. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  2199. m.can_write = &b
  2200. m.appendcan_write = nil
  2201. }
  2202. // CanWrite returns the value of the "can_write" field in the mutation.
  2203. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  2204. v := m.can_write
  2205. if v == nil {
  2206. return
  2207. }
  2208. return *v, true
  2209. }
  2210. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  2211. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2212. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2213. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  2214. if !m.op.Is(OpUpdateOne) {
  2215. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  2216. }
  2217. if m.id == nil || m.oldValue == nil {
  2218. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  2219. }
  2220. oldValue, err := m.oldValue(ctx)
  2221. if err != nil {
  2222. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  2223. }
  2224. return oldValue.CanWrite, nil
  2225. }
  2226. // AppendCanWrite adds b to the "can_write" field.
  2227. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  2228. m.appendcan_write = append(m.appendcan_write, b...)
  2229. }
  2230. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  2231. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  2232. if len(m.appendcan_write) == 0 {
  2233. return nil, false
  2234. }
  2235. return m.appendcan_write, true
  2236. }
  2237. // ClearCanWrite clears the value of the "can_write" field.
  2238. func (m *AgentBaseMutation) ClearCanWrite() {
  2239. m.can_write = nil
  2240. m.appendcan_write = nil
  2241. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  2242. }
  2243. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  2244. func (m *AgentBaseMutation) CanWriteCleared() bool {
  2245. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  2246. return ok
  2247. }
  2248. // ResetCanWrite resets all changes to the "can_write" field.
  2249. func (m *AgentBaseMutation) ResetCanWrite() {
  2250. m.can_write = nil
  2251. m.appendcan_write = nil
  2252. delete(m.clearedFields, agentbase.FieldCanWrite)
  2253. }
  2254. // SetIsOwner sets the "is_owner" field.
  2255. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  2256. m.is_owner = &b
  2257. m.appendis_owner = nil
  2258. }
  2259. // IsOwner returns the value of the "is_owner" field in the mutation.
  2260. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  2261. v := m.is_owner
  2262. if v == nil {
  2263. return
  2264. }
  2265. return *v, true
  2266. }
  2267. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  2268. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2269. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2270. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  2271. if !m.op.Is(OpUpdateOne) {
  2272. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  2273. }
  2274. if m.id == nil || m.oldValue == nil {
  2275. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  2276. }
  2277. oldValue, err := m.oldValue(ctx)
  2278. if err != nil {
  2279. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  2280. }
  2281. return oldValue.IsOwner, nil
  2282. }
  2283. // AppendIsOwner adds b to the "is_owner" field.
  2284. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  2285. m.appendis_owner = append(m.appendis_owner, b...)
  2286. }
  2287. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  2288. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  2289. if len(m.appendis_owner) == 0 {
  2290. return nil, false
  2291. }
  2292. return m.appendis_owner, true
  2293. }
  2294. // ClearIsOwner clears the value of the "is_owner" field.
  2295. func (m *AgentBaseMutation) ClearIsOwner() {
  2296. m.is_owner = nil
  2297. m.appendis_owner = nil
  2298. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  2299. }
  2300. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  2301. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  2302. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  2303. return ok
  2304. }
  2305. // ResetIsOwner resets all changes to the "is_owner" field.
  2306. func (m *AgentBaseMutation) ResetIsOwner() {
  2307. m.is_owner = nil
  2308. m.appendis_owner = nil
  2309. delete(m.clearedFields, agentbase.FieldIsOwner)
  2310. }
  2311. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  2312. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  2313. if m.wx_agent == nil {
  2314. m.wx_agent = make(map[uint64]struct{})
  2315. }
  2316. for i := range ids {
  2317. m.wx_agent[ids[i]] = struct{}{}
  2318. }
  2319. }
  2320. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  2321. func (m *AgentBaseMutation) ClearWxAgent() {
  2322. m.clearedwx_agent = true
  2323. }
  2324. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  2325. func (m *AgentBaseMutation) WxAgentCleared() bool {
  2326. return m.clearedwx_agent
  2327. }
  2328. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  2329. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  2330. if m.removedwx_agent == nil {
  2331. m.removedwx_agent = make(map[uint64]struct{})
  2332. }
  2333. for i := range ids {
  2334. delete(m.wx_agent, ids[i])
  2335. m.removedwx_agent[ids[i]] = struct{}{}
  2336. }
  2337. }
  2338. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  2339. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  2340. for id := range m.removedwx_agent {
  2341. ids = append(ids, id)
  2342. }
  2343. return
  2344. }
  2345. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  2346. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  2347. for id := range m.wx_agent {
  2348. ids = append(ids, id)
  2349. }
  2350. return
  2351. }
  2352. // ResetWxAgent resets all changes to the "wx_agent" edge.
  2353. func (m *AgentBaseMutation) ResetWxAgent() {
  2354. m.wx_agent = nil
  2355. m.clearedwx_agent = false
  2356. m.removedwx_agent = nil
  2357. }
  2358. // Where appends a list predicates to the AgentBaseMutation builder.
  2359. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  2360. m.predicates = append(m.predicates, ps...)
  2361. }
  2362. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  2363. // users can use type-assertion to append predicates that do not depend on any generated package.
  2364. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  2365. p := make([]predicate.AgentBase, len(ps))
  2366. for i := range ps {
  2367. p[i] = ps[i]
  2368. }
  2369. m.Where(p...)
  2370. }
  2371. // Op returns the operation name.
  2372. func (m *AgentBaseMutation) Op() Op {
  2373. return m.op
  2374. }
  2375. // SetOp allows setting the mutation operation.
  2376. func (m *AgentBaseMutation) SetOp(op Op) {
  2377. m.op = op
  2378. }
  2379. // Type returns the node type of this mutation (AgentBase).
  2380. func (m *AgentBaseMutation) Type() string {
  2381. return m.typ
  2382. }
  2383. // Fields returns all fields that were changed during this mutation. Note that in
  2384. // order to get all numeric fields that were incremented/decremented, call
  2385. // AddedFields().
  2386. func (m *AgentBaseMutation) Fields() []string {
  2387. fields := make([]string, 0, 9)
  2388. if m.q != nil {
  2389. fields = append(fields, agentbase.FieldQ)
  2390. }
  2391. if m.a != nil {
  2392. fields = append(fields, agentbase.FieldA)
  2393. }
  2394. if m.chunk_index != nil {
  2395. fields = append(fields, agentbase.FieldChunkIndex)
  2396. }
  2397. if m.indexes != nil {
  2398. fields = append(fields, agentbase.FieldIndexes)
  2399. }
  2400. if m.dataset_id != nil {
  2401. fields = append(fields, agentbase.FieldDatasetID)
  2402. }
  2403. if m.collection_id != nil {
  2404. fields = append(fields, agentbase.FieldCollectionID)
  2405. }
  2406. if m.source_name != nil {
  2407. fields = append(fields, agentbase.FieldSourceName)
  2408. }
  2409. if m.can_write != nil {
  2410. fields = append(fields, agentbase.FieldCanWrite)
  2411. }
  2412. if m.is_owner != nil {
  2413. fields = append(fields, agentbase.FieldIsOwner)
  2414. }
  2415. return fields
  2416. }
  2417. // Field returns the value of a field with the given name. The second boolean
  2418. // return value indicates that this field was not set, or was not defined in the
  2419. // schema.
  2420. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  2421. switch name {
  2422. case agentbase.FieldQ:
  2423. return m.Q()
  2424. case agentbase.FieldA:
  2425. return m.A()
  2426. case agentbase.FieldChunkIndex:
  2427. return m.ChunkIndex()
  2428. case agentbase.FieldIndexes:
  2429. return m.Indexes()
  2430. case agentbase.FieldDatasetID:
  2431. return m.DatasetID()
  2432. case agentbase.FieldCollectionID:
  2433. return m.CollectionID()
  2434. case agentbase.FieldSourceName:
  2435. return m.SourceName()
  2436. case agentbase.FieldCanWrite:
  2437. return m.CanWrite()
  2438. case agentbase.FieldIsOwner:
  2439. return m.IsOwner()
  2440. }
  2441. return nil, false
  2442. }
  2443. // OldField returns the old value of the field from the database. An error is
  2444. // returned if the mutation operation is not UpdateOne, or the query to the
  2445. // database failed.
  2446. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2447. switch name {
  2448. case agentbase.FieldQ:
  2449. return m.OldQ(ctx)
  2450. case agentbase.FieldA:
  2451. return m.OldA(ctx)
  2452. case agentbase.FieldChunkIndex:
  2453. return m.OldChunkIndex(ctx)
  2454. case agentbase.FieldIndexes:
  2455. return m.OldIndexes(ctx)
  2456. case agentbase.FieldDatasetID:
  2457. return m.OldDatasetID(ctx)
  2458. case agentbase.FieldCollectionID:
  2459. return m.OldCollectionID(ctx)
  2460. case agentbase.FieldSourceName:
  2461. return m.OldSourceName(ctx)
  2462. case agentbase.FieldCanWrite:
  2463. return m.OldCanWrite(ctx)
  2464. case agentbase.FieldIsOwner:
  2465. return m.OldIsOwner(ctx)
  2466. }
  2467. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  2468. }
  2469. // SetField sets the value of a field with the given name. It returns an error if
  2470. // the field is not defined in the schema, or if the type mismatched the field
  2471. // type.
  2472. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  2473. switch name {
  2474. case agentbase.FieldQ:
  2475. v, ok := value.(string)
  2476. if !ok {
  2477. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2478. }
  2479. m.SetQ(v)
  2480. return nil
  2481. case agentbase.FieldA:
  2482. v, ok := value.(string)
  2483. if !ok {
  2484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2485. }
  2486. m.SetA(v)
  2487. return nil
  2488. case agentbase.FieldChunkIndex:
  2489. v, ok := value.(uint64)
  2490. if !ok {
  2491. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2492. }
  2493. m.SetChunkIndex(v)
  2494. return nil
  2495. case agentbase.FieldIndexes:
  2496. v, ok := value.([]string)
  2497. if !ok {
  2498. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2499. }
  2500. m.SetIndexes(v)
  2501. return nil
  2502. case agentbase.FieldDatasetID:
  2503. v, ok := value.(string)
  2504. if !ok {
  2505. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2506. }
  2507. m.SetDatasetID(v)
  2508. return nil
  2509. case agentbase.FieldCollectionID:
  2510. v, ok := value.(string)
  2511. if !ok {
  2512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2513. }
  2514. m.SetCollectionID(v)
  2515. return nil
  2516. case agentbase.FieldSourceName:
  2517. v, ok := value.(string)
  2518. if !ok {
  2519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2520. }
  2521. m.SetSourceName(v)
  2522. return nil
  2523. case agentbase.FieldCanWrite:
  2524. v, ok := value.([]bool)
  2525. if !ok {
  2526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2527. }
  2528. m.SetCanWrite(v)
  2529. return nil
  2530. case agentbase.FieldIsOwner:
  2531. v, ok := value.([]bool)
  2532. if !ok {
  2533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2534. }
  2535. m.SetIsOwner(v)
  2536. return nil
  2537. }
  2538. return fmt.Errorf("unknown AgentBase field %s", name)
  2539. }
  2540. // AddedFields returns all numeric fields that were incremented/decremented during
  2541. // this mutation.
  2542. func (m *AgentBaseMutation) AddedFields() []string {
  2543. var fields []string
  2544. if m.addchunk_index != nil {
  2545. fields = append(fields, agentbase.FieldChunkIndex)
  2546. }
  2547. return fields
  2548. }
  2549. // AddedField returns the numeric value that was incremented/decremented on a field
  2550. // with the given name. The second boolean return value indicates that this field
  2551. // was not set, or was not defined in the schema.
  2552. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  2553. switch name {
  2554. case agentbase.FieldChunkIndex:
  2555. return m.AddedChunkIndex()
  2556. }
  2557. return nil, false
  2558. }
  2559. // AddField adds the value to the field with the given name. It returns an error if
  2560. // the field is not defined in the schema, or if the type mismatched the field
  2561. // type.
  2562. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  2563. switch name {
  2564. case agentbase.FieldChunkIndex:
  2565. v, ok := value.(int64)
  2566. if !ok {
  2567. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2568. }
  2569. m.AddChunkIndex(v)
  2570. return nil
  2571. }
  2572. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  2573. }
  2574. // ClearedFields returns all nullable fields that were cleared during this
  2575. // mutation.
  2576. func (m *AgentBaseMutation) ClearedFields() []string {
  2577. var fields []string
  2578. if m.FieldCleared(agentbase.FieldQ) {
  2579. fields = append(fields, agentbase.FieldQ)
  2580. }
  2581. if m.FieldCleared(agentbase.FieldA) {
  2582. fields = append(fields, agentbase.FieldA)
  2583. }
  2584. if m.FieldCleared(agentbase.FieldIndexes) {
  2585. fields = append(fields, agentbase.FieldIndexes)
  2586. }
  2587. if m.FieldCleared(agentbase.FieldDatasetID) {
  2588. fields = append(fields, agentbase.FieldDatasetID)
  2589. }
  2590. if m.FieldCleared(agentbase.FieldCollectionID) {
  2591. fields = append(fields, agentbase.FieldCollectionID)
  2592. }
  2593. if m.FieldCleared(agentbase.FieldSourceName) {
  2594. fields = append(fields, agentbase.FieldSourceName)
  2595. }
  2596. if m.FieldCleared(agentbase.FieldCanWrite) {
  2597. fields = append(fields, agentbase.FieldCanWrite)
  2598. }
  2599. if m.FieldCleared(agentbase.FieldIsOwner) {
  2600. fields = append(fields, agentbase.FieldIsOwner)
  2601. }
  2602. return fields
  2603. }
  2604. // FieldCleared returns a boolean indicating if a field with the given name was
  2605. // cleared in this mutation.
  2606. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2607. _, ok := m.clearedFields[name]
  2608. return ok
  2609. }
  2610. // ClearField clears the value of the field with the given name. It returns an
  2611. // error if the field is not defined in the schema.
  2612. func (m *AgentBaseMutation) ClearField(name string) error {
  2613. switch name {
  2614. case agentbase.FieldQ:
  2615. m.ClearQ()
  2616. return nil
  2617. case agentbase.FieldA:
  2618. m.ClearA()
  2619. return nil
  2620. case agentbase.FieldIndexes:
  2621. m.ClearIndexes()
  2622. return nil
  2623. case agentbase.FieldDatasetID:
  2624. m.ClearDatasetID()
  2625. return nil
  2626. case agentbase.FieldCollectionID:
  2627. m.ClearCollectionID()
  2628. return nil
  2629. case agentbase.FieldSourceName:
  2630. m.ClearSourceName()
  2631. return nil
  2632. case agentbase.FieldCanWrite:
  2633. m.ClearCanWrite()
  2634. return nil
  2635. case agentbase.FieldIsOwner:
  2636. m.ClearIsOwner()
  2637. return nil
  2638. }
  2639. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2640. }
  2641. // ResetField resets all changes in the mutation for the field with the given name.
  2642. // It returns an error if the field is not defined in the schema.
  2643. func (m *AgentBaseMutation) ResetField(name string) error {
  2644. switch name {
  2645. case agentbase.FieldQ:
  2646. m.ResetQ()
  2647. return nil
  2648. case agentbase.FieldA:
  2649. m.ResetA()
  2650. return nil
  2651. case agentbase.FieldChunkIndex:
  2652. m.ResetChunkIndex()
  2653. return nil
  2654. case agentbase.FieldIndexes:
  2655. m.ResetIndexes()
  2656. return nil
  2657. case agentbase.FieldDatasetID:
  2658. m.ResetDatasetID()
  2659. return nil
  2660. case agentbase.FieldCollectionID:
  2661. m.ResetCollectionID()
  2662. return nil
  2663. case agentbase.FieldSourceName:
  2664. m.ResetSourceName()
  2665. return nil
  2666. case agentbase.FieldCanWrite:
  2667. m.ResetCanWrite()
  2668. return nil
  2669. case agentbase.FieldIsOwner:
  2670. m.ResetIsOwner()
  2671. return nil
  2672. }
  2673. return fmt.Errorf("unknown AgentBase field %s", name)
  2674. }
  2675. // AddedEdges returns all edge names that were set/added in this mutation.
  2676. func (m *AgentBaseMutation) AddedEdges() []string {
  2677. edges := make([]string, 0, 1)
  2678. if m.wx_agent != nil {
  2679. edges = append(edges, agentbase.EdgeWxAgent)
  2680. }
  2681. return edges
  2682. }
  2683. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2684. // name in this mutation.
  2685. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2686. switch name {
  2687. case agentbase.EdgeWxAgent:
  2688. ids := make([]ent.Value, 0, len(m.wx_agent))
  2689. for id := range m.wx_agent {
  2690. ids = append(ids, id)
  2691. }
  2692. return ids
  2693. }
  2694. return nil
  2695. }
  2696. // RemovedEdges returns all edge names that were removed in this mutation.
  2697. func (m *AgentBaseMutation) RemovedEdges() []string {
  2698. edges := make([]string, 0, 1)
  2699. if m.removedwx_agent != nil {
  2700. edges = append(edges, agentbase.EdgeWxAgent)
  2701. }
  2702. return edges
  2703. }
  2704. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2705. // the given name in this mutation.
  2706. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2707. switch name {
  2708. case agentbase.EdgeWxAgent:
  2709. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2710. for id := range m.removedwx_agent {
  2711. ids = append(ids, id)
  2712. }
  2713. return ids
  2714. }
  2715. return nil
  2716. }
  2717. // ClearedEdges returns all edge names that were cleared in this mutation.
  2718. func (m *AgentBaseMutation) ClearedEdges() []string {
  2719. edges := make([]string, 0, 1)
  2720. if m.clearedwx_agent {
  2721. edges = append(edges, agentbase.EdgeWxAgent)
  2722. }
  2723. return edges
  2724. }
  2725. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2726. // was cleared in this mutation.
  2727. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2728. switch name {
  2729. case agentbase.EdgeWxAgent:
  2730. return m.clearedwx_agent
  2731. }
  2732. return false
  2733. }
  2734. // ClearEdge clears the value of the edge with the given name. It returns an error
  2735. // if that edge is not defined in the schema.
  2736. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2737. switch name {
  2738. }
  2739. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2740. }
  2741. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2742. // It returns an error if the edge is not defined in the schema.
  2743. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2744. switch name {
  2745. case agentbase.EdgeWxAgent:
  2746. m.ResetWxAgent()
  2747. return nil
  2748. }
  2749. return fmt.Errorf("unknown AgentBase edge %s", name)
  2750. }
  2751. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2752. type AliyunAvatarMutation struct {
  2753. config
  2754. op Op
  2755. typ string
  2756. id *uint64
  2757. created_at *time.Time
  2758. updated_at *time.Time
  2759. deleted_at *time.Time
  2760. user_id *uint64
  2761. adduser_id *int64
  2762. biz_id *string
  2763. access_key_id *string
  2764. access_key_secret *string
  2765. app_id *string
  2766. tenant_id *uint64
  2767. addtenant_id *int64
  2768. response *string
  2769. token *string
  2770. session_id *string
  2771. clearedFields map[string]struct{}
  2772. done bool
  2773. oldValue func(context.Context) (*AliyunAvatar, error)
  2774. predicates []predicate.AliyunAvatar
  2775. }
  2776. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2777. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2778. type aliyunavatarOption func(*AliyunAvatarMutation)
  2779. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2780. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2781. m := &AliyunAvatarMutation{
  2782. config: c,
  2783. op: op,
  2784. typ: TypeAliyunAvatar,
  2785. clearedFields: make(map[string]struct{}),
  2786. }
  2787. for _, opt := range opts {
  2788. opt(m)
  2789. }
  2790. return m
  2791. }
  2792. // withAliyunAvatarID sets the ID field of the mutation.
  2793. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2794. return func(m *AliyunAvatarMutation) {
  2795. var (
  2796. err error
  2797. once sync.Once
  2798. value *AliyunAvatar
  2799. )
  2800. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2801. once.Do(func() {
  2802. if m.done {
  2803. err = errors.New("querying old values post mutation is not allowed")
  2804. } else {
  2805. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2806. }
  2807. })
  2808. return value, err
  2809. }
  2810. m.id = &id
  2811. }
  2812. }
  2813. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2814. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2815. return func(m *AliyunAvatarMutation) {
  2816. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2817. return node, nil
  2818. }
  2819. m.id = &node.ID
  2820. }
  2821. }
  2822. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2823. // executed in a transaction (ent.Tx), a transactional client is returned.
  2824. func (m AliyunAvatarMutation) Client() *Client {
  2825. client := &Client{config: m.config}
  2826. client.init()
  2827. return client
  2828. }
  2829. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2830. // it returns an error otherwise.
  2831. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2832. if _, ok := m.driver.(*txDriver); !ok {
  2833. return nil, errors.New("ent: mutation is not running in a transaction")
  2834. }
  2835. tx := &Tx{config: m.config}
  2836. tx.init()
  2837. return tx, nil
  2838. }
  2839. // SetID sets the value of the id field. Note that this
  2840. // operation is only accepted on creation of AliyunAvatar entities.
  2841. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2842. m.id = &id
  2843. }
  2844. // ID returns the ID value in the mutation. Note that the ID is only available
  2845. // if it was provided to the builder or after it was returned from the database.
  2846. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2847. if m.id == nil {
  2848. return
  2849. }
  2850. return *m.id, true
  2851. }
  2852. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2853. // That means, if the mutation is applied within a transaction with an isolation level such
  2854. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2855. // or updated by the mutation.
  2856. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2857. switch {
  2858. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2859. id, exists := m.ID()
  2860. if exists {
  2861. return []uint64{id}, nil
  2862. }
  2863. fallthrough
  2864. case m.op.Is(OpUpdate | OpDelete):
  2865. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2866. default:
  2867. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2868. }
  2869. }
  2870. // SetCreatedAt sets the "created_at" field.
  2871. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2872. m.created_at = &t
  2873. }
  2874. // CreatedAt returns the value of the "created_at" field in the mutation.
  2875. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2876. v := m.created_at
  2877. if v == nil {
  2878. return
  2879. }
  2880. return *v, true
  2881. }
  2882. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2883. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2884. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2885. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2886. if !m.op.Is(OpUpdateOne) {
  2887. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2888. }
  2889. if m.id == nil || m.oldValue == nil {
  2890. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2891. }
  2892. oldValue, err := m.oldValue(ctx)
  2893. if err != nil {
  2894. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2895. }
  2896. return oldValue.CreatedAt, nil
  2897. }
  2898. // ResetCreatedAt resets all changes to the "created_at" field.
  2899. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2900. m.created_at = nil
  2901. }
  2902. // SetUpdatedAt sets the "updated_at" field.
  2903. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2904. m.updated_at = &t
  2905. }
  2906. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2907. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2908. v := m.updated_at
  2909. if v == nil {
  2910. return
  2911. }
  2912. return *v, true
  2913. }
  2914. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2915. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2916. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2917. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2918. if !m.op.Is(OpUpdateOne) {
  2919. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2920. }
  2921. if m.id == nil || m.oldValue == nil {
  2922. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2923. }
  2924. oldValue, err := m.oldValue(ctx)
  2925. if err != nil {
  2926. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2927. }
  2928. return oldValue.UpdatedAt, nil
  2929. }
  2930. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2931. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2932. m.updated_at = nil
  2933. }
  2934. // SetDeletedAt sets the "deleted_at" field.
  2935. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2936. m.deleted_at = &t
  2937. }
  2938. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2939. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2940. v := m.deleted_at
  2941. if v == nil {
  2942. return
  2943. }
  2944. return *v, true
  2945. }
  2946. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2947. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2948. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2949. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2950. if !m.op.Is(OpUpdateOne) {
  2951. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2952. }
  2953. if m.id == nil || m.oldValue == nil {
  2954. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2955. }
  2956. oldValue, err := m.oldValue(ctx)
  2957. if err != nil {
  2958. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2959. }
  2960. return oldValue.DeletedAt, nil
  2961. }
  2962. // ClearDeletedAt clears the value of the "deleted_at" field.
  2963. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2964. m.deleted_at = nil
  2965. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2966. }
  2967. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2968. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2969. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2970. return ok
  2971. }
  2972. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2973. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2974. m.deleted_at = nil
  2975. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2976. }
  2977. // SetUserID sets the "user_id" field.
  2978. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2979. m.user_id = &u
  2980. m.adduser_id = nil
  2981. }
  2982. // UserID returns the value of the "user_id" field in the mutation.
  2983. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2984. v := m.user_id
  2985. if v == nil {
  2986. return
  2987. }
  2988. return *v, true
  2989. }
  2990. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2991. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2992. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2993. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2994. if !m.op.Is(OpUpdateOne) {
  2995. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2996. }
  2997. if m.id == nil || m.oldValue == nil {
  2998. return v, errors.New("OldUserID requires an ID field in the mutation")
  2999. }
  3000. oldValue, err := m.oldValue(ctx)
  3001. if err != nil {
  3002. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  3003. }
  3004. return oldValue.UserID, nil
  3005. }
  3006. // AddUserID adds u to the "user_id" field.
  3007. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  3008. if m.adduser_id != nil {
  3009. *m.adduser_id += u
  3010. } else {
  3011. m.adduser_id = &u
  3012. }
  3013. }
  3014. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  3015. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  3016. v := m.adduser_id
  3017. if v == nil {
  3018. return
  3019. }
  3020. return *v, true
  3021. }
  3022. // ResetUserID resets all changes to the "user_id" field.
  3023. func (m *AliyunAvatarMutation) ResetUserID() {
  3024. m.user_id = nil
  3025. m.adduser_id = nil
  3026. }
  3027. // SetBizID sets the "biz_id" field.
  3028. func (m *AliyunAvatarMutation) SetBizID(s string) {
  3029. m.biz_id = &s
  3030. }
  3031. // BizID returns the value of the "biz_id" field in the mutation.
  3032. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  3033. v := m.biz_id
  3034. if v == nil {
  3035. return
  3036. }
  3037. return *v, true
  3038. }
  3039. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  3040. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3041. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3042. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  3043. if !m.op.Is(OpUpdateOne) {
  3044. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  3045. }
  3046. if m.id == nil || m.oldValue == nil {
  3047. return v, errors.New("OldBizID requires an ID field in the mutation")
  3048. }
  3049. oldValue, err := m.oldValue(ctx)
  3050. if err != nil {
  3051. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  3052. }
  3053. return oldValue.BizID, nil
  3054. }
  3055. // ResetBizID resets all changes to the "biz_id" field.
  3056. func (m *AliyunAvatarMutation) ResetBizID() {
  3057. m.biz_id = nil
  3058. }
  3059. // SetAccessKeyID sets the "access_key_id" field.
  3060. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  3061. m.access_key_id = &s
  3062. }
  3063. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  3064. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  3065. v := m.access_key_id
  3066. if v == nil {
  3067. return
  3068. }
  3069. return *v, true
  3070. }
  3071. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  3072. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3073. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3074. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  3075. if !m.op.Is(OpUpdateOne) {
  3076. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  3077. }
  3078. if m.id == nil || m.oldValue == nil {
  3079. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  3080. }
  3081. oldValue, err := m.oldValue(ctx)
  3082. if err != nil {
  3083. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  3084. }
  3085. return oldValue.AccessKeyID, nil
  3086. }
  3087. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  3088. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  3089. m.access_key_id = nil
  3090. }
  3091. // SetAccessKeySecret sets the "access_key_secret" field.
  3092. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  3093. m.access_key_secret = &s
  3094. }
  3095. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  3096. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  3097. v := m.access_key_secret
  3098. if v == nil {
  3099. return
  3100. }
  3101. return *v, true
  3102. }
  3103. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  3104. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3105. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3106. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  3107. if !m.op.Is(OpUpdateOne) {
  3108. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  3109. }
  3110. if m.id == nil || m.oldValue == nil {
  3111. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  3112. }
  3113. oldValue, err := m.oldValue(ctx)
  3114. if err != nil {
  3115. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  3116. }
  3117. return oldValue.AccessKeySecret, nil
  3118. }
  3119. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  3120. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  3121. m.access_key_secret = nil
  3122. }
  3123. // SetAppID sets the "app_id" field.
  3124. func (m *AliyunAvatarMutation) SetAppID(s string) {
  3125. m.app_id = &s
  3126. }
  3127. // AppID returns the value of the "app_id" field in the mutation.
  3128. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  3129. v := m.app_id
  3130. if v == nil {
  3131. return
  3132. }
  3133. return *v, true
  3134. }
  3135. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  3136. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3137. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3138. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  3139. if !m.op.Is(OpUpdateOne) {
  3140. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  3141. }
  3142. if m.id == nil || m.oldValue == nil {
  3143. return v, errors.New("OldAppID requires an ID field in the mutation")
  3144. }
  3145. oldValue, err := m.oldValue(ctx)
  3146. if err != nil {
  3147. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  3148. }
  3149. return oldValue.AppID, nil
  3150. }
  3151. // ClearAppID clears the value of the "app_id" field.
  3152. func (m *AliyunAvatarMutation) ClearAppID() {
  3153. m.app_id = nil
  3154. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  3155. }
  3156. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  3157. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  3158. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  3159. return ok
  3160. }
  3161. // ResetAppID resets all changes to the "app_id" field.
  3162. func (m *AliyunAvatarMutation) ResetAppID() {
  3163. m.app_id = nil
  3164. delete(m.clearedFields, aliyunavatar.FieldAppID)
  3165. }
  3166. // SetTenantID sets the "tenant_id" field.
  3167. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  3168. m.tenant_id = &u
  3169. m.addtenant_id = nil
  3170. }
  3171. // TenantID returns the value of the "tenant_id" field in the mutation.
  3172. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  3173. v := m.tenant_id
  3174. if v == nil {
  3175. return
  3176. }
  3177. return *v, true
  3178. }
  3179. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  3180. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3181. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3182. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  3183. if !m.op.Is(OpUpdateOne) {
  3184. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  3185. }
  3186. if m.id == nil || m.oldValue == nil {
  3187. return v, errors.New("OldTenantID requires an ID field in the mutation")
  3188. }
  3189. oldValue, err := m.oldValue(ctx)
  3190. if err != nil {
  3191. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  3192. }
  3193. return oldValue.TenantID, nil
  3194. }
  3195. // AddTenantID adds u to the "tenant_id" field.
  3196. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  3197. if m.addtenant_id != nil {
  3198. *m.addtenant_id += u
  3199. } else {
  3200. m.addtenant_id = &u
  3201. }
  3202. }
  3203. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  3204. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  3205. v := m.addtenant_id
  3206. if v == nil {
  3207. return
  3208. }
  3209. return *v, true
  3210. }
  3211. // ResetTenantID resets all changes to the "tenant_id" field.
  3212. func (m *AliyunAvatarMutation) ResetTenantID() {
  3213. m.tenant_id = nil
  3214. m.addtenant_id = nil
  3215. }
  3216. // SetResponse sets the "response" field.
  3217. func (m *AliyunAvatarMutation) SetResponse(s string) {
  3218. m.response = &s
  3219. }
  3220. // Response returns the value of the "response" field in the mutation.
  3221. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  3222. v := m.response
  3223. if v == nil {
  3224. return
  3225. }
  3226. return *v, true
  3227. }
  3228. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  3229. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3230. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3231. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  3232. if !m.op.Is(OpUpdateOne) {
  3233. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  3234. }
  3235. if m.id == nil || m.oldValue == nil {
  3236. return v, errors.New("OldResponse requires an ID field in the mutation")
  3237. }
  3238. oldValue, err := m.oldValue(ctx)
  3239. if err != nil {
  3240. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  3241. }
  3242. return oldValue.Response, nil
  3243. }
  3244. // ResetResponse resets all changes to the "response" field.
  3245. func (m *AliyunAvatarMutation) ResetResponse() {
  3246. m.response = nil
  3247. }
  3248. // SetToken sets the "token" field.
  3249. func (m *AliyunAvatarMutation) SetToken(s string) {
  3250. m.token = &s
  3251. }
  3252. // Token returns the value of the "token" field in the mutation.
  3253. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  3254. v := m.token
  3255. if v == nil {
  3256. return
  3257. }
  3258. return *v, true
  3259. }
  3260. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  3261. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3263. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  3264. if !m.op.Is(OpUpdateOne) {
  3265. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  3266. }
  3267. if m.id == nil || m.oldValue == nil {
  3268. return v, errors.New("OldToken requires an ID field in the mutation")
  3269. }
  3270. oldValue, err := m.oldValue(ctx)
  3271. if err != nil {
  3272. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  3273. }
  3274. return oldValue.Token, nil
  3275. }
  3276. // ResetToken resets all changes to the "token" field.
  3277. func (m *AliyunAvatarMutation) ResetToken() {
  3278. m.token = nil
  3279. }
  3280. // SetSessionID sets the "session_id" field.
  3281. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  3282. m.session_id = &s
  3283. }
  3284. // SessionID returns the value of the "session_id" field in the mutation.
  3285. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  3286. v := m.session_id
  3287. if v == nil {
  3288. return
  3289. }
  3290. return *v, true
  3291. }
  3292. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  3293. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3294. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3295. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  3296. if !m.op.Is(OpUpdateOne) {
  3297. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  3298. }
  3299. if m.id == nil || m.oldValue == nil {
  3300. return v, errors.New("OldSessionID requires an ID field in the mutation")
  3301. }
  3302. oldValue, err := m.oldValue(ctx)
  3303. if err != nil {
  3304. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  3305. }
  3306. return oldValue.SessionID, nil
  3307. }
  3308. // ResetSessionID resets all changes to the "session_id" field.
  3309. func (m *AliyunAvatarMutation) ResetSessionID() {
  3310. m.session_id = nil
  3311. }
  3312. // Where appends a list predicates to the AliyunAvatarMutation builder.
  3313. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  3314. m.predicates = append(m.predicates, ps...)
  3315. }
  3316. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  3317. // users can use type-assertion to append predicates that do not depend on any generated package.
  3318. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  3319. p := make([]predicate.AliyunAvatar, len(ps))
  3320. for i := range ps {
  3321. p[i] = ps[i]
  3322. }
  3323. m.Where(p...)
  3324. }
  3325. // Op returns the operation name.
  3326. func (m *AliyunAvatarMutation) Op() Op {
  3327. return m.op
  3328. }
  3329. // SetOp allows setting the mutation operation.
  3330. func (m *AliyunAvatarMutation) SetOp(op Op) {
  3331. m.op = op
  3332. }
  3333. // Type returns the node type of this mutation (AliyunAvatar).
  3334. func (m *AliyunAvatarMutation) Type() string {
  3335. return m.typ
  3336. }
  3337. // Fields returns all fields that were changed during this mutation. Note that in
  3338. // order to get all numeric fields that were incremented/decremented, call
  3339. // AddedFields().
  3340. func (m *AliyunAvatarMutation) Fields() []string {
  3341. fields := make([]string, 0, 12)
  3342. if m.created_at != nil {
  3343. fields = append(fields, aliyunavatar.FieldCreatedAt)
  3344. }
  3345. if m.updated_at != nil {
  3346. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  3347. }
  3348. if m.deleted_at != nil {
  3349. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3350. }
  3351. if m.user_id != nil {
  3352. fields = append(fields, aliyunavatar.FieldUserID)
  3353. }
  3354. if m.biz_id != nil {
  3355. fields = append(fields, aliyunavatar.FieldBizID)
  3356. }
  3357. if m.access_key_id != nil {
  3358. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  3359. }
  3360. if m.access_key_secret != nil {
  3361. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  3362. }
  3363. if m.app_id != nil {
  3364. fields = append(fields, aliyunavatar.FieldAppID)
  3365. }
  3366. if m.tenant_id != nil {
  3367. fields = append(fields, aliyunavatar.FieldTenantID)
  3368. }
  3369. if m.response != nil {
  3370. fields = append(fields, aliyunavatar.FieldResponse)
  3371. }
  3372. if m.token != nil {
  3373. fields = append(fields, aliyunavatar.FieldToken)
  3374. }
  3375. if m.session_id != nil {
  3376. fields = append(fields, aliyunavatar.FieldSessionID)
  3377. }
  3378. return fields
  3379. }
  3380. // Field returns the value of a field with the given name. The second boolean
  3381. // return value indicates that this field was not set, or was not defined in the
  3382. // schema.
  3383. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  3384. switch name {
  3385. case aliyunavatar.FieldCreatedAt:
  3386. return m.CreatedAt()
  3387. case aliyunavatar.FieldUpdatedAt:
  3388. return m.UpdatedAt()
  3389. case aliyunavatar.FieldDeletedAt:
  3390. return m.DeletedAt()
  3391. case aliyunavatar.FieldUserID:
  3392. return m.UserID()
  3393. case aliyunavatar.FieldBizID:
  3394. return m.BizID()
  3395. case aliyunavatar.FieldAccessKeyID:
  3396. return m.AccessKeyID()
  3397. case aliyunavatar.FieldAccessKeySecret:
  3398. return m.AccessKeySecret()
  3399. case aliyunavatar.FieldAppID:
  3400. return m.AppID()
  3401. case aliyunavatar.FieldTenantID:
  3402. return m.TenantID()
  3403. case aliyunavatar.FieldResponse:
  3404. return m.Response()
  3405. case aliyunavatar.FieldToken:
  3406. return m.Token()
  3407. case aliyunavatar.FieldSessionID:
  3408. return m.SessionID()
  3409. }
  3410. return nil, false
  3411. }
  3412. // OldField returns the old value of the field from the database. An error is
  3413. // returned if the mutation operation is not UpdateOne, or the query to the
  3414. // database failed.
  3415. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3416. switch name {
  3417. case aliyunavatar.FieldCreatedAt:
  3418. return m.OldCreatedAt(ctx)
  3419. case aliyunavatar.FieldUpdatedAt:
  3420. return m.OldUpdatedAt(ctx)
  3421. case aliyunavatar.FieldDeletedAt:
  3422. return m.OldDeletedAt(ctx)
  3423. case aliyunavatar.FieldUserID:
  3424. return m.OldUserID(ctx)
  3425. case aliyunavatar.FieldBizID:
  3426. return m.OldBizID(ctx)
  3427. case aliyunavatar.FieldAccessKeyID:
  3428. return m.OldAccessKeyID(ctx)
  3429. case aliyunavatar.FieldAccessKeySecret:
  3430. return m.OldAccessKeySecret(ctx)
  3431. case aliyunavatar.FieldAppID:
  3432. return m.OldAppID(ctx)
  3433. case aliyunavatar.FieldTenantID:
  3434. return m.OldTenantID(ctx)
  3435. case aliyunavatar.FieldResponse:
  3436. return m.OldResponse(ctx)
  3437. case aliyunavatar.FieldToken:
  3438. return m.OldToken(ctx)
  3439. case aliyunavatar.FieldSessionID:
  3440. return m.OldSessionID(ctx)
  3441. }
  3442. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  3443. }
  3444. // SetField sets the value of a field with the given name. It returns an error if
  3445. // the field is not defined in the schema, or if the type mismatched the field
  3446. // type.
  3447. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  3448. switch name {
  3449. case aliyunavatar.FieldCreatedAt:
  3450. v, ok := value.(time.Time)
  3451. if !ok {
  3452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3453. }
  3454. m.SetCreatedAt(v)
  3455. return nil
  3456. case aliyunavatar.FieldUpdatedAt:
  3457. v, ok := value.(time.Time)
  3458. if !ok {
  3459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3460. }
  3461. m.SetUpdatedAt(v)
  3462. return nil
  3463. case aliyunavatar.FieldDeletedAt:
  3464. v, ok := value.(time.Time)
  3465. if !ok {
  3466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3467. }
  3468. m.SetDeletedAt(v)
  3469. return nil
  3470. case aliyunavatar.FieldUserID:
  3471. v, ok := value.(uint64)
  3472. if !ok {
  3473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3474. }
  3475. m.SetUserID(v)
  3476. return nil
  3477. case aliyunavatar.FieldBizID:
  3478. v, ok := value.(string)
  3479. if !ok {
  3480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3481. }
  3482. m.SetBizID(v)
  3483. return nil
  3484. case aliyunavatar.FieldAccessKeyID:
  3485. v, ok := value.(string)
  3486. if !ok {
  3487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3488. }
  3489. m.SetAccessKeyID(v)
  3490. return nil
  3491. case aliyunavatar.FieldAccessKeySecret:
  3492. v, ok := value.(string)
  3493. if !ok {
  3494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3495. }
  3496. m.SetAccessKeySecret(v)
  3497. return nil
  3498. case aliyunavatar.FieldAppID:
  3499. v, ok := value.(string)
  3500. if !ok {
  3501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3502. }
  3503. m.SetAppID(v)
  3504. return nil
  3505. case aliyunavatar.FieldTenantID:
  3506. v, ok := value.(uint64)
  3507. if !ok {
  3508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3509. }
  3510. m.SetTenantID(v)
  3511. return nil
  3512. case aliyunavatar.FieldResponse:
  3513. v, ok := value.(string)
  3514. if !ok {
  3515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3516. }
  3517. m.SetResponse(v)
  3518. return nil
  3519. case aliyunavatar.FieldToken:
  3520. v, ok := value.(string)
  3521. if !ok {
  3522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3523. }
  3524. m.SetToken(v)
  3525. return nil
  3526. case aliyunavatar.FieldSessionID:
  3527. v, ok := value.(string)
  3528. if !ok {
  3529. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3530. }
  3531. m.SetSessionID(v)
  3532. return nil
  3533. }
  3534. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3535. }
  3536. // AddedFields returns all numeric fields that were incremented/decremented during
  3537. // this mutation.
  3538. func (m *AliyunAvatarMutation) AddedFields() []string {
  3539. var fields []string
  3540. if m.adduser_id != nil {
  3541. fields = append(fields, aliyunavatar.FieldUserID)
  3542. }
  3543. if m.addtenant_id != nil {
  3544. fields = append(fields, aliyunavatar.FieldTenantID)
  3545. }
  3546. return fields
  3547. }
  3548. // AddedField returns the numeric value that was incremented/decremented on a field
  3549. // with the given name. The second boolean return value indicates that this field
  3550. // was not set, or was not defined in the schema.
  3551. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  3552. switch name {
  3553. case aliyunavatar.FieldUserID:
  3554. return m.AddedUserID()
  3555. case aliyunavatar.FieldTenantID:
  3556. return m.AddedTenantID()
  3557. }
  3558. return nil, false
  3559. }
  3560. // AddField adds the value to the field with the given name. It returns an error if
  3561. // the field is not defined in the schema, or if the type mismatched the field
  3562. // type.
  3563. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  3564. switch name {
  3565. case aliyunavatar.FieldUserID:
  3566. v, ok := value.(int64)
  3567. if !ok {
  3568. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3569. }
  3570. m.AddUserID(v)
  3571. return nil
  3572. case aliyunavatar.FieldTenantID:
  3573. v, ok := value.(int64)
  3574. if !ok {
  3575. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3576. }
  3577. m.AddTenantID(v)
  3578. return nil
  3579. }
  3580. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3581. }
  3582. // ClearedFields returns all nullable fields that were cleared during this
  3583. // mutation.
  3584. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3585. var fields []string
  3586. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3587. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3588. }
  3589. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3590. fields = append(fields, aliyunavatar.FieldAppID)
  3591. }
  3592. return fields
  3593. }
  3594. // FieldCleared returns a boolean indicating if a field with the given name was
  3595. // cleared in this mutation.
  3596. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3597. _, ok := m.clearedFields[name]
  3598. return ok
  3599. }
  3600. // ClearField clears the value of the field with the given name. It returns an
  3601. // error if the field is not defined in the schema.
  3602. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3603. switch name {
  3604. case aliyunavatar.FieldDeletedAt:
  3605. m.ClearDeletedAt()
  3606. return nil
  3607. case aliyunavatar.FieldAppID:
  3608. m.ClearAppID()
  3609. return nil
  3610. }
  3611. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3612. }
  3613. // ResetField resets all changes in the mutation for the field with the given name.
  3614. // It returns an error if the field is not defined in the schema.
  3615. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3616. switch name {
  3617. case aliyunavatar.FieldCreatedAt:
  3618. m.ResetCreatedAt()
  3619. return nil
  3620. case aliyunavatar.FieldUpdatedAt:
  3621. m.ResetUpdatedAt()
  3622. return nil
  3623. case aliyunavatar.FieldDeletedAt:
  3624. m.ResetDeletedAt()
  3625. return nil
  3626. case aliyunavatar.FieldUserID:
  3627. m.ResetUserID()
  3628. return nil
  3629. case aliyunavatar.FieldBizID:
  3630. m.ResetBizID()
  3631. return nil
  3632. case aliyunavatar.FieldAccessKeyID:
  3633. m.ResetAccessKeyID()
  3634. return nil
  3635. case aliyunavatar.FieldAccessKeySecret:
  3636. m.ResetAccessKeySecret()
  3637. return nil
  3638. case aliyunavatar.FieldAppID:
  3639. m.ResetAppID()
  3640. return nil
  3641. case aliyunavatar.FieldTenantID:
  3642. m.ResetTenantID()
  3643. return nil
  3644. case aliyunavatar.FieldResponse:
  3645. m.ResetResponse()
  3646. return nil
  3647. case aliyunavatar.FieldToken:
  3648. m.ResetToken()
  3649. return nil
  3650. case aliyunavatar.FieldSessionID:
  3651. m.ResetSessionID()
  3652. return nil
  3653. }
  3654. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3655. }
  3656. // AddedEdges returns all edge names that were set/added in this mutation.
  3657. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3658. edges := make([]string, 0, 0)
  3659. return edges
  3660. }
  3661. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3662. // name in this mutation.
  3663. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3664. return nil
  3665. }
  3666. // RemovedEdges returns all edge names that were removed in this mutation.
  3667. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3668. edges := make([]string, 0, 0)
  3669. return edges
  3670. }
  3671. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3672. // the given name in this mutation.
  3673. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3674. return nil
  3675. }
  3676. // ClearedEdges returns all edge names that were cleared in this mutation.
  3677. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3678. edges := make([]string, 0, 0)
  3679. return edges
  3680. }
  3681. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3682. // was cleared in this mutation.
  3683. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3684. return false
  3685. }
  3686. // ClearEdge clears the value of the edge with the given name. It returns an error
  3687. // if that edge is not defined in the schema.
  3688. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3689. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3690. }
  3691. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3692. // It returns an error if the edge is not defined in the schema.
  3693. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3694. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3695. }
  3696. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  3697. type AllocAgentMutation struct {
  3698. config
  3699. op Op
  3700. typ string
  3701. id *uint64
  3702. created_at *time.Time
  3703. updated_at *time.Time
  3704. deleted_at *time.Time
  3705. user_id *string
  3706. organization_id *uint64
  3707. addorganization_id *int64
  3708. agents *[]uint64
  3709. appendagents []uint64
  3710. status *int
  3711. addstatus *int
  3712. clearedFields map[string]struct{}
  3713. done bool
  3714. oldValue func(context.Context) (*AllocAgent, error)
  3715. predicates []predicate.AllocAgent
  3716. }
  3717. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  3718. // allocagentOption allows management of the mutation configuration using functional options.
  3719. type allocagentOption func(*AllocAgentMutation)
  3720. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  3721. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  3722. m := &AllocAgentMutation{
  3723. config: c,
  3724. op: op,
  3725. typ: TypeAllocAgent,
  3726. clearedFields: make(map[string]struct{}),
  3727. }
  3728. for _, opt := range opts {
  3729. opt(m)
  3730. }
  3731. return m
  3732. }
  3733. // withAllocAgentID sets the ID field of the mutation.
  3734. func withAllocAgentID(id uint64) allocagentOption {
  3735. return func(m *AllocAgentMutation) {
  3736. var (
  3737. err error
  3738. once sync.Once
  3739. value *AllocAgent
  3740. )
  3741. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  3742. once.Do(func() {
  3743. if m.done {
  3744. err = errors.New("querying old values post mutation is not allowed")
  3745. } else {
  3746. value, err = m.Client().AllocAgent.Get(ctx, id)
  3747. }
  3748. })
  3749. return value, err
  3750. }
  3751. m.id = &id
  3752. }
  3753. }
  3754. // withAllocAgent sets the old AllocAgent of the mutation.
  3755. func withAllocAgent(node *AllocAgent) allocagentOption {
  3756. return func(m *AllocAgentMutation) {
  3757. m.oldValue = func(context.Context) (*AllocAgent, error) {
  3758. return node, nil
  3759. }
  3760. m.id = &node.ID
  3761. }
  3762. }
  3763. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3764. // executed in a transaction (ent.Tx), a transactional client is returned.
  3765. func (m AllocAgentMutation) Client() *Client {
  3766. client := &Client{config: m.config}
  3767. client.init()
  3768. return client
  3769. }
  3770. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3771. // it returns an error otherwise.
  3772. func (m AllocAgentMutation) Tx() (*Tx, error) {
  3773. if _, ok := m.driver.(*txDriver); !ok {
  3774. return nil, errors.New("ent: mutation is not running in a transaction")
  3775. }
  3776. tx := &Tx{config: m.config}
  3777. tx.init()
  3778. return tx, nil
  3779. }
  3780. // SetID sets the value of the id field. Note that this
  3781. // operation is only accepted on creation of AllocAgent entities.
  3782. func (m *AllocAgentMutation) SetID(id uint64) {
  3783. m.id = &id
  3784. }
  3785. // ID returns the ID value in the mutation. Note that the ID is only available
  3786. // if it was provided to the builder or after it was returned from the database.
  3787. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  3788. if m.id == nil {
  3789. return
  3790. }
  3791. return *m.id, true
  3792. }
  3793. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3794. // That means, if the mutation is applied within a transaction with an isolation level such
  3795. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3796. // or updated by the mutation.
  3797. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  3798. switch {
  3799. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3800. id, exists := m.ID()
  3801. if exists {
  3802. return []uint64{id}, nil
  3803. }
  3804. fallthrough
  3805. case m.op.Is(OpUpdate | OpDelete):
  3806. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  3807. default:
  3808. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3809. }
  3810. }
  3811. // SetCreatedAt sets the "created_at" field.
  3812. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  3813. m.created_at = &t
  3814. }
  3815. // CreatedAt returns the value of the "created_at" field in the mutation.
  3816. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  3817. v := m.created_at
  3818. if v == nil {
  3819. return
  3820. }
  3821. return *v, true
  3822. }
  3823. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  3824. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3825. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3826. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3827. if !m.op.Is(OpUpdateOne) {
  3828. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3829. }
  3830. if m.id == nil || m.oldValue == nil {
  3831. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3832. }
  3833. oldValue, err := m.oldValue(ctx)
  3834. if err != nil {
  3835. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3836. }
  3837. return oldValue.CreatedAt, nil
  3838. }
  3839. // ResetCreatedAt resets all changes to the "created_at" field.
  3840. func (m *AllocAgentMutation) ResetCreatedAt() {
  3841. m.created_at = nil
  3842. }
  3843. // SetUpdatedAt sets the "updated_at" field.
  3844. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  3845. m.updated_at = &t
  3846. }
  3847. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3848. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  3849. v := m.updated_at
  3850. if v == nil {
  3851. return
  3852. }
  3853. return *v, true
  3854. }
  3855. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  3856. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3857. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3858. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3859. if !m.op.Is(OpUpdateOne) {
  3860. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3861. }
  3862. if m.id == nil || m.oldValue == nil {
  3863. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3864. }
  3865. oldValue, err := m.oldValue(ctx)
  3866. if err != nil {
  3867. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3868. }
  3869. return oldValue.UpdatedAt, nil
  3870. }
  3871. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3872. func (m *AllocAgentMutation) ResetUpdatedAt() {
  3873. m.updated_at = nil
  3874. }
  3875. // SetDeletedAt sets the "deleted_at" field.
  3876. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  3877. m.deleted_at = &t
  3878. }
  3879. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3880. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  3881. v := m.deleted_at
  3882. if v == nil {
  3883. return
  3884. }
  3885. return *v, true
  3886. }
  3887. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  3888. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3889. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3890. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3891. if !m.op.Is(OpUpdateOne) {
  3892. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3893. }
  3894. if m.id == nil || m.oldValue == nil {
  3895. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3896. }
  3897. oldValue, err := m.oldValue(ctx)
  3898. if err != nil {
  3899. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3900. }
  3901. return oldValue.DeletedAt, nil
  3902. }
  3903. // ClearDeletedAt clears the value of the "deleted_at" field.
  3904. func (m *AllocAgentMutation) ClearDeletedAt() {
  3905. m.deleted_at = nil
  3906. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  3907. }
  3908. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3909. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  3910. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  3911. return ok
  3912. }
  3913. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3914. func (m *AllocAgentMutation) ResetDeletedAt() {
  3915. m.deleted_at = nil
  3916. delete(m.clearedFields, allocagent.FieldDeletedAt)
  3917. }
  3918. // SetUserID sets the "user_id" field.
  3919. func (m *AllocAgentMutation) SetUserID(s string) {
  3920. m.user_id = &s
  3921. }
  3922. // UserID returns the value of the "user_id" field in the mutation.
  3923. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  3924. v := m.user_id
  3925. if v == nil {
  3926. return
  3927. }
  3928. return *v, true
  3929. }
  3930. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  3931. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3932. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3933. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  3934. if !m.op.Is(OpUpdateOne) {
  3935. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  3936. }
  3937. if m.id == nil || m.oldValue == nil {
  3938. return v, errors.New("OldUserID requires an ID field in the mutation")
  3939. }
  3940. oldValue, err := m.oldValue(ctx)
  3941. if err != nil {
  3942. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  3943. }
  3944. return oldValue.UserID, nil
  3945. }
  3946. // ClearUserID clears the value of the "user_id" field.
  3947. func (m *AllocAgentMutation) ClearUserID() {
  3948. m.user_id = nil
  3949. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  3950. }
  3951. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  3952. func (m *AllocAgentMutation) UserIDCleared() bool {
  3953. _, ok := m.clearedFields[allocagent.FieldUserID]
  3954. return ok
  3955. }
  3956. // ResetUserID resets all changes to the "user_id" field.
  3957. func (m *AllocAgentMutation) ResetUserID() {
  3958. m.user_id = nil
  3959. delete(m.clearedFields, allocagent.FieldUserID)
  3960. }
  3961. // SetOrganizationID sets the "organization_id" field.
  3962. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  3963. m.organization_id = &u
  3964. m.addorganization_id = nil
  3965. }
  3966. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3967. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  3968. v := m.organization_id
  3969. if v == nil {
  3970. return
  3971. }
  3972. return *v, true
  3973. }
  3974. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  3975. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3976. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3977. func (m *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3978. if !m.op.Is(OpUpdateOne) {
  3979. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3980. }
  3981. if m.id == nil || m.oldValue == nil {
  3982. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3983. }
  3984. oldValue, err := m.oldValue(ctx)
  3985. if err != nil {
  3986. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3987. }
  3988. return oldValue.OrganizationID, nil
  3989. }
  3990. // AddOrganizationID adds u to the "organization_id" field.
  3991. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  3992. if m.addorganization_id != nil {
  3993. *m.addorganization_id += u
  3994. } else {
  3995. m.addorganization_id = &u
  3996. }
  3997. }
  3998. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3999. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  4000. v := m.addorganization_id
  4001. if v == nil {
  4002. return
  4003. }
  4004. return *v, true
  4005. }
  4006. // ClearOrganizationID clears the value of the "organization_id" field.
  4007. func (m *AllocAgentMutation) ClearOrganizationID() {
  4008. m.organization_id = nil
  4009. m.addorganization_id = nil
  4010. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  4011. }
  4012. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  4013. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  4014. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  4015. return ok
  4016. }
  4017. // ResetOrganizationID resets all changes to the "organization_id" field.
  4018. func (m *AllocAgentMutation) ResetOrganizationID() {
  4019. m.organization_id = nil
  4020. m.addorganization_id = nil
  4021. delete(m.clearedFields, allocagent.FieldOrganizationID)
  4022. }
  4023. // SetAgents sets the "agents" field.
  4024. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  4025. m.agents = &u
  4026. m.appendagents = nil
  4027. }
  4028. // Agents returns the value of the "agents" field in the mutation.
  4029. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  4030. v := m.agents
  4031. if v == nil {
  4032. return
  4033. }
  4034. return *v, true
  4035. }
  4036. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  4037. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  4038. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4039. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  4040. if !m.op.Is(OpUpdateOne) {
  4041. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  4042. }
  4043. if m.id == nil || m.oldValue == nil {
  4044. return v, errors.New("OldAgents requires an ID field in the mutation")
  4045. }
  4046. oldValue, err := m.oldValue(ctx)
  4047. if err != nil {
  4048. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  4049. }
  4050. return oldValue.Agents, nil
  4051. }
  4052. // AppendAgents adds u to the "agents" field.
  4053. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  4054. m.appendagents = append(m.appendagents, u...)
  4055. }
  4056. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  4057. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  4058. if len(m.appendagents) == 0 {
  4059. return nil, false
  4060. }
  4061. return m.appendagents, true
  4062. }
  4063. // ResetAgents resets all changes to the "agents" field.
  4064. func (m *AllocAgentMutation) ResetAgents() {
  4065. m.agents = nil
  4066. m.appendagents = nil
  4067. }
  4068. // SetStatus sets the "status" field.
  4069. func (m *AllocAgentMutation) SetStatus(i int) {
  4070. m.status = &i
  4071. m.addstatus = nil
  4072. }
  4073. // Status returns the value of the "status" field in the mutation.
  4074. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  4075. v := m.status
  4076. if v == nil {
  4077. return
  4078. }
  4079. return *v, true
  4080. }
  4081. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  4082. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  4083. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4084. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  4085. if !m.op.Is(OpUpdateOne) {
  4086. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  4087. }
  4088. if m.id == nil || m.oldValue == nil {
  4089. return v, errors.New("OldStatus requires an ID field in the mutation")
  4090. }
  4091. oldValue, err := m.oldValue(ctx)
  4092. if err != nil {
  4093. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  4094. }
  4095. return oldValue.Status, nil
  4096. }
  4097. // AddStatus adds i to the "status" field.
  4098. func (m *AllocAgentMutation) AddStatus(i int) {
  4099. if m.addstatus != nil {
  4100. *m.addstatus += i
  4101. } else {
  4102. m.addstatus = &i
  4103. }
  4104. }
  4105. // AddedStatus returns the value that was added to the "status" field in this mutation.
  4106. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  4107. v := m.addstatus
  4108. if v == nil {
  4109. return
  4110. }
  4111. return *v, true
  4112. }
  4113. // ClearStatus clears the value of the "status" field.
  4114. func (m *AllocAgentMutation) ClearStatus() {
  4115. m.status = nil
  4116. m.addstatus = nil
  4117. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  4118. }
  4119. // StatusCleared returns if the "status" field was cleared in this mutation.
  4120. func (m *AllocAgentMutation) StatusCleared() bool {
  4121. _, ok := m.clearedFields[allocagent.FieldStatus]
  4122. return ok
  4123. }
  4124. // ResetStatus resets all changes to the "status" field.
  4125. func (m *AllocAgentMutation) ResetStatus() {
  4126. m.status = nil
  4127. m.addstatus = nil
  4128. delete(m.clearedFields, allocagent.FieldStatus)
  4129. }
  4130. // Where appends a list predicates to the AllocAgentMutation builder.
  4131. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  4132. m.predicates = append(m.predicates, ps...)
  4133. }
  4134. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  4135. // users can use type-assertion to append predicates that do not depend on any generated package.
  4136. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  4137. p := make([]predicate.AllocAgent, len(ps))
  4138. for i := range ps {
  4139. p[i] = ps[i]
  4140. }
  4141. m.Where(p...)
  4142. }
  4143. // Op returns the operation name.
  4144. func (m *AllocAgentMutation) Op() Op {
  4145. return m.op
  4146. }
  4147. // SetOp allows setting the mutation operation.
  4148. func (m *AllocAgentMutation) SetOp(op Op) {
  4149. m.op = op
  4150. }
  4151. // Type returns the node type of this mutation (AllocAgent).
  4152. func (m *AllocAgentMutation) Type() string {
  4153. return m.typ
  4154. }
  4155. // Fields returns all fields that were changed during this mutation. Note that in
  4156. // order to get all numeric fields that were incremented/decremented, call
  4157. // AddedFields().
  4158. func (m *AllocAgentMutation) Fields() []string {
  4159. fields := make([]string, 0, 7)
  4160. if m.created_at != nil {
  4161. fields = append(fields, allocagent.FieldCreatedAt)
  4162. }
  4163. if m.updated_at != nil {
  4164. fields = append(fields, allocagent.FieldUpdatedAt)
  4165. }
  4166. if m.deleted_at != nil {
  4167. fields = append(fields, allocagent.FieldDeletedAt)
  4168. }
  4169. if m.user_id != nil {
  4170. fields = append(fields, allocagent.FieldUserID)
  4171. }
  4172. if m.organization_id != nil {
  4173. fields = append(fields, allocagent.FieldOrganizationID)
  4174. }
  4175. if m.agents != nil {
  4176. fields = append(fields, allocagent.FieldAgents)
  4177. }
  4178. if m.status != nil {
  4179. fields = append(fields, allocagent.FieldStatus)
  4180. }
  4181. return fields
  4182. }
  4183. // Field returns the value of a field with the given name. The second boolean
  4184. // return value indicates that this field was not set, or was not defined in the
  4185. // schema.
  4186. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  4187. switch name {
  4188. case allocagent.FieldCreatedAt:
  4189. return m.CreatedAt()
  4190. case allocagent.FieldUpdatedAt:
  4191. return m.UpdatedAt()
  4192. case allocagent.FieldDeletedAt:
  4193. return m.DeletedAt()
  4194. case allocagent.FieldUserID:
  4195. return m.UserID()
  4196. case allocagent.FieldOrganizationID:
  4197. return m.OrganizationID()
  4198. case allocagent.FieldAgents:
  4199. return m.Agents()
  4200. case allocagent.FieldStatus:
  4201. return m.Status()
  4202. }
  4203. return nil, false
  4204. }
  4205. // OldField returns the old value of the field from the database. An error is
  4206. // returned if the mutation operation is not UpdateOne, or the query to the
  4207. // database failed.
  4208. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4209. switch name {
  4210. case allocagent.FieldCreatedAt:
  4211. return m.OldCreatedAt(ctx)
  4212. case allocagent.FieldUpdatedAt:
  4213. return m.OldUpdatedAt(ctx)
  4214. case allocagent.FieldDeletedAt:
  4215. return m.OldDeletedAt(ctx)
  4216. case allocagent.FieldUserID:
  4217. return m.OldUserID(ctx)
  4218. case allocagent.FieldOrganizationID:
  4219. return m.OldOrganizationID(ctx)
  4220. case allocagent.FieldAgents:
  4221. return m.OldAgents(ctx)
  4222. case allocagent.FieldStatus:
  4223. return m.OldStatus(ctx)
  4224. }
  4225. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  4226. }
  4227. // SetField sets the value of a field with the given name. It returns an error if
  4228. // the field is not defined in the schema, or if the type mismatched the field
  4229. // type.
  4230. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  4231. switch name {
  4232. case allocagent.FieldCreatedAt:
  4233. v, ok := value.(time.Time)
  4234. if !ok {
  4235. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4236. }
  4237. m.SetCreatedAt(v)
  4238. return nil
  4239. case allocagent.FieldUpdatedAt:
  4240. v, ok := value.(time.Time)
  4241. if !ok {
  4242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4243. }
  4244. m.SetUpdatedAt(v)
  4245. return nil
  4246. case allocagent.FieldDeletedAt:
  4247. v, ok := value.(time.Time)
  4248. if !ok {
  4249. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4250. }
  4251. m.SetDeletedAt(v)
  4252. return nil
  4253. case allocagent.FieldUserID:
  4254. v, ok := value.(string)
  4255. if !ok {
  4256. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4257. }
  4258. m.SetUserID(v)
  4259. return nil
  4260. case allocagent.FieldOrganizationID:
  4261. v, ok := value.(uint64)
  4262. if !ok {
  4263. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4264. }
  4265. m.SetOrganizationID(v)
  4266. return nil
  4267. case allocagent.FieldAgents:
  4268. v, ok := value.([]uint64)
  4269. if !ok {
  4270. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4271. }
  4272. m.SetAgents(v)
  4273. return nil
  4274. case allocagent.FieldStatus:
  4275. v, ok := value.(int)
  4276. if !ok {
  4277. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4278. }
  4279. m.SetStatus(v)
  4280. return nil
  4281. }
  4282. return fmt.Errorf("unknown AllocAgent field %s", name)
  4283. }
  4284. // AddedFields returns all numeric fields that were incremented/decremented during
  4285. // this mutation.
  4286. func (m *AllocAgentMutation) AddedFields() []string {
  4287. var fields []string
  4288. if m.addorganization_id != nil {
  4289. fields = append(fields, allocagent.FieldOrganizationID)
  4290. }
  4291. if m.addstatus != nil {
  4292. fields = append(fields, allocagent.FieldStatus)
  4293. }
  4294. return fields
  4295. }
  4296. // AddedField returns the numeric value that was incremented/decremented on a field
  4297. // with the given name. The second boolean return value indicates that this field
  4298. // was not set, or was not defined in the schema.
  4299. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  4300. switch name {
  4301. case allocagent.FieldOrganizationID:
  4302. return m.AddedOrganizationID()
  4303. case allocagent.FieldStatus:
  4304. return m.AddedStatus()
  4305. }
  4306. return nil, false
  4307. }
  4308. // AddField adds the value to the field with the given name. It returns an error if
  4309. // the field is not defined in the schema, or if the type mismatched the field
  4310. // type.
  4311. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  4312. switch name {
  4313. case allocagent.FieldOrganizationID:
  4314. v, ok := value.(int64)
  4315. if !ok {
  4316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4317. }
  4318. m.AddOrganizationID(v)
  4319. return nil
  4320. case allocagent.FieldStatus:
  4321. v, ok := value.(int)
  4322. if !ok {
  4323. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4324. }
  4325. m.AddStatus(v)
  4326. return nil
  4327. }
  4328. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  4329. }
  4330. // ClearedFields returns all nullable fields that were cleared during this
  4331. // mutation.
  4332. func (m *AllocAgentMutation) ClearedFields() []string {
  4333. var fields []string
  4334. if m.FieldCleared(allocagent.FieldDeletedAt) {
  4335. fields = append(fields, allocagent.FieldDeletedAt)
  4336. }
  4337. if m.FieldCleared(allocagent.FieldUserID) {
  4338. fields = append(fields, allocagent.FieldUserID)
  4339. }
  4340. if m.FieldCleared(allocagent.FieldOrganizationID) {
  4341. fields = append(fields, allocagent.FieldOrganizationID)
  4342. }
  4343. if m.FieldCleared(allocagent.FieldStatus) {
  4344. fields = append(fields, allocagent.FieldStatus)
  4345. }
  4346. return fields
  4347. }
  4348. // FieldCleared returns a boolean indicating if a field with the given name was
  4349. // cleared in this mutation.
  4350. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  4351. _, ok := m.clearedFields[name]
  4352. return ok
  4353. }
  4354. // ClearField clears the value of the field with the given name. It returns an
  4355. // error if the field is not defined in the schema.
  4356. func (m *AllocAgentMutation) ClearField(name string) error {
  4357. switch name {
  4358. case allocagent.FieldDeletedAt:
  4359. m.ClearDeletedAt()
  4360. return nil
  4361. case allocagent.FieldUserID:
  4362. m.ClearUserID()
  4363. return nil
  4364. case allocagent.FieldOrganizationID:
  4365. m.ClearOrganizationID()
  4366. return nil
  4367. case allocagent.FieldStatus:
  4368. m.ClearStatus()
  4369. return nil
  4370. }
  4371. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  4372. }
  4373. // ResetField resets all changes in the mutation for the field with the given name.
  4374. // It returns an error if the field is not defined in the schema.
  4375. func (m *AllocAgentMutation) ResetField(name string) error {
  4376. switch name {
  4377. case allocagent.FieldCreatedAt:
  4378. m.ResetCreatedAt()
  4379. return nil
  4380. case allocagent.FieldUpdatedAt:
  4381. m.ResetUpdatedAt()
  4382. return nil
  4383. case allocagent.FieldDeletedAt:
  4384. m.ResetDeletedAt()
  4385. return nil
  4386. case allocagent.FieldUserID:
  4387. m.ResetUserID()
  4388. return nil
  4389. case allocagent.FieldOrganizationID:
  4390. m.ResetOrganizationID()
  4391. return nil
  4392. case allocagent.FieldAgents:
  4393. m.ResetAgents()
  4394. return nil
  4395. case allocagent.FieldStatus:
  4396. m.ResetStatus()
  4397. return nil
  4398. }
  4399. return fmt.Errorf("unknown AllocAgent field %s", name)
  4400. }
  4401. // AddedEdges returns all edge names that were set/added in this mutation.
  4402. func (m *AllocAgentMutation) AddedEdges() []string {
  4403. edges := make([]string, 0, 0)
  4404. return edges
  4405. }
  4406. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4407. // name in this mutation.
  4408. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  4409. return nil
  4410. }
  4411. // RemovedEdges returns all edge names that were removed in this mutation.
  4412. func (m *AllocAgentMutation) RemovedEdges() []string {
  4413. edges := make([]string, 0, 0)
  4414. return edges
  4415. }
  4416. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4417. // the given name in this mutation.
  4418. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  4419. return nil
  4420. }
  4421. // ClearedEdges returns all edge names that were cleared in this mutation.
  4422. func (m *AllocAgentMutation) ClearedEdges() []string {
  4423. edges := make([]string, 0, 0)
  4424. return edges
  4425. }
  4426. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4427. // was cleared in this mutation.
  4428. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  4429. return false
  4430. }
  4431. // ClearEdge clears the value of the edge with the given name. It returns an error
  4432. // if that edge is not defined in the schema.
  4433. func (m *AllocAgentMutation) ClearEdge(name string) error {
  4434. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  4435. }
  4436. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4437. // It returns an error if the edge is not defined in the schema.
  4438. func (m *AllocAgentMutation) ResetEdge(name string) error {
  4439. return fmt.Errorf("unknown AllocAgent edge %s", name)
  4440. }
  4441. // ApiKeyMutation represents an operation that mutates the ApiKey nodes in the graph.
  4442. type ApiKeyMutation struct {
  4443. config
  4444. op Op
  4445. typ string
  4446. id *uint64
  4447. created_at *time.Time
  4448. updated_at *time.Time
  4449. deleted_at *time.Time
  4450. title *string
  4451. key *string
  4452. organization_id *uint64
  4453. addorganization_id *int64
  4454. custom_agent_base *string
  4455. custom_agent_key *string
  4456. openai_base *string
  4457. openai_key *string
  4458. clearedFields map[string]struct{}
  4459. agent *uint64
  4460. clearedagent bool
  4461. done bool
  4462. oldValue func(context.Context) (*ApiKey, error)
  4463. predicates []predicate.ApiKey
  4464. }
  4465. var _ ent.Mutation = (*ApiKeyMutation)(nil)
  4466. // apikeyOption allows management of the mutation configuration using functional options.
  4467. type apikeyOption func(*ApiKeyMutation)
  4468. // newApiKeyMutation creates new mutation for the ApiKey entity.
  4469. func newApiKeyMutation(c config, op Op, opts ...apikeyOption) *ApiKeyMutation {
  4470. m := &ApiKeyMutation{
  4471. config: c,
  4472. op: op,
  4473. typ: TypeApiKey,
  4474. clearedFields: make(map[string]struct{}),
  4475. }
  4476. for _, opt := range opts {
  4477. opt(m)
  4478. }
  4479. return m
  4480. }
  4481. // withApiKeyID sets the ID field of the mutation.
  4482. func withApiKeyID(id uint64) apikeyOption {
  4483. return func(m *ApiKeyMutation) {
  4484. var (
  4485. err error
  4486. once sync.Once
  4487. value *ApiKey
  4488. )
  4489. m.oldValue = func(ctx context.Context) (*ApiKey, error) {
  4490. once.Do(func() {
  4491. if m.done {
  4492. err = errors.New("querying old values post mutation is not allowed")
  4493. } else {
  4494. value, err = m.Client().ApiKey.Get(ctx, id)
  4495. }
  4496. })
  4497. return value, err
  4498. }
  4499. m.id = &id
  4500. }
  4501. }
  4502. // withApiKey sets the old ApiKey of the mutation.
  4503. func withApiKey(node *ApiKey) apikeyOption {
  4504. return func(m *ApiKeyMutation) {
  4505. m.oldValue = func(context.Context) (*ApiKey, error) {
  4506. return node, nil
  4507. }
  4508. m.id = &node.ID
  4509. }
  4510. }
  4511. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4512. // executed in a transaction (ent.Tx), a transactional client is returned.
  4513. func (m ApiKeyMutation) Client() *Client {
  4514. client := &Client{config: m.config}
  4515. client.init()
  4516. return client
  4517. }
  4518. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4519. // it returns an error otherwise.
  4520. func (m ApiKeyMutation) Tx() (*Tx, error) {
  4521. if _, ok := m.driver.(*txDriver); !ok {
  4522. return nil, errors.New("ent: mutation is not running in a transaction")
  4523. }
  4524. tx := &Tx{config: m.config}
  4525. tx.init()
  4526. return tx, nil
  4527. }
  4528. // SetID sets the value of the id field. Note that this
  4529. // operation is only accepted on creation of ApiKey entities.
  4530. func (m *ApiKeyMutation) SetID(id uint64) {
  4531. m.id = &id
  4532. }
  4533. // ID returns the ID value in the mutation. Note that the ID is only available
  4534. // if it was provided to the builder or after it was returned from the database.
  4535. func (m *ApiKeyMutation) ID() (id uint64, exists bool) {
  4536. if m.id == nil {
  4537. return
  4538. }
  4539. return *m.id, true
  4540. }
  4541. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4542. // That means, if the mutation is applied within a transaction with an isolation level such
  4543. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4544. // or updated by the mutation.
  4545. func (m *ApiKeyMutation) IDs(ctx context.Context) ([]uint64, error) {
  4546. switch {
  4547. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4548. id, exists := m.ID()
  4549. if exists {
  4550. return []uint64{id}, nil
  4551. }
  4552. fallthrough
  4553. case m.op.Is(OpUpdate | OpDelete):
  4554. return m.Client().ApiKey.Query().Where(m.predicates...).IDs(ctx)
  4555. default:
  4556. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4557. }
  4558. }
  4559. // SetCreatedAt sets the "created_at" field.
  4560. func (m *ApiKeyMutation) SetCreatedAt(t time.Time) {
  4561. m.created_at = &t
  4562. }
  4563. // CreatedAt returns the value of the "created_at" field in the mutation.
  4564. func (m *ApiKeyMutation) CreatedAt() (r time.Time, exists bool) {
  4565. v := m.created_at
  4566. if v == nil {
  4567. return
  4568. }
  4569. return *v, true
  4570. }
  4571. // OldCreatedAt returns the old "created_at" field's value of the ApiKey entity.
  4572. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4573. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4574. func (m *ApiKeyMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4575. if !m.op.Is(OpUpdateOne) {
  4576. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4577. }
  4578. if m.id == nil || m.oldValue == nil {
  4579. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4580. }
  4581. oldValue, err := m.oldValue(ctx)
  4582. if err != nil {
  4583. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4584. }
  4585. return oldValue.CreatedAt, nil
  4586. }
  4587. // ResetCreatedAt resets all changes to the "created_at" field.
  4588. func (m *ApiKeyMutation) ResetCreatedAt() {
  4589. m.created_at = nil
  4590. }
  4591. // SetUpdatedAt sets the "updated_at" field.
  4592. func (m *ApiKeyMutation) SetUpdatedAt(t time.Time) {
  4593. m.updated_at = &t
  4594. }
  4595. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4596. func (m *ApiKeyMutation) UpdatedAt() (r time.Time, exists bool) {
  4597. v := m.updated_at
  4598. if v == nil {
  4599. return
  4600. }
  4601. return *v, true
  4602. }
  4603. // OldUpdatedAt returns the old "updated_at" field's value of the ApiKey entity.
  4604. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4605. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4606. func (m *ApiKeyMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4607. if !m.op.Is(OpUpdateOne) {
  4608. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4609. }
  4610. if m.id == nil || m.oldValue == nil {
  4611. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4612. }
  4613. oldValue, err := m.oldValue(ctx)
  4614. if err != nil {
  4615. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4616. }
  4617. return oldValue.UpdatedAt, nil
  4618. }
  4619. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4620. func (m *ApiKeyMutation) ResetUpdatedAt() {
  4621. m.updated_at = nil
  4622. }
  4623. // SetDeletedAt sets the "deleted_at" field.
  4624. func (m *ApiKeyMutation) SetDeletedAt(t time.Time) {
  4625. m.deleted_at = &t
  4626. }
  4627. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4628. func (m *ApiKeyMutation) DeletedAt() (r time.Time, exists bool) {
  4629. v := m.deleted_at
  4630. if v == nil {
  4631. return
  4632. }
  4633. return *v, true
  4634. }
  4635. // OldDeletedAt returns the old "deleted_at" field's value of the ApiKey entity.
  4636. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4637. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4638. func (m *ApiKeyMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4639. if !m.op.Is(OpUpdateOne) {
  4640. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4641. }
  4642. if m.id == nil || m.oldValue == nil {
  4643. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4644. }
  4645. oldValue, err := m.oldValue(ctx)
  4646. if err != nil {
  4647. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4648. }
  4649. return oldValue.DeletedAt, nil
  4650. }
  4651. // ClearDeletedAt clears the value of the "deleted_at" field.
  4652. func (m *ApiKeyMutation) ClearDeletedAt() {
  4653. m.deleted_at = nil
  4654. m.clearedFields[apikey.FieldDeletedAt] = struct{}{}
  4655. }
  4656. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4657. func (m *ApiKeyMutation) DeletedAtCleared() bool {
  4658. _, ok := m.clearedFields[apikey.FieldDeletedAt]
  4659. return ok
  4660. }
  4661. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4662. func (m *ApiKeyMutation) ResetDeletedAt() {
  4663. m.deleted_at = nil
  4664. delete(m.clearedFields, apikey.FieldDeletedAt)
  4665. }
  4666. // SetTitle sets the "title" field.
  4667. func (m *ApiKeyMutation) SetTitle(s string) {
  4668. m.title = &s
  4669. }
  4670. // Title returns the value of the "title" field in the mutation.
  4671. func (m *ApiKeyMutation) Title() (r string, exists bool) {
  4672. v := m.title
  4673. if v == nil {
  4674. return
  4675. }
  4676. return *v, true
  4677. }
  4678. // OldTitle returns the old "title" field's value of the ApiKey entity.
  4679. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4680. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4681. func (m *ApiKeyMutation) OldTitle(ctx context.Context) (v string, err error) {
  4682. if !m.op.Is(OpUpdateOne) {
  4683. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  4684. }
  4685. if m.id == nil || m.oldValue == nil {
  4686. return v, errors.New("OldTitle requires an ID field in the mutation")
  4687. }
  4688. oldValue, err := m.oldValue(ctx)
  4689. if err != nil {
  4690. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  4691. }
  4692. return oldValue.Title, nil
  4693. }
  4694. // ClearTitle clears the value of the "title" field.
  4695. func (m *ApiKeyMutation) ClearTitle() {
  4696. m.title = nil
  4697. m.clearedFields[apikey.FieldTitle] = struct{}{}
  4698. }
  4699. // TitleCleared returns if the "title" field was cleared in this mutation.
  4700. func (m *ApiKeyMutation) TitleCleared() bool {
  4701. _, ok := m.clearedFields[apikey.FieldTitle]
  4702. return ok
  4703. }
  4704. // ResetTitle resets all changes to the "title" field.
  4705. func (m *ApiKeyMutation) ResetTitle() {
  4706. m.title = nil
  4707. delete(m.clearedFields, apikey.FieldTitle)
  4708. }
  4709. // SetKey sets the "key" field.
  4710. func (m *ApiKeyMutation) SetKey(s string) {
  4711. m.key = &s
  4712. }
  4713. // Key returns the value of the "key" field in the mutation.
  4714. func (m *ApiKeyMutation) Key() (r string, exists bool) {
  4715. v := m.key
  4716. if v == nil {
  4717. return
  4718. }
  4719. return *v, true
  4720. }
  4721. // OldKey returns the old "key" field's value of the ApiKey entity.
  4722. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4723. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4724. func (m *ApiKeyMutation) OldKey(ctx context.Context) (v string, err error) {
  4725. if !m.op.Is(OpUpdateOne) {
  4726. return v, errors.New("OldKey is only allowed on UpdateOne operations")
  4727. }
  4728. if m.id == nil || m.oldValue == nil {
  4729. return v, errors.New("OldKey requires an ID field in the mutation")
  4730. }
  4731. oldValue, err := m.oldValue(ctx)
  4732. if err != nil {
  4733. return v, fmt.Errorf("querying old value for OldKey: %w", err)
  4734. }
  4735. return oldValue.Key, nil
  4736. }
  4737. // ClearKey clears the value of the "key" field.
  4738. func (m *ApiKeyMutation) ClearKey() {
  4739. m.key = nil
  4740. m.clearedFields[apikey.FieldKey] = struct{}{}
  4741. }
  4742. // KeyCleared returns if the "key" field was cleared in this mutation.
  4743. func (m *ApiKeyMutation) KeyCleared() bool {
  4744. _, ok := m.clearedFields[apikey.FieldKey]
  4745. return ok
  4746. }
  4747. // ResetKey resets all changes to the "key" field.
  4748. func (m *ApiKeyMutation) ResetKey() {
  4749. m.key = nil
  4750. delete(m.clearedFields, apikey.FieldKey)
  4751. }
  4752. // SetOrganizationID sets the "organization_id" field.
  4753. func (m *ApiKeyMutation) SetOrganizationID(u uint64) {
  4754. m.organization_id = &u
  4755. m.addorganization_id = nil
  4756. }
  4757. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4758. func (m *ApiKeyMutation) OrganizationID() (r uint64, exists bool) {
  4759. v := m.organization_id
  4760. if v == nil {
  4761. return
  4762. }
  4763. return *v, true
  4764. }
  4765. // OldOrganizationID returns the old "organization_id" field's value of the ApiKey entity.
  4766. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4767. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4768. func (m *ApiKeyMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4769. if !m.op.Is(OpUpdateOne) {
  4770. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4771. }
  4772. if m.id == nil || m.oldValue == nil {
  4773. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4774. }
  4775. oldValue, err := m.oldValue(ctx)
  4776. if err != nil {
  4777. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4778. }
  4779. return oldValue.OrganizationID, nil
  4780. }
  4781. // AddOrganizationID adds u to the "organization_id" field.
  4782. func (m *ApiKeyMutation) AddOrganizationID(u int64) {
  4783. if m.addorganization_id != nil {
  4784. *m.addorganization_id += u
  4785. } else {
  4786. m.addorganization_id = &u
  4787. }
  4788. }
  4789. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4790. func (m *ApiKeyMutation) AddedOrganizationID() (r int64, exists bool) {
  4791. v := m.addorganization_id
  4792. if v == nil {
  4793. return
  4794. }
  4795. return *v, true
  4796. }
  4797. // ResetOrganizationID resets all changes to the "organization_id" field.
  4798. func (m *ApiKeyMutation) ResetOrganizationID() {
  4799. m.organization_id = nil
  4800. m.addorganization_id = nil
  4801. }
  4802. // SetAgentID sets the "agent_id" field.
  4803. func (m *ApiKeyMutation) SetAgentID(u uint64) {
  4804. m.agent = &u
  4805. }
  4806. // AgentID returns the value of the "agent_id" field in the mutation.
  4807. func (m *ApiKeyMutation) AgentID() (r uint64, exists bool) {
  4808. v := m.agent
  4809. if v == nil {
  4810. return
  4811. }
  4812. return *v, true
  4813. }
  4814. // OldAgentID returns the old "agent_id" field's value of the ApiKey entity.
  4815. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4816. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4817. func (m *ApiKeyMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  4818. if !m.op.Is(OpUpdateOne) {
  4819. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  4820. }
  4821. if m.id == nil || m.oldValue == nil {
  4822. return v, errors.New("OldAgentID requires an ID field in the mutation")
  4823. }
  4824. oldValue, err := m.oldValue(ctx)
  4825. if err != nil {
  4826. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  4827. }
  4828. return oldValue.AgentID, nil
  4829. }
  4830. // ResetAgentID resets all changes to the "agent_id" field.
  4831. func (m *ApiKeyMutation) ResetAgentID() {
  4832. m.agent = nil
  4833. }
  4834. // SetCustomAgentBase sets the "custom_agent_base" field.
  4835. func (m *ApiKeyMutation) SetCustomAgentBase(s string) {
  4836. m.custom_agent_base = &s
  4837. }
  4838. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  4839. func (m *ApiKeyMutation) CustomAgentBase() (r string, exists bool) {
  4840. v := m.custom_agent_base
  4841. if v == nil {
  4842. return
  4843. }
  4844. return *v, true
  4845. }
  4846. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the ApiKey entity.
  4847. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4848. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4849. func (m *ApiKeyMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  4850. if !m.op.Is(OpUpdateOne) {
  4851. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  4852. }
  4853. if m.id == nil || m.oldValue == nil {
  4854. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  4855. }
  4856. oldValue, err := m.oldValue(ctx)
  4857. if err != nil {
  4858. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  4859. }
  4860. return oldValue.CustomAgentBase, nil
  4861. }
  4862. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  4863. func (m *ApiKeyMutation) ClearCustomAgentBase() {
  4864. m.custom_agent_base = nil
  4865. m.clearedFields[apikey.FieldCustomAgentBase] = struct{}{}
  4866. }
  4867. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  4868. func (m *ApiKeyMutation) CustomAgentBaseCleared() bool {
  4869. _, ok := m.clearedFields[apikey.FieldCustomAgentBase]
  4870. return ok
  4871. }
  4872. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  4873. func (m *ApiKeyMutation) ResetCustomAgentBase() {
  4874. m.custom_agent_base = nil
  4875. delete(m.clearedFields, apikey.FieldCustomAgentBase)
  4876. }
  4877. // SetCustomAgentKey sets the "custom_agent_key" field.
  4878. func (m *ApiKeyMutation) SetCustomAgentKey(s string) {
  4879. m.custom_agent_key = &s
  4880. }
  4881. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  4882. func (m *ApiKeyMutation) CustomAgentKey() (r string, exists bool) {
  4883. v := m.custom_agent_key
  4884. if v == nil {
  4885. return
  4886. }
  4887. return *v, true
  4888. }
  4889. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the ApiKey entity.
  4890. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4891. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4892. func (m *ApiKeyMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  4893. if !m.op.Is(OpUpdateOne) {
  4894. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  4895. }
  4896. if m.id == nil || m.oldValue == nil {
  4897. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  4898. }
  4899. oldValue, err := m.oldValue(ctx)
  4900. if err != nil {
  4901. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  4902. }
  4903. return oldValue.CustomAgentKey, nil
  4904. }
  4905. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  4906. func (m *ApiKeyMutation) ClearCustomAgentKey() {
  4907. m.custom_agent_key = nil
  4908. m.clearedFields[apikey.FieldCustomAgentKey] = struct{}{}
  4909. }
  4910. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  4911. func (m *ApiKeyMutation) CustomAgentKeyCleared() bool {
  4912. _, ok := m.clearedFields[apikey.FieldCustomAgentKey]
  4913. return ok
  4914. }
  4915. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  4916. func (m *ApiKeyMutation) ResetCustomAgentKey() {
  4917. m.custom_agent_key = nil
  4918. delete(m.clearedFields, apikey.FieldCustomAgentKey)
  4919. }
  4920. // SetOpenaiBase sets the "openai_base" field.
  4921. func (m *ApiKeyMutation) SetOpenaiBase(s string) {
  4922. m.openai_base = &s
  4923. }
  4924. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  4925. func (m *ApiKeyMutation) OpenaiBase() (r string, exists bool) {
  4926. v := m.openai_base
  4927. if v == nil {
  4928. return
  4929. }
  4930. return *v, true
  4931. }
  4932. // OldOpenaiBase returns the old "openai_base" field's value of the ApiKey entity.
  4933. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4934. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4935. func (m *ApiKeyMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  4936. if !m.op.Is(OpUpdateOne) {
  4937. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  4938. }
  4939. if m.id == nil || m.oldValue == nil {
  4940. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  4941. }
  4942. oldValue, err := m.oldValue(ctx)
  4943. if err != nil {
  4944. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  4945. }
  4946. return oldValue.OpenaiBase, nil
  4947. }
  4948. // ClearOpenaiBase clears the value of the "openai_base" field.
  4949. func (m *ApiKeyMutation) ClearOpenaiBase() {
  4950. m.openai_base = nil
  4951. m.clearedFields[apikey.FieldOpenaiBase] = struct{}{}
  4952. }
  4953. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  4954. func (m *ApiKeyMutation) OpenaiBaseCleared() bool {
  4955. _, ok := m.clearedFields[apikey.FieldOpenaiBase]
  4956. return ok
  4957. }
  4958. // ResetOpenaiBase resets all changes to the "openai_base" field.
  4959. func (m *ApiKeyMutation) ResetOpenaiBase() {
  4960. m.openai_base = nil
  4961. delete(m.clearedFields, apikey.FieldOpenaiBase)
  4962. }
  4963. // SetOpenaiKey sets the "openai_key" field.
  4964. func (m *ApiKeyMutation) SetOpenaiKey(s string) {
  4965. m.openai_key = &s
  4966. }
  4967. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  4968. func (m *ApiKeyMutation) OpenaiKey() (r string, exists bool) {
  4969. v := m.openai_key
  4970. if v == nil {
  4971. return
  4972. }
  4973. return *v, true
  4974. }
  4975. // OldOpenaiKey returns the old "openai_key" field's value of the ApiKey entity.
  4976. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4977. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4978. func (m *ApiKeyMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  4979. if !m.op.Is(OpUpdateOne) {
  4980. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  4981. }
  4982. if m.id == nil || m.oldValue == nil {
  4983. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  4984. }
  4985. oldValue, err := m.oldValue(ctx)
  4986. if err != nil {
  4987. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  4988. }
  4989. return oldValue.OpenaiKey, nil
  4990. }
  4991. // ClearOpenaiKey clears the value of the "openai_key" field.
  4992. func (m *ApiKeyMutation) ClearOpenaiKey() {
  4993. m.openai_key = nil
  4994. m.clearedFields[apikey.FieldOpenaiKey] = struct{}{}
  4995. }
  4996. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  4997. func (m *ApiKeyMutation) OpenaiKeyCleared() bool {
  4998. _, ok := m.clearedFields[apikey.FieldOpenaiKey]
  4999. return ok
  5000. }
  5001. // ResetOpenaiKey resets all changes to the "openai_key" field.
  5002. func (m *ApiKeyMutation) ResetOpenaiKey() {
  5003. m.openai_key = nil
  5004. delete(m.clearedFields, apikey.FieldOpenaiKey)
  5005. }
  5006. // ClearAgent clears the "agent" edge to the Agent entity.
  5007. func (m *ApiKeyMutation) ClearAgent() {
  5008. m.clearedagent = true
  5009. m.clearedFields[apikey.FieldAgentID] = struct{}{}
  5010. }
  5011. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  5012. func (m *ApiKeyMutation) AgentCleared() bool {
  5013. return m.clearedagent
  5014. }
  5015. // AgentIDs returns the "agent" edge IDs in the mutation.
  5016. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  5017. // AgentID instead. It exists only for internal usage by the builders.
  5018. func (m *ApiKeyMutation) AgentIDs() (ids []uint64) {
  5019. if id := m.agent; id != nil {
  5020. ids = append(ids, *id)
  5021. }
  5022. return
  5023. }
  5024. // ResetAgent resets all changes to the "agent" edge.
  5025. func (m *ApiKeyMutation) ResetAgent() {
  5026. m.agent = nil
  5027. m.clearedagent = false
  5028. }
  5029. // Where appends a list predicates to the ApiKeyMutation builder.
  5030. func (m *ApiKeyMutation) Where(ps ...predicate.ApiKey) {
  5031. m.predicates = append(m.predicates, ps...)
  5032. }
  5033. // WhereP appends storage-level predicates to the ApiKeyMutation builder. Using this method,
  5034. // users can use type-assertion to append predicates that do not depend on any generated package.
  5035. func (m *ApiKeyMutation) WhereP(ps ...func(*sql.Selector)) {
  5036. p := make([]predicate.ApiKey, len(ps))
  5037. for i := range ps {
  5038. p[i] = ps[i]
  5039. }
  5040. m.Where(p...)
  5041. }
  5042. // Op returns the operation name.
  5043. func (m *ApiKeyMutation) Op() Op {
  5044. return m.op
  5045. }
  5046. // SetOp allows setting the mutation operation.
  5047. func (m *ApiKeyMutation) SetOp(op Op) {
  5048. m.op = op
  5049. }
  5050. // Type returns the node type of this mutation (ApiKey).
  5051. func (m *ApiKeyMutation) Type() string {
  5052. return m.typ
  5053. }
  5054. // Fields returns all fields that were changed during this mutation. Note that in
  5055. // order to get all numeric fields that were incremented/decremented, call
  5056. // AddedFields().
  5057. func (m *ApiKeyMutation) Fields() []string {
  5058. fields := make([]string, 0, 11)
  5059. if m.created_at != nil {
  5060. fields = append(fields, apikey.FieldCreatedAt)
  5061. }
  5062. if m.updated_at != nil {
  5063. fields = append(fields, apikey.FieldUpdatedAt)
  5064. }
  5065. if m.deleted_at != nil {
  5066. fields = append(fields, apikey.FieldDeletedAt)
  5067. }
  5068. if m.title != nil {
  5069. fields = append(fields, apikey.FieldTitle)
  5070. }
  5071. if m.key != nil {
  5072. fields = append(fields, apikey.FieldKey)
  5073. }
  5074. if m.organization_id != nil {
  5075. fields = append(fields, apikey.FieldOrganizationID)
  5076. }
  5077. if m.agent != nil {
  5078. fields = append(fields, apikey.FieldAgentID)
  5079. }
  5080. if m.custom_agent_base != nil {
  5081. fields = append(fields, apikey.FieldCustomAgentBase)
  5082. }
  5083. if m.custom_agent_key != nil {
  5084. fields = append(fields, apikey.FieldCustomAgentKey)
  5085. }
  5086. if m.openai_base != nil {
  5087. fields = append(fields, apikey.FieldOpenaiBase)
  5088. }
  5089. if m.openai_key != nil {
  5090. fields = append(fields, apikey.FieldOpenaiKey)
  5091. }
  5092. return fields
  5093. }
  5094. // Field returns the value of a field with the given name. The second boolean
  5095. // return value indicates that this field was not set, or was not defined in the
  5096. // schema.
  5097. func (m *ApiKeyMutation) Field(name string) (ent.Value, bool) {
  5098. switch name {
  5099. case apikey.FieldCreatedAt:
  5100. return m.CreatedAt()
  5101. case apikey.FieldUpdatedAt:
  5102. return m.UpdatedAt()
  5103. case apikey.FieldDeletedAt:
  5104. return m.DeletedAt()
  5105. case apikey.FieldTitle:
  5106. return m.Title()
  5107. case apikey.FieldKey:
  5108. return m.Key()
  5109. case apikey.FieldOrganizationID:
  5110. return m.OrganizationID()
  5111. case apikey.FieldAgentID:
  5112. return m.AgentID()
  5113. case apikey.FieldCustomAgentBase:
  5114. return m.CustomAgentBase()
  5115. case apikey.FieldCustomAgentKey:
  5116. return m.CustomAgentKey()
  5117. case apikey.FieldOpenaiBase:
  5118. return m.OpenaiBase()
  5119. case apikey.FieldOpenaiKey:
  5120. return m.OpenaiKey()
  5121. }
  5122. return nil, false
  5123. }
  5124. // OldField returns the old value of the field from the database. An error is
  5125. // returned if the mutation operation is not UpdateOne, or the query to the
  5126. // database failed.
  5127. func (m *ApiKeyMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5128. switch name {
  5129. case apikey.FieldCreatedAt:
  5130. return m.OldCreatedAt(ctx)
  5131. case apikey.FieldUpdatedAt:
  5132. return m.OldUpdatedAt(ctx)
  5133. case apikey.FieldDeletedAt:
  5134. return m.OldDeletedAt(ctx)
  5135. case apikey.FieldTitle:
  5136. return m.OldTitle(ctx)
  5137. case apikey.FieldKey:
  5138. return m.OldKey(ctx)
  5139. case apikey.FieldOrganizationID:
  5140. return m.OldOrganizationID(ctx)
  5141. case apikey.FieldAgentID:
  5142. return m.OldAgentID(ctx)
  5143. case apikey.FieldCustomAgentBase:
  5144. return m.OldCustomAgentBase(ctx)
  5145. case apikey.FieldCustomAgentKey:
  5146. return m.OldCustomAgentKey(ctx)
  5147. case apikey.FieldOpenaiBase:
  5148. return m.OldOpenaiBase(ctx)
  5149. case apikey.FieldOpenaiKey:
  5150. return m.OldOpenaiKey(ctx)
  5151. }
  5152. return nil, fmt.Errorf("unknown ApiKey field %s", name)
  5153. }
  5154. // SetField sets the value of a field with the given name. It returns an error if
  5155. // the field is not defined in the schema, or if the type mismatched the field
  5156. // type.
  5157. func (m *ApiKeyMutation) SetField(name string, value ent.Value) error {
  5158. switch name {
  5159. case apikey.FieldCreatedAt:
  5160. v, ok := value.(time.Time)
  5161. if !ok {
  5162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5163. }
  5164. m.SetCreatedAt(v)
  5165. return nil
  5166. case apikey.FieldUpdatedAt:
  5167. v, ok := value.(time.Time)
  5168. if !ok {
  5169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5170. }
  5171. m.SetUpdatedAt(v)
  5172. return nil
  5173. case apikey.FieldDeletedAt:
  5174. v, ok := value.(time.Time)
  5175. if !ok {
  5176. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5177. }
  5178. m.SetDeletedAt(v)
  5179. return nil
  5180. case apikey.FieldTitle:
  5181. v, ok := value.(string)
  5182. if !ok {
  5183. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5184. }
  5185. m.SetTitle(v)
  5186. return nil
  5187. case apikey.FieldKey:
  5188. v, ok := value.(string)
  5189. if !ok {
  5190. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5191. }
  5192. m.SetKey(v)
  5193. return nil
  5194. case apikey.FieldOrganizationID:
  5195. v, ok := value.(uint64)
  5196. if !ok {
  5197. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5198. }
  5199. m.SetOrganizationID(v)
  5200. return nil
  5201. case apikey.FieldAgentID:
  5202. v, ok := value.(uint64)
  5203. if !ok {
  5204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5205. }
  5206. m.SetAgentID(v)
  5207. return nil
  5208. case apikey.FieldCustomAgentBase:
  5209. v, ok := value.(string)
  5210. if !ok {
  5211. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5212. }
  5213. m.SetCustomAgentBase(v)
  5214. return nil
  5215. case apikey.FieldCustomAgentKey:
  5216. v, ok := value.(string)
  5217. if !ok {
  5218. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5219. }
  5220. m.SetCustomAgentKey(v)
  5221. return nil
  5222. case apikey.FieldOpenaiBase:
  5223. v, ok := value.(string)
  5224. if !ok {
  5225. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5226. }
  5227. m.SetOpenaiBase(v)
  5228. return nil
  5229. case apikey.FieldOpenaiKey:
  5230. v, ok := value.(string)
  5231. if !ok {
  5232. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5233. }
  5234. m.SetOpenaiKey(v)
  5235. return nil
  5236. }
  5237. return fmt.Errorf("unknown ApiKey field %s", name)
  5238. }
  5239. // AddedFields returns all numeric fields that were incremented/decremented during
  5240. // this mutation.
  5241. func (m *ApiKeyMutation) AddedFields() []string {
  5242. var fields []string
  5243. if m.addorganization_id != nil {
  5244. fields = append(fields, apikey.FieldOrganizationID)
  5245. }
  5246. return fields
  5247. }
  5248. // AddedField returns the numeric value that was incremented/decremented on a field
  5249. // with the given name. The second boolean return value indicates that this field
  5250. // was not set, or was not defined in the schema.
  5251. func (m *ApiKeyMutation) AddedField(name string) (ent.Value, bool) {
  5252. switch name {
  5253. case apikey.FieldOrganizationID:
  5254. return m.AddedOrganizationID()
  5255. }
  5256. return nil, false
  5257. }
  5258. // AddField adds the value to the field with the given name. It returns an error if
  5259. // the field is not defined in the schema, or if the type mismatched the field
  5260. // type.
  5261. func (m *ApiKeyMutation) AddField(name string, value ent.Value) error {
  5262. switch name {
  5263. case apikey.FieldOrganizationID:
  5264. v, ok := value.(int64)
  5265. if !ok {
  5266. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5267. }
  5268. m.AddOrganizationID(v)
  5269. return nil
  5270. }
  5271. return fmt.Errorf("unknown ApiKey numeric field %s", name)
  5272. }
  5273. // ClearedFields returns all nullable fields that were cleared during this
  5274. // mutation.
  5275. func (m *ApiKeyMutation) ClearedFields() []string {
  5276. var fields []string
  5277. if m.FieldCleared(apikey.FieldDeletedAt) {
  5278. fields = append(fields, apikey.FieldDeletedAt)
  5279. }
  5280. if m.FieldCleared(apikey.FieldTitle) {
  5281. fields = append(fields, apikey.FieldTitle)
  5282. }
  5283. if m.FieldCleared(apikey.FieldKey) {
  5284. fields = append(fields, apikey.FieldKey)
  5285. }
  5286. if m.FieldCleared(apikey.FieldCustomAgentBase) {
  5287. fields = append(fields, apikey.FieldCustomAgentBase)
  5288. }
  5289. if m.FieldCleared(apikey.FieldCustomAgentKey) {
  5290. fields = append(fields, apikey.FieldCustomAgentKey)
  5291. }
  5292. if m.FieldCleared(apikey.FieldOpenaiBase) {
  5293. fields = append(fields, apikey.FieldOpenaiBase)
  5294. }
  5295. if m.FieldCleared(apikey.FieldOpenaiKey) {
  5296. fields = append(fields, apikey.FieldOpenaiKey)
  5297. }
  5298. return fields
  5299. }
  5300. // FieldCleared returns a boolean indicating if a field with the given name was
  5301. // cleared in this mutation.
  5302. func (m *ApiKeyMutation) FieldCleared(name string) bool {
  5303. _, ok := m.clearedFields[name]
  5304. return ok
  5305. }
  5306. // ClearField clears the value of the field with the given name. It returns an
  5307. // error if the field is not defined in the schema.
  5308. func (m *ApiKeyMutation) ClearField(name string) error {
  5309. switch name {
  5310. case apikey.FieldDeletedAt:
  5311. m.ClearDeletedAt()
  5312. return nil
  5313. case apikey.FieldTitle:
  5314. m.ClearTitle()
  5315. return nil
  5316. case apikey.FieldKey:
  5317. m.ClearKey()
  5318. return nil
  5319. case apikey.FieldCustomAgentBase:
  5320. m.ClearCustomAgentBase()
  5321. return nil
  5322. case apikey.FieldCustomAgentKey:
  5323. m.ClearCustomAgentKey()
  5324. return nil
  5325. case apikey.FieldOpenaiBase:
  5326. m.ClearOpenaiBase()
  5327. return nil
  5328. case apikey.FieldOpenaiKey:
  5329. m.ClearOpenaiKey()
  5330. return nil
  5331. }
  5332. return fmt.Errorf("unknown ApiKey nullable field %s", name)
  5333. }
  5334. // ResetField resets all changes in the mutation for the field with the given name.
  5335. // It returns an error if the field is not defined in the schema.
  5336. func (m *ApiKeyMutation) ResetField(name string) error {
  5337. switch name {
  5338. case apikey.FieldCreatedAt:
  5339. m.ResetCreatedAt()
  5340. return nil
  5341. case apikey.FieldUpdatedAt:
  5342. m.ResetUpdatedAt()
  5343. return nil
  5344. case apikey.FieldDeletedAt:
  5345. m.ResetDeletedAt()
  5346. return nil
  5347. case apikey.FieldTitle:
  5348. m.ResetTitle()
  5349. return nil
  5350. case apikey.FieldKey:
  5351. m.ResetKey()
  5352. return nil
  5353. case apikey.FieldOrganizationID:
  5354. m.ResetOrganizationID()
  5355. return nil
  5356. case apikey.FieldAgentID:
  5357. m.ResetAgentID()
  5358. return nil
  5359. case apikey.FieldCustomAgentBase:
  5360. m.ResetCustomAgentBase()
  5361. return nil
  5362. case apikey.FieldCustomAgentKey:
  5363. m.ResetCustomAgentKey()
  5364. return nil
  5365. case apikey.FieldOpenaiBase:
  5366. m.ResetOpenaiBase()
  5367. return nil
  5368. case apikey.FieldOpenaiKey:
  5369. m.ResetOpenaiKey()
  5370. return nil
  5371. }
  5372. return fmt.Errorf("unknown ApiKey field %s", name)
  5373. }
  5374. // AddedEdges returns all edge names that were set/added in this mutation.
  5375. func (m *ApiKeyMutation) AddedEdges() []string {
  5376. edges := make([]string, 0, 1)
  5377. if m.agent != nil {
  5378. edges = append(edges, apikey.EdgeAgent)
  5379. }
  5380. return edges
  5381. }
  5382. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5383. // name in this mutation.
  5384. func (m *ApiKeyMutation) AddedIDs(name string) []ent.Value {
  5385. switch name {
  5386. case apikey.EdgeAgent:
  5387. if id := m.agent; id != nil {
  5388. return []ent.Value{*id}
  5389. }
  5390. }
  5391. return nil
  5392. }
  5393. // RemovedEdges returns all edge names that were removed in this mutation.
  5394. func (m *ApiKeyMutation) RemovedEdges() []string {
  5395. edges := make([]string, 0, 1)
  5396. return edges
  5397. }
  5398. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5399. // the given name in this mutation.
  5400. func (m *ApiKeyMutation) RemovedIDs(name string) []ent.Value {
  5401. return nil
  5402. }
  5403. // ClearedEdges returns all edge names that were cleared in this mutation.
  5404. func (m *ApiKeyMutation) ClearedEdges() []string {
  5405. edges := make([]string, 0, 1)
  5406. if m.clearedagent {
  5407. edges = append(edges, apikey.EdgeAgent)
  5408. }
  5409. return edges
  5410. }
  5411. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5412. // was cleared in this mutation.
  5413. func (m *ApiKeyMutation) EdgeCleared(name string) bool {
  5414. switch name {
  5415. case apikey.EdgeAgent:
  5416. return m.clearedagent
  5417. }
  5418. return false
  5419. }
  5420. // ClearEdge clears the value of the edge with the given name. It returns an error
  5421. // if that edge is not defined in the schema.
  5422. func (m *ApiKeyMutation) ClearEdge(name string) error {
  5423. switch name {
  5424. case apikey.EdgeAgent:
  5425. m.ClearAgent()
  5426. return nil
  5427. }
  5428. return fmt.Errorf("unknown ApiKey unique edge %s", name)
  5429. }
  5430. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5431. // It returns an error if the edge is not defined in the schema.
  5432. func (m *ApiKeyMutation) ResetEdge(name string) error {
  5433. switch name {
  5434. case apikey.EdgeAgent:
  5435. m.ResetAgent()
  5436. return nil
  5437. }
  5438. return fmt.Errorf("unknown ApiKey edge %s", name)
  5439. }
  5440. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  5441. type BatchMsgMutation struct {
  5442. config
  5443. op Op
  5444. typ string
  5445. id *uint64
  5446. created_at *time.Time
  5447. updated_at *time.Time
  5448. deleted_at *time.Time
  5449. status *uint8
  5450. addstatus *int8
  5451. batch_no *string
  5452. task_name *string
  5453. fromwxid *string
  5454. msg *string
  5455. tag *string
  5456. tagids *string
  5457. total *int32
  5458. addtotal *int32
  5459. success *int32
  5460. addsuccess *int32
  5461. fail *int32
  5462. addfail *int32
  5463. start_time *time.Time
  5464. stop_time *time.Time
  5465. send_time *time.Time
  5466. _type *int32
  5467. add_type *int32
  5468. organization_id *uint64
  5469. addorganization_id *int64
  5470. ctype *uint64
  5471. addctype *int64
  5472. cc *string
  5473. phone *string
  5474. template_name *string
  5475. template_code *string
  5476. lang *string
  5477. clearedFields map[string]struct{}
  5478. done bool
  5479. oldValue func(context.Context) (*BatchMsg, error)
  5480. predicates []predicate.BatchMsg
  5481. }
  5482. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  5483. // batchmsgOption allows management of the mutation configuration using functional options.
  5484. type batchmsgOption func(*BatchMsgMutation)
  5485. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  5486. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  5487. m := &BatchMsgMutation{
  5488. config: c,
  5489. op: op,
  5490. typ: TypeBatchMsg,
  5491. clearedFields: make(map[string]struct{}),
  5492. }
  5493. for _, opt := range opts {
  5494. opt(m)
  5495. }
  5496. return m
  5497. }
  5498. // withBatchMsgID sets the ID field of the mutation.
  5499. func withBatchMsgID(id uint64) batchmsgOption {
  5500. return func(m *BatchMsgMutation) {
  5501. var (
  5502. err error
  5503. once sync.Once
  5504. value *BatchMsg
  5505. )
  5506. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  5507. once.Do(func() {
  5508. if m.done {
  5509. err = errors.New("querying old values post mutation is not allowed")
  5510. } else {
  5511. value, err = m.Client().BatchMsg.Get(ctx, id)
  5512. }
  5513. })
  5514. return value, err
  5515. }
  5516. m.id = &id
  5517. }
  5518. }
  5519. // withBatchMsg sets the old BatchMsg of the mutation.
  5520. func withBatchMsg(node *BatchMsg) batchmsgOption {
  5521. return func(m *BatchMsgMutation) {
  5522. m.oldValue = func(context.Context) (*BatchMsg, error) {
  5523. return node, nil
  5524. }
  5525. m.id = &node.ID
  5526. }
  5527. }
  5528. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5529. // executed in a transaction (ent.Tx), a transactional client is returned.
  5530. func (m BatchMsgMutation) Client() *Client {
  5531. client := &Client{config: m.config}
  5532. client.init()
  5533. return client
  5534. }
  5535. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5536. // it returns an error otherwise.
  5537. func (m BatchMsgMutation) Tx() (*Tx, error) {
  5538. if _, ok := m.driver.(*txDriver); !ok {
  5539. return nil, errors.New("ent: mutation is not running in a transaction")
  5540. }
  5541. tx := &Tx{config: m.config}
  5542. tx.init()
  5543. return tx, nil
  5544. }
  5545. // SetID sets the value of the id field. Note that this
  5546. // operation is only accepted on creation of BatchMsg entities.
  5547. func (m *BatchMsgMutation) SetID(id uint64) {
  5548. m.id = &id
  5549. }
  5550. // ID returns the ID value in the mutation. Note that the ID is only available
  5551. // if it was provided to the builder or after it was returned from the database.
  5552. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  5553. if m.id == nil {
  5554. return
  5555. }
  5556. return *m.id, true
  5557. }
  5558. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5559. // That means, if the mutation is applied within a transaction with an isolation level such
  5560. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5561. // or updated by the mutation.
  5562. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  5563. switch {
  5564. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5565. id, exists := m.ID()
  5566. if exists {
  5567. return []uint64{id}, nil
  5568. }
  5569. fallthrough
  5570. case m.op.Is(OpUpdate | OpDelete):
  5571. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  5572. default:
  5573. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5574. }
  5575. }
  5576. // SetCreatedAt sets the "created_at" field.
  5577. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  5578. m.created_at = &t
  5579. }
  5580. // CreatedAt returns the value of the "created_at" field in the mutation.
  5581. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  5582. v := m.created_at
  5583. if v == nil {
  5584. return
  5585. }
  5586. return *v, true
  5587. }
  5588. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  5589. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5590. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5591. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5592. if !m.op.Is(OpUpdateOne) {
  5593. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5594. }
  5595. if m.id == nil || m.oldValue == nil {
  5596. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5597. }
  5598. oldValue, err := m.oldValue(ctx)
  5599. if err != nil {
  5600. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5601. }
  5602. return oldValue.CreatedAt, nil
  5603. }
  5604. // ResetCreatedAt resets all changes to the "created_at" field.
  5605. func (m *BatchMsgMutation) ResetCreatedAt() {
  5606. m.created_at = nil
  5607. }
  5608. // SetUpdatedAt sets the "updated_at" field.
  5609. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  5610. m.updated_at = &t
  5611. }
  5612. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5613. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  5614. v := m.updated_at
  5615. if v == nil {
  5616. return
  5617. }
  5618. return *v, true
  5619. }
  5620. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  5621. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5622. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5623. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5624. if !m.op.Is(OpUpdateOne) {
  5625. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5626. }
  5627. if m.id == nil || m.oldValue == nil {
  5628. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5629. }
  5630. oldValue, err := m.oldValue(ctx)
  5631. if err != nil {
  5632. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5633. }
  5634. return oldValue.UpdatedAt, nil
  5635. }
  5636. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5637. func (m *BatchMsgMutation) ResetUpdatedAt() {
  5638. m.updated_at = nil
  5639. }
  5640. // SetDeletedAt sets the "deleted_at" field.
  5641. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  5642. m.deleted_at = &t
  5643. }
  5644. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5645. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  5646. v := m.deleted_at
  5647. if v == nil {
  5648. return
  5649. }
  5650. return *v, true
  5651. }
  5652. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  5653. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5654. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5655. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5656. if !m.op.Is(OpUpdateOne) {
  5657. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5658. }
  5659. if m.id == nil || m.oldValue == nil {
  5660. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5661. }
  5662. oldValue, err := m.oldValue(ctx)
  5663. if err != nil {
  5664. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5665. }
  5666. return oldValue.DeletedAt, nil
  5667. }
  5668. // ClearDeletedAt clears the value of the "deleted_at" field.
  5669. func (m *BatchMsgMutation) ClearDeletedAt() {
  5670. m.deleted_at = nil
  5671. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  5672. }
  5673. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5674. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  5675. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  5676. return ok
  5677. }
  5678. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5679. func (m *BatchMsgMutation) ResetDeletedAt() {
  5680. m.deleted_at = nil
  5681. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  5682. }
  5683. // SetStatus sets the "status" field.
  5684. func (m *BatchMsgMutation) SetStatus(u uint8) {
  5685. m.status = &u
  5686. m.addstatus = nil
  5687. }
  5688. // Status returns the value of the "status" field in the mutation.
  5689. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  5690. v := m.status
  5691. if v == nil {
  5692. return
  5693. }
  5694. return *v, true
  5695. }
  5696. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  5697. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5699. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  5700. if !m.op.Is(OpUpdateOne) {
  5701. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  5702. }
  5703. if m.id == nil || m.oldValue == nil {
  5704. return v, errors.New("OldStatus requires an ID field in the mutation")
  5705. }
  5706. oldValue, err := m.oldValue(ctx)
  5707. if err != nil {
  5708. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  5709. }
  5710. return oldValue.Status, nil
  5711. }
  5712. // AddStatus adds u to the "status" field.
  5713. func (m *BatchMsgMutation) AddStatus(u int8) {
  5714. if m.addstatus != nil {
  5715. *m.addstatus += u
  5716. } else {
  5717. m.addstatus = &u
  5718. }
  5719. }
  5720. // AddedStatus returns the value that was added to the "status" field in this mutation.
  5721. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  5722. v := m.addstatus
  5723. if v == nil {
  5724. return
  5725. }
  5726. return *v, true
  5727. }
  5728. // ClearStatus clears the value of the "status" field.
  5729. func (m *BatchMsgMutation) ClearStatus() {
  5730. m.status = nil
  5731. m.addstatus = nil
  5732. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  5733. }
  5734. // StatusCleared returns if the "status" field was cleared in this mutation.
  5735. func (m *BatchMsgMutation) StatusCleared() bool {
  5736. _, ok := m.clearedFields[batchmsg.FieldStatus]
  5737. return ok
  5738. }
  5739. // ResetStatus resets all changes to the "status" field.
  5740. func (m *BatchMsgMutation) ResetStatus() {
  5741. m.status = nil
  5742. m.addstatus = nil
  5743. delete(m.clearedFields, batchmsg.FieldStatus)
  5744. }
  5745. // SetBatchNo sets the "batch_no" field.
  5746. func (m *BatchMsgMutation) SetBatchNo(s string) {
  5747. m.batch_no = &s
  5748. }
  5749. // BatchNo returns the value of the "batch_no" field in the mutation.
  5750. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  5751. v := m.batch_no
  5752. if v == nil {
  5753. return
  5754. }
  5755. return *v, true
  5756. }
  5757. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  5758. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5759. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5760. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  5761. if !m.op.Is(OpUpdateOne) {
  5762. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  5763. }
  5764. if m.id == nil || m.oldValue == nil {
  5765. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  5766. }
  5767. oldValue, err := m.oldValue(ctx)
  5768. if err != nil {
  5769. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  5770. }
  5771. return oldValue.BatchNo, nil
  5772. }
  5773. // ClearBatchNo clears the value of the "batch_no" field.
  5774. func (m *BatchMsgMutation) ClearBatchNo() {
  5775. m.batch_no = nil
  5776. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  5777. }
  5778. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  5779. func (m *BatchMsgMutation) BatchNoCleared() bool {
  5780. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  5781. return ok
  5782. }
  5783. // ResetBatchNo resets all changes to the "batch_no" field.
  5784. func (m *BatchMsgMutation) ResetBatchNo() {
  5785. m.batch_no = nil
  5786. delete(m.clearedFields, batchmsg.FieldBatchNo)
  5787. }
  5788. // SetTaskName sets the "task_name" field.
  5789. func (m *BatchMsgMutation) SetTaskName(s string) {
  5790. m.task_name = &s
  5791. }
  5792. // TaskName returns the value of the "task_name" field in the mutation.
  5793. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  5794. v := m.task_name
  5795. if v == nil {
  5796. return
  5797. }
  5798. return *v, true
  5799. }
  5800. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  5801. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5802. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5803. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  5804. if !m.op.Is(OpUpdateOne) {
  5805. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  5806. }
  5807. if m.id == nil || m.oldValue == nil {
  5808. return v, errors.New("OldTaskName requires an ID field in the mutation")
  5809. }
  5810. oldValue, err := m.oldValue(ctx)
  5811. if err != nil {
  5812. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  5813. }
  5814. return oldValue.TaskName, nil
  5815. }
  5816. // ClearTaskName clears the value of the "task_name" field.
  5817. func (m *BatchMsgMutation) ClearTaskName() {
  5818. m.task_name = nil
  5819. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  5820. }
  5821. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  5822. func (m *BatchMsgMutation) TaskNameCleared() bool {
  5823. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  5824. return ok
  5825. }
  5826. // ResetTaskName resets all changes to the "task_name" field.
  5827. func (m *BatchMsgMutation) ResetTaskName() {
  5828. m.task_name = nil
  5829. delete(m.clearedFields, batchmsg.FieldTaskName)
  5830. }
  5831. // SetFromwxid sets the "fromwxid" field.
  5832. func (m *BatchMsgMutation) SetFromwxid(s string) {
  5833. m.fromwxid = &s
  5834. }
  5835. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  5836. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  5837. v := m.fromwxid
  5838. if v == nil {
  5839. return
  5840. }
  5841. return *v, true
  5842. }
  5843. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  5844. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5846. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  5847. if !m.op.Is(OpUpdateOne) {
  5848. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  5849. }
  5850. if m.id == nil || m.oldValue == nil {
  5851. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  5852. }
  5853. oldValue, err := m.oldValue(ctx)
  5854. if err != nil {
  5855. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  5856. }
  5857. return oldValue.Fromwxid, nil
  5858. }
  5859. // ClearFromwxid clears the value of the "fromwxid" field.
  5860. func (m *BatchMsgMutation) ClearFromwxid() {
  5861. m.fromwxid = nil
  5862. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  5863. }
  5864. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  5865. func (m *BatchMsgMutation) FromwxidCleared() bool {
  5866. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  5867. return ok
  5868. }
  5869. // ResetFromwxid resets all changes to the "fromwxid" field.
  5870. func (m *BatchMsgMutation) ResetFromwxid() {
  5871. m.fromwxid = nil
  5872. delete(m.clearedFields, batchmsg.FieldFromwxid)
  5873. }
  5874. // SetMsg sets the "msg" field.
  5875. func (m *BatchMsgMutation) SetMsg(s string) {
  5876. m.msg = &s
  5877. }
  5878. // Msg returns the value of the "msg" field in the mutation.
  5879. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  5880. v := m.msg
  5881. if v == nil {
  5882. return
  5883. }
  5884. return *v, true
  5885. }
  5886. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  5887. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5888. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5889. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  5890. if !m.op.Is(OpUpdateOne) {
  5891. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  5892. }
  5893. if m.id == nil || m.oldValue == nil {
  5894. return v, errors.New("OldMsg requires an ID field in the mutation")
  5895. }
  5896. oldValue, err := m.oldValue(ctx)
  5897. if err != nil {
  5898. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  5899. }
  5900. return oldValue.Msg, nil
  5901. }
  5902. // ClearMsg clears the value of the "msg" field.
  5903. func (m *BatchMsgMutation) ClearMsg() {
  5904. m.msg = nil
  5905. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  5906. }
  5907. // MsgCleared returns if the "msg" field was cleared in this mutation.
  5908. func (m *BatchMsgMutation) MsgCleared() bool {
  5909. _, ok := m.clearedFields[batchmsg.FieldMsg]
  5910. return ok
  5911. }
  5912. // ResetMsg resets all changes to the "msg" field.
  5913. func (m *BatchMsgMutation) ResetMsg() {
  5914. m.msg = nil
  5915. delete(m.clearedFields, batchmsg.FieldMsg)
  5916. }
  5917. // SetTag sets the "tag" field.
  5918. func (m *BatchMsgMutation) SetTag(s string) {
  5919. m.tag = &s
  5920. }
  5921. // Tag returns the value of the "tag" field in the mutation.
  5922. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  5923. v := m.tag
  5924. if v == nil {
  5925. return
  5926. }
  5927. return *v, true
  5928. }
  5929. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  5930. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5931. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5932. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  5933. if !m.op.Is(OpUpdateOne) {
  5934. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  5935. }
  5936. if m.id == nil || m.oldValue == nil {
  5937. return v, errors.New("OldTag requires an ID field in the mutation")
  5938. }
  5939. oldValue, err := m.oldValue(ctx)
  5940. if err != nil {
  5941. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  5942. }
  5943. return oldValue.Tag, nil
  5944. }
  5945. // ClearTag clears the value of the "tag" field.
  5946. func (m *BatchMsgMutation) ClearTag() {
  5947. m.tag = nil
  5948. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  5949. }
  5950. // TagCleared returns if the "tag" field was cleared in this mutation.
  5951. func (m *BatchMsgMutation) TagCleared() bool {
  5952. _, ok := m.clearedFields[batchmsg.FieldTag]
  5953. return ok
  5954. }
  5955. // ResetTag resets all changes to the "tag" field.
  5956. func (m *BatchMsgMutation) ResetTag() {
  5957. m.tag = nil
  5958. delete(m.clearedFields, batchmsg.FieldTag)
  5959. }
  5960. // SetTagids sets the "tagids" field.
  5961. func (m *BatchMsgMutation) SetTagids(s string) {
  5962. m.tagids = &s
  5963. }
  5964. // Tagids returns the value of the "tagids" field in the mutation.
  5965. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  5966. v := m.tagids
  5967. if v == nil {
  5968. return
  5969. }
  5970. return *v, true
  5971. }
  5972. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  5973. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5974. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5975. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  5976. if !m.op.Is(OpUpdateOne) {
  5977. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  5978. }
  5979. if m.id == nil || m.oldValue == nil {
  5980. return v, errors.New("OldTagids requires an ID field in the mutation")
  5981. }
  5982. oldValue, err := m.oldValue(ctx)
  5983. if err != nil {
  5984. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  5985. }
  5986. return oldValue.Tagids, nil
  5987. }
  5988. // ClearTagids clears the value of the "tagids" field.
  5989. func (m *BatchMsgMutation) ClearTagids() {
  5990. m.tagids = nil
  5991. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  5992. }
  5993. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  5994. func (m *BatchMsgMutation) TagidsCleared() bool {
  5995. _, ok := m.clearedFields[batchmsg.FieldTagids]
  5996. return ok
  5997. }
  5998. // ResetTagids resets all changes to the "tagids" field.
  5999. func (m *BatchMsgMutation) ResetTagids() {
  6000. m.tagids = nil
  6001. delete(m.clearedFields, batchmsg.FieldTagids)
  6002. }
  6003. // SetTotal sets the "total" field.
  6004. func (m *BatchMsgMutation) SetTotal(i int32) {
  6005. m.total = &i
  6006. m.addtotal = nil
  6007. }
  6008. // Total returns the value of the "total" field in the mutation.
  6009. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  6010. v := m.total
  6011. if v == nil {
  6012. return
  6013. }
  6014. return *v, true
  6015. }
  6016. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  6017. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6018. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6019. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  6020. if !m.op.Is(OpUpdateOne) {
  6021. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  6022. }
  6023. if m.id == nil || m.oldValue == nil {
  6024. return v, errors.New("OldTotal requires an ID field in the mutation")
  6025. }
  6026. oldValue, err := m.oldValue(ctx)
  6027. if err != nil {
  6028. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  6029. }
  6030. return oldValue.Total, nil
  6031. }
  6032. // AddTotal adds i to the "total" field.
  6033. func (m *BatchMsgMutation) AddTotal(i int32) {
  6034. if m.addtotal != nil {
  6035. *m.addtotal += i
  6036. } else {
  6037. m.addtotal = &i
  6038. }
  6039. }
  6040. // AddedTotal returns the value that was added to the "total" field in this mutation.
  6041. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  6042. v := m.addtotal
  6043. if v == nil {
  6044. return
  6045. }
  6046. return *v, true
  6047. }
  6048. // ClearTotal clears the value of the "total" field.
  6049. func (m *BatchMsgMutation) ClearTotal() {
  6050. m.total = nil
  6051. m.addtotal = nil
  6052. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  6053. }
  6054. // TotalCleared returns if the "total" field was cleared in this mutation.
  6055. func (m *BatchMsgMutation) TotalCleared() bool {
  6056. _, ok := m.clearedFields[batchmsg.FieldTotal]
  6057. return ok
  6058. }
  6059. // ResetTotal resets all changes to the "total" field.
  6060. func (m *BatchMsgMutation) ResetTotal() {
  6061. m.total = nil
  6062. m.addtotal = nil
  6063. delete(m.clearedFields, batchmsg.FieldTotal)
  6064. }
  6065. // SetSuccess sets the "success" field.
  6066. func (m *BatchMsgMutation) SetSuccess(i int32) {
  6067. m.success = &i
  6068. m.addsuccess = nil
  6069. }
  6070. // Success returns the value of the "success" field in the mutation.
  6071. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  6072. v := m.success
  6073. if v == nil {
  6074. return
  6075. }
  6076. return *v, true
  6077. }
  6078. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  6079. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6080. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6081. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  6082. if !m.op.Is(OpUpdateOne) {
  6083. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  6084. }
  6085. if m.id == nil || m.oldValue == nil {
  6086. return v, errors.New("OldSuccess requires an ID field in the mutation")
  6087. }
  6088. oldValue, err := m.oldValue(ctx)
  6089. if err != nil {
  6090. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  6091. }
  6092. return oldValue.Success, nil
  6093. }
  6094. // AddSuccess adds i to the "success" field.
  6095. func (m *BatchMsgMutation) AddSuccess(i int32) {
  6096. if m.addsuccess != nil {
  6097. *m.addsuccess += i
  6098. } else {
  6099. m.addsuccess = &i
  6100. }
  6101. }
  6102. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  6103. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  6104. v := m.addsuccess
  6105. if v == nil {
  6106. return
  6107. }
  6108. return *v, true
  6109. }
  6110. // ClearSuccess clears the value of the "success" field.
  6111. func (m *BatchMsgMutation) ClearSuccess() {
  6112. m.success = nil
  6113. m.addsuccess = nil
  6114. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  6115. }
  6116. // SuccessCleared returns if the "success" field was cleared in this mutation.
  6117. func (m *BatchMsgMutation) SuccessCleared() bool {
  6118. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  6119. return ok
  6120. }
  6121. // ResetSuccess resets all changes to the "success" field.
  6122. func (m *BatchMsgMutation) ResetSuccess() {
  6123. m.success = nil
  6124. m.addsuccess = nil
  6125. delete(m.clearedFields, batchmsg.FieldSuccess)
  6126. }
  6127. // SetFail sets the "fail" field.
  6128. func (m *BatchMsgMutation) SetFail(i int32) {
  6129. m.fail = &i
  6130. m.addfail = nil
  6131. }
  6132. // Fail returns the value of the "fail" field in the mutation.
  6133. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  6134. v := m.fail
  6135. if v == nil {
  6136. return
  6137. }
  6138. return *v, true
  6139. }
  6140. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  6141. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6142. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6143. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  6144. if !m.op.Is(OpUpdateOne) {
  6145. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  6146. }
  6147. if m.id == nil || m.oldValue == nil {
  6148. return v, errors.New("OldFail requires an ID field in the mutation")
  6149. }
  6150. oldValue, err := m.oldValue(ctx)
  6151. if err != nil {
  6152. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  6153. }
  6154. return oldValue.Fail, nil
  6155. }
  6156. // AddFail adds i to the "fail" field.
  6157. func (m *BatchMsgMutation) AddFail(i int32) {
  6158. if m.addfail != nil {
  6159. *m.addfail += i
  6160. } else {
  6161. m.addfail = &i
  6162. }
  6163. }
  6164. // AddedFail returns the value that was added to the "fail" field in this mutation.
  6165. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  6166. v := m.addfail
  6167. if v == nil {
  6168. return
  6169. }
  6170. return *v, true
  6171. }
  6172. // ClearFail clears the value of the "fail" field.
  6173. func (m *BatchMsgMutation) ClearFail() {
  6174. m.fail = nil
  6175. m.addfail = nil
  6176. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  6177. }
  6178. // FailCleared returns if the "fail" field was cleared in this mutation.
  6179. func (m *BatchMsgMutation) FailCleared() bool {
  6180. _, ok := m.clearedFields[batchmsg.FieldFail]
  6181. return ok
  6182. }
  6183. // ResetFail resets all changes to the "fail" field.
  6184. func (m *BatchMsgMutation) ResetFail() {
  6185. m.fail = nil
  6186. m.addfail = nil
  6187. delete(m.clearedFields, batchmsg.FieldFail)
  6188. }
  6189. // SetStartTime sets the "start_time" field.
  6190. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  6191. m.start_time = &t
  6192. }
  6193. // StartTime returns the value of the "start_time" field in the mutation.
  6194. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  6195. v := m.start_time
  6196. if v == nil {
  6197. return
  6198. }
  6199. return *v, true
  6200. }
  6201. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  6202. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6203. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6204. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  6205. if !m.op.Is(OpUpdateOne) {
  6206. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  6207. }
  6208. if m.id == nil || m.oldValue == nil {
  6209. return v, errors.New("OldStartTime requires an ID field in the mutation")
  6210. }
  6211. oldValue, err := m.oldValue(ctx)
  6212. if err != nil {
  6213. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  6214. }
  6215. return oldValue.StartTime, nil
  6216. }
  6217. // ClearStartTime clears the value of the "start_time" field.
  6218. func (m *BatchMsgMutation) ClearStartTime() {
  6219. m.start_time = nil
  6220. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  6221. }
  6222. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  6223. func (m *BatchMsgMutation) StartTimeCleared() bool {
  6224. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  6225. return ok
  6226. }
  6227. // ResetStartTime resets all changes to the "start_time" field.
  6228. func (m *BatchMsgMutation) ResetStartTime() {
  6229. m.start_time = nil
  6230. delete(m.clearedFields, batchmsg.FieldStartTime)
  6231. }
  6232. // SetStopTime sets the "stop_time" field.
  6233. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  6234. m.stop_time = &t
  6235. }
  6236. // StopTime returns the value of the "stop_time" field in the mutation.
  6237. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  6238. v := m.stop_time
  6239. if v == nil {
  6240. return
  6241. }
  6242. return *v, true
  6243. }
  6244. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  6245. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6246. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6247. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  6248. if !m.op.Is(OpUpdateOne) {
  6249. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  6250. }
  6251. if m.id == nil || m.oldValue == nil {
  6252. return v, errors.New("OldStopTime requires an ID field in the mutation")
  6253. }
  6254. oldValue, err := m.oldValue(ctx)
  6255. if err != nil {
  6256. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  6257. }
  6258. return oldValue.StopTime, nil
  6259. }
  6260. // ClearStopTime clears the value of the "stop_time" field.
  6261. func (m *BatchMsgMutation) ClearStopTime() {
  6262. m.stop_time = nil
  6263. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  6264. }
  6265. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  6266. func (m *BatchMsgMutation) StopTimeCleared() bool {
  6267. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  6268. return ok
  6269. }
  6270. // ResetStopTime resets all changes to the "stop_time" field.
  6271. func (m *BatchMsgMutation) ResetStopTime() {
  6272. m.stop_time = nil
  6273. delete(m.clearedFields, batchmsg.FieldStopTime)
  6274. }
  6275. // SetSendTime sets the "send_time" field.
  6276. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  6277. m.send_time = &t
  6278. }
  6279. // SendTime returns the value of the "send_time" field in the mutation.
  6280. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  6281. v := m.send_time
  6282. if v == nil {
  6283. return
  6284. }
  6285. return *v, true
  6286. }
  6287. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  6288. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6289. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6290. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  6291. if !m.op.Is(OpUpdateOne) {
  6292. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  6293. }
  6294. if m.id == nil || m.oldValue == nil {
  6295. return v, errors.New("OldSendTime requires an ID field in the mutation")
  6296. }
  6297. oldValue, err := m.oldValue(ctx)
  6298. if err != nil {
  6299. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  6300. }
  6301. return oldValue.SendTime, nil
  6302. }
  6303. // ClearSendTime clears the value of the "send_time" field.
  6304. func (m *BatchMsgMutation) ClearSendTime() {
  6305. m.send_time = nil
  6306. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  6307. }
  6308. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  6309. func (m *BatchMsgMutation) SendTimeCleared() bool {
  6310. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  6311. return ok
  6312. }
  6313. // ResetSendTime resets all changes to the "send_time" field.
  6314. func (m *BatchMsgMutation) ResetSendTime() {
  6315. m.send_time = nil
  6316. delete(m.clearedFields, batchmsg.FieldSendTime)
  6317. }
  6318. // SetType sets the "type" field.
  6319. func (m *BatchMsgMutation) SetType(i int32) {
  6320. m._type = &i
  6321. m.add_type = nil
  6322. }
  6323. // GetType returns the value of the "type" field in the mutation.
  6324. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  6325. v := m._type
  6326. if v == nil {
  6327. return
  6328. }
  6329. return *v, true
  6330. }
  6331. // OldType returns the old "type" field's value of the BatchMsg entity.
  6332. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6333. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6334. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  6335. if !m.op.Is(OpUpdateOne) {
  6336. return v, errors.New("OldType is only allowed on UpdateOne operations")
  6337. }
  6338. if m.id == nil || m.oldValue == nil {
  6339. return v, errors.New("OldType requires an ID field in the mutation")
  6340. }
  6341. oldValue, err := m.oldValue(ctx)
  6342. if err != nil {
  6343. return v, fmt.Errorf("querying old value for OldType: %w", err)
  6344. }
  6345. return oldValue.Type, nil
  6346. }
  6347. // AddType adds i to the "type" field.
  6348. func (m *BatchMsgMutation) AddType(i int32) {
  6349. if m.add_type != nil {
  6350. *m.add_type += i
  6351. } else {
  6352. m.add_type = &i
  6353. }
  6354. }
  6355. // AddedType returns the value that was added to the "type" field in this mutation.
  6356. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  6357. v := m.add_type
  6358. if v == nil {
  6359. return
  6360. }
  6361. return *v, true
  6362. }
  6363. // ClearType clears the value of the "type" field.
  6364. func (m *BatchMsgMutation) ClearType() {
  6365. m._type = nil
  6366. m.add_type = nil
  6367. m.clearedFields[batchmsg.FieldType] = struct{}{}
  6368. }
  6369. // TypeCleared returns if the "type" field was cleared in this mutation.
  6370. func (m *BatchMsgMutation) TypeCleared() bool {
  6371. _, ok := m.clearedFields[batchmsg.FieldType]
  6372. return ok
  6373. }
  6374. // ResetType resets all changes to the "type" field.
  6375. func (m *BatchMsgMutation) ResetType() {
  6376. m._type = nil
  6377. m.add_type = nil
  6378. delete(m.clearedFields, batchmsg.FieldType)
  6379. }
  6380. // SetOrganizationID sets the "organization_id" field.
  6381. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  6382. m.organization_id = &u
  6383. m.addorganization_id = nil
  6384. }
  6385. // OrganizationID returns the value of the "organization_id" field in the mutation.
  6386. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  6387. v := m.organization_id
  6388. if v == nil {
  6389. return
  6390. }
  6391. return *v, true
  6392. }
  6393. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  6394. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6395. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6396. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  6397. if !m.op.Is(OpUpdateOne) {
  6398. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  6399. }
  6400. if m.id == nil || m.oldValue == nil {
  6401. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  6402. }
  6403. oldValue, err := m.oldValue(ctx)
  6404. if err != nil {
  6405. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6406. }
  6407. return oldValue.OrganizationID, nil
  6408. }
  6409. // AddOrganizationID adds u to the "organization_id" field.
  6410. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  6411. if m.addorganization_id != nil {
  6412. *m.addorganization_id += u
  6413. } else {
  6414. m.addorganization_id = &u
  6415. }
  6416. }
  6417. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6418. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  6419. v := m.addorganization_id
  6420. if v == nil {
  6421. return
  6422. }
  6423. return *v, true
  6424. }
  6425. // ResetOrganizationID resets all changes to the "organization_id" field.
  6426. func (m *BatchMsgMutation) ResetOrganizationID() {
  6427. m.organization_id = nil
  6428. m.addorganization_id = nil
  6429. }
  6430. // SetCtype sets the "ctype" field.
  6431. func (m *BatchMsgMutation) SetCtype(u uint64) {
  6432. m.ctype = &u
  6433. m.addctype = nil
  6434. }
  6435. // Ctype returns the value of the "ctype" field in the mutation.
  6436. func (m *BatchMsgMutation) Ctype() (r uint64, exists bool) {
  6437. v := m.ctype
  6438. if v == nil {
  6439. return
  6440. }
  6441. return *v, true
  6442. }
  6443. // OldCtype returns the old "ctype" field's value of the BatchMsg entity.
  6444. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6445. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6446. func (m *BatchMsgMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  6447. if !m.op.Is(OpUpdateOne) {
  6448. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  6449. }
  6450. if m.id == nil || m.oldValue == nil {
  6451. return v, errors.New("OldCtype requires an ID field in the mutation")
  6452. }
  6453. oldValue, err := m.oldValue(ctx)
  6454. if err != nil {
  6455. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  6456. }
  6457. return oldValue.Ctype, nil
  6458. }
  6459. // AddCtype adds u to the "ctype" field.
  6460. func (m *BatchMsgMutation) AddCtype(u int64) {
  6461. if m.addctype != nil {
  6462. *m.addctype += u
  6463. } else {
  6464. m.addctype = &u
  6465. }
  6466. }
  6467. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  6468. func (m *BatchMsgMutation) AddedCtype() (r int64, exists bool) {
  6469. v := m.addctype
  6470. if v == nil {
  6471. return
  6472. }
  6473. return *v, true
  6474. }
  6475. // ResetCtype resets all changes to the "ctype" field.
  6476. func (m *BatchMsgMutation) ResetCtype() {
  6477. m.ctype = nil
  6478. m.addctype = nil
  6479. }
  6480. // SetCc sets the "cc" field.
  6481. func (m *BatchMsgMutation) SetCc(s string) {
  6482. m.cc = &s
  6483. }
  6484. // Cc returns the value of the "cc" field in the mutation.
  6485. func (m *BatchMsgMutation) Cc() (r string, exists bool) {
  6486. v := m.cc
  6487. if v == nil {
  6488. return
  6489. }
  6490. return *v, true
  6491. }
  6492. // OldCc returns the old "cc" field's value of the BatchMsg entity.
  6493. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6494. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6495. func (m *BatchMsgMutation) OldCc(ctx context.Context) (v string, err error) {
  6496. if !m.op.Is(OpUpdateOne) {
  6497. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  6498. }
  6499. if m.id == nil || m.oldValue == nil {
  6500. return v, errors.New("OldCc requires an ID field in the mutation")
  6501. }
  6502. oldValue, err := m.oldValue(ctx)
  6503. if err != nil {
  6504. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  6505. }
  6506. return oldValue.Cc, nil
  6507. }
  6508. // ClearCc clears the value of the "cc" field.
  6509. func (m *BatchMsgMutation) ClearCc() {
  6510. m.cc = nil
  6511. m.clearedFields[batchmsg.FieldCc] = struct{}{}
  6512. }
  6513. // CcCleared returns if the "cc" field was cleared in this mutation.
  6514. func (m *BatchMsgMutation) CcCleared() bool {
  6515. _, ok := m.clearedFields[batchmsg.FieldCc]
  6516. return ok
  6517. }
  6518. // ResetCc resets all changes to the "cc" field.
  6519. func (m *BatchMsgMutation) ResetCc() {
  6520. m.cc = nil
  6521. delete(m.clearedFields, batchmsg.FieldCc)
  6522. }
  6523. // SetPhone sets the "phone" field.
  6524. func (m *BatchMsgMutation) SetPhone(s string) {
  6525. m.phone = &s
  6526. }
  6527. // Phone returns the value of the "phone" field in the mutation.
  6528. func (m *BatchMsgMutation) Phone() (r string, exists bool) {
  6529. v := m.phone
  6530. if v == nil {
  6531. return
  6532. }
  6533. return *v, true
  6534. }
  6535. // OldPhone returns the old "phone" field's value of the BatchMsg entity.
  6536. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6537. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6538. func (m *BatchMsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  6539. if !m.op.Is(OpUpdateOne) {
  6540. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  6541. }
  6542. if m.id == nil || m.oldValue == nil {
  6543. return v, errors.New("OldPhone requires an ID field in the mutation")
  6544. }
  6545. oldValue, err := m.oldValue(ctx)
  6546. if err != nil {
  6547. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  6548. }
  6549. return oldValue.Phone, nil
  6550. }
  6551. // ClearPhone clears the value of the "phone" field.
  6552. func (m *BatchMsgMutation) ClearPhone() {
  6553. m.phone = nil
  6554. m.clearedFields[batchmsg.FieldPhone] = struct{}{}
  6555. }
  6556. // PhoneCleared returns if the "phone" field was cleared in this mutation.
  6557. func (m *BatchMsgMutation) PhoneCleared() bool {
  6558. _, ok := m.clearedFields[batchmsg.FieldPhone]
  6559. return ok
  6560. }
  6561. // ResetPhone resets all changes to the "phone" field.
  6562. func (m *BatchMsgMutation) ResetPhone() {
  6563. m.phone = nil
  6564. delete(m.clearedFields, batchmsg.FieldPhone)
  6565. }
  6566. // SetTemplateName sets the "template_name" field.
  6567. func (m *BatchMsgMutation) SetTemplateName(s string) {
  6568. m.template_name = &s
  6569. }
  6570. // TemplateName returns the value of the "template_name" field in the mutation.
  6571. func (m *BatchMsgMutation) TemplateName() (r string, exists bool) {
  6572. v := m.template_name
  6573. if v == nil {
  6574. return
  6575. }
  6576. return *v, true
  6577. }
  6578. // OldTemplateName returns the old "template_name" field's value of the BatchMsg entity.
  6579. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6580. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6581. func (m *BatchMsgMutation) OldTemplateName(ctx context.Context) (v string, err error) {
  6582. if !m.op.Is(OpUpdateOne) {
  6583. return v, errors.New("OldTemplateName is only allowed on UpdateOne operations")
  6584. }
  6585. if m.id == nil || m.oldValue == nil {
  6586. return v, errors.New("OldTemplateName requires an ID field in the mutation")
  6587. }
  6588. oldValue, err := m.oldValue(ctx)
  6589. if err != nil {
  6590. return v, fmt.Errorf("querying old value for OldTemplateName: %w", err)
  6591. }
  6592. return oldValue.TemplateName, nil
  6593. }
  6594. // ClearTemplateName clears the value of the "template_name" field.
  6595. func (m *BatchMsgMutation) ClearTemplateName() {
  6596. m.template_name = nil
  6597. m.clearedFields[batchmsg.FieldTemplateName] = struct{}{}
  6598. }
  6599. // TemplateNameCleared returns if the "template_name" field was cleared in this mutation.
  6600. func (m *BatchMsgMutation) TemplateNameCleared() bool {
  6601. _, ok := m.clearedFields[batchmsg.FieldTemplateName]
  6602. return ok
  6603. }
  6604. // ResetTemplateName resets all changes to the "template_name" field.
  6605. func (m *BatchMsgMutation) ResetTemplateName() {
  6606. m.template_name = nil
  6607. delete(m.clearedFields, batchmsg.FieldTemplateName)
  6608. }
  6609. // SetTemplateCode sets the "template_code" field.
  6610. func (m *BatchMsgMutation) SetTemplateCode(s string) {
  6611. m.template_code = &s
  6612. }
  6613. // TemplateCode returns the value of the "template_code" field in the mutation.
  6614. func (m *BatchMsgMutation) TemplateCode() (r string, exists bool) {
  6615. v := m.template_code
  6616. if v == nil {
  6617. return
  6618. }
  6619. return *v, true
  6620. }
  6621. // OldTemplateCode returns the old "template_code" field's value of the BatchMsg entity.
  6622. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6623. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6624. func (m *BatchMsgMutation) OldTemplateCode(ctx context.Context) (v string, err error) {
  6625. if !m.op.Is(OpUpdateOne) {
  6626. return v, errors.New("OldTemplateCode is only allowed on UpdateOne operations")
  6627. }
  6628. if m.id == nil || m.oldValue == nil {
  6629. return v, errors.New("OldTemplateCode requires an ID field in the mutation")
  6630. }
  6631. oldValue, err := m.oldValue(ctx)
  6632. if err != nil {
  6633. return v, fmt.Errorf("querying old value for OldTemplateCode: %w", err)
  6634. }
  6635. return oldValue.TemplateCode, nil
  6636. }
  6637. // ClearTemplateCode clears the value of the "template_code" field.
  6638. func (m *BatchMsgMutation) ClearTemplateCode() {
  6639. m.template_code = nil
  6640. m.clearedFields[batchmsg.FieldTemplateCode] = struct{}{}
  6641. }
  6642. // TemplateCodeCleared returns if the "template_code" field was cleared in this mutation.
  6643. func (m *BatchMsgMutation) TemplateCodeCleared() bool {
  6644. _, ok := m.clearedFields[batchmsg.FieldTemplateCode]
  6645. return ok
  6646. }
  6647. // ResetTemplateCode resets all changes to the "template_code" field.
  6648. func (m *BatchMsgMutation) ResetTemplateCode() {
  6649. m.template_code = nil
  6650. delete(m.clearedFields, batchmsg.FieldTemplateCode)
  6651. }
  6652. // SetLang sets the "lang" field.
  6653. func (m *BatchMsgMutation) SetLang(s string) {
  6654. m.lang = &s
  6655. }
  6656. // Lang returns the value of the "lang" field in the mutation.
  6657. func (m *BatchMsgMutation) Lang() (r string, exists bool) {
  6658. v := m.lang
  6659. if v == nil {
  6660. return
  6661. }
  6662. return *v, true
  6663. }
  6664. // OldLang returns the old "lang" field's value of the BatchMsg entity.
  6665. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6666. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6667. func (m *BatchMsgMutation) OldLang(ctx context.Context) (v string, err error) {
  6668. if !m.op.Is(OpUpdateOne) {
  6669. return v, errors.New("OldLang is only allowed on UpdateOne operations")
  6670. }
  6671. if m.id == nil || m.oldValue == nil {
  6672. return v, errors.New("OldLang requires an ID field in the mutation")
  6673. }
  6674. oldValue, err := m.oldValue(ctx)
  6675. if err != nil {
  6676. return v, fmt.Errorf("querying old value for OldLang: %w", err)
  6677. }
  6678. return oldValue.Lang, nil
  6679. }
  6680. // ClearLang clears the value of the "lang" field.
  6681. func (m *BatchMsgMutation) ClearLang() {
  6682. m.lang = nil
  6683. m.clearedFields[batchmsg.FieldLang] = struct{}{}
  6684. }
  6685. // LangCleared returns if the "lang" field was cleared in this mutation.
  6686. func (m *BatchMsgMutation) LangCleared() bool {
  6687. _, ok := m.clearedFields[batchmsg.FieldLang]
  6688. return ok
  6689. }
  6690. // ResetLang resets all changes to the "lang" field.
  6691. func (m *BatchMsgMutation) ResetLang() {
  6692. m.lang = nil
  6693. delete(m.clearedFields, batchmsg.FieldLang)
  6694. }
  6695. // Where appends a list predicates to the BatchMsgMutation builder.
  6696. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  6697. m.predicates = append(m.predicates, ps...)
  6698. }
  6699. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  6700. // users can use type-assertion to append predicates that do not depend on any generated package.
  6701. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  6702. p := make([]predicate.BatchMsg, len(ps))
  6703. for i := range ps {
  6704. p[i] = ps[i]
  6705. }
  6706. m.Where(p...)
  6707. }
  6708. // Op returns the operation name.
  6709. func (m *BatchMsgMutation) Op() Op {
  6710. return m.op
  6711. }
  6712. // SetOp allows setting the mutation operation.
  6713. func (m *BatchMsgMutation) SetOp(op Op) {
  6714. m.op = op
  6715. }
  6716. // Type returns the node type of this mutation (BatchMsg).
  6717. func (m *BatchMsgMutation) Type() string {
  6718. return m.typ
  6719. }
  6720. // Fields returns all fields that were changed during this mutation. Note that in
  6721. // order to get all numeric fields that were incremented/decremented, call
  6722. // AddedFields().
  6723. func (m *BatchMsgMutation) Fields() []string {
  6724. fields := make([]string, 0, 24)
  6725. if m.created_at != nil {
  6726. fields = append(fields, batchmsg.FieldCreatedAt)
  6727. }
  6728. if m.updated_at != nil {
  6729. fields = append(fields, batchmsg.FieldUpdatedAt)
  6730. }
  6731. if m.deleted_at != nil {
  6732. fields = append(fields, batchmsg.FieldDeletedAt)
  6733. }
  6734. if m.status != nil {
  6735. fields = append(fields, batchmsg.FieldStatus)
  6736. }
  6737. if m.batch_no != nil {
  6738. fields = append(fields, batchmsg.FieldBatchNo)
  6739. }
  6740. if m.task_name != nil {
  6741. fields = append(fields, batchmsg.FieldTaskName)
  6742. }
  6743. if m.fromwxid != nil {
  6744. fields = append(fields, batchmsg.FieldFromwxid)
  6745. }
  6746. if m.msg != nil {
  6747. fields = append(fields, batchmsg.FieldMsg)
  6748. }
  6749. if m.tag != nil {
  6750. fields = append(fields, batchmsg.FieldTag)
  6751. }
  6752. if m.tagids != nil {
  6753. fields = append(fields, batchmsg.FieldTagids)
  6754. }
  6755. if m.total != nil {
  6756. fields = append(fields, batchmsg.FieldTotal)
  6757. }
  6758. if m.success != nil {
  6759. fields = append(fields, batchmsg.FieldSuccess)
  6760. }
  6761. if m.fail != nil {
  6762. fields = append(fields, batchmsg.FieldFail)
  6763. }
  6764. if m.start_time != nil {
  6765. fields = append(fields, batchmsg.FieldStartTime)
  6766. }
  6767. if m.stop_time != nil {
  6768. fields = append(fields, batchmsg.FieldStopTime)
  6769. }
  6770. if m.send_time != nil {
  6771. fields = append(fields, batchmsg.FieldSendTime)
  6772. }
  6773. if m._type != nil {
  6774. fields = append(fields, batchmsg.FieldType)
  6775. }
  6776. if m.organization_id != nil {
  6777. fields = append(fields, batchmsg.FieldOrganizationID)
  6778. }
  6779. if m.ctype != nil {
  6780. fields = append(fields, batchmsg.FieldCtype)
  6781. }
  6782. if m.cc != nil {
  6783. fields = append(fields, batchmsg.FieldCc)
  6784. }
  6785. if m.phone != nil {
  6786. fields = append(fields, batchmsg.FieldPhone)
  6787. }
  6788. if m.template_name != nil {
  6789. fields = append(fields, batchmsg.FieldTemplateName)
  6790. }
  6791. if m.template_code != nil {
  6792. fields = append(fields, batchmsg.FieldTemplateCode)
  6793. }
  6794. if m.lang != nil {
  6795. fields = append(fields, batchmsg.FieldLang)
  6796. }
  6797. return fields
  6798. }
  6799. // Field returns the value of a field with the given name. The second boolean
  6800. // return value indicates that this field was not set, or was not defined in the
  6801. // schema.
  6802. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  6803. switch name {
  6804. case batchmsg.FieldCreatedAt:
  6805. return m.CreatedAt()
  6806. case batchmsg.FieldUpdatedAt:
  6807. return m.UpdatedAt()
  6808. case batchmsg.FieldDeletedAt:
  6809. return m.DeletedAt()
  6810. case batchmsg.FieldStatus:
  6811. return m.Status()
  6812. case batchmsg.FieldBatchNo:
  6813. return m.BatchNo()
  6814. case batchmsg.FieldTaskName:
  6815. return m.TaskName()
  6816. case batchmsg.FieldFromwxid:
  6817. return m.Fromwxid()
  6818. case batchmsg.FieldMsg:
  6819. return m.Msg()
  6820. case batchmsg.FieldTag:
  6821. return m.Tag()
  6822. case batchmsg.FieldTagids:
  6823. return m.Tagids()
  6824. case batchmsg.FieldTotal:
  6825. return m.Total()
  6826. case batchmsg.FieldSuccess:
  6827. return m.Success()
  6828. case batchmsg.FieldFail:
  6829. return m.Fail()
  6830. case batchmsg.FieldStartTime:
  6831. return m.StartTime()
  6832. case batchmsg.FieldStopTime:
  6833. return m.StopTime()
  6834. case batchmsg.FieldSendTime:
  6835. return m.SendTime()
  6836. case batchmsg.FieldType:
  6837. return m.GetType()
  6838. case batchmsg.FieldOrganizationID:
  6839. return m.OrganizationID()
  6840. case batchmsg.FieldCtype:
  6841. return m.Ctype()
  6842. case batchmsg.FieldCc:
  6843. return m.Cc()
  6844. case batchmsg.FieldPhone:
  6845. return m.Phone()
  6846. case batchmsg.FieldTemplateName:
  6847. return m.TemplateName()
  6848. case batchmsg.FieldTemplateCode:
  6849. return m.TemplateCode()
  6850. case batchmsg.FieldLang:
  6851. return m.Lang()
  6852. }
  6853. return nil, false
  6854. }
  6855. // OldField returns the old value of the field from the database. An error is
  6856. // returned if the mutation operation is not UpdateOne, or the query to the
  6857. // database failed.
  6858. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6859. switch name {
  6860. case batchmsg.FieldCreatedAt:
  6861. return m.OldCreatedAt(ctx)
  6862. case batchmsg.FieldUpdatedAt:
  6863. return m.OldUpdatedAt(ctx)
  6864. case batchmsg.FieldDeletedAt:
  6865. return m.OldDeletedAt(ctx)
  6866. case batchmsg.FieldStatus:
  6867. return m.OldStatus(ctx)
  6868. case batchmsg.FieldBatchNo:
  6869. return m.OldBatchNo(ctx)
  6870. case batchmsg.FieldTaskName:
  6871. return m.OldTaskName(ctx)
  6872. case batchmsg.FieldFromwxid:
  6873. return m.OldFromwxid(ctx)
  6874. case batchmsg.FieldMsg:
  6875. return m.OldMsg(ctx)
  6876. case batchmsg.FieldTag:
  6877. return m.OldTag(ctx)
  6878. case batchmsg.FieldTagids:
  6879. return m.OldTagids(ctx)
  6880. case batchmsg.FieldTotal:
  6881. return m.OldTotal(ctx)
  6882. case batchmsg.FieldSuccess:
  6883. return m.OldSuccess(ctx)
  6884. case batchmsg.FieldFail:
  6885. return m.OldFail(ctx)
  6886. case batchmsg.FieldStartTime:
  6887. return m.OldStartTime(ctx)
  6888. case batchmsg.FieldStopTime:
  6889. return m.OldStopTime(ctx)
  6890. case batchmsg.FieldSendTime:
  6891. return m.OldSendTime(ctx)
  6892. case batchmsg.FieldType:
  6893. return m.OldType(ctx)
  6894. case batchmsg.FieldOrganizationID:
  6895. return m.OldOrganizationID(ctx)
  6896. case batchmsg.FieldCtype:
  6897. return m.OldCtype(ctx)
  6898. case batchmsg.FieldCc:
  6899. return m.OldCc(ctx)
  6900. case batchmsg.FieldPhone:
  6901. return m.OldPhone(ctx)
  6902. case batchmsg.FieldTemplateName:
  6903. return m.OldTemplateName(ctx)
  6904. case batchmsg.FieldTemplateCode:
  6905. return m.OldTemplateCode(ctx)
  6906. case batchmsg.FieldLang:
  6907. return m.OldLang(ctx)
  6908. }
  6909. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  6910. }
  6911. // SetField sets the value of a field with the given name. It returns an error if
  6912. // the field is not defined in the schema, or if the type mismatched the field
  6913. // type.
  6914. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  6915. switch name {
  6916. case batchmsg.FieldCreatedAt:
  6917. v, ok := value.(time.Time)
  6918. if !ok {
  6919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6920. }
  6921. m.SetCreatedAt(v)
  6922. return nil
  6923. case batchmsg.FieldUpdatedAt:
  6924. v, ok := value.(time.Time)
  6925. if !ok {
  6926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6927. }
  6928. m.SetUpdatedAt(v)
  6929. return nil
  6930. case batchmsg.FieldDeletedAt:
  6931. v, ok := value.(time.Time)
  6932. if !ok {
  6933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6934. }
  6935. m.SetDeletedAt(v)
  6936. return nil
  6937. case batchmsg.FieldStatus:
  6938. v, ok := value.(uint8)
  6939. if !ok {
  6940. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6941. }
  6942. m.SetStatus(v)
  6943. return nil
  6944. case batchmsg.FieldBatchNo:
  6945. v, ok := value.(string)
  6946. if !ok {
  6947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6948. }
  6949. m.SetBatchNo(v)
  6950. return nil
  6951. case batchmsg.FieldTaskName:
  6952. v, ok := value.(string)
  6953. if !ok {
  6954. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6955. }
  6956. m.SetTaskName(v)
  6957. return nil
  6958. case batchmsg.FieldFromwxid:
  6959. v, ok := value.(string)
  6960. if !ok {
  6961. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6962. }
  6963. m.SetFromwxid(v)
  6964. return nil
  6965. case batchmsg.FieldMsg:
  6966. v, ok := value.(string)
  6967. if !ok {
  6968. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6969. }
  6970. m.SetMsg(v)
  6971. return nil
  6972. case batchmsg.FieldTag:
  6973. v, ok := value.(string)
  6974. if !ok {
  6975. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6976. }
  6977. m.SetTag(v)
  6978. return nil
  6979. case batchmsg.FieldTagids:
  6980. v, ok := value.(string)
  6981. if !ok {
  6982. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6983. }
  6984. m.SetTagids(v)
  6985. return nil
  6986. case batchmsg.FieldTotal:
  6987. v, ok := value.(int32)
  6988. if !ok {
  6989. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6990. }
  6991. m.SetTotal(v)
  6992. return nil
  6993. case batchmsg.FieldSuccess:
  6994. v, ok := value.(int32)
  6995. if !ok {
  6996. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6997. }
  6998. m.SetSuccess(v)
  6999. return nil
  7000. case batchmsg.FieldFail:
  7001. v, ok := value.(int32)
  7002. if !ok {
  7003. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7004. }
  7005. m.SetFail(v)
  7006. return nil
  7007. case batchmsg.FieldStartTime:
  7008. v, ok := value.(time.Time)
  7009. if !ok {
  7010. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7011. }
  7012. m.SetStartTime(v)
  7013. return nil
  7014. case batchmsg.FieldStopTime:
  7015. v, ok := value.(time.Time)
  7016. if !ok {
  7017. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7018. }
  7019. m.SetStopTime(v)
  7020. return nil
  7021. case batchmsg.FieldSendTime:
  7022. v, ok := value.(time.Time)
  7023. if !ok {
  7024. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7025. }
  7026. m.SetSendTime(v)
  7027. return nil
  7028. case batchmsg.FieldType:
  7029. v, ok := value.(int32)
  7030. if !ok {
  7031. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7032. }
  7033. m.SetType(v)
  7034. return nil
  7035. case batchmsg.FieldOrganizationID:
  7036. v, ok := value.(uint64)
  7037. if !ok {
  7038. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7039. }
  7040. m.SetOrganizationID(v)
  7041. return nil
  7042. case batchmsg.FieldCtype:
  7043. v, ok := value.(uint64)
  7044. if !ok {
  7045. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7046. }
  7047. m.SetCtype(v)
  7048. return nil
  7049. case batchmsg.FieldCc:
  7050. v, ok := value.(string)
  7051. if !ok {
  7052. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7053. }
  7054. m.SetCc(v)
  7055. return nil
  7056. case batchmsg.FieldPhone:
  7057. v, ok := value.(string)
  7058. if !ok {
  7059. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7060. }
  7061. m.SetPhone(v)
  7062. return nil
  7063. case batchmsg.FieldTemplateName:
  7064. v, ok := value.(string)
  7065. if !ok {
  7066. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7067. }
  7068. m.SetTemplateName(v)
  7069. return nil
  7070. case batchmsg.FieldTemplateCode:
  7071. v, ok := value.(string)
  7072. if !ok {
  7073. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7074. }
  7075. m.SetTemplateCode(v)
  7076. return nil
  7077. case batchmsg.FieldLang:
  7078. v, ok := value.(string)
  7079. if !ok {
  7080. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7081. }
  7082. m.SetLang(v)
  7083. return nil
  7084. }
  7085. return fmt.Errorf("unknown BatchMsg field %s", name)
  7086. }
  7087. // AddedFields returns all numeric fields that were incremented/decremented during
  7088. // this mutation.
  7089. func (m *BatchMsgMutation) AddedFields() []string {
  7090. var fields []string
  7091. if m.addstatus != nil {
  7092. fields = append(fields, batchmsg.FieldStatus)
  7093. }
  7094. if m.addtotal != nil {
  7095. fields = append(fields, batchmsg.FieldTotal)
  7096. }
  7097. if m.addsuccess != nil {
  7098. fields = append(fields, batchmsg.FieldSuccess)
  7099. }
  7100. if m.addfail != nil {
  7101. fields = append(fields, batchmsg.FieldFail)
  7102. }
  7103. if m.add_type != nil {
  7104. fields = append(fields, batchmsg.FieldType)
  7105. }
  7106. if m.addorganization_id != nil {
  7107. fields = append(fields, batchmsg.FieldOrganizationID)
  7108. }
  7109. if m.addctype != nil {
  7110. fields = append(fields, batchmsg.FieldCtype)
  7111. }
  7112. return fields
  7113. }
  7114. // AddedField returns the numeric value that was incremented/decremented on a field
  7115. // with the given name. The second boolean return value indicates that this field
  7116. // was not set, or was not defined in the schema.
  7117. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  7118. switch name {
  7119. case batchmsg.FieldStatus:
  7120. return m.AddedStatus()
  7121. case batchmsg.FieldTotal:
  7122. return m.AddedTotal()
  7123. case batchmsg.FieldSuccess:
  7124. return m.AddedSuccess()
  7125. case batchmsg.FieldFail:
  7126. return m.AddedFail()
  7127. case batchmsg.FieldType:
  7128. return m.AddedType()
  7129. case batchmsg.FieldOrganizationID:
  7130. return m.AddedOrganizationID()
  7131. case batchmsg.FieldCtype:
  7132. return m.AddedCtype()
  7133. }
  7134. return nil, false
  7135. }
  7136. // AddField adds the value to the field with the given name. It returns an error if
  7137. // the field is not defined in the schema, or if the type mismatched the field
  7138. // type.
  7139. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  7140. switch name {
  7141. case batchmsg.FieldStatus:
  7142. v, ok := value.(int8)
  7143. if !ok {
  7144. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7145. }
  7146. m.AddStatus(v)
  7147. return nil
  7148. case batchmsg.FieldTotal:
  7149. v, ok := value.(int32)
  7150. if !ok {
  7151. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7152. }
  7153. m.AddTotal(v)
  7154. return nil
  7155. case batchmsg.FieldSuccess:
  7156. v, ok := value.(int32)
  7157. if !ok {
  7158. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7159. }
  7160. m.AddSuccess(v)
  7161. return nil
  7162. case batchmsg.FieldFail:
  7163. v, ok := value.(int32)
  7164. if !ok {
  7165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7166. }
  7167. m.AddFail(v)
  7168. return nil
  7169. case batchmsg.FieldType:
  7170. v, ok := value.(int32)
  7171. if !ok {
  7172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7173. }
  7174. m.AddType(v)
  7175. return nil
  7176. case batchmsg.FieldOrganizationID:
  7177. v, ok := value.(int64)
  7178. if !ok {
  7179. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7180. }
  7181. m.AddOrganizationID(v)
  7182. return nil
  7183. case batchmsg.FieldCtype:
  7184. v, ok := value.(int64)
  7185. if !ok {
  7186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7187. }
  7188. m.AddCtype(v)
  7189. return nil
  7190. }
  7191. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  7192. }
  7193. // ClearedFields returns all nullable fields that were cleared during this
  7194. // mutation.
  7195. func (m *BatchMsgMutation) ClearedFields() []string {
  7196. var fields []string
  7197. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  7198. fields = append(fields, batchmsg.FieldDeletedAt)
  7199. }
  7200. if m.FieldCleared(batchmsg.FieldStatus) {
  7201. fields = append(fields, batchmsg.FieldStatus)
  7202. }
  7203. if m.FieldCleared(batchmsg.FieldBatchNo) {
  7204. fields = append(fields, batchmsg.FieldBatchNo)
  7205. }
  7206. if m.FieldCleared(batchmsg.FieldTaskName) {
  7207. fields = append(fields, batchmsg.FieldTaskName)
  7208. }
  7209. if m.FieldCleared(batchmsg.FieldFromwxid) {
  7210. fields = append(fields, batchmsg.FieldFromwxid)
  7211. }
  7212. if m.FieldCleared(batchmsg.FieldMsg) {
  7213. fields = append(fields, batchmsg.FieldMsg)
  7214. }
  7215. if m.FieldCleared(batchmsg.FieldTag) {
  7216. fields = append(fields, batchmsg.FieldTag)
  7217. }
  7218. if m.FieldCleared(batchmsg.FieldTagids) {
  7219. fields = append(fields, batchmsg.FieldTagids)
  7220. }
  7221. if m.FieldCleared(batchmsg.FieldTotal) {
  7222. fields = append(fields, batchmsg.FieldTotal)
  7223. }
  7224. if m.FieldCleared(batchmsg.FieldSuccess) {
  7225. fields = append(fields, batchmsg.FieldSuccess)
  7226. }
  7227. if m.FieldCleared(batchmsg.FieldFail) {
  7228. fields = append(fields, batchmsg.FieldFail)
  7229. }
  7230. if m.FieldCleared(batchmsg.FieldStartTime) {
  7231. fields = append(fields, batchmsg.FieldStartTime)
  7232. }
  7233. if m.FieldCleared(batchmsg.FieldStopTime) {
  7234. fields = append(fields, batchmsg.FieldStopTime)
  7235. }
  7236. if m.FieldCleared(batchmsg.FieldSendTime) {
  7237. fields = append(fields, batchmsg.FieldSendTime)
  7238. }
  7239. if m.FieldCleared(batchmsg.FieldType) {
  7240. fields = append(fields, batchmsg.FieldType)
  7241. }
  7242. if m.FieldCleared(batchmsg.FieldCc) {
  7243. fields = append(fields, batchmsg.FieldCc)
  7244. }
  7245. if m.FieldCleared(batchmsg.FieldPhone) {
  7246. fields = append(fields, batchmsg.FieldPhone)
  7247. }
  7248. if m.FieldCleared(batchmsg.FieldTemplateName) {
  7249. fields = append(fields, batchmsg.FieldTemplateName)
  7250. }
  7251. if m.FieldCleared(batchmsg.FieldTemplateCode) {
  7252. fields = append(fields, batchmsg.FieldTemplateCode)
  7253. }
  7254. if m.FieldCleared(batchmsg.FieldLang) {
  7255. fields = append(fields, batchmsg.FieldLang)
  7256. }
  7257. return fields
  7258. }
  7259. // FieldCleared returns a boolean indicating if a field with the given name was
  7260. // cleared in this mutation.
  7261. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  7262. _, ok := m.clearedFields[name]
  7263. return ok
  7264. }
  7265. // ClearField clears the value of the field with the given name. It returns an
  7266. // error if the field is not defined in the schema.
  7267. func (m *BatchMsgMutation) ClearField(name string) error {
  7268. switch name {
  7269. case batchmsg.FieldDeletedAt:
  7270. m.ClearDeletedAt()
  7271. return nil
  7272. case batchmsg.FieldStatus:
  7273. m.ClearStatus()
  7274. return nil
  7275. case batchmsg.FieldBatchNo:
  7276. m.ClearBatchNo()
  7277. return nil
  7278. case batchmsg.FieldTaskName:
  7279. m.ClearTaskName()
  7280. return nil
  7281. case batchmsg.FieldFromwxid:
  7282. m.ClearFromwxid()
  7283. return nil
  7284. case batchmsg.FieldMsg:
  7285. m.ClearMsg()
  7286. return nil
  7287. case batchmsg.FieldTag:
  7288. m.ClearTag()
  7289. return nil
  7290. case batchmsg.FieldTagids:
  7291. m.ClearTagids()
  7292. return nil
  7293. case batchmsg.FieldTotal:
  7294. m.ClearTotal()
  7295. return nil
  7296. case batchmsg.FieldSuccess:
  7297. m.ClearSuccess()
  7298. return nil
  7299. case batchmsg.FieldFail:
  7300. m.ClearFail()
  7301. return nil
  7302. case batchmsg.FieldStartTime:
  7303. m.ClearStartTime()
  7304. return nil
  7305. case batchmsg.FieldStopTime:
  7306. m.ClearStopTime()
  7307. return nil
  7308. case batchmsg.FieldSendTime:
  7309. m.ClearSendTime()
  7310. return nil
  7311. case batchmsg.FieldType:
  7312. m.ClearType()
  7313. return nil
  7314. case batchmsg.FieldCc:
  7315. m.ClearCc()
  7316. return nil
  7317. case batchmsg.FieldPhone:
  7318. m.ClearPhone()
  7319. return nil
  7320. case batchmsg.FieldTemplateName:
  7321. m.ClearTemplateName()
  7322. return nil
  7323. case batchmsg.FieldTemplateCode:
  7324. m.ClearTemplateCode()
  7325. return nil
  7326. case batchmsg.FieldLang:
  7327. m.ClearLang()
  7328. return nil
  7329. }
  7330. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  7331. }
  7332. // ResetField resets all changes in the mutation for the field with the given name.
  7333. // It returns an error if the field is not defined in the schema.
  7334. func (m *BatchMsgMutation) ResetField(name string) error {
  7335. switch name {
  7336. case batchmsg.FieldCreatedAt:
  7337. m.ResetCreatedAt()
  7338. return nil
  7339. case batchmsg.FieldUpdatedAt:
  7340. m.ResetUpdatedAt()
  7341. return nil
  7342. case batchmsg.FieldDeletedAt:
  7343. m.ResetDeletedAt()
  7344. return nil
  7345. case batchmsg.FieldStatus:
  7346. m.ResetStatus()
  7347. return nil
  7348. case batchmsg.FieldBatchNo:
  7349. m.ResetBatchNo()
  7350. return nil
  7351. case batchmsg.FieldTaskName:
  7352. m.ResetTaskName()
  7353. return nil
  7354. case batchmsg.FieldFromwxid:
  7355. m.ResetFromwxid()
  7356. return nil
  7357. case batchmsg.FieldMsg:
  7358. m.ResetMsg()
  7359. return nil
  7360. case batchmsg.FieldTag:
  7361. m.ResetTag()
  7362. return nil
  7363. case batchmsg.FieldTagids:
  7364. m.ResetTagids()
  7365. return nil
  7366. case batchmsg.FieldTotal:
  7367. m.ResetTotal()
  7368. return nil
  7369. case batchmsg.FieldSuccess:
  7370. m.ResetSuccess()
  7371. return nil
  7372. case batchmsg.FieldFail:
  7373. m.ResetFail()
  7374. return nil
  7375. case batchmsg.FieldStartTime:
  7376. m.ResetStartTime()
  7377. return nil
  7378. case batchmsg.FieldStopTime:
  7379. m.ResetStopTime()
  7380. return nil
  7381. case batchmsg.FieldSendTime:
  7382. m.ResetSendTime()
  7383. return nil
  7384. case batchmsg.FieldType:
  7385. m.ResetType()
  7386. return nil
  7387. case batchmsg.FieldOrganizationID:
  7388. m.ResetOrganizationID()
  7389. return nil
  7390. case batchmsg.FieldCtype:
  7391. m.ResetCtype()
  7392. return nil
  7393. case batchmsg.FieldCc:
  7394. m.ResetCc()
  7395. return nil
  7396. case batchmsg.FieldPhone:
  7397. m.ResetPhone()
  7398. return nil
  7399. case batchmsg.FieldTemplateName:
  7400. m.ResetTemplateName()
  7401. return nil
  7402. case batchmsg.FieldTemplateCode:
  7403. m.ResetTemplateCode()
  7404. return nil
  7405. case batchmsg.FieldLang:
  7406. m.ResetLang()
  7407. return nil
  7408. }
  7409. return fmt.Errorf("unknown BatchMsg field %s", name)
  7410. }
  7411. // AddedEdges returns all edge names that were set/added in this mutation.
  7412. func (m *BatchMsgMutation) AddedEdges() []string {
  7413. edges := make([]string, 0, 0)
  7414. return edges
  7415. }
  7416. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7417. // name in this mutation.
  7418. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  7419. return nil
  7420. }
  7421. // RemovedEdges returns all edge names that were removed in this mutation.
  7422. func (m *BatchMsgMutation) RemovedEdges() []string {
  7423. edges := make([]string, 0, 0)
  7424. return edges
  7425. }
  7426. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7427. // the given name in this mutation.
  7428. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  7429. return nil
  7430. }
  7431. // ClearedEdges returns all edge names that were cleared in this mutation.
  7432. func (m *BatchMsgMutation) ClearedEdges() []string {
  7433. edges := make([]string, 0, 0)
  7434. return edges
  7435. }
  7436. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7437. // was cleared in this mutation.
  7438. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  7439. return false
  7440. }
  7441. // ClearEdge clears the value of the edge with the given name. It returns an error
  7442. // if that edge is not defined in the schema.
  7443. func (m *BatchMsgMutation) ClearEdge(name string) error {
  7444. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  7445. }
  7446. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7447. // It returns an error if the edge is not defined in the schema.
  7448. func (m *BatchMsgMutation) ResetEdge(name string) error {
  7449. return fmt.Errorf("unknown BatchMsg edge %s", name)
  7450. }
  7451. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  7452. type CategoryMutation struct {
  7453. config
  7454. op Op
  7455. typ string
  7456. id *uint64
  7457. created_at *time.Time
  7458. updated_at *time.Time
  7459. deleted_at *time.Time
  7460. name *string
  7461. organization_id *uint64
  7462. addorganization_id *int64
  7463. clearedFields map[string]struct{}
  7464. done bool
  7465. oldValue func(context.Context) (*Category, error)
  7466. predicates []predicate.Category
  7467. }
  7468. var _ ent.Mutation = (*CategoryMutation)(nil)
  7469. // categoryOption allows management of the mutation configuration using functional options.
  7470. type categoryOption func(*CategoryMutation)
  7471. // newCategoryMutation creates new mutation for the Category entity.
  7472. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  7473. m := &CategoryMutation{
  7474. config: c,
  7475. op: op,
  7476. typ: TypeCategory,
  7477. clearedFields: make(map[string]struct{}),
  7478. }
  7479. for _, opt := range opts {
  7480. opt(m)
  7481. }
  7482. return m
  7483. }
  7484. // withCategoryID sets the ID field of the mutation.
  7485. func withCategoryID(id uint64) categoryOption {
  7486. return func(m *CategoryMutation) {
  7487. var (
  7488. err error
  7489. once sync.Once
  7490. value *Category
  7491. )
  7492. m.oldValue = func(ctx context.Context) (*Category, error) {
  7493. once.Do(func() {
  7494. if m.done {
  7495. err = errors.New("querying old values post mutation is not allowed")
  7496. } else {
  7497. value, err = m.Client().Category.Get(ctx, id)
  7498. }
  7499. })
  7500. return value, err
  7501. }
  7502. m.id = &id
  7503. }
  7504. }
  7505. // withCategory sets the old Category of the mutation.
  7506. func withCategory(node *Category) categoryOption {
  7507. return func(m *CategoryMutation) {
  7508. m.oldValue = func(context.Context) (*Category, error) {
  7509. return node, nil
  7510. }
  7511. m.id = &node.ID
  7512. }
  7513. }
  7514. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7515. // executed in a transaction (ent.Tx), a transactional client is returned.
  7516. func (m CategoryMutation) Client() *Client {
  7517. client := &Client{config: m.config}
  7518. client.init()
  7519. return client
  7520. }
  7521. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7522. // it returns an error otherwise.
  7523. func (m CategoryMutation) Tx() (*Tx, error) {
  7524. if _, ok := m.driver.(*txDriver); !ok {
  7525. return nil, errors.New("ent: mutation is not running in a transaction")
  7526. }
  7527. tx := &Tx{config: m.config}
  7528. tx.init()
  7529. return tx, nil
  7530. }
  7531. // SetID sets the value of the id field. Note that this
  7532. // operation is only accepted on creation of Category entities.
  7533. func (m *CategoryMutation) SetID(id uint64) {
  7534. m.id = &id
  7535. }
  7536. // ID returns the ID value in the mutation. Note that the ID is only available
  7537. // if it was provided to the builder or after it was returned from the database.
  7538. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  7539. if m.id == nil {
  7540. return
  7541. }
  7542. return *m.id, true
  7543. }
  7544. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7545. // That means, if the mutation is applied within a transaction with an isolation level such
  7546. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7547. // or updated by the mutation.
  7548. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  7549. switch {
  7550. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7551. id, exists := m.ID()
  7552. if exists {
  7553. return []uint64{id}, nil
  7554. }
  7555. fallthrough
  7556. case m.op.Is(OpUpdate | OpDelete):
  7557. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  7558. default:
  7559. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7560. }
  7561. }
  7562. // SetCreatedAt sets the "created_at" field.
  7563. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  7564. m.created_at = &t
  7565. }
  7566. // CreatedAt returns the value of the "created_at" field in the mutation.
  7567. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  7568. v := m.created_at
  7569. if v == nil {
  7570. return
  7571. }
  7572. return *v, true
  7573. }
  7574. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  7575. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7576. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7577. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7578. if !m.op.Is(OpUpdateOne) {
  7579. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7580. }
  7581. if m.id == nil || m.oldValue == nil {
  7582. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7583. }
  7584. oldValue, err := m.oldValue(ctx)
  7585. if err != nil {
  7586. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7587. }
  7588. return oldValue.CreatedAt, nil
  7589. }
  7590. // ResetCreatedAt resets all changes to the "created_at" field.
  7591. func (m *CategoryMutation) ResetCreatedAt() {
  7592. m.created_at = nil
  7593. }
  7594. // SetUpdatedAt sets the "updated_at" field.
  7595. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  7596. m.updated_at = &t
  7597. }
  7598. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7599. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  7600. v := m.updated_at
  7601. if v == nil {
  7602. return
  7603. }
  7604. return *v, true
  7605. }
  7606. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  7607. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7608. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7609. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7610. if !m.op.Is(OpUpdateOne) {
  7611. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7612. }
  7613. if m.id == nil || m.oldValue == nil {
  7614. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7615. }
  7616. oldValue, err := m.oldValue(ctx)
  7617. if err != nil {
  7618. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7619. }
  7620. return oldValue.UpdatedAt, nil
  7621. }
  7622. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7623. func (m *CategoryMutation) ResetUpdatedAt() {
  7624. m.updated_at = nil
  7625. }
  7626. // SetDeletedAt sets the "deleted_at" field.
  7627. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  7628. m.deleted_at = &t
  7629. }
  7630. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7631. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  7632. v := m.deleted_at
  7633. if v == nil {
  7634. return
  7635. }
  7636. return *v, true
  7637. }
  7638. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  7639. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7640. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7641. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7642. if !m.op.Is(OpUpdateOne) {
  7643. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7644. }
  7645. if m.id == nil || m.oldValue == nil {
  7646. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7647. }
  7648. oldValue, err := m.oldValue(ctx)
  7649. if err != nil {
  7650. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7651. }
  7652. return oldValue.DeletedAt, nil
  7653. }
  7654. // ClearDeletedAt clears the value of the "deleted_at" field.
  7655. func (m *CategoryMutation) ClearDeletedAt() {
  7656. m.deleted_at = nil
  7657. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  7658. }
  7659. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7660. func (m *CategoryMutation) DeletedAtCleared() bool {
  7661. _, ok := m.clearedFields[category.FieldDeletedAt]
  7662. return ok
  7663. }
  7664. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7665. func (m *CategoryMutation) ResetDeletedAt() {
  7666. m.deleted_at = nil
  7667. delete(m.clearedFields, category.FieldDeletedAt)
  7668. }
  7669. // SetName sets the "name" field.
  7670. func (m *CategoryMutation) SetName(s string) {
  7671. m.name = &s
  7672. }
  7673. // Name returns the value of the "name" field in the mutation.
  7674. func (m *CategoryMutation) Name() (r string, exists bool) {
  7675. v := m.name
  7676. if v == nil {
  7677. return
  7678. }
  7679. return *v, true
  7680. }
  7681. // OldName returns the old "name" field's value of the Category entity.
  7682. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7683. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7684. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  7685. if !m.op.Is(OpUpdateOne) {
  7686. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7687. }
  7688. if m.id == nil || m.oldValue == nil {
  7689. return v, errors.New("OldName requires an ID field in the mutation")
  7690. }
  7691. oldValue, err := m.oldValue(ctx)
  7692. if err != nil {
  7693. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7694. }
  7695. return oldValue.Name, nil
  7696. }
  7697. // ResetName resets all changes to the "name" field.
  7698. func (m *CategoryMutation) ResetName() {
  7699. m.name = nil
  7700. }
  7701. // SetOrganizationID sets the "organization_id" field.
  7702. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  7703. m.organization_id = &u
  7704. m.addorganization_id = nil
  7705. }
  7706. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7707. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  7708. v := m.organization_id
  7709. if v == nil {
  7710. return
  7711. }
  7712. return *v, true
  7713. }
  7714. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  7715. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7716. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7717. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7718. if !m.op.Is(OpUpdateOne) {
  7719. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7720. }
  7721. if m.id == nil || m.oldValue == nil {
  7722. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  7723. }
  7724. oldValue, err := m.oldValue(ctx)
  7725. if err != nil {
  7726. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  7727. }
  7728. return oldValue.OrganizationID, nil
  7729. }
  7730. // AddOrganizationID adds u to the "organization_id" field.
  7731. func (m *CategoryMutation) AddOrganizationID(u int64) {
  7732. if m.addorganization_id != nil {
  7733. *m.addorganization_id += u
  7734. } else {
  7735. m.addorganization_id = &u
  7736. }
  7737. }
  7738. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7739. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  7740. v := m.addorganization_id
  7741. if v == nil {
  7742. return
  7743. }
  7744. return *v, true
  7745. }
  7746. // ResetOrganizationID resets all changes to the "organization_id" field.
  7747. func (m *CategoryMutation) ResetOrganizationID() {
  7748. m.organization_id = nil
  7749. m.addorganization_id = nil
  7750. }
  7751. // Where appends a list predicates to the CategoryMutation builder.
  7752. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  7753. m.predicates = append(m.predicates, ps...)
  7754. }
  7755. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  7756. // users can use type-assertion to append predicates that do not depend on any generated package.
  7757. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  7758. p := make([]predicate.Category, len(ps))
  7759. for i := range ps {
  7760. p[i] = ps[i]
  7761. }
  7762. m.Where(p...)
  7763. }
  7764. // Op returns the operation name.
  7765. func (m *CategoryMutation) Op() Op {
  7766. return m.op
  7767. }
  7768. // SetOp allows setting the mutation operation.
  7769. func (m *CategoryMutation) SetOp(op Op) {
  7770. m.op = op
  7771. }
  7772. // Type returns the node type of this mutation (Category).
  7773. func (m *CategoryMutation) Type() string {
  7774. return m.typ
  7775. }
  7776. // Fields returns all fields that were changed during this mutation. Note that in
  7777. // order to get all numeric fields that were incremented/decremented, call
  7778. // AddedFields().
  7779. func (m *CategoryMutation) Fields() []string {
  7780. fields := make([]string, 0, 5)
  7781. if m.created_at != nil {
  7782. fields = append(fields, category.FieldCreatedAt)
  7783. }
  7784. if m.updated_at != nil {
  7785. fields = append(fields, category.FieldUpdatedAt)
  7786. }
  7787. if m.deleted_at != nil {
  7788. fields = append(fields, category.FieldDeletedAt)
  7789. }
  7790. if m.name != nil {
  7791. fields = append(fields, category.FieldName)
  7792. }
  7793. if m.organization_id != nil {
  7794. fields = append(fields, category.FieldOrganizationID)
  7795. }
  7796. return fields
  7797. }
  7798. // Field returns the value of a field with the given name. The second boolean
  7799. // return value indicates that this field was not set, or was not defined in the
  7800. // schema.
  7801. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  7802. switch name {
  7803. case category.FieldCreatedAt:
  7804. return m.CreatedAt()
  7805. case category.FieldUpdatedAt:
  7806. return m.UpdatedAt()
  7807. case category.FieldDeletedAt:
  7808. return m.DeletedAt()
  7809. case category.FieldName:
  7810. return m.Name()
  7811. case category.FieldOrganizationID:
  7812. return m.OrganizationID()
  7813. }
  7814. return nil, false
  7815. }
  7816. // OldField returns the old value of the field from the database. An error is
  7817. // returned if the mutation operation is not UpdateOne, or the query to the
  7818. // database failed.
  7819. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7820. switch name {
  7821. case category.FieldCreatedAt:
  7822. return m.OldCreatedAt(ctx)
  7823. case category.FieldUpdatedAt:
  7824. return m.OldUpdatedAt(ctx)
  7825. case category.FieldDeletedAt:
  7826. return m.OldDeletedAt(ctx)
  7827. case category.FieldName:
  7828. return m.OldName(ctx)
  7829. case category.FieldOrganizationID:
  7830. return m.OldOrganizationID(ctx)
  7831. }
  7832. return nil, fmt.Errorf("unknown Category field %s", name)
  7833. }
  7834. // SetField sets the value of a field with the given name. It returns an error if
  7835. // the field is not defined in the schema, or if the type mismatched the field
  7836. // type.
  7837. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  7838. switch name {
  7839. case category.FieldCreatedAt:
  7840. v, ok := value.(time.Time)
  7841. if !ok {
  7842. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7843. }
  7844. m.SetCreatedAt(v)
  7845. return nil
  7846. case category.FieldUpdatedAt:
  7847. v, ok := value.(time.Time)
  7848. if !ok {
  7849. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7850. }
  7851. m.SetUpdatedAt(v)
  7852. return nil
  7853. case category.FieldDeletedAt:
  7854. v, ok := value.(time.Time)
  7855. if !ok {
  7856. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7857. }
  7858. m.SetDeletedAt(v)
  7859. return nil
  7860. case category.FieldName:
  7861. v, ok := value.(string)
  7862. if !ok {
  7863. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7864. }
  7865. m.SetName(v)
  7866. return nil
  7867. case category.FieldOrganizationID:
  7868. v, ok := value.(uint64)
  7869. if !ok {
  7870. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7871. }
  7872. m.SetOrganizationID(v)
  7873. return nil
  7874. }
  7875. return fmt.Errorf("unknown Category field %s", name)
  7876. }
  7877. // AddedFields returns all numeric fields that were incremented/decremented during
  7878. // this mutation.
  7879. func (m *CategoryMutation) AddedFields() []string {
  7880. var fields []string
  7881. if m.addorganization_id != nil {
  7882. fields = append(fields, category.FieldOrganizationID)
  7883. }
  7884. return fields
  7885. }
  7886. // AddedField returns the numeric value that was incremented/decremented on a field
  7887. // with the given name. The second boolean return value indicates that this field
  7888. // was not set, or was not defined in the schema.
  7889. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  7890. switch name {
  7891. case category.FieldOrganizationID:
  7892. return m.AddedOrganizationID()
  7893. }
  7894. return nil, false
  7895. }
  7896. // AddField adds the value to the field with the given name. It returns an error if
  7897. // the field is not defined in the schema, or if the type mismatched the field
  7898. // type.
  7899. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  7900. switch name {
  7901. case category.FieldOrganizationID:
  7902. v, ok := value.(int64)
  7903. if !ok {
  7904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7905. }
  7906. m.AddOrganizationID(v)
  7907. return nil
  7908. }
  7909. return fmt.Errorf("unknown Category numeric field %s", name)
  7910. }
  7911. // ClearedFields returns all nullable fields that were cleared during this
  7912. // mutation.
  7913. func (m *CategoryMutation) ClearedFields() []string {
  7914. var fields []string
  7915. if m.FieldCleared(category.FieldDeletedAt) {
  7916. fields = append(fields, category.FieldDeletedAt)
  7917. }
  7918. return fields
  7919. }
  7920. // FieldCleared returns a boolean indicating if a field with the given name was
  7921. // cleared in this mutation.
  7922. func (m *CategoryMutation) FieldCleared(name string) bool {
  7923. _, ok := m.clearedFields[name]
  7924. return ok
  7925. }
  7926. // ClearField clears the value of the field with the given name. It returns an
  7927. // error if the field is not defined in the schema.
  7928. func (m *CategoryMutation) ClearField(name string) error {
  7929. switch name {
  7930. case category.FieldDeletedAt:
  7931. m.ClearDeletedAt()
  7932. return nil
  7933. }
  7934. return fmt.Errorf("unknown Category nullable field %s", name)
  7935. }
  7936. // ResetField resets all changes in the mutation for the field with the given name.
  7937. // It returns an error if the field is not defined in the schema.
  7938. func (m *CategoryMutation) ResetField(name string) error {
  7939. switch name {
  7940. case category.FieldCreatedAt:
  7941. m.ResetCreatedAt()
  7942. return nil
  7943. case category.FieldUpdatedAt:
  7944. m.ResetUpdatedAt()
  7945. return nil
  7946. case category.FieldDeletedAt:
  7947. m.ResetDeletedAt()
  7948. return nil
  7949. case category.FieldName:
  7950. m.ResetName()
  7951. return nil
  7952. case category.FieldOrganizationID:
  7953. m.ResetOrganizationID()
  7954. return nil
  7955. }
  7956. return fmt.Errorf("unknown Category field %s", name)
  7957. }
  7958. // AddedEdges returns all edge names that were set/added in this mutation.
  7959. func (m *CategoryMutation) AddedEdges() []string {
  7960. edges := make([]string, 0, 0)
  7961. return edges
  7962. }
  7963. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7964. // name in this mutation.
  7965. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  7966. return nil
  7967. }
  7968. // RemovedEdges returns all edge names that were removed in this mutation.
  7969. func (m *CategoryMutation) RemovedEdges() []string {
  7970. edges := make([]string, 0, 0)
  7971. return edges
  7972. }
  7973. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7974. // the given name in this mutation.
  7975. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  7976. return nil
  7977. }
  7978. // ClearedEdges returns all edge names that were cleared in this mutation.
  7979. func (m *CategoryMutation) ClearedEdges() []string {
  7980. edges := make([]string, 0, 0)
  7981. return edges
  7982. }
  7983. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7984. // was cleared in this mutation.
  7985. func (m *CategoryMutation) EdgeCleared(name string) bool {
  7986. return false
  7987. }
  7988. // ClearEdge clears the value of the edge with the given name. It returns an error
  7989. // if that edge is not defined in the schema.
  7990. func (m *CategoryMutation) ClearEdge(name string) error {
  7991. return fmt.Errorf("unknown Category unique edge %s", name)
  7992. }
  7993. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7994. // It returns an error if the edge is not defined in the schema.
  7995. func (m *CategoryMutation) ResetEdge(name string) error {
  7996. return fmt.Errorf("unknown Category edge %s", name)
  7997. }
  7998. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  7999. type ChatRecordsMutation struct {
  8000. config
  8001. op Op
  8002. typ string
  8003. id *uint64
  8004. created_at *time.Time
  8005. updated_at *time.Time
  8006. deleted_at *time.Time
  8007. content *string
  8008. content_type *uint8
  8009. addcontent_type *int8
  8010. session_id *uint64
  8011. addsession_id *int64
  8012. user_id *uint64
  8013. adduser_id *int64
  8014. bot_id *uint64
  8015. addbot_id *int64
  8016. bot_type *uint8
  8017. addbot_type *int8
  8018. clearedFields map[string]struct{}
  8019. done bool
  8020. oldValue func(context.Context) (*ChatRecords, error)
  8021. predicates []predicate.ChatRecords
  8022. }
  8023. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  8024. // chatrecordsOption allows management of the mutation configuration using functional options.
  8025. type chatrecordsOption func(*ChatRecordsMutation)
  8026. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  8027. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  8028. m := &ChatRecordsMutation{
  8029. config: c,
  8030. op: op,
  8031. typ: TypeChatRecords,
  8032. clearedFields: make(map[string]struct{}),
  8033. }
  8034. for _, opt := range opts {
  8035. opt(m)
  8036. }
  8037. return m
  8038. }
  8039. // withChatRecordsID sets the ID field of the mutation.
  8040. func withChatRecordsID(id uint64) chatrecordsOption {
  8041. return func(m *ChatRecordsMutation) {
  8042. var (
  8043. err error
  8044. once sync.Once
  8045. value *ChatRecords
  8046. )
  8047. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  8048. once.Do(func() {
  8049. if m.done {
  8050. err = errors.New("querying old values post mutation is not allowed")
  8051. } else {
  8052. value, err = m.Client().ChatRecords.Get(ctx, id)
  8053. }
  8054. })
  8055. return value, err
  8056. }
  8057. m.id = &id
  8058. }
  8059. }
  8060. // withChatRecords sets the old ChatRecords of the mutation.
  8061. func withChatRecords(node *ChatRecords) chatrecordsOption {
  8062. return func(m *ChatRecordsMutation) {
  8063. m.oldValue = func(context.Context) (*ChatRecords, error) {
  8064. return node, nil
  8065. }
  8066. m.id = &node.ID
  8067. }
  8068. }
  8069. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8070. // executed in a transaction (ent.Tx), a transactional client is returned.
  8071. func (m ChatRecordsMutation) Client() *Client {
  8072. client := &Client{config: m.config}
  8073. client.init()
  8074. return client
  8075. }
  8076. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8077. // it returns an error otherwise.
  8078. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  8079. if _, ok := m.driver.(*txDriver); !ok {
  8080. return nil, errors.New("ent: mutation is not running in a transaction")
  8081. }
  8082. tx := &Tx{config: m.config}
  8083. tx.init()
  8084. return tx, nil
  8085. }
  8086. // SetID sets the value of the id field. Note that this
  8087. // operation is only accepted on creation of ChatRecords entities.
  8088. func (m *ChatRecordsMutation) SetID(id uint64) {
  8089. m.id = &id
  8090. }
  8091. // ID returns the ID value in the mutation. Note that the ID is only available
  8092. // if it was provided to the builder or after it was returned from the database.
  8093. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  8094. if m.id == nil {
  8095. return
  8096. }
  8097. return *m.id, true
  8098. }
  8099. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8100. // That means, if the mutation is applied within a transaction with an isolation level such
  8101. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8102. // or updated by the mutation.
  8103. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  8104. switch {
  8105. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8106. id, exists := m.ID()
  8107. if exists {
  8108. return []uint64{id}, nil
  8109. }
  8110. fallthrough
  8111. case m.op.Is(OpUpdate | OpDelete):
  8112. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  8113. default:
  8114. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8115. }
  8116. }
  8117. // SetCreatedAt sets the "created_at" field.
  8118. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  8119. m.created_at = &t
  8120. }
  8121. // CreatedAt returns the value of the "created_at" field in the mutation.
  8122. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  8123. v := m.created_at
  8124. if v == nil {
  8125. return
  8126. }
  8127. return *v, true
  8128. }
  8129. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  8130. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8131. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8132. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8133. if !m.op.Is(OpUpdateOne) {
  8134. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8135. }
  8136. if m.id == nil || m.oldValue == nil {
  8137. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8138. }
  8139. oldValue, err := m.oldValue(ctx)
  8140. if err != nil {
  8141. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8142. }
  8143. return oldValue.CreatedAt, nil
  8144. }
  8145. // ResetCreatedAt resets all changes to the "created_at" field.
  8146. func (m *ChatRecordsMutation) ResetCreatedAt() {
  8147. m.created_at = nil
  8148. }
  8149. // SetUpdatedAt sets the "updated_at" field.
  8150. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  8151. m.updated_at = &t
  8152. }
  8153. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8154. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  8155. v := m.updated_at
  8156. if v == nil {
  8157. return
  8158. }
  8159. return *v, true
  8160. }
  8161. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  8162. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8163. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8164. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8165. if !m.op.Is(OpUpdateOne) {
  8166. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8167. }
  8168. if m.id == nil || m.oldValue == nil {
  8169. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8170. }
  8171. oldValue, err := m.oldValue(ctx)
  8172. if err != nil {
  8173. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8174. }
  8175. return oldValue.UpdatedAt, nil
  8176. }
  8177. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8178. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  8179. m.updated_at = nil
  8180. }
  8181. // SetDeletedAt sets the "deleted_at" field.
  8182. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  8183. m.deleted_at = &t
  8184. }
  8185. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8186. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  8187. v := m.deleted_at
  8188. if v == nil {
  8189. return
  8190. }
  8191. return *v, true
  8192. }
  8193. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  8194. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8195. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8196. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8197. if !m.op.Is(OpUpdateOne) {
  8198. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8199. }
  8200. if m.id == nil || m.oldValue == nil {
  8201. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8202. }
  8203. oldValue, err := m.oldValue(ctx)
  8204. if err != nil {
  8205. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8206. }
  8207. return oldValue.DeletedAt, nil
  8208. }
  8209. // ClearDeletedAt clears the value of the "deleted_at" field.
  8210. func (m *ChatRecordsMutation) ClearDeletedAt() {
  8211. m.deleted_at = nil
  8212. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  8213. }
  8214. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8215. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  8216. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  8217. return ok
  8218. }
  8219. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8220. func (m *ChatRecordsMutation) ResetDeletedAt() {
  8221. m.deleted_at = nil
  8222. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  8223. }
  8224. // SetContent sets the "content" field.
  8225. func (m *ChatRecordsMutation) SetContent(s string) {
  8226. m.content = &s
  8227. }
  8228. // Content returns the value of the "content" field in the mutation.
  8229. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  8230. v := m.content
  8231. if v == nil {
  8232. return
  8233. }
  8234. return *v, true
  8235. }
  8236. // OldContent returns the old "content" field's value of the ChatRecords entity.
  8237. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8238. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8239. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  8240. if !m.op.Is(OpUpdateOne) {
  8241. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  8242. }
  8243. if m.id == nil || m.oldValue == nil {
  8244. return v, errors.New("OldContent requires an ID field in the mutation")
  8245. }
  8246. oldValue, err := m.oldValue(ctx)
  8247. if err != nil {
  8248. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  8249. }
  8250. return oldValue.Content, nil
  8251. }
  8252. // ResetContent resets all changes to the "content" field.
  8253. func (m *ChatRecordsMutation) ResetContent() {
  8254. m.content = nil
  8255. }
  8256. // SetContentType sets the "content_type" field.
  8257. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  8258. m.content_type = &u
  8259. m.addcontent_type = nil
  8260. }
  8261. // ContentType returns the value of the "content_type" field in the mutation.
  8262. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  8263. v := m.content_type
  8264. if v == nil {
  8265. return
  8266. }
  8267. return *v, true
  8268. }
  8269. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  8270. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8272. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  8273. if !m.op.Is(OpUpdateOne) {
  8274. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  8275. }
  8276. if m.id == nil || m.oldValue == nil {
  8277. return v, errors.New("OldContentType requires an ID field in the mutation")
  8278. }
  8279. oldValue, err := m.oldValue(ctx)
  8280. if err != nil {
  8281. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  8282. }
  8283. return oldValue.ContentType, nil
  8284. }
  8285. // AddContentType adds u to the "content_type" field.
  8286. func (m *ChatRecordsMutation) AddContentType(u int8) {
  8287. if m.addcontent_type != nil {
  8288. *m.addcontent_type += u
  8289. } else {
  8290. m.addcontent_type = &u
  8291. }
  8292. }
  8293. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  8294. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  8295. v := m.addcontent_type
  8296. if v == nil {
  8297. return
  8298. }
  8299. return *v, true
  8300. }
  8301. // ResetContentType resets all changes to the "content_type" field.
  8302. func (m *ChatRecordsMutation) ResetContentType() {
  8303. m.content_type = nil
  8304. m.addcontent_type = nil
  8305. }
  8306. // SetSessionID sets the "session_id" field.
  8307. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  8308. m.session_id = &u
  8309. m.addsession_id = nil
  8310. }
  8311. // SessionID returns the value of the "session_id" field in the mutation.
  8312. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  8313. v := m.session_id
  8314. if v == nil {
  8315. return
  8316. }
  8317. return *v, true
  8318. }
  8319. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  8320. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8321. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8322. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  8323. if !m.op.Is(OpUpdateOne) {
  8324. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  8325. }
  8326. if m.id == nil || m.oldValue == nil {
  8327. return v, errors.New("OldSessionID requires an ID field in the mutation")
  8328. }
  8329. oldValue, err := m.oldValue(ctx)
  8330. if err != nil {
  8331. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  8332. }
  8333. return oldValue.SessionID, nil
  8334. }
  8335. // AddSessionID adds u to the "session_id" field.
  8336. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  8337. if m.addsession_id != nil {
  8338. *m.addsession_id += u
  8339. } else {
  8340. m.addsession_id = &u
  8341. }
  8342. }
  8343. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  8344. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  8345. v := m.addsession_id
  8346. if v == nil {
  8347. return
  8348. }
  8349. return *v, true
  8350. }
  8351. // ResetSessionID resets all changes to the "session_id" field.
  8352. func (m *ChatRecordsMutation) ResetSessionID() {
  8353. m.session_id = nil
  8354. m.addsession_id = nil
  8355. }
  8356. // SetUserID sets the "user_id" field.
  8357. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  8358. m.user_id = &u
  8359. m.adduser_id = nil
  8360. }
  8361. // UserID returns the value of the "user_id" field in the mutation.
  8362. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  8363. v := m.user_id
  8364. if v == nil {
  8365. return
  8366. }
  8367. return *v, true
  8368. }
  8369. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  8370. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8371. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8372. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  8373. if !m.op.Is(OpUpdateOne) {
  8374. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  8375. }
  8376. if m.id == nil || m.oldValue == nil {
  8377. return v, errors.New("OldUserID requires an ID field in the mutation")
  8378. }
  8379. oldValue, err := m.oldValue(ctx)
  8380. if err != nil {
  8381. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  8382. }
  8383. return oldValue.UserID, nil
  8384. }
  8385. // AddUserID adds u to the "user_id" field.
  8386. func (m *ChatRecordsMutation) AddUserID(u int64) {
  8387. if m.adduser_id != nil {
  8388. *m.adduser_id += u
  8389. } else {
  8390. m.adduser_id = &u
  8391. }
  8392. }
  8393. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  8394. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  8395. v := m.adduser_id
  8396. if v == nil {
  8397. return
  8398. }
  8399. return *v, true
  8400. }
  8401. // ResetUserID resets all changes to the "user_id" field.
  8402. func (m *ChatRecordsMutation) ResetUserID() {
  8403. m.user_id = nil
  8404. m.adduser_id = nil
  8405. }
  8406. // SetBotID sets the "bot_id" field.
  8407. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  8408. m.bot_id = &u
  8409. m.addbot_id = nil
  8410. }
  8411. // BotID returns the value of the "bot_id" field in the mutation.
  8412. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  8413. v := m.bot_id
  8414. if v == nil {
  8415. return
  8416. }
  8417. return *v, true
  8418. }
  8419. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  8420. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8421. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8422. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  8423. if !m.op.Is(OpUpdateOne) {
  8424. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  8425. }
  8426. if m.id == nil || m.oldValue == nil {
  8427. return v, errors.New("OldBotID requires an ID field in the mutation")
  8428. }
  8429. oldValue, err := m.oldValue(ctx)
  8430. if err != nil {
  8431. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  8432. }
  8433. return oldValue.BotID, nil
  8434. }
  8435. // AddBotID adds u to the "bot_id" field.
  8436. func (m *ChatRecordsMutation) AddBotID(u int64) {
  8437. if m.addbot_id != nil {
  8438. *m.addbot_id += u
  8439. } else {
  8440. m.addbot_id = &u
  8441. }
  8442. }
  8443. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  8444. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  8445. v := m.addbot_id
  8446. if v == nil {
  8447. return
  8448. }
  8449. return *v, true
  8450. }
  8451. // ResetBotID resets all changes to the "bot_id" field.
  8452. func (m *ChatRecordsMutation) ResetBotID() {
  8453. m.bot_id = nil
  8454. m.addbot_id = nil
  8455. }
  8456. // SetBotType sets the "bot_type" field.
  8457. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  8458. m.bot_type = &u
  8459. m.addbot_type = nil
  8460. }
  8461. // BotType returns the value of the "bot_type" field in the mutation.
  8462. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  8463. v := m.bot_type
  8464. if v == nil {
  8465. return
  8466. }
  8467. return *v, true
  8468. }
  8469. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  8470. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8471. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8472. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  8473. if !m.op.Is(OpUpdateOne) {
  8474. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  8475. }
  8476. if m.id == nil || m.oldValue == nil {
  8477. return v, errors.New("OldBotType requires an ID field in the mutation")
  8478. }
  8479. oldValue, err := m.oldValue(ctx)
  8480. if err != nil {
  8481. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  8482. }
  8483. return oldValue.BotType, nil
  8484. }
  8485. // AddBotType adds u to the "bot_type" field.
  8486. func (m *ChatRecordsMutation) AddBotType(u int8) {
  8487. if m.addbot_type != nil {
  8488. *m.addbot_type += u
  8489. } else {
  8490. m.addbot_type = &u
  8491. }
  8492. }
  8493. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  8494. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  8495. v := m.addbot_type
  8496. if v == nil {
  8497. return
  8498. }
  8499. return *v, true
  8500. }
  8501. // ResetBotType resets all changes to the "bot_type" field.
  8502. func (m *ChatRecordsMutation) ResetBotType() {
  8503. m.bot_type = nil
  8504. m.addbot_type = nil
  8505. }
  8506. // Where appends a list predicates to the ChatRecordsMutation builder.
  8507. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  8508. m.predicates = append(m.predicates, ps...)
  8509. }
  8510. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  8511. // users can use type-assertion to append predicates that do not depend on any generated package.
  8512. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  8513. p := make([]predicate.ChatRecords, len(ps))
  8514. for i := range ps {
  8515. p[i] = ps[i]
  8516. }
  8517. m.Where(p...)
  8518. }
  8519. // Op returns the operation name.
  8520. func (m *ChatRecordsMutation) Op() Op {
  8521. return m.op
  8522. }
  8523. // SetOp allows setting the mutation operation.
  8524. func (m *ChatRecordsMutation) SetOp(op Op) {
  8525. m.op = op
  8526. }
  8527. // Type returns the node type of this mutation (ChatRecords).
  8528. func (m *ChatRecordsMutation) Type() string {
  8529. return m.typ
  8530. }
  8531. // Fields returns all fields that were changed during this mutation. Note that in
  8532. // order to get all numeric fields that were incremented/decremented, call
  8533. // AddedFields().
  8534. func (m *ChatRecordsMutation) Fields() []string {
  8535. fields := make([]string, 0, 9)
  8536. if m.created_at != nil {
  8537. fields = append(fields, chatrecords.FieldCreatedAt)
  8538. }
  8539. if m.updated_at != nil {
  8540. fields = append(fields, chatrecords.FieldUpdatedAt)
  8541. }
  8542. if m.deleted_at != nil {
  8543. fields = append(fields, chatrecords.FieldDeletedAt)
  8544. }
  8545. if m.content != nil {
  8546. fields = append(fields, chatrecords.FieldContent)
  8547. }
  8548. if m.content_type != nil {
  8549. fields = append(fields, chatrecords.FieldContentType)
  8550. }
  8551. if m.session_id != nil {
  8552. fields = append(fields, chatrecords.FieldSessionID)
  8553. }
  8554. if m.user_id != nil {
  8555. fields = append(fields, chatrecords.FieldUserID)
  8556. }
  8557. if m.bot_id != nil {
  8558. fields = append(fields, chatrecords.FieldBotID)
  8559. }
  8560. if m.bot_type != nil {
  8561. fields = append(fields, chatrecords.FieldBotType)
  8562. }
  8563. return fields
  8564. }
  8565. // Field returns the value of a field with the given name. The second boolean
  8566. // return value indicates that this field was not set, or was not defined in the
  8567. // schema.
  8568. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  8569. switch name {
  8570. case chatrecords.FieldCreatedAt:
  8571. return m.CreatedAt()
  8572. case chatrecords.FieldUpdatedAt:
  8573. return m.UpdatedAt()
  8574. case chatrecords.FieldDeletedAt:
  8575. return m.DeletedAt()
  8576. case chatrecords.FieldContent:
  8577. return m.Content()
  8578. case chatrecords.FieldContentType:
  8579. return m.ContentType()
  8580. case chatrecords.FieldSessionID:
  8581. return m.SessionID()
  8582. case chatrecords.FieldUserID:
  8583. return m.UserID()
  8584. case chatrecords.FieldBotID:
  8585. return m.BotID()
  8586. case chatrecords.FieldBotType:
  8587. return m.BotType()
  8588. }
  8589. return nil, false
  8590. }
  8591. // OldField returns the old value of the field from the database. An error is
  8592. // returned if the mutation operation is not UpdateOne, or the query to the
  8593. // database failed.
  8594. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8595. switch name {
  8596. case chatrecords.FieldCreatedAt:
  8597. return m.OldCreatedAt(ctx)
  8598. case chatrecords.FieldUpdatedAt:
  8599. return m.OldUpdatedAt(ctx)
  8600. case chatrecords.FieldDeletedAt:
  8601. return m.OldDeletedAt(ctx)
  8602. case chatrecords.FieldContent:
  8603. return m.OldContent(ctx)
  8604. case chatrecords.FieldContentType:
  8605. return m.OldContentType(ctx)
  8606. case chatrecords.FieldSessionID:
  8607. return m.OldSessionID(ctx)
  8608. case chatrecords.FieldUserID:
  8609. return m.OldUserID(ctx)
  8610. case chatrecords.FieldBotID:
  8611. return m.OldBotID(ctx)
  8612. case chatrecords.FieldBotType:
  8613. return m.OldBotType(ctx)
  8614. }
  8615. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  8616. }
  8617. // SetField sets the value of a field with the given name. It returns an error if
  8618. // the field is not defined in the schema, or if the type mismatched the field
  8619. // type.
  8620. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  8621. switch name {
  8622. case chatrecords.FieldCreatedAt:
  8623. v, ok := value.(time.Time)
  8624. if !ok {
  8625. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8626. }
  8627. m.SetCreatedAt(v)
  8628. return nil
  8629. case chatrecords.FieldUpdatedAt:
  8630. v, ok := value.(time.Time)
  8631. if !ok {
  8632. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8633. }
  8634. m.SetUpdatedAt(v)
  8635. return nil
  8636. case chatrecords.FieldDeletedAt:
  8637. v, ok := value.(time.Time)
  8638. if !ok {
  8639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8640. }
  8641. m.SetDeletedAt(v)
  8642. return nil
  8643. case chatrecords.FieldContent:
  8644. v, ok := value.(string)
  8645. if !ok {
  8646. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8647. }
  8648. m.SetContent(v)
  8649. return nil
  8650. case chatrecords.FieldContentType:
  8651. v, ok := value.(uint8)
  8652. if !ok {
  8653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8654. }
  8655. m.SetContentType(v)
  8656. return nil
  8657. case chatrecords.FieldSessionID:
  8658. v, ok := value.(uint64)
  8659. if !ok {
  8660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8661. }
  8662. m.SetSessionID(v)
  8663. return nil
  8664. case chatrecords.FieldUserID:
  8665. v, ok := value.(uint64)
  8666. if !ok {
  8667. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8668. }
  8669. m.SetUserID(v)
  8670. return nil
  8671. case chatrecords.FieldBotID:
  8672. v, ok := value.(uint64)
  8673. if !ok {
  8674. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8675. }
  8676. m.SetBotID(v)
  8677. return nil
  8678. case chatrecords.FieldBotType:
  8679. v, ok := value.(uint8)
  8680. if !ok {
  8681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8682. }
  8683. m.SetBotType(v)
  8684. return nil
  8685. }
  8686. return fmt.Errorf("unknown ChatRecords field %s", name)
  8687. }
  8688. // AddedFields returns all numeric fields that were incremented/decremented during
  8689. // this mutation.
  8690. func (m *ChatRecordsMutation) AddedFields() []string {
  8691. var fields []string
  8692. if m.addcontent_type != nil {
  8693. fields = append(fields, chatrecords.FieldContentType)
  8694. }
  8695. if m.addsession_id != nil {
  8696. fields = append(fields, chatrecords.FieldSessionID)
  8697. }
  8698. if m.adduser_id != nil {
  8699. fields = append(fields, chatrecords.FieldUserID)
  8700. }
  8701. if m.addbot_id != nil {
  8702. fields = append(fields, chatrecords.FieldBotID)
  8703. }
  8704. if m.addbot_type != nil {
  8705. fields = append(fields, chatrecords.FieldBotType)
  8706. }
  8707. return fields
  8708. }
  8709. // AddedField returns the numeric value that was incremented/decremented on a field
  8710. // with the given name. The second boolean return value indicates that this field
  8711. // was not set, or was not defined in the schema.
  8712. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  8713. switch name {
  8714. case chatrecords.FieldContentType:
  8715. return m.AddedContentType()
  8716. case chatrecords.FieldSessionID:
  8717. return m.AddedSessionID()
  8718. case chatrecords.FieldUserID:
  8719. return m.AddedUserID()
  8720. case chatrecords.FieldBotID:
  8721. return m.AddedBotID()
  8722. case chatrecords.FieldBotType:
  8723. return m.AddedBotType()
  8724. }
  8725. return nil, false
  8726. }
  8727. // AddField adds the value to the field with the given name. It returns an error if
  8728. // the field is not defined in the schema, or if the type mismatched the field
  8729. // type.
  8730. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  8731. switch name {
  8732. case chatrecords.FieldContentType:
  8733. v, ok := value.(int8)
  8734. if !ok {
  8735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8736. }
  8737. m.AddContentType(v)
  8738. return nil
  8739. case chatrecords.FieldSessionID:
  8740. v, ok := value.(int64)
  8741. if !ok {
  8742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8743. }
  8744. m.AddSessionID(v)
  8745. return nil
  8746. case chatrecords.FieldUserID:
  8747. v, ok := value.(int64)
  8748. if !ok {
  8749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8750. }
  8751. m.AddUserID(v)
  8752. return nil
  8753. case chatrecords.FieldBotID:
  8754. v, ok := value.(int64)
  8755. if !ok {
  8756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8757. }
  8758. m.AddBotID(v)
  8759. return nil
  8760. case chatrecords.FieldBotType:
  8761. v, ok := value.(int8)
  8762. if !ok {
  8763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8764. }
  8765. m.AddBotType(v)
  8766. return nil
  8767. }
  8768. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  8769. }
  8770. // ClearedFields returns all nullable fields that were cleared during this
  8771. // mutation.
  8772. func (m *ChatRecordsMutation) ClearedFields() []string {
  8773. var fields []string
  8774. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  8775. fields = append(fields, chatrecords.FieldDeletedAt)
  8776. }
  8777. return fields
  8778. }
  8779. // FieldCleared returns a boolean indicating if a field with the given name was
  8780. // cleared in this mutation.
  8781. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  8782. _, ok := m.clearedFields[name]
  8783. return ok
  8784. }
  8785. // ClearField clears the value of the field with the given name. It returns an
  8786. // error if the field is not defined in the schema.
  8787. func (m *ChatRecordsMutation) ClearField(name string) error {
  8788. switch name {
  8789. case chatrecords.FieldDeletedAt:
  8790. m.ClearDeletedAt()
  8791. return nil
  8792. }
  8793. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  8794. }
  8795. // ResetField resets all changes in the mutation for the field with the given name.
  8796. // It returns an error if the field is not defined in the schema.
  8797. func (m *ChatRecordsMutation) ResetField(name string) error {
  8798. switch name {
  8799. case chatrecords.FieldCreatedAt:
  8800. m.ResetCreatedAt()
  8801. return nil
  8802. case chatrecords.FieldUpdatedAt:
  8803. m.ResetUpdatedAt()
  8804. return nil
  8805. case chatrecords.FieldDeletedAt:
  8806. m.ResetDeletedAt()
  8807. return nil
  8808. case chatrecords.FieldContent:
  8809. m.ResetContent()
  8810. return nil
  8811. case chatrecords.FieldContentType:
  8812. m.ResetContentType()
  8813. return nil
  8814. case chatrecords.FieldSessionID:
  8815. m.ResetSessionID()
  8816. return nil
  8817. case chatrecords.FieldUserID:
  8818. m.ResetUserID()
  8819. return nil
  8820. case chatrecords.FieldBotID:
  8821. m.ResetBotID()
  8822. return nil
  8823. case chatrecords.FieldBotType:
  8824. m.ResetBotType()
  8825. return nil
  8826. }
  8827. return fmt.Errorf("unknown ChatRecords field %s", name)
  8828. }
  8829. // AddedEdges returns all edge names that were set/added in this mutation.
  8830. func (m *ChatRecordsMutation) AddedEdges() []string {
  8831. edges := make([]string, 0, 0)
  8832. return edges
  8833. }
  8834. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8835. // name in this mutation.
  8836. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  8837. return nil
  8838. }
  8839. // RemovedEdges returns all edge names that were removed in this mutation.
  8840. func (m *ChatRecordsMutation) RemovedEdges() []string {
  8841. edges := make([]string, 0, 0)
  8842. return edges
  8843. }
  8844. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8845. // the given name in this mutation.
  8846. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  8847. return nil
  8848. }
  8849. // ClearedEdges returns all edge names that were cleared in this mutation.
  8850. func (m *ChatRecordsMutation) ClearedEdges() []string {
  8851. edges := make([]string, 0, 0)
  8852. return edges
  8853. }
  8854. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8855. // was cleared in this mutation.
  8856. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  8857. return false
  8858. }
  8859. // ClearEdge clears the value of the edge with the given name. It returns an error
  8860. // if that edge is not defined in the schema.
  8861. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  8862. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  8863. }
  8864. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8865. // It returns an error if the edge is not defined in the schema.
  8866. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  8867. return fmt.Errorf("unknown ChatRecords edge %s", name)
  8868. }
  8869. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  8870. type ChatSessionMutation struct {
  8871. config
  8872. op Op
  8873. typ string
  8874. id *uint64
  8875. created_at *time.Time
  8876. updated_at *time.Time
  8877. deleted_at *time.Time
  8878. name *string
  8879. user_id *uint64
  8880. adduser_id *int64
  8881. bot_id *uint64
  8882. addbot_id *int64
  8883. bot_type *uint8
  8884. addbot_type *int8
  8885. clearedFields map[string]struct{}
  8886. done bool
  8887. oldValue func(context.Context) (*ChatSession, error)
  8888. predicates []predicate.ChatSession
  8889. }
  8890. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  8891. // chatsessionOption allows management of the mutation configuration using functional options.
  8892. type chatsessionOption func(*ChatSessionMutation)
  8893. // newChatSessionMutation creates new mutation for the ChatSession entity.
  8894. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  8895. m := &ChatSessionMutation{
  8896. config: c,
  8897. op: op,
  8898. typ: TypeChatSession,
  8899. clearedFields: make(map[string]struct{}),
  8900. }
  8901. for _, opt := range opts {
  8902. opt(m)
  8903. }
  8904. return m
  8905. }
  8906. // withChatSessionID sets the ID field of the mutation.
  8907. func withChatSessionID(id uint64) chatsessionOption {
  8908. return func(m *ChatSessionMutation) {
  8909. var (
  8910. err error
  8911. once sync.Once
  8912. value *ChatSession
  8913. )
  8914. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  8915. once.Do(func() {
  8916. if m.done {
  8917. err = errors.New("querying old values post mutation is not allowed")
  8918. } else {
  8919. value, err = m.Client().ChatSession.Get(ctx, id)
  8920. }
  8921. })
  8922. return value, err
  8923. }
  8924. m.id = &id
  8925. }
  8926. }
  8927. // withChatSession sets the old ChatSession of the mutation.
  8928. func withChatSession(node *ChatSession) chatsessionOption {
  8929. return func(m *ChatSessionMutation) {
  8930. m.oldValue = func(context.Context) (*ChatSession, error) {
  8931. return node, nil
  8932. }
  8933. m.id = &node.ID
  8934. }
  8935. }
  8936. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8937. // executed in a transaction (ent.Tx), a transactional client is returned.
  8938. func (m ChatSessionMutation) Client() *Client {
  8939. client := &Client{config: m.config}
  8940. client.init()
  8941. return client
  8942. }
  8943. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8944. // it returns an error otherwise.
  8945. func (m ChatSessionMutation) Tx() (*Tx, error) {
  8946. if _, ok := m.driver.(*txDriver); !ok {
  8947. return nil, errors.New("ent: mutation is not running in a transaction")
  8948. }
  8949. tx := &Tx{config: m.config}
  8950. tx.init()
  8951. return tx, nil
  8952. }
  8953. // SetID sets the value of the id field. Note that this
  8954. // operation is only accepted on creation of ChatSession entities.
  8955. func (m *ChatSessionMutation) SetID(id uint64) {
  8956. m.id = &id
  8957. }
  8958. // ID returns the ID value in the mutation. Note that the ID is only available
  8959. // if it was provided to the builder or after it was returned from the database.
  8960. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  8961. if m.id == nil {
  8962. return
  8963. }
  8964. return *m.id, true
  8965. }
  8966. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8967. // That means, if the mutation is applied within a transaction with an isolation level such
  8968. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8969. // or updated by the mutation.
  8970. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  8971. switch {
  8972. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8973. id, exists := m.ID()
  8974. if exists {
  8975. return []uint64{id}, nil
  8976. }
  8977. fallthrough
  8978. case m.op.Is(OpUpdate | OpDelete):
  8979. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  8980. default:
  8981. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8982. }
  8983. }
  8984. // SetCreatedAt sets the "created_at" field.
  8985. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  8986. m.created_at = &t
  8987. }
  8988. // CreatedAt returns the value of the "created_at" field in the mutation.
  8989. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  8990. v := m.created_at
  8991. if v == nil {
  8992. return
  8993. }
  8994. return *v, true
  8995. }
  8996. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  8997. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8998. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8999. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9000. if !m.op.Is(OpUpdateOne) {
  9001. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9002. }
  9003. if m.id == nil || m.oldValue == nil {
  9004. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9005. }
  9006. oldValue, err := m.oldValue(ctx)
  9007. if err != nil {
  9008. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9009. }
  9010. return oldValue.CreatedAt, nil
  9011. }
  9012. // ResetCreatedAt resets all changes to the "created_at" field.
  9013. func (m *ChatSessionMutation) ResetCreatedAt() {
  9014. m.created_at = nil
  9015. }
  9016. // SetUpdatedAt sets the "updated_at" field.
  9017. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  9018. m.updated_at = &t
  9019. }
  9020. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9021. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  9022. v := m.updated_at
  9023. if v == nil {
  9024. return
  9025. }
  9026. return *v, true
  9027. }
  9028. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  9029. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9030. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9031. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9032. if !m.op.Is(OpUpdateOne) {
  9033. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9034. }
  9035. if m.id == nil || m.oldValue == nil {
  9036. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9037. }
  9038. oldValue, err := m.oldValue(ctx)
  9039. if err != nil {
  9040. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9041. }
  9042. return oldValue.UpdatedAt, nil
  9043. }
  9044. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9045. func (m *ChatSessionMutation) ResetUpdatedAt() {
  9046. m.updated_at = nil
  9047. }
  9048. // SetDeletedAt sets the "deleted_at" field.
  9049. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  9050. m.deleted_at = &t
  9051. }
  9052. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9053. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  9054. v := m.deleted_at
  9055. if v == nil {
  9056. return
  9057. }
  9058. return *v, true
  9059. }
  9060. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  9061. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9062. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9063. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9064. if !m.op.Is(OpUpdateOne) {
  9065. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9066. }
  9067. if m.id == nil || m.oldValue == nil {
  9068. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9069. }
  9070. oldValue, err := m.oldValue(ctx)
  9071. if err != nil {
  9072. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9073. }
  9074. return oldValue.DeletedAt, nil
  9075. }
  9076. // ClearDeletedAt clears the value of the "deleted_at" field.
  9077. func (m *ChatSessionMutation) ClearDeletedAt() {
  9078. m.deleted_at = nil
  9079. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  9080. }
  9081. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9082. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  9083. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  9084. return ok
  9085. }
  9086. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9087. func (m *ChatSessionMutation) ResetDeletedAt() {
  9088. m.deleted_at = nil
  9089. delete(m.clearedFields, chatsession.FieldDeletedAt)
  9090. }
  9091. // SetName sets the "name" field.
  9092. func (m *ChatSessionMutation) SetName(s string) {
  9093. m.name = &s
  9094. }
  9095. // Name returns the value of the "name" field in the mutation.
  9096. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  9097. v := m.name
  9098. if v == nil {
  9099. return
  9100. }
  9101. return *v, true
  9102. }
  9103. // OldName returns the old "name" field's value of the ChatSession entity.
  9104. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9105. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9106. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  9107. if !m.op.Is(OpUpdateOne) {
  9108. return v, errors.New("OldName is only allowed on UpdateOne operations")
  9109. }
  9110. if m.id == nil || m.oldValue == nil {
  9111. return v, errors.New("OldName requires an ID field in the mutation")
  9112. }
  9113. oldValue, err := m.oldValue(ctx)
  9114. if err != nil {
  9115. return v, fmt.Errorf("querying old value for OldName: %w", err)
  9116. }
  9117. return oldValue.Name, nil
  9118. }
  9119. // ResetName resets all changes to the "name" field.
  9120. func (m *ChatSessionMutation) ResetName() {
  9121. m.name = nil
  9122. }
  9123. // SetUserID sets the "user_id" field.
  9124. func (m *ChatSessionMutation) SetUserID(u uint64) {
  9125. m.user_id = &u
  9126. m.adduser_id = nil
  9127. }
  9128. // UserID returns the value of the "user_id" field in the mutation.
  9129. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  9130. v := m.user_id
  9131. if v == nil {
  9132. return
  9133. }
  9134. return *v, true
  9135. }
  9136. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  9137. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9138. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9139. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  9140. if !m.op.Is(OpUpdateOne) {
  9141. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  9142. }
  9143. if m.id == nil || m.oldValue == nil {
  9144. return v, errors.New("OldUserID requires an ID field in the mutation")
  9145. }
  9146. oldValue, err := m.oldValue(ctx)
  9147. if err != nil {
  9148. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  9149. }
  9150. return oldValue.UserID, nil
  9151. }
  9152. // AddUserID adds u to the "user_id" field.
  9153. func (m *ChatSessionMutation) AddUserID(u int64) {
  9154. if m.adduser_id != nil {
  9155. *m.adduser_id += u
  9156. } else {
  9157. m.adduser_id = &u
  9158. }
  9159. }
  9160. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  9161. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  9162. v := m.adduser_id
  9163. if v == nil {
  9164. return
  9165. }
  9166. return *v, true
  9167. }
  9168. // ResetUserID resets all changes to the "user_id" field.
  9169. func (m *ChatSessionMutation) ResetUserID() {
  9170. m.user_id = nil
  9171. m.adduser_id = nil
  9172. }
  9173. // SetBotID sets the "bot_id" field.
  9174. func (m *ChatSessionMutation) SetBotID(u uint64) {
  9175. m.bot_id = &u
  9176. m.addbot_id = nil
  9177. }
  9178. // BotID returns the value of the "bot_id" field in the mutation.
  9179. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  9180. v := m.bot_id
  9181. if v == nil {
  9182. return
  9183. }
  9184. return *v, true
  9185. }
  9186. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  9187. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9189. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  9190. if !m.op.Is(OpUpdateOne) {
  9191. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  9192. }
  9193. if m.id == nil || m.oldValue == nil {
  9194. return v, errors.New("OldBotID requires an ID field in the mutation")
  9195. }
  9196. oldValue, err := m.oldValue(ctx)
  9197. if err != nil {
  9198. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  9199. }
  9200. return oldValue.BotID, nil
  9201. }
  9202. // AddBotID adds u to the "bot_id" field.
  9203. func (m *ChatSessionMutation) AddBotID(u int64) {
  9204. if m.addbot_id != nil {
  9205. *m.addbot_id += u
  9206. } else {
  9207. m.addbot_id = &u
  9208. }
  9209. }
  9210. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  9211. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  9212. v := m.addbot_id
  9213. if v == nil {
  9214. return
  9215. }
  9216. return *v, true
  9217. }
  9218. // ResetBotID resets all changes to the "bot_id" field.
  9219. func (m *ChatSessionMutation) ResetBotID() {
  9220. m.bot_id = nil
  9221. m.addbot_id = nil
  9222. }
  9223. // SetBotType sets the "bot_type" field.
  9224. func (m *ChatSessionMutation) SetBotType(u uint8) {
  9225. m.bot_type = &u
  9226. m.addbot_type = nil
  9227. }
  9228. // BotType returns the value of the "bot_type" field in the mutation.
  9229. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  9230. v := m.bot_type
  9231. if v == nil {
  9232. return
  9233. }
  9234. return *v, true
  9235. }
  9236. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  9237. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9238. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9239. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  9240. if !m.op.Is(OpUpdateOne) {
  9241. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  9242. }
  9243. if m.id == nil || m.oldValue == nil {
  9244. return v, errors.New("OldBotType requires an ID field in the mutation")
  9245. }
  9246. oldValue, err := m.oldValue(ctx)
  9247. if err != nil {
  9248. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  9249. }
  9250. return oldValue.BotType, nil
  9251. }
  9252. // AddBotType adds u to the "bot_type" field.
  9253. func (m *ChatSessionMutation) AddBotType(u int8) {
  9254. if m.addbot_type != nil {
  9255. *m.addbot_type += u
  9256. } else {
  9257. m.addbot_type = &u
  9258. }
  9259. }
  9260. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  9261. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  9262. v := m.addbot_type
  9263. if v == nil {
  9264. return
  9265. }
  9266. return *v, true
  9267. }
  9268. // ResetBotType resets all changes to the "bot_type" field.
  9269. func (m *ChatSessionMutation) ResetBotType() {
  9270. m.bot_type = nil
  9271. m.addbot_type = nil
  9272. }
  9273. // Where appends a list predicates to the ChatSessionMutation builder.
  9274. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  9275. m.predicates = append(m.predicates, ps...)
  9276. }
  9277. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  9278. // users can use type-assertion to append predicates that do not depend on any generated package.
  9279. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  9280. p := make([]predicate.ChatSession, len(ps))
  9281. for i := range ps {
  9282. p[i] = ps[i]
  9283. }
  9284. m.Where(p...)
  9285. }
  9286. // Op returns the operation name.
  9287. func (m *ChatSessionMutation) Op() Op {
  9288. return m.op
  9289. }
  9290. // SetOp allows setting the mutation operation.
  9291. func (m *ChatSessionMutation) SetOp(op Op) {
  9292. m.op = op
  9293. }
  9294. // Type returns the node type of this mutation (ChatSession).
  9295. func (m *ChatSessionMutation) Type() string {
  9296. return m.typ
  9297. }
  9298. // Fields returns all fields that were changed during this mutation. Note that in
  9299. // order to get all numeric fields that were incremented/decremented, call
  9300. // AddedFields().
  9301. func (m *ChatSessionMutation) Fields() []string {
  9302. fields := make([]string, 0, 7)
  9303. if m.created_at != nil {
  9304. fields = append(fields, chatsession.FieldCreatedAt)
  9305. }
  9306. if m.updated_at != nil {
  9307. fields = append(fields, chatsession.FieldUpdatedAt)
  9308. }
  9309. if m.deleted_at != nil {
  9310. fields = append(fields, chatsession.FieldDeletedAt)
  9311. }
  9312. if m.name != nil {
  9313. fields = append(fields, chatsession.FieldName)
  9314. }
  9315. if m.user_id != nil {
  9316. fields = append(fields, chatsession.FieldUserID)
  9317. }
  9318. if m.bot_id != nil {
  9319. fields = append(fields, chatsession.FieldBotID)
  9320. }
  9321. if m.bot_type != nil {
  9322. fields = append(fields, chatsession.FieldBotType)
  9323. }
  9324. return fields
  9325. }
  9326. // Field returns the value of a field with the given name. The second boolean
  9327. // return value indicates that this field was not set, or was not defined in the
  9328. // schema.
  9329. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  9330. switch name {
  9331. case chatsession.FieldCreatedAt:
  9332. return m.CreatedAt()
  9333. case chatsession.FieldUpdatedAt:
  9334. return m.UpdatedAt()
  9335. case chatsession.FieldDeletedAt:
  9336. return m.DeletedAt()
  9337. case chatsession.FieldName:
  9338. return m.Name()
  9339. case chatsession.FieldUserID:
  9340. return m.UserID()
  9341. case chatsession.FieldBotID:
  9342. return m.BotID()
  9343. case chatsession.FieldBotType:
  9344. return m.BotType()
  9345. }
  9346. return nil, false
  9347. }
  9348. // OldField returns the old value of the field from the database. An error is
  9349. // returned if the mutation operation is not UpdateOne, or the query to the
  9350. // database failed.
  9351. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9352. switch name {
  9353. case chatsession.FieldCreatedAt:
  9354. return m.OldCreatedAt(ctx)
  9355. case chatsession.FieldUpdatedAt:
  9356. return m.OldUpdatedAt(ctx)
  9357. case chatsession.FieldDeletedAt:
  9358. return m.OldDeletedAt(ctx)
  9359. case chatsession.FieldName:
  9360. return m.OldName(ctx)
  9361. case chatsession.FieldUserID:
  9362. return m.OldUserID(ctx)
  9363. case chatsession.FieldBotID:
  9364. return m.OldBotID(ctx)
  9365. case chatsession.FieldBotType:
  9366. return m.OldBotType(ctx)
  9367. }
  9368. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  9369. }
  9370. // SetField sets the value of a field with the given name. It returns an error if
  9371. // the field is not defined in the schema, or if the type mismatched the field
  9372. // type.
  9373. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  9374. switch name {
  9375. case chatsession.FieldCreatedAt:
  9376. v, ok := value.(time.Time)
  9377. if !ok {
  9378. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9379. }
  9380. m.SetCreatedAt(v)
  9381. return nil
  9382. case chatsession.FieldUpdatedAt:
  9383. v, ok := value.(time.Time)
  9384. if !ok {
  9385. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9386. }
  9387. m.SetUpdatedAt(v)
  9388. return nil
  9389. case chatsession.FieldDeletedAt:
  9390. v, ok := value.(time.Time)
  9391. if !ok {
  9392. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9393. }
  9394. m.SetDeletedAt(v)
  9395. return nil
  9396. case chatsession.FieldName:
  9397. v, ok := value.(string)
  9398. if !ok {
  9399. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9400. }
  9401. m.SetName(v)
  9402. return nil
  9403. case chatsession.FieldUserID:
  9404. v, ok := value.(uint64)
  9405. if !ok {
  9406. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9407. }
  9408. m.SetUserID(v)
  9409. return nil
  9410. case chatsession.FieldBotID:
  9411. v, ok := value.(uint64)
  9412. if !ok {
  9413. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9414. }
  9415. m.SetBotID(v)
  9416. return nil
  9417. case chatsession.FieldBotType:
  9418. v, ok := value.(uint8)
  9419. if !ok {
  9420. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9421. }
  9422. m.SetBotType(v)
  9423. return nil
  9424. }
  9425. return fmt.Errorf("unknown ChatSession field %s", name)
  9426. }
  9427. // AddedFields returns all numeric fields that were incremented/decremented during
  9428. // this mutation.
  9429. func (m *ChatSessionMutation) AddedFields() []string {
  9430. var fields []string
  9431. if m.adduser_id != nil {
  9432. fields = append(fields, chatsession.FieldUserID)
  9433. }
  9434. if m.addbot_id != nil {
  9435. fields = append(fields, chatsession.FieldBotID)
  9436. }
  9437. if m.addbot_type != nil {
  9438. fields = append(fields, chatsession.FieldBotType)
  9439. }
  9440. return fields
  9441. }
  9442. // AddedField returns the numeric value that was incremented/decremented on a field
  9443. // with the given name. The second boolean return value indicates that this field
  9444. // was not set, or was not defined in the schema.
  9445. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  9446. switch name {
  9447. case chatsession.FieldUserID:
  9448. return m.AddedUserID()
  9449. case chatsession.FieldBotID:
  9450. return m.AddedBotID()
  9451. case chatsession.FieldBotType:
  9452. return m.AddedBotType()
  9453. }
  9454. return nil, false
  9455. }
  9456. // AddField adds the value to the field with the given name. It returns an error if
  9457. // the field is not defined in the schema, or if the type mismatched the field
  9458. // type.
  9459. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  9460. switch name {
  9461. case chatsession.FieldUserID:
  9462. v, ok := value.(int64)
  9463. if !ok {
  9464. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9465. }
  9466. m.AddUserID(v)
  9467. return nil
  9468. case chatsession.FieldBotID:
  9469. v, ok := value.(int64)
  9470. if !ok {
  9471. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9472. }
  9473. m.AddBotID(v)
  9474. return nil
  9475. case chatsession.FieldBotType:
  9476. v, ok := value.(int8)
  9477. if !ok {
  9478. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9479. }
  9480. m.AddBotType(v)
  9481. return nil
  9482. }
  9483. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  9484. }
  9485. // ClearedFields returns all nullable fields that were cleared during this
  9486. // mutation.
  9487. func (m *ChatSessionMutation) ClearedFields() []string {
  9488. var fields []string
  9489. if m.FieldCleared(chatsession.FieldDeletedAt) {
  9490. fields = append(fields, chatsession.FieldDeletedAt)
  9491. }
  9492. return fields
  9493. }
  9494. // FieldCleared returns a boolean indicating if a field with the given name was
  9495. // cleared in this mutation.
  9496. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  9497. _, ok := m.clearedFields[name]
  9498. return ok
  9499. }
  9500. // ClearField clears the value of the field with the given name. It returns an
  9501. // error if the field is not defined in the schema.
  9502. func (m *ChatSessionMutation) ClearField(name string) error {
  9503. switch name {
  9504. case chatsession.FieldDeletedAt:
  9505. m.ClearDeletedAt()
  9506. return nil
  9507. }
  9508. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  9509. }
  9510. // ResetField resets all changes in the mutation for the field with the given name.
  9511. // It returns an error if the field is not defined in the schema.
  9512. func (m *ChatSessionMutation) ResetField(name string) error {
  9513. switch name {
  9514. case chatsession.FieldCreatedAt:
  9515. m.ResetCreatedAt()
  9516. return nil
  9517. case chatsession.FieldUpdatedAt:
  9518. m.ResetUpdatedAt()
  9519. return nil
  9520. case chatsession.FieldDeletedAt:
  9521. m.ResetDeletedAt()
  9522. return nil
  9523. case chatsession.FieldName:
  9524. m.ResetName()
  9525. return nil
  9526. case chatsession.FieldUserID:
  9527. m.ResetUserID()
  9528. return nil
  9529. case chatsession.FieldBotID:
  9530. m.ResetBotID()
  9531. return nil
  9532. case chatsession.FieldBotType:
  9533. m.ResetBotType()
  9534. return nil
  9535. }
  9536. return fmt.Errorf("unknown ChatSession field %s", name)
  9537. }
  9538. // AddedEdges returns all edge names that were set/added in this mutation.
  9539. func (m *ChatSessionMutation) AddedEdges() []string {
  9540. edges := make([]string, 0, 0)
  9541. return edges
  9542. }
  9543. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9544. // name in this mutation.
  9545. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  9546. return nil
  9547. }
  9548. // RemovedEdges returns all edge names that were removed in this mutation.
  9549. func (m *ChatSessionMutation) RemovedEdges() []string {
  9550. edges := make([]string, 0, 0)
  9551. return edges
  9552. }
  9553. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9554. // the given name in this mutation.
  9555. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  9556. return nil
  9557. }
  9558. // ClearedEdges returns all edge names that were cleared in this mutation.
  9559. func (m *ChatSessionMutation) ClearedEdges() []string {
  9560. edges := make([]string, 0, 0)
  9561. return edges
  9562. }
  9563. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9564. // was cleared in this mutation.
  9565. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  9566. return false
  9567. }
  9568. // ClearEdge clears the value of the edge with the given name. It returns an error
  9569. // if that edge is not defined in the schema.
  9570. func (m *ChatSessionMutation) ClearEdge(name string) error {
  9571. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  9572. }
  9573. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9574. // It returns an error if the edge is not defined in the schema.
  9575. func (m *ChatSessionMutation) ResetEdge(name string) error {
  9576. return fmt.Errorf("unknown ChatSession edge %s", name)
  9577. }
  9578. // CompapiAsynctaskMutation represents an operation that mutates the CompapiAsynctask nodes in the graph.
  9579. type CompapiAsynctaskMutation struct {
  9580. config
  9581. op Op
  9582. typ string
  9583. id *uint64
  9584. created_at *time.Time
  9585. updated_at *time.Time
  9586. auth_token *string
  9587. event_type *string
  9588. chat_id *string
  9589. response_chat_item_id *string
  9590. organization_id *uint64
  9591. addorganization_id *int64
  9592. openai_base *string
  9593. openai_key *string
  9594. request_raw *string
  9595. response_raw *string
  9596. callback_url *string
  9597. callback_response_raw *string
  9598. model *string
  9599. task_status *int8
  9600. addtask_status *int8
  9601. retry_count *int8
  9602. addretry_count *int8
  9603. last_error *string
  9604. clearedFields map[string]struct{}
  9605. done bool
  9606. oldValue func(context.Context) (*CompapiAsynctask, error)
  9607. predicates []predicate.CompapiAsynctask
  9608. }
  9609. var _ ent.Mutation = (*CompapiAsynctaskMutation)(nil)
  9610. // compapiasynctaskOption allows management of the mutation configuration using functional options.
  9611. type compapiasynctaskOption func(*CompapiAsynctaskMutation)
  9612. // newCompapiAsynctaskMutation creates new mutation for the CompapiAsynctask entity.
  9613. func newCompapiAsynctaskMutation(c config, op Op, opts ...compapiasynctaskOption) *CompapiAsynctaskMutation {
  9614. m := &CompapiAsynctaskMutation{
  9615. config: c,
  9616. op: op,
  9617. typ: TypeCompapiAsynctask,
  9618. clearedFields: make(map[string]struct{}),
  9619. }
  9620. for _, opt := range opts {
  9621. opt(m)
  9622. }
  9623. return m
  9624. }
  9625. // withCompapiAsynctaskID sets the ID field of the mutation.
  9626. func withCompapiAsynctaskID(id uint64) compapiasynctaskOption {
  9627. return func(m *CompapiAsynctaskMutation) {
  9628. var (
  9629. err error
  9630. once sync.Once
  9631. value *CompapiAsynctask
  9632. )
  9633. m.oldValue = func(ctx context.Context) (*CompapiAsynctask, error) {
  9634. once.Do(func() {
  9635. if m.done {
  9636. err = errors.New("querying old values post mutation is not allowed")
  9637. } else {
  9638. value, err = m.Client().CompapiAsynctask.Get(ctx, id)
  9639. }
  9640. })
  9641. return value, err
  9642. }
  9643. m.id = &id
  9644. }
  9645. }
  9646. // withCompapiAsynctask sets the old CompapiAsynctask of the mutation.
  9647. func withCompapiAsynctask(node *CompapiAsynctask) compapiasynctaskOption {
  9648. return func(m *CompapiAsynctaskMutation) {
  9649. m.oldValue = func(context.Context) (*CompapiAsynctask, error) {
  9650. return node, nil
  9651. }
  9652. m.id = &node.ID
  9653. }
  9654. }
  9655. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9656. // executed in a transaction (ent.Tx), a transactional client is returned.
  9657. func (m CompapiAsynctaskMutation) Client() *Client {
  9658. client := &Client{config: m.config}
  9659. client.init()
  9660. return client
  9661. }
  9662. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9663. // it returns an error otherwise.
  9664. func (m CompapiAsynctaskMutation) Tx() (*Tx, error) {
  9665. if _, ok := m.driver.(*txDriver); !ok {
  9666. return nil, errors.New("ent: mutation is not running in a transaction")
  9667. }
  9668. tx := &Tx{config: m.config}
  9669. tx.init()
  9670. return tx, nil
  9671. }
  9672. // SetID sets the value of the id field. Note that this
  9673. // operation is only accepted on creation of CompapiAsynctask entities.
  9674. func (m *CompapiAsynctaskMutation) SetID(id uint64) {
  9675. m.id = &id
  9676. }
  9677. // ID returns the ID value in the mutation. Note that the ID is only available
  9678. // if it was provided to the builder or after it was returned from the database.
  9679. func (m *CompapiAsynctaskMutation) ID() (id uint64, exists bool) {
  9680. if m.id == nil {
  9681. return
  9682. }
  9683. return *m.id, true
  9684. }
  9685. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9686. // That means, if the mutation is applied within a transaction with an isolation level such
  9687. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9688. // or updated by the mutation.
  9689. func (m *CompapiAsynctaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  9690. switch {
  9691. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9692. id, exists := m.ID()
  9693. if exists {
  9694. return []uint64{id}, nil
  9695. }
  9696. fallthrough
  9697. case m.op.Is(OpUpdate | OpDelete):
  9698. return m.Client().CompapiAsynctask.Query().Where(m.predicates...).IDs(ctx)
  9699. default:
  9700. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9701. }
  9702. }
  9703. // SetCreatedAt sets the "created_at" field.
  9704. func (m *CompapiAsynctaskMutation) SetCreatedAt(t time.Time) {
  9705. m.created_at = &t
  9706. }
  9707. // CreatedAt returns the value of the "created_at" field in the mutation.
  9708. func (m *CompapiAsynctaskMutation) CreatedAt() (r time.Time, exists bool) {
  9709. v := m.created_at
  9710. if v == nil {
  9711. return
  9712. }
  9713. return *v, true
  9714. }
  9715. // OldCreatedAt returns the old "created_at" field's value of the CompapiAsynctask entity.
  9716. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9717. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9718. func (m *CompapiAsynctaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9719. if !m.op.Is(OpUpdateOne) {
  9720. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9721. }
  9722. if m.id == nil || m.oldValue == nil {
  9723. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9724. }
  9725. oldValue, err := m.oldValue(ctx)
  9726. if err != nil {
  9727. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9728. }
  9729. return oldValue.CreatedAt, nil
  9730. }
  9731. // ResetCreatedAt resets all changes to the "created_at" field.
  9732. func (m *CompapiAsynctaskMutation) ResetCreatedAt() {
  9733. m.created_at = nil
  9734. }
  9735. // SetUpdatedAt sets the "updated_at" field.
  9736. func (m *CompapiAsynctaskMutation) SetUpdatedAt(t time.Time) {
  9737. m.updated_at = &t
  9738. }
  9739. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9740. func (m *CompapiAsynctaskMutation) UpdatedAt() (r time.Time, exists bool) {
  9741. v := m.updated_at
  9742. if v == nil {
  9743. return
  9744. }
  9745. return *v, true
  9746. }
  9747. // OldUpdatedAt returns the old "updated_at" field's value of the CompapiAsynctask entity.
  9748. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9749. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9750. func (m *CompapiAsynctaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9751. if !m.op.Is(OpUpdateOne) {
  9752. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9753. }
  9754. if m.id == nil || m.oldValue == nil {
  9755. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9756. }
  9757. oldValue, err := m.oldValue(ctx)
  9758. if err != nil {
  9759. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9760. }
  9761. return oldValue.UpdatedAt, nil
  9762. }
  9763. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9764. func (m *CompapiAsynctaskMutation) ResetUpdatedAt() {
  9765. m.updated_at = nil
  9766. }
  9767. // SetAuthToken sets the "auth_token" field.
  9768. func (m *CompapiAsynctaskMutation) SetAuthToken(s string) {
  9769. m.auth_token = &s
  9770. }
  9771. // AuthToken returns the value of the "auth_token" field in the mutation.
  9772. func (m *CompapiAsynctaskMutation) AuthToken() (r string, exists bool) {
  9773. v := m.auth_token
  9774. if v == nil {
  9775. return
  9776. }
  9777. return *v, true
  9778. }
  9779. // OldAuthToken returns the old "auth_token" field's value of the CompapiAsynctask entity.
  9780. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9781. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9782. func (m *CompapiAsynctaskMutation) OldAuthToken(ctx context.Context) (v string, err error) {
  9783. if !m.op.Is(OpUpdateOne) {
  9784. return v, errors.New("OldAuthToken is only allowed on UpdateOne operations")
  9785. }
  9786. if m.id == nil || m.oldValue == nil {
  9787. return v, errors.New("OldAuthToken requires an ID field in the mutation")
  9788. }
  9789. oldValue, err := m.oldValue(ctx)
  9790. if err != nil {
  9791. return v, fmt.Errorf("querying old value for OldAuthToken: %w", err)
  9792. }
  9793. return oldValue.AuthToken, nil
  9794. }
  9795. // ResetAuthToken resets all changes to the "auth_token" field.
  9796. func (m *CompapiAsynctaskMutation) ResetAuthToken() {
  9797. m.auth_token = nil
  9798. }
  9799. // SetEventType sets the "event_type" field.
  9800. func (m *CompapiAsynctaskMutation) SetEventType(s string) {
  9801. m.event_type = &s
  9802. }
  9803. // EventType returns the value of the "event_type" field in the mutation.
  9804. func (m *CompapiAsynctaskMutation) EventType() (r string, exists bool) {
  9805. v := m.event_type
  9806. if v == nil {
  9807. return
  9808. }
  9809. return *v, true
  9810. }
  9811. // OldEventType returns the old "event_type" field's value of the CompapiAsynctask entity.
  9812. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9814. func (m *CompapiAsynctaskMutation) OldEventType(ctx context.Context) (v string, err error) {
  9815. if !m.op.Is(OpUpdateOne) {
  9816. return v, errors.New("OldEventType is only allowed on UpdateOne operations")
  9817. }
  9818. if m.id == nil || m.oldValue == nil {
  9819. return v, errors.New("OldEventType requires an ID field in the mutation")
  9820. }
  9821. oldValue, err := m.oldValue(ctx)
  9822. if err != nil {
  9823. return v, fmt.Errorf("querying old value for OldEventType: %w", err)
  9824. }
  9825. return oldValue.EventType, nil
  9826. }
  9827. // ResetEventType resets all changes to the "event_type" field.
  9828. func (m *CompapiAsynctaskMutation) ResetEventType() {
  9829. m.event_type = nil
  9830. }
  9831. // SetChatID sets the "chat_id" field.
  9832. func (m *CompapiAsynctaskMutation) SetChatID(s string) {
  9833. m.chat_id = &s
  9834. }
  9835. // ChatID returns the value of the "chat_id" field in the mutation.
  9836. func (m *CompapiAsynctaskMutation) ChatID() (r string, exists bool) {
  9837. v := m.chat_id
  9838. if v == nil {
  9839. return
  9840. }
  9841. return *v, true
  9842. }
  9843. // OldChatID returns the old "chat_id" field's value of the CompapiAsynctask entity.
  9844. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9846. func (m *CompapiAsynctaskMutation) OldChatID(ctx context.Context) (v string, err error) {
  9847. if !m.op.Is(OpUpdateOne) {
  9848. return v, errors.New("OldChatID is only allowed on UpdateOne operations")
  9849. }
  9850. if m.id == nil || m.oldValue == nil {
  9851. return v, errors.New("OldChatID requires an ID field in the mutation")
  9852. }
  9853. oldValue, err := m.oldValue(ctx)
  9854. if err != nil {
  9855. return v, fmt.Errorf("querying old value for OldChatID: %w", err)
  9856. }
  9857. return oldValue.ChatID, nil
  9858. }
  9859. // ClearChatID clears the value of the "chat_id" field.
  9860. func (m *CompapiAsynctaskMutation) ClearChatID() {
  9861. m.chat_id = nil
  9862. m.clearedFields[compapiasynctask.FieldChatID] = struct{}{}
  9863. }
  9864. // ChatIDCleared returns if the "chat_id" field was cleared in this mutation.
  9865. func (m *CompapiAsynctaskMutation) ChatIDCleared() bool {
  9866. _, ok := m.clearedFields[compapiasynctask.FieldChatID]
  9867. return ok
  9868. }
  9869. // ResetChatID resets all changes to the "chat_id" field.
  9870. func (m *CompapiAsynctaskMutation) ResetChatID() {
  9871. m.chat_id = nil
  9872. delete(m.clearedFields, compapiasynctask.FieldChatID)
  9873. }
  9874. // SetResponseChatItemID sets the "response_chat_item_id" field.
  9875. func (m *CompapiAsynctaskMutation) SetResponseChatItemID(s string) {
  9876. m.response_chat_item_id = &s
  9877. }
  9878. // ResponseChatItemID returns the value of the "response_chat_item_id" field in the mutation.
  9879. func (m *CompapiAsynctaskMutation) ResponseChatItemID() (r string, exists bool) {
  9880. v := m.response_chat_item_id
  9881. if v == nil {
  9882. return
  9883. }
  9884. return *v, true
  9885. }
  9886. // OldResponseChatItemID returns the old "response_chat_item_id" field's value of the CompapiAsynctask entity.
  9887. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9888. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9889. func (m *CompapiAsynctaskMutation) OldResponseChatItemID(ctx context.Context) (v string, err error) {
  9890. if !m.op.Is(OpUpdateOne) {
  9891. return v, errors.New("OldResponseChatItemID is only allowed on UpdateOne operations")
  9892. }
  9893. if m.id == nil || m.oldValue == nil {
  9894. return v, errors.New("OldResponseChatItemID requires an ID field in the mutation")
  9895. }
  9896. oldValue, err := m.oldValue(ctx)
  9897. if err != nil {
  9898. return v, fmt.Errorf("querying old value for OldResponseChatItemID: %w", err)
  9899. }
  9900. return oldValue.ResponseChatItemID, nil
  9901. }
  9902. // ClearResponseChatItemID clears the value of the "response_chat_item_id" field.
  9903. func (m *CompapiAsynctaskMutation) ClearResponseChatItemID() {
  9904. m.response_chat_item_id = nil
  9905. m.clearedFields[compapiasynctask.FieldResponseChatItemID] = struct{}{}
  9906. }
  9907. // ResponseChatItemIDCleared returns if the "response_chat_item_id" field was cleared in this mutation.
  9908. func (m *CompapiAsynctaskMutation) ResponseChatItemIDCleared() bool {
  9909. _, ok := m.clearedFields[compapiasynctask.FieldResponseChatItemID]
  9910. return ok
  9911. }
  9912. // ResetResponseChatItemID resets all changes to the "response_chat_item_id" field.
  9913. func (m *CompapiAsynctaskMutation) ResetResponseChatItemID() {
  9914. m.response_chat_item_id = nil
  9915. delete(m.clearedFields, compapiasynctask.FieldResponseChatItemID)
  9916. }
  9917. // SetOrganizationID sets the "organization_id" field.
  9918. func (m *CompapiAsynctaskMutation) SetOrganizationID(u uint64) {
  9919. m.organization_id = &u
  9920. m.addorganization_id = nil
  9921. }
  9922. // OrganizationID returns the value of the "organization_id" field in the mutation.
  9923. func (m *CompapiAsynctaskMutation) OrganizationID() (r uint64, exists bool) {
  9924. v := m.organization_id
  9925. if v == nil {
  9926. return
  9927. }
  9928. return *v, true
  9929. }
  9930. // OldOrganizationID returns the old "organization_id" field's value of the CompapiAsynctask entity.
  9931. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9932. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9933. func (m *CompapiAsynctaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  9934. if !m.op.Is(OpUpdateOne) {
  9935. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  9936. }
  9937. if m.id == nil || m.oldValue == nil {
  9938. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  9939. }
  9940. oldValue, err := m.oldValue(ctx)
  9941. if err != nil {
  9942. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  9943. }
  9944. return oldValue.OrganizationID, nil
  9945. }
  9946. // AddOrganizationID adds u to the "organization_id" field.
  9947. func (m *CompapiAsynctaskMutation) AddOrganizationID(u int64) {
  9948. if m.addorganization_id != nil {
  9949. *m.addorganization_id += u
  9950. } else {
  9951. m.addorganization_id = &u
  9952. }
  9953. }
  9954. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  9955. func (m *CompapiAsynctaskMutation) AddedOrganizationID() (r int64, exists bool) {
  9956. v := m.addorganization_id
  9957. if v == nil {
  9958. return
  9959. }
  9960. return *v, true
  9961. }
  9962. // ResetOrganizationID resets all changes to the "organization_id" field.
  9963. func (m *CompapiAsynctaskMutation) ResetOrganizationID() {
  9964. m.organization_id = nil
  9965. m.addorganization_id = nil
  9966. }
  9967. // SetOpenaiBase sets the "openai_base" field.
  9968. func (m *CompapiAsynctaskMutation) SetOpenaiBase(s string) {
  9969. m.openai_base = &s
  9970. }
  9971. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  9972. func (m *CompapiAsynctaskMutation) OpenaiBase() (r string, exists bool) {
  9973. v := m.openai_base
  9974. if v == nil {
  9975. return
  9976. }
  9977. return *v, true
  9978. }
  9979. // OldOpenaiBase returns the old "openai_base" field's value of the CompapiAsynctask entity.
  9980. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9981. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9982. func (m *CompapiAsynctaskMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  9983. if !m.op.Is(OpUpdateOne) {
  9984. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  9985. }
  9986. if m.id == nil || m.oldValue == nil {
  9987. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  9988. }
  9989. oldValue, err := m.oldValue(ctx)
  9990. if err != nil {
  9991. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  9992. }
  9993. return oldValue.OpenaiBase, nil
  9994. }
  9995. // ResetOpenaiBase resets all changes to the "openai_base" field.
  9996. func (m *CompapiAsynctaskMutation) ResetOpenaiBase() {
  9997. m.openai_base = nil
  9998. }
  9999. // SetOpenaiKey sets the "openai_key" field.
  10000. func (m *CompapiAsynctaskMutation) SetOpenaiKey(s string) {
  10001. m.openai_key = &s
  10002. }
  10003. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  10004. func (m *CompapiAsynctaskMutation) OpenaiKey() (r string, exists bool) {
  10005. v := m.openai_key
  10006. if v == nil {
  10007. return
  10008. }
  10009. return *v, true
  10010. }
  10011. // OldOpenaiKey returns the old "openai_key" field's value of the CompapiAsynctask entity.
  10012. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10013. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10014. func (m *CompapiAsynctaskMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  10015. if !m.op.Is(OpUpdateOne) {
  10016. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  10017. }
  10018. if m.id == nil || m.oldValue == nil {
  10019. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  10020. }
  10021. oldValue, err := m.oldValue(ctx)
  10022. if err != nil {
  10023. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  10024. }
  10025. return oldValue.OpenaiKey, nil
  10026. }
  10027. // ResetOpenaiKey resets all changes to the "openai_key" field.
  10028. func (m *CompapiAsynctaskMutation) ResetOpenaiKey() {
  10029. m.openai_key = nil
  10030. }
  10031. // SetRequestRaw sets the "request_raw" field.
  10032. func (m *CompapiAsynctaskMutation) SetRequestRaw(s string) {
  10033. m.request_raw = &s
  10034. }
  10035. // RequestRaw returns the value of the "request_raw" field in the mutation.
  10036. func (m *CompapiAsynctaskMutation) RequestRaw() (r string, exists bool) {
  10037. v := m.request_raw
  10038. if v == nil {
  10039. return
  10040. }
  10041. return *v, true
  10042. }
  10043. // OldRequestRaw returns the old "request_raw" field's value of the CompapiAsynctask entity.
  10044. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10045. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10046. func (m *CompapiAsynctaskMutation) OldRequestRaw(ctx context.Context) (v string, err error) {
  10047. if !m.op.Is(OpUpdateOne) {
  10048. return v, errors.New("OldRequestRaw is only allowed on UpdateOne operations")
  10049. }
  10050. if m.id == nil || m.oldValue == nil {
  10051. return v, errors.New("OldRequestRaw requires an ID field in the mutation")
  10052. }
  10053. oldValue, err := m.oldValue(ctx)
  10054. if err != nil {
  10055. return v, fmt.Errorf("querying old value for OldRequestRaw: %w", err)
  10056. }
  10057. return oldValue.RequestRaw, nil
  10058. }
  10059. // ResetRequestRaw resets all changes to the "request_raw" field.
  10060. func (m *CompapiAsynctaskMutation) ResetRequestRaw() {
  10061. m.request_raw = nil
  10062. }
  10063. // SetResponseRaw sets the "response_raw" field.
  10064. func (m *CompapiAsynctaskMutation) SetResponseRaw(s string) {
  10065. m.response_raw = &s
  10066. }
  10067. // ResponseRaw returns the value of the "response_raw" field in the mutation.
  10068. func (m *CompapiAsynctaskMutation) ResponseRaw() (r string, exists bool) {
  10069. v := m.response_raw
  10070. if v == nil {
  10071. return
  10072. }
  10073. return *v, true
  10074. }
  10075. // OldResponseRaw returns the old "response_raw" field's value of the CompapiAsynctask entity.
  10076. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10077. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10078. func (m *CompapiAsynctaskMutation) OldResponseRaw(ctx context.Context) (v string, err error) {
  10079. if !m.op.Is(OpUpdateOne) {
  10080. return v, errors.New("OldResponseRaw is only allowed on UpdateOne operations")
  10081. }
  10082. if m.id == nil || m.oldValue == nil {
  10083. return v, errors.New("OldResponseRaw requires an ID field in the mutation")
  10084. }
  10085. oldValue, err := m.oldValue(ctx)
  10086. if err != nil {
  10087. return v, fmt.Errorf("querying old value for OldResponseRaw: %w", err)
  10088. }
  10089. return oldValue.ResponseRaw, nil
  10090. }
  10091. // ClearResponseRaw clears the value of the "response_raw" field.
  10092. func (m *CompapiAsynctaskMutation) ClearResponseRaw() {
  10093. m.response_raw = nil
  10094. m.clearedFields[compapiasynctask.FieldResponseRaw] = struct{}{}
  10095. }
  10096. // ResponseRawCleared returns if the "response_raw" field was cleared in this mutation.
  10097. func (m *CompapiAsynctaskMutation) ResponseRawCleared() bool {
  10098. _, ok := m.clearedFields[compapiasynctask.FieldResponseRaw]
  10099. return ok
  10100. }
  10101. // ResetResponseRaw resets all changes to the "response_raw" field.
  10102. func (m *CompapiAsynctaskMutation) ResetResponseRaw() {
  10103. m.response_raw = nil
  10104. delete(m.clearedFields, compapiasynctask.FieldResponseRaw)
  10105. }
  10106. // SetCallbackURL sets the "callback_url" field.
  10107. func (m *CompapiAsynctaskMutation) SetCallbackURL(s string) {
  10108. m.callback_url = &s
  10109. }
  10110. // CallbackURL returns the value of the "callback_url" field in the mutation.
  10111. func (m *CompapiAsynctaskMutation) CallbackURL() (r string, exists bool) {
  10112. v := m.callback_url
  10113. if v == nil {
  10114. return
  10115. }
  10116. return *v, true
  10117. }
  10118. // OldCallbackURL returns the old "callback_url" field's value of the CompapiAsynctask entity.
  10119. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10120. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10121. func (m *CompapiAsynctaskMutation) OldCallbackURL(ctx context.Context) (v string, err error) {
  10122. if !m.op.Is(OpUpdateOne) {
  10123. return v, errors.New("OldCallbackURL is only allowed on UpdateOne operations")
  10124. }
  10125. if m.id == nil || m.oldValue == nil {
  10126. return v, errors.New("OldCallbackURL requires an ID field in the mutation")
  10127. }
  10128. oldValue, err := m.oldValue(ctx)
  10129. if err != nil {
  10130. return v, fmt.Errorf("querying old value for OldCallbackURL: %w", err)
  10131. }
  10132. return oldValue.CallbackURL, nil
  10133. }
  10134. // ResetCallbackURL resets all changes to the "callback_url" field.
  10135. func (m *CompapiAsynctaskMutation) ResetCallbackURL() {
  10136. m.callback_url = nil
  10137. }
  10138. // SetCallbackResponseRaw sets the "callback_response_raw" field.
  10139. func (m *CompapiAsynctaskMutation) SetCallbackResponseRaw(s string) {
  10140. m.callback_response_raw = &s
  10141. }
  10142. // CallbackResponseRaw returns the value of the "callback_response_raw" field in the mutation.
  10143. func (m *CompapiAsynctaskMutation) CallbackResponseRaw() (r string, exists bool) {
  10144. v := m.callback_response_raw
  10145. if v == nil {
  10146. return
  10147. }
  10148. return *v, true
  10149. }
  10150. // OldCallbackResponseRaw returns the old "callback_response_raw" field's value of the CompapiAsynctask entity.
  10151. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10152. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10153. func (m *CompapiAsynctaskMutation) OldCallbackResponseRaw(ctx context.Context) (v string, err error) {
  10154. if !m.op.Is(OpUpdateOne) {
  10155. return v, errors.New("OldCallbackResponseRaw is only allowed on UpdateOne operations")
  10156. }
  10157. if m.id == nil || m.oldValue == nil {
  10158. return v, errors.New("OldCallbackResponseRaw requires an ID field in the mutation")
  10159. }
  10160. oldValue, err := m.oldValue(ctx)
  10161. if err != nil {
  10162. return v, fmt.Errorf("querying old value for OldCallbackResponseRaw: %w", err)
  10163. }
  10164. return oldValue.CallbackResponseRaw, nil
  10165. }
  10166. // ClearCallbackResponseRaw clears the value of the "callback_response_raw" field.
  10167. func (m *CompapiAsynctaskMutation) ClearCallbackResponseRaw() {
  10168. m.callback_response_raw = nil
  10169. m.clearedFields[compapiasynctask.FieldCallbackResponseRaw] = struct{}{}
  10170. }
  10171. // CallbackResponseRawCleared returns if the "callback_response_raw" field was cleared in this mutation.
  10172. func (m *CompapiAsynctaskMutation) CallbackResponseRawCleared() bool {
  10173. _, ok := m.clearedFields[compapiasynctask.FieldCallbackResponseRaw]
  10174. return ok
  10175. }
  10176. // ResetCallbackResponseRaw resets all changes to the "callback_response_raw" field.
  10177. func (m *CompapiAsynctaskMutation) ResetCallbackResponseRaw() {
  10178. m.callback_response_raw = nil
  10179. delete(m.clearedFields, compapiasynctask.FieldCallbackResponseRaw)
  10180. }
  10181. // SetModel sets the "model" field.
  10182. func (m *CompapiAsynctaskMutation) SetModel(s string) {
  10183. m.model = &s
  10184. }
  10185. // Model returns the value of the "model" field in the mutation.
  10186. func (m *CompapiAsynctaskMutation) Model() (r string, exists bool) {
  10187. v := m.model
  10188. if v == nil {
  10189. return
  10190. }
  10191. return *v, true
  10192. }
  10193. // OldModel returns the old "model" field's value of the CompapiAsynctask entity.
  10194. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10195. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10196. func (m *CompapiAsynctaskMutation) OldModel(ctx context.Context) (v string, err error) {
  10197. if !m.op.Is(OpUpdateOne) {
  10198. return v, errors.New("OldModel is only allowed on UpdateOne operations")
  10199. }
  10200. if m.id == nil || m.oldValue == nil {
  10201. return v, errors.New("OldModel requires an ID field in the mutation")
  10202. }
  10203. oldValue, err := m.oldValue(ctx)
  10204. if err != nil {
  10205. return v, fmt.Errorf("querying old value for OldModel: %w", err)
  10206. }
  10207. return oldValue.Model, nil
  10208. }
  10209. // ClearModel clears the value of the "model" field.
  10210. func (m *CompapiAsynctaskMutation) ClearModel() {
  10211. m.model = nil
  10212. m.clearedFields[compapiasynctask.FieldModel] = struct{}{}
  10213. }
  10214. // ModelCleared returns if the "model" field was cleared in this mutation.
  10215. func (m *CompapiAsynctaskMutation) ModelCleared() bool {
  10216. _, ok := m.clearedFields[compapiasynctask.FieldModel]
  10217. return ok
  10218. }
  10219. // ResetModel resets all changes to the "model" field.
  10220. func (m *CompapiAsynctaskMutation) ResetModel() {
  10221. m.model = nil
  10222. delete(m.clearedFields, compapiasynctask.FieldModel)
  10223. }
  10224. // SetTaskStatus sets the "task_status" field.
  10225. func (m *CompapiAsynctaskMutation) SetTaskStatus(i int8) {
  10226. m.task_status = &i
  10227. m.addtask_status = nil
  10228. }
  10229. // TaskStatus returns the value of the "task_status" field in the mutation.
  10230. func (m *CompapiAsynctaskMutation) TaskStatus() (r int8, exists bool) {
  10231. v := m.task_status
  10232. if v == nil {
  10233. return
  10234. }
  10235. return *v, true
  10236. }
  10237. // OldTaskStatus returns the old "task_status" field's value of the CompapiAsynctask entity.
  10238. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10239. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10240. func (m *CompapiAsynctaskMutation) OldTaskStatus(ctx context.Context) (v int8, err error) {
  10241. if !m.op.Is(OpUpdateOne) {
  10242. return v, errors.New("OldTaskStatus is only allowed on UpdateOne operations")
  10243. }
  10244. if m.id == nil || m.oldValue == nil {
  10245. return v, errors.New("OldTaskStatus requires an ID field in the mutation")
  10246. }
  10247. oldValue, err := m.oldValue(ctx)
  10248. if err != nil {
  10249. return v, fmt.Errorf("querying old value for OldTaskStatus: %w", err)
  10250. }
  10251. return oldValue.TaskStatus, nil
  10252. }
  10253. // AddTaskStatus adds i to the "task_status" field.
  10254. func (m *CompapiAsynctaskMutation) AddTaskStatus(i int8) {
  10255. if m.addtask_status != nil {
  10256. *m.addtask_status += i
  10257. } else {
  10258. m.addtask_status = &i
  10259. }
  10260. }
  10261. // AddedTaskStatus returns the value that was added to the "task_status" field in this mutation.
  10262. func (m *CompapiAsynctaskMutation) AddedTaskStatus() (r int8, exists bool) {
  10263. v := m.addtask_status
  10264. if v == nil {
  10265. return
  10266. }
  10267. return *v, true
  10268. }
  10269. // ClearTaskStatus clears the value of the "task_status" field.
  10270. func (m *CompapiAsynctaskMutation) ClearTaskStatus() {
  10271. m.task_status = nil
  10272. m.addtask_status = nil
  10273. m.clearedFields[compapiasynctask.FieldTaskStatus] = struct{}{}
  10274. }
  10275. // TaskStatusCleared returns if the "task_status" field was cleared in this mutation.
  10276. func (m *CompapiAsynctaskMutation) TaskStatusCleared() bool {
  10277. _, ok := m.clearedFields[compapiasynctask.FieldTaskStatus]
  10278. return ok
  10279. }
  10280. // ResetTaskStatus resets all changes to the "task_status" field.
  10281. func (m *CompapiAsynctaskMutation) ResetTaskStatus() {
  10282. m.task_status = nil
  10283. m.addtask_status = nil
  10284. delete(m.clearedFields, compapiasynctask.FieldTaskStatus)
  10285. }
  10286. // SetRetryCount sets the "retry_count" field.
  10287. func (m *CompapiAsynctaskMutation) SetRetryCount(i int8) {
  10288. m.retry_count = &i
  10289. m.addretry_count = nil
  10290. }
  10291. // RetryCount returns the value of the "retry_count" field in the mutation.
  10292. func (m *CompapiAsynctaskMutation) RetryCount() (r int8, exists bool) {
  10293. v := m.retry_count
  10294. if v == nil {
  10295. return
  10296. }
  10297. return *v, true
  10298. }
  10299. // OldRetryCount returns the old "retry_count" field's value of the CompapiAsynctask entity.
  10300. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10301. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10302. func (m *CompapiAsynctaskMutation) OldRetryCount(ctx context.Context) (v int8, err error) {
  10303. if !m.op.Is(OpUpdateOne) {
  10304. return v, errors.New("OldRetryCount is only allowed on UpdateOne operations")
  10305. }
  10306. if m.id == nil || m.oldValue == nil {
  10307. return v, errors.New("OldRetryCount requires an ID field in the mutation")
  10308. }
  10309. oldValue, err := m.oldValue(ctx)
  10310. if err != nil {
  10311. return v, fmt.Errorf("querying old value for OldRetryCount: %w", err)
  10312. }
  10313. return oldValue.RetryCount, nil
  10314. }
  10315. // AddRetryCount adds i to the "retry_count" field.
  10316. func (m *CompapiAsynctaskMutation) AddRetryCount(i int8) {
  10317. if m.addretry_count != nil {
  10318. *m.addretry_count += i
  10319. } else {
  10320. m.addretry_count = &i
  10321. }
  10322. }
  10323. // AddedRetryCount returns the value that was added to the "retry_count" field in this mutation.
  10324. func (m *CompapiAsynctaskMutation) AddedRetryCount() (r int8, exists bool) {
  10325. v := m.addretry_count
  10326. if v == nil {
  10327. return
  10328. }
  10329. return *v, true
  10330. }
  10331. // ClearRetryCount clears the value of the "retry_count" field.
  10332. func (m *CompapiAsynctaskMutation) ClearRetryCount() {
  10333. m.retry_count = nil
  10334. m.addretry_count = nil
  10335. m.clearedFields[compapiasynctask.FieldRetryCount] = struct{}{}
  10336. }
  10337. // RetryCountCleared returns if the "retry_count" field was cleared in this mutation.
  10338. func (m *CompapiAsynctaskMutation) RetryCountCleared() bool {
  10339. _, ok := m.clearedFields[compapiasynctask.FieldRetryCount]
  10340. return ok
  10341. }
  10342. // ResetRetryCount resets all changes to the "retry_count" field.
  10343. func (m *CompapiAsynctaskMutation) ResetRetryCount() {
  10344. m.retry_count = nil
  10345. m.addretry_count = nil
  10346. delete(m.clearedFields, compapiasynctask.FieldRetryCount)
  10347. }
  10348. // SetLastError sets the "last_error" field.
  10349. func (m *CompapiAsynctaskMutation) SetLastError(s string) {
  10350. m.last_error = &s
  10351. }
  10352. // LastError returns the value of the "last_error" field in the mutation.
  10353. func (m *CompapiAsynctaskMutation) LastError() (r string, exists bool) {
  10354. v := m.last_error
  10355. if v == nil {
  10356. return
  10357. }
  10358. return *v, true
  10359. }
  10360. // OldLastError returns the old "last_error" field's value of the CompapiAsynctask entity.
  10361. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10363. func (m *CompapiAsynctaskMutation) OldLastError(ctx context.Context) (v string, err error) {
  10364. if !m.op.Is(OpUpdateOne) {
  10365. return v, errors.New("OldLastError is only allowed on UpdateOne operations")
  10366. }
  10367. if m.id == nil || m.oldValue == nil {
  10368. return v, errors.New("OldLastError requires an ID field in the mutation")
  10369. }
  10370. oldValue, err := m.oldValue(ctx)
  10371. if err != nil {
  10372. return v, fmt.Errorf("querying old value for OldLastError: %w", err)
  10373. }
  10374. return oldValue.LastError, nil
  10375. }
  10376. // ClearLastError clears the value of the "last_error" field.
  10377. func (m *CompapiAsynctaskMutation) ClearLastError() {
  10378. m.last_error = nil
  10379. m.clearedFields[compapiasynctask.FieldLastError] = struct{}{}
  10380. }
  10381. // LastErrorCleared returns if the "last_error" field was cleared in this mutation.
  10382. func (m *CompapiAsynctaskMutation) LastErrorCleared() bool {
  10383. _, ok := m.clearedFields[compapiasynctask.FieldLastError]
  10384. return ok
  10385. }
  10386. // ResetLastError resets all changes to the "last_error" field.
  10387. func (m *CompapiAsynctaskMutation) ResetLastError() {
  10388. m.last_error = nil
  10389. delete(m.clearedFields, compapiasynctask.FieldLastError)
  10390. }
  10391. // Where appends a list predicates to the CompapiAsynctaskMutation builder.
  10392. func (m *CompapiAsynctaskMutation) Where(ps ...predicate.CompapiAsynctask) {
  10393. m.predicates = append(m.predicates, ps...)
  10394. }
  10395. // WhereP appends storage-level predicates to the CompapiAsynctaskMutation builder. Using this method,
  10396. // users can use type-assertion to append predicates that do not depend on any generated package.
  10397. func (m *CompapiAsynctaskMutation) WhereP(ps ...func(*sql.Selector)) {
  10398. p := make([]predicate.CompapiAsynctask, len(ps))
  10399. for i := range ps {
  10400. p[i] = ps[i]
  10401. }
  10402. m.Where(p...)
  10403. }
  10404. // Op returns the operation name.
  10405. func (m *CompapiAsynctaskMutation) Op() Op {
  10406. return m.op
  10407. }
  10408. // SetOp allows setting the mutation operation.
  10409. func (m *CompapiAsynctaskMutation) SetOp(op Op) {
  10410. m.op = op
  10411. }
  10412. // Type returns the node type of this mutation (CompapiAsynctask).
  10413. func (m *CompapiAsynctaskMutation) Type() string {
  10414. return m.typ
  10415. }
  10416. // Fields returns all fields that were changed during this mutation. Note that in
  10417. // order to get all numeric fields that were incremented/decremented, call
  10418. // AddedFields().
  10419. func (m *CompapiAsynctaskMutation) Fields() []string {
  10420. fields := make([]string, 0, 17)
  10421. if m.created_at != nil {
  10422. fields = append(fields, compapiasynctask.FieldCreatedAt)
  10423. }
  10424. if m.updated_at != nil {
  10425. fields = append(fields, compapiasynctask.FieldUpdatedAt)
  10426. }
  10427. if m.auth_token != nil {
  10428. fields = append(fields, compapiasynctask.FieldAuthToken)
  10429. }
  10430. if m.event_type != nil {
  10431. fields = append(fields, compapiasynctask.FieldEventType)
  10432. }
  10433. if m.chat_id != nil {
  10434. fields = append(fields, compapiasynctask.FieldChatID)
  10435. }
  10436. if m.response_chat_item_id != nil {
  10437. fields = append(fields, compapiasynctask.FieldResponseChatItemID)
  10438. }
  10439. if m.organization_id != nil {
  10440. fields = append(fields, compapiasynctask.FieldOrganizationID)
  10441. }
  10442. if m.openai_base != nil {
  10443. fields = append(fields, compapiasynctask.FieldOpenaiBase)
  10444. }
  10445. if m.openai_key != nil {
  10446. fields = append(fields, compapiasynctask.FieldOpenaiKey)
  10447. }
  10448. if m.request_raw != nil {
  10449. fields = append(fields, compapiasynctask.FieldRequestRaw)
  10450. }
  10451. if m.response_raw != nil {
  10452. fields = append(fields, compapiasynctask.FieldResponseRaw)
  10453. }
  10454. if m.callback_url != nil {
  10455. fields = append(fields, compapiasynctask.FieldCallbackURL)
  10456. }
  10457. if m.callback_response_raw != nil {
  10458. fields = append(fields, compapiasynctask.FieldCallbackResponseRaw)
  10459. }
  10460. if m.model != nil {
  10461. fields = append(fields, compapiasynctask.FieldModel)
  10462. }
  10463. if m.task_status != nil {
  10464. fields = append(fields, compapiasynctask.FieldTaskStatus)
  10465. }
  10466. if m.retry_count != nil {
  10467. fields = append(fields, compapiasynctask.FieldRetryCount)
  10468. }
  10469. if m.last_error != nil {
  10470. fields = append(fields, compapiasynctask.FieldLastError)
  10471. }
  10472. return fields
  10473. }
  10474. // Field returns the value of a field with the given name. The second boolean
  10475. // return value indicates that this field was not set, or was not defined in the
  10476. // schema.
  10477. func (m *CompapiAsynctaskMutation) Field(name string) (ent.Value, bool) {
  10478. switch name {
  10479. case compapiasynctask.FieldCreatedAt:
  10480. return m.CreatedAt()
  10481. case compapiasynctask.FieldUpdatedAt:
  10482. return m.UpdatedAt()
  10483. case compapiasynctask.FieldAuthToken:
  10484. return m.AuthToken()
  10485. case compapiasynctask.FieldEventType:
  10486. return m.EventType()
  10487. case compapiasynctask.FieldChatID:
  10488. return m.ChatID()
  10489. case compapiasynctask.FieldResponseChatItemID:
  10490. return m.ResponseChatItemID()
  10491. case compapiasynctask.FieldOrganizationID:
  10492. return m.OrganizationID()
  10493. case compapiasynctask.FieldOpenaiBase:
  10494. return m.OpenaiBase()
  10495. case compapiasynctask.FieldOpenaiKey:
  10496. return m.OpenaiKey()
  10497. case compapiasynctask.FieldRequestRaw:
  10498. return m.RequestRaw()
  10499. case compapiasynctask.FieldResponseRaw:
  10500. return m.ResponseRaw()
  10501. case compapiasynctask.FieldCallbackURL:
  10502. return m.CallbackURL()
  10503. case compapiasynctask.FieldCallbackResponseRaw:
  10504. return m.CallbackResponseRaw()
  10505. case compapiasynctask.FieldModel:
  10506. return m.Model()
  10507. case compapiasynctask.FieldTaskStatus:
  10508. return m.TaskStatus()
  10509. case compapiasynctask.FieldRetryCount:
  10510. return m.RetryCount()
  10511. case compapiasynctask.FieldLastError:
  10512. return m.LastError()
  10513. }
  10514. return nil, false
  10515. }
  10516. // OldField returns the old value of the field from the database. An error is
  10517. // returned if the mutation operation is not UpdateOne, or the query to the
  10518. // database failed.
  10519. func (m *CompapiAsynctaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10520. switch name {
  10521. case compapiasynctask.FieldCreatedAt:
  10522. return m.OldCreatedAt(ctx)
  10523. case compapiasynctask.FieldUpdatedAt:
  10524. return m.OldUpdatedAt(ctx)
  10525. case compapiasynctask.FieldAuthToken:
  10526. return m.OldAuthToken(ctx)
  10527. case compapiasynctask.FieldEventType:
  10528. return m.OldEventType(ctx)
  10529. case compapiasynctask.FieldChatID:
  10530. return m.OldChatID(ctx)
  10531. case compapiasynctask.FieldResponseChatItemID:
  10532. return m.OldResponseChatItemID(ctx)
  10533. case compapiasynctask.FieldOrganizationID:
  10534. return m.OldOrganizationID(ctx)
  10535. case compapiasynctask.FieldOpenaiBase:
  10536. return m.OldOpenaiBase(ctx)
  10537. case compapiasynctask.FieldOpenaiKey:
  10538. return m.OldOpenaiKey(ctx)
  10539. case compapiasynctask.FieldRequestRaw:
  10540. return m.OldRequestRaw(ctx)
  10541. case compapiasynctask.FieldResponseRaw:
  10542. return m.OldResponseRaw(ctx)
  10543. case compapiasynctask.FieldCallbackURL:
  10544. return m.OldCallbackURL(ctx)
  10545. case compapiasynctask.FieldCallbackResponseRaw:
  10546. return m.OldCallbackResponseRaw(ctx)
  10547. case compapiasynctask.FieldModel:
  10548. return m.OldModel(ctx)
  10549. case compapiasynctask.FieldTaskStatus:
  10550. return m.OldTaskStatus(ctx)
  10551. case compapiasynctask.FieldRetryCount:
  10552. return m.OldRetryCount(ctx)
  10553. case compapiasynctask.FieldLastError:
  10554. return m.OldLastError(ctx)
  10555. }
  10556. return nil, fmt.Errorf("unknown CompapiAsynctask field %s", name)
  10557. }
  10558. // SetField sets the value of a field with the given name. It returns an error if
  10559. // the field is not defined in the schema, or if the type mismatched the field
  10560. // type.
  10561. func (m *CompapiAsynctaskMutation) SetField(name string, value ent.Value) error {
  10562. switch name {
  10563. case compapiasynctask.FieldCreatedAt:
  10564. v, ok := value.(time.Time)
  10565. if !ok {
  10566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10567. }
  10568. m.SetCreatedAt(v)
  10569. return nil
  10570. case compapiasynctask.FieldUpdatedAt:
  10571. v, ok := value.(time.Time)
  10572. if !ok {
  10573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10574. }
  10575. m.SetUpdatedAt(v)
  10576. return nil
  10577. case compapiasynctask.FieldAuthToken:
  10578. v, ok := value.(string)
  10579. if !ok {
  10580. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10581. }
  10582. m.SetAuthToken(v)
  10583. return nil
  10584. case compapiasynctask.FieldEventType:
  10585. v, ok := value.(string)
  10586. if !ok {
  10587. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10588. }
  10589. m.SetEventType(v)
  10590. return nil
  10591. case compapiasynctask.FieldChatID:
  10592. v, ok := value.(string)
  10593. if !ok {
  10594. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10595. }
  10596. m.SetChatID(v)
  10597. return nil
  10598. case compapiasynctask.FieldResponseChatItemID:
  10599. v, ok := value.(string)
  10600. if !ok {
  10601. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10602. }
  10603. m.SetResponseChatItemID(v)
  10604. return nil
  10605. case compapiasynctask.FieldOrganizationID:
  10606. v, ok := value.(uint64)
  10607. if !ok {
  10608. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10609. }
  10610. m.SetOrganizationID(v)
  10611. return nil
  10612. case compapiasynctask.FieldOpenaiBase:
  10613. v, ok := value.(string)
  10614. if !ok {
  10615. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10616. }
  10617. m.SetOpenaiBase(v)
  10618. return nil
  10619. case compapiasynctask.FieldOpenaiKey:
  10620. v, ok := value.(string)
  10621. if !ok {
  10622. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10623. }
  10624. m.SetOpenaiKey(v)
  10625. return nil
  10626. case compapiasynctask.FieldRequestRaw:
  10627. v, ok := value.(string)
  10628. if !ok {
  10629. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10630. }
  10631. m.SetRequestRaw(v)
  10632. return nil
  10633. case compapiasynctask.FieldResponseRaw:
  10634. v, ok := value.(string)
  10635. if !ok {
  10636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10637. }
  10638. m.SetResponseRaw(v)
  10639. return nil
  10640. case compapiasynctask.FieldCallbackURL:
  10641. v, ok := value.(string)
  10642. if !ok {
  10643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10644. }
  10645. m.SetCallbackURL(v)
  10646. return nil
  10647. case compapiasynctask.FieldCallbackResponseRaw:
  10648. v, ok := value.(string)
  10649. if !ok {
  10650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10651. }
  10652. m.SetCallbackResponseRaw(v)
  10653. return nil
  10654. case compapiasynctask.FieldModel:
  10655. v, ok := value.(string)
  10656. if !ok {
  10657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10658. }
  10659. m.SetModel(v)
  10660. return nil
  10661. case compapiasynctask.FieldTaskStatus:
  10662. v, ok := value.(int8)
  10663. if !ok {
  10664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10665. }
  10666. m.SetTaskStatus(v)
  10667. return nil
  10668. case compapiasynctask.FieldRetryCount:
  10669. v, ok := value.(int8)
  10670. if !ok {
  10671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10672. }
  10673. m.SetRetryCount(v)
  10674. return nil
  10675. case compapiasynctask.FieldLastError:
  10676. v, ok := value.(string)
  10677. if !ok {
  10678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10679. }
  10680. m.SetLastError(v)
  10681. return nil
  10682. }
  10683. return fmt.Errorf("unknown CompapiAsynctask field %s", name)
  10684. }
  10685. // AddedFields returns all numeric fields that were incremented/decremented during
  10686. // this mutation.
  10687. func (m *CompapiAsynctaskMutation) AddedFields() []string {
  10688. var fields []string
  10689. if m.addorganization_id != nil {
  10690. fields = append(fields, compapiasynctask.FieldOrganizationID)
  10691. }
  10692. if m.addtask_status != nil {
  10693. fields = append(fields, compapiasynctask.FieldTaskStatus)
  10694. }
  10695. if m.addretry_count != nil {
  10696. fields = append(fields, compapiasynctask.FieldRetryCount)
  10697. }
  10698. return fields
  10699. }
  10700. // AddedField returns the numeric value that was incremented/decremented on a field
  10701. // with the given name. The second boolean return value indicates that this field
  10702. // was not set, or was not defined in the schema.
  10703. func (m *CompapiAsynctaskMutation) AddedField(name string) (ent.Value, bool) {
  10704. switch name {
  10705. case compapiasynctask.FieldOrganizationID:
  10706. return m.AddedOrganizationID()
  10707. case compapiasynctask.FieldTaskStatus:
  10708. return m.AddedTaskStatus()
  10709. case compapiasynctask.FieldRetryCount:
  10710. return m.AddedRetryCount()
  10711. }
  10712. return nil, false
  10713. }
  10714. // AddField adds the value to the field with the given name. It returns an error if
  10715. // the field is not defined in the schema, or if the type mismatched the field
  10716. // type.
  10717. func (m *CompapiAsynctaskMutation) AddField(name string, value ent.Value) error {
  10718. switch name {
  10719. case compapiasynctask.FieldOrganizationID:
  10720. v, ok := value.(int64)
  10721. if !ok {
  10722. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10723. }
  10724. m.AddOrganizationID(v)
  10725. return nil
  10726. case compapiasynctask.FieldTaskStatus:
  10727. v, ok := value.(int8)
  10728. if !ok {
  10729. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10730. }
  10731. m.AddTaskStatus(v)
  10732. return nil
  10733. case compapiasynctask.FieldRetryCount:
  10734. v, ok := value.(int8)
  10735. if !ok {
  10736. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10737. }
  10738. m.AddRetryCount(v)
  10739. return nil
  10740. }
  10741. return fmt.Errorf("unknown CompapiAsynctask numeric field %s", name)
  10742. }
  10743. // ClearedFields returns all nullable fields that were cleared during this
  10744. // mutation.
  10745. func (m *CompapiAsynctaskMutation) ClearedFields() []string {
  10746. var fields []string
  10747. if m.FieldCleared(compapiasynctask.FieldChatID) {
  10748. fields = append(fields, compapiasynctask.FieldChatID)
  10749. }
  10750. if m.FieldCleared(compapiasynctask.FieldResponseChatItemID) {
  10751. fields = append(fields, compapiasynctask.FieldResponseChatItemID)
  10752. }
  10753. if m.FieldCleared(compapiasynctask.FieldResponseRaw) {
  10754. fields = append(fields, compapiasynctask.FieldResponseRaw)
  10755. }
  10756. if m.FieldCleared(compapiasynctask.FieldCallbackResponseRaw) {
  10757. fields = append(fields, compapiasynctask.FieldCallbackResponseRaw)
  10758. }
  10759. if m.FieldCleared(compapiasynctask.FieldModel) {
  10760. fields = append(fields, compapiasynctask.FieldModel)
  10761. }
  10762. if m.FieldCleared(compapiasynctask.FieldTaskStatus) {
  10763. fields = append(fields, compapiasynctask.FieldTaskStatus)
  10764. }
  10765. if m.FieldCleared(compapiasynctask.FieldRetryCount) {
  10766. fields = append(fields, compapiasynctask.FieldRetryCount)
  10767. }
  10768. if m.FieldCleared(compapiasynctask.FieldLastError) {
  10769. fields = append(fields, compapiasynctask.FieldLastError)
  10770. }
  10771. return fields
  10772. }
  10773. // FieldCleared returns a boolean indicating if a field with the given name was
  10774. // cleared in this mutation.
  10775. func (m *CompapiAsynctaskMutation) FieldCleared(name string) bool {
  10776. _, ok := m.clearedFields[name]
  10777. return ok
  10778. }
  10779. // ClearField clears the value of the field with the given name. It returns an
  10780. // error if the field is not defined in the schema.
  10781. func (m *CompapiAsynctaskMutation) ClearField(name string) error {
  10782. switch name {
  10783. case compapiasynctask.FieldChatID:
  10784. m.ClearChatID()
  10785. return nil
  10786. case compapiasynctask.FieldResponseChatItemID:
  10787. m.ClearResponseChatItemID()
  10788. return nil
  10789. case compapiasynctask.FieldResponseRaw:
  10790. m.ClearResponseRaw()
  10791. return nil
  10792. case compapiasynctask.FieldCallbackResponseRaw:
  10793. m.ClearCallbackResponseRaw()
  10794. return nil
  10795. case compapiasynctask.FieldModel:
  10796. m.ClearModel()
  10797. return nil
  10798. case compapiasynctask.FieldTaskStatus:
  10799. m.ClearTaskStatus()
  10800. return nil
  10801. case compapiasynctask.FieldRetryCount:
  10802. m.ClearRetryCount()
  10803. return nil
  10804. case compapiasynctask.FieldLastError:
  10805. m.ClearLastError()
  10806. return nil
  10807. }
  10808. return fmt.Errorf("unknown CompapiAsynctask nullable field %s", name)
  10809. }
  10810. // ResetField resets all changes in the mutation for the field with the given name.
  10811. // It returns an error if the field is not defined in the schema.
  10812. func (m *CompapiAsynctaskMutation) ResetField(name string) error {
  10813. switch name {
  10814. case compapiasynctask.FieldCreatedAt:
  10815. m.ResetCreatedAt()
  10816. return nil
  10817. case compapiasynctask.FieldUpdatedAt:
  10818. m.ResetUpdatedAt()
  10819. return nil
  10820. case compapiasynctask.FieldAuthToken:
  10821. m.ResetAuthToken()
  10822. return nil
  10823. case compapiasynctask.FieldEventType:
  10824. m.ResetEventType()
  10825. return nil
  10826. case compapiasynctask.FieldChatID:
  10827. m.ResetChatID()
  10828. return nil
  10829. case compapiasynctask.FieldResponseChatItemID:
  10830. m.ResetResponseChatItemID()
  10831. return nil
  10832. case compapiasynctask.FieldOrganizationID:
  10833. m.ResetOrganizationID()
  10834. return nil
  10835. case compapiasynctask.FieldOpenaiBase:
  10836. m.ResetOpenaiBase()
  10837. return nil
  10838. case compapiasynctask.FieldOpenaiKey:
  10839. m.ResetOpenaiKey()
  10840. return nil
  10841. case compapiasynctask.FieldRequestRaw:
  10842. m.ResetRequestRaw()
  10843. return nil
  10844. case compapiasynctask.FieldResponseRaw:
  10845. m.ResetResponseRaw()
  10846. return nil
  10847. case compapiasynctask.FieldCallbackURL:
  10848. m.ResetCallbackURL()
  10849. return nil
  10850. case compapiasynctask.FieldCallbackResponseRaw:
  10851. m.ResetCallbackResponseRaw()
  10852. return nil
  10853. case compapiasynctask.FieldModel:
  10854. m.ResetModel()
  10855. return nil
  10856. case compapiasynctask.FieldTaskStatus:
  10857. m.ResetTaskStatus()
  10858. return nil
  10859. case compapiasynctask.FieldRetryCount:
  10860. m.ResetRetryCount()
  10861. return nil
  10862. case compapiasynctask.FieldLastError:
  10863. m.ResetLastError()
  10864. return nil
  10865. }
  10866. return fmt.Errorf("unknown CompapiAsynctask field %s", name)
  10867. }
  10868. // AddedEdges returns all edge names that were set/added in this mutation.
  10869. func (m *CompapiAsynctaskMutation) AddedEdges() []string {
  10870. edges := make([]string, 0, 0)
  10871. return edges
  10872. }
  10873. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10874. // name in this mutation.
  10875. func (m *CompapiAsynctaskMutation) AddedIDs(name string) []ent.Value {
  10876. return nil
  10877. }
  10878. // RemovedEdges returns all edge names that were removed in this mutation.
  10879. func (m *CompapiAsynctaskMutation) RemovedEdges() []string {
  10880. edges := make([]string, 0, 0)
  10881. return edges
  10882. }
  10883. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10884. // the given name in this mutation.
  10885. func (m *CompapiAsynctaskMutation) RemovedIDs(name string) []ent.Value {
  10886. return nil
  10887. }
  10888. // ClearedEdges returns all edge names that were cleared in this mutation.
  10889. func (m *CompapiAsynctaskMutation) ClearedEdges() []string {
  10890. edges := make([]string, 0, 0)
  10891. return edges
  10892. }
  10893. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10894. // was cleared in this mutation.
  10895. func (m *CompapiAsynctaskMutation) EdgeCleared(name string) bool {
  10896. return false
  10897. }
  10898. // ClearEdge clears the value of the edge with the given name. It returns an error
  10899. // if that edge is not defined in the schema.
  10900. func (m *CompapiAsynctaskMutation) ClearEdge(name string) error {
  10901. return fmt.Errorf("unknown CompapiAsynctask unique edge %s", name)
  10902. }
  10903. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10904. // It returns an error if the edge is not defined in the schema.
  10905. func (m *CompapiAsynctaskMutation) ResetEdge(name string) error {
  10906. return fmt.Errorf("unknown CompapiAsynctask edge %s", name)
  10907. }
  10908. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  10909. type ContactMutation struct {
  10910. config
  10911. op Op
  10912. typ string
  10913. id *uint64
  10914. created_at *time.Time
  10915. updated_at *time.Time
  10916. status *uint8
  10917. addstatus *int8
  10918. deleted_at *time.Time
  10919. wx_wxid *string
  10920. _type *int
  10921. add_type *int
  10922. wxid *string
  10923. account *string
  10924. nickname *string
  10925. markname *string
  10926. headimg *string
  10927. sex *int
  10928. addsex *int
  10929. starrole *string
  10930. dontseeit *int
  10931. adddontseeit *int
  10932. dontseeme *int
  10933. adddontseeme *int
  10934. lag *string
  10935. gid *string
  10936. gname *string
  10937. v3 *string
  10938. organization_id *uint64
  10939. addorganization_id *int64
  10940. ctype *uint64
  10941. addctype *int64
  10942. cage *int
  10943. addcage *int
  10944. cname *string
  10945. carea *string
  10946. cbirthday *string
  10947. cbirtharea *string
  10948. cidcard_no *string
  10949. ctitle *string
  10950. cc *string
  10951. phone *string
  10952. clearedFields map[string]struct{}
  10953. contact_relationships map[uint64]struct{}
  10954. removedcontact_relationships map[uint64]struct{}
  10955. clearedcontact_relationships bool
  10956. contact_fields map[uint64]struct{}
  10957. removedcontact_fields map[uint64]struct{}
  10958. clearedcontact_fields bool
  10959. contact_messages map[uint64]struct{}
  10960. removedcontact_messages map[uint64]struct{}
  10961. clearedcontact_messages bool
  10962. done bool
  10963. oldValue func(context.Context) (*Contact, error)
  10964. predicates []predicate.Contact
  10965. }
  10966. var _ ent.Mutation = (*ContactMutation)(nil)
  10967. // contactOption allows management of the mutation configuration using functional options.
  10968. type contactOption func(*ContactMutation)
  10969. // newContactMutation creates new mutation for the Contact entity.
  10970. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  10971. m := &ContactMutation{
  10972. config: c,
  10973. op: op,
  10974. typ: TypeContact,
  10975. clearedFields: make(map[string]struct{}),
  10976. }
  10977. for _, opt := range opts {
  10978. opt(m)
  10979. }
  10980. return m
  10981. }
  10982. // withContactID sets the ID field of the mutation.
  10983. func withContactID(id uint64) contactOption {
  10984. return func(m *ContactMutation) {
  10985. var (
  10986. err error
  10987. once sync.Once
  10988. value *Contact
  10989. )
  10990. m.oldValue = func(ctx context.Context) (*Contact, error) {
  10991. once.Do(func() {
  10992. if m.done {
  10993. err = errors.New("querying old values post mutation is not allowed")
  10994. } else {
  10995. value, err = m.Client().Contact.Get(ctx, id)
  10996. }
  10997. })
  10998. return value, err
  10999. }
  11000. m.id = &id
  11001. }
  11002. }
  11003. // withContact sets the old Contact of the mutation.
  11004. func withContact(node *Contact) contactOption {
  11005. return func(m *ContactMutation) {
  11006. m.oldValue = func(context.Context) (*Contact, error) {
  11007. return node, nil
  11008. }
  11009. m.id = &node.ID
  11010. }
  11011. }
  11012. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11013. // executed in a transaction (ent.Tx), a transactional client is returned.
  11014. func (m ContactMutation) Client() *Client {
  11015. client := &Client{config: m.config}
  11016. client.init()
  11017. return client
  11018. }
  11019. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11020. // it returns an error otherwise.
  11021. func (m ContactMutation) Tx() (*Tx, error) {
  11022. if _, ok := m.driver.(*txDriver); !ok {
  11023. return nil, errors.New("ent: mutation is not running in a transaction")
  11024. }
  11025. tx := &Tx{config: m.config}
  11026. tx.init()
  11027. return tx, nil
  11028. }
  11029. // SetID sets the value of the id field. Note that this
  11030. // operation is only accepted on creation of Contact entities.
  11031. func (m *ContactMutation) SetID(id uint64) {
  11032. m.id = &id
  11033. }
  11034. // ID returns the ID value in the mutation. Note that the ID is only available
  11035. // if it was provided to the builder or after it was returned from the database.
  11036. func (m *ContactMutation) ID() (id uint64, exists bool) {
  11037. if m.id == nil {
  11038. return
  11039. }
  11040. return *m.id, true
  11041. }
  11042. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11043. // That means, if the mutation is applied within a transaction with an isolation level such
  11044. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11045. // or updated by the mutation.
  11046. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  11047. switch {
  11048. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11049. id, exists := m.ID()
  11050. if exists {
  11051. return []uint64{id}, nil
  11052. }
  11053. fallthrough
  11054. case m.op.Is(OpUpdate | OpDelete):
  11055. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  11056. default:
  11057. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11058. }
  11059. }
  11060. // SetCreatedAt sets the "created_at" field.
  11061. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  11062. m.created_at = &t
  11063. }
  11064. // CreatedAt returns the value of the "created_at" field in the mutation.
  11065. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  11066. v := m.created_at
  11067. if v == nil {
  11068. return
  11069. }
  11070. return *v, true
  11071. }
  11072. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  11073. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11074. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11075. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11076. if !m.op.Is(OpUpdateOne) {
  11077. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11078. }
  11079. if m.id == nil || m.oldValue == nil {
  11080. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11081. }
  11082. oldValue, err := m.oldValue(ctx)
  11083. if err != nil {
  11084. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11085. }
  11086. return oldValue.CreatedAt, nil
  11087. }
  11088. // ResetCreatedAt resets all changes to the "created_at" field.
  11089. func (m *ContactMutation) ResetCreatedAt() {
  11090. m.created_at = nil
  11091. }
  11092. // SetUpdatedAt sets the "updated_at" field.
  11093. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  11094. m.updated_at = &t
  11095. }
  11096. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11097. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  11098. v := m.updated_at
  11099. if v == nil {
  11100. return
  11101. }
  11102. return *v, true
  11103. }
  11104. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  11105. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11106. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11107. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11108. if !m.op.Is(OpUpdateOne) {
  11109. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11110. }
  11111. if m.id == nil || m.oldValue == nil {
  11112. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11113. }
  11114. oldValue, err := m.oldValue(ctx)
  11115. if err != nil {
  11116. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11117. }
  11118. return oldValue.UpdatedAt, nil
  11119. }
  11120. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11121. func (m *ContactMutation) ResetUpdatedAt() {
  11122. m.updated_at = nil
  11123. }
  11124. // SetStatus sets the "status" field.
  11125. func (m *ContactMutation) SetStatus(u uint8) {
  11126. m.status = &u
  11127. m.addstatus = nil
  11128. }
  11129. // Status returns the value of the "status" field in the mutation.
  11130. func (m *ContactMutation) Status() (r uint8, exists bool) {
  11131. v := m.status
  11132. if v == nil {
  11133. return
  11134. }
  11135. return *v, true
  11136. }
  11137. // OldStatus returns the old "status" field's value of the Contact entity.
  11138. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11139. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11140. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  11141. if !m.op.Is(OpUpdateOne) {
  11142. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11143. }
  11144. if m.id == nil || m.oldValue == nil {
  11145. return v, errors.New("OldStatus requires an ID field in the mutation")
  11146. }
  11147. oldValue, err := m.oldValue(ctx)
  11148. if err != nil {
  11149. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11150. }
  11151. return oldValue.Status, nil
  11152. }
  11153. // AddStatus adds u to the "status" field.
  11154. func (m *ContactMutation) AddStatus(u int8) {
  11155. if m.addstatus != nil {
  11156. *m.addstatus += u
  11157. } else {
  11158. m.addstatus = &u
  11159. }
  11160. }
  11161. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11162. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  11163. v := m.addstatus
  11164. if v == nil {
  11165. return
  11166. }
  11167. return *v, true
  11168. }
  11169. // ClearStatus clears the value of the "status" field.
  11170. func (m *ContactMutation) ClearStatus() {
  11171. m.status = nil
  11172. m.addstatus = nil
  11173. m.clearedFields[contact.FieldStatus] = struct{}{}
  11174. }
  11175. // StatusCleared returns if the "status" field was cleared in this mutation.
  11176. func (m *ContactMutation) StatusCleared() bool {
  11177. _, ok := m.clearedFields[contact.FieldStatus]
  11178. return ok
  11179. }
  11180. // ResetStatus resets all changes to the "status" field.
  11181. func (m *ContactMutation) ResetStatus() {
  11182. m.status = nil
  11183. m.addstatus = nil
  11184. delete(m.clearedFields, contact.FieldStatus)
  11185. }
  11186. // SetDeletedAt sets the "deleted_at" field.
  11187. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  11188. m.deleted_at = &t
  11189. }
  11190. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11191. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  11192. v := m.deleted_at
  11193. if v == nil {
  11194. return
  11195. }
  11196. return *v, true
  11197. }
  11198. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  11199. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11200. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11201. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11202. if !m.op.Is(OpUpdateOne) {
  11203. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11204. }
  11205. if m.id == nil || m.oldValue == nil {
  11206. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11207. }
  11208. oldValue, err := m.oldValue(ctx)
  11209. if err != nil {
  11210. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11211. }
  11212. return oldValue.DeletedAt, nil
  11213. }
  11214. // ClearDeletedAt clears the value of the "deleted_at" field.
  11215. func (m *ContactMutation) ClearDeletedAt() {
  11216. m.deleted_at = nil
  11217. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  11218. }
  11219. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11220. func (m *ContactMutation) DeletedAtCleared() bool {
  11221. _, ok := m.clearedFields[contact.FieldDeletedAt]
  11222. return ok
  11223. }
  11224. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11225. func (m *ContactMutation) ResetDeletedAt() {
  11226. m.deleted_at = nil
  11227. delete(m.clearedFields, contact.FieldDeletedAt)
  11228. }
  11229. // SetWxWxid sets the "wx_wxid" field.
  11230. func (m *ContactMutation) SetWxWxid(s string) {
  11231. m.wx_wxid = &s
  11232. }
  11233. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  11234. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  11235. v := m.wx_wxid
  11236. if v == nil {
  11237. return
  11238. }
  11239. return *v, true
  11240. }
  11241. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  11242. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11243. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11244. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  11245. if !m.op.Is(OpUpdateOne) {
  11246. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  11247. }
  11248. if m.id == nil || m.oldValue == nil {
  11249. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  11250. }
  11251. oldValue, err := m.oldValue(ctx)
  11252. if err != nil {
  11253. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  11254. }
  11255. return oldValue.WxWxid, nil
  11256. }
  11257. // ResetWxWxid resets all changes to the "wx_wxid" field.
  11258. func (m *ContactMutation) ResetWxWxid() {
  11259. m.wx_wxid = nil
  11260. }
  11261. // SetType sets the "type" field.
  11262. func (m *ContactMutation) SetType(i int) {
  11263. m._type = &i
  11264. m.add_type = nil
  11265. }
  11266. // GetType returns the value of the "type" field in the mutation.
  11267. func (m *ContactMutation) GetType() (r int, exists bool) {
  11268. v := m._type
  11269. if v == nil {
  11270. return
  11271. }
  11272. return *v, true
  11273. }
  11274. // OldType returns the old "type" field's value of the Contact entity.
  11275. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11276. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11277. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  11278. if !m.op.Is(OpUpdateOne) {
  11279. return v, errors.New("OldType is only allowed on UpdateOne operations")
  11280. }
  11281. if m.id == nil || m.oldValue == nil {
  11282. return v, errors.New("OldType requires an ID field in the mutation")
  11283. }
  11284. oldValue, err := m.oldValue(ctx)
  11285. if err != nil {
  11286. return v, fmt.Errorf("querying old value for OldType: %w", err)
  11287. }
  11288. return oldValue.Type, nil
  11289. }
  11290. // AddType adds i to the "type" field.
  11291. func (m *ContactMutation) AddType(i int) {
  11292. if m.add_type != nil {
  11293. *m.add_type += i
  11294. } else {
  11295. m.add_type = &i
  11296. }
  11297. }
  11298. // AddedType returns the value that was added to the "type" field in this mutation.
  11299. func (m *ContactMutation) AddedType() (r int, exists bool) {
  11300. v := m.add_type
  11301. if v == nil {
  11302. return
  11303. }
  11304. return *v, true
  11305. }
  11306. // ClearType clears the value of the "type" field.
  11307. func (m *ContactMutation) ClearType() {
  11308. m._type = nil
  11309. m.add_type = nil
  11310. m.clearedFields[contact.FieldType] = struct{}{}
  11311. }
  11312. // TypeCleared returns if the "type" field was cleared in this mutation.
  11313. func (m *ContactMutation) TypeCleared() bool {
  11314. _, ok := m.clearedFields[contact.FieldType]
  11315. return ok
  11316. }
  11317. // ResetType resets all changes to the "type" field.
  11318. func (m *ContactMutation) ResetType() {
  11319. m._type = nil
  11320. m.add_type = nil
  11321. delete(m.clearedFields, contact.FieldType)
  11322. }
  11323. // SetWxid sets the "wxid" field.
  11324. func (m *ContactMutation) SetWxid(s string) {
  11325. m.wxid = &s
  11326. }
  11327. // Wxid returns the value of the "wxid" field in the mutation.
  11328. func (m *ContactMutation) Wxid() (r string, exists bool) {
  11329. v := m.wxid
  11330. if v == nil {
  11331. return
  11332. }
  11333. return *v, true
  11334. }
  11335. // OldWxid returns the old "wxid" field's value of the Contact entity.
  11336. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11337. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11338. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  11339. if !m.op.Is(OpUpdateOne) {
  11340. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  11341. }
  11342. if m.id == nil || m.oldValue == nil {
  11343. return v, errors.New("OldWxid requires an ID field in the mutation")
  11344. }
  11345. oldValue, err := m.oldValue(ctx)
  11346. if err != nil {
  11347. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  11348. }
  11349. return oldValue.Wxid, nil
  11350. }
  11351. // ResetWxid resets all changes to the "wxid" field.
  11352. func (m *ContactMutation) ResetWxid() {
  11353. m.wxid = nil
  11354. }
  11355. // SetAccount sets the "account" field.
  11356. func (m *ContactMutation) SetAccount(s string) {
  11357. m.account = &s
  11358. }
  11359. // Account returns the value of the "account" field in the mutation.
  11360. func (m *ContactMutation) Account() (r string, exists bool) {
  11361. v := m.account
  11362. if v == nil {
  11363. return
  11364. }
  11365. return *v, true
  11366. }
  11367. // OldAccount returns the old "account" field's value of the Contact entity.
  11368. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11369. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11370. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  11371. if !m.op.Is(OpUpdateOne) {
  11372. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  11373. }
  11374. if m.id == nil || m.oldValue == nil {
  11375. return v, errors.New("OldAccount requires an ID field in the mutation")
  11376. }
  11377. oldValue, err := m.oldValue(ctx)
  11378. if err != nil {
  11379. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  11380. }
  11381. return oldValue.Account, nil
  11382. }
  11383. // ResetAccount resets all changes to the "account" field.
  11384. func (m *ContactMutation) ResetAccount() {
  11385. m.account = nil
  11386. }
  11387. // SetNickname sets the "nickname" field.
  11388. func (m *ContactMutation) SetNickname(s string) {
  11389. m.nickname = &s
  11390. }
  11391. // Nickname returns the value of the "nickname" field in the mutation.
  11392. func (m *ContactMutation) Nickname() (r string, exists bool) {
  11393. v := m.nickname
  11394. if v == nil {
  11395. return
  11396. }
  11397. return *v, true
  11398. }
  11399. // OldNickname returns the old "nickname" field's value of the Contact entity.
  11400. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11402. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  11403. if !m.op.Is(OpUpdateOne) {
  11404. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  11405. }
  11406. if m.id == nil || m.oldValue == nil {
  11407. return v, errors.New("OldNickname requires an ID field in the mutation")
  11408. }
  11409. oldValue, err := m.oldValue(ctx)
  11410. if err != nil {
  11411. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  11412. }
  11413. return oldValue.Nickname, nil
  11414. }
  11415. // ResetNickname resets all changes to the "nickname" field.
  11416. func (m *ContactMutation) ResetNickname() {
  11417. m.nickname = nil
  11418. }
  11419. // SetMarkname sets the "markname" field.
  11420. func (m *ContactMutation) SetMarkname(s string) {
  11421. m.markname = &s
  11422. }
  11423. // Markname returns the value of the "markname" field in the mutation.
  11424. func (m *ContactMutation) Markname() (r string, exists bool) {
  11425. v := m.markname
  11426. if v == nil {
  11427. return
  11428. }
  11429. return *v, true
  11430. }
  11431. // OldMarkname returns the old "markname" field's value of the Contact entity.
  11432. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11433. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11434. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  11435. if !m.op.Is(OpUpdateOne) {
  11436. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  11437. }
  11438. if m.id == nil || m.oldValue == nil {
  11439. return v, errors.New("OldMarkname requires an ID field in the mutation")
  11440. }
  11441. oldValue, err := m.oldValue(ctx)
  11442. if err != nil {
  11443. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  11444. }
  11445. return oldValue.Markname, nil
  11446. }
  11447. // ResetMarkname resets all changes to the "markname" field.
  11448. func (m *ContactMutation) ResetMarkname() {
  11449. m.markname = nil
  11450. }
  11451. // SetHeadimg sets the "headimg" field.
  11452. func (m *ContactMutation) SetHeadimg(s string) {
  11453. m.headimg = &s
  11454. }
  11455. // Headimg returns the value of the "headimg" field in the mutation.
  11456. func (m *ContactMutation) Headimg() (r string, exists bool) {
  11457. v := m.headimg
  11458. if v == nil {
  11459. return
  11460. }
  11461. return *v, true
  11462. }
  11463. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  11464. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11465. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11466. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  11467. if !m.op.Is(OpUpdateOne) {
  11468. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  11469. }
  11470. if m.id == nil || m.oldValue == nil {
  11471. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  11472. }
  11473. oldValue, err := m.oldValue(ctx)
  11474. if err != nil {
  11475. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  11476. }
  11477. return oldValue.Headimg, nil
  11478. }
  11479. // ResetHeadimg resets all changes to the "headimg" field.
  11480. func (m *ContactMutation) ResetHeadimg() {
  11481. m.headimg = nil
  11482. }
  11483. // SetSex sets the "sex" field.
  11484. func (m *ContactMutation) SetSex(i int) {
  11485. m.sex = &i
  11486. m.addsex = nil
  11487. }
  11488. // Sex returns the value of the "sex" field in the mutation.
  11489. func (m *ContactMutation) Sex() (r int, exists bool) {
  11490. v := m.sex
  11491. if v == nil {
  11492. return
  11493. }
  11494. return *v, true
  11495. }
  11496. // OldSex returns the old "sex" field's value of the Contact entity.
  11497. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11498. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11499. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  11500. if !m.op.Is(OpUpdateOne) {
  11501. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  11502. }
  11503. if m.id == nil || m.oldValue == nil {
  11504. return v, errors.New("OldSex requires an ID field in the mutation")
  11505. }
  11506. oldValue, err := m.oldValue(ctx)
  11507. if err != nil {
  11508. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  11509. }
  11510. return oldValue.Sex, nil
  11511. }
  11512. // AddSex adds i to the "sex" field.
  11513. func (m *ContactMutation) AddSex(i int) {
  11514. if m.addsex != nil {
  11515. *m.addsex += i
  11516. } else {
  11517. m.addsex = &i
  11518. }
  11519. }
  11520. // AddedSex returns the value that was added to the "sex" field in this mutation.
  11521. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  11522. v := m.addsex
  11523. if v == nil {
  11524. return
  11525. }
  11526. return *v, true
  11527. }
  11528. // ResetSex resets all changes to the "sex" field.
  11529. func (m *ContactMutation) ResetSex() {
  11530. m.sex = nil
  11531. m.addsex = nil
  11532. }
  11533. // SetStarrole sets the "starrole" field.
  11534. func (m *ContactMutation) SetStarrole(s string) {
  11535. m.starrole = &s
  11536. }
  11537. // Starrole returns the value of the "starrole" field in the mutation.
  11538. func (m *ContactMutation) Starrole() (r string, exists bool) {
  11539. v := m.starrole
  11540. if v == nil {
  11541. return
  11542. }
  11543. return *v, true
  11544. }
  11545. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  11546. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11547. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11548. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  11549. if !m.op.Is(OpUpdateOne) {
  11550. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  11551. }
  11552. if m.id == nil || m.oldValue == nil {
  11553. return v, errors.New("OldStarrole requires an ID field in the mutation")
  11554. }
  11555. oldValue, err := m.oldValue(ctx)
  11556. if err != nil {
  11557. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  11558. }
  11559. return oldValue.Starrole, nil
  11560. }
  11561. // ResetStarrole resets all changes to the "starrole" field.
  11562. func (m *ContactMutation) ResetStarrole() {
  11563. m.starrole = nil
  11564. }
  11565. // SetDontseeit sets the "dontseeit" field.
  11566. func (m *ContactMutation) SetDontseeit(i int) {
  11567. m.dontseeit = &i
  11568. m.adddontseeit = nil
  11569. }
  11570. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  11571. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  11572. v := m.dontseeit
  11573. if v == nil {
  11574. return
  11575. }
  11576. return *v, true
  11577. }
  11578. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  11579. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11580. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11581. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  11582. if !m.op.Is(OpUpdateOne) {
  11583. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  11584. }
  11585. if m.id == nil || m.oldValue == nil {
  11586. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  11587. }
  11588. oldValue, err := m.oldValue(ctx)
  11589. if err != nil {
  11590. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  11591. }
  11592. return oldValue.Dontseeit, nil
  11593. }
  11594. // AddDontseeit adds i to the "dontseeit" field.
  11595. func (m *ContactMutation) AddDontseeit(i int) {
  11596. if m.adddontseeit != nil {
  11597. *m.adddontseeit += i
  11598. } else {
  11599. m.adddontseeit = &i
  11600. }
  11601. }
  11602. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  11603. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  11604. v := m.adddontseeit
  11605. if v == nil {
  11606. return
  11607. }
  11608. return *v, true
  11609. }
  11610. // ResetDontseeit resets all changes to the "dontseeit" field.
  11611. func (m *ContactMutation) ResetDontseeit() {
  11612. m.dontseeit = nil
  11613. m.adddontseeit = nil
  11614. }
  11615. // SetDontseeme sets the "dontseeme" field.
  11616. func (m *ContactMutation) SetDontseeme(i int) {
  11617. m.dontseeme = &i
  11618. m.adddontseeme = nil
  11619. }
  11620. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  11621. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  11622. v := m.dontseeme
  11623. if v == nil {
  11624. return
  11625. }
  11626. return *v, true
  11627. }
  11628. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  11629. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11630. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11631. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  11632. if !m.op.Is(OpUpdateOne) {
  11633. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  11634. }
  11635. if m.id == nil || m.oldValue == nil {
  11636. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  11637. }
  11638. oldValue, err := m.oldValue(ctx)
  11639. if err != nil {
  11640. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  11641. }
  11642. return oldValue.Dontseeme, nil
  11643. }
  11644. // AddDontseeme adds i to the "dontseeme" field.
  11645. func (m *ContactMutation) AddDontseeme(i int) {
  11646. if m.adddontseeme != nil {
  11647. *m.adddontseeme += i
  11648. } else {
  11649. m.adddontseeme = &i
  11650. }
  11651. }
  11652. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  11653. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  11654. v := m.adddontseeme
  11655. if v == nil {
  11656. return
  11657. }
  11658. return *v, true
  11659. }
  11660. // ResetDontseeme resets all changes to the "dontseeme" field.
  11661. func (m *ContactMutation) ResetDontseeme() {
  11662. m.dontseeme = nil
  11663. m.adddontseeme = nil
  11664. }
  11665. // SetLag sets the "lag" field.
  11666. func (m *ContactMutation) SetLag(s string) {
  11667. m.lag = &s
  11668. }
  11669. // Lag returns the value of the "lag" field in the mutation.
  11670. func (m *ContactMutation) Lag() (r string, exists bool) {
  11671. v := m.lag
  11672. if v == nil {
  11673. return
  11674. }
  11675. return *v, true
  11676. }
  11677. // OldLag returns the old "lag" field's value of the Contact entity.
  11678. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11680. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  11681. if !m.op.Is(OpUpdateOne) {
  11682. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  11683. }
  11684. if m.id == nil || m.oldValue == nil {
  11685. return v, errors.New("OldLag requires an ID field in the mutation")
  11686. }
  11687. oldValue, err := m.oldValue(ctx)
  11688. if err != nil {
  11689. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  11690. }
  11691. return oldValue.Lag, nil
  11692. }
  11693. // ResetLag resets all changes to the "lag" field.
  11694. func (m *ContactMutation) ResetLag() {
  11695. m.lag = nil
  11696. }
  11697. // SetGid sets the "gid" field.
  11698. func (m *ContactMutation) SetGid(s string) {
  11699. m.gid = &s
  11700. }
  11701. // Gid returns the value of the "gid" field in the mutation.
  11702. func (m *ContactMutation) Gid() (r string, exists bool) {
  11703. v := m.gid
  11704. if v == nil {
  11705. return
  11706. }
  11707. return *v, true
  11708. }
  11709. // OldGid returns the old "gid" field's value of the Contact entity.
  11710. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11711. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11712. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  11713. if !m.op.Is(OpUpdateOne) {
  11714. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  11715. }
  11716. if m.id == nil || m.oldValue == nil {
  11717. return v, errors.New("OldGid requires an ID field in the mutation")
  11718. }
  11719. oldValue, err := m.oldValue(ctx)
  11720. if err != nil {
  11721. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  11722. }
  11723. return oldValue.Gid, nil
  11724. }
  11725. // ResetGid resets all changes to the "gid" field.
  11726. func (m *ContactMutation) ResetGid() {
  11727. m.gid = nil
  11728. }
  11729. // SetGname sets the "gname" field.
  11730. func (m *ContactMutation) SetGname(s string) {
  11731. m.gname = &s
  11732. }
  11733. // Gname returns the value of the "gname" field in the mutation.
  11734. func (m *ContactMutation) Gname() (r string, exists bool) {
  11735. v := m.gname
  11736. if v == nil {
  11737. return
  11738. }
  11739. return *v, true
  11740. }
  11741. // OldGname returns the old "gname" field's value of the Contact entity.
  11742. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11743. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11744. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  11745. if !m.op.Is(OpUpdateOne) {
  11746. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  11747. }
  11748. if m.id == nil || m.oldValue == nil {
  11749. return v, errors.New("OldGname requires an ID field in the mutation")
  11750. }
  11751. oldValue, err := m.oldValue(ctx)
  11752. if err != nil {
  11753. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  11754. }
  11755. return oldValue.Gname, nil
  11756. }
  11757. // ResetGname resets all changes to the "gname" field.
  11758. func (m *ContactMutation) ResetGname() {
  11759. m.gname = nil
  11760. }
  11761. // SetV3 sets the "v3" field.
  11762. func (m *ContactMutation) SetV3(s string) {
  11763. m.v3 = &s
  11764. }
  11765. // V3 returns the value of the "v3" field in the mutation.
  11766. func (m *ContactMutation) V3() (r string, exists bool) {
  11767. v := m.v3
  11768. if v == nil {
  11769. return
  11770. }
  11771. return *v, true
  11772. }
  11773. // OldV3 returns the old "v3" field's value of the Contact entity.
  11774. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11775. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11776. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  11777. if !m.op.Is(OpUpdateOne) {
  11778. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  11779. }
  11780. if m.id == nil || m.oldValue == nil {
  11781. return v, errors.New("OldV3 requires an ID field in the mutation")
  11782. }
  11783. oldValue, err := m.oldValue(ctx)
  11784. if err != nil {
  11785. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  11786. }
  11787. return oldValue.V3, nil
  11788. }
  11789. // ResetV3 resets all changes to the "v3" field.
  11790. func (m *ContactMutation) ResetV3() {
  11791. m.v3 = nil
  11792. }
  11793. // SetOrganizationID sets the "organization_id" field.
  11794. func (m *ContactMutation) SetOrganizationID(u uint64) {
  11795. m.organization_id = &u
  11796. m.addorganization_id = nil
  11797. }
  11798. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11799. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  11800. v := m.organization_id
  11801. if v == nil {
  11802. return
  11803. }
  11804. return *v, true
  11805. }
  11806. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  11807. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11808. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11809. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11810. if !m.op.Is(OpUpdateOne) {
  11811. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11812. }
  11813. if m.id == nil || m.oldValue == nil {
  11814. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11815. }
  11816. oldValue, err := m.oldValue(ctx)
  11817. if err != nil {
  11818. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11819. }
  11820. return oldValue.OrganizationID, nil
  11821. }
  11822. // AddOrganizationID adds u to the "organization_id" field.
  11823. func (m *ContactMutation) AddOrganizationID(u int64) {
  11824. if m.addorganization_id != nil {
  11825. *m.addorganization_id += u
  11826. } else {
  11827. m.addorganization_id = &u
  11828. }
  11829. }
  11830. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11831. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  11832. v := m.addorganization_id
  11833. if v == nil {
  11834. return
  11835. }
  11836. return *v, true
  11837. }
  11838. // ClearOrganizationID clears the value of the "organization_id" field.
  11839. func (m *ContactMutation) ClearOrganizationID() {
  11840. m.organization_id = nil
  11841. m.addorganization_id = nil
  11842. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  11843. }
  11844. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  11845. func (m *ContactMutation) OrganizationIDCleared() bool {
  11846. _, ok := m.clearedFields[contact.FieldOrganizationID]
  11847. return ok
  11848. }
  11849. // ResetOrganizationID resets all changes to the "organization_id" field.
  11850. func (m *ContactMutation) ResetOrganizationID() {
  11851. m.organization_id = nil
  11852. m.addorganization_id = nil
  11853. delete(m.clearedFields, contact.FieldOrganizationID)
  11854. }
  11855. // SetCtype sets the "ctype" field.
  11856. func (m *ContactMutation) SetCtype(u uint64) {
  11857. m.ctype = &u
  11858. m.addctype = nil
  11859. }
  11860. // Ctype returns the value of the "ctype" field in the mutation.
  11861. func (m *ContactMutation) Ctype() (r uint64, exists bool) {
  11862. v := m.ctype
  11863. if v == nil {
  11864. return
  11865. }
  11866. return *v, true
  11867. }
  11868. // OldCtype returns the old "ctype" field's value of the Contact entity.
  11869. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11870. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11871. func (m *ContactMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  11872. if !m.op.Is(OpUpdateOne) {
  11873. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  11874. }
  11875. if m.id == nil || m.oldValue == nil {
  11876. return v, errors.New("OldCtype requires an ID field in the mutation")
  11877. }
  11878. oldValue, err := m.oldValue(ctx)
  11879. if err != nil {
  11880. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  11881. }
  11882. return oldValue.Ctype, nil
  11883. }
  11884. // AddCtype adds u to the "ctype" field.
  11885. func (m *ContactMutation) AddCtype(u int64) {
  11886. if m.addctype != nil {
  11887. *m.addctype += u
  11888. } else {
  11889. m.addctype = &u
  11890. }
  11891. }
  11892. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  11893. func (m *ContactMutation) AddedCtype() (r int64, exists bool) {
  11894. v := m.addctype
  11895. if v == nil {
  11896. return
  11897. }
  11898. return *v, true
  11899. }
  11900. // ResetCtype resets all changes to the "ctype" field.
  11901. func (m *ContactMutation) ResetCtype() {
  11902. m.ctype = nil
  11903. m.addctype = nil
  11904. }
  11905. // SetCage sets the "cage" field.
  11906. func (m *ContactMutation) SetCage(i int) {
  11907. m.cage = &i
  11908. m.addcage = nil
  11909. }
  11910. // Cage returns the value of the "cage" field in the mutation.
  11911. func (m *ContactMutation) Cage() (r int, exists bool) {
  11912. v := m.cage
  11913. if v == nil {
  11914. return
  11915. }
  11916. return *v, true
  11917. }
  11918. // OldCage returns the old "cage" field's value of the Contact entity.
  11919. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11920. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11921. func (m *ContactMutation) OldCage(ctx context.Context) (v int, err error) {
  11922. if !m.op.Is(OpUpdateOne) {
  11923. return v, errors.New("OldCage is only allowed on UpdateOne operations")
  11924. }
  11925. if m.id == nil || m.oldValue == nil {
  11926. return v, errors.New("OldCage requires an ID field in the mutation")
  11927. }
  11928. oldValue, err := m.oldValue(ctx)
  11929. if err != nil {
  11930. return v, fmt.Errorf("querying old value for OldCage: %w", err)
  11931. }
  11932. return oldValue.Cage, nil
  11933. }
  11934. // AddCage adds i to the "cage" field.
  11935. func (m *ContactMutation) AddCage(i int) {
  11936. if m.addcage != nil {
  11937. *m.addcage += i
  11938. } else {
  11939. m.addcage = &i
  11940. }
  11941. }
  11942. // AddedCage returns the value that was added to the "cage" field in this mutation.
  11943. func (m *ContactMutation) AddedCage() (r int, exists bool) {
  11944. v := m.addcage
  11945. if v == nil {
  11946. return
  11947. }
  11948. return *v, true
  11949. }
  11950. // ResetCage resets all changes to the "cage" field.
  11951. func (m *ContactMutation) ResetCage() {
  11952. m.cage = nil
  11953. m.addcage = nil
  11954. }
  11955. // SetCname sets the "cname" field.
  11956. func (m *ContactMutation) SetCname(s string) {
  11957. m.cname = &s
  11958. }
  11959. // Cname returns the value of the "cname" field in the mutation.
  11960. func (m *ContactMutation) Cname() (r string, exists bool) {
  11961. v := m.cname
  11962. if v == nil {
  11963. return
  11964. }
  11965. return *v, true
  11966. }
  11967. // OldCname returns the old "cname" field's value of the Contact entity.
  11968. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11969. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11970. func (m *ContactMutation) OldCname(ctx context.Context) (v string, err error) {
  11971. if !m.op.Is(OpUpdateOne) {
  11972. return v, errors.New("OldCname is only allowed on UpdateOne operations")
  11973. }
  11974. if m.id == nil || m.oldValue == nil {
  11975. return v, errors.New("OldCname requires an ID field in the mutation")
  11976. }
  11977. oldValue, err := m.oldValue(ctx)
  11978. if err != nil {
  11979. return v, fmt.Errorf("querying old value for OldCname: %w", err)
  11980. }
  11981. return oldValue.Cname, nil
  11982. }
  11983. // ResetCname resets all changes to the "cname" field.
  11984. func (m *ContactMutation) ResetCname() {
  11985. m.cname = nil
  11986. }
  11987. // SetCarea sets the "carea" field.
  11988. func (m *ContactMutation) SetCarea(s string) {
  11989. m.carea = &s
  11990. }
  11991. // Carea returns the value of the "carea" field in the mutation.
  11992. func (m *ContactMutation) Carea() (r string, exists bool) {
  11993. v := m.carea
  11994. if v == nil {
  11995. return
  11996. }
  11997. return *v, true
  11998. }
  11999. // OldCarea returns the old "carea" field's value of the Contact entity.
  12000. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12001. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12002. func (m *ContactMutation) OldCarea(ctx context.Context) (v string, err error) {
  12003. if !m.op.Is(OpUpdateOne) {
  12004. return v, errors.New("OldCarea is only allowed on UpdateOne operations")
  12005. }
  12006. if m.id == nil || m.oldValue == nil {
  12007. return v, errors.New("OldCarea requires an ID field in the mutation")
  12008. }
  12009. oldValue, err := m.oldValue(ctx)
  12010. if err != nil {
  12011. return v, fmt.Errorf("querying old value for OldCarea: %w", err)
  12012. }
  12013. return oldValue.Carea, nil
  12014. }
  12015. // ResetCarea resets all changes to the "carea" field.
  12016. func (m *ContactMutation) ResetCarea() {
  12017. m.carea = nil
  12018. }
  12019. // SetCbirthday sets the "cbirthday" field.
  12020. func (m *ContactMutation) SetCbirthday(s string) {
  12021. m.cbirthday = &s
  12022. }
  12023. // Cbirthday returns the value of the "cbirthday" field in the mutation.
  12024. func (m *ContactMutation) Cbirthday() (r string, exists bool) {
  12025. v := m.cbirthday
  12026. if v == nil {
  12027. return
  12028. }
  12029. return *v, true
  12030. }
  12031. // OldCbirthday returns the old "cbirthday" field's value of the Contact entity.
  12032. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12033. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12034. func (m *ContactMutation) OldCbirthday(ctx context.Context) (v string, err error) {
  12035. if !m.op.Is(OpUpdateOne) {
  12036. return v, errors.New("OldCbirthday is only allowed on UpdateOne operations")
  12037. }
  12038. if m.id == nil || m.oldValue == nil {
  12039. return v, errors.New("OldCbirthday requires an ID field in the mutation")
  12040. }
  12041. oldValue, err := m.oldValue(ctx)
  12042. if err != nil {
  12043. return v, fmt.Errorf("querying old value for OldCbirthday: %w", err)
  12044. }
  12045. return oldValue.Cbirthday, nil
  12046. }
  12047. // ResetCbirthday resets all changes to the "cbirthday" field.
  12048. func (m *ContactMutation) ResetCbirthday() {
  12049. m.cbirthday = nil
  12050. }
  12051. // SetCbirtharea sets the "cbirtharea" field.
  12052. func (m *ContactMutation) SetCbirtharea(s string) {
  12053. m.cbirtharea = &s
  12054. }
  12055. // Cbirtharea returns the value of the "cbirtharea" field in the mutation.
  12056. func (m *ContactMutation) Cbirtharea() (r string, exists bool) {
  12057. v := m.cbirtharea
  12058. if v == nil {
  12059. return
  12060. }
  12061. return *v, true
  12062. }
  12063. // OldCbirtharea returns the old "cbirtharea" field's value of the Contact entity.
  12064. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12065. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12066. func (m *ContactMutation) OldCbirtharea(ctx context.Context) (v string, err error) {
  12067. if !m.op.Is(OpUpdateOne) {
  12068. return v, errors.New("OldCbirtharea is only allowed on UpdateOne operations")
  12069. }
  12070. if m.id == nil || m.oldValue == nil {
  12071. return v, errors.New("OldCbirtharea requires an ID field in the mutation")
  12072. }
  12073. oldValue, err := m.oldValue(ctx)
  12074. if err != nil {
  12075. return v, fmt.Errorf("querying old value for OldCbirtharea: %w", err)
  12076. }
  12077. return oldValue.Cbirtharea, nil
  12078. }
  12079. // ResetCbirtharea resets all changes to the "cbirtharea" field.
  12080. func (m *ContactMutation) ResetCbirtharea() {
  12081. m.cbirtharea = nil
  12082. }
  12083. // SetCidcardNo sets the "cidcard_no" field.
  12084. func (m *ContactMutation) SetCidcardNo(s string) {
  12085. m.cidcard_no = &s
  12086. }
  12087. // CidcardNo returns the value of the "cidcard_no" field in the mutation.
  12088. func (m *ContactMutation) CidcardNo() (r string, exists bool) {
  12089. v := m.cidcard_no
  12090. if v == nil {
  12091. return
  12092. }
  12093. return *v, true
  12094. }
  12095. // OldCidcardNo returns the old "cidcard_no" field's value of the Contact entity.
  12096. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12097. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12098. func (m *ContactMutation) OldCidcardNo(ctx context.Context) (v string, err error) {
  12099. if !m.op.Is(OpUpdateOne) {
  12100. return v, errors.New("OldCidcardNo is only allowed on UpdateOne operations")
  12101. }
  12102. if m.id == nil || m.oldValue == nil {
  12103. return v, errors.New("OldCidcardNo requires an ID field in the mutation")
  12104. }
  12105. oldValue, err := m.oldValue(ctx)
  12106. if err != nil {
  12107. return v, fmt.Errorf("querying old value for OldCidcardNo: %w", err)
  12108. }
  12109. return oldValue.CidcardNo, nil
  12110. }
  12111. // ResetCidcardNo resets all changes to the "cidcard_no" field.
  12112. func (m *ContactMutation) ResetCidcardNo() {
  12113. m.cidcard_no = nil
  12114. }
  12115. // SetCtitle sets the "ctitle" field.
  12116. func (m *ContactMutation) SetCtitle(s string) {
  12117. m.ctitle = &s
  12118. }
  12119. // Ctitle returns the value of the "ctitle" field in the mutation.
  12120. func (m *ContactMutation) Ctitle() (r string, exists bool) {
  12121. v := m.ctitle
  12122. if v == nil {
  12123. return
  12124. }
  12125. return *v, true
  12126. }
  12127. // OldCtitle returns the old "ctitle" field's value of the Contact entity.
  12128. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12129. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12130. func (m *ContactMutation) OldCtitle(ctx context.Context) (v string, err error) {
  12131. if !m.op.Is(OpUpdateOne) {
  12132. return v, errors.New("OldCtitle is only allowed on UpdateOne operations")
  12133. }
  12134. if m.id == nil || m.oldValue == nil {
  12135. return v, errors.New("OldCtitle requires an ID field in the mutation")
  12136. }
  12137. oldValue, err := m.oldValue(ctx)
  12138. if err != nil {
  12139. return v, fmt.Errorf("querying old value for OldCtitle: %w", err)
  12140. }
  12141. return oldValue.Ctitle, nil
  12142. }
  12143. // ResetCtitle resets all changes to the "ctitle" field.
  12144. func (m *ContactMutation) ResetCtitle() {
  12145. m.ctitle = nil
  12146. }
  12147. // SetCc sets the "cc" field.
  12148. func (m *ContactMutation) SetCc(s string) {
  12149. m.cc = &s
  12150. }
  12151. // Cc returns the value of the "cc" field in the mutation.
  12152. func (m *ContactMutation) Cc() (r string, exists bool) {
  12153. v := m.cc
  12154. if v == nil {
  12155. return
  12156. }
  12157. return *v, true
  12158. }
  12159. // OldCc returns the old "cc" field's value of the Contact entity.
  12160. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12161. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12162. func (m *ContactMutation) OldCc(ctx context.Context) (v string, err error) {
  12163. if !m.op.Is(OpUpdateOne) {
  12164. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  12165. }
  12166. if m.id == nil || m.oldValue == nil {
  12167. return v, errors.New("OldCc requires an ID field in the mutation")
  12168. }
  12169. oldValue, err := m.oldValue(ctx)
  12170. if err != nil {
  12171. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  12172. }
  12173. return oldValue.Cc, nil
  12174. }
  12175. // ResetCc resets all changes to the "cc" field.
  12176. func (m *ContactMutation) ResetCc() {
  12177. m.cc = nil
  12178. }
  12179. // SetPhone sets the "phone" field.
  12180. func (m *ContactMutation) SetPhone(s string) {
  12181. m.phone = &s
  12182. }
  12183. // Phone returns the value of the "phone" field in the mutation.
  12184. func (m *ContactMutation) Phone() (r string, exists bool) {
  12185. v := m.phone
  12186. if v == nil {
  12187. return
  12188. }
  12189. return *v, true
  12190. }
  12191. // OldPhone returns the old "phone" field's value of the Contact entity.
  12192. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12193. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12194. func (m *ContactMutation) OldPhone(ctx context.Context) (v string, err error) {
  12195. if !m.op.Is(OpUpdateOne) {
  12196. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  12197. }
  12198. if m.id == nil || m.oldValue == nil {
  12199. return v, errors.New("OldPhone requires an ID field in the mutation")
  12200. }
  12201. oldValue, err := m.oldValue(ctx)
  12202. if err != nil {
  12203. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  12204. }
  12205. return oldValue.Phone, nil
  12206. }
  12207. // ResetPhone resets all changes to the "phone" field.
  12208. func (m *ContactMutation) ResetPhone() {
  12209. m.phone = nil
  12210. }
  12211. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  12212. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  12213. if m.contact_relationships == nil {
  12214. m.contact_relationships = make(map[uint64]struct{})
  12215. }
  12216. for i := range ids {
  12217. m.contact_relationships[ids[i]] = struct{}{}
  12218. }
  12219. }
  12220. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  12221. func (m *ContactMutation) ClearContactRelationships() {
  12222. m.clearedcontact_relationships = true
  12223. }
  12224. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  12225. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  12226. return m.clearedcontact_relationships
  12227. }
  12228. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  12229. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  12230. if m.removedcontact_relationships == nil {
  12231. m.removedcontact_relationships = make(map[uint64]struct{})
  12232. }
  12233. for i := range ids {
  12234. delete(m.contact_relationships, ids[i])
  12235. m.removedcontact_relationships[ids[i]] = struct{}{}
  12236. }
  12237. }
  12238. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  12239. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  12240. for id := range m.removedcontact_relationships {
  12241. ids = append(ids, id)
  12242. }
  12243. return
  12244. }
  12245. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  12246. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  12247. for id := range m.contact_relationships {
  12248. ids = append(ids, id)
  12249. }
  12250. return
  12251. }
  12252. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  12253. func (m *ContactMutation) ResetContactRelationships() {
  12254. m.contact_relationships = nil
  12255. m.clearedcontact_relationships = false
  12256. m.removedcontact_relationships = nil
  12257. }
  12258. // AddContactFieldIDs adds the "contact_fields" edge to the ContactField entity by ids.
  12259. func (m *ContactMutation) AddContactFieldIDs(ids ...uint64) {
  12260. if m.contact_fields == nil {
  12261. m.contact_fields = make(map[uint64]struct{})
  12262. }
  12263. for i := range ids {
  12264. m.contact_fields[ids[i]] = struct{}{}
  12265. }
  12266. }
  12267. // ClearContactFields clears the "contact_fields" edge to the ContactField entity.
  12268. func (m *ContactMutation) ClearContactFields() {
  12269. m.clearedcontact_fields = true
  12270. }
  12271. // ContactFieldsCleared reports if the "contact_fields" edge to the ContactField entity was cleared.
  12272. func (m *ContactMutation) ContactFieldsCleared() bool {
  12273. return m.clearedcontact_fields
  12274. }
  12275. // RemoveContactFieldIDs removes the "contact_fields" edge to the ContactField entity by IDs.
  12276. func (m *ContactMutation) RemoveContactFieldIDs(ids ...uint64) {
  12277. if m.removedcontact_fields == nil {
  12278. m.removedcontact_fields = make(map[uint64]struct{})
  12279. }
  12280. for i := range ids {
  12281. delete(m.contact_fields, ids[i])
  12282. m.removedcontact_fields[ids[i]] = struct{}{}
  12283. }
  12284. }
  12285. // RemovedContactFields returns the removed IDs of the "contact_fields" edge to the ContactField entity.
  12286. func (m *ContactMutation) RemovedContactFieldsIDs() (ids []uint64) {
  12287. for id := range m.removedcontact_fields {
  12288. ids = append(ids, id)
  12289. }
  12290. return
  12291. }
  12292. // ContactFieldsIDs returns the "contact_fields" edge IDs in the mutation.
  12293. func (m *ContactMutation) ContactFieldsIDs() (ids []uint64) {
  12294. for id := range m.contact_fields {
  12295. ids = append(ids, id)
  12296. }
  12297. return
  12298. }
  12299. // ResetContactFields resets all changes to the "contact_fields" edge.
  12300. func (m *ContactMutation) ResetContactFields() {
  12301. m.contact_fields = nil
  12302. m.clearedcontact_fields = false
  12303. m.removedcontact_fields = nil
  12304. }
  12305. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  12306. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  12307. if m.contact_messages == nil {
  12308. m.contact_messages = make(map[uint64]struct{})
  12309. }
  12310. for i := range ids {
  12311. m.contact_messages[ids[i]] = struct{}{}
  12312. }
  12313. }
  12314. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  12315. func (m *ContactMutation) ClearContactMessages() {
  12316. m.clearedcontact_messages = true
  12317. }
  12318. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  12319. func (m *ContactMutation) ContactMessagesCleared() bool {
  12320. return m.clearedcontact_messages
  12321. }
  12322. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  12323. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  12324. if m.removedcontact_messages == nil {
  12325. m.removedcontact_messages = make(map[uint64]struct{})
  12326. }
  12327. for i := range ids {
  12328. delete(m.contact_messages, ids[i])
  12329. m.removedcontact_messages[ids[i]] = struct{}{}
  12330. }
  12331. }
  12332. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  12333. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  12334. for id := range m.removedcontact_messages {
  12335. ids = append(ids, id)
  12336. }
  12337. return
  12338. }
  12339. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  12340. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  12341. for id := range m.contact_messages {
  12342. ids = append(ids, id)
  12343. }
  12344. return
  12345. }
  12346. // ResetContactMessages resets all changes to the "contact_messages" edge.
  12347. func (m *ContactMutation) ResetContactMessages() {
  12348. m.contact_messages = nil
  12349. m.clearedcontact_messages = false
  12350. m.removedcontact_messages = nil
  12351. }
  12352. // Where appends a list predicates to the ContactMutation builder.
  12353. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  12354. m.predicates = append(m.predicates, ps...)
  12355. }
  12356. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  12357. // users can use type-assertion to append predicates that do not depend on any generated package.
  12358. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  12359. p := make([]predicate.Contact, len(ps))
  12360. for i := range ps {
  12361. p[i] = ps[i]
  12362. }
  12363. m.Where(p...)
  12364. }
  12365. // Op returns the operation name.
  12366. func (m *ContactMutation) Op() Op {
  12367. return m.op
  12368. }
  12369. // SetOp allows setting the mutation operation.
  12370. func (m *ContactMutation) SetOp(op Op) {
  12371. m.op = op
  12372. }
  12373. // Type returns the node type of this mutation (Contact).
  12374. func (m *ContactMutation) Type() string {
  12375. return m.typ
  12376. }
  12377. // Fields returns all fields that were changed during this mutation. Note that in
  12378. // order to get all numeric fields that were incremented/decremented, call
  12379. // AddedFields().
  12380. func (m *ContactMutation) Fields() []string {
  12381. fields := make([]string, 0, 30)
  12382. if m.created_at != nil {
  12383. fields = append(fields, contact.FieldCreatedAt)
  12384. }
  12385. if m.updated_at != nil {
  12386. fields = append(fields, contact.FieldUpdatedAt)
  12387. }
  12388. if m.status != nil {
  12389. fields = append(fields, contact.FieldStatus)
  12390. }
  12391. if m.deleted_at != nil {
  12392. fields = append(fields, contact.FieldDeletedAt)
  12393. }
  12394. if m.wx_wxid != nil {
  12395. fields = append(fields, contact.FieldWxWxid)
  12396. }
  12397. if m._type != nil {
  12398. fields = append(fields, contact.FieldType)
  12399. }
  12400. if m.wxid != nil {
  12401. fields = append(fields, contact.FieldWxid)
  12402. }
  12403. if m.account != nil {
  12404. fields = append(fields, contact.FieldAccount)
  12405. }
  12406. if m.nickname != nil {
  12407. fields = append(fields, contact.FieldNickname)
  12408. }
  12409. if m.markname != nil {
  12410. fields = append(fields, contact.FieldMarkname)
  12411. }
  12412. if m.headimg != nil {
  12413. fields = append(fields, contact.FieldHeadimg)
  12414. }
  12415. if m.sex != nil {
  12416. fields = append(fields, contact.FieldSex)
  12417. }
  12418. if m.starrole != nil {
  12419. fields = append(fields, contact.FieldStarrole)
  12420. }
  12421. if m.dontseeit != nil {
  12422. fields = append(fields, contact.FieldDontseeit)
  12423. }
  12424. if m.dontseeme != nil {
  12425. fields = append(fields, contact.FieldDontseeme)
  12426. }
  12427. if m.lag != nil {
  12428. fields = append(fields, contact.FieldLag)
  12429. }
  12430. if m.gid != nil {
  12431. fields = append(fields, contact.FieldGid)
  12432. }
  12433. if m.gname != nil {
  12434. fields = append(fields, contact.FieldGname)
  12435. }
  12436. if m.v3 != nil {
  12437. fields = append(fields, contact.FieldV3)
  12438. }
  12439. if m.organization_id != nil {
  12440. fields = append(fields, contact.FieldOrganizationID)
  12441. }
  12442. if m.ctype != nil {
  12443. fields = append(fields, contact.FieldCtype)
  12444. }
  12445. if m.cage != nil {
  12446. fields = append(fields, contact.FieldCage)
  12447. }
  12448. if m.cname != nil {
  12449. fields = append(fields, contact.FieldCname)
  12450. }
  12451. if m.carea != nil {
  12452. fields = append(fields, contact.FieldCarea)
  12453. }
  12454. if m.cbirthday != nil {
  12455. fields = append(fields, contact.FieldCbirthday)
  12456. }
  12457. if m.cbirtharea != nil {
  12458. fields = append(fields, contact.FieldCbirtharea)
  12459. }
  12460. if m.cidcard_no != nil {
  12461. fields = append(fields, contact.FieldCidcardNo)
  12462. }
  12463. if m.ctitle != nil {
  12464. fields = append(fields, contact.FieldCtitle)
  12465. }
  12466. if m.cc != nil {
  12467. fields = append(fields, contact.FieldCc)
  12468. }
  12469. if m.phone != nil {
  12470. fields = append(fields, contact.FieldPhone)
  12471. }
  12472. return fields
  12473. }
  12474. // Field returns the value of a field with the given name. The second boolean
  12475. // return value indicates that this field was not set, or was not defined in the
  12476. // schema.
  12477. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  12478. switch name {
  12479. case contact.FieldCreatedAt:
  12480. return m.CreatedAt()
  12481. case contact.FieldUpdatedAt:
  12482. return m.UpdatedAt()
  12483. case contact.FieldStatus:
  12484. return m.Status()
  12485. case contact.FieldDeletedAt:
  12486. return m.DeletedAt()
  12487. case contact.FieldWxWxid:
  12488. return m.WxWxid()
  12489. case contact.FieldType:
  12490. return m.GetType()
  12491. case contact.FieldWxid:
  12492. return m.Wxid()
  12493. case contact.FieldAccount:
  12494. return m.Account()
  12495. case contact.FieldNickname:
  12496. return m.Nickname()
  12497. case contact.FieldMarkname:
  12498. return m.Markname()
  12499. case contact.FieldHeadimg:
  12500. return m.Headimg()
  12501. case contact.FieldSex:
  12502. return m.Sex()
  12503. case contact.FieldStarrole:
  12504. return m.Starrole()
  12505. case contact.FieldDontseeit:
  12506. return m.Dontseeit()
  12507. case contact.FieldDontseeme:
  12508. return m.Dontseeme()
  12509. case contact.FieldLag:
  12510. return m.Lag()
  12511. case contact.FieldGid:
  12512. return m.Gid()
  12513. case contact.FieldGname:
  12514. return m.Gname()
  12515. case contact.FieldV3:
  12516. return m.V3()
  12517. case contact.FieldOrganizationID:
  12518. return m.OrganizationID()
  12519. case contact.FieldCtype:
  12520. return m.Ctype()
  12521. case contact.FieldCage:
  12522. return m.Cage()
  12523. case contact.FieldCname:
  12524. return m.Cname()
  12525. case contact.FieldCarea:
  12526. return m.Carea()
  12527. case contact.FieldCbirthday:
  12528. return m.Cbirthday()
  12529. case contact.FieldCbirtharea:
  12530. return m.Cbirtharea()
  12531. case contact.FieldCidcardNo:
  12532. return m.CidcardNo()
  12533. case contact.FieldCtitle:
  12534. return m.Ctitle()
  12535. case contact.FieldCc:
  12536. return m.Cc()
  12537. case contact.FieldPhone:
  12538. return m.Phone()
  12539. }
  12540. return nil, false
  12541. }
  12542. // OldField returns the old value of the field from the database. An error is
  12543. // returned if the mutation operation is not UpdateOne, or the query to the
  12544. // database failed.
  12545. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12546. switch name {
  12547. case contact.FieldCreatedAt:
  12548. return m.OldCreatedAt(ctx)
  12549. case contact.FieldUpdatedAt:
  12550. return m.OldUpdatedAt(ctx)
  12551. case contact.FieldStatus:
  12552. return m.OldStatus(ctx)
  12553. case contact.FieldDeletedAt:
  12554. return m.OldDeletedAt(ctx)
  12555. case contact.FieldWxWxid:
  12556. return m.OldWxWxid(ctx)
  12557. case contact.FieldType:
  12558. return m.OldType(ctx)
  12559. case contact.FieldWxid:
  12560. return m.OldWxid(ctx)
  12561. case contact.FieldAccount:
  12562. return m.OldAccount(ctx)
  12563. case contact.FieldNickname:
  12564. return m.OldNickname(ctx)
  12565. case contact.FieldMarkname:
  12566. return m.OldMarkname(ctx)
  12567. case contact.FieldHeadimg:
  12568. return m.OldHeadimg(ctx)
  12569. case contact.FieldSex:
  12570. return m.OldSex(ctx)
  12571. case contact.FieldStarrole:
  12572. return m.OldStarrole(ctx)
  12573. case contact.FieldDontseeit:
  12574. return m.OldDontseeit(ctx)
  12575. case contact.FieldDontseeme:
  12576. return m.OldDontseeme(ctx)
  12577. case contact.FieldLag:
  12578. return m.OldLag(ctx)
  12579. case contact.FieldGid:
  12580. return m.OldGid(ctx)
  12581. case contact.FieldGname:
  12582. return m.OldGname(ctx)
  12583. case contact.FieldV3:
  12584. return m.OldV3(ctx)
  12585. case contact.FieldOrganizationID:
  12586. return m.OldOrganizationID(ctx)
  12587. case contact.FieldCtype:
  12588. return m.OldCtype(ctx)
  12589. case contact.FieldCage:
  12590. return m.OldCage(ctx)
  12591. case contact.FieldCname:
  12592. return m.OldCname(ctx)
  12593. case contact.FieldCarea:
  12594. return m.OldCarea(ctx)
  12595. case contact.FieldCbirthday:
  12596. return m.OldCbirthday(ctx)
  12597. case contact.FieldCbirtharea:
  12598. return m.OldCbirtharea(ctx)
  12599. case contact.FieldCidcardNo:
  12600. return m.OldCidcardNo(ctx)
  12601. case contact.FieldCtitle:
  12602. return m.OldCtitle(ctx)
  12603. case contact.FieldCc:
  12604. return m.OldCc(ctx)
  12605. case contact.FieldPhone:
  12606. return m.OldPhone(ctx)
  12607. }
  12608. return nil, fmt.Errorf("unknown Contact field %s", name)
  12609. }
  12610. // SetField sets the value of a field with the given name. It returns an error if
  12611. // the field is not defined in the schema, or if the type mismatched the field
  12612. // type.
  12613. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  12614. switch name {
  12615. case contact.FieldCreatedAt:
  12616. v, ok := value.(time.Time)
  12617. if !ok {
  12618. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12619. }
  12620. m.SetCreatedAt(v)
  12621. return nil
  12622. case contact.FieldUpdatedAt:
  12623. v, ok := value.(time.Time)
  12624. if !ok {
  12625. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12626. }
  12627. m.SetUpdatedAt(v)
  12628. return nil
  12629. case contact.FieldStatus:
  12630. v, ok := value.(uint8)
  12631. if !ok {
  12632. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12633. }
  12634. m.SetStatus(v)
  12635. return nil
  12636. case contact.FieldDeletedAt:
  12637. v, ok := value.(time.Time)
  12638. if !ok {
  12639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12640. }
  12641. m.SetDeletedAt(v)
  12642. return nil
  12643. case contact.FieldWxWxid:
  12644. v, ok := value.(string)
  12645. if !ok {
  12646. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12647. }
  12648. m.SetWxWxid(v)
  12649. return nil
  12650. case contact.FieldType:
  12651. v, ok := value.(int)
  12652. if !ok {
  12653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12654. }
  12655. m.SetType(v)
  12656. return nil
  12657. case contact.FieldWxid:
  12658. v, ok := value.(string)
  12659. if !ok {
  12660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12661. }
  12662. m.SetWxid(v)
  12663. return nil
  12664. case contact.FieldAccount:
  12665. v, ok := value.(string)
  12666. if !ok {
  12667. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12668. }
  12669. m.SetAccount(v)
  12670. return nil
  12671. case contact.FieldNickname:
  12672. v, ok := value.(string)
  12673. if !ok {
  12674. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12675. }
  12676. m.SetNickname(v)
  12677. return nil
  12678. case contact.FieldMarkname:
  12679. v, ok := value.(string)
  12680. if !ok {
  12681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12682. }
  12683. m.SetMarkname(v)
  12684. return nil
  12685. case contact.FieldHeadimg:
  12686. v, ok := value.(string)
  12687. if !ok {
  12688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12689. }
  12690. m.SetHeadimg(v)
  12691. return nil
  12692. case contact.FieldSex:
  12693. v, ok := value.(int)
  12694. if !ok {
  12695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12696. }
  12697. m.SetSex(v)
  12698. return nil
  12699. case contact.FieldStarrole:
  12700. v, ok := value.(string)
  12701. if !ok {
  12702. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12703. }
  12704. m.SetStarrole(v)
  12705. return nil
  12706. case contact.FieldDontseeit:
  12707. v, ok := value.(int)
  12708. if !ok {
  12709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12710. }
  12711. m.SetDontseeit(v)
  12712. return nil
  12713. case contact.FieldDontseeme:
  12714. v, ok := value.(int)
  12715. if !ok {
  12716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12717. }
  12718. m.SetDontseeme(v)
  12719. return nil
  12720. case contact.FieldLag:
  12721. v, ok := value.(string)
  12722. if !ok {
  12723. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12724. }
  12725. m.SetLag(v)
  12726. return nil
  12727. case contact.FieldGid:
  12728. v, ok := value.(string)
  12729. if !ok {
  12730. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12731. }
  12732. m.SetGid(v)
  12733. return nil
  12734. case contact.FieldGname:
  12735. v, ok := value.(string)
  12736. if !ok {
  12737. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12738. }
  12739. m.SetGname(v)
  12740. return nil
  12741. case contact.FieldV3:
  12742. v, ok := value.(string)
  12743. if !ok {
  12744. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12745. }
  12746. m.SetV3(v)
  12747. return nil
  12748. case contact.FieldOrganizationID:
  12749. v, ok := value.(uint64)
  12750. if !ok {
  12751. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12752. }
  12753. m.SetOrganizationID(v)
  12754. return nil
  12755. case contact.FieldCtype:
  12756. v, ok := value.(uint64)
  12757. if !ok {
  12758. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12759. }
  12760. m.SetCtype(v)
  12761. return nil
  12762. case contact.FieldCage:
  12763. v, ok := value.(int)
  12764. if !ok {
  12765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12766. }
  12767. m.SetCage(v)
  12768. return nil
  12769. case contact.FieldCname:
  12770. v, ok := value.(string)
  12771. if !ok {
  12772. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12773. }
  12774. m.SetCname(v)
  12775. return nil
  12776. case contact.FieldCarea:
  12777. v, ok := value.(string)
  12778. if !ok {
  12779. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12780. }
  12781. m.SetCarea(v)
  12782. return nil
  12783. case contact.FieldCbirthday:
  12784. v, ok := value.(string)
  12785. if !ok {
  12786. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12787. }
  12788. m.SetCbirthday(v)
  12789. return nil
  12790. case contact.FieldCbirtharea:
  12791. v, ok := value.(string)
  12792. if !ok {
  12793. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12794. }
  12795. m.SetCbirtharea(v)
  12796. return nil
  12797. case contact.FieldCidcardNo:
  12798. v, ok := value.(string)
  12799. if !ok {
  12800. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12801. }
  12802. m.SetCidcardNo(v)
  12803. return nil
  12804. case contact.FieldCtitle:
  12805. v, ok := value.(string)
  12806. if !ok {
  12807. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12808. }
  12809. m.SetCtitle(v)
  12810. return nil
  12811. case contact.FieldCc:
  12812. v, ok := value.(string)
  12813. if !ok {
  12814. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12815. }
  12816. m.SetCc(v)
  12817. return nil
  12818. case contact.FieldPhone:
  12819. v, ok := value.(string)
  12820. if !ok {
  12821. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12822. }
  12823. m.SetPhone(v)
  12824. return nil
  12825. }
  12826. return fmt.Errorf("unknown Contact field %s", name)
  12827. }
  12828. // AddedFields returns all numeric fields that were incremented/decremented during
  12829. // this mutation.
  12830. func (m *ContactMutation) AddedFields() []string {
  12831. var fields []string
  12832. if m.addstatus != nil {
  12833. fields = append(fields, contact.FieldStatus)
  12834. }
  12835. if m.add_type != nil {
  12836. fields = append(fields, contact.FieldType)
  12837. }
  12838. if m.addsex != nil {
  12839. fields = append(fields, contact.FieldSex)
  12840. }
  12841. if m.adddontseeit != nil {
  12842. fields = append(fields, contact.FieldDontseeit)
  12843. }
  12844. if m.adddontseeme != nil {
  12845. fields = append(fields, contact.FieldDontseeme)
  12846. }
  12847. if m.addorganization_id != nil {
  12848. fields = append(fields, contact.FieldOrganizationID)
  12849. }
  12850. if m.addctype != nil {
  12851. fields = append(fields, contact.FieldCtype)
  12852. }
  12853. if m.addcage != nil {
  12854. fields = append(fields, contact.FieldCage)
  12855. }
  12856. return fields
  12857. }
  12858. // AddedField returns the numeric value that was incremented/decremented on a field
  12859. // with the given name. The second boolean return value indicates that this field
  12860. // was not set, or was not defined in the schema.
  12861. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  12862. switch name {
  12863. case contact.FieldStatus:
  12864. return m.AddedStatus()
  12865. case contact.FieldType:
  12866. return m.AddedType()
  12867. case contact.FieldSex:
  12868. return m.AddedSex()
  12869. case contact.FieldDontseeit:
  12870. return m.AddedDontseeit()
  12871. case contact.FieldDontseeme:
  12872. return m.AddedDontseeme()
  12873. case contact.FieldOrganizationID:
  12874. return m.AddedOrganizationID()
  12875. case contact.FieldCtype:
  12876. return m.AddedCtype()
  12877. case contact.FieldCage:
  12878. return m.AddedCage()
  12879. }
  12880. return nil, false
  12881. }
  12882. // AddField adds the value to the field with the given name. It returns an error if
  12883. // the field is not defined in the schema, or if the type mismatched the field
  12884. // type.
  12885. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  12886. switch name {
  12887. case contact.FieldStatus:
  12888. v, ok := value.(int8)
  12889. if !ok {
  12890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12891. }
  12892. m.AddStatus(v)
  12893. return nil
  12894. case contact.FieldType:
  12895. v, ok := value.(int)
  12896. if !ok {
  12897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12898. }
  12899. m.AddType(v)
  12900. return nil
  12901. case contact.FieldSex:
  12902. v, ok := value.(int)
  12903. if !ok {
  12904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12905. }
  12906. m.AddSex(v)
  12907. return nil
  12908. case contact.FieldDontseeit:
  12909. v, ok := value.(int)
  12910. if !ok {
  12911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12912. }
  12913. m.AddDontseeit(v)
  12914. return nil
  12915. case contact.FieldDontseeme:
  12916. v, ok := value.(int)
  12917. if !ok {
  12918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12919. }
  12920. m.AddDontseeme(v)
  12921. return nil
  12922. case contact.FieldOrganizationID:
  12923. v, ok := value.(int64)
  12924. if !ok {
  12925. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12926. }
  12927. m.AddOrganizationID(v)
  12928. return nil
  12929. case contact.FieldCtype:
  12930. v, ok := value.(int64)
  12931. if !ok {
  12932. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12933. }
  12934. m.AddCtype(v)
  12935. return nil
  12936. case contact.FieldCage:
  12937. v, ok := value.(int)
  12938. if !ok {
  12939. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12940. }
  12941. m.AddCage(v)
  12942. return nil
  12943. }
  12944. return fmt.Errorf("unknown Contact numeric field %s", name)
  12945. }
  12946. // ClearedFields returns all nullable fields that were cleared during this
  12947. // mutation.
  12948. func (m *ContactMutation) ClearedFields() []string {
  12949. var fields []string
  12950. if m.FieldCleared(contact.FieldStatus) {
  12951. fields = append(fields, contact.FieldStatus)
  12952. }
  12953. if m.FieldCleared(contact.FieldDeletedAt) {
  12954. fields = append(fields, contact.FieldDeletedAt)
  12955. }
  12956. if m.FieldCleared(contact.FieldType) {
  12957. fields = append(fields, contact.FieldType)
  12958. }
  12959. if m.FieldCleared(contact.FieldOrganizationID) {
  12960. fields = append(fields, contact.FieldOrganizationID)
  12961. }
  12962. return fields
  12963. }
  12964. // FieldCleared returns a boolean indicating if a field with the given name was
  12965. // cleared in this mutation.
  12966. func (m *ContactMutation) FieldCleared(name string) bool {
  12967. _, ok := m.clearedFields[name]
  12968. return ok
  12969. }
  12970. // ClearField clears the value of the field with the given name. It returns an
  12971. // error if the field is not defined in the schema.
  12972. func (m *ContactMutation) ClearField(name string) error {
  12973. switch name {
  12974. case contact.FieldStatus:
  12975. m.ClearStatus()
  12976. return nil
  12977. case contact.FieldDeletedAt:
  12978. m.ClearDeletedAt()
  12979. return nil
  12980. case contact.FieldType:
  12981. m.ClearType()
  12982. return nil
  12983. case contact.FieldOrganizationID:
  12984. m.ClearOrganizationID()
  12985. return nil
  12986. }
  12987. return fmt.Errorf("unknown Contact nullable field %s", name)
  12988. }
  12989. // ResetField resets all changes in the mutation for the field with the given name.
  12990. // It returns an error if the field is not defined in the schema.
  12991. func (m *ContactMutation) ResetField(name string) error {
  12992. switch name {
  12993. case contact.FieldCreatedAt:
  12994. m.ResetCreatedAt()
  12995. return nil
  12996. case contact.FieldUpdatedAt:
  12997. m.ResetUpdatedAt()
  12998. return nil
  12999. case contact.FieldStatus:
  13000. m.ResetStatus()
  13001. return nil
  13002. case contact.FieldDeletedAt:
  13003. m.ResetDeletedAt()
  13004. return nil
  13005. case contact.FieldWxWxid:
  13006. m.ResetWxWxid()
  13007. return nil
  13008. case contact.FieldType:
  13009. m.ResetType()
  13010. return nil
  13011. case contact.FieldWxid:
  13012. m.ResetWxid()
  13013. return nil
  13014. case contact.FieldAccount:
  13015. m.ResetAccount()
  13016. return nil
  13017. case contact.FieldNickname:
  13018. m.ResetNickname()
  13019. return nil
  13020. case contact.FieldMarkname:
  13021. m.ResetMarkname()
  13022. return nil
  13023. case contact.FieldHeadimg:
  13024. m.ResetHeadimg()
  13025. return nil
  13026. case contact.FieldSex:
  13027. m.ResetSex()
  13028. return nil
  13029. case contact.FieldStarrole:
  13030. m.ResetStarrole()
  13031. return nil
  13032. case contact.FieldDontseeit:
  13033. m.ResetDontseeit()
  13034. return nil
  13035. case contact.FieldDontseeme:
  13036. m.ResetDontseeme()
  13037. return nil
  13038. case contact.FieldLag:
  13039. m.ResetLag()
  13040. return nil
  13041. case contact.FieldGid:
  13042. m.ResetGid()
  13043. return nil
  13044. case contact.FieldGname:
  13045. m.ResetGname()
  13046. return nil
  13047. case contact.FieldV3:
  13048. m.ResetV3()
  13049. return nil
  13050. case contact.FieldOrganizationID:
  13051. m.ResetOrganizationID()
  13052. return nil
  13053. case contact.FieldCtype:
  13054. m.ResetCtype()
  13055. return nil
  13056. case contact.FieldCage:
  13057. m.ResetCage()
  13058. return nil
  13059. case contact.FieldCname:
  13060. m.ResetCname()
  13061. return nil
  13062. case contact.FieldCarea:
  13063. m.ResetCarea()
  13064. return nil
  13065. case contact.FieldCbirthday:
  13066. m.ResetCbirthday()
  13067. return nil
  13068. case contact.FieldCbirtharea:
  13069. m.ResetCbirtharea()
  13070. return nil
  13071. case contact.FieldCidcardNo:
  13072. m.ResetCidcardNo()
  13073. return nil
  13074. case contact.FieldCtitle:
  13075. m.ResetCtitle()
  13076. return nil
  13077. case contact.FieldCc:
  13078. m.ResetCc()
  13079. return nil
  13080. case contact.FieldPhone:
  13081. m.ResetPhone()
  13082. return nil
  13083. }
  13084. return fmt.Errorf("unknown Contact field %s", name)
  13085. }
  13086. // AddedEdges returns all edge names that were set/added in this mutation.
  13087. func (m *ContactMutation) AddedEdges() []string {
  13088. edges := make([]string, 0, 3)
  13089. if m.contact_relationships != nil {
  13090. edges = append(edges, contact.EdgeContactRelationships)
  13091. }
  13092. if m.contact_fields != nil {
  13093. edges = append(edges, contact.EdgeContactFields)
  13094. }
  13095. if m.contact_messages != nil {
  13096. edges = append(edges, contact.EdgeContactMessages)
  13097. }
  13098. return edges
  13099. }
  13100. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13101. // name in this mutation.
  13102. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  13103. switch name {
  13104. case contact.EdgeContactRelationships:
  13105. ids := make([]ent.Value, 0, len(m.contact_relationships))
  13106. for id := range m.contact_relationships {
  13107. ids = append(ids, id)
  13108. }
  13109. return ids
  13110. case contact.EdgeContactFields:
  13111. ids := make([]ent.Value, 0, len(m.contact_fields))
  13112. for id := range m.contact_fields {
  13113. ids = append(ids, id)
  13114. }
  13115. return ids
  13116. case contact.EdgeContactMessages:
  13117. ids := make([]ent.Value, 0, len(m.contact_messages))
  13118. for id := range m.contact_messages {
  13119. ids = append(ids, id)
  13120. }
  13121. return ids
  13122. }
  13123. return nil
  13124. }
  13125. // RemovedEdges returns all edge names that were removed in this mutation.
  13126. func (m *ContactMutation) RemovedEdges() []string {
  13127. edges := make([]string, 0, 3)
  13128. if m.removedcontact_relationships != nil {
  13129. edges = append(edges, contact.EdgeContactRelationships)
  13130. }
  13131. if m.removedcontact_fields != nil {
  13132. edges = append(edges, contact.EdgeContactFields)
  13133. }
  13134. if m.removedcontact_messages != nil {
  13135. edges = append(edges, contact.EdgeContactMessages)
  13136. }
  13137. return edges
  13138. }
  13139. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13140. // the given name in this mutation.
  13141. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  13142. switch name {
  13143. case contact.EdgeContactRelationships:
  13144. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  13145. for id := range m.removedcontact_relationships {
  13146. ids = append(ids, id)
  13147. }
  13148. return ids
  13149. case contact.EdgeContactFields:
  13150. ids := make([]ent.Value, 0, len(m.removedcontact_fields))
  13151. for id := range m.removedcontact_fields {
  13152. ids = append(ids, id)
  13153. }
  13154. return ids
  13155. case contact.EdgeContactMessages:
  13156. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  13157. for id := range m.removedcontact_messages {
  13158. ids = append(ids, id)
  13159. }
  13160. return ids
  13161. }
  13162. return nil
  13163. }
  13164. // ClearedEdges returns all edge names that were cleared in this mutation.
  13165. func (m *ContactMutation) ClearedEdges() []string {
  13166. edges := make([]string, 0, 3)
  13167. if m.clearedcontact_relationships {
  13168. edges = append(edges, contact.EdgeContactRelationships)
  13169. }
  13170. if m.clearedcontact_fields {
  13171. edges = append(edges, contact.EdgeContactFields)
  13172. }
  13173. if m.clearedcontact_messages {
  13174. edges = append(edges, contact.EdgeContactMessages)
  13175. }
  13176. return edges
  13177. }
  13178. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13179. // was cleared in this mutation.
  13180. func (m *ContactMutation) EdgeCleared(name string) bool {
  13181. switch name {
  13182. case contact.EdgeContactRelationships:
  13183. return m.clearedcontact_relationships
  13184. case contact.EdgeContactFields:
  13185. return m.clearedcontact_fields
  13186. case contact.EdgeContactMessages:
  13187. return m.clearedcontact_messages
  13188. }
  13189. return false
  13190. }
  13191. // ClearEdge clears the value of the edge with the given name. It returns an error
  13192. // if that edge is not defined in the schema.
  13193. func (m *ContactMutation) ClearEdge(name string) error {
  13194. switch name {
  13195. }
  13196. return fmt.Errorf("unknown Contact unique edge %s", name)
  13197. }
  13198. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13199. // It returns an error if the edge is not defined in the schema.
  13200. func (m *ContactMutation) ResetEdge(name string) error {
  13201. switch name {
  13202. case contact.EdgeContactRelationships:
  13203. m.ResetContactRelationships()
  13204. return nil
  13205. case contact.EdgeContactFields:
  13206. m.ResetContactFields()
  13207. return nil
  13208. case contact.EdgeContactMessages:
  13209. m.ResetContactMessages()
  13210. return nil
  13211. }
  13212. return fmt.Errorf("unknown Contact edge %s", name)
  13213. }
  13214. // ContactFieldMutation represents an operation that mutates the ContactField nodes in the graph.
  13215. type ContactFieldMutation struct {
  13216. config
  13217. op Op
  13218. typ string
  13219. id *uint64
  13220. created_at *time.Time
  13221. updated_at *time.Time
  13222. status *uint8
  13223. addstatus *int8
  13224. deleted_at *time.Time
  13225. form_id *string
  13226. value *[]string
  13227. appendvalue []string
  13228. clearedFields map[string]struct{}
  13229. field_contact *uint64
  13230. clearedfield_contact bool
  13231. done bool
  13232. oldValue func(context.Context) (*ContactField, error)
  13233. predicates []predicate.ContactField
  13234. }
  13235. var _ ent.Mutation = (*ContactFieldMutation)(nil)
  13236. // contactfieldOption allows management of the mutation configuration using functional options.
  13237. type contactfieldOption func(*ContactFieldMutation)
  13238. // newContactFieldMutation creates new mutation for the ContactField entity.
  13239. func newContactFieldMutation(c config, op Op, opts ...contactfieldOption) *ContactFieldMutation {
  13240. m := &ContactFieldMutation{
  13241. config: c,
  13242. op: op,
  13243. typ: TypeContactField,
  13244. clearedFields: make(map[string]struct{}),
  13245. }
  13246. for _, opt := range opts {
  13247. opt(m)
  13248. }
  13249. return m
  13250. }
  13251. // withContactFieldID sets the ID field of the mutation.
  13252. func withContactFieldID(id uint64) contactfieldOption {
  13253. return func(m *ContactFieldMutation) {
  13254. var (
  13255. err error
  13256. once sync.Once
  13257. value *ContactField
  13258. )
  13259. m.oldValue = func(ctx context.Context) (*ContactField, error) {
  13260. once.Do(func() {
  13261. if m.done {
  13262. err = errors.New("querying old values post mutation is not allowed")
  13263. } else {
  13264. value, err = m.Client().ContactField.Get(ctx, id)
  13265. }
  13266. })
  13267. return value, err
  13268. }
  13269. m.id = &id
  13270. }
  13271. }
  13272. // withContactField sets the old ContactField of the mutation.
  13273. func withContactField(node *ContactField) contactfieldOption {
  13274. return func(m *ContactFieldMutation) {
  13275. m.oldValue = func(context.Context) (*ContactField, error) {
  13276. return node, nil
  13277. }
  13278. m.id = &node.ID
  13279. }
  13280. }
  13281. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13282. // executed in a transaction (ent.Tx), a transactional client is returned.
  13283. func (m ContactFieldMutation) Client() *Client {
  13284. client := &Client{config: m.config}
  13285. client.init()
  13286. return client
  13287. }
  13288. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13289. // it returns an error otherwise.
  13290. func (m ContactFieldMutation) Tx() (*Tx, error) {
  13291. if _, ok := m.driver.(*txDriver); !ok {
  13292. return nil, errors.New("ent: mutation is not running in a transaction")
  13293. }
  13294. tx := &Tx{config: m.config}
  13295. tx.init()
  13296. return tx, nil
  13297. }
  13298. // SetID sets the value of the id field. Note that this
  13299. // operation is only accepted on creation of ContactField entities.
  13300. func (m *ContactFieldMutation) SetID(id uint64) {
  13301. m.id = &id
  13302. }
  13303. // ID returns the ID value in the mutation. Note that the ID is only available
  13304. // if it was provided to the builder or after it was returned from the database.
  13305. func (m *ContactFieldMutation) ID() (id uint64, exists bool) {
  13306. if m.id == nil {
  13307. return
  13308. }
  13309. return *m.id, true
  13310. }
  13311. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13312. // That means, if the mutation is applied within a transaction with an isolation level such
  13313. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13314. // or updated by the mutation.
  13315. func (m *ContactFieldMutation) IDs(ctx context.Context) ([]uint64, error) {
  13316. switch {
  13317. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13318. id, exists := m.ID()
  13319. if exists {
  13320. return []uint64{id}, nil
  13321. }
  13322. fallthrough
  13323. case m.op.Is(OpUpdate | OpDelete):
  13324. return m.Client().ContactField.Query().Where(m.predicates...).IDs(ctx)
  13325. default:
  13326. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13327. }
  13328. }
  13329. // SetCreatedAt sets the "created_at" field.
  13330. func (m *ContactFieldMutation) SetCreatedAt(t time.Time) {
  13331. m.created_at = &t
  13332. }
  13333. // CreatedAt returns the value of the "created_at" field in the mutation.
  13334. func (m *ContactFieldMutation) CreatedAt() (r time.Time, exists bool) {
  13335. v := m.created_at
  13336. if v == nil {
  13337. return
  13338. }
  13339. return *v, true
  13340. }
  13341. // OldCreatedAt returns the old "created_at" field's value of the ContactField entity.
  13342. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  13343. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13344. func (m *ContactFieldMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13345. if !m.op.Is(OpUpdateOne) {
  13346. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13347. }
  13348. if m.id == nil || m.oldValue == nil {
  13349. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13350. }
  13351. oldValue, err := m.oldValue(ctx)
  13352. if err != nil {
  13353. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13354. }
  13355. return oldValue.CreatedAt, nil
  13356. }
  13357. // ResetCreatedAt resets all changes to the "created_at" field.
  13358. func (m *ContactFieldMutation) ResetCreatedAt() {
  13359. m.created_at = nil
  13360. }
  13361. // SetUpdatedAt sets the "updated_at" field.
  13362. func (m *ContactFieldMutation) SetUpdatedAt(t time.Time) {
  13363. m.updated_at = &t
  13364. }
  13365. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13366. func (m *ContactFieldMutation) UpdatedAt() (r time.Time, exists bool) {
  13367. v := m.updated_at
  13368. if v == nil {
  13369. return
  13370. }
  13371. return *v, true
  13372. }
  13373. // OldUpdatedAt returns the old "updated_at" field's value of the ContactField entity.
  13374. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  13375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13376. func (m *ContactFieldMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13377. if !m.op.Is(OpUpdateOne) {
  13378. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13379. }
  13380. if m.id == nil || m.oldValue == nil {
  13381. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13382. }
  13383. oldValue, err := m.oldValue(ctx)
  13384. if err != nil {
  13385. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13386. }
  13387. return oldValue.UpdatedAt, nil
  13388. }
  13389. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13390. func (m *ContactFieldMutation) ResetUpdatedAt() {
  13391. m.updated_at = nil
  13392. }
  13393. // SetStatus sets the "status" field.
  13394. func (m *ContactFieldMutation) SetStatus(u uint8) {
  13395. m.status = &u
  13396. m.addstatus = nil
  13397. }
  13398. // Status returns the value of the "status" field in the mutation.
  13399. func (m *ContactFieldMutation) Status() (r uint8, exists bool) {
  13400. v := m.status
  13401. if v == nil {
  13402. return
  13403. }
  13404. return *v, true
  13405. }
  13406. // OldStatus returns the old "status" field's value of the ContactField entity.
  13407. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  13408. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13409. func (m *ContactFieldMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13410. if !m.op.Is(OpUpdateOne) {
  13411. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13412. }
  13413. if m.id == nil || m.oldValue == nil {
  13414. return v, errors.New("OldStatus requires an ID field in the mutation")
  13415. }
  13416. oldValue, err := m.oldValue(ctx)
  13417. if err != nil {
  13418. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13419. }
  13420. return oldValue.Status, nil
  13421. }
  13422. // AddStatus adds u to the "status" field.
  13423. func (m *ContactFieldMutation) AddStatus(u int8) {
  13424. if m.addstatus != nil {
  13425. *m.addstatus += u
  13426. } else {
  13427. m.addstatus = &u
  13428. }
  13429. }
  13430. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13431. func (m *ContactFieldMutation) AddedStatus() (r int8, exists bool) {
  13432. v := m.addstatus
  13433. if v == nil {
  13434. return
  13435. }
  13436. return *v, true
  13437. }
  13438. // ClearStatus clears the value of the "status" field.
  13439. func (m *ContactFieldMutation) ClearStatus() {
  13440. m.status = nil
  13441. m.addstatus = nil
  13442. m.clearedFields[contactfield.FieldStatus] = struct{}{}
  13443. }
  13444. // StatusCleared returns if the "status" field was cleared in this mutation.
  13445. func (m *ContactFieldMutation) StatusCleared() bool {
  13446. _, ok := m.clearedFields[contactfield.FieldStatus]
  13447. return ok
  13448. }
  13449. // ResetStatus resets all changes to the "status" field.
  13450. func (m *ContactFieldMutation) ResetStatus() {
  13451. m.status = nil
  13452. m.addstatus = nil
  13453. delete(m.clearedFields, contactfield.FieldStatus)
  13454. }
  13455. // SetDeletedAt sets the "deleted_at" field.
  13456. func (m *ContactFieldMutation) SetDeletedAt(t time.Time) {
  13457. m.deleted_at = &t
  13458. }
  13459. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13460. func (m *ContactFieldMutation) DeletedAt() (r time.Time, exists bool) {
  13461. v := m.deleted_at
  13462. if v == nil {
  13463. return
  13464. }
  13465. return *v, true
  13466. }
  13467. // OldDeletedAt returns the old "deleted_at" field's value of the ContactField entity.
  13468. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  13469. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13470. func (m *ContactFieldMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13471. if !m.op.Is(OpUpdateOne) {
  13472. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13473. }
  13474. if m.id == nil || m.oldValue == nil {
  13475. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13476. }
  13477. oldValue, err := m.oldValue(ctx)
  13478. if err != nil {
  13479. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13480. }
  13481. return oldValue.DeletedAt, nil
  13482. }
  13483. // ClearDeletedAt clears the value of the "deleted_at" field.
  13484. func (m *ContactFieldMutation) ClearDeletedAt() {
  13485. m.deleted_at = nil
  13486. m.clearedFields[contactfield.FieldDeletedAt] = struct{}{}
  13487. }
  13488. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13489. func (m *ContactFieldMutation) DeletedAtCleared() bool {
  13490. _, ok := m.clearedFields[contactfield.FieldDeletedAt]
  13491. return ok
  13492. }
  13493. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13494. func (m *ContactFieldMutation) ResetDeletedAt() {
  13495. m.deleted_at = nil
  13496. delete(m.clearedFields, contactfield.FieldDeletedAt)
  13497. }
  13498. // SetContactID sets the "contact_id" field.
  13499. func (m *ContactFieldMutation) SetContactID(u uint64) {
  13500. m.field_contact = &u
  13501. }
  13502. // ContactID returns the value of the "contact_id" field in the mutation.
  13503. func (m *ContactFieldMutation) ContactID() (r uint64, exists bool) {
  13504. v := m.field_contact
  13505. if v == nil {
  13506. return
  13507. }
  13508. return *v, true
  13509. }
  13510. // OldContactID returns the old "contact_id" field's value of the ContactField entity.
  13511. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  13512. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13513. func (m *ContactFieldMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  13514. if !m.op.Is(OpUpdateOne) {
  13515. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  13516. }
  13517. if m.id == nil || m.oldValue == nil {
  13518. return v, errors.New("OldContactID requires an ID field in the mutation")
  13519. }
  13520. oldValue, err := m.oldValue(ctx)
  13521. if err != nil {
  13522. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  13523. }
  13524. return oldValue.ContactID, nil
  13525. }
  13526. // ResetContactID resets all changes to the "contact_id" field.
  13527. func (m *ContactFieldMutation) ResetContactID() {
  13528. m.field_contact = nil
  13529. }
  13530. // SetFormID sets the "form_id" field.
  13531. func (m *ContactFieldMutation) SetFormID(s string) {
  13532. m.form_id = &s
  13533. }
  13534. // FormID returns the value of the "form_id" field in the mutation.
  13535. func (m *ContactFieldMutation) FormID() (r string, exists bool) {
  13536. v := m.form_id
  13537. if v == nil {
  13538. return
  13539. }
  13540. return *v, true
  13541. }
  13542. // OldFormID returns the old "form_id" field's value of the ContactField entity.
  13543. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  13544. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13545. func (m *ContactFieldMutation) OldFormID(ctx context.Context) (v string, err error) {
  13546. if !m.op.Is(OpUpdateOne) {
  13547. return v, errors.New("OldFormID is only allowed on UpdateOne operations")
  13548. }
  13549. if m.id == nil || m.oldValue == nil {
  13550. return v, errors.New("OldFormID requires an ID field in the mutation")
  13551. }
  13552. oldValue, err := m.oldValue(ctx)
  13553. if err != nil {
  13554. return v, fmt.Errorf("querying old value for OldFormID: %w", err)
  13555. }
  13556. return oldValue.FormID, nil
  13557. }
  13558. // ResetFormID resets all changes to the "form_id" field.
  13559. func (m *ContactFieldMutation) ResetFormID() {
  13560. m.form_id = nil
  13561. }
  13562. // SetValue sets the "value" field.
  13563. func (m *ContactFieldMutation) SetValue(s []string) {
  13564. m.value = &s
  13565. m.appendvalue = nil
  13566. }
  13567. // Value returns the value of the "value" field in the mutation.
  13568. func (m *ContactFieldMutation) Value() (r []string, exists bool) {
  13569. v := m.value
  13570. if v == nil {
  13571. return
  13572. }
  13573. return *v, true
  13574. }
  13575. // OldValue returns the old "value" field's value of the ContactField entity.
  13576. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  13577. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13578. func (m *ContactFieldMutation) OldValue(ctx context.Context) (v []string, err error) {
  13579. if !m.op.Is(OpUpdateOne) {
  13580. return v, errors.New("OldValue is only allowed on UpdateOne operations")
  13581. }
  13582. if m.id == nil || m.oldValue == nil {
  13583. return v, errors.New("OldValue requires an ID field in the mutation")
  13584. }
  13585. oldValue, err := m.oldValue(ctx)
  13586. if err != nil {
  13587. return v, fmt.Errorf("querying old value for OldValue: %w", err)
  13588. }
  13589. return oldValue.Value, nil
  13590. }
  13591. // AppendValue adds s to the "value" field.
  13592. func (m *ContactFieldMutation) AppendValue(s []string) {
  13593. m.appendvalue = append(m.appendvalue, s...)
  13594. }
  13595. // AppendedValue returns the list of values that were appended to the "value" field in this mutation.
  13596. func (m *ContactFieldMutation) AppendedValue() ([]string, bool) {
  13597. if len(m.appendvalue) == 0 {
  13598. return nil, false
  13599. }
  13600. return m.appendvalue, true
  13601. }
  13602. // ResetValue resets all changes to the "value" field.
  13603. func (m *ContactFieldMutation) ResetValue() {
  13604. m.value = nil
  13605. m.appendvalue = nil
  13606. }
  13607. // SetFieldContactID sets the "field_contact" edge to the Contact entity by id.
  13608. func (m *ContactFieldMutation) SetFieldContactID(id uint64) {
  13609. m.field_contact = &id
  13610. }
  13611. // ClearFieldContact clears the "field_contact" edge to the Contact entity.
  13612. func (m *ContactFieldMutation) ClearFieldContact() {
  13613. m.clearedfield_contact = true
  13614. m.clearedFields[contactfield.FieldContactID] = struct{}{}
  13615. }
  13616. // FieldContactCleared reports if the "field_contact" edge to the Contact entity was cleared.
  13617. func (m *ContactFieldMutation) FieldContactCleared() bool {
  13618. return m.clearedfield_contact
  13619. }
  13620. // FieldContactID returns the "field_contact" edge ID in the mutation.
  13621. func (m *ContactFieldMutation) FieldContactID() (id uint64, exists bool) {
  13622. if m.field_contact != nil {
  13623. return *m.field_contact, true
  13624. }
  13625. return
  13626. }
  13627. // FieldContactIDs returns the "field_contact" edge IDs in the mutation.
  13628. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  13629. // FieldContactID instead. It exists only for internal usage by the builders.
  13630. func (m *ContactFieldMutation) FieldContactIDs() (ids []uint64) {
  13631. if id := m.field_contact; id != nil {
  13632. ids = append(ids, *id)
  13633. }
  13634. return
  13635. }
  13636. // ResetFieldContact resets all changes to the "field_contact" edge.
  13637. func (m *ContactFieldMutation) ResetFieldContact() {
  13638. m.field_contact = nil
  13639. m.clearedfield_contact = false
  13640. }
  13641. // Where appends a list predicates to the ContactFieldMutation builder.
  13642. func (m *ContactFieldMutation) Where(ps ...predicate.ContactField) {
  13643. m.predicates = append(m.predicates, ps...)
  13644. }
  13645. // WhereP appends storage-level predicates to the ContactFieldMutation builder. Using this method,
  13646. // users can use type-assertion to append predicates that do not depend on any generated package.
  13647. func (m *ContactFieldMutation) WhereP(ps ...func(*sql.Selector)) {
  13648. p := make([]predicate.ContactField, len(ps))
  13649. for i := range ps {
  13650. p[i] = ps[i]
  13651. }
  13652. m.Where(p...)
  13653. }
  13654. // Op returns the operation name.
  13655. func (m *ContactFieldMutation) Op() Op {
  13656. return m.op
  13657. }
  13658. // SetOp allows setting the mutation operation.
  13659. func (m *ContactFieldMutation) SetOp(op Op) {
  13660. m.op = op
  13661. }
  13662. // Type returns the node type of this mutation (ContactField).
  13663. func (m *ContactFieldMutation) Type() string {
  13664. return m.typ
  13665. }
  13666. // Fields returns all fields that were changed during this mutation. Note that in
  13667. // order to get all numeric fields that were incremented/decremented, call
  13668. // AddedFields().
  13669. func (m *ContactFieldMutation) Fields() []string {
  13670. fields := make([]string, 0, 7)
  13671. if m.created_at != nil {
  13672. fields = append(fields, contactfield.FieldCreatedAt)
  13673. }
  13674. if m.updated_at != nil {
  13675. fields = append(fields, contactfield.FieldUpdatedAt)
  13676. }
  13677. if m.status != nil {
  13678. fields = append(fields, contactfield.FieldStatus)
  13679. }
  13680. if m.deleted_at != nil {
  13681. fields = append(fields, contactfield.FieldDeletedAt)
  13682. }
  13683. if m.field_contact != nil {
  13684. fields = append(fields, contactfield.FieldContactID)
  13685. }
  13686. if m.form_id != nil {
  13687. fields = append(fields, contactfield.FieldFormID)
  13688. }
  13689. if m.value != nil {
  13690. fields = append(fields, contactfield.FieldValue)
  13691. }
  13692. return fields
  13693. }
  13694. // Field returns the value of a field with the given name. The second boolean
  13695. // return value indicates that this field was not set, or was not defined in the
  13696. // schema.
  13697. func (m *ContactFieldMutation) Field(name string) (ent.Value, bool) {
  13698. switch name {
  13699. case contactfield.FieldCreatedAt:
  13700. return m.CreatedAt()
  13701. case contactfield.FieldUpdatedAt:
  13702. return m.UpdatedAt()
  13703. case contactfield.FieldStatus:
  13704. return m.Status()
  13705. case contactfield.FieldDeletedAt:
  13706. return m.DeletedAt()
  13707. case contactfield.FieldContactID:
  13708. return m.ContactID()
  13709. case contactfield.FieldFormID:
  13710. return m.FormID()
  13711. case contactfield.FieldValue:
  13712. return m.Value()
  13713. }
  13714. return nil, false
  13715. }
  13716. // OldField returns the old value of the field from the database. An error is
  13717. // returned if the mutation operation is not UpdateOne, or the query to the
  13718. // database failed.
  13719. func (m *ContactFieldMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13720. switch name {
  13721. case contactfield.FieldCreatedAt:
  13722. return m.OldCreatedAt(ctx)
  13723. case contactfield.FieldUpdatedAt:
  13724. return m.OldUpdatedAt(ctx)
  13725. case contactfield.FieldStatus:
  13726. return m.OldStatus(ctx)
  13727. case contactfield.FieldDeletedAt:
  13728. return m.OldDeletedAt(ctx)
  13729. case contactfield.FieldContactID:
  13730. return m.OldContactID(ctx)
  13731. case contactfield.FieldFormID:
  13732. return m.OldFormID(ctx)
  13733. case contactfield.FieldValue:
  13734. return m.OldValue(ctx)
  13735. }
  13736. return nil, fmt.Errorf("unknown ContactField field %s", name)
  13737. }
  13738. // SetField sets the value of a field with the given name. It returns an error if
  13739. // the field is not defined in the schema, or if the type mismatched the field
  13740. // type.
  13741. func (m *ContactFieldMutation) SetField(name string, value ent.Value) error {
  13742. switch name {
  13743. case contactfield.FieldCreatedAt:
  13744. v, ok := value.(time.Time)
  13745. if !ok {
  13746. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13747. }
  13748. m.SetCreatedAt(v)
  13749. return nil
  13750. case contactfield.FieldUpdatedAt:
  13751. v, ok := value.(time.Time)
  13752. if !ok {
  13753. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13754. }
  13755. m.SetUpdatedAt(v)
  13756. return nil
  13757. case contactfield.FieldStatus:
  13758. v, ok := value.(uint8)
  13759. if !ok {
  13760. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13761. }
  13762. m.SetStatus(v)
  13763. return nil
  13764. case contactfield.FieldDeletedAt:
  13765. v, ok := value.(time.Time)
  13766. if !ok {
  13767. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13768. }
  13769. m.SetDeletedAt(v)
  13770. return nil
  13771. case contactfield.FieldContactID:
  13772. v, ok := value.(uint64)
  13773. if !ok {
  13774. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13775. }
  13776. m.SetContactID(v)
  13777. return nil
  13778. case contactfield.FieldFormID:
  13779. v, ok := value.(string)
  13780. if !ok {
  13781. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13782. }
  13783. m.SetFormID(v)
  13784. return nil
  13785. case contactfield.FieldValue:
  13786. v, ok := value.([]string)
  13787. if !ok {
  13788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13789. }
  13790. m.SetValue(v)
  13791. return nil
  13792. }
  13793. return fmt.Errorf("unknown ContactField field %s", name)
  13794. }
  13795. // AddedFields returns all numeric fields that were incremented/decremented during
  13796. // this mutation.
  13797. func (m *ContactFieldMutation) AddedFields() []string {
  13798. var fields []string
  13799. if m.addstatus != nil {
  13800. fields = append(fields, contactfield.FieldStatus)
  13801. }
  13802. return fields
  13803. }
  13804. // AddedField returns the numeric value that was incremented/decremented on a field
  13805. // with the given name. The second boolean return value indicates that this field
  13806. // was not set, or was not defined in the schema.
  13807. func (m *ContactFieldMutation) AddedField(name string) (ent.Value, bool) {
  13808. switch name {
  13809. case contactfield.FieldStatus:
  13810. return m.AddedStatus()
  13811. }
  13812. return nil, false
  13813. }
  13814. // AddField adds the value to the field with the given name. It returns an error if
  13815. // the field is not defined in the schema, or if the type mismatched the field
  13816. // type.
  13817. func (m *ContactFieldMutation) AddField(name string, value ent.Value) error {
  13818. switch name {
  13819. case contactfield.FieldStatus:
  13820. v, ok := value.(int8)
  13821. if !ok {
  13822. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13823. }
  13824. m.AddStatus(v)
  13825. return nil
  13826. }
  13827. return fmt.Errorf("unknown ContactField numeric field %s", name)
  13828. }
  13829. // ClearedFields returns all nullable fields that were cleared during this
  13830. // mutation.
  13831. func (m *ContactFieldMutation) ClearedFields() []string {
  13832. var fields []string
  13833. if m.FieldCleared(contactfield.FieldStatus) {
  13834. fields = append(fields, contactfield.FieldStatus)
  13835. }
  13836. if m.FieldCleared(contactfield.FieldDeletedAt) {
  13837. fields = append(fields, contactfield.FieldDeletedAt)
  13838. }
  13839. return fields
  13840. }
  13841. // FieldCleared returns a boolean indicating if a field with the given name was
  13842. // cleared in this mutation.
  13843. func (m *ContactFieldMutation) FieldCleared(name string) bool {
  13844. _, ok := m.clearedFields[name]
  13845. return ok
  13846. }
  13847. // ClearField clears the value of the field with the given name. It returns an
  13848. // error if the field is not defined in the schema.
  13849. func (m *ContactFieldMutation) ClearField(name string) error {
  13850. switch name {
  13851. case contactfield.FieldStatus:
  13852. m.ClearStatus()
  13853. return nil
  13854. case contactfield.FieldDeletedAt:
  13855. m.ClearDeletedAt()
  13856. return nil
  13857. }
  13858. return fmt.Errorf("unknown ContactField nullable field %s", name)
  13859. }
  13860. // ResetField resets all changes in the mutation for the field with the given name.
  13861. // It returns an error if the field is not defined in the schema.
  13862. func (m *ContactFieldMutation) ResetField(name string) error {
  13863. switch name {
  13864. case contactfield.FieldCreatedAt:
  13865. m.ResetCreatedAt()
  13866. return nil
  13867. case contactfield.FieldUpdatedAt:
  13868. m.ResetUpdatedAt()
  13869. return nil
  13870. case contactfield.FieldStatus:
  13871. m.ResetStatus()
  13872. return nil
  13873. case contactfield.FieldDeletedAt:
  13874. m.ResetDeletedAt()
  13875. return nil
  13876. case contactfield.FieldContactID:
  13877. m.ResetContactID()
  13878. return nil
  13879. case contactfield.FieldFormID:
  13880. m.ResetFormID()
  13881. return nil
  13882. case contactfield.FieldValue:
  13883. m.ResetValue()
  13884. return nil
  13885. }
  13886. return fmt.Errorf("unknown ContactField field %s", name)
  13887. }
  13888. // AddedEdges returns all edge names that were set/added in this mutation.
  13889. func (m *ContactFieldMutation) AddedEdges() []string {
  13890. edges := make([]string, 0, 1)
  13891. if m.field_contact != nil {
  13892. edges = append(edges, contactfield.EdgeFieldContact)
  13893. }
  13894. return edges
  13895. }
  13896. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13897. // name in this mutation.
  13898. func (m *ContactFieldMutation) AddedIDs(name string) []ent.Value {
  13899. switch name {
  13900. case contactfield.EdgeFieldContact:
  13901. if id := m.field_contact; id != nil {
  13902. return []ent.Value{*id}
  13903. }
  13904. }
  13905. return nil
  13906. }
  13907. // RemovedEdges returns all edge names that were removed in this mutation.
  13908. func (m *ContactFieldMutation) RemovedEdges() []string {
  13909. edges := make([]string, 0, 1)
  13910. return edges
  13911. }
  13912. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13913. // the given name in this mutation.
  13914. func (m *ContactFieldMutation) RemovedIDs(name string) []ent.Value {
  13915. return nil
  13916. }
  13917. // ClearedEdges returns all edge names that were cleared in this mutation.
  13918. func (m *ContactFieldMutation) ClearedEdges() []string {
  13919. edges := make([]string, 0, 1)
  13920. if m.clearedfield_contact {
  13921. edges = append(edges, contactfield.EdgeFieldContact)
  13922. }
  13923. return edges
  13924. }
  13925. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13926. // was cleared in this mutation.
  13927. func (m *ContactFieldMutation) EdgeCleared(name string) bool {
  13928. switch name {
  13929. case contactfield.EdgeFieldContact:
  13930. return m.clearedfield_contact
  13931. }
  13932. return false
  13933. }
  13934. // ClearEdge clears the value of the edge with the given name. It returns an error
  13935. // if that edge is not defined in the schema.
  13936. func (m *ContactFieldMutation) ClearEdge(name string) error {
  13937. switch name {
  13938. case contactfield.EdgeFieldContact:
  13939. m.ClearFieldContact()
  13940. return nil
  13941. }
  13942. return fmt.Errorf("unknown ContactField unique edge %s", name)
  13943. }
  13944. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13945. // It returns an error if the edge is not defined in the schema.
  13946. func (m *ContactFieldMutation) ResetEdge(name string) error {
  13947. switch name {
  13948. case contactfield.EdgeFieldContact:
  13949. m.ResetFieldContact()
  13950. return nil
  13951. }
  13952. return fmt.Errorf("unknown ContactField edge %s", name)
  13953. }
  13954. // ContactFieldTemplateMutation represents an operation that mutates the ContactFieldTemplate nodes in the graph.
  13955. type ContactFieldTemplateMutation struct {
  13956. config
  13957. op Op
  13958. typ string
  13959. id *uint64
  13960. created_at *time.Time
  13961. updated_at *time.Time
  13962. status *uint8
  13963. addstatus *int8
  13964. deleted_at *time.Time
  13965. organization_id *uint64
  13966. addorganization_id *int64
  13967. template *[]custom_types.ContactFieldTemplate
  13968. appendtemplate []custom_types.ContactFieldTemplate
  13969. clearedFields map[string]struct{}
  13970. done bool
  13971. oldValue func(context.Context) (*ContactFieldTemplate, error)
  13972. predicates []predicate.ContactFieldTemplate
  13973. }
  13974. var _ ent.Mutation = (*ContactFieldTemplateMutation)(nil)
  13975. // contactfieldtemplateOption allows management of the mutation configuration using functional options.
  13976. type contactfieldtemplateOption func(*ContactFieldTemplateMutation)
  13977. // newContactFieldTemplateMutation creates new mutation for the ContactFieldTemplate entity.
  13978. func newContactFieldTemplateMutation(c config, op Op, opts ...contactfieldtemplateOption) *ContactFieldTemplateMutation {
  13979. m := &ContactFieldTemplateMutation{
  13980. config: c,
  13981. op: op,
  13982. typ: TypeContactFieldTemplate,
  13983. clearedFields: make(map[string]struct{}),
  13984. }
  13985. for _, opt := range opts {
  13986. opt(m)
  13987. }
  13988. return m
  13989. }
  13990. // withContactFieldTemplateID sets the ID field of the mutation.
  13991. func withContactFieldTemplateID(id uint64) contactfieldtemplateOption {
  13992. return func(m *ContactFieldTemplateMutation) {
  13993. var (
  13994. err error
  13995. once sync.Once
  13996. value *ContactFieldTemplate
  13997. )
  13998. m.oldValue = func(ctx context.Context) (*ContactFieldTemplate, error) {
  13999. once.Do(func() {
  14000. if m.done {
  14001. err = errors.New("querying old values post mutation is not allowed")
  14002. } else {
  14003. value, err = m.Client().ContactFieldTemplate.Get(ctx, id)
  14004. }
  14005. })
  14006. return value, err
  14007. }
  14008. m.id = &id
  14009. }
  14010. }
  14011. // withContactFieldTemplate sets the old ContactFieldTemplate of the mutation.
  14012. func withContactFieldTemplate(node *ContactFieldTemplate) contactfieldtemplateOption {
  14013. return func(m *ContactFieldTemplateMutation) {
  14014. m.oldValue = func(context.Context) (*ContactFieldTemplate, error) {
  14015. return node, nil
  14016. }
  14017. m.id = &node.ID
  14018. }
  14019. }
  14020. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14021. // executed in a transaction (ent.Tx), a transactional client is returned.
  14022. func (m ContactFieldTemplateMutation) Client() *Client {
  14023. client := &Client{config: m.config}
  14024. client.init()
  14025. return client
  14026. }
  14027. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14028. // it returns an error otherwise.
  14029. func (m ContactFieldTemplateMutation) Tx() (*Tx, error) {
  14030. if _, ok := m.driver.(*txDriver); !ok {
  14031. return nil, errors.New("ent: mutation is not running in a transaction")
  14032. }
  14033. tx := &Tx{config: m.config}
  14034. tx.init()
  14035. return tx, nil
  14036. }
  14037. // SetID sets the value of the id field. Note that this
  14038. // operation is only accepted on creation of ContactFieldTemplate entities.
  14039. func (m *ContactFieldTemplateMutation) SetID(id uint64) {
  14040. m.id = &id
  14041. }
  14042. // ID returns the ID value in the mutation. Note that the ID is only available
  14043. // if it was provided to the builder or after it was returned from the database.
  14044. func (m *ContactFieldTemplateMutation) ID() (id uint64, exists bool) {
  14045. if m.id == nil {
  14046. return
  14047. }
  14048. return *m.id, true
  14049. }
  14050. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14051. // That means, if the mutation is applied within a transaction with an isolation level such
  14052. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14053. // or updated by the mutation.
  14054. func (m *ContactFieldTemplateMutation) IDs(ctx context.Context) ([]uint64, error) {
  14055. switch {
  14056. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14057. id, exists := m.ID()
  14058. if exists {
  14059. return []uint64{id}, nil
  14060. }
  14061. fallthrough
  14062. case m.op.Is(OpUpdate | OpDelete):
  14063. return m.Client().ContactFieldTemplate.Query().Where(m.predicates...).IDs(ctx)
  14064. default:
  14065. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14066. }
  14067. }
  14068. // SetCreatedAt sets the "created_at" field.
  14069. func (m *ContactFieldTemplateMutation) SetCreatedAt(t time.Time) {
  14070. m.created_at = &t
  14071. }
  14072. // CreatedAt returns the value of the "created_at" field in the mutation.
  14073. func (m *ContactFieldTemplateMutation) CreatedAt() (r time.Time, exists bool) {
  14074. v := m.created_at
  14075. if v == nil {
  14076. return
  14077. }
  14078. return *v, true
  14079. }
  14080. // OldCreatedAt returns the old "created_at" field's value of the ContactFieldTemplate entity.
  14081. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  14082. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14083. func (m *ContactFieldTemplateMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14084. if !m.op.Is(OpUpdateOne) {
  14085. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14086. }
  14087. if m.id == nil || m.oldValue == nil {
  14088. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14089. }
  14090. oldValue, err := m.oldValue(ctx)
  14091. if err != nil {
  14092. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14093. }
  14094. return oldValue.CreatedAt, nil
  14095. }
  14096. // ResetCreatedAt resets all changes to the "created_at" field.
  14097. func (m *ContactFieldTemplateMutation) ResetCreatedAt() {
  14098. m.created_at = nil
  14099. }
  14100. // SetUpdatedAt sets the "updated_at" field.
  14101. func (m *ContactFieldTemplateMutation) SetUpdatedAt(t time.Time) {
  14102. m.updated_at = &t
  14103. }
  14104. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14105. func (m *ContactFieldTemplateMutation) UpdatedAt() (r time.Time, exists bool) {
  14106. v := m.updated_at
  14107. if v == nil {
  14108. return
  14109. }
  14110. return *v, true
  14111. }
  14112. // OldUpdatedAt returns the old "updated_at" field's value of the ContactFieldTemplate entity.
  14113. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  14114. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14115. func (m *ContactFieldTemplateMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14116. if !m.op.Is(OpUpdateOne) {
  14117. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14118. }
  14119. if m.id == nil || m.oldValue == nil {
  14120. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14121. }
  14122. oldValue, err := m.oldValue(ctx)
  14123. if err != nil {
  14124. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14125. }
  14126. return oldValue.UpdatedAt, nil
  14127. }
  14128. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14129. func (m *ContactFieldTemplateMutation) ResetUpdatedAt() {
  14130. m.updated_at = nil
  14131. }
  14132. // SetStatus sets the "status" field.
  14133. func (m *ContactFieldTemplateMutation) SetStatus(u uint8) {
  14134. m.status = &u
  14135. m.addstatus = nil
  14136. }
  14137. // Status returns the value of the "status" field in the mutation.
  14138. func (m *ContactFieldTemplateMutation) Status() (r uint8, exists bool) {
  14139. v := m.status
  14140. if v == nil {
  14141. return
  14142. }
  14143. return *v, true
  14144. }
  14145. // OldStatus returns the old "status" field's value of the ContactFieldTemplate entity.
  14146. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  14147. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14148. func (m *ContactFieldTemplateMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14149. if !m.op.Is(OpUpdateOne) {
  14150. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14151. }
  14152. if m.id == nil || m.oldValue == nil {
  14153. return v, errors.New("OldStatus requires an ID field in the mutation")
  14154. }
  14155. oldValue, err := m.oldValue(ctx)
  14156. if err != nil {
  14157. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14158. }
  14159. return oldValue.Status, nil
  14160. }
  14161. // AddStatus adds u to the "status" field.
  14162. func (m *ContactFieldTemplateMutation) AddStatus(u int8) {
  14163. if m.addstatus != nil {
  14164. *m.addstatus += u
  14165. } else {
  14166. m.addstatus = &u
  14167. }
  14168. }
  14169. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14170. func (m *ContactFieldTemplateMutation) AddedStatus() (r int8, exists bool) {
  14171. v := m.addstatus
  14172. if v == nil {
  14173. return
  14174. }
  14175. return *v, true
  14176. }
  14177. // ClearStatus clears the value of the "status" field.
  14178. func (m *ContactFieldTemplateMutation) ClearStatus() {
  14179. m.status = nil
  14180. m.addstatus = nil
  14181. m.clearedFields[contactfieldtemplate.FieldStatus] = struct{}{}
  14182. }
  14183. // StatusCleared returns if the "status" field was cleared in this mutation.
  14184. func (m *ContactFieldTemplateMutation) StatusCleared() bool {
  14185. _, ok := m.clearedFields[contactfieldtemplate.FieldStatus]
  14186. return ok
  14187. }
  14188. // ResetStatus resets all changes to the "status" field.
  14189. func (m *ContactFieldTemplateMutation) ResetStatus() {
  14190. m.status = nil
  14191. m.addstatus = nil
  14192. delete(m.clearedFields, contactfieldtemplate.FieldStatus)
  14193. }
  14194. // SetDeletedAt sets the "deleted_at" field.
  14195. func (m *ContactFieldTemplateMutation) SetDeletedAt(t time.Time) {
  14196. m.deleted_at = &t
  14197. }
  14198. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14199. func (m *ContactFieldTemplateMutation) DeletedAt() (r time.Time, exists bool) {
  14200. v := m.deleted_at
  14201. if v == nil {
  14202. return
  14203. }
  14204. return *v, true
  14205. }
  14206. // OldDeletedAt returns the old "deleted_at" field's value of the ContactFieldTemplate entity.
  14207. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  14208. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14209. func (m *ContactFieldTemplateMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14210. if !m.op.Is(OpUpdateOne) {
  14211. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14212. }
  14213. if m.id == nil || m.oldValue == nil {
  14214. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14215. }
  14216. oldValue, err := m.oldValue(ctx)
  14217. if err != nil {
  14218. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14219. }
  14220. return oldValue.DeletedAt, nil
  14221. }
  14222. // ClearDeletedAt clears the value of the "deleted_at" field.
  14223. func (m *ContactFieldTemplateMutation) ClearDeletedAt() {
  14224. m.deleted_at = nil
  14225. m.clearedFields[contactfieldtemplate.FieldDeletedAt] = struct{}{}
  14226. }
  14227. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14228. func (m *ContactFieldTemplateMutation) DeletedAtCleared() bool {
  14229. _, ok := m.clearedFields[contactfieldtemplate.FieldDeletedAt]
  14230. return ok
  14231. }
  14232. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14233. func (m *ContactFieldTemplateMutation) ResetDeletedAt() {
  14234. m.deleted_at = nil
  14235. delete(m.clearedFields, contactfieldtemplate.FieldDeletedAt)
  14236. }
  14237. // SetOrganizationID sets the "organization_id" field.
  14238. func (m *ContactFieldTemplateMutation) SetOrganizationID(u uint64) {
  14239. m.organization_id = &u
  14240. m.addorganization_id = nil
  14241. }
  14242. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14243. func (m *ContactFieldTemplateMutation) OrganizationID() (r uint64, exists bool) {
  14244. v := m.organization_id
  14245. if v == nil {
  14246. return
  14247. }
  14248. return *v, true
  14249. }
  14250. // OldOrganizationID returns the old "organization_id" field's value of the ContactFieldTemplate entity.
  14251. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  14252. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14253. func (m *ContactFieldTemplateMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14254. if !m.op.Is(OpUpdateOne) {
  14255. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14256. }
  14257. if m.id == nil || m.oldValue == nil {
  14258. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14259. }
  14260. oldValue, err := m.oldValue(ctx)
  14261. if err != nil {
  14262. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14263. }
  14264. return oldValue.OrganizationID, nil
  14265. }
  14266. // AddOrganizationID adds u to the "organization_id" field.
  14267. func (m *ContactFieldTemplateMutation) AddOrganizationID(u int64) {
  14268. if m.addorganization_id != nil {
  14269. *m.addorganization_id += u
  14270. } else {
  14271. m.addorganization_id = &u
  14272. }
  14273. }
  14274. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14275. func (m *ContactFieldTemplateMutation) AddedOrganizationID() (r int64, exists bool) {
  14276. v := m.addorganization_id
  14277. if v == nil {
  14278. return
  14279. }
  14280. return *v, true
  14281. }
  14282. // ResetOrganizationID resets all changes to the "organization_id" field.
  14283. func (m *ContactFieldTemplateMutation) ResetOrganizationID() {
  14284. m.organization_id = nil
  14285. m.addorganization_id = nil
  14286. }
  14287. // SetTemplate sets the "template" field.
  14288. func (m *ContactFieldTemplateMutation) SetTemplate(ctft []custom_types.ContactFieldTemplate) {
  14289. m.template = &ctft
  14290. m.appendtemplate = nil
  14291. }
  14292. // Template returns the value of the "template" field in the mutation.
  14293. func (m *ContactFieldTemplateMutation) Template() (r []custom_types.ContactFieldTemplate, exists bool) {
  14294. v := m.template
  14295. if v == nil {
  14296. return
  14297. }
  14298. return *v, true
  14299. }
  14300. // OldTemplate returns the old "template" field's value of the ContactFieldTemplate entity.
  14301. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  14302. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14303. func (m *ContactFieldTemplateMutation) OldTemplate(ctx context.Context) (v []custom_types.ContactFieldTemplate, err error) {
  14304. if !m.op.Is(OpUpdateOne) {
  14305. return v, errors.New("OldTemplate is only allowed on UpdateOne operations")
  14306. }
  14307. if m.id == nil || m.oldValue == nil {
  14308. return v, errors.New("OldTemplate requires an ID field in the mutation")
  14309. }
  14310. oldValue, err := m.oldValue(ctx)
  14311. if err != nil {
  14312. return v, fmt.Errorf("querying old value for OldTemplate: %w", err)
  14313. }
  14314. return oldValue.Template, nil
  14315. }
  14316. // AppendTemplate adds ctft to the "template" field.
  14317. func (m *ContactFieldTemplateMutation) AppendTemplate(ctft []custom_types.ContactFieldTemplate) {
  14318. m.appendtemplate = append(m.appendtemplate, ctft...)
  14319. }
  14320. // AppendedTemplate returns the list of values that were appended to the "template" field in this mutation.
  14321. func (m *ContactFieldTemplateMutation) AppendedTemplate() ([]custom_types.ContactFieldTemplate, bool) {
  14322. if len(m.appendtemplate) == 0 {
  14323. return nil, false
  14324. }
  14325. return m.appendtemplate, true
  14326. }
  14327. // ResetTemplate resets all changes to the "template" field.
  14328. func (m *ContactFieldTemplateMutation) ResetTemplate() {
  14329. m.template = nil
  14330. m.appendtemplate = nil
  14331. }
  14332. // Where appends a list predicates to the ContactFieldTemplateMutation builder.
  14333. func (m *ContactFieldTemplateMutation) Where(ps ...predicate.ContactFieldTemplate) {
  14334. m.predicates = append(m.predicates, ps...)
  14335. }
  14336. // WhereP appends storage-level predicates to the ContactFieldTemplateMutation builder. Using this method,
  14337. // users can use type-assertion to append predicates that do not depend on any generated package.
  14338. func (m *ContactFieldTemplateMutation) WhereP(ps ...func(*sql.Selector)) {
  14339. p := make([]predicate.ContactFieldTemplate, len(ps))
  14340. for i := range ps {
  14341. p[i] = ps[i]
  14342. }
  14343. m.Where(p...)
  14344. }
  14345. // Op returns the operation name.
  14346. func (m *ContactFieldTemplateMutation) Op() Op {
  14347. return m.op
  14348. }
  14349. // SetOp allows setting the mutation operation.
  14350. func (m *ContactFieldTemplateMutation) SetOp(op Op) {
  14351. m.op = op
  14352. }
  14353. // Type returns the node type of this mutation (ContactFieldTemplate).
  14354. func (m *ContactFieldTemplateMutation) Type() string {
  14355. return m.typ
  14356. }
  14357. // Fields returns all fields that were changed during this mutation. Note that in
  14358. // order to get all numeric fields that were incremented/decremented, call
  14359. // AddedFields().
  14360. func (m *ContactFieldTemplateMutation) Fields() []string {
  14361. fields := make([]string, 0, 6)
  14362. if m.created_at != nil {
  14363. fields = append(fields, contactfieldtemplate.FieldCreatedAt)
  14364. }
  14365. if m.updated_at != nil {
  14366. fields = append(fields, contactfieldtemplate.FieldUpdatedAt)
  14367. }
  14368. if m.status != nil {
  14369. fields = append(fields, contactfieldtemplate.FieldStatus)
  14370. }
  14371. if m.deleted_at != nil {
  14372. fields = append(fields, contactfieldtemplate.FieldDeletedAt)
  14373. }
  14374. if m.organization_id != nil {
  14375. fields = append(fields, contactfieldtemplate.FieldOrganizationID)
  14376. }
  14377. if m.template != nil {
  14378. fields = append(fields, contactfieldtemplate.FieldTemplate)
  14379. }
  14380. return fields
  14381. }
  14382. // Field returns the value of a field with the given name. The second boolean
  14383. // return value indicates that this field was not set, or was not defined in the
  14384. // schema.
  14385. func (m *ContactFieldTemplateMutation) Field(name string) (ent.Value, bool) {
  14386. switch name {
  14387. case contactfieldtemplate.FieldCreatedAt:
  14388. return m.CreatedAt()
  14389. case contactfieldtemplate.FieldUpdatedAt:
  14390. return m.UpdatedAt()
  14391. case contactfieldtemplate.FieldStatus:
  14392. return m.Status()
  14393. case contactfieldtemplate.FieldDeletedAt:
  14394. return m.DeletedAt()
  14395. case contactfieldtemplate.FieldOrganizationID:
  14396. return m.OrganizationID()
  14397. case contactfieldtemplate.FieldTemplate:
  14398. return m.Template()
  14399. }
  14400. return nil, false
  14401. }
  14402. // OldField returns the old value of the field from the database. An error is
  14403. // returned if the mutation operation is not UpdateOne, or the query to the
  14404. // database failed.
  14405. func (m *ContactFieldTemplateMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14406. switch name {
  14407. case contactfieldtemplate.FieldCreatedAt:
  14408. return m.OldCreatedAt(ctx)
  14409. case contactfieldtemplate.FieldUpdatedAt:
  14410. return m.OldUpdatedAt(ctx)
  14411. case contactfieldtemplate.FieldStatus:
  14412. return m.OldStatus(ctx)
  14413. case contactfieldtemplate.FieldDeletedAt:
  14414. return m.OldDeletedAt(ctx)
  14415. case contactfieldtemplate.FieldOrganizationID:
  14416. return m.OldOrganizationID(ctx)
  14417. case contactfieldtemplate.FieldTemplate:
  14418. return m.OldTemplate(ctx)
  14419. }
  14420. return nil, fmt.Errorf("unknown ContactFieldTemplate field %s", name)
  14421. }
  14422. // SetField sets the value of a field with the given name. It returns an error if
  14423. // the field is not defined in the schema, or if the type mismatched the field
  14424. // type.
  14425. func (m *ContactFieldTemplateMutation) SetField(name string, value ent.Value) error {
  14426. switch name {
  14427. case contactfieldtemplate.FieldCreatedAt:
  14428. v, ok := value.(time.Time)
  14429. if !ok {
  14430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14431. }
  14432. m.SetCreatedAt(v)
  14433. return nil
  14434. case contactfieldtemplate.FieldUpdatedAt:
  14435. v, ok := value.(time.Time)
  14436. if !ok {
  14437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14438. }
  14439. m.SetUpdatedAt(v)
  14440. return nil
  14441. case contactfieldtemplate.FieldStatus:
  14442. v, ok := value.(uint8)
  14443. if !ok {
  14444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14445. }
  14446. m.SetStatus(v)
  14447. return nil
  14448. case contactfieldtemplate.FieldDeletedAt:
  14449. v, ok := value.(time.Time)
  14450. if !ok {
  14451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14452. }
  14453. m.SetDeletedAt(v)
  14454. return nil
  14455. case contactfieldtemplate.FieldOrganizationID:
  14456. v, ok := value.(uint64)
  14457. if !ok {
  14458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14459. }
  14460. m.SetOrganizationID(v)
  14461. return nil
  14462. case contactfieldtemplate.FieldTemplate:
  14463. v, ok := value.([]custom_types.ContactFieldTemplate)
  14464. if !ok {
  14465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14466. }
  14467. m.SetTemplate(v)
  14468. return nil
  14469. }
  14470. return fmt.Errorf("unknown ContactFieldTemplate field %s", name)
  14471. }
  14472. // AddedFields returns all numeric fields that were incremented/decremented during
  14473. // this mutation.
  14474. func (m *ContactFieldTemplateMutation) AddedFields() []string {
  14475. var fields []string
  14476. if m.addstatus != nil {
  14477. fields = append(fields, contactfieldtemplate.FieldStatus)
  14478. }
  14479. if m.addorganization_id != nil {
  14480. fields = append(fields, contactfieldtemplate.FieldOrganizationID)
  14481. }
  14482. return fields
  14483. }
  14484. // AddedField returns the numeric value that was incremented/decremented on a field
  14485. // with the given name. The second boolean return value indicates that this field
  14486. // was not set, or was not defined in the schema.
  14487. func (m *ContactFieldTemplateMutation) AddedField(name string) (ent.Value, bool) {
  14488. switch name {
  14489. case contactfieldtemplate.FieldStatus:
  14490. return m.AddedStatus()
  14491. case contactfieldtemplate.FieldOrganizationID:
  14492. return m.AddedOrganizationID()
  14493. }
  14494. return nil, false
  14495. }
  14496. // AddField adds the value to the field with the given name. It returns an error if
  14497. // the field is not defined in the schema, or if the type mismatched the field
  14498. // type.
  14499. func (m *ContactFieldTemplateMutation) AddField(name string, value ent.Value) error {
  14500. switch name {
  14501. case contactfieldtemplate.FieldStatus:
  14502. v, ok := value.(int8)
  14503. if !ok {
  14504. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14505. }
  14506. m.AddStatus(v)
  14507. return nil
  14508. case contactfieldtemplate.FieldOrganizationID:
  14509. v, ok := value.(int64)
  14510. if !ok {
  14511. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14512. }
  14513. m.AddOrganizationID(v)
  14514. return nil
  14515. }
  14516. return fmt.Errorf("unknown ContactFieldTemplate numeric field %s", name)
  14517. }
  14518. // ClearedFields returns all nullable fields that were cleared during this
  14519. // mutation.
  14520. func (m *ContactFieldTemplateMutation) ClearedFields() []string {
  14521. var fields []string
  14522. if m.FieldCleared(contactfieldtemplate.FieldStatus) {
  14523. fields = append(fields, contactfieldtemplate.FieldStatus)
  14524. }
  14525. if m.FieldCleared(contactfieldtemplate.FieldDeletedAt) {
  14526. fields = append(fields, contactfieldtemplate.FieldDeletedAt)
  14527. }
  14528. return fields
  14529. }
  14530. // FieldCleared returns a boolean indicating if a field with the given name was
  14531. // cleared in this mutation.
  14532. func (m *ContactFieldTemplateMutation) FieldCleared(name string) bool {
  14533. _, ok := m.clearedFields[name]
  14534. return ok
  14535. }
  14536. // ClearField clears the value of the field with the given name. It returns an
  14537. // error if the field is not defined in the schema.
  14538. func (m *ContactFieldTemplateMutation) ClearField(name string) error {
  14539. switch name {
  14540. case contactfieldtemplate.FieldStatus:
  14541. m.ClearStatus()
  14542. return nil
  14543. case contactfieldtemplate.FieldDeletedAt:
  14544. m.ClearDeletedAt()
  14545. return nil
  14546. }
  14547. return fmt.Errorf("unknown ContactFieldTemplate nullable field %s", name)
  14548. }
  14549. // ResetField resets all changes in the mutation for the field with the given name.
  14550. // It returns an error if the field is not defined in the schema.
  14551. func (m *ContactFieldTemplateMutation) ResetField(name string) error {
  14552. switch name {
  14553. case contactfieldtemplate.FieldCreatedAt:
  14554. m.ResetCreatedAt()
  14555. return nil
  14556. case contactfieldtemplate.FieldUpdatedAt:
  14557. m.ResetUpdatedAt()
  14558. return nil
  14559. case contactfieldtemplate.FieldStatus:
  14560. m.ResetStatus()
  14561. return nil
  14562. case contactfieldtemplate.FieldDeletedAt:
  14563. m.ResetDeletedAt()
  14564. return nil
  14565. case contactfieldtemplate.FieldOrganizationID:
  14566. m.ResetOrganizationID()
  14567. return nil
  14568. case contactfieldtemplate.FieldTemplate:
  14569. m.ResetTemplate()
  14570. return nil
  14571. }
  14572. return fmt.Errorf("unknown ContactFieldTemplate field %s", name)
  14573. }
  14574. // AddedEdges returns all edge names that were set/added in this mutation.
  14575. func (m *ContactFieldTemplateMutation) AddedEdges() []string {
  14576. edges := make([]string, 0, 0)
  14577. return edges
  14578. }
  14579. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14580. // name in this mutation.
  14581. func (m *ContactFieldTemplateMutation) AddedIDs(name string) []ent.Value {
  14582. return nil
  14583. }
  14584. // RemovedEdges returns all edge names that were removed in this mutation.
  14585. func (m *ContactFieldTemplateMutation) RemovedEdges() []string {
  14586. edges := make([]string, 0, 0)
  14587. return edges
  14588. }
  14589. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14590. // the given name in this mutation.
  14591. func (m *ContactFieldTemplateMutation) RemovedIDs(name string) []ent.Value {
  14592. return nil
  14593. }
  14594. // ClearedEdges returns all edge names that were cleared in this mutation.
  14595. func (m *ContactFieldTemplateMutation) ClearedEdges() []string {
  14596. edges := make([]string, 0, 0)
  14597. return edges
  14598. }
  14599. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14600. // was cleared in this mutation.
  14601. func (m *ContactFieldTemplateMutation) EdgeCleared(name string) bool {
  14602. return false
  14603. }
  14604. // ClearEdge clears the value of the edge with the given name. It returns an error
  14605. // if that edge is not defined in the schema.
  14606. func (m *ContactFieldTemplateMutation) ClearEdge(name string) error {
  14607. return fmt.Errorf("unknown ContactFieldTemplate unique edge %s", name)
  14608. }
  14609. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14610. // It returns an error if the edge is not defined in the schema.
  14611. func (m *ContactFieldTemplateMutation) ResetEdge(name string) error {
  14612. return fmt.Errorf("unknown ContactFieldTemplate edge %s", name)
  14613. }
  14614. // CreditBalanceMutation represents an operation that mutates the CreditBalance nodes in the graph.
  14615. type CreditBalanceMutation struct {
  14616. config
  14617. op Op
  14618. typ string
  14619. id *uint64
  14620. created_at *time.Time
  14621. updated_at *time.Time
  14622. deleted_at *time.Time
  14623. user_id *string
  14624. balance *float64
  14625. addbalance *float64
  14626. status *int
  14627. addstatus *int
  14628. organization_id *uint64
  14629. addorganization_id *int64
  14630. clearedFields map[string]struct{}
  14631. done bool
  14632. oldValue func(context.Context) (*CreditBalance, error)
  14633. predicates []predicate.CreditBalance
  14634. }
  14635. var _ ent.Mutation = (*CreditBalanceMutation)(nil)
  14636. // creditbalanceOption allows management of the mutation configuration using functional options.
  14637. type creditbalanceOption func(*CreditBalanceMutation)
  14638. // newCreditBalanceMutation creates new mutation for the CreditBalance entity.
  14639. func newCreditBalanceMutation(c config, op Op, opts ...creditbalanceOption) *CreditBalanceMutation {
  14640. m := &CreditBalanceMutation{
  14641. config: c,
  14642. op: op,
  14643. typ: TypeCreditBalance,
  14644. clearedFields: make(map[string]struct{}),
  14645. }
  14646. for _, opt := range opts {
  14647. opt(m)
  14648. }
  14649. return m
  14650. }
  14651. // withCreditBalanceID sets the ID field of the mutation.
  14652. func withCreditBalanceID(id uint64) creditbalanceOption {
  14653. return func(m *CreditBalanceMutation) {
  14654. var (
  14655. err error
  14656. once sync.Once
  14657. value *CreditBalance
  14658. )
  14659. m.oldValue = func(ctx context.Context) (*CreditBalance, error) {
  14660. once.Do(func() {
  14661. if m.done {
  14662. err = errors.New("querying old values post mutation is not allowed")
  14663. } else {
  14664. value, err = m.Client().CreditBalance.Get(ctx, id)
  14665. }
  14666. })
  14667. return value, err
  14668. }
  14669. m.id = &id
  14670. }
  14671. }
  14672. // withCreditBalance sets the old CreditBalance of the mutation.
  14673. func withCreditBalance(node *CreditBalance) creditbalanceOption {
  14674. return func(m *CreditBalanceMutation) {
  14675. m.oldValue = func(context.Context) (*CreditBalance, error) {
  14676. return node, nil
  14677. }
  14678. m.id = &node.ID
  14679. }
  14680. }
  14681. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14682. // executed in a transaction (ent.Tx), a transactional client is returned.
  14683. func (m CreditBalanceMutation) Client() *Client {
  14684. client := &Client{config: m.config}
  14685. client.init()
  14686. return client
  14687. }
  14688. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14689. // it returns an error otherwise.
  14690. func (m CreditBalanceMutation) Tx() (*Tx, error) {
  14691. if _, ok := m.driver.(*txDriver); !ok {
  14692. return nil, errors.New("ent: mutation is not running in a transaction")
  14693. }
  14694. tx := &Tx{config: m.config}
  14695. tx.init()
  14696. return tx, nil
  14697. }
  14698. // SetID sets the value of the id field. Note that this
  14699. // operation is only accepted on creation of CreditBalance entities.
  14700. func (m *CreditBalanceMutation) SetID(id uint64) {
  14701. m.id = &id
  14702. }
  14703. // ID returns the ID value in the mutation. Note that the ID is only available
  14704. // if it was provided to the builder or after it was returned from the database.
  14705. func (m *CreditBalanceMutation) ID() (id uint64, exists bool) {
  14706. if m.id == nil {
  14707. return
  14708. }
  14709. return *m.id, true
  14710. }
  14711. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14712. // That means, if the mutation is applied within a transaction with an isolation level such
  14713. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14714. // or updated by the mutation.
  14715. func (m *CreditBalanceMutation) IDs(ctx context.Context) ([]uint64, error) {
  14716. switch {
  14717. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14718. id, exists := m.ID()
  14719. if exists {
  14720. return []uint64{id}, nil
  14721. }
  14722. fallthrough
  14723. case m.op.Is(OpUpdate | OpDelete):
  14724. return m.Client().CreditBalance.Query().Where(m.predicates...).IDs(ctx)
  14725. default:
  14726. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14727. }
  14728. }
  14729. // SetCreatedAt sets the "created_at" field.
  14730. func (m *CreditBalanceMutation) SetCreatedAt(t time.Time) {
  14731. m.created_at = &t
  14732. }
  14733. // CreatedAt returns the value of the "created_at" field in the mutation.
  14734. func (m *CreditBalanceMutation) CreatedAt() (r time.Time, exists bool) {
  14735. v := m.created_at
  14736. if v == nil {
  14737. return
  14738. }
  14739. return *v, true
  14740. }
  14741. // OldCreatedAt returns the old "created_at" field's value of the CreditBalance entity.
  14742. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  14743. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14744. func (m *CreditBalanceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14745. if !m.op.Is(OpUpdateOne) {
  14746. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14747. }
  14748. if m.id == nil || m.oldValue == nil {
  14749. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14750. }
  14751. oldValue, err := m.oldValue(ctx)
  14752. if err != nil {
  14753. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14754. }
  14755. return oldValue.CreatedAt, nil
  14756. }
  14757. // ResetCreatedAt resets all changes to the "created_at" field.
  14758. func (m *CreditBalanceMutation) ResetCreatedAt() {
  14759. m.created_at = nil
  14760. }
  14761. // SetUpdatedAt sets the "updated_at" field.
  14762. func (m *CreditBalanceMutation) SetUpdatedAt(t time.Time) {
  14763. m.updated_at = &t
  14764. }
  14765. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14766. func (m *CreditBalanceMutation) UpdatedAt() (r time.Time, exists bool) {
  14767. v := m.updated_at
  14768. if v == nil {
  14769. return
  14770. }
  14771. return *v, true
  14772. }
  14773. // OldUpdatedAt returns the old "updated_at" field's value of the CreditBalance entity.
  14774. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  14775. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14776. func (m *CreditBalanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14777. if !m.op.Is(OpUpdateOne) {
  14778. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14779. }
  14780. if m.id == nil || m.oldValue == nil {
  14781. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14782. }
  14783. oldValue, err := m.oldValue(ctx)
  14784. if err != nil {
  14785. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14786. }
  14787. return oldValue.UpdatedAt, nil
  14788. }
  14789. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14790. func (m *CreditBalanceMutation) ResetUpdatedAt() {
  14791. m.updated_at = nil
  14792. }
  14793. // SetDeletedAt sets the "deleted_at" field.
  14794. func (m *CreditBalanceMutation) SetDeletedAt(t time.Time) {
  14795. m.deleted_at = &t
  14796. }
  14797. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14798. func (m *CreditBalanceMutation) DeletedAt() (r time.Time, exists bool) {
  14799. v := m.deleted_at
  14800. if v == nil {
  14801. return
  14802. }
  14803. return *v, true
  14804. }
  14805. // OldDeletedAt returns the old "deleted_at" field's value of the CreditBalance entity.
  14806. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  14807. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14808. func (m *CreditBalanceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14809. if !m.op.Is(OpUpdateOne) {
  14810. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14811. }
  14812. if m.id == nil || m.oldValue == nil {
  14813. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14814. }
  14815. oldValue, err := m.oldValue(ctx)
  14816. if err != nil {
  14817. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14818. }
  14819. return oldValue.DeletedAt, nil
  14820. }
  14821. // ClearDeletedAt clears the value of the "deleted_at" field.
  14822. func (m *CreditBalanceMutation) ClearDeletedAt() {
  14823. m.deleted_at = nil
  14824. m.clearedFields[creditbalance.FieldDeletedAt] = struct{}{}
  14825. }
  14826. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14827. func (m *CreditBalanceMutation) DeletedAtCleared() bool {
  14828. _, ok := m.clearedFields[creditbalance.FieldDeletedAt]
  14829. return ok
  14830. }
  14831. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14832. func (m *CreditBalanceMutation) ResetDeletedAt() {
  14833. m.deleted_at = nil
  14834. delete(m.clearedFields, creditbalance.FieldDeletedAt)
  14835. }
  14836. // SetUserID sets the "user_id" field.
  14837. func (m *CreditBalanceMutation) SetUserID(s string) {
  14838. m.user_id = &s
  14839. }
  14840. // UserID returns the value of the "user_id" field in the mutation.
  14841. func (m *CreditBalanceMutation) UserID() (r string, exists bool) {
  14842. v := m.user_id
  14843. if v == nil {
  14844. return
  14845. }
  14846. return *v, true
  14847. }
  14848. // OldUserID returns the old "user_id" field's value of the CreditBalance entity.
  14849. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  14850. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14851. func (m *CreditBalanceMutation) OldUserID(ctx context.Context) (v string, err error) {
  14852. if !m.op.Is(OpUpdateOne) {
  14853. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  14854. }
  14855. if m.id == nil || m.oldValue == nil {
  14856. return v, errors.New("OldUserID requires an ID field in the mutation")
  14857. }
  14858. oldValue, err := m.oldValue(ctx)
  14859. if err != nil {
  14860. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  14861. }
  14862. return oldValue.UserID, nil
  14863. }
  14864. // ClearUserID clears the value of the "user_id" field.
  14865. func (m *CreditBalanceMutation) ClearUserID() {
  14866. m.user_id = nil
  14867. m.clearedFields[creditbalance.FieldUserID] = struct{}{}
  14868. }
  14869. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  14870. func (m *CreditBalanceMutation) UserIDCleared() bool {
  14871. _, ok := m.clearedFields[creditbalance.FieldUserID]
  14872. return ok
  14873. }
  14874. // ResetUserID resets all changes to the "user_id" field.
  14875. func (m *CreditBalanceMutation) ResetUserID() {
  14876. m.user_id = nil
  14877. delete(m.clearedFields, creditbalance.FieldUserID)
  14878. }
  14879. // SetBalance sets the "balance" field.
  14880. func (m *CreditBalanceMutation) SetBalance(f float64) {
  14881. m.balance = &f
  14882. m.addbalance = nil
  14883. }
  14884. // Balance returns the value of the "balance" field in the mutation.
  14885. func (m *CreditBalanceMutation) Balance() (r float64, exists bool) {
  14886. v := m.balance
  14887. if v == nil {
  14888. return
  14889. }
  14890. return *v, true
  14891. }
  14892. // OldBalance returns the old "balance" field's value of the CreditBalance entity.
  14893. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  14894. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14895. func (m *CreditBalanceMutation) OldBalance(ctx context.Context) (v float64, err error) {
  14896. if !m.op.Is(OpUpdateOne) {
  14897. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  14898. }
  14899. if m.id == nil || m.oldValue == nil {
  14900. return v, errors.New("OldBalance requires an ID field in the mutation")
  14901. }
  14902. oldValue, err := m.oldValue(ctx)
  14903. if err != nil {
  14904. return v, fmt.Errorf("querying old value for OldBalance: %w", err)
  14905. }
  14906. return oldValue.Balance, nil
  14907. }
  14908. // AddBalance adds f to the "balance" field.
  14909. func (m *CreditBalanceMutation) AddBalance(f float64) {
  14910. if m.addbalance != nil {
  14911. *m.addbalance += f
  14912. } else {
  14913. m.addbalance = &f
  14914. }
  14915. }
  14916. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  14917. func (m *CreditBalanceMutation) AddedBalance() (r float64, exists bool) {
  14918. v := m.addbalance
  14919. if v == nil {
  14920. return
  14921. }
  14922. return *v, true
  14923. }
  14924. // ResetBalance resets all changes to the "balance" field.
  14925. func (m *CreditBalanceMutation) ResetBalance() {
  14926. m.balance = nil
  14927. m.addbalance = nil
  14928. }
  14929. // SetStatus sets the "status" field.
  14930. func (m *CreditBalanceMutation) SetStatus(i int) {
  14931. m.status = &i
  14932. m.addstatus = nil
  14933. }
  14934. // Status returns the value of the "status" field in the mutation.
  14935. func (m *CreditBalanceMutation) Status() (r int, exists bool) {
  14936. v := m.status
  14937. if v == nil {
  14938. return
  14939. }
  14940. return *v, true
  14941. }
  14942. // OldStatus returns the old "status" field's value of the CreditBalance entity.
  14943. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  14944. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14945. func (m *CreditBalanceMutation) OldStatus(ctx context.Context) (v int, err error) {
  14946. if !m.op.Is(OpUpdateOne) {
  14947. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14948. }
  14949. if m.id == nil || m.oldValue == nil {
  14950. return v, errors.New("OldStatus requires an ID field in the mutation")
  14951. }
  14952. oldValue, err := m.oldValue(ctx)
  14953. if err != nil {
  14954. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14955. }
  14956. return oldValue.Status, nil
  14957. }
  14958. // AddStatus adds i to the "status" field.
  14959. func (m *CreditBalanceMutation) AddStatus(i int) {
  14960. if m.addstatus != nil {
  14961. *m.addstatus += i
  14962. } else {
  14963. m.addstatus = &i
  14964. }
  14965. }
  14966. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14967. func (m *CreditBalanceMutation) AddedStatus() (r int, exists bool) {
  14968. v := m.addstatus
  14969. if v == nil {
  14970. return
  14971. }
  14972. return *v, true
  14973. }
  14974. // ClearStatus clears the value of the "status" field.
  14975. func (m *CreditBalanceMutation) ClearStatus() {
  14976. m.status = nil
  14977. m.addstatus = nil
  14978. m.clearedFields[creditbalance.FieldStatus] = struct{}{}
  14979. }
  14980. // StatusCleared returns if the "status" field was cleared in this mutation.
  14981. func (m *CreditBalanceMutation) StatusCleared() bool {
  14982. _, ok := m.clearedFields[creditbalance.FieldStatus]
  14983. return ok
  14984. }
  14985. // ResetStatus resets all changes to the "status" field.
  14986. func (m *CreditBalanceMutation) ResetStatus() {
  14987. m.status = nil
  14988. m.addstatus = nil
  14989. delete(m.clearedFields, creditbalance.FieldStatus)
  14990. }
  14991. // SetOrganizationID sets the "organization_id" field.
  14992. func (m *CreditBalanceMutation) SetOrganizationID(u uint64) {
  14993. m.organization_id = &u
  14994. m.addorganization_id = nil
  14995. }
  14996. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14997. func (m *CreditBalanceMutation) OrganizationID() (r uint64, exists bool) {
  14998. v := m.organization_id
  14999. if v == nil {
  15000. return
  15001. }
  15002. return *v, true
  15003. }
  15004. // OldOrganizationID returns the old "organization_id" field's value of the CreditBalance entity.
  15005. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  15006. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15007. func (m *CreditBalanceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15008. if !m.op.Is(OpUpdateOne) {
  15009. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15010. }
  15011. if m.id == nil || m.oldValue == nil {
  15012. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15013. }
  15014. oldValue, err := m.oldValue(ctx)
  15015. if err != nil {
  15016. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15017. }
  15018. return oldValue.OrganizationID, nil
  15019. }
  15020. // AddOrganizationID adds u to the "organization_id" field.
  15021. func (m *CreditBalanceMutation) AddOrganizationID(u int64) {
  15022. if m.addorganization_id != nil {
  15023. *m.addorganization_id += u
  15024. } else {
  15025. m.addorganization_id = &u
  15026. }
  15027. }
  15028. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15029. func (m *CreditBalanceMutation) AddedOrganizationID() (r int64, exists bool) {
  15030. v := m.addorganization_id
  15031. if v == nil {
  15032. return
  15033. }
  15034. return *v, true
  15035. }
  15036. // ClearOrganizationID clears the value of the "organization_id" field.
  15037. func (m *CreditBalanceMutation) ClearOrganizationID() {
  15038. m.organization_id = nil
  15039. m.addorganization_id = nil
  15040. m.clearedFields[creditbalance.FieldOrganizationID] = struct{}{}
  15041. }
  15042. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  15043. func (m *CreditBalanceMutation) OrganizationIDCleared() bool {
  15044. _, ok := m.clearedFields[creditbalance.FieldOrganizationID]
  15045. return ok
  15046. }
  15047. // ResetOrganizationID resets all changes to the "organization_id" field.
  15048. func (m *CreditBalanceMutation) ResetOrganizationID() {
  15049. m.organization_id = nil
  15050. m.addorganization_id = nil
  15051. delete(m.clearedFields, creditbalance.FieldOrganizationID)
  15052. }
  15053. // Where appends a list predicates to the CreditBalanceMutation builder.
  15054. func (m *CreditBalanceMutation) Where(ps ...predicate.CreditBalance) {
  15055. m.predicates = append(m.predicates, ps...)
  15056. }
  15057. // WhereP appends storage-level predicates to the CreditBalanceMutation builder. Using this method,
  15058. // users can use type-assertion to append predicates that do not depend on any generated package.
  15059. func (m *CreditBalanceMutation) WhereP(ps ...func(*sql.Selector)) {
  15060. p := make([]predicate.CreditBalance, len(ps))
  15061. for i := range ps {
  15062. p[i] = ps[i]
  15063. }
  15064. m.Where(p...)
  15065. }
  15066. // Op returns the operation name.
  15067. func (m *CreditBalanceMutation) Op() Op {
  15068. return m.op
  15069. }
  15070. // SetOp allows setting the mutation operation.
  15071. func (m *CreditBalanceMutation) SetOp(op Op) {
  15072. m.op = op
  15073. }
  15074. // Type returns the node type of this mutation (CreditBalance).
  15075. func (m *CreditBalanceMutation) Type() string {
  15076. return m.typ
  15077. }
  15078. // Fields returns all fields that were changed during this mutation. Note that in
  15079. // order to get all numeric fields that were incremented/decremented, call
  15080. // AddedFields().
  15081. func (m *CreditBalanceMutation) Fields() []string {
  15082. fields := make([]string, 0, 7)
  15083. if m.created_at != nil {
  15084. fields = append(fields, creditbalance.FieldCreatedAt)
  15085. }
  15086. if m.updated_at != nil {
  15087. fields = append(fields, creditbalance.FieldUpdatedAt)
  15088. }
  15089. if m.deleted_at != nil {
  15090. fields = append(fields, creditbalance.FieldDeletedAt)
  15091. }
  15092. if m.user_id != nil {
  15093. fields = append(fields, creditbalance.FieldUserID)
  15094. }
  15095. if m.balance != nil {
  15096. fields = append(fields, creditbalance.FieldBalance)
  15097. }
  15098. if m.status != nil {
  15099. fields = append(fields, creditbalance.FieldStatus)
  15100. }
  15101. if m.organization_id != nil {
  15102. fields = append(fields, creditbalance.FieldOrganizationID)
  15103. }
  15104. return fields
  15105. }
  15106. // Field returns the value of a field with the given name. The second boolean
  15107. // return value indicates that this field was not set, or was not defined in the
  15108. // schema.
  15109. func (m *CreditBalanceMutation) Field(name string) (ent.Value, bool) {
  15110. switch name {
  15111. case creditbalance.FieldCreatedAt:
  15112. return m.CreatedAt()
  15113. case creditbalance.FieldUpdatedAt:
  15114. return m.UpdatedAt()
  15115. case creditbalance.FieldDeletedAt:
  15116. return m.DeletedAt()
  15117. case creditbalance.FieldUserID:
  15118. return m.UserID()
  15119. case creditbalance.FieldBalance:
  15120. return m.Balance()
  15121. case creditbalance.FieldStatus:
  15122. return m.Status()
  15123. case creditbalance.FieldOrganizationID:
  15124. return m.OrganizationID()
  15125. }
  15126. return nil, false
  15127. }
  15128. // OldField returns the old value of the field from the database. An error is
  15129. // returned if the mutation operation is not UpdateOne, or the query to the
  15130. // database failed.
  15131. func (m *CreditBalanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15132. switch name {
  15133. case creditbalance.FieldCreatedAt:
  15134. return m.OldCreatedAt(ctx)
  15135. case creditbalance.FieldUpdatedAt:
  15136. return m.OldUpdatedAt(ctx)
  15137. case creditbalance.FieldDeletedAt:
  15138. return m.OldDeletedAt(ctx)
  15139. case creditbalance.FieldUserID:
  15140. return m.OldUserID(ctx)
  15141. case creditbalance.FieldBalance:
  15142. return m.OldBalance(ctx)
  15143. case creditbalance.FieldStatus:
  15144. return m.OldStatus(ctx)
  15145. case creditbalance.FieldOrganizationID:
  15146. return m.OldOrganizationID(ctx)
  15147. }
  15148. return nil, fmt.Errorf("unknown CreditBalance field %s", name)
  15149. }
  15150. // SetField sets the value of a field with the given name. It returns an error if
  15151. // the field is not defined in the schema, or if the type mismatched the field
  15152. // type.
  15153. func (m *CreditBalanceMutation) SetField(name string, value ent.Value) error {
  15154. switch name {
  15155. case creditbalance.FieldCreatedAt:
  15156. v, ok := value.(time.Time)
  15157. if !ok {
  15158. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15159. }
  15160. m.SetCreatedAt(v)
  15161. return nil
  15162. case creditbalance.FieldUpdatedAt:
  15163. v, ok := value.(time.Time)
  15164. if !ok {
  15165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15166. }
  15167. m.SetUpdatedAt(v)
  15168. return nil
  15169. case creditbalance.FieldDeletedAt:
  15170. v, ok := value.(time.Time)
  15171. if !ok {
  15172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15173. }
  15174. m.SetDeletedAt(v)
  15175. return nil
  15176. case creditbalance.FieldUserID:
  15177. v, ok := value.(string)
  15178. if !ok {
  15179. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15180. }
  15181. m.SetUserID(v)
  15182. return nil
  15183. case creditbalance.FieldBalance:
  15184. v, ok := value.(float64)
  15185. if !ok {
  15186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15187. }
  15188. m.SetBalance(v)
  15189. return nil
  15190. case creditbalance.FieldStatus:
  15191. v, ok := value.(int)
  15192. if !ok {
  15193. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15194. }
  15195. m.SetStatus(v)
  15196. return nil
  15197. case creditbalance.FieldOrganizationID:
  15198. v, ok := value.(uint64)
  15199. if !ok {
  15200. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15201. }
  15202. m.SetOrganizationID(v)
  15203. return nil
  15204. }
  15205. return fmt.Errorf("unknown CreditBalance field %s", name)
  15206. }
  15207. // AddedFields returns all numeric fields that were incremented/decremented during
  15208. // this mutation.
  15209. func (m *CreditBalanceMutation) AddedFields() []string {
  15210. var fields []string
  15211. if m.addbalance != nil {
  15212. fields = append(fields, creditbalance.FieldBalance)
  15213. }
  15214. if m.addstatus != nil {
  15215. fields = append(fields, creditbalance.FieldStatus)
  15216. }
  15217. if m.addorganization_id != nil {
  15218. fields = append(fields, creditbalance.FieldOrganizationID)
  15219. }
  15220. return fields
  15221. }
  15222. // AddedField returns the numeric value that was incremented/decremented on a field
  15223. // with the given name. The second boolean return value indicates that this field
  15224. // was not set, or was not defined in the schema.
  15225. func (m *CreditBalanceMutation) AddedField(name string) (ent.Value, bool) {
  15226. switch name {
  15227. case creditbalance.FieldBalance:
  15228. return m.AddedBalance()
  15229. case creditbalance.FieldStatus:
  15230. return m.AddedStatus()
  15231. case creditbalance.FieldOrganizationID:
  15232. return m.AddedOrganizationID()
  15233. }
  15234. return nil, false
  15235. }
  15236. // AddField adds the value to the field with the given name. It returns an error if
  15237. // the field is not defined in the schema, or if the type mismatched the field
  15238. // type.
  15239. func (m *CreditBalanceMutation) AddField(name string, value ent.Value) error {
  15240. switch name {
  15241. case creditbalance.FieldBalance:
  15242. v, ok := value.(float64)
  15243. if !ok {
  15244. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15245. }
  15246. m.AddBalance(v)
  15247. return nil
  15248. case creditbalance.FieldStatus:
  15249. v, ok := value.(int)
  15250. if !ok {
  15251. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15252. }
  15253. m.AddStatus(v)
  15254. return nil
  15255. case creditbalance.FieldOrganizationID:
  15256. v, ok := value.(int64)
  15257. if !ok {
  15258. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15259. }
  15260. m.AddOrganizationID(v)
  15261. return nil
  15262. }
  15263. return fmt.Errorf("unknown CreditBalance numeric field %s", name)
  15264. }
  15265. // ClearedFields returns all nullable fields that were cleared during this
  15266. // mutation.
  15267. func (m *CreditBalanceMutation) ClearedFields() []string {
  15268. var fields []string
  15269. if m.FieldCleared(creditbalance.FieldDeletedAt) {
  15270. fields = append(fields, creditbalance.FieldDeletedAt)
  15271. }
  15272. if m.FieldCleared(creditbalance.FieldUserID) {
  15273. fields = append(fields, creditbalance.FieldUserID)
  15274. }
  15275. if m.FieldCleared(creditbalance.FieldStatus) {
  15276. fields = append(fields, creditbalance.FieldStatus)
  15277. }
  15278. if m.FieldCleared(creditbalance.FieldOrganizationID) {
  15279. fields = append(fields, creditbalance.FieldOrganizationID)
  15280. }
  15281. return fields
  15282. }
  15283. // FieldCleared returns a boolean indicating if a field with the given name was
  15284. // cleared in this mutation.
  15285. func (m *CreditBalanceMutation) FieldCleared(name string) bool {
  15286. _, ok := m.clearedFields[name]
  15287. return ok
  15288. }
  15289. // ClearField clears the value of the field with the given name. It returns an
  15290. // error if the field is not defined in the schema.
  15291. func (m *CreditBalanceMutation) ClearField(name string) error {
  15292. switch name {
  15293. case creditbalance.FieldDeletedAt:
  15294. m.ClearDeletedAt()
  15295. return nil
  15296. case creditbalance.FieldUserID:
  15297. m.ClearUserID()
  15298. return nil
  15299. case creditbalance.FieldStatus:
  15300. m.ClearStatus()
  15301. return nil
  15302. case creditbalance.FieldOrganizationID:
  15303. m.ClearOrganizationID()
  15304. return nil
  15305. }
  15306. return fmt.Errorf("unknown CreditBalance nullable field %s", name)
  15307. }
  15308. // ResetField resets all changes in the mutation for the field with the given name.
  15309. // It returns an error if the field is not defined in the schema.
  15310. func (m *CreditBalanceMutation) ResetField(name string) error {
  15311. switch name {
  15312. case creditbalance.FieldCreatedAt:
  15313. m.ResetCreatedAt()
  15314. return nil
  15315. case creditbalance.FieldUpdatedAt:
  15316. m.ResetUpdatedAt()
  15317. return nil
  15318. case creditbalance.FieldDeletedAt:
  15319. m.ResetDeletedAt()
  15320. return nil
  15321. case creditbalance.FieldUserID:
  15322. m.ResetUserID()
  15323. return nil
  15324. case creditbalance.FieldBalance:
  15325. m.ResetBalance()
  15326. return nil
  15327. case creditbalance.FieldStatus:
  15328. m.ResetStatus()
  15329. return nil
  15330. case creditbalance.FieldOrganizationID:
  15331. m.ResetOrganizationID()
  15332. return nil
  15333. }
  15334. return fmt.Errorf("unknown CreditBalance field %s", name)
  15335. }
  15336. // AddedEdges returns all edge names that were set/added in this mutation.
  15337. func (m *CreditBalanceMutation) AddedEdges() []string {
  15338. edges := make([]string, 0, 0)
  15339. return edges
  15340. }
  15341. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15342. // name in this mutation.
  15343. func (m *CreditBalanceMutation) AddedIDs(name string) []ent.Value {
  15344. return nil
  15345. }
  15346. // RemovedEdges returns all edge names that were removed in this mutation.
  15347. func (m *CreditBalanceMutation) RemovedEdges() []string {
  15348. edges := make([]string, 0, 0)
  15349. return edges
  15350. }
  15351. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15352. // the given name in this mutation.
  15353. func (m *CreditBalanceMutation) RemovedIDs(name string) []ent.Value {
  15354. return nil
  15355. }
  15356. // ClearedEdges returns all edge names that were cleared in this mutation.
  15357. func (m *CreditBalanceMutation) ClearedEdges() []string {
  15358. edges := make([]string, 0, 0)
  15359. return edges
  15360. }
  15361. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15362. // was cleared in this mutation.
  15363. func (m *CreditBalanceMutation) EdgeCleared(name string) bool {
  15364. return false
  15365. }
  15366. // ClearEdge clears the value of the edge with the given name. It returns an error
  15367. // if that edge is not defined in the schema.
  15368. func (m *CreditBalanceMutation) ClearEdge(name string) error {
  15369. return fmt.Errorf("unknown CreditBalance unique edge %s", name)
  15370. }
  15371. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15372. // It returns an error if the edge is not defined in the schema.
  15373. func (m *CreditBalanceMutation) ResetEdge(name string) error {
  15374. return fmt.Errorf("unknown CreditBalance edge %s", name)
  15375. }
  15376. // CreditUsageMutation represents an operation that mutates the CreditUsage nodes in the graph.
  15377. type CreditUsageMutation struct {
  15378. config
  15379. op Op
  15380. typ string
  15381. id *uint64
  15382. created_at *time.Time
  15383. updated_at *time.Time
  15384. deleted_at *time.Time
  15385. user_id *string
  15386. number *float64
  15387. addnumber *float64
  15388. pay_number *float64
  15389. addpay_number *float64
  15390. before_number *float64
  15391. addbefore_number *float64
  15392. after_number *float64
  15393. addafter_number *float64
  15394. pay_method *int
  15395. addpay_method *int
  15396. status *int
  15397. addstatus *int
  15398. ntype *int
  15399. addntype *int
  15400. table *string
  15401. organization_id *uint64
  15402. addorganization_id *int64
  15403. nid *uint64
  15404. addnid *int64
  15405. reason *string
  15406. operator *string
  15407. clearedFields map[string]struct{}
  15408. done bool
  15409. oldValue func(context.Context) (*CreditUsage, error)
  15410. predicates []predicate.CreditUsage
  15411. }
  15412. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  15413. // creditusageOption allows management of the mutation configuration using functional options.
  15414. type creditusageOption func(*CreditUsageMutation)
  15415. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  15416. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  15417. m := &CreditUsageMutation{
  15418. config: c,
  15419. op: op,
  15420. typ: TypeCreditUsage,
  15421. clearedFields: make(map[string]struct{}),
  15422. }
  15423. for _, opt := range opts {
  15424. opt(m)
  15425. }
  15426. return m
  15427. }
  15428. // withCreditUsageID sets the ID field of the mutation.
  15429. func withCreditUsageID(id uint64) creditusageOption {
  15430. return func(m *CreditUsageMutation) {
  15431. var (
  15432. err error
  15433. once sync.Once
  15434. value *CreditUsage
  15435. )
  15436. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  15437. once.Do(func() {
  15438. if m.done {
  15439. err = errors.New("querying old values post mutation is not allowed")
  15440. } else {
  15441. value, err = m.Client().CreditUsage.Get(ctx, id)
  15442. }
  15443. })
  15444. return value, err
  15445. }
  15446. m.id = &id
  15447. }
  15448. }
  15449. // withCreditUsage sets the old CreditUsage of the mutation.
  15450. func withCreditUsage(node *CreditUsage) creditusageOption {
  15451. return func(m *CreditUsageMutation) {
  15452. m.oldValue = func(context.Context) (*CreditUsage, error) {
  15453. return node, nil
  15454. }
  15455. m.id = &node.ID
  15456. }
  15457. }
  15458. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15459. // executed in a transaction (ent.Tx), a transactional client is returned.
  15460. func (m CreditUsageMutation) Client() *Client {
  15461. client := &Client{config: m.config}
  15462. client.init()
  15463. return client
  15464. }
  15465. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15466. // it returns an error otherwise.
  15467. func (m CreditUsageMutation) Tx() (*Tx, error) {
  15468. if _, ok := m.driver.(*txDriver); !ok {
  15469. return nil, errors.New("ent: mutation is not running in a transaction")
  15470. }
  15471. tx := &Tx{config: m.config}
  15472. tx.init()
  15473. return tx, nil
  15474. }
  15475. // SetID sets the value of the id field. Note that this
  15476. // operation is only accepted on creation of CreditUsage entities.
  15477. func (m *CreditUsageMutation) SetID(id uint64) {
  15478. m.id = &id
  15479. }
  15480. // ID returns the ID value in the mutation. Note that the ID is only available
  15481. // if it was provided to the builder or after it was returned from the database.
  15482. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  15483. if m.id == nil {
  15484. return
  15485. }
  15486. return *m.id, true
  15487. }
  15488. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15489. // That means, if the mutation is applied within a transaction with an isolation level such
  15490. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15491. // or updated by the mutation.
  15492. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  15493. switch {
  15494. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15495. id, exists := m.ID()
  15496. if exists {
  15497. return []uint64{id}, nil
  15498. }
  15499. fallthrough
  15500. case m.op.Is(OpUpdate | OpDelete):
  15501. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  15502. default:
  15503. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15504. }
  15505. }
  15506. // SetCreatedAt sets the "created_at" field.
  15507. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  15508. m.created_at = &t
  15509. }
  15510. // CreatedAt returns the value of the "created_at" field in the mutation.
  15511. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  15512. v := m.created_at
  15513. if v == nil {
  15514. return
  15515. }
  15516. return *v, true
  15517. }
  15518. // OldCreatedAt returns the old "created_at" field's value of the CreditUsage entity.
  15519. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15520. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15521. func (m *CreditUsageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15522. if !m.op.Is(OpUpdateOne) {
  15523. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15524. }
  15525. if m.id == nil || m.oldValue == nil {
  15526. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15527. }
  15528. oldValue, err := m.oldValue(ctx)
  15529. if err != nil {
  15530. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15531. }
  15532. return oldValue.CreatedAt, nil
  15533. }
  15534. // ResetCreatedAt resets all changes to the "created_at" field.
  15535. func (m *CreditUsageMutation) ResetCreatedAt() {
  15536. m.created_at = nil
  15537. }
  15538. // SetUpdatedAt sets the "updated_at" field.
  15539. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  15540. m.updated_at = &t
  15541. }
  15542. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15543. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  15544. v := m.updated_at
  15545. if v == nil {
  15546. return
  15547. }
  15548. return *v, true
  15549. }
  15550. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  15551. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15552. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15553. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15554. if !m.op.Is(OpUpdateOne) {
  15555. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15556. }
  15557. if m.id == nil || m.oldValue == nil {
  15558. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15559. }
  15560. oldValue, err := m.oldValue(ctx)
  15561. if err != nil {
  15562. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15563. }
  15564. return oldValue.UpdatedAt, nil
  15565. }
  15566. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15567. func (m *CreditUsageMutation) ResetUpdatedAt() {
  15568. m.updated_at = nil
  15569. }
  15570. // SetDeletedAt sets the "deleted_at" field.
  15571. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  15572. m.deleted_at = &t
  15573. }
  15574. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15575. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  15576. v := m.deleted_at
  15577. if v == nil {
  15578. return
  15579. }
  15580. return *v, true
  15581. }
  15582. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  15583. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15584. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15585. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15586. if !m.op.Is(OpUpdateOne) {
  15587. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15588. }
  15589. if m.id == nil || m.oldValue == nil {
  15590. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15591. }
  15592. oldValue, err := m.oldValue(ctx)
  15593. if err != nil {
  15594. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15595. }
  15596. return oldValue.DeletedAt, nil
  15597. }
  15598. // ClearDeletedAt clears the value of the "deleted_at" field.
  15599. func (m *CreditUsageMutation) ClearDeletedAt() {
  15600. m.deleted_at = nil
  15601. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  15602. }
  15603. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15604. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  15605. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  15606. return ok
  15607. }
  15608. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15609. func (m *CreditUsageMutation) ResetDeletedAt() {
  15610. m.deleted_at = nil
  15611. delete(m.clearedFields, creditusage.FieldDeletedAt)
  15612. }
  15613. // SetUserID sets the "user_id" field.
  15614. func (m *CreditUsageMutation) SetUserID(s string) {
  15615. m.user_id = &s
  15616. }
  15617. // UserID returns the value of the "user_id" field in the mutation.
  15618. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  15619. v := m.user_id
  15620. if v == nil {
  15621. return
  15622. }
  15623. return *v, true
  15624. }
  15625. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  15626. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15627. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15628. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  15629. if !m.op.Is(OpUpdateOne) {
  15630. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  15631. }
  15632. if m.id == nil || m.oldValue == nil {
  15633. return v, errors.New("OldUserID requires an ID field in the mutation")
  15634. }
  15635. oldValue, err := m.oldValue(ctx)
  15636. if err != nil {
  15637. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  15638. }
  15639. return oldValue.UserID, nil
  15640. }
  15641. // ClearUserID clears the value of the "user_id" field.
  15642. func (m *CreditUsageMutation) ClearUserID() {
  15643. m.user_id = nil
  15644. m.clearedFields[creditusage.FieldUserID] = struct{}{}
  15645. }
  15646. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  15647. func (m *CreditUsageMutation) UserIDCleared() bool {
  15648. _, ok := m.clearedFields[creditusage.FieldUserID]
  15649. return ok
  15650. }
  15651. // ResetUserID resets all changes to the "user_id" field.
  15652. func (m *CreditUsageMutation) ResetUserID() {
  15653. m.user_id = nil
  15654. delete(m.clearedFields, creditusage.FieldUserID)
  15655. }
  15656. // SetNumber sets the "number" field.
  15657. func (m *CreditUsageMutation) SetNumber(f float64) {
  15658. m.number = &f
  15659. m.addnumber = nil
  15660. }
  15661. // Number returns the value of the "number" field in the mutation.
  15662. func (m *CreditUsageMutation) Number() (r float64, exists bool) {
  15663. v := m.number
  15664. if v == nil {
  15665. return
  15666. }
  15667. return *v, true
  15668. }
  15669. // OldNumber returns the old "number" field's value of the CreditUsage entity.
  15670. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15671. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15672. func (m *CreditUsageMutation) OldNumber(ctx context.Context) (v float64, err error) {
  15673. if !m.op.Is(OpUpdateOne) {
  15674. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  15675. }
  15676. if m.id == nil || m.oldValue == nil {
  15677. return v, errors.New("OldNumber requires an ID field in the mutation")
  15678. }
  15679. oldValue, err := m.oldValue(ctx)
  15680. if err != nil {
  15681. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  15682. }
  15683. return oldValue.Number, nil
  15684. }
  15685. // AddNumber adds f to the "number" field.
  15686. func (m *CreditUsageMutation) AddNumber(f float64) {
  15687. if m.addnumber != nil {
  15688. *m.addnumber += f
  15689. } else {
  15690. m.addnumber = &f
  15691. }
  15692. }
  15693. // AddedNumber returns the value that was added to the "number" field in this mutation.
  15694. func (m *CreditUsageMutation) AddedNumber() (r float64, exists bool) {
  15695. v := m.addnumber
  15696. if v == nil {
  15697. return
  15698. }
  15699. return *v, true
  15700. }
  15701. // ResetNumber resets all changes to the "number" field.
  15702. func (m *CreditUsageMutation) ResetNumber() {
  15703. m.number = nil
  15704. m.addnumber = nil
  15705. }
  15706. // SetPayNumber sets the "pay_number" field.
  15707. func (m *CreditUsageMutation) SetPayNumber(f float64) {
  15708. m.pay_number = &f
  15709. m.addpay_number = nil
  15710. }
  15711. // PayNumber returns the value of the "pay_number" field in the mutation.
  15712. func (m *CreditUsageMutation) PayNumber() (r float64, exists bool) {
  15713. v := m.pay_number
  15714. if v == nil {
  15715. return
  15716. }
  15717. return *v, true
  15718. }
  15719. // OldPayNumber returns the old "pay_number" field's value of the CreditUsage entity.
  15720. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15721. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15722. func (m *CreditUsageMutation) OldPayNumber(ctx context.Context) (v float64, err error) {
  15723. if !m.op.Is(OpUpdateOne) {
  15724. return v, errors.New("OldPayNumber is only allowed on UpdateOne operations")
  15725. }
  15726. if m.id == nil || m.oldValue == nil {
  15727. return v, errors.New("OldPayNumber requires an ID field in the mutation")
  15728. }
  15729. oldValue, err := m.oldValue(ctx)
  15730. if err != nil {
  15731. return v, fmt.Errorf("querying old value for OldPayNumber: %w", err)
  15732. }
  15733. return oldValue.PayNumber, nil
  15734. }
  15735. // AddPayNumber adds f to the "pay_number" field.
  15736. func (m *CreditUsageMutation) AddPayNumber(f float64) {
  15737. if m.addpay_number != nil {
  15738. *m.addpay_number += f
  15739. } else {
  15740. m.addpay_number = &f
  15741. }
  15742. }
  15743. // AddedPayNumber returns the value that was added to the "pay_number" field in this mutation.
  15744. func (m *CreditUsageMutation) AddedPayNumber() (r float64, exists bool) {
  15745. v := m.addpay_number
  15746. if v == nil {
  15747. return
  15748. }
  15749. return *v, true
  15750. }
  15751. // ClearPayNumber clears the value of the "pay_number" field.
  15752. func (m *CreditUsageMutation) ClearPayNumber() {
  15753. m.pay_number = nil
  15754. m.addpay_number = nil
  15755. m.clearedFields[creditusage.FieldPayNumber] = struct{}{}
  15756. }
  15757. // PayNumberCleared returns if the "pay_number" field was cleared in this mutation.
  15758. func (m *CreditUsageMutation) PayNumberCleared() bool {
  15759. _, ok := m.clearedFields[creditusage.FieldPayNumber]
  15760. return ok
  15761. }
  15762. // ResetPayNumber resets all changes to the "pay_number" field.
  15763. func (m *CreditUsageMutation) ResetPayNumber() {
  15764. m.pay_number = nil
  15765. m.addpay_number = nil
  15766. delete(m.clearedFields, creditusage.FieldPayNumber)
  15767. }
  15768. // SetBeforeNumber sets the "before_number" field.
  15769. func (m *CreditUsageMutation) SetBeforeNumber(f float64) {
  15770. m.before_number = &f
  15771. m.addbefore_number = nil
  15772. }
  15773. // BeforeNumber returns the value of the "before_number" field in the mutation.
  15774. func (m *CreditUsageMutation) BeforeNumber() (r float64, exists bool) {
  15775. v := m.before_number
  15776. if v == nil {
  15777. return
  15778. }
  15779. return *v, true
  15780. }
  15781. // OldBeforeNumber returns the old "before_number" field's value of the CreditUsage entity.
  15782. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15783. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15784. func (m *CreditUsageMutation) OldBeforeNumber(ctx context.Context) (v float64, err error) {
  15785. if !m.op.Is(OpUpdateOne) {
  15786. return v, errors.New("OldBeforeNumber is only allowed on UpdateOne operations")
  15787. }
  15788. if m.id == nil || m.oldValue == nil {
  15789. return v, errors.New("OldBeforeNumber requires an ID field in the mutation")
  15790. }
  15791. oldValue, err := m.oldValue(ctx)
  15792. if err != nil {
  15793. return v, fmt.Errorf("querying old value for OldBeforeNumber: %w", err)
  15794. }
  15795. return oldValue.BeforeNumber, nil
  15796. }
  15797. // AddBeforeNumber adds f to the "before_number" field.
  15798. func (m *CreditUsageMutation) AddBeforeNumber(f float64) {
  15799. if m.addbefore_number != nil {
  15800. *m.addbefore_number += f
  15801. } else {
  15802. m.addbefore_number = &f
  15803. }
  15804. }
  15805. // AddedBeforeNumber returns the value that was added to the "before_number" field in this mutation.
  15806. func (m *CreditUsageMutation) AddedBeforeNumber() (r float64, exists bool) {
  15807. v := m.addbefore_number
  15808. if v == nil {
  15809. return
  15810. }
  15811. return *v, true
  15812. }
  15813. // ClearBeforeNumber clears the value of the "before_number" field.
  15814. func (m *CreditUsageMutation) ClearBeforeNumber() {
  15815. m.before_number = nil
  15816. m.addbefore_number = nil
  15817. m.clearedFields[creditusage.FieldBeforeNumber] = struct{}{}
  15818. }
  15819. // BeforeNumberCleared returns if the "before_number" field was cleared in this mutation.
  15820. func (m *CreditUsageMutation) BeforeNumberCleared() bool {
  15821. _, ok := m.clearedFields[creditusage.FieldBeforeNumber]
  15822. return ok
  15823. }
  15824. // ResetBeforeNumber resets all changes to the "before_number" field.
  15825. func (m *CreditUsageMutation) ResetBeforeNumber() {
  15826. m.before_number = nil
  15827. m.addbefore_number = nil
  15828. delete(m.clearedFields, creditusage.FieldBeforeNumber)
  15829. }
  15830. // SetAfterNumber sets the "after_number" field.
  15831. func (m *CreditUsageMutation) SetAfterNumber(f float64) {
  15832. m.after_number = &f
  15833. m.addafter_number = nil
  15834. }
  15835. // AfterNumber returns the value of the "after_number" field in the mutation.
  15836. func (m *CreditUsageMutation) AfterNumber() (r float64, exists bool) {
  15837. v := m.after_number
  15838. if v == nil {
  15839. return
  15840. }
  15841. return *v, true
  15842. }
  15843. // OldAfterNumber returns the old "after_number" field's value of the CreditUsage entity.
  15844. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15846. func (m *CreditUsageMutation) OldAfterNumber(ctx context.Context) (v float64, err error) {
  15847. if !m.op.Is(OpUpdateOne) {
  15848. return v, errors.New("OldAfterNumber is only allowed on UpdateOne operations")
  15849. }
  15850. if m.id == nil || m.oldValue == nil {
  15851. return v, errors.New("OldAfterNumber requires an ID field in the mutation")
  15852. }
  15853. oldValue, err := m.oldValue(ctx)
  15854. if err != nil {
  15855. return v, fmt.Errorf("querying old value for OldAfterNumber: %w", err)
  15856. }
  15857. return oldValue.AfterNumber, nil
  15858. }
  15859. // AddAfterNumber adds f to the "after_number" field.
  15860. func (m *CreditUsageMutation) AddAfterNumber(f float64) {
  15861. if m.addafter_number != nil {
  15862. *m.addafter_number += f
  15863. } else {
  15864. m.addafter_number = &f
  15865. }
  15866. }
  15867. // AddedAfterNumber returns the value that was added to the "after_number" field in this mutation.
  15868. func (m *CreditUsageMutation) AddedAfterNumber() (r float64, exists bool) {
  15869. v := m.addafter_number
  15870. if v == nil {
  15871. return
  15872. }
  15873. return *v, true
  15874. }
  15875. // ClearAfterNumber clears the value of the "after_number" field.
  15876. func (m *CreditUsageMutation) ClearAfterNumber() {
  15877. m.after_number = nil
  15878. m.addafter_number = nil
  15879. m.clearedFields[creditusage.FieldAfterNumber] = struct{}{}
  15880. }
  15881. // AfterNumberCleared returns if the "after_number" field was cleared in this mutation.
  15882. func (m *CreditUsageMutation) AfterNumberCleared() bool {
  15883. _, ok := m.clearedFields[creditusage.FieldAfterNumber]
  15884. return ok
  15885. }
  15886. // ResetAfterNumber resets all changes to the "after_number" field.
  15887. func (m *CreditUsageMutation) ResetAfterNumber() {
  15888. m.after_number = nil
  15889. m.addafter_number = nil
  15890. delete(m.clearedFields, creditusage.FieldAfterNumber)
  15891. }
  15892. // SetPayMethod sets the "pay_method" field.
  15893. func (m *CreditUsageMutation) SetPayMethod(i int) {
  15894. m.pay_method = &i
  15895. m.addpay_method = nil
  15896. }
  15897. // PayMethod returns the value of the "pay_method" field in the mutation.
  15898. func (m *CreditUsageMutation) PayMethod() (r int, exists bool) {
  15899. v := m.pay_method
  15900. if v == nil {
  15901. return
  15902. }
  15903. return *v, true
  15904. }
  15905. // OldPayMethod returns the old "pay_method" field's value of the CreditUsage entity.
  15906. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15907. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15908. func (m *CreditUsageMutation) OldPayMethod(ctx context.Context) (v int, err error) {
  15909. if !m.op.Is(OpUpdateOne) {
  15910. return v, errors.New("OldPayMethod is only allowed on UpdateOne operations")
  15911. }
  15912. if m.id == nil || m.oldValue == nil {
  15913. return v, errors.New("OldPayMethod requires an ID field in the mutation")
  15914. }
  15915. oldValue, err := m.oldValue(ctx)
  15916. if err != nil {
  15917. return v, fmt.Errorf("querying old value for OldPayMethod: %w", err)
  15918. }
  15919. return oldValue.PayMethod, nil
  15920. }
  15921. // AddPayMethod adds i to the "pay_method" field.
  15922. func (m *CreditUsageMutation) AddPayMethod(i int) {
  15923. if m.addpay_method != nil {
  15924. *m.addpay_method += i
  15925. } else {
  15926. m.addpay_method = &i
  15927. }
  15928. }
  15929. // AddedPayMethod returns the value that was added to the "pay_method" field in this mutation.
  15930. func (m *CreditUsageMutation) AddedPayMethod() (r int, exists bool) {
  15931. v := m.addpay_method
  15932. if v == nil {
  15933. return
  15934. }
  15935. return *v, true
  15936. }
  15937. // ClearPayMethod clears the value of the "pay_method" field.
  15938. func (m *CreditUsageMutation) ClearPayMethod() {
  15939. m.pay_method = nil
  15940. m.addpay_method = nil
  15941. m.clearedFields[creditusage.FieldPayMethod] = struct{}{}
  15942. }
  15943. // PayMethodCleared returns if the "pay_method" field was cleared in this mutation.
  15944. func (m *CreditUsageMutation) PayMethodCleared() bool {
  15945. _, ok := m.clearedFields[creditusage.FieldPayMethod]
  15946. return ok
  15947. }
  15948. // ResetPayMethod resets all changes to the "pay_method" field.
  15949. func (m *CreditUsageMutation) ResetPayMethod() {
  15950. m.pay_method = nil
  15951. m.addpay_method = nil
  15952. delete(m.clearedFields, creditusage.FieldPayMethod)
  15953. }
  15954. // SetStatus sets the "status" field.
  15955. func (m *CreditUsageMutation) SetStatus(i int) {
  15956. m.status = &i
  15957. m.addstatus = nil
  15958. }
  15959. // Status returns the value of the "status" field in the mutation.
  15960. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  15961. v := m.status
  15962. if v == nil {
  15963. return
  15964. }
  15965. return *v, true
  15966. }
  15967. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  15968. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15969. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15970. func (m *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  15971. if !m.op.Is(OpUpdateOne) {
  15972. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15973. }
  15974. if m.id == nil || m.oldValue == nil {
  15975. return v, errors.New("OldStatus requires an ID field in the mutation")
  15976. }
  15977. oldValue, err := m.oldValue(ctx)
  15978. if err != nil {
  15979. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15980. }
  15981. return oldValue.Status, nil
  15982. }
  15983. // AddStatus adds i to the "status" field.
  15984. func (m *CreditUsageMutation) AddStatus(i int) {
  15985. if m.addstatus != nil {
  15986. *m.addstatus += i
  15987. } else {
  15988. m.addstatus = &i
  15989. }
  15990. }
  15991. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15992. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  15993. v := m.addstatus
  15994. if v == nil {
  15995. return
  15996. }
  15997. return *v, true
  15998. }
  15999. // ClearStatus clears the value of the "status" field.
  16000. func (m *CreditUsageMutation) ClearStatus() {
  16001. m.status = nil
  16002. m.addstatus = nil
  16003. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  16004. }
  16005. // StatusCleared returns if the "status" field was cleared in this mutation.
  16006. func (m *CreditUsageMutation) StatusCleared() bool {
  16007. _, ok := m.clearedFields[creditusage.FieldStatus]
  16008. return ok
  16009. }
  16010. // ResetStatus resets all changes to the "status" field.
  16011. func (m *CreditUsageMutation) ResetStatus() {
  16012. m.status = nil
  16013. m.addstatus = nil
  16014. delete(m.clearedFields, creditusage.FieldStatus)
  16015. }
  16016. // SetNtype sets the "ntype" field.
  16017. func (m *CreditUsageMutation) SetNtype(i int) {
  16018. m.ntype = &i
  16019. m.addntype = nil
  16020. }
  16021. // Ntype returns the value of the "ntype" field in the mutation.
  16022. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  16023. v := m.ntype
  16024. if v == nil {
  16025. return
  16026. }
  16027. return *v, true
  16028. }
  16029. // OldNtype returns the old "ntype" field's value of the CreditUsage entity.
  16030. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16031. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16032. func (m *CreditUsageMutation) OldNtype(ctx context.Context) (v int, err error) {
  16033. if !m.op.Is(OpUpdateOne) {
  16034. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  16035. }
  16036. if m.id == nil || m.oldValue == nil {
  16037. return v, errors.New("OldNtype requires an ID field in the mutation")
  16038. }
  16039. oldValue, err := m.oldValue(ctx)
  16040. if err != nil {
  16041. return v, fmt.Errorf("querying old value for OldNtype: %w", err)
  16042. }
  16043. return oldValue.Ntype, nil
  16044. }
  16045. // AddNtype adds i to the "ntype" field.
  16046. func (m *CreditUsageMutation) AddNtype(i int) {
  16047. if m.addntype != nil {
  16048. *m.addntype += i
  16049. } else {
  16050. m.addntype = &i
  16051. }
  16052. }
  16053. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  16054. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  16055. v := m.addntype
  16056. if v == nil {
  16057. return
  16058. }
  16059. return *v, true
  16060. }
  16061. // ResetNtype resets all changes to the "ntype" field.
  16062. func (m *CreditUsageMutation) ResetNtype() {
  16063. m.ntype = nil
  16064. m.addntype = nil
  16065. }
  16066. // SetTable sets the "table" field.
  16067. func (m *CreditUsageMutation) SetTable(s string) {
  16068. m.table = &s
  16069. }
  16070. // Table returns the value of the "table" field in the mutation.
  16071. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  16072. v := m.table
  16073. if v == nil {
  16074. return
  16075. }
  16076. return *v, true
  16077. }
  16078. // OldTable returns the old "table" field's value of the CreditUsage entity.
  16079. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16080. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16081. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  16082. if !m.op.Is(OpUpdateOne) {
  16083. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  16084. }
  16085. if m.id == nil || m.oldValue == nil {
  16086. return v, errors.New("OldTable requires an ID field in the mutation")
  16087. }
  16088. oldValue, err := m.oldValue(ctx)
  16089. if err != nil {
  16090. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  16091. }
  16092. return oldValue.Table, nil
  16093. }
  16094. // ResetTable resets all changes to the "table" field.
  16095. func (m *CreditUsageMutation) ResetTable() {
  16096. m.table = nil
  16097. }
  16098. // SetOrganizationID sets the "organization_id" field.
  16099. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  16100. m.organization_id = &u
  16101. m.addorganization_id = nil
  16102. }
  16103. // OrganizationID returns the value of the "organization_id" field in the mutation.
  16104. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  16105. v := m.organization_id
  16106. if v == nil {
  16107. return
  16108. }
  16109. return *v, true
  16110. }
  16111. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  16112. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16113. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16114. func (m *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  16115. if !m.op.Is(OpUpdateOne) {
  16116. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  16117. }
  16118. if m.id == nil || m.oldValue == nil {
  16119. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  16120. }
  16121. oldValue, err := m.oldValue(ctx)
  16122. if err != nil {
  16123. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  16124. }
  16125. return oldValue.OrganizationID, nil
  16126. }
  16127. // AddOrganizationID adds u to the "organization_id" field.
  16128. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  16129. if m.addorganization_id != nil {
  16130. *m.addorganization_id += u
  16131. } else {
  16132. m.addorganization_id = &u
  16133. }
  16134. }
  16135. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  16136. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  16137. v := m.addorganization_id
  16138. if v == nil {
  16139. return
  16140. }
  16141. return *v, true
  16142. }
  16143. // ClearOrganizationID clears the value of the "organization_id" field.
  16144. func (m *CreditUsageMutation) ClearOrganizationID() {
  16145. m.organization_id = nil
  16146. m.addorganization_id = nil
  16147. m.clearedFields[creditusage.FieldOrganizationID] = struct{}{}
  16148. }
  16149. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  16150. func (m *CreditUsageMutation) OrganizationIDCleared() bool {
  16151. _, ok := m.clearedFields[creditusage.FieldOrganizationID]
  16152. return ok
  16153. }
  16154. // ResetOrganizationID resets all changes to the "organization_id" field.
  16155. func (m *CreditUsageMutation) ResetOrganizationID() {
  16156. m.organization_id = nil
  16157. m.addorganization_id = nil
  16158. delete(m.clearedFields, creditusage.FieldOrganizationID)
  16159. }
  16160. // SetNid sets the "nid" field.
  16161. func (m *CreditUsageMutation) SetNid(u uint64) {
  16162. m.nid = &u
  16163. m.addnid = nil
  16164. }
  16165. // Nid returns the value of the "nid" field in the mutation.
  16166. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  16167. v := m.nid
  16168. if v == nil {
  16169. return
  16170. }
  16171. return *v, true
  16172. }
  16173. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  16174. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16175. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16176. func (m *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  16177. if !m.op.Is(OpUpdateOne) {
  16178. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  16179. }
  16180. if m.id == nil || m.oldValue == nil {
  16181. return v, errors.New("OldNid requires an ID field in the mutation")
  16182. }
  16183. oldValue, err := m.oldValue(ctx)
  16184. if err != nil {
  16185. return v, fmt.Errorf("querying old value for OldNid: %w", err)
  16186. }
  16187. return oldValue.Nid, nil
  16188. }
  16189. // AddNid adds u to the "nid" field.
  16190. func (m *CreditUsageMutation) AddNid(u int64) {
  16191. if m.addnid != nil {
  16192. *m.addnid += u
  16193. } else {
  16194. m.addnid = &u
  16195. }
  16196. }
  16197. // AddedNid returns the value that was added to the "nid" field in this mutation.
  16198. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  16199. v := m.addnid
  16200. if v == nil {
  16201. return
  16202. }
  16203. return *v, true
  16204. }
  16205. // ResetNid resets all changes to the "nid" field.
  16206. func (m *CreditUsageMutation) ResetNid() {
  16207. m.nid = nil
  16208. m.addnid = nil
  16209. }
  16210. // SetReason sets the "reason" field.
  16211. func (m *CreditUsageMutation) SetReason(s string) {
  16212. m.reason = &s
  16213. }
  16214. // Reason returns the value of the "reason" field in the mutation.
  16215. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  16216. v := m.reason
  16217. if v == nil {
  16218. return
  16219. }
  16220. return *v, true
  16221. }
  16222. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  16223. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16224. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16225. func (m *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  16226. if !m.op.Is(OpUpdateOne) {
  16227. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  16228. }
  16229. if m.id == nil || m.oldValue == nil {
  16230. return v, errors.New("OldReason requires an ID field in the mutation")
  16231. }
  16232. oldValue, err := m.oldValue(ctx)
  16233. if err != nil {
  16234. return v, fmt.Errorf("querying old value for OldReason: %w", err)
  16235. }
  16236. return oldValue.Reason, nil
  16237. }
  16238. // ResetReason resets all changes to the "reason" field.
  16239. func (m *CreditUsageMutation) ResetReason() {
  16240. m.reason = nil
  16241. }
  16242. // SetOperator sets the "operator" field.
  16243. func (m *CreditUsageMutation) SetOperator(s string) {
  16244. m.operator = &s
  16245. }
  16246. // Operator returns the value of the "operator" field in the mutation.
  16247. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  16248. v := m.operator
  16249. if v == nil {
  16250. return
  16251. }
  16252. return *v, true
  16253. }
  16254. // OldOperator returns the old "operator" field's value of the CreditUsage entity.
  16255. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16256. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16257. func (m *CreditUsageMutation) OldOperator(ctx context.Context) (v string, err error) {
  16258. if !m.op.Is(OpUpdateOne) {
  16259. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  16260. }
  16261. if m.id == nil || m.oldValue == nil {
  16262. return v, errors.New("OldOperator requires an ID field in the mutation")
  16263. }
  16264. oldValue, err := m.oldValue(ctx)
  16265. if err != nil {
  16266. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  16267. }
  16268. return oldValue.Operator, nil
  16269. }
  16270. // ResetOperator resets all changes to the "operator" field.
  16271. func (m *CreditUsageMutation) ResetOperator() {
  16272. m.operator = nil
  16273. }
  16274. // Where appends a list predicates to the CreditUsageMutation builder.
  16275. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  16276. m.predicates = append(m.predicates, ps...)
  16277. }
  16278. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  16279. // users can use type-assertion to append predicates that do not depend on any generated package.
  16280. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  16281. p := make([]predicate.CreditUsage, len(ps))
  16282. for i := range ps {
  16283. p[i] = ps[i]
  16284. }
  16285. m.Where(p...)
  16286. }
  16287. // Op returns the operation name.
  16288. func (m *CreditUsageMutation) Op() Op {
  16289. return m.op
  16290. }
  16291. // SetOp allows setting the mutation operation.
  16292. func (m *CreditUsageMutation) SetOp(op Op) {
  16293. m.op = op
  16294. }
  16295. // Type returns the node type of this mutation (CreditUsage).
  16296. func (m *CreditUsageMutation) Type() string {
  16297. return m.typ
  16298. }
  16299. // Fields returns all fields that were changed during this mutation. Note that in
  16300. // order to get all numeric fields that were incremented/decremented, call
  16301. // AddedFields().
  16302. func (m *CreditUsageMutation) Fields() []string {
  16303. fields := make([]string, 0, 16)
  16304. if m.created_at != nil {
  16305. fields = append(fields, creditusage.FieldCreatedAt)
  16306. }
  16307. if m.updated_at != nil {
  16308. fields = append(fields, creditusage.FieldUpdatedAt)
  16309. }
  16310. if m.deleted_at != nil {
  16311. fields = append(fields, creditusage.FieldDeletedAt)
  16312. }
  16313. if m.user_id != nil {
  16314. fields = append(fields, creditusage.FieldUserID)
  16315. }
  16316. if m.number != nil {
  16317. fields = append(fields, creditusage.FieldNumber)
  16318. }
  16319. if m.pay_number != nil {
  16320. fields = append(fields, creditusage.FieldPayNumber)
  16321. }
  16322. if m.before_number != nil {
  16323. fields = append(fields, creditusage.FieldBeforeNumber)
  16324. }
  16325. if m.after_number != nil {
  16326. fields = append(fields, creditusage.FieldAfterNumber)
  16327. }
  16328. if m.pay_method != nil {
  16329. fields = append(fields, creditusage.FieldPayMethod)
  16330. }
  16331. if m.status != nil {
  16332. fields = append(fields, creditusage.FieldStatus)
  16333. }
  16334. if m.ntype != nil {
  16335. fields = append(fields, creditusage.FieldNtype)
  16336. }
  16337. if m.table != nil {
  16338. fields = append(fields, creditusage.FieldTable)
  16339. }
  16340. if m.organization_id != nil {
  16341. fields = append(fields, creditusage.FieldOrganizationID)
  16342. }
  16343. if m.nid != nil {
  16344. fields = append(fields, creditusage.FieldNid)
  16345. }
  16346. if m.reason != nil {
  16347. fields = append(fields, creditusage.FieldReason)
  16348. }
  16349. if m.operator != nil {
  16350. fields = append(fields, creditusage.FieldOperator)
  16351. }
  16352. return fields
  16353. }
  16354. // Field returns the value of a field with the given name. The second boolean
  16355. // return value indicates that this field was not set, or was not defined in the
  16356. // schema.
  16357. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  16358. switch name {
  16359. case creditusage.FieldCreatedAt:
  16360. return m.CreatedAt()
  16361. case creditusage.FieldUpdatedAt:
  16362. return m.UpdatedAt()
  16363. case creditusage.FieldDeletedAt:
  16364. return m.DeletedAt()
  16365. case creditusage.FieldUserID:
  16366. return m.UserID()
  16367. case creditusage.FieldNumber:
  16368. return m.Number()
  16369. case creditusage.FieldPayNumber:
  16370. return m.PayNumber()
  16371. case creditusage.FieldBeforeNumber:
  16372. return m.BeforeNumber()
  16373. case creditusage.FieldAfterNumber:
  16374. return m.AfterNumber()
  16375. case creditusage.FieldPayMethod:
  16376. return m.PayMethod()
  16377. case creditusage.FieldStatus:
  16378. return m.Status()
  16379. case creditusage.FieldNtype:
  16380. return m.Ntype()
  16381. case creditusage.FieldTable:
  16382. return m.Table()
  16383. case creditusage.FieldOrganizationID:
  16384. return m.OrganizationID()
  16385. case creditusage.FieldNid:
  16386. return m.Nid()
  16387. case creditusage.FieldReason:
  16388. return m.Reason()
  16389. case creditusage.FieldOperator:
  16390. return m.Operator()
  16391. }
  16392. return nil, false
  16393. }
  16394. // OldField returns the old value of the field from the database. An error is
  16395. // returned if the mutation operation is not UpdateOne, or the query to the
  16396. // database failed.
  16397. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16398. switch name {
  16399. case creditusage.FieldCreatedAt:
  16400. return m.OldCreatedAt(ctx)
  16401. case creditusage.FieldUpdatedAt:
  16402. return m.OldUpdatedAt(ctx)
  16403. case creditusage.FieldDeletedAt:
  16404. return m.OldDeletedAt(ctx)
  16405. case creditusage.FieldUserID:
  16406. return m.OldUserID(ctx)
  16407. case creditusage.FieldNumber:
  16408. return m.OldNumber(ctx)
  16409. case creditusage.FieldPayNumber:
  16410. return m.OldPayNumber(ctx)
  16411. case creditusage.FieldBeforeNumber:
  16412. return m.OldBeforeNumber(ctx)
  16413. case creditusage.FieldAfterNumber:
  16414. return m.OldAfterNumber(ctx)
  16415. case creditusage.FieldPayMethod:
  16416. return m.OldPayMethod(ctx)
  16417. case creditusage.FieldStatus:
  16418. return m.OldStatus(ctx)
  16419. case creditusage.FieldNtype:
  16420. return m.OldNtype(ctx)
  16421. case creditusage.FieldTable:
  16422. return m.OldTable(ctx)
  16423. case creditusage.FieldOrganizationID:
  16424. return m.OldOrganizationID(ctx)
  16425. case creditusage.FieldNid:
  16426. return m.OldNid(ctx)
  16427. case creditusage.FieldReason:
  16428. return m.OldReason(ctx)
  16429. case creditusage.FieldOperator:
  16430. return m.OldOperator(ctx)
  16431. }
  16432. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  16433. }
  16434. // SetField sets the value of a field with the given name. It returns an error if
  16435. // the field is not defined in the schema, or if the type mismatched the field
  16436. // type.
  16437. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  16438. switch name {
  16439. case creditusage.FieldCreatedAt:
  16440. v, ok := value.(time.Time)
  16441. if !ok {
  16442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16443. }
  16444. m.SetCreatedAt(v)
  16445. return nil
  16446. case creditusage.FieldUpdatedAt:
  16447. v, ok := value.(time.Time)
  16448. if !ok {
  16449. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16450. }
  16451. m.SetUpdatedAt(v)
  16452. return nil
  16453. case creditusage.FieldDeletedAt:
  16454. v, ok := value.(time.Time)
  16455. if !ok {
  16456. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16457. }
  16458. m.SetDeletedAt(v)
  16459. return nil
  16460. case creditusage.FieldUserID:
  16461. v, ok := value.(string)
  16462. if !ok {
  16463. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16464. }
  16465. m.SetUserID(v)
  16466. return nil
  16467. case creditusage.FieldNumber:
  16468. v, ok := value.(float64)
  16469. if !ok {
  16470. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16471. }
  16472. m.SetNumber(v)
  16473. return nil
  16474. case creditusage.FieldPayNumber:
  16475. v, ok := value.(float64)
  16476. if !ok {
  16477. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16478. }
  16479. m.SetPayNumber(v)
  16480. return nil
  16481. case creditusage.FieldBeforeNumber:
  16482. v, ok := value.(float64)
  16483. if !ok {
  16484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16485. }
  16486. m.SetBeforeNumber(v)
  16487. return nil
  16488. case creditusage.FieldAfterNumber:
  16489. v, ok := value.(float64)
  16490. if !ok {
  16491. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16492. }
  16493. m.SetAfterNumber(v)
  16494. return nil
  16495. case creditusage.FieldPayMethod:
  16496. v, ok := value.(int)
  16497. if !ok {
  16498. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16499. }
  16500. m.SetPayMethod(v)
  16501. return nil
  16502. case creditusage.FieldStatus:
  16503. v, ok := value.(int)
  16504. if !ok {
  16505. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16506. }
  16507. m.SetStatus(v)
  16508. return nil
  16509. case creditusage.FieldNtype:
  16510. v, ok := value.(int)
  16511. if !ok {
  16512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16513. }
  16514. m.SetNtype(v)
  16515. return nil
  16516. case creditusage.FieldTable:
  16517. v, ok := value.(string)
  16518. if !ok {
  16519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16520. }
  16521. m.SetTable(v)
  16522. return nil
  16523. case creditusage.FieldOrganizationID:
  16524. v, ok := value.(uint64)
  16525. if !ok {
  16526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16527. }
  16528. m.SetOrganizationID(v)
  16529. return nil
  16530. case creditusage.FieldNid:
  16531. v, ok := value.(uint64)
  16532. if !ok {
  16533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16534. }
  16535. m.SetNid(v)
  16536. return nil
  16537. case creditusage.FieldReason:
  16538. v, ok := value.(string)
  16539. if !ok {
  16540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16541. }
  16542. m.SetReason(v)
  16543. return nil
  16544. case creditusage.FieldOperator:
  16545. v, ok := value.(string)
  16546. if !ok {
  16547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16548. }
  16549. m.SetOperator(v)
  16550. return nil
  16551. }
  16552. return fmt.Errorf("unknown CreditUsage field %s", name)
  16553. }
  16554. // AddedFields returns all numeric fields that were incremented/decremented during
  16555. // this mutation.
  16556. func (m *CreditUsageMutation) AddedFields() []string {
  16557. var fields []string
  16558. if m.addnumber != nil {
  16559. fields = append(fields, creditusage.FieldNumber)
  16560. }
  16561. if m.addpay_number != nil {
  16562. fields = append(fields, creditusage.FieldPayNumber)
  16563. }
  16564. if m.addbefore_number != nil {
  16565. fields = append(fields, creditusage.FieldBeforeNumber)
  16566. }
  16567. if m.addafter_number != nil {
  16568. fields = append(fields, creditusage.FieldAfterNumber)
  16569. }
  16570. if m.addpay_method != nil {
  16571. fields = append(fields, creditusage.FieldPayMethod)
  16572. }
  16573. if m.addstatus != nil {
  16574. fields = append(fields, creditusage.FieldStatus)
  16575. }
  16576. if m.addntype != nil {
  16577. fields = append(fields, creditusage.FieldNtype)
  16578. }
  16579. if m.addorganization_id != nil {
  16580. fields = append(fields, creditusage.FieldOrganizationID)
  16581. }
  16582. if m.addnid != nil {
  16583. fields = append(fields, creditusage.FieldNid)
  16584. }
  16585. return fields
  16586. }
  16587. // AddedField returns the numeric value that was incremented/decremented on a field
  16588. // with the given name. The second boolean return value indicates that this field
  16589. // was not set, or was not defined in the schema.
  16590. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  16591. switch name {
  16592. case creditusage.FieldNumber:
  16593. return m.AddedNumber()
  16594. case creditusage.FieldPayNumber:
  16595. return m.AddedPayNumber()
  16596. case creditusage.FieldBeforeNumber:
  16597. return m.AddedBeforeNumber()
  16598. case creditusage.FieldAfterNumber:
  16599. return m.AddedAfterNumber()
  16600. case creditusage.FieldPayMethod:
  16601. return m.AddedPayMethod()
  16602. case creditusage.FieldStatus:
  16603. return m.AddedStatus()
  16604. case creditusage.FieldNtype:
  16605. return m.AddedNtype()
  16606. case creditusage.FieldOrganizationID:
  16607. return m.AddedOrganizationID()
  16608. case creditusage.FieldNid:
  16609. return m.AddedNid()
  16610. }
  16611. return nil, false
  16612. }
  16613. // AddField adds the value to the field with the given name. It returns an error if
  16614. // the field is not defined in the schema, or if the type mismatched the field
  16615. // type.
  16616. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  16617. switch name {
  16618. case creditusage.FieldNumber:
  16619. v, ok := value.(float64)
  16620. if !ok {
  16621. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16622. }
  16623. m.AddNumber(v)
  16624. return nil
  16625. case creditusage.FieldPayNumber:
  16626. v, ok := value.(float64)
  16627. if !ok {
  16628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16629. }
  16630. m.AddPayNumber(v)
  16631. return nil
  16632. case creditusage.FieldBeforeNumber:
  16633. v, ok := value.(float64)
  16634. if !ok {
  16635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16636. }
  16637. m.AddBeforeNumber(v)
  16638. return nil
  16639. case creditusage.FieldAfterNumber:
  16640. v, ok := value.(float64)
  16641. if !ok {
  16642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16643. }
  16644. m.AddAfterNumber(v)
  16645. return nil
  16646. case creditusage.FieldPayMethod:
  16647. v, ok := value.(int)
  16648. if !ok {
  16649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16650. }
  16651. m.AddPayMethod(v)
  16652. return nil
  16653. case creditusage.FieldStatus:
  16654. v, ok := value.(int)
  16655. if !ok {
  16656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16657. }
  16658. m.AddStatus(v)
  16659. return nil
  16660. case creditusage.FieldNtype:
  16661. v, ok := value.(int)
  16662. if !ok {
  16663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16664. }
  16665. m.AddNtype(v)
  16666. return nil
  16667. case creditusage.FieldOrganizationID:
  16668. v, ok := value.(int64)
  16669. if !ok {
  16670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16671. }
  16672. m.AddOrganizationID(v)
  16673. return nil
  16674. case creditusage.FieldNid:
  16675. v, ok := value.(int64)
  16676. if !ok {
  16677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16678. }
  16679. m.AddNid(v)
  16680. return nil
  16681. }
  16682. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  16683. }
  16684. // ClearedFields returns all nullable fields that were cleared during this
  16685. // mutation.
  16686. func (m *CreditUsageMutation) ClearedFields() []string {
  16687. var fields []string
  16688. if m.FieldCleared(creditusage.FieldDeletedAt) {
  16689. fields = append(fields, creditusage.FieldDeletedAt)
  16690. }
  16691. if m.FieldCleared(creditusage.FieldUserID) {
  16692. fields = append(fields, creditusage.FieldUserID)
  16693. }
  16694. if m.FieldCleared(creditusage.FieldPayNumber) {
  16695. fields = append(fields, creditusage.FieldPayNumber)
  16696. }
  16697. if m.FieldCleared(creditusage.FieldBeforeNumber) {
  16698. fields = append(fields, creditusage.FieldBeforeNumber)
  16699. }
  16700. if m.FieldCleared(creditusage.FieldAfterNumber) {
  16701. fields = append(fields, creditusage.FieldAfterNumber)
  16702. }
  16703. if m.FieldCleared(creditusage.FieldPayMethod) {
  16704. fields = append(fields, creditusage.FieldPayMethod)
  16705. }
  16706. if m.FieldCleared(creditusage.FieldStatus) {
  16707. fields = append(fields, creditusage.FieldStatus)
  16708. }
  16709. if m.FieldCleared(creditusage.FieldOrganizationID) {
  16710. fields = append(fields, creditusage.FieldOrganizationID)
  16711. }
  16712. return fields
  16713. }
  16714. // FieldCleared returns a boolean indicating if a field with the given name was
  16715. // cleared in this mutation.
  16716. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  16717. _, ok := m.clearedFields[name]
  16718. return ok
  16719. }
  16720. // ClearField clears the value of the field with the given name. It returns an
  16721. // error if the field is not defined in the schema.
  16722. func (m *CreditUsageMutation) ClearField(name string) error {
  16723. switch name {
  16724. case creditusage.FieldDeletedAt:
  16725. m.ClearDeletedAt()
  16726. return nil
  16727. case creditusage.FieldUserID:
  16728. m.ClearUserID()
  16729. return nil
  16730. case creditusage.FieldPayNumber:
  16731. m.ClearPayNumber()
  16732. return nil
  16733. case creditusage.FieldBeforeNumber:
  16734. m.ClearBeforeNumber()
  16735. return nil
  16736. case creditusage.FieldAfterNumber:
  16737. m.ClearAfterNumber()
  16738. return nil
  16739. case creditusage.FieldPayMethod:
  16740. m.ClearPayMethod()
  16741. return nil
  16742. case creditusage.FieldStatus:
  16743. m.ClearStatus()
  16744. return nil
  16745. case creditusage.FieldOrganizationID:
  16746. m.ClearOrganizationID()
  16747. return nil
  16748. }
  16749. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  16750. }
  16751. // ResetField resets all changes in the mutation for the field with the given name.
  16752. // It returns an error if the field is not defined in the schema.
  16753. func (m *CreditUsageMutation) ResetField(name string) error {
  16754. switch name {
  16755. case creditusage.FieldCreatedAt:
  16756. m.ResetCreatedAt()
  16757. return nil
  16758. case creditusage.FieldUpdatedAt:
  16759. m.ResetUpdatedAt()
  16760. return nil
  16761. case creditusage.FieldDeletedAt:
  16762. m.ResetDeletedAt()
  16763. return nil
  16764. case creditusage.FieldUserID:
  16765. m.ResetUserID()
  16766. return nil
  16767. case creditusage.FieldNumber:
  16768. m.ResetNumber()
  16769. return nil
  16770. case creditusage.FieldPayNumber:
  16771. m.ResetPayNumber()
  16772. return nil
  16773. case creditusage.FieldBeforeNumber:
  16774. m.ResetBeforeNumber()
  16775. return nil
  16776. case creditusage.FieldAfterNumber:
  16777. m.ResetAfterNumber()
  16778. return nil
  16779. case creditusage.FieldPayMethod:
  16780. m.ResetPayMethod()
  16781. return nil
  16782. case creditusage.FieldStatus:
  16783. m.ResetStatus()
  16784. return nil
  16785. case creditusage.FieldNtype:
  16786. m.ResetNtype()
  16787. return nil
  16788. case creditusage.FieldTable:
  16789. m.ResetTable()
  16790. return nil
  16791. case creditusage.FieldOrganizationID:
  16792. m.ResetOrganizationID()
  16793. return nil
  16794. case creditusage.FieldNid:
  16795. m.ResetNid()
  16796. return nil
  16797. case creditusage.FieldReason:
  16798. m.ResetReason()
  16799. return nil
  16800. case creditusage.FieldOperator:
  16801. m.ResetOperator()
  16802. return nil
  16803. }
  16804. return fmt.Errorf("unknown CreditUsage field %s", name)
  16805. }
  16806. // AddedEdges returns all edge names that were set/added in this mutation.
  16807. func (m *CreditUsageMutation) AddedEdges() []string {
  16808. edges := make([]string, 0, 0)
  16809. return edges
  16810. }
  16811. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16812. // name in this mutation.
  16813. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  16814. return nil
  16815. }
  16816. // RemovedEdges returns all edge names that were removed in this mutation.
  16817. func (m *CreditUsageMutation) RemovedEdges() []string {
  16818. edges := make([]string, 0, 0)
  16819. return edges
  16820. }
  16821. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16822. // the given name in this mutation.
  16823. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  16824. return nil
  16825. }
  16826. // ClearedEdges returns all edge names that were cleared in this mutation.
  16827. func (m *CreditUsageMutation) ClearedEdges() []string {
  16828. edges := make([]string, 0, 0)
  16829. return edges
  16830. }
  16831. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16832. // was cleared in this mutation.
  16833. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  16834. return false
  16835. }
  16836. // ClearEdge clears the value of the edge with the given name. It returns an error
  16837. // if that edge is not defined in the schema.
  16838. func (m *CreditUsageMutation) ClearEdge(name string) error {
  16839. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  16840. }
  16841. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16842. // It returns an error if the edge is not defined in the schema.
  16843. func (m *CreditUsageMutation) ResetEdge(name string) error {
  16844. return fmt.Errorf("unknown CreditUsage edge %s", name)
  16845. }
  16846. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  16847. type EmployeeMutation struct {
  16848. config
  16849. op Op
  16850. typ string
  16851. id *uint64
  16852. created_at *time.Time
  16853. updated_at *time.Time
  16854. deleted_at *time.Time
  16855. title *string
  16856. avatar *string
  16857. tags *string
  16858. hire_count *int
  16859. addhire_count *int
  16860. service_count *int
  16861. addservice_count *int
  16862. achievement_count *int
  16863. addachievement_count *int
  16864. intro *string
  16865. estimate *string
  16866. skill *string
  16867. ability_type *string
  16868. scene *string
  16869. switch_in *string
  16870. video_url *string
  16871. organization_id *uint64
  16872. addorganization_id *int64
  16873. category_id *uint64
  16874. addcategory_id *int64
  16875. api_base *string
  16876. api_key *string
  16877. ai_info *string
  16878. is_vip *int
  16879. addis_vip *int
  16880. chat_url *string
  16881. clearedFields map[string]struct{}
  16882. em_work_experiences map[uint64]struct{}
  16883. removedem_work_experiences map[uint64]struct{}
  16884. clearedem_work_experiences bool
  16885. em_tutorial map[uint64]struct{}
  16886. removedem_tutorial map[uint64]struct{}
  16887. clearedem_tutorial bool
  16888. done bool
  16889. oldValue func(context.Context) (*Employee, error)
  16890. predicates []predicate.Employee
  16891. }
  16892. var _ ent.Mutation = (*EmployeeMutation)(nil)
  16893. // employeeOption allows management of the mutation configuration using functional options.
  16894. type employeeOption func(*EmployeeMutation)
  16895. // newEmployeeMutation creates new mutation for the Employee entity.
  16896. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  16897. m := &EmployeeMutation{
  16898. config: c,
  16899. op: op,
  16900. typ: TypeEmployee,
  16901. clearedFields: make(map[string]struct{}),
  16902. }
  16903. for _, opt := range opts {
  16904. opt(m)
  16905. }
  16906. return m
  16907. }
  16908. // withEmployeeID sets the ID field of the mutation.
  16909. func withEmployeeID(id uint64) employeeOption {
  16910. return func(m *EmployeeMutation) {
  16911. var (
  16912. err error
  16913. once sync.Once
  16914. value *Employee
  16915. )
  16916. m.oldValue = func(ctx context.Context) (*Employee, error) {
  16917. once.Do(func() {
  16918. if m.done {
  16919. err = errors.New("querying old values post mutation is not allowed")
  16920. } else {
  16921. value, err = m.Client().Employee.Get(ctx, id)
  16922. }
  16923. })
  16924. return value, err
  16925. }
  16926. m.id = &id
  16927. }
  16928. }
  16929. // withEmployee sets the old Employee of the mutation.
  16930. func withEmployee(node *Employee) employeeOption {
  16931. return func(m *EmployeeMutation) {
  16932. m.oldValue = func(context.Context) (*Employee, error) {
  16933. return node, nil
  16934. }
  16935. m.id = &node.ID
  16936. }
  16937. }
  16938. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16939. // executed in a transaction (ent.Tx), a transactional client is returned.
  16940. func (m EmployeeMutation) Client() *Client {
  16941. client := &Client{config: m.config}
  16942. client.init()
  16943. return client
  16944. }
  16945. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16946. // it returns an error otherwise.
  16947. func (m EmployeeMutation) Tx() (*Tx, error) {
  16948. if _, ok := m.driver.(*txDriver); !ok {
  16949. return nil, errors.New("ent: mutation is not running in a transaction")
  16950. }
  16951. tx := &Tx{config: m.config}
  16952. tx.init()
  16953. return tx, nil
  16954. }
  16955. // SetID sets the value of the id field. Note that this
  16956. // operation is only accepted on creation of Employee entities.
  16957. func (m *EmployeeMutation) SetID(id uint64) {
  16958. m.id = &id
  16959. }
  16960. // ID returns the ID value in the mutation. Note that the ID is only available
  16961. // if it was provided to the builder or after it was returned from the database.
  16962. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  16963. if m.id == nil {
  16964. return
  16965. }
  16966. return *m.id, true
  16967. }
  16968. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16969. // That means, if the mutation is applied within a transaction with an isolation level such
  16970. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16971. // or updated by the mutation.
  16972. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  16973. switch {
  16974. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16975. id, exists := m.ID()
  16976. if exists {
  16977. return []uint64{id}, nil
  16978. }
  16979. fallthrough
  16980. case m.op.Is(OpUpdate | OpDelete):
  16981. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  16982. default:
  16983. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16984. }
  16985. }
  16986. // SetCreatedAt sets the "created_at" field.
  16987. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  16988. m.created_at = &t
  16989. }
  16990. // CreatedAt returns the value of the "created_at" field in the mutation.
  16991. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  16992. v := m.created_at
  16993. if v == nil {
  16994. return
  16995. }
  16996. return *v, true
  16997. }
  16998. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  16999. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17001. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17002. if !m.op.Is(OpUpdateOne) {
  17003. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17004. }
  17005. if m.id == nil || m.oldValue == nil {
  17006. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17007. }
  17008. oldValue, err := m.oldValue(ctx)
  17009. if err != nil {
  17010. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17011. }
  17012. return oldValue.CreatedAt, nil
  17013. }
  17014. // ResetCreatedAt resets all changes to the "created_at" field.
  17015. func (m *EmployeeMutation) ResetCreatedAt() {
  17016. m.created_at = nil
  17017. }
  17018. // SetUpdatedAt sets the "updated_at" field.
  17019. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  17020. m.updated_at = &t
  17021. }
  17022. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17023. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  17024. v := m.updated_at
  17025. if v == nil {
  17026. return
  17027. }
  17028. return *v, true
  17029. }
  17030. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  17031. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17032. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17033. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17034. if !m.op.Is(OpUpdateOne) {
  17035. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17036. }
  17037. if m.id == nil || m.oldValue == nil {
  17038. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17039. }
  17040. oldValue, err := m.oldValue(ctx)
  17041. if err != nil {
  17042. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17043. }
  17044. return oldValue.UpdatedAt, nil
  17045. }
  17046. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17047. func (m *EmployeeMutation) ResetUpdatedAt() {
  17048. m.updated_at = nil
  17049. }
  17050. // SetDeletedAt sets the "deleted_at" field.
  17051. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  17052. m.deleted_at = &t
  17053. }
  17054. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  17055. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  17056. v := m.deleted_at
  17057. if v == nil {
  17058. return
  17059. }
  17060. return *v, true
  17061. }
  17062. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  17063. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17064. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17065. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  17066. if !m.op.Is(OpUpdateOne) {
  17067. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  17068. }
  17069. if m.id == nil || m.oldValue == nil {
  17070. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  17071. }
  17072. oldValue, err := m.oldValue(ctx)
  17073. if err != nil {
  17074. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  17075. }
  17076. return oldValue.DeletedAt, nil
  17077. }
  17078. // ClearDeletedAt clears the value of the "deleted_at" field.
  17079. func (m *EmployeeMutation) ClearDeletedAt() {
  17080. m.deleted_at = nil
  17081. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  17082. }
  17083. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  17084. func (m *EmployeeMutation) DeletedAtCleared() bool {
  17085. _, ok := m.clearedFields[employee.FieldDeletedAt]
  17086. return ok
  17087. }
  17088. // ResetDeletedAt resets all changes to the "deleted_at" field.
  17089. func (m *EmployeeMutation) ResetDeletedAt() {
  17090. m.deleted_at = nil
  17091. delete(m.clearedFields, employee.FieldDeletedAt)
  17092. }
  17093. // SetTitle sets the "title" field.
  17094. func (m *EmployeeMutation) SetTitle(s string) {
  17095. m.title = &s
  17096. }
  17097. // Title returns the value of the "title" field in the mutation.
  17098. func (m *EmployeeMutation) Title() (r string, exists bool) {
  17099. v := m.title
  17100. if v == nil {
  17101. return
  17102. }
  17103. return *v, true
  17104. }
  17105. // OldTitle returns the old "title" field's value of the Employee entity.
  17106. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17107. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17108. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  17109. if !m.op.Is(OpUpdateOne) {
  17110. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  17111. }
  17112. if m.id == nil || m.oldValue == nil {
  17113. return v, errors.New("OldTitle requires an ID field in the mutation")
  17114. }
  17115. oldValue, err := m.oldValue(ctx)
  17116. if err != nil {
  17117. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  17118. }
  17119. return oldValue.Title, nil
  17120. }
  17121. // ResetTitle resets all changes to the "title" field.
  17122. func (m *EmployeeMutation) ResetTitle() {
  17123. m.title = nil
  17124. }
  17125. // SetAvatar sets the "avatar" field.
  17126. func (m *EmployeeMutation) SetAvatar(s string) {
  17127. m.avatar = &s
  17128. }
  17129. // Avatar returns the value of the "avatar" field in the mutation.
  17130. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  17131. v := m.avatar
  17132. if v == nil {
  17133. return
  17134. }
  17135. return *v, true
  17136. }
  17137. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  17138. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17139. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17140. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  17141. if !m.op.Is(OpUpdateOne) {
  17142. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  17143. }
  17144. if m.id == nil || m.oldValue == nil {
  17145. return v, errors.New("OldAvatar requires an ID field in the mutation")
  17146. }
  17147. oldValue, err := m.oldValue(ctx)
  17148. if err != nil {
  17149. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  17150. }
  17151. return oldValue.Avatar, nil
  17152. }
  17153. // ResetAvatar resets all changes to the "avatar" field.
  17154. func (m *EmployeeMutation) ResetAvatar() {
  17155. m.avatar = nil
  17156. }
  17157. // SetTags sets the "tags" field.
  17158. func (m *EmployeeMutation) SetTags(s string) {
  17159. m.tags = &s
  17160. }
  17161. // Tags returns the value of the "tags" field in the mutation.
  17162. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  17163. v := m.tags
  17164. if v == nil {
  17165. return
  17166. }
  17167. return *v, true
  17168. }
  17169. // OldTags returns the old "tags" field's value of the Employee entity.
  17170. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17171. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17172. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  17173. if !m.op.Is(OpUpdateOne) {
  17174. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  17175. }
  17176. if m.id == nil || m.oldValue == nil {
  17177. return v, errors.New("OldTags requires an ID field in the mutation")
  17178. }
  17179. oldValue, err := m.oldValue(ctx)
  17180. if err != nil {
  17181. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  17182. }
  17183. return oldValue.Tags, nil
  17184. }
  17185. // ResetTags resets all changes to the "tags" field.
  17186. func (m *EmployeeMutation) ResetTags() {
  17187. m.tags = nil
  17188. }
  17189. // SetHireCount sets the "hire_count" field.
  17190. func (m *EmployeeMutation) SetHireCount(i int) {
  17191. m.hire_count = &i
  17192. m.addhire_count = nil
  17193. }
  17194. // HireCount returns the value of the "hire_count" field in the mutation.
  17195. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  17196. v := m.hire_count
  17197. if v == nil {
  17198. return
  17199. }
  17200. return *v, true
  17201. }
  17202. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  17203. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17204. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17205. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  17206. if !m.op.Is(OpUpdateOne) {
  17207. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  17208. }
  17209. if m.id == nil || m.oldValue == nil {
  17210. return v, errors.New("OldHireCount requires an ID field in the mutation")
  17211. }
  17212. oldValue, err := m.oldValue(ctx)
  17213. if err != nil {
  17214. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  17215. }
  17216. return oldValue.HireCount, nil
  17217. }
  17218. // AddHireCount adds i to the "hire_count" field.
  17219. func (m *EmployeeMutation) AddHireCount(i int) {
  17220. if m.addhire_count != nil {
  17221. *m.addhire_count += i
  17222. } else {
  17223. m.addhire_count = &i
  17224. }
  17225. }
  17226. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  17227. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  17228. v := m.addhire_count
  17229. if v == nil {
  17230. return
  17231. }
  17232. return *v, true
  17233. }
  17234. // ResetHireCount resets all changes to the "hire_count" field.
  17235. func (m *EmployeeMutation) ResetHireCount() {
  17236. m.hire_count = nil
  17237. m.addhire_count = nil
  17238. }
  17239. // SetServiceCount sets the "service_count" field.
  17240. func (m *EmployeeMutation) SetServiceCount(i int) {
  17241. m.service_count = &i
  17242. m.addservice_count = nil
  17243. }
  17244. // ServiceCount returns the value of the "service_count" field in the mutation.
  17245. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  17246. v := m.service_count
  17247. if v == nil {
  17248. return
  17249. }
  17250. return *v, true
  17251. }
  17252. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  17253. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17255. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  17256. if !m.op.Is(OpUpdateOne) {
  17257. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  17258. }
  17259. if m.id == nil || m.oldValue == nil {
  17260. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  17261. }
  17262. oldValue, err := m.oldValue(ctx)
  17263. if err != nil {
  17264. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  17265. }
  17266. return oldValue.ServiceCount, nil
  17267. }
  17268. // AddServiceCount adds i to the "service_count" field.
  17269. func (m *EmployeeMutation) AddServiceCount(i int) {
  17270. if m.addservice_count != nil {
  17271. *m.addservice_count += i
  17272. } else {
  17273. m.addservice_count = &i
  17274. }
  17275. }
  17276. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  17277. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  17278. v := m.addservice_count
  17279. if v == nil {
  17280. return
  17281. }
  17282. return *v, true
  17283. }
  17284. // ResetServiceCount resets all changes to the "service_count" field.
  17285. func (m *EmployeeMutation) ResetServiceCount() {
  17286. m.service_count = nil
  17287. m.addservice_count = nil
  17288. }
  17289. // SetAchievementCount sets the "achievement_count" field.
  17290. func (m *EmployeeMutation) SetAchievementCount(i int) {
  17291. m.achievement_count = &i
  17292. m.addachievement_count = nil
  17293. }
  17294. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  17295. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  17296. v := m.achievement_count
  17297. if v == nil {
  17298. return
  17299. }
  17300. return *v, true
  17301. }
  17302. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  17303. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17304. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17305. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  17306. if !m.op.Is(OpUpdateOne) {
  17307. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  17308. }
  17309. if m.id == nil || m.oldValue == nil {
  17310. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  17311. }
  17312. oldValue, err := m.oldValue(ctx)
  17313. if err != nil {
  17314. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  17315. }
  17316. return oldValue.AchievementCount, nil
  17317. }
  17318. // AddAchievementCount adds i to the "achievement_count" field.
  17319. func (m *EmployeeMutation) AddAchievementCount(i int) {
  17320. if m.addachievement_count != nil {
  17321. *m.addachievement_count += i
  17322. } else {
  17323. m.addachievement_count = &i
  17324. }
  17325. }
  17326. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  17327. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  17328. v := m.addachievement_count
  17329. if v == nil {
  17330. return
  17331. }
  17332. return *v, true
  17333. }
  17334. // ResetAchievementCount resets all changes to the "achievement_count" field.
  17335. func (m *EmployeeMutation) ResetAchievementCount() {
  17336. m.achievement_count = nil
  17337. m.addachievement_count = nil
  17338. }
  17339. // SetIntro sets the "intro" field.
  17340. func (m *EmployeeMutation) SetIntro(s string) {
  17341. m.intro = &s
  17342. }
  17343. // Intro returns the value of the "intro" field in the mutation.
  17344. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  17345. v := m.intro
  17346. if v == nil {
  17347. return
  17348. }
  17349. return *v, true
  17350. }
  17351. // OldIntro returns the old "intro" field's value of the Employee entity.
  17352. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17353. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17354. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  17355. if !m.op.Is(OpUpdateOne) {
  17356. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  17357. }
  17358. if m.id == nil || m.oldValue == nil {
  17359. return v, errors.New("OldIntro requires an ID field in the mutation")
  17360. }
  17361. oldValue, err := m.oldValue(ctx)
  17362. if err != nil {
  17363. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  17364. }
  17365. return oldValue.Intro, nil
  17366. }
  17367. // ResetIntro resets all changes to the "intro" field.
  17368. func (m *EmployeeMutation) ResetIntro() {
  17369. m.intro = nil
  17370. }
  17371. // SetEstimate sets the "estimate" field.
  17372. func (m *EmployeeMutation) SetEstimate(s string) {
  17373. m.estimate = &s
  17374. }
  17375. // Estimate returns the value of the "estimate" field in the mutation.
  17376. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  17377. v := m.estimate
  17378. if v == nil {
  17379. return
  17380. }
  17381. return *v, true
  17382. }
  17383. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  17384. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17386. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  17387. if !m.op.Is(OpUpdateOne) {
  17388. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  17389. }
  17390. if m.id == nil || m.oldValue == nil {
  17391. return v, errors.New("OldEstimate requires an ID field in the mutation")
  17392. }
  17393. oldValue, err := m.oldValue(ctx)
  17394. if err != nil {
  17395. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  17396. }
  17397. return oldValue.Estimate, nil
  17398. }
  17399. // ResetEstimate resets all changes to the "estimate" field.
  17400. func (m *EmployeeMutation) ResetEstimate() {
  17401. m.estimate = nil
  17402. }
  17403. // SetSkill sets the "skill" field.
  17404. func (m *EmployeeMutation) SetSkill(s string) {
  17405. m.skill = &s
  17406. }
  17407. // Skill returns the value of the "skill" field in the mutation.
  17408. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  17409. v := m.skill
  17410. if v == nil {
  17411. return
  17412. }
  17413. return *v, true
  17414. }
  17415. // OldSkill returns the old "skill" field's value of the Employee entity.
  17416. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17417. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17418. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  17419. if !m.op.Is(OpUpdateOne) {
  17420. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  17421. }
  17422. if m.id == nil || m.oldValue == nil {
  17423. return v, errors.New("OldSkill requires an ID field in the mutation")
  17424. }
  17425. oldValue, err := m.oldValue(ctx)
  17426. if err != nil {
  17427. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  17428. }
  17429. return oldValue.Skill, nil
  17430. }
  17431. // ResetSkill resets all changes to the "skill" field.
  17432. func (m *EmployeeMutation) ResetSkill() {
  17433. m.skill = nil
  17434. }
  17435. // SetAbilityType sets the "ability_type" field.
  17436. func (m *EmployeeMutation) SetAbilityType(s string) {
  17437. m.ability_type = &s
  17438. }
  17439. // AbilityType returns the value of the "ability_type" field in the mutation.
  17440. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  17441. v := m.ability_type
  17442. if v == nil {
  17443. return
  17444. }
  17445. return *v, true
  17446. }
  17447. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  17448. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17450. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  17451. if !m.op.Is(OpUpdateOne) {
  17452. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  17453. }
  17454. if m.id == nil || m.oldValue == nil {
  17455. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  17456. }
  17457. oldValue, err := m.oldValue(ctx)
  17458. if err != nil {
  17459. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  17460. }
  17461. return oldValue.AbilityType, nil
  17462. }
  17463. // ResetAbilityType resets all changes to the "ability_type" field.
  17464. func (m *EmployeeMutation) ResetAbilityType() {
  17465. m.ability_type = nil
  17466. }
  17467. // SetScene sets the "scene" field.
  17468. func (m *EmployeeMutation) SetScene(s string) {
  17469. m.scene = &s
  17470. }
  17471. // Scene returns the value of the "scene" field in the mutation.
  17472. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  17473. v := m.scene
  17474. if v == nil {
  17475. return
  17476. }
  17477. return *v, true
  17478. }
  17479. // OldScene returns the old "scene" field's value of the Employee entity.
  17480. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17481. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17482. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  17483. if !m.op.Is(OpUpdateOne) {
  17484. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  17485. }
  17486. if m.id == nil || m.oldValue == nil {
  17487. return v, errors.New("OldScene requires an ID field in the mutation")
  17488. }
  17489. oldValue, err := m.oldValue(ctx)
  17490. if err != nil {
  17491. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  17492. }
  17493. return oldValue.Scene, nil
  17494. }
  17495. // ResetScene resets all changes to the "scene" field.
  17496. func (m *EmployeeMutation) ResetScene() {
  17497. m.scene = nil
  17498. }
  17499. // SetSwitchIn sets the "switch_in" field.
  17500. func (m *EmployeeMutation) SetSwitchIn(s string) {
  17501. m.switch_in = &s
  17502. }
  17503. // SwitchIn returns the value of the "switch_in" field in the mutation.
  17504. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  17505. v := m.switch_in
  17506. if v == nil {
  17507. return
  17508. }
  17509. return *v, true
  17510. }
  17511. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  17512. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17513. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17514. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  17515. if !m.op.Is(OpUpdateOne) {
  17516. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  17517. }
  17518. if m.id == nil || m.oldValue == nil {
  17519. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  17520. }
  17521. oldValue, err := m.oldValue(ctx)
  17522. if err != nil {
  17523. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  17524. }
  17525. return oldValue.SwitchIn, nil
  17526. }
  17527. // ResetSwitchIn resets all changes to the "switch_in" field.
  17528. func (m *EmployeeMutation) ResetSwitchIn() {
  17529. m.switch_in = nil
  17530. }
  17531. // SetVideoURL sets the "video_url" field.
  17532. func (m *EmployeeMutation) SetVideoURL(s string) {
  17533. m.video_url = &s
  17534. }
  17535. // VideoURL returns the value of the "video_url" field in the mutation.
  17536. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  17537. v := m.video_url
  17538. if v == nil {
  17539. return
  17540. }
  17541. return *v, true
  17542. }
  17543. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  17544. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17545. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17546. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  17547. if !m.op.Is(OpUpdateOne) {
  17548. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  17549. }
  17550. if m.id == nil || m.oldValue == nil {
  17551. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  17552. }
  17553. oldValue, err := m.oldValue(ctx)
  17554. if err != nil {
  17555. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  17556. }
  17557. return oldValue.VideoURL, nil
  17558. }
  17559. // ResetVideoURL resets all changes to the "video_url" field.
  17560. func (m *EmployeeMutation) ResetVideoURL() {
  17561. m.video_url = nil
  17562. }
  17563. // SetOrganizationID sets the "organization_id" field.
  17564. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  17565. m.organization_id = &u
  17566. m.addorganization_id = nil
  17567. }
  17568. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17569. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  17570. v := m.organization_id
  17571. if v == nil {
  17572. return
  17573. }
  17574. return *v, true
  17575. }
  17576. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  17577. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17578. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17579. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17580. if !m.op.Is(OpUpdateOne) {
  17581. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17582. }
  17583. if m.id == nil || m.oldValue == nil {
  17584. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17585. }
  17586. oldValue, err := m.oldValue(ctx)
  17587. if err != nil {
  17588. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17589. }
  17590. return oldValue.OrganizationID, nil
  17591. }
  17592. // AddOrganizationID adds u to the "organization_id" field.
  17593. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  17594. if m.addorganization_id != nil {
  17595. *m.addorganization_id += u
  17596. } else {
  17597. m.addorganization_id = &u
  17598. }
  17599. }
  17600. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17601. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  17602. v := m.addorganization_id
  17603. if v == nil {
  17604. return
  17605. }
  17606. return *v, true
  17607. }
  17608. // ResetOrganizationID resets all changes to the "organization_id" field.
  17609. func (m *EmployeeMutation) ResetOrganizationID() {
  17610. m.organization_id = nil
  17611. m.addorganization_id = nil
  17612. }
  17613. // SetCategoryID sets the "category_id" field.
  17614. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  17615. m.category_id = &u
  17616. m.addcategory_id = nil
  17617. }
  17618. // CategoryID returns the value of the "category_id" field in the mutation.
  17619. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  17620. v := m.category_id
  17621. if v == nil {
  17622. return
  17623. }
  17624. return *v, true
  17625. }
  17626. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  17627. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17628. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17629. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  17630. if !m.op.Is(OpUpdateOne) {
  17631. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  17632. }
  17633. if m.id == nil || m.oldValue == nil {
  17634. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  17635. }
  17636. oldValue, err := m.oldValue(ctx)
  17637. if err != nil {
  17638. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  17639. }
  17640. return oldValue.CategoryID, nil
  17641. }
  17642. // AddCategoryID adds u to the "category_id" field.
  17643. func (m *EmployeeMutation) AddCategoryID(u int64) {
  17644. if m.addcategory_id != nil {
  17645. *m.addcategory_id += u
  17646. } else {
  17647. m.addcategory_id = &u
  17648. }
  17649. }
  17650. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  17651. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  17652. v := m.addcategory_id
  17653. if v == nil {
  17654. return
  17655. }
  17656. return *v, true
  17657. }
  17658. // ResetCategoryID resets all changes to the "category_id" field.
  17659. func (m *EmployeeMutation) ResetCategoryID() {
  17660. m.category_id = nil
  17661. m.addcategory_id = nil
  17662. }
  17663. // SetAPIBase sets the "api_base" field.
  17664. func (m *EmployeeMutation) SetAPIBase(s string) {
  17665. m.api_base = &s
  17666. }
  17667. // APIBase returns the value of the "api_base" field in the mutation.
  17668. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  17669. v := m.api_base
  17670. if v == nil {
  17671. return
  17672. }
  17673. return *v, true
  17674. }
  17675. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  17676. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17677. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17678. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  17679. if !m.op.Is(OpUpdateOne) {
  17680. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  17681. }
  17682. if m.id == nil || m.oldValue == nil {
  17683. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  17684. }
  17685. oldValue, err := m.oldValue(ctx)
  17686. if err != nil {
  17687. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  17688. }
  17689. return oldValue.APIBase, nil
  17690. }
  17691. // ResetAPIBase resets all changes to the "api_base" field.
  17692. func (m *EmployeeMutation) ResetAPIBase() {
  17693. m.api_base = nil
  17694. }
  17695. // SetAPIKey sets the "api_key" field.
  17696. func (m *EmployeeMutation) SetAPIKey(s string) {
  17697. m.api_key = &s
  17698. }
  17699. // APIKey returns the value of the "api_key" field in the mutation.
  17700. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  17701. v := m.api_key
  17702. if v == nil {
  17703. return
  17704. }
  17705. return *v, true
  17706. }
  17707. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  17708. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17709. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17710. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  17711. if !m.op.Is(OpUpdateOne) {
  17712. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  17713. }
  17714. if m.id == nil || m.oldValue == nil {
  17715. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  17716. }
  17717. oldValue, err := m.oldValue(ctx)
  17718. if err != nil {
  17719. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  17720. }
  17721. return oldValue.APIKey, nil
  17722. }
  17723. // ResetAPIKey resets all changes to the "api_key" field.
  17724. func (m *EmployeeMutation) ResetAPIKey() {
  17725. m.api_key = nil
  17726. }
  17727. // SetAiInfo sets the "ai_info" field.
  17728. func (m *EmployeeMutation) SetAiInfo(s string) {
  17729. m.ai_info = &s
  17730. }
  17731. // AiInfo returns the value of the "ai_info" field in the mutation.
  17732. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  17733. v := m.ai_info
  17734. if v == nil {
  17735. return
  17736. }
  17737. return *v, true
  17738. }
  17739. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  17740. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17741. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17742. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  17743. if !m.op.Is(OpUpdateOne) {
  17744. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  17745. }
  17746. if m.id == nil || m.oldValue == nil {
  17747. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  17748. }
  17749. oldValue, err := m.oldValue(ctx)
  17750. if err != nil {
  17751. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  17752. }
  17753. return oldValue.AiInfo, nil
  17754. }
  17755. // ClearAiInfo clears the value of the "ai_info" field.
  17756. func (m *EmployeeMutation) ClearAiInfo() {
  17757. m.ai_info = nil
  17758. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  17759. }
  17760. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  17761. func (m *EmployeeMutation) AiInfoCleared() bool {
  17762. _, ok := m.clearedFields[employee.FieldAiInfo]
  17763. return ok
  17764. }
  17765. // ResetAiInfo resets all changes to the "ai_info" field.
  17766. func (m *EmployeeMutation) ResetAiInfo() {
  17767. m.ai_info = nil
  17768. delete(m.clearedFields, employee.FieldAiInfo)
  17769. }
  17770. // SetIsVip sets the "is_vip" field.
  17771. func (m *EmployeeMutation) SetIsVip(i int) {
  17772. m.is_vip = &i
  17773. m.addis_vip = nil
  17774. }
  17775. // IsVip returns the value of the "is_vip" field in the mutation.
  17776. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  17777. v := m.is_vip
  17778. if v == nil {
  17779. return
  17780. }
  17781. return *v, true
  17782. }
  17783. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  17784. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17785. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17786. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  17787. if !m.op.Is(OpUpdateOne) {
  17788. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  17789. }
  17790. if m.id == nil || m.oldValue == nil {
  17791. return v, errors.New("OldIsVip requires an ID field in the mutation")
  17792. }
  17793. oldValue, err := m.oldValue(ctx)
  17794. if err != nil {
  17795. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  17796. }
  17797. return oldValue.IsVip, nil
  17798. }
  17799. // AddIsVip adds i to the "is_vip" field.
  17800. func (m *EmployeeMutation) AddIsVip(i int) {
  17801. if m.addis_vip != nil {
  17802. *m.addis_vip += i
  17803. } else {
  17804. m.addis_vip = &i
  17805. }
  17806. }
  17807. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  17808. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  17809. v := m.addis_vip
  17810. if v == nil {
  17811. return
  17812. }
  17813. return *v, true
  17814. }
  17815. // ResetIsVip resets all changes to the "is_vip" field.
  17816. func (m *EmployeeMutation) ResetIsVip() {
  17817. m.is_vip = nil
  17818. m.addis_vip = nil
  17819. }
  17820. // SetChatURL sets the "chat_url" field.
  17821. func (m *EmployeeMutation) SetChatURL(s string) {
  17822. m.chat_url = &s
  17823. }
  17824. // ChatURL returns the value of the "chat_url" field in the mutation.
  17825. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  17826. v := m.chat_url
  17827. if v == nil {
  17828. return
  17829. }
  17830. return *v, true
  17831. }
  17832. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  17833. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17834. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17835. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  17836. if !m.op.Is(OpUpdateOne) {
  17837. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  17838. }
  17839. if m.id == nil || m.oldValue == nil {
  17840. return v, errors.New("OldChatURL requires an ID field in the mutation")
  17841. }
  17842. oldValue, err := m.oldValue(ctx)
  17843. if err != nil {
  17844. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  17845. }
  17846. return oldValue.ChatURL, nil
  17847. }
  17848. // ResetChatURL resets all changes to the "chat_url" field.
  17849. func (m *EmployeeMutation) ResetChatURL() {
  17850. m.chat_url = nil
  17851. }
  17852. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  17853. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  17854. if m.em_work_experiences == nil {
  17855. m.em_work_experiences = make(map[uint64]struct{})
  17856. }
  17857. for i := range ids {
  17858. m.em_work_experiences[ids[i]] = struct{}{}
  17859. }
  17860. }
  17861. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  17862. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  17863. m.clearedem_work_experiences = true
  17864. }
  17865. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  17866. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  17867. return m.clearedem_work_experiences
  17868. }
  17869. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  17870. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  17871. if m.removedem_work_experiences == nil {
  17872. m.removedem_work_experiences = make(map[uint64]struct{})
  17873. }
  17874. for i := range ids {
  17875. delete(m.em_work_experiences, ids[i])
  17876. m.removedem_work_experiences[ids[i]] = struct{}{}
  17877. }
  17878. }
  17879. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  17880. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  17881. for id := range m.removedem_work_experiences {
  17882. ids = append(ids, id)
  17883. }
  17884. return
  17885. }
  17886. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  17887. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  17888. for id := range m.em_work_experiences {
  17889. ids = append(ids, id)
  17890. }
  17891. return
  17892. }
  17893. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  17894. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  17895. m.em_work_experiences = nil
  17896. m.clearedem_work_experiences = false
  17897. m.removedem_work_experiences = nil
  17898. }
  17899. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  17900. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  17901. if m.em_tutorial == nil {
  17902. m.em_tutorial = make(map[uint64]struct{})
  17903. }
  17904. for i := range ids {
  17905. m.em_tutorial[ids[i]] = struct{}{}
  17906. }
  17907. }
  17908. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  17909. func (m *EmployeeMutation) ClearEmTutorial() {
  17910. m.clearedem_tutorial = true
  17911. }
  17912. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  17913. func (m *EmployeeMutation) EmTutorialCleared() bool {
  17914. return m.clearedem_tutorial
  17915. }
  17916. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  17917. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  17918. if m.removedem_tutorial == nil {
  17919. m.removedem_tutorial = make(map[uint64]struct{})
  17920. }
  17921. for i := range ids {
  17922. delete(m.em_tutorial, ids[i])
  17923. m.removedem_tutorial[ids[i]] = struct{}{}
  17924. }
  17925. }
  17926. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  17927. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  17928. for id := range m.removedem_tutorial {
  17929. ids = append(ids, id)
  17930. }
  17931. return
  17932. }
  17933. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  17934. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  17935. for id := range m.em_tutorial {
  17936. ids = append(ids, id)
  17937. }
  17938. return
  17939. }
  17940. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  17941. func (m *EmployeeMutation) ResetEmTutorial() {
  17942. m.em_tutorial = nil
  17943. m.clearedem_tutorial = false
  17944. m.removedem_tutorial = nil
  17945. }
  17946. // Where appends a list predicates to the EmployeeMutation builder.
  17947. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  17948. m.predicates = append(m.predicates, ps...)
  17949. }
  17950. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  17951. // users can use type-assertion to append predicates that do not depend on any generated package.
  17952. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  17953. p := make([]predicate.Employee, len(ps))
  17954. for i := range ps {
  17955. p[i] = ps[i]
  17956. }
  17957. m.Where(p...)
  17958. }
  17959. // Op returns the operation name.
  17960. func (m *EmployeeMutation) Op() Op {
  17961. return m.op
  17962. }
  17963. // SetOp allows setting the mutation operation.
  17964. func (m *EmployeeMutation) SetOp(op Op) {
  17965. m.op = op
  17966. }
  17967. // Type returns the node type of this mutation (Employee).
  17968. func (m *EmployeeMutation) Type() string {
  17969. return m.typ
  17970. }
  17971. // Fields returns all fields that were changed during this mutation. Note that in
  17972. // order to get all numeric fields that were incremented/decremented, call
  17973. // AddedFields().
  17974. func (m *EmployeeMutation) Fields() []string {
  17975. fields := make([]string, 0, 23)
  17976. if m.created_at != nil {
  17977. fields = append(fields, employee.FieldCreatedAt)
  17978. }
  17979. if m.updated_at != nil {
  17980. fields = append(fields, employee.FieldUpdatedAt)
  17981. }
  17982. if m.deleted_at != nil {
  17983. fields = append(fields, employee.FieldDeletedAt)
  17984. }
  17985. if m.title != nil {
  17986. fields = append(fields, employee.FieldTitle)
  17987. }
  17988. if m.avatar != nil {
  17989. fields = append(fields, employee.FieldAvatar)
  17990. }
  17991. if m.tags != nil {
  17992. fields = append(fields, employee.FieldTags)
  17993. }
  17994. if m.hire_count != nil {
  17995. fields = append(fields, employee.FieldHireCount)
  17996. }
  17997. if m.service_count != nil {
  17998. fields = append(fields, employee.FieldServiceCount)
  17999. }
  18000. if m.achievement_count != nil {
  18001. fields = append(fields, employee.FieldAchievementCount)
  18002. }
  18003. if m.intro != nil {
  18004. fields = append(fields, employee.FieldIntro)
  18005. }
  18006. if m.estimate != nil {
  18007. fields = append(fields, employee.FieldEstimate)
  18008. }
  18009. if m.skill != nil {
  18010. fields = append(fields, employee.FieldSkill)
  18011. }
  18012. if m.ability_type != nil {
  18013. fields = append(fields, employee.FieldAbilityType)
  18014. }
  18015. if m.scene != nil {
  18016. fields = append(fields, employee.FieldScene)
  18017. }
  18018. if m.switch_in != nil {
  18019. fields = append(fields, employee.FieldSwitchIn)
  18020. }
  18021. if m.video_url != nil {
  18022. fields = append(fields, employee.FieldVideoURL)
  18023. }
  18024. if m.organization_id != nil {
  18025. fields = append(fields, employee.FieldOrganizationID)
  18026. }
  18027. if m.category_id != nil {
  18028. fields = append(fields, employee.FieldCategoryID)
  18029. }
  18030. if m.api_base != nil {
  18031. fields = append(fields, employee.FieldAPIBase)
  18032. }
  18033. if m.api_key != nil {
  18034. fields = append(fields, employee.FieldAPIKey)
  18035. }
  18036. if m.ai_info != nil {
  18037. fields = append(fields, employee.FieldAiInfo)
  18038. }
  18039. if m.is_vip != nil {
  18040. fields = append(fields, employee.FieldIsVip)
  18041. }
  18042. if m.chat_url != nil {
  18043. fields = append(fields, employee.FieldChatURL)
  18044. }
  18045. return fields
  18046. }
  18047. // Field returns the value of a field with the given name. The second boolean
  18048. // return value indicates that this field was not set, or was not defined in the
  18049. // schema.
  18050. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  18051. switch name {
  18052. case employee.FieldCreatedAt:
  18053. return m.CreatedAt()
  18054. case employee.FieldUpdatedAt:
  18055. return m.UpdatedAt()
  18056. case employee.FieldDeletedAt:
  18057. return m.DeletedAt()
  18058. case employee.FieldTitle:
  18059. return m.Title()
  18060. case employee.FieldAvatar:
  18061. return m.Avatar()
  18062. case employee.FieldTags:
  18063. return m.Tags()
  18064. case employee.FieldHireCount:
  18065. return m.HireCount()
  18066. case employee.FieldServiceCount:
  18067. return m.ServiceCount()
  18068. case employee.FieldAchievementCount:
  18069. return m.AchievementCount()
  18070. case employee.FieldIntro:
  18071. return m.Intro()
  18072. case employee.FieldEstimate:
  18073. return m.Estimate()
  18074. case employee.FieldSkill:
  18075. return m.Skill()
  18076. case employee.FieldAbilityType:
  18077. return m.AbilityType()
  18078. case employee.FieldScene:
  18079. return m.Scene()
  18080. case employee.FieldSwitchIn:
  18081. return m.SwitchIn()
  18082. case employee.FieldVideoURL:
  18083. return m.VideoURL()
  18084. case employee.FieldOrganizationID:
  18085. return m.OrganizationID()
  18086. case employee.FieldCategoryID:
  18087. return m.CategoryID()
  18088. case employee.FieldAPIBase:
  18089. return m.APIBase()
  18090. case employee.FieldAPIKey:
  18091. return m.APIKey()
  18092. case employee.FieldAiInfo:
  18093. return m.AiInfo()
  18094. case employee.FieldIsVip:
  18095. return m.IsVip()
  18096. case employee.FieldChatURL:
  18097. return m.ChatURL()
  18098. }
  18099. return nil, false
  18100. }
  18101. // OldField returns the old value of the field from the database. An error is
  18102. // returned if the mutation operation is not UpdateOne, or the query to the
  18103. // database failed.
  18104. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18105. switch name {
  18106. case employee.FieldCreatedAt:
  18107. return m.OldCreatedAt(ctx)
  18108. case employee.FieldUpdatedAt:
  18109. return m.OldUpdatedAt(ctx)
  18110. case employee.FieldDeletedAt:
  18111. return m.OldDeletedAt(ctx)
  18112. case employee.FieldTitle:
  18113. return m.OldTitle(ctx)
  18114. case employee.FieldAvatar:
  18115. return m.OldAvatar(ctx)
  18116. case employee.FieldTags:
  18117. return m.OldTags(ctx)
  18118. case employee.FieldHireCount:
  18119. return m.OldHireCount(ctx)
  18120. case employee.FieldServiceCount:
  18121. return m.OldServiceCount(ctx)
  18122. case employee.FieldAchievementCount:
  18123. return m.OldAchievementCount(ctx)
  18124. case employee.FieldIntro:
  18125. return m.OldIntro(ctx)
  18126. case employee.FieldEstimate:
  18127. return m.OldEstimate(ctx)
  18128. case employee.FieldSkill:
  18129. return m.OldSkill(ctx)
  18130. case employee.FieldAbilityType:
  18131. return m.OldAbilityType(ctx)
  18132. case employee.FieldScene:
  18133. return m.OldScene(ctx)
  18134. case employee.FieldSwitchIn:
  18135. return m.OldSwitchIn(ctx)
  18136. case employee.FieldVideoURL:
  18137. return m.OldVideoURL(ctx)
  18138. case employee.FieldOrganizationID:
  18139. return m.OldOrganizationID(ctx)
  18140. case employee.FieldCategoryID:
  18141. return m.OldCategoryID(ctx)
  18142. case employee.FieldAPIBase:
  18143. return m.OldAPIBase(ctx)
  18144. case employee.FieldAPIKey:
  18145. return m.OldAPIKey(ctx)
  18146. case employee.FieldAiInfo:
  18147. return m.OldAiInfo(ctx)
  18148. case employee.FieldIsVip:
  18149. return m.OldIsVip(ctx)
  18150. case employee.FieldChatURL:
  18151. return m.OldChatURL(ctx)
  18152. }
  18153. return nil, fmt.Errorf("unknown Employee field %s", name)
  18154. }
  18155. // SetField sets the value of a field with the given name. It returns an error if
  18156. // the field is not defined in the schema, or if the type mismatched the field
  18157. // type.
  18158. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  18159. switch name {
  18160. case employee.FieldCreatedAt:
  18161. v, ok := value.(time.Time)
  18162. if !ok {
  18163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18164. }
  18165. m.SetCreatedAt(v)
  18166. return nil
  18167. case employee.FieldUpdatedAt:
  18168. v, ok := value.(time.Time)
  18169. if !ok {
  18170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18171. }
  18172. m.SetUpdatedAt(v)
  18173. return nil
  18174. case employee.FieldDeletedAt:
  18175. v, ok := value.(time.Time)
  18176. if !ok {
  18177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18178. }
  18179. m.SetDeletedAt(v)
  18180. return nil
  18181. case employee.FieldTitle:
  18182. v, ok := value.(string)
  18183. if !ok {
  18184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18185. }
  18186. m.SetTitle(v)
  18187. return nil
  18188. case employee.FieldAvatar:
  18189. v, ok := value.(string)
  18190. if !ok {
  18191. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18192. }
  18193. m.SetAvatar(v)
  18194. return nil
  18195. case employee.FieldTags:
  18196. v, ok := value.(string)
  18197. if !ok {
  18198. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18199. }
  18200. m.SetTags(v)
  18201. return nil
  18202. case employee.FieldHireCount:
  18203. v, ok := value.(int)
  18204. if !ok {
  18205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18206. }
  18207. m.SetHireCount(v)
  18208. return nil
  18209. case employee.FieldServiceCount:
  18210. v, ok := value.(int)
  18211. if !ok {
  18212. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18213. }
  18214. m.SetServiceCount(v)
  18215. return nil
  18216. case employee.FieldAchievementCount:
  18217. v, ok := value.(int)
  18218. if !ok {
  18219. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18220. }
  18221. m.SetAchievementCount(v)
  18222. return nil
  18223. case employee.FieldIntro:
  18224. v, ok := value.(string)
  18225. if !ok {
  18226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18227. }
  18228. m.SetIntro(v)
  18229. return nil
  18230. case employee.FieldEstimate:
  18231. v, ok := value.(string)
  18232. if !ok {
  18233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18234. }
  18235. m.SetEstimate(v)
  18236. return nil
  18237. case employee.FieldSkill:
  18238. v, ok := value.(string)
  18239. if !ok {
  18240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18241. }
  18242. m.SetSkill(v)
  18243. return nil
  18244. case employee.FieldAbilityType:
  18245. v, ok := value.(string)
  18246. if !ok {
  18247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18248. }
  18249. m.SetAbilityType(v)
  18250. return nil
  18251. case employee.FieldScene:
  18252. v, ok := value.(string)
  18253. if !ok {
  18254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18255. }
  18256. m.SetScene(v)
  18257. return nil
  18258. case employee.FieldSwitchIn:
  18259. v, ok := value.(string)
  18260. if !ok {
  18261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18262. }
  18263. m.SetSwitchIn(v)
  18264. return nil
  18265. case employee.FieldVideoURL:
  18266. v, ok := value.(string)
  18267. if !ok {
  18268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18269. }
  18270. m.SetVideoURL(v)
  18271. return nil
  18272. case employee.FieldOrganizationID:
  18273. v, ok := value.(uint64)
  18274. if !ok {
  18275. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18276. }
  18277. m.SetOrganizationID(v)
  18278. return nil
  18279. case employee.FieldCategoryID:
  18280. v, ok := value.(uint64)
  18281. if !ok {
  18282. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18283. }
  18284. m.SetCategoryID(v)
  18285. return nil
  18286. case employee.FieldAPIBase:
  18287. v, ok := value.(string)
  18288. if !ok {
  18289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18290. }
  18291. m.SetAPIBase(v)
  18292. return nil
  18293. case employee.FieldAPIKey:
  18294. v, ok := value.(string)
  18295. if !ok {
  18296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18297. }
  18298. m.SetAPIKey(v)
  18299. return nil
  18300. case employee.FieldAiInfo:
  18301. v, ok := value.(string)
  18302. if !ok {
  18303. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18304. }
  18305. m.SetAiInfo(v)
  18306. return nil
  18307. case employee.FieldIsVip:
  18308. v, ok := value.(int)
  18309. if !ok {
  18310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18311. }
  18312. m.SetIsVip(v)
  18313. return nil
  18314. case employee.FieldChatURL:
  18315. v, ok := value.(string)
  18316. if !ok {
  18317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18318. }
  18319. m.SetChatURL(v)
  18320. return nil
  18321. }
  18322. return fmt.Errorf("unknown Employee field %s", name)
  18323. }
  18324. // AddedFields returns all numeric fields that were incremented/decremented during
  18325. // this mutation.
  18326. func (m *EmployeeMutation) AddedFields() []string {
  18327. var fields []string
  18328. if m.addhire_count != nil {
  18329. fields = append(fields, employee.FieldHireCount)
  18330. }
  18331. if m.addservice_count != nil {
  18332. fields = append(fields, employee.FieldServiceCount)
  18333. }
  18334. if m.addachievement_count != nil {
  18335. fields = append(fields, employee.FieldAchievementCount)
  18336. }
  18337. if m.addorganization_id != nil {
  18338. fields = append(fields, employee.FieldOrganizationID)
  18339. }
  18340. if m.addcategory_id != nil {
  18341. fields = append(fields, employee.FieldCategoryID)
  18342. }
  18343. if m.addis_vip != nil {
  18344. fields = append(fields, employee.FieldIsVip)
  18345. }
  18346. return fields
  18347. }
  18348. // AddedField returns the numeric value that was incremented/decremented on a field
  18349. // with the given name. The second boolean return value indicates that this field
  18350. // was not set, or was not defined in the schema.
  18351. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  18352. switch name {
  18353. case employee.FieldHireCount:
  18354. return m.AddedHireCount()
  18355. case employee.FieldServiceCount:
  18356. return m.AddedServiceCount()
  18357. case employee.FieldAchievementCount:
  18358. return m.AddedAchievementCount()
  18359. case employee.FieldOrganizationID:
  18360. return m.AddedOrganizationID()
  18361. case employee.FieldCategoryID:
  18362. return m.AddedCategoryID()
  18363. case employee.FieldIsVip:
  18364. return m.AddedIsVip()
  18365. }
  18366. return nil, false
  18367. }
  18368. // AddField adds the value to the field with the given name. It returns an error if
  18369. // the field is not defined in the schema, or if the type mismatched the field
  18370. // type.
  18371. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  18372. switch name {
  18373. case employee.FieldHireCount:
  18374. v, ok := value.(int)
  18375. if !ok {
  18376. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18377. }
  18378. m.AddHireCount(v)
  18379. return nil
  18380. case employee.FieldServiceCount:
  18381. v, ok := value.(int)
  18382. if !ok {
  18383. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18384. }
  18385. m.AddServiceCount(v)
  18386. return nil
  18387. case employee.FieldAchievementCount:
  18388. v, ok := value.(int)
  18389. if !ok {
  18390. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18391. }
  18392. m.AddAchievementCount(v)
  18393. return nil
  18394. case employee.FieldOrganizationID:
  18395. v, ok := value.(int64)
  18396. if !ok {
  18397. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18398. }
  18399. m.AddOrganizationID(v)
  18400. return nil
  18401. case employee.FieldCategoryID:
  18402. v, ok := value.(int64)
  18403. if !ok {
  18404. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18405. }
  18406. m.AddCategoryID(v)
  18407. return nil
  18408. case employee.FieldIsVip:
  18409. v, ok := value.(int)
  18410. if !ok {
  18411. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18412. }
  18413. m.AddIsVip(v)
  18414. return nil
  18415. }
  18416. return fmt.Errorf("unknown Employee numeric field %s", name)
  18417. }
  18418. // ClearedFields returns all nullable fields that were cleared during this
  18419. // mutation.
  18420. func (m *EmployeeMutation) ClearedFields() []string {
  18421. var fields []string
  18422. if m.FieldCleared(employee.FieldDeletedAt) {
  18423. fields = append(fields, employee.FieldDeletedAt)
  18424. }
  18425. if m.FieldCleared(employee.FieldAiInfo) {
  18426. fields = append(fields, employee.FieldAiInfo)
  18427. }
  18428. return fields
  18429. }
  18430. // FieldCleared returns a boolean indicating if a field with the given name was
  18431. // cleared in this mutation.
  18432. func (m *EmployeeMutation) FieldCleared(name string) bool {
  18433. _, ok := m.clearedFields[name]
  18434. return ok
  18435. }
  18436. // ClearField clears the value of the field with the given name. It returns an
  18437. // error if the field is not defined in the schema.
  18438. func (m *EmployeeMutation) ClearField(name string) error {
  18439. switch name {
  18440. case employee.FieldDeletedAt:
  18441. m.ClearDeletedAt()
  18442. return nil
  18443. case employee.FieldAiInfo:
  18444. m.ClearAiInfo()
  18445. return nil
  18446. }
  18447. return fmt.Errorf("unknown Employee nullable field %s", name)
  18448. }
  18449. // ResetField resets all changes in the mutation for the field with the given name.
  18450. // It returns an error if the field is not defined in the schema.
  18451. func (m *EmployeeMutation) ResetField(name string) error {
  18452. switch name {
  18453. case employee.FieldCreatedAt:
  18454. m.ResetCreatedAt()
  18455. return nil
  18456. case employee.FieldUpdatedAt:
  18457. m.ResetUpdatedAt()
  18458. return nil
  18459. case employee.FieldDeletedAt:
  18460. m.ResetDeletedAt()
  18461. return nil
  18462. case employee.FieldTitle:
  18463. m.ResetTitle()
  18464. return nil
  18465. case employee.FieldAvatar:
  18466. m.ResetAvatar()
  18467. return nil
  18468. case employee.FieldTags:
  18469. m.ResetTags()
  18470. return nil
  18471. case employee.FieldHireCount:
  18472. m.ResetHireCount()
  18473. return nil
  18474. case employee.FieldServiceCount:
  18475. m.ResetServiceCount()
  18476. return nil
  18477. case employee.FieldAchievementCount:
  18478. m.ResetAchievementCount()
  18479. return nil
  18480. case employee.FieldIntro:
  18481. m.ResetIntro()
  18482. return nil
  18483. case employee.FieldEstimate:
  18484. m.ResetEstimate()
  18485. return nil
  18486. case employee.FieldSkill:
  18487. m.ResetSkill()
  18488. return nil
  18489. case employee.FieldAbilityType:
  18490. m.ResetAbilityType()
  18491. return nil
  18492. case employee.FieldScene:
  18493. m.ResetScene()
  18494. return nil
  18495. case employee.FieldSwitchIn:
  18496. m.ResetSwitchIn()
  18497. return nil
  18498. case employee.FieldVideoURL:
  18499. m.ResetVideoURL()
  18500. return nil
  18501. case employee.FieldOrganizationID:
  18502. m.ResetOrganizationID()
  18503. return nil
  18504. case employee.FieldCategoryID:
  18505. m.ResetCategoryID()
  18506. return nil
  18507. case employee.FieldAPIBase:
  18508. m.ResetAPIBase()
  18509. return nil
  18510. case employee.FieldAPIKey:
  18511. m.ResetAPIKey()
  18512. return nil
  18513. case employee.FieldAiInfo:
  18514. m.ResetAiInfo()
  18515. return nil
  18516. case employee.FieldIsVip:
  18517. m.ResetIsVip()
  18518. return nil
  18519. case employee.FieldChatURL:
  18520. m.ResetChatURL()
  18521. return nil
  18522. }
  18523. return fmt.Errorf("unknown Employee field %s", name)
  18524. }
  18525. // AddedEdges returns all edge names that were set/added in this mutation.
  18526. func (m *EmployeeMutation) AddedEdges() []string {
  18527. edges := make([]string, 0, 2)
  18528. if m.em_work_experiences != nil {
  18529. edges = append(edges, employee.EdgeEmWorkExperiences)
  18530. }
  18531. if m.em_tutorial != nil {
  18532. edges = append(edges, employee.EdgeEmTutorial)
  18533. }
  18534. return edges
  18535. }
  18536. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18537. // name in this mutation.
  18538. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  18539. switch name {
  18540. case employee.EdgeEmWorkExperiences:
  18541. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  18542. for id := range m.em_work_experiences {
  18543. ids = append(ids, id)
  18544. }
  18545. return ids
  18546. case employee.EdgeEmTutorial:
  18547. ids := make([]ent.Value, 0, len(m.em_tutorial))
  18548. for id := range m.em_tutorial {
  18549. ids = append(ids, id)
  18550. }
  18551. return ids
  18552. }
  18553. return nil
  18554. }
  18555. // RemovedEdges returns all edge names that were removed in this mutation.
  18556. func (m *EmployeeMutation) RemovedEdges() []string {
  18557. edges := make([]string, 0, 2)
  18558. if m.removedem_work_experiences != nil {
  18559. edges = append(edges, employee.EdgeEmWorkExperiences)
  18560. }
  18561. if m.removedem_tutorial != nil {
  18562. edges = append(edges, employee.EdgeEmTutorial)
  18563. }
  18564. return edges
  18565. }
  18566. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18567. // the given name in this mutation.
  18568. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  18569. switch name {
  18570. case employee.EdgeEmWorkExperiences:
  18571. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  18572. for id := range m.removedem_work_experiences {
  18573. ids = append(ids, id)
  18574. }
  18575. return ids
  18576. case employee.EdgeEmTutorial:
  18577. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  18578. for id := range m.removedem_tutorial {
  18579. ids = append(ids, id)
  18580. }
  18581. return ids
  18582. }
  18583. return nil
  18584. }
  18585. // ClearedEdges returns all edge names that were cleared in this mutation.
  18586. func (m *EmployeeMutation) ClearedEdges() []string {
  18587. edges := make([]string, 0, 2)
  18588. if m.clearedem_work_experiences {
  18589. edges = append(edges, employee.EdgeEmWorkExperiences)
  18590. }
  18591. if m.clearedem_tutorial {
  18592. edges = append(edges, employee.EdgeEmTutorial)
  18593. }
  18594. return edges
  18595. }
  18596. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18597. // was cleared in this mutation.
  18598. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  18599. switch name {
  18600. case employee.EdgeEmWorkExperiences:
  18601. return m.clearedem_work_experiences
  18602. case employee.EdgeEmTutorial:
  18603. return m.clearedem_tutorial
  18604. }
  18605. return false
  18606. }
  18607. // ClearEdge clears the value of the edge with the given name. It returns an error
  18608. // if that edge is not defined in the schema.
  18609. func (m *EmployeeMutation) ClearEdge(name string) error {
  18610. switch name {
  18611. }
  18612. return fmt.Errorf("unknown Employee unique edge %s", name)
  18613. }
  18614. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18615. // It returns an error if the edge is not defined in the schema.
  18616. func (m *EmployeeMutation) ResetEdge(name string) error {
  18617. switch name {
  18618. case employee.EdgeEmWorkExperiences:
  18619. m.ResetEmWorkExperiences()
  18620. return nil
  18621. case employee.EdgeEmTutorial:
  18622. m.ResetEmTutorial()
  18623. return nil
  18624. }
  18625. return fmt.Errorf("unknown Employee edge %s", name)
  18626. }
  18627. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  18628. type EmployeeConfigMutation struct {
  18629. config
  18630. op Op
  18631. typ string
  18632. id *uint64
  18633. created_at *time.Time
  18634. updated_at *time.Time
  18635. deleted_at *time.Time
  18636. stype *string
  18637. title *string
  18638. photo *string
  18639. organization_id *uint64
  18640. addorganization_id *int64
  18641. clearedFields map[string]struct{}
  18642. done bool
  18643. oldValue func(context.Context) (*EmployeeConfig, error)
  18644. predicates []predicate.EmployeeConfig
  18645. }
  18646. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  18647. // employeeconfigOption allows management of the mutation configuration using functional options.
  18648. type employeeconfigOption func(*EmployeeConfigMutation)
  18649. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  18650. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  18651. m := &EmployeeConfigMutation{
  18652. config: c,
  18653. op: op,
  18654. typ: TypeEmployeeConfig,
  18655. clearedFields: make(map[string]struct{}),
  18656. }
  18657. for _, opt := range opts {
  18658. opt(m)
  18659. }
  18660. return m
  18661. }
  18662. // withEmployeeConfigID sets the ID field of the mutation.
  18663. func withEmployeeConfigID(id uint64) employeeconfigOption {
  18664. return func(m *EmployeeConfigMutation) {
  18665. var (
  18666. err error
  18667. once sync.Once
  18668. value *EmployeeConfig
  18669. )
  18670. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  18671. once.Do(func() {
  18672. if m.done {
  18673. err = errors.New("querying old values post mutation is not allowed")
  18674. } else {
  18675. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  18676. }
  18677. })
  18678. return value, err
  18679. }
  18680. m.id = &id
  18681. }
  18682. }
  18683. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  18684. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  18685. return func(m *EmployeeConfigMutation) {
  18686. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  18687. return node, nil
  18688. }
  18689. m.id = &node.ID
  18690. }
  18691. }
  18692. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18693. // executed in a transaction (ent.Tx), a transactional client is returned.
  18694. func (m EmployeeConfigMutation) Client() *Client {
  18695. client := &Client{config: m.config}
  18696. client.init()
  18697. return client
  18698. }
  18699. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18700. // it returns an error otherwise.
  18701. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  18702. if _, ok := m.driver.(*txDriver); !ok {
  18703. return nil, errors.New("ent: mutation is not running in a transaction")
  18704. }
  18705. tx := &Tx{config: m.config}
  18706. tx.init()
  18707. return tx, nil
  18708. }
  18709. // SetID sets the value of the id field. Note that this
  18710. // operation is only accepted on creation of EmployeeConfig entities.
  18711. func (m *EmployeeConfigMutation) SetID(id uint64) {
  18712. m.id = &id
  18713. }
  18714. // ID returns the ID value in the mutation. Note that the ID is only available
  18715. // if it was provided to the builder or after it was returned from the database.
  18716. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  18717. if m.id == nil {
  18718. return
  18719. }
  18720. return *m.id, true
  18721. }
  18722. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18723. // That means, if the mutation is applied within a transaction with an isolation level such
  18724. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18725. // or updated by the mutation.
  18726. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  18727. switch {
  18728. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18729. id, exists := m.ID()
  18730. if exists {
  18731. return []uint64{id}, nil
  18732. }
  18733. fallthrough
  18734. case m.op.Is(OpUpdate | OpDelete):
  18735. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  18736. default:
  18737. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18738. }
  18739. }
  18740. // SetCreatedAt sets the "created_at" field.
  18741. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  18742. m.created_at = &t
  18743. }
  18744. // CreatedAt returns the value of the "created_at" field in the mutation.
  18745. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  18746. v := m.created_at
  18747. if v == nil {
  18748. return
  18749. }
  18750. return *v, true
  18751. }
  18752. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  18753. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  18754. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18755. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18756. if !m.op.Is(OpUpdateOne) {
  18757. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18758. }
  18759. if m.id == nil || m.oldValue == nil {
  18760. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18761. }
  18762. oldValue, err := m.oldValue(ctx)
  18763. if err != nil {
  18764. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18765. }
  18766. return oldValue.CreatedAt, nil
  18767. }
  18768. // ResetCreatedAt resets all changes to the "created_at" field.
  18769. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  18770. m.created_at = nil
  18771. }
  18772. // SetUpdatedAt sets the "updated_at" field.
  18773. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  18774. m.updated_at = &t
  18775. }
  18776. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18777. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  18778. v := m.updated_at
  18779. if v == nil {
  18780. return
  18781. }
  18782. return *v, true
  18783. }
  18784. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  18785. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  18786. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18787. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18788. if !m.op.Is(OpUpdateOne) {
  18789. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18790. }
  18791. if m.id == nil || m.oldValue == nil {
  18792. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18793. }
  18794. oldValue, err := m.oldValue(ctx)
  18795. if err != nil {
  18796. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18797. }
  18798. return oldValue.UpdatedAt, nil
  18799. }
  18800. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18801. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  18802. m.updated_at = nil
  18803. }
  18804. // SetDeletedAt sets the "deleted_at" field.
  18805. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  18806. m.deleted_at = &t
  18807. }
  18808. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18809. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  18810. v := m.deleted_at
  18811. if v == nil {
  18812. return
  18813. }
  18814. return *v, true
  18815. }
  18816. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  18817. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  18818. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18819. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18820. if !m.op.Is(OpUpdateOne) {
  18821. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18822. }
  18823. if m.id == nil || m.oldValue == nil {
  18824. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18825. }
  18826. oldValue, err := m.oldValue(ctx)
  18827. if err != nil {
  18828. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18829. }
  18830. return oldValue.DeletedAt, nil
  18831. }
  18832. // ClearDeletedAt clears the value of the "deleted_at" field.
  18833. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  18834. m.deleted_at = nil
  18835. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  18836. }
  18837. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18838. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  18839. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  18840. return ok
  18841. }
  18842. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18843. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  18844. m.deleted_at = nil
  18845. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  18846. }
  18847. // SetStype sets the "stype" field.
  18848. func (m *EmployeeConfigMutation) SetStype(s string) {
  18849. m.stype = &s
  18850. }
  18851. // Stype returns the value of the "stype" field in the mutation.
  18852. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  18853. v := m.stype
  18854. if v == nil {
  18855. return
  18856. }
  18857. return *v, true
  18858. }
  18859. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  18860. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  18861. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18862. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  18863. if !m.op.Is(OpUpdateOne) {
  18864. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  18865. }
  18866. if m.id == nil || m.oldValue == nil {
  18867. return v, errors.New("OldStype requires an ID field in the mutation")
  18868. }
  18869. oldValue, err := m.oldValue(ctx)
  18870. if err != nil {
  18871. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  18872. }
  18873. return oldValue.Stype, nil
  18874. }
  18875. // ResetStype resets all changes to the "stype" field.
  18876. func (m *EmployeeConfigMutation) ResetStype() {
  18877. m.stype = nil
  18878. }
  18879. // SetTitle sets the "title" field.
  18880. func (m *EmployeeConfigMutation) SetTitle(s string) {
  18881. m.title = &s
  18882. }
  18883. // Title returns the value of the "title" field in the mutation.
  18884. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  18885. v := m.title
  18886. if v == nil {
  18887. return
  18888. }
  18889. return *v, true
  18890. }
  18891. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  18892. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  18893. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18894. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  18895. if !m.op.Is(OpUpdateOne) {
  18896. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  18897. }
  18898. if m.id == nil || m.oldValue == nil {
  18899. return v, errors.New("OldTitle requires an ID field in the mutation")
  18900. }
  18901. oldValue, err := m.oldValue(ctx)
  18902. if err != nil {
  18903. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  18904. }
  18905. return oldValue.Title, nil
  18906. }
  18907. // ResetTitle resets all changes to the "title" field.
  18908. func (m *EmployeeConfigMutation) ResetTitle() {
  18909. m.title = nil
  18910. }
  18911. // SetPhoto sets the "photo" field.
  18912. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  18913. m.photo = &s
  18914. }
  18915. // Photo returns the value of the "photo" field in the mutation.
  18916. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  18917. v := m.photo
  18918. if v == nil {
  18919. return
  18920. }
  18921. return *v, true
  18922. }
  18923. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  18924. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  18925. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18926. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  18927. if !m.op.Is(OpUpdateOne) {
  18928. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  18929. }
  18930. if m.id == nil || m.oldValue == nil {
  18931. return v, errors.New("OldPhoto requires an ID field in the mutation")
  18932. }
  18933. oldValue, err := m.oldValue(ctx)
  18934. if err != nil {
  18935. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  18936. }
  18937. return oldValue.Photo, nil
  18938. }
  18939. // ResetPhoto resets all changes to the "photo" field.
  18940. func (m *EmployeeConfigMutation) ResetPhoto() {
  18941. m.photo = nil
  18942. }
  18943. // SetOrganizationID sets the "organization_id" field.
  18944. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  18945. m.organization_id = &u
  18946. m.addorganization_id = nil
  18947. }
  18948. // OrganizationID returns the value of the "organization_id" field in the mutation.
  18949. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  18950. v := m.organization_id
  18951. if v == nil {
  18952. return
  18953. }
  18954. return *v, true
  18955. }
  18956. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  18957. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  18958. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18959. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  18960. if !m.op.Is(OpUpdateOne) {
  18961. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  18962. }
  18963. if m.id == nil || m.oldValue == nil {
  18964. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  18965. }
  18966. oldValue, err := m.oldValue(ctx)
  18967. if err != nil {
  18968. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  18969. }
  18970. return oldValue.OrganizationID, nil
  18971. }
  18972. // AddOrganizationID adds u to the "organization_id" field.
  18973. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  18974. if m.addorganization_id != nil {
  18975. *m.addorganization_id += u
  18976. } else {
  18977. m.addorganization_id = &u
  18978. }
  18979. }
  18980. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  18981. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  18982. v := m.addorganization_id
  18983. if v == nil {
  18984. return
  18985. }
  18986. return *v, true
  18987. }
  18988. // ClearOrganizationID clears the value of the "organization_id" field.
  18989. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  18990. m.organization_id = nil
  18991. m.addorganization_id = nil
  18992. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  18993. }
  18994. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  18995. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  18996. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  18997. return ok
  18998. }
  18999. // ResetOrganizationID resets all changes to the "organization_id" field.
  19000. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  19001. m.organization_id = nil
  19002. m.addorganization_id = nil
  19003. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  19004. }
  19005. // Where appends a list predicates to the EmployeeConfigMutation builder.
  19006. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  19007. m.predicates = append(m.predicates, ps...)
  19008. }
  19009. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  19010. // users can use type-assertion to append predicates that do not depend on any generated package.
  19011. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  19012. p := make([]predicate.EmployeeConfig, len(ps))
  19013. for i := range ps {
  19014. p[i] = ps[i]
  19015. }
  19016. m.Where(p...)
  19017. }
  19018. // Op returns the operation name.
  19019. func (m *EmployeeConfigMutation) Op() Op {
  19020. return m.op
  19021. }
  19022. // SetOp allows setting the mutation operation.
  19023. func (m *EmployeeConfigMutation) SetOp(op Op) {
  19024. m.op = op
  19025. }
  19026. // Type returns the node type of this mutation (EmployeeConfig).
  19027. func (m *EmployeeConfigMutation) Type() string {
  19028. return m.typ
  19029. }
  19030. // Fields returns all fields that were changed during this mutation. Note that in
  19031. // order to get all numeric fields that were incremented/decremented, call
  19032. // AddedFields().
  19033. func (m *EmployeeConfigMutation) Fields() []string {
  19034. fields := make([]string, 0, 7)
  19035. if m.created_at != nil {
  19036. fields = append(fields, employeeconfig.FieldCreatedAt)
  19037. }
  19038. if m.updated_at != nil {
  19039. fields = append(fields, employeeconfig.FieldUpdatedAt)
  19040. }
  19041. if m.deleted_at != nil {
  19042. fields = append(fields, employeeconfig.FieldDeletedAt)
  19043. }
  19044. if m.stype != nil {
  19045. fields = append(fields, employeeconfig.FieldStype)
  19046. }
  19047. if m.title != nil {
  19048. fields = append(fields, employeeconfig.FieldTitle)
  19049. }
  19050. if m.photo != nil {
  19051. fields = append(fields, employeeconfig.FieldPhoto)
  19052. }
  19053. if m.organization_id != nil {
  19054. fields = append(fields, employeeconfig.FieldOrganizationID)
  19055. }
  19056. return fields
  19057. }
  19058. // Field returns the value of a field with the given name. The second boolean
  19059. // return value indicates that this field was not set, or was not defined in the
  19060. // schema.
  19061. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  19062. switch name {
  19063. case employeeconfig.FieldCreatedAt:
  19064. return m.CreatedAt()
  19065. case employeeconfig.FieldUpdatedAt:
  19066. return m.UpdatedAt()
  19067. case employeeconfig.FieldDeletedAt:
  19068. return m.DeletedAt()
  19069. case employeeconfig.FieldStype:
  19070. return m.Stype()
  19071. case employeeconfig.FieldTitle:
  19072. return m.Title()
  19073. case employeeconfig.FieldPhoto:
  19074. return m.Photo()
  19075. case employeeconfig.FieldOrganizationID:
  19076. return m.OrganizationID()
  19077. }
  19078. return nil, false
  19079. }
  19080. // OldField returns the old value of the field from the database. An error is
  19081. // returned if the mutation operation is not UpdateOne, or the query to the
  19082. // database failed.
  19083. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19084. switch name {
  19085. case employeeconfig.FieldCreatedAt:
  19086. return m.OldCreatedAt(ctx)
  19087. case employeeconfig.FieldUpdatedAt:
  19088. return m.OldUpdatedAt(ctx)
  19089. case employeeconfig.FieldDeletedAt:
  19090. return m.OldDeletedAt(ctx)
  19091. case employeeconfig.FieldStype:
  19092. return m.OldStype(ctx)
  19093. case employeeconfig.FieldTitle:
  19094. return m.OldTitle(ctx)
  19095. case employeeconfig.FieldPhoto:
  19096. return m.OldPhoto(ctx)
  19097. case employeeconfig.FieldOrganizationID:
  19098. return m.OldOrganizationID(ctx)
  19099. }
  19100. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  19101. }
  19102. // SetField sets the value of a field with the given name. It returns an error if
  19103. // the field is not defined in the schema, or if the type mismatched the field
  19104. // type.
  19105. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  19106. switch name {
  19107. case employeeconfig.FieldCreatedAt:
  19108. v, ok := value.(time.Time)
  19109. if !ok {
  19110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19111. }
  19112. m.SetCreatedAt(v)
  19113. return nil
  19114. case employeeconfig.FieldUpdatedAt:
  19115. v, ok := value.(time.Time)
  19116. if !ok {
  19117. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19118. }
  19119. m.SetUpdatedAt(v)
  19120. return nil
  19121. case employeeconfig.FieldDeletedAt:
  19122. v, ok := value.(time.Time)
  19123. if !ok {
  19124. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19125. }
  19126. m.SetDeletedAt(v)
  19127. return nil
  19128. case employeeconfig.FieldStype:
  19129. v, ok := value.(string)
  19130. if !ok {
  19131. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19132. }
  19133. m.SetStype(v)
  19134. return nil
  19135. case employeeconfig.FieldTitle:
  19136. v, ok := value.(string)
  19137. if !ok {
  19138. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19139. }
  19140. m.SetTitle(v)
  19141. return nil
  19142. case employeeconfig.FieldPhoto:
  19143. v, ok := value.(string)
  19144. if !ok {
  19145. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19146. }
  19147. m.SetPhoto(v)
  19148. return nil
  19149. case employeeconfig.FieldOrganizationID:
  19150. v, ok := value.(uint64)
  19151. if !ok {
  19152. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19153. }
  19154. m.SetOrganizationID(v)
  19155. return nil
  19156. }
  19157. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  19158. }
  19159. // AddedFields returns all numeric fields that were incremented/decremented during
  19160. // this mutation.
  19161. func (m *EmployeeConfigMutation) AddedFields() []string {
  19162. var fields []string
  19163. if m.addorganization_id != nil {
  19164. fields = append(fields, employeeconfig.FieldOrganizationID)
  19165. }
  19166. return fields
  19167. }
  19168. // AddedField returns the numeric value that was incremented/decremented on a field
  19169. // with the given name. The second boolean return value indicates that this field
  19170. // was not set, or was not defined in the schema.
  19171. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  19172. switch name {
  19173. case employeeconfig.FieldOrganizationID:
  19174. return m.AddedOrganizationID()
  19175. }
  19176. return nil, false
  19177. }
  19178. // AddField adds the value to the field with the given name. It returns an error if
  19179. // the field is not defined in the schema, or if the type mismatched the field
  19180. // type.
  19181. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  19182. switch name {
  19183. case employeeconfig.FieldOrganizationID:
  19184. v, ok := value.(int64)
  19185. if !ok {
  19186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19187. }
  19188. m.AddOrganizationID(v)
  19189. return nil
  19190. }
  19191. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  19192. }
  19193. // ClearedFields returns all nullable fields that were cleared during this
  19194. // mutation.
  19195. func (m *EmployeeConfigMutation) ClearedFields() []string {
  19196. var fields []string
  19197. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  19198. fields = append(fields, employeeconfig.FieldDeletedAt)
  19199. }
  19200. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  19201. fields = append(fields, employeeconfig.FieldOrganizationID)
  19202. }
  19203. return fields
  19204. }
  19205. // FieldCleared returns a boolean indicating if a field with the given name was
  19206. // cleared in this mutation.
  19207. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  19208. _, ok := m.clearedFields[name]
  19209. return ok
  19210. }
  19211. // ClearField clears the value of the field with the given name. It returns an
  19212. // error if the field is not defined in the schema.
  19213. func (m *EmployeeConfigMutation) ClearField(name string) error {
  19214. switch name {
  19215. case employeeconfig.FieldDeletedAt:
  19216. m.ClearDeletedAt()
  19217. return nil
  19218. case employeeconfig.FieldOrganizationID:
  19219. m.ClearOrganizationID()
  19220. return nil
  19221. }
  19222. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  19223. }
  19224. // ResetField resets all changes in the mutation for the field with the given name.
  19225. // It returns an error if the field is not defined in the schema.
  19226. func (m *EmployeeConfigMutation) ResetField(name string) error {
  19227. switch name {
  19228. case employeeconfig.FieldCreatedAt:
  19229. m.ResetCreatedAt()
  19230. return nil
  19231. case employeeconfig.FieldUpdatedAt:
  19232. m.ResetUpdatedAt()
  19233. return nil
  19234. case employeeconfig.FieldDeletedAt:
  19235. m.ResetDeletedAt()
  19236. return nil
  19237. case employeeconfig.FieldStype:
  19238. m.ResetStype()
  19239. return nil
  19240. case employeeconfig.FieldTitle:
  19241. m.ResetTitle()
  19242. return nil
  19243. case employeeconfig.FieldPhoto:
  19244. m.ResetPhoto()
  19245. return nil
  19246. case employeeconfig.FieldOrganizationID:
  19247. m.ResetOrganizationID()
  19248. return nil
  19249. }
  19250. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  19251. }
  19252. // AddedEdges returns all edge names that were set/added in this mutation.
  19253. func (m *EmployeeConfigMutation) AddedEdges() []string {
  19254. edges := make([]string, 0, 0)
  19255. return edges
  19256. }
  19257. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19258. // name in this mutation.
  19259. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  19260. return nil
  19261. }
  19262. // RemovedEdges returns all edge names that were removed in this mutation.
  19263. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  19264. edges := make([]string, 0, 0)
  19265. return edges
  19266. }
  19267. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19268. // the given name in this mutation.
  19269. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  19270. return nil
  19271. }
  19272. // ClearedEdges returns all edge names that were cleared in this mutation.
  19273. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  19274. edges := make([]string, 0, 0)
  19275. return edges
  19276. }
  19277. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19278. // was cleared in this mutation.
  19279. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  19280. return false
  19281. }
  19282. // ClearEdge clears the value of the edge with the given name. It returns an error
  19283. // if that edge is not defined in the schema.
  19284. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  19285. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  19286. }
  19287. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19288. // It returns an error if the edge is not defined in the schema.
  19289. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  19290. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  19291. }
  19292. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  19293. type LabelMutation struct {
  19294. config
  19295. op Op
  19296. typ string
  19297. id *uint64
  19298. created_at *time.Time
  19299. updated_at *time.Time
  19300. status *uint8
  19301. addstatus *int8
  19302. deleted_at *time.Time
  19303. _type *int
  19304. add_type *int
  19305. name *string
  19306. from *int
  19307. addfrom *int
  19308. mode *int
  19309. addmode *int
  19310. conditions *string
  19311. organization_id *uint64
  19312. addorganization_id *int64
  19313. clearedFields map[string]struct{}
  19314. label_relationships map[uint64]struct{}
  19315. removedlabel_relationships map[uint64]struct{}
  19316. clearedlabel_relationships bool
  19317. done bool
  19318. oldValue func(context.Context) (*Label, error)
  19319. predicates []predicate.Label
  19320. }
  19321. var _ ent.Mutation = (*LabelMutation)(nil)
  19322. // labelOption allows management of the mutation configuration using functional options.
  19323. type labelOption func(*LabelMutation)
  19324. // newLabelMutation creates new mutation for the Label entity.
  19325. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  19326. m := &LabelMutation{
  19327. config: c,
  19328. op: op,
  19329. typ: TypeLabel,
  19330. clearedFields: make(map[string]struct{}),
  19331. }
  19332. for _, opt := range opts {
  19333. opt(m)
  19334. }
  19335. return m
  19336. }
  19337. // withLabelID sets the ID field of the mutation.
  19338. func withLabelID(id uint64) labelOption {
  19339. return func(m *LabelMutation) {
  19340. var (
  19341. err error
  19342. once sync.Once
  19343. value *Label
  19344. )
  19345. m.oldValue = func(ctx context.Context) (*Label, error) {
  19346. once.Do(func() {
  19347. if m.done {
  19348. err = errors.New("querying old values post mutation is not allowed")
  19349. } else {
  19350. value, err = m.Client().Label.Get(ctx, id)
  19351. }
  19352. })
  19353. return value, err
  19354. }
  19355. m.id = &id
  19356. }
  19357. }
  19358. // withLabel sets the old Label of the mutation.
  19359. func withLabel(node *Label) labelOption {
  19360. return func(m *LabelMutation) {
  19361. m.oldValue = func(context.Context) (*Label, error) {
  19362. return node, nil
  19363. }
  19364. m.id = &node.ID
  19365. }
  19366. }
  19367. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19368. // executed in a transaction (ent.Tx), a transactional client is returned.
  19369. func (m LabelMutation) Client() *Client {
  19370. client := &Client{config: m.config}
  19371. client.init()
  19372. return client
  19373. }
  19374. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19375. // it returns an error otherwise.
  19376. func (m LabelMutation) Tx() (*Tx, error) {
  19377. if _, ok := m.driver.(*txDriver); !ok {
  19378. return nil, errors.New("ent: mutation is not running in a transaction")
  19379. }
  19380. tx := &Tx{config: m.config}
  19381. tx.init()
  19382. return tx, nil
  19383. }
  19384. // SetID sets the value of the id field. Note that this
  19385. // operation is only accepted on creation of Label entities.
  19386. func (m *LabelMutation) SetID(id uint64) {
  19387. m.id = &id
  19388. }
  19389. // ID returns the ID value in the mutation. Note that the ID is only available
  19390. // if it was provided to the builder or after it was returned from the database.
  19391. func (m *LabelMutation) ID() (id uint64, exists bool) {
  19392. if m.id == nil {
  19393. return
  19394. }
  19395. return *m.id, true
  19396. }
  19397. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19398. // That means, if the mutation is applied within a transaction with an isolation level such
  19399. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19400. // or updated by the mutation.
  19401. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  19402. switch {
  19403. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19404. id, exists := m.ID()
  19405. if exists {
  19406. return []uint64{id}, nil
  19407. }
  19408. fallthrough
  19409. case m.op.Is(OpUpdate | OpDelete):
  19410. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  19411. default:
  19412. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19413. }
  19414. }
  19415. // SetCreatedAt sets the "created_at" field.
  19416. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  19417. m.created_at = &t
  19418. }
  19419. // CreatedAt returns the value of the "created_at" field in the mutation.
  19420. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  19421. v := m.created_at
  19422. if v == nil {
  19423. return
  19424. }
  19425. return *v, true
  19426. }
  19427. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  19428. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19429. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19430. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19431. if !m.op.Is(OpUpdateOne) {
  19432. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19433. }
  19434. if m.id == nil || m.oldValue == nil {
  19435. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19436. }
  19437. oldValue, err := m.oldValue(ctx)
  19438. if err != nil {
  19439. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19440. }
  19441. return oldValue.CreatedAt, nil
  19442. }
  19443. // ResetCreatedAt resets all changes to the "created_at" field.
  19444. func (m *LabelMutation) ResetCreatedAt() {
  19445. m.created_at = nil
  19446. }
  19447. // SetUpdatedAt sets the "updated_at" field.
  19448. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  19449. m.updated_at = &t
  19450. }
  19451. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19452. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  19453. v := m.updated_at
  19454. if v == nil {
  19455. return
  19456. }
  19457. return *v, true
  19458. }
  19459. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  19460. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19461. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19462. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19463. if !m.op.Is(OpUpdateOne) {
  19464. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19465. }
  19466. if m.id == nil || m.oldValue == nil {
  19467. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19468. }
  19469. oldValue, err := m.oldValue(ctx)
  19470. if err != nil {
  19471. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19472. }
  19473. return oldValue.UpdatedAt, nil
  19474. }
  19475. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19476. func (m *LabelMutation) ResetUpdatedAt() {
  19477. m.updated_at = nil
  19478. }
  19479. // SetStatus sets the "status" field.
  19480. func (m *LabelMutation) SetStatus(u uint8) {
  19481. m.status = &u
  19482. m.addstatus = nil
  19483. }
  19484. // Status returns the value of the "status" field in the mutation.
  19485. func (m *LabelMutation) Status() (r uint8, exists bool) {
  19486. v := m.status
  19487. if v == nil {
  19488. return
  19489. }
  19490. return *v, true
  19491. }
  19492. // OldStatus returns the old "status" field's value of the Label entity.
  19493. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19494. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19495. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  19496. if !m.op.Is(OpUpdateOne) {
  19497. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19498. }
  19499. if m.id == nil || m.oldValue == nil {
  19500. return v, errors.New("OldStatus requires an ID field in the mutation")
  19501. }
  19502. oldValue, err := m.oldValue(ctx)
  19503. if err != nil {
  19504. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19505. }
  19506. return oldValue.Status, nil
  19507. }
  19508. // AddStatus adds u to the "status" field.
  19509. func (m *LabelMutation) AddStatus(u int8) {
  19510. if m.addstatus != nil {
  19511. *m.addstatus += u
  19512. } else {
  19513. m.addstatus = &u
  19514. }
  19515. }
  19516. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19517. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  19518. v := m.addstatus
  19519. if v == nil {
  19520. return
  19521. }
  19522. return *v, true
  19523. }
  19524. // ClearStatus clears the value of the "status" field.
  19525. func (m *LabelMutation) ClearStatus() {
  19526. m.status = nil
  19527. m.addstatus = nil
  19528. m.clearedFields[label.FieldStatus] = struct{}{}
  19529. }
  19530. // StatusCleared returns if the "status" field was cleared in this mutation.
  19531. func (m *LabelMutation) StatusCleared() bool {
  19532. _, ok := m.clearedFields[label.FieldStatus]
  19533. return ok
  19534. }
  19535. // ResetStatus resets all changes to the "status" field.
  19536. func (m *LabelMutation) ResetStatus() {
  19537. m.status = nil
  19538. m.addstatus = nil
  19539. delete(m.clearedFields, label.FieldStatus)
  19540. }
  19541. // SetDeletedAt sets the "deleted_at" field.
  19542. func (m *LabelMutation) SetDeletedAt(t time.Time) {
  19543. m.deleted_at = &t
  19544. }
  19545. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19546. func (m *LabelMutation) DeletedAt() (r time.Time, exists bool) {
  19547. v := m.deleted_at
  19548. if v == nil {
  19549. return
  19550. }
  19551. return *v, true
  19552. }
  19553. // OldDeletedAt returns the old "deleted_at" field's value of the Label entity.
  19554. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19555. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19556. func (m *LabelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19557. if !m.op.Is(OpUpdateOne) {
  19558. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19559. }
  19560. if m.id == nil || m.oldValue == nil {
  19561. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19562. }
  19563. oldValue, err := m.oldValue(ctx)
  19564. if err != nil {
  19565. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19566. }
  19567. return oldValue.DeletedAt, nil
  19568. }
  19569. // ClearDeletedAt clears the value of the "deleted_at" field.
  19570. func (m *LabelMutation) ClearDeletedAt() {
  19571. m.deleted_at = nil
  19572. m.clearedFields[label.FieldDeletedAt] = struct{}{}
  19573. }
  19574. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19575. func (m *LabelMutation) DeletedAtCleared() bool {
  19576. _, ok := m.clearedFields[label.FieldDeletedAt]
  19577. return ok
  19578. }
  19579. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19580. func (m *LabelMutation) ResetDeletedAt() {
  19581. m.deleted_at = nil
  19582. delete(m.clearedFields, label.FieldDeletedAt)
  19583. }
  19584. // SetType sets the "type" field.
  19585. func (m *LabelMutation) SetType(i int) {
  19586. m._type = &i
  19587. m.add_type = nil
  19588. }
  19589. // GetType returns the value of the "type" field in the mutation.
  19590. func (m *LabelMutation) GetType() (r int, exists bool) {
  19591. v := m._type
  19592. if v == nil {
  19593. return
  19594. }
  19595. return *v, true
  19596. }
  19597. // OldType returns the old "type" field's value of the Label entity.
  19598. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19600. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  19601. if !m.op.Is(OpUpdateOne) {
  19602. return v, errors.New("OldType is only allowed on UpdateOne operations")
  19603. }
  19604. if m.id == nil || m.oldValue == nil {
  19605. return v, errors.New("OldType requires an ID field in the mutation")
  19606. }
  19607. oldValue, err := m.oldValue(ctx)
  19608. if err != nil {
  19609. return v, fmt.Errorf("querying old value for OldType: %w", err)
  19610. }
  19611. return oldValue.Type, nil
  19612. }
  19613. // AddType adds i to the "type" field.
  19614. func (m *LabelMutation) AddType(i int) {
  19615. if m.add_type != nil {
  19616. *m.add_type += i
  19617. } else {
  19618. m.add_type = &i
  19619. }
  19620. }
  19621. // AddedType returns the value that was added to the "type" field in this mutation.
  19622. func (m *LabelMutation) AddedType() (r int, exists bool) {
  19623. v := m.add_type
  19624. if v == nil {
  19625. return
  19626. }
  19627. return *v, true
  19628. }
  19629. // ResetType resets all changes to the "type" field.
  19630. func (m *LabelMutation) ResetType() {
  19631. m._type = nil
  19632. m.add_type = nil
  19633. }
  19634. // SetName sets the "name" field.
  19635. func (m *LabelMutation) SetName(s string) {
  19636. m.name = &s
  19637. }
  19638. // Name returns the value of the "name" field in the mutation.
  19639. func (m *LabelMutation) Name() (r string, exists bool) {
  19640. v := m.name
  19641. if v == nil {
  19642. return
  19643. }
  19644. return *v, true
  19645. }
  19646. // OldName returns the old "name" field's value of the Label entity.
  19647. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19648. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19649. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  19650. if !m.op.Is(OpUpdateOne) {
  19651. return v, errors.New("OldName is only allowed on UpdateOne operations")
  19652. }
  19653. if m.id == nil || m.oldValue == nil {
  19654. return v, errors.New("OldName requires an ID field in the mutation")
  19655. }
  19656. oldValue, err := m.oldValue(ctx)
  19657. if err != nil {
  19658. return v, fmt.Errorf("querying old value for OldName: %w", err)
  19659. }
  19660. return oldValue.Name, nil
  19661. }
  19662. // ResetName resets all changes to the "name" field.
  19663. func (m *LabelMutation) ResetName() {
  19664. m.name = nil
  19665. }
  19666. // SetFrom sets the "from" field.
  19667. func (m *LabelMutation) SetFrom(i int) {
  19668. m.from = &i
  19669. m.addfrom = nil
  19670. }
  19671. // From returns the value of the "from" field in the mutation.
  19672. func (m *LabelMutation) From() (r int, exists bool) {
  19673. v := m.from
  19674. if v == nil {
  19675. return
  19676. }
  19677. return *v, true
  19678. }
  19679. // OldFrom returns the old "from" field's value of the Label entity.
  19680. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19681. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19682. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  19683. if !m.op.Is(OpUpdateOne) {
  19684. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  19685. }
  19686. if m.id == nil || m.oldValue == nil {
  19687. return v, errors.New("OldFrom requires an ID field in the mutation")
  19688. }
  19689. oldValue, err := m.oldValue(ctx)
  19690. if err != nil {
  19691. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  19692. }
  19693. return oldValue.From, nil
  19694. }
  19695. // AddFrom adds i to the "from" field.
  19696. func (m *LabelMutation) AddFrom(i int) {
  19697. if m.addfrom != nil {
  19698. *m.addfrom += i
  19699. } else {
  19700. m.addfrom = &i
  19701. }
  19702. }
  19703. // AddedFrom returns the value that was added to the "from" field in this mutation.
  19704. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  19705. v := m.addfrom
  19706. if v == nil {
  19707. return
  19708. }
  19709. return *v, true
  19710. }
  19711. // ResetFrom resets all changes to the "from" field.
  19712. func (m *LabelMutation) ResetFrom() {
  19713. m.from = nil
  19714. m.addfrom = nil
  19715. }
  19716. // SetMode sets the "mode" field.
  19717. func (m *LabelMutation) SetMode(i int) {
  19718. m.mode = &i
  19719. m.addmode = nil
  19720. }
  19721. // Mode returns the value of the "mode" field in the mutation.
  19722. func (m *LabelMutation) Mode() (r int, exists bool) {
  19723. v := m.mode
  19724. if v == nil {
  19725. return
  19726. }
  19727. return *v, true
  19728. }
  19729. // OldMode returns the old "mode" field's value of the Label entity.
  19730. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19731. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19732. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  19733. if !m.op.Is(OpUpdateOne) {
  19734. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  19735. }
  19736. if m.id == nil || m.oldValue == nil {
  19737. return v, errors.New("OldMode requires an ID field in the mutation")
  19738. }
  19739. oldValue, err := m.oldValue(ctx)
  19740. if err != nil {
  19741. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  19742. }
  19743. return oldValue.Mode, nil
  19744. }
  19745. // AddMode adds i to the "mode" field.
  19746. func (m *LabelMutation) AddMode(i int) {
  19747. if m.addmode != nil {
  19748. *m.addmode += i
  19749. } else {
  19750. m.addmode = &i
  19751. }
  19752. }
  19753. // AddedMode returns the value that was added to the "mode" field in this mutation.
  19754. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  19755. v := m.addmode
  19756. if v == nil {
  19757. return
  19758. }
  19759. return *v, true
  19760. }
  19761. // ResetMode resets all changes to the "mode" field.
  19762. func (m *LabelMutation) ResetMode() {
  19763. m.mode = nil
  19764. m.addmode = nil
  19765. }
  19766. // SetConditions sets the "conditions" field.
  19767. func (m *LabelMutation) SetConditions(s string) {
  19768. m.conditions = &s
  19769. }
  19770. // Conditions returns the value of the "conditions" field in the mutation.
  19771. func (m *LabelMutation) Conditions() (r string, exists bool) {
  19772. v := m.conditions
  19773. if v == nil {
  19774. return
  19775. }
  19776. return *v, true
  19777. }
  19778. // OldConditions returns the old "conditions" field's value of the Label entity.
  19779. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19781. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  19782. if !m.op.Is(OpUpdateOne) {
  19783. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  19784. }
  19785. if m.id == nil || m.oldValue == nil {
  19786. return v, errors.New("OldConditions requires an ID field in the mutation")
  19787. }
  19788. oldValue, err := m.oldValue(ctx)
  19789. if err != nil {
  19790. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  19791. }
  19792. return oldValue.Conditions, nil
  19793. }
  19794. // ClearConditions clears the value of the "conditions" field.
  19795. func (m *LabelMutation) ClearConditions() {
  19796. m.conditions = nil
  19797. m.clearedFields[label.FieldConditions] = struct{}{}
  19798. }
  19799. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  19800. func (m *LabelMutation) ConditionsCleared() bool {
  19801. _, ok := m.clearedFields[label.FieldConditions]
  19802. return ok
  19803. }
  19804. // ResetConditions resets all changes to the "conditions" field.
  19805. func (m *LabelMutation) ResetConditions() {
  19806. m.conditions = nil
  19807. delete(m.clearedFields, label.FieldConditions)
  19808. }
  19809. // SetOrganizationID sets the "organization_id" field.
  19810. func (m *LabelMutation) SetOrganizationID(u uint64) {
  19811. m.organization_id = &u
  19812. m.addorganization_id = nil
  19813. }
  19814. // OrganizationID returns the value of the "organization_id" field in the mutation.
  19815. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  19816. v := m.organization_id
  19817. if v == nil {
  19818. return
  19819. }
  19820. return *v, true
  19821. }
  19822. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  19823. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19824. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19825. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  19826. if !m.op.Is(OpUpdateOne) {
  19827. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  19828. }
  19829. if m.id == nil || m.oldValue == nil {
  19830. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  19831. }
  19832. oldValue, err := m.oldValue(ctx)
  19833. if err != nil {
  19834. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  19835. }
  19836. return oldValue.OrganizationID, nil
  19837. }
  19838. // AddOrganizationID adds u to the "organization_id" field.
  19839. func (m *LabelMutation) AddOrganizationID(u int64) {
  19840. if m.addorganization_id != nil {
  19841. *m.addorganization_id += u
  19842. } else {
  19843. m.addorganization_id = &u
  19844. }
  19845. }
  19846. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  19847. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  19848. v := m.addorganization_id
  19849. if v == nil {
  19850. return
  19851. }
  19852. return *v, true
  19853. }
  19854. // ClearOrganizationID clears the value of the "organization_id" field.
  19855. func (m *LabelMutation) ClearOrganizationID() {
  19856. m.organization_id = nil
  19857. m.addorganization_id = nil
  19858. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  19859. }
  19860. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  19861. func (m *LabelMutation) OrganizationIDCleared() bool {
  19862. _, ok := m.clearedFields[label.FieldOrganizationID]
  19863. return ok
  19864. }
  19865. // ResetOrganizationID resets all changes to the "organization_id" field.
  19866. func (m *LabelMutation) ResetOrganizationID() {
  19867. m.organization_id = nil
  19868. m.addorganization_id = nil
  19869. delete(m.clearedFields, label.FieldOrganizationID)
  19870. }
  19871. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  19872. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  19873. if m.label_relationships == nil {
  19874. m.label_relationships = make(map[uint64]struct{})
  19875. }
  19876. for i := range ids {
  19877. m.label_relationships[ids[i]] = struct{}{}
  19878. }
  19879. }
  19880. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  19881. func (m *LabelMutation) ClearLabelRelationships() {
  19882. m.clearedlabel_relationships = true
  19883. }
  19884. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  19885. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  19886. return m.clearedlabel_relationships
  19887. }
  19888. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  19889. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  19890. if m.removedlabel_relationships == nil {
  19891. m.removedlabel_relationships = make(map[uint64]struct{})
  19892. }
  19893. for i := range ids {
  19894. delete(m.label_relationships, ids[i])
  19895. m.removedlabel_relationships[ids[i]] = struct{}{}
  19896. }
  19897. }
  19898. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  19899. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  19900. for id := range m.removedlabel_relationships {
  19901. ids = append(ids, id)
  19902. }
  19903. return
  19904. }
  19905. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  19906. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  19907. for id := range m.label_relationships {
  19908. ids = append(ids, id)
  19909. }
  19910. return
  19911. }
  19912. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  19913. func (m *LabelMutation) ResetLabelRelationships() {
  19914. m.label_relationships = nil
  19915. m.clearedlabel_relationships = false
  19916. m.removedlabel_relationships = nil
  19917. }
  19918. // Where appends a list predicates to the LabelMutation builder.
  19919. func (m *LabelMutation) Where(ps ...predicate.Label) {
  19920. m.predicates = append(m.predicates, ps...)
  19921. }
  19922. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  19923. // users can use type-assertion to append predicates that do not depend on any generated package.
  19924. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  19925. p := make([]predicate.Label, len(ps))
  19926. for i := range ps {
  19927. p[i] = ps[i]
  19928. }
  19929. m.Where(p...)
  19930. }
  19931. // Op returns the operation name.
  19932. func (m *LabelMutation) Op() Op {
  19933. return m.op
  19934. }
  19935. // SetOp allows setting the mutation operation.
  19936. func (m *LabelMutation) SetOp(op Op) {
  19937. m.op = op
  19938. }
  19939. // Type returns the node type of this mutation (Label).
  19940. func (m *LabelMutation) Type() string {
  19941. return m.typ
  19942. }
  19943. // Fields returns all fields that were changed during this mutation. Note that in
  19944. // order to get all numeric fields that were incremented/decremented, call
  19945. // AddedFields().
  19946. func (m *LabelMutation) Fields() []string {
  19947. fields := make([]string, 0, 10)
  19948. if m.created_at != nil {
  19949. fields = append(fields, label.FieldCreatedAt)
  19950. }
  19951. if m.updated_at != nil {
  19952. fields = append(fields, label.FieldUpdatedAt)
  19953. }
  19954. if m.status != nil {
  19955. fields = append(fields, label.FieldStatus)
  19956. }
  19957. if m.deleted_at != nil {
  19958. fields = append(fields, label.FieldDeletedAt)
  19959. }
  19960. if m._type != nil {
  19961. fields = append(fields, label.FieldType)
  19962. }
  19963. if m.name != nil {
  19964. fields = append(fields, label.FieldName)
  19965. }
  19966. if m.from != nil {
  19967. fields = append(fields, label.FieldFrom)
  19968. }
  19969. if m.mode != nil {
  19970. fields = append(fields, label.FieldMode)
  19971. }
  19972. if m.conditions != nil {
  19973. fields = append(fields, label.FieldConditions)
  19974. }
  19975. if m.organization_id != nil {
  19976. fields = append(fields, label.FieldOrganizationID)
  19977. }
  19978. return fields
  19979. }
  19980. // Field returns the value of a field with the given name. The second boolean
  19981. // return value indicates that this field was not set, or was not defined in the
  19982. // schema.
  19983. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  19984. switch name {
  19985. case label.FieldCreatedAt:
  19986. return m.CreatedAt()
  19987. case label.FieldUpdatedAt:
  19988. return m.UpdatedAt()
  19989. case label.FieldStatus:
  19990. return m.Status()
  19991. case label.FieldDeletedAt:
  19992. return m.DeletedAt()
  19993. case label.FieldType:
  19994. return m.GetType()
  19995. case label.FieldName:
  19996. return m.Name()
  19997. case label.FieldFrom:
  19998. return m.From()
  19999. case label.FieldMode:
  20000. return m.Mode()
  20001. case label.FieldConditions:
  20002. return m.Conditions()
  20003. case label.FieldOrganizationID:
  20004. return m.OrganizationID()
  20005. }
  20006. return nil, false
  20007. }
  20008. // OldField returns the old value of the field from the database. An error is
  20009. // returned if the mutation operation is not UpdateOne, or the query to the
  20010. // database failed.
  20011. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20012. switch name {
  20013. case label.FieldCreatedAt:
  20014. return m.OldCreatedAt(ctx)
  20015. case label.FieldUpdatedAt:
  20016. return m.OldUpdatedAt(ctx)
  20017. case label.FieldStatus:
  20018. return m.OldStatus(ctx)
  20019. case label.FieldDeletedAt:
  20020. return m.OldDeletedAt(ctx)
  20021. case label.FieldType:
  20022. return m.OldType(ctx)
  20023. case label.FieldName:
  20024. return m.OldName(ctx)
  20025. case label.FieldFrom:
  20026. return m.OldFrom(ctx)
  20027. case label.FieldMode:
  20028. return m.OldMode(ctx)
  20029. case label.FieldConditions:
  20030. return m.OldConditions(ctx)
  20031. case label.FieldOrganizationID:
  20032. return m.OldOrganizationID(ctx)
  20033. }
  20034. return nil, fmt.Errorf("unknown Label field %s", name)
  20035. }
  20036. // SetField sets the value of a field with the given name. It returns an error if
  20037. // the field is not defined in the schema, or if the type mismatched the field
  20038. // type.
  20039. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  20040. switch name {
  20041. case label.FieldCreatedAt:
  20042. v, ok := value.(time.Time)
  20043. if !ok {
  20044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20045. }
  20046. m.SetCreatedAt(v)
  20047. return nil
  20048. case label.FieldUpdatedAt:
  20049. v, ok := value.(time.Time)
  20050. if !ok {
  20051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20052. }
  20053. m.SetUpdatedAt(v)
  20054. return nil
  20055. case label.FieldStatus:
  20056. v, ok := value.(uint8)
  20057. if !ok {
  20058. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20059. }
  20060. m.SetStatus(v)
  20061. return nil
  20062. case label.FieldDeletedAt:
  20063. v, ok := value.(time.Time)
  20064. if !ok {
  20065. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20066. }
  20067. m.SetDeletedAt(v)
  20068. return nil
  20069. case label.FieldType:
  20070. v, ok := value.(int)
  20071. if !ok {
  20072. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20073. }
  20074. m.SetType(v)
  20075. return nil
  20076. case label.FieldName:
  20077. v, ok := value.(string)
  20078. if !ok {
  20079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20080. }
  20081. m.SetName(v)
  20082. return nil
  20083. case label.FieldFrom:
  20084. v, ok := value.(int)
  20085. if !ok {
  20086. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20087. }
  20088. m.SetFrom(v)
  20089. return nil
  20090. case label.FieldMode:
  20091. v, ok := value.(int)
  20092. if !ok {
  20093. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20094. }
  20095. m.SetMode(v)
  20096. return nil
  20097. case label.FieldConditions:
  20098. v, ok := value.(string)
  20099. if !ok {
  20100. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20101. }
  20102. m.SetConditions(v)
  20103. return nil
  20104. case label.FieldOrganizationID:
  20105. v, ok := value.(uint64)
  20106. if !ok {
  20107. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20108. }
  20109. m.SetOrganizationID(v)
  20110. return nil
  20111. }
  20112. return fmt.Errorf("unknown Label field %s", name)
  20113. }
  20114. // AddedFields returns all numeric fields that were incremented/decremented during
  20115. // this mutation.
  20116. func (m *LabelMutation) AddedFields() []string {
  20117. var fields []string
  20118. if m.addstatus != nil {
  20119. fields = append(fields, label.FieldStatus)
  20120. }
  20121. if m.add_type != nil {
  20122. fields = append(fields, label.FieldType)
  20123. }
  20124. if m.addfrom != nil {
  20125. fields = append(fields, label.FieldFrom)
  20126. }
  20127. if m.addmode != nil {
  20128. fields = append(fields, label.FieldMode)
  20129. }
  20130. if m.addorganization_id != nil {
  20131. fields = append(fields, label.FieldOrganizationID)
  20132. }
  20133. return fields
  20134. }
  20135. // AddedField returns the numeric value that was incremented/decremented on a field
  20136. // with the given name. The second boolean return value indicates that this field
  20137. // was not set, or was not defined in the schema.
  20138. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  20139. switch name {
  20140. case label.FieldStatus:
  20141. return m.AddedStatus()
  20142. case label.FieldType:
  20143. return m.AddedType()
  20144. case label.FieldFrom:
  20145. return m.AddedFrom()
  20146. case label.FieldMode:
  20147. return m.AddedMode()
  20148. case label.FieldOrganizationID:
  20149. return m.AddedOrganizationID()
  20150. }
  20151. return nil, false
  20152. }
  20153. // AddField adds the value to the field with the given name. It returns an error if
  20154. // the field is not defined in the schema, or if the type mismatched the field
  20155. // type.
  20156. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  20157. switch name {
  20158. case label.FieldStatus:
  20159. v, ok := value.(int8)
  20160. if !ok {
  20161. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20162. }
  20163. m.AddStatus(v)
  20164. return nil
  20165. case label.FieldType:
  20166. v, ok := value.(int)
  20167. if !ok {
  20168. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20169. }
  20170. m.AddType(v)
  20171. return nil
  20172. case label.FieldFrom:
  20173. v, ok := value.(int)
  20174. if !ok {
  20175. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20176. }
  20177. m.AddFrom(v)
  20178. return nil
  20179. case label.FieldMode:
  20180. v, ok := value.(int)
  20181. if !ok {
  20182. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20183. }
  20184. m.AddMode(v)
  20185. return nil
  20186. case label.FieldOrganizationID:
  20187. v, ok := value.(int64)
  20188. if !ok {
  20189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20190. }
  20191. m.AddOrganizationID(v)
  20192. return nil
  20193. }
  20194. return fmt.Errorf("unknown Label numeric field %s", name)
  20195. }
  20196. // ClearedFields returns all nullable fields that were cleared during this
  20197. // mutation.
  20198. func (m *LabelMutation) ClearedFields() []string {
  20199. var fields []string
  20200. if m.FieldCleared(label.FieldStatus) {
  20201. fields = append(fields, label.FieldStatus)
  20202. }
  20203. if m.FieldCleared(label.FieldDeletedAt) {
  20204. fields = append(fields, label.FieldDeletedAt)
  20205. }
  20206. if m.FieldCleared(label.FieldConditions) {
  20207. fields = append(fields, label.FieldConditions)
  20208. }
  20209. if m.FieldCleared(label.FieldOrganizationID) {
  20210. fields = append(fields, label.FieldOrganizationID)
  20211. }
  20212. return fields
  20213. }
  20214. // FieldCleared returns a boolean indicating if a field with the given name was
  20215. // cleared in this mutation.
  20216. func (m *LabelMutation) FieldCleared(name string) bool {
  20217. _, ok := m.clearedFields[name]
  20218. return ok
  20219. }
  20220. // ClearField clears the value of the field with the given name. It returns an
  20221. // error if the field is not defined in the schema.
  20222. func (m *LabelMutation) ClearField(name string) error {
  20223. switch name {
  20224. case label.FieldStatus:
  20225. m.ClearStatus()
  20226. return nil
  20227. case label.FieldDeletedAt:
  20228. m.ClearDeletedAt()
  20229. return nil
  20230. case label.FieldConditions:
  20231. m.ClearConditions()
  20232. return nil
  20233. case label.FieldOrganizationID:
  20234. m.ClearOrganizationID()
  20235. return nil
  20236. }
  20237. return fmt.Errorf("unknown Label nullable field %s", name)
  20238. }
  20239. // ResetField resets all changes in the mutation for the field with the given name.
  20240. // It returns an error if the field is not defined in the schema.
  20241. func (m *LabelMutation) ResetField(name string) error {
  20242. switch name {
  20243. case label.FieldCreatedAt:
  20244. m.ResetCreatedAt()
  20245. return nil
  20246. case label.FieldUpdatedAt:
  20247. m.ResetUpdatedAt()
  20248. return nil
  20249. case label.FieldStatus:
  20250. m.ResetStatus()
  20251. return nil
  20252. case label.FieldDeletedAt:
  20253. m.ResetDeletedAt()
  20254. return nil
  20255. case label.FieldType:
  20256. m.ResetType()
  20257. return nil
  20258. case label.FieldName:
  20259. m.ResetName()
  20260. return nil
  20261. case label.FieldFrom:
  20262. m.ResetFrom()
  20263. return nil
  20264. case label.FieldMode:
  20265. m.ResetMode()
  20266. return nil
  20267. case label.FieldConditions:
  20268. m.ResetConditions()
  20269. return nil
  20270. case label.FieldOrganizationID:
  20271. m.ResetOrganizationID()
  20272. return nil
  20273. }
  20274. return fmt.Errorf("unknown Label field %s", name)
  20275. }
  20276. // AddedEdges returns all edge names that were set/added in this mutation.
  20277. func (m *LabelMutation) AddedEdges() []string {
  20278. edges := make([]string, 0, 1)
  20279. if m.label_relationships != nil {
  20280. edges = append(edges, label.EdgeLabelRelationships)
  20281. }
  20282. return edges
  20283. }
  20284. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20285. // name in this mutation.
  20286. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  20287. switch name {
  20288. case label.EdgeLabelRelationships:
  20289. ids := make([]ent.Value, 0, len(m.label_relationships))
  20290. for id := range m.label_relationships {
  20291. ids = append(ids, id)
  20292. }
  20293. return ids
  20294. }
  20295. return nil
  20296. }
  20297. // RemovedEdges returns all edge names that were removed in this mutation.
  20298. func (m *LabelMutation) RemovedEdges() []string {
  20299. edges := make([]string, 0, 1)
  20300. if m.removedlabel_relationships != nil {
  20301. edges = append(edges, label.EdgeLabelRelationships)
  20302. }
  20303. return edges
  20304. }
  20305. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20306. // the given name in this mutation.
  20307. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  20308. switch name {
  20309. case label.EdgeLabelRelationships:
  20310. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  20311. for id := range m.removedlabel_relationships {
  20312. ids = append(ids, id)
  20313. }
  20314. return ids
  20315. }
  20316. return nil
  20317. }
  20318. // ClearedEdges returns all edge names that were cleared in this mutation.
  20319. func (m *LabelMutation) ClearedEdges() []string {
  20320. edges := make([]string, 0, 1)
  20321. if m.clearedlabel_relationships {
  20322. edges = append(edges, label.EdgeLabelRelationships)
  20323. }
  20324. return edges
  20325. }
  20326. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20327. // was cleared in this mutation.
  20328. func (m *LabelMutation) EdgeCleared(name string) bool {
  20329. switch name {
  20330. case label.EdgeLabelRelationships:
  20331. return m.clearedlabel_relationships
  20332. }
  20333. return false
  20334. }
  20335. // ClearEdge clears the value of the edge with the given name. It returns an error
  20336. // if that edge is not defined in the schema.
  20337. func (m *LabelMutation) ClearEdge(name string) error {
  20338. switch name {
  20339. }
  20340. return fmt.Errorf("unknown Label unique edge %s", name)
  20341. }
  20342. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20343. // It returns an error if the edge is not defined in the schema.
  20344. func (m *LabelMutation) ResetEdge(name string) error {
  20345. switch name {
  20346. case label.EdgeLabelRelationships:
  20347. m.ResetLabelRelationships()
  20348. return nil
  20349. }
  20350. return fmt.Errorf("unknown Label edge %s", name)
  20351. }
  20352. // LabelLogMutation represents an operation that mutates the LabelLog nodes in the graph.
  20353. type LabelLogMutation struct {
  20354. config
  20355. op Op
  20356. typ string
  20357. id *uint64
  20358. created_at *time.Time
  20359. updated_at *time.Time
  20360. label_name *string
  20361. label_id *int
  20362. addlabel_id *int
  20363. wx_id *string
  20364. organization_id *uint64
  20365. addorganization_id *int64
  20366. clearedFields map[string]struct{}
  20367. done bool
  20368. oldValue func(context.Context) (*LabelLog, error)
  20369. predicates []predicate.LabelLog
  20370. }
  20371. var _ ent.Mutation = (*LabelLogMutation)(nil)
  20372. // labellogOption allows management of the mutation configuration using functional options.
  20373. type labellogOption func(*LabelLogMutation)
  20374. // newLabelLogMutation creates new mutation for the LabelLog entity.
  20375. func newLabelLogMutation(c config, op Op, opts ...labellogOption) *LabelLogMutation {
  20376. m := &LabelLogMutation{
  20377. config: c,
  20378. op: op,
  20379. typ: TypeLabelLog,
  20380. clearedFields: make(map[string]struct{}),
  20381. }
  20382. for _, opt := range opts {
  20383. opt(m)
  20384. }
  20385. return m
  20386. }
  20387. // withLabelLogID sets the ID field of the mutation.
  20388. func withLabelLogID(id uint64) labellogOption {
  20389. return func(m *LabelLogMutation) {
  20390. var (
  20391. err error
  20392. once sync.Once
  20393. value *LabelLog
  20394. )
  20395. m.oldValue = func(ctx context.Context) (*LabelLog, error) {
  20396. once.Do(func() {
  20397. if m.done {
  20398. err = errors.New("querying old values post mutation is not allowed")
  20399. } else {
  20400. value, err = m.Client().LabelLog.Get(ctx, id)
  20401. }
  20402. })
  20403. return value, err
  20404. }
  20405. m.id = &id
  20406. }
  20407. }
  20408. // withLabelLog sets the old LabelLog of the mutation.
  20409. func withLabelLog(node *LabelLog) labellogOption {
  20410. return func(m *LabelLogMutation) {
  20411. m.oldValue = func(context.Context) (*LabelLog, error) {
  20412. return node, nil
  20413. }
  20414. m.id = &node.ID
  20415. }
  20416. }
  20417. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20418. // executed in a transaction (ent.Tx), a transactional client is returned.
  20419. func (m LabelLogMutation) Client() *Client {
  20420. client := &Client{config: m.config}
  20421. client.init()
  20422. return client
  20423. }
  20424. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20425. // it returns an error otherwise.
  20426. func (m LabelLogMutation) Tx() (*Tx, error) {
  20427. if _, ok := m.driver.(*txDriver); !ok {
  20428. return nil, errors.New("ent: mutation is not running in a transaction")
  20429. }
  20430. tx := &Tx{config: m.config}
  20431. tx.init()
  20432. return tx, nil
  20433. }
  20434. // SetID sets the value of the id field. Note that this
  20435. // operation is only accepted on creation of LabelLog entities.
  20436. func (m *LabelLogMutation) SetID(id uint64) {
  20437. m.id = &id
  20438. }
  20439. // ID returns the ID value in the mutation. Note that the ID is only available
  20440. // if it was provided to the builder or after it was returned from the database.
  20441. func (m *LabelLogMutation) ID() (id uint64, exists bool) {
  20442. if m.id == nil {
  20443. return
  20444. }
  20445. return *m.id, true
  20446. }
  20447. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20448. // That means, if the mutation is applied within a transaction with an isolation level such
  20449. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20450. // or updated by the mutation.
  20451. func (m *LabelLogMutation) IDs(ctx context.Context) ([]uint64, error) {
  20452. switch {
  20453. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20454. id, exists := m.ID()
  20455. if exists {
  20456. return []uint64{id}, nil
  20457. }
  20458. fallthrough
  20459. case m.op.Is(OpUpdate | OpDelete):
  20460. return m.Client().LabelLog.Query().Where(m.predicates...).IDs(ctx)
  20461. default:
  20462. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20463. }
  20464. }
  20465. // SetCreatedAt sets the "created_at" field.
  20466. func (m *LabelLogMutation) SetCreatedAt(t time.Time) {
  20467. m.created_at = &t
  20468. }
  20469. // CreatedAt returns the value of the "created_at" field in the mutation.
  20470. func (m *LabelLogMutation) CreatedAt() (r time.Time, exists bool) {
  20471. v := m.created_at
  20472. if v == nil {
  20473. return
  20474. }
  20475. return *v, true
  20476. }
  20477. // OldCreatedAt returns the old "created_at" field's value of the LabelLog entity.
  20478. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  20479. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20480. func (m *LabelLogMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20481. if !m.op.Is(OpUpdateOne) {
  20482. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20483. }
  20484. if m.id == nil || m.oldValue == nil {
  20485. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20486. }
  20487. oldValue, err := m.oldValue(ctx)
  20488. if err != nil {
  20489. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20490. }
  20491. return oldValue.CreatedAt, nil
  20492. }
  20493. // ResetCreatedAt resets all changes to the "created_at" field.
  20494. func (m *LabelLogMutation) ResetCreatedAt() {
  20495. m.created_at = nil
  20496. }
  20497. // SetUpdatedAt sets the "updated_at" field.
  20498. func (m *LabelLogMutation) SetUpdatedAt(t time.Time) {
  20499. m.updated_at = &t
  20500. }
  20501. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20502. func (m *LabelLogMutation) UpdatedAt() (r time.Time, exists bool) {
  20503. v := m.updated_at
  20504. if v == nil {
  20505. return
  20506. }
  20507. return *v, true
  20508. }
  20509. // OldUpdatedAt returns the old "updated_at" field's value of the LabelLog entity.
  20510. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  20511. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20512. func (m *LabelLogMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20513. if !m.op.Is(OpUpdateOne) {
  20514. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20515. }
  20516. if m.id == nil || m.oldValue == nil {
  20517. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20518. }
  20519. oldValue, err := m.oldValue(ctx)
  20520. if err != nil {
  20521. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20522. }
  20523. return oldValue.UpdatedAt, nil
  20524. }
  20525. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20526. func (m *LabelLogMutation) ResetUpdatedAt() {
  20527. m.updated_at = nil
  20528. }
  20529. // SetLabelName sets the "label_name" field.
  20530. func (m *LabelLogMutation) SetLabelName(s string) {
  20531. m.label_name = &s
  20532. }
  20533. // LabelName returns the value of the "label_name" field in the mutation.
  20534. func (m *LabelLogMutation) LabelName() (r string, exists bool) {
  20535. v := m.label_name
  20536. if v == nil {
  20537. return
  20538. }
  20539. return *v, true
  20540. }
  20541. // OldLabelName returns the old "label_name" field's value of the LabelLog entity.
  20542. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  20543. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20544. func (m *LabelLogMutation) OldLabelName(ctx context.Context) (v string, err error) {
  20545. if !m.op.Is(OpUpdateOne) {
  20546. return v, errors.New("OldLabelName is only allowed on UpdateOne operations")
  20547. }
  20548. if m.id == nil || m.oldValue == nil {
  20549. return v, errors.New("OldLabelName requires an ID field in the mutation")
  20550. }
  20551. oldValue, err := m.oldValue(ctx)
  20552. if err != nil {
  20553. return v, fmt.Errorf("querying old value for OldLabelName: %w", err)
  20554. }
  20555. return oldValue.LabelName, nil
  20556. }
  20557. // ResetLabelName resets all changes to the "label_name" field.
  20558. func (m *LabelLogMutation) ResetLabelName() {
  20559. m.label_name = nil
  20560. }
  20561. // SetLabelID sets the "label_id" field.
  20562. func (m *LabelLogMutation) SetLabelID(i int) {
  20563. m.label_id = &i
  20564. m.addlabel_id = nil
  20565. }
  20566. // LabelID returns the value of the "label_id" field in the mutation.
  20567. func (m *LabelLogMutation) LabelID() (r int, exists bool) {
  20568. v := m.label_id
  20569. if v == nil {
  20570. return
  20571. }
  20572. return *v, true
  20573. }
  20574. // OldLabelID returns the old "label_id" field's value of the LabelLog entity.
  20575. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  20576. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20577. func (m *LabelLogMutation) OldLabelID(ctx context.Context) (v int, err error) {
  20578. if !m.op.Is(OpUpdateOne) {
  20579. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  20580. }
  20581. if m.id == nil || m.oldValue == nil {
  20582. return v, errors.New("OldLabelID requires an ID field in the mutation")
  20583. }
  20584. oldValue, err := m.oldValue(ctx)
  20585. if err != nil {
  20586. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  20587. }
  20588. return oldValue.LabelID, nil
  20589. }
  20590. // AddLabelID adds i to the "label_id" field.
  20591. func (m *LabelLogMutation) AddLabelID(i int) {
  20592. if m.addlabel_id != nil {
  20593. *m.addlabel_id += i
  20594. } else {
  20595. m.addlabel_id = &i
  20596. }
  20597. }
  20598. // AddedLabelID returns the value that was added to the "label_id" field in this mutation.
  20599. func (m *LabelLogMutation) AddedLabelID() (r int, exists bool) {
  20600. v := m.addlabel_id
  20601. if v == nil {
  20602. return
  20603. }
  20604. return *v, true
  20605. }
  20606. // ResetLabelID resets all changes to the "label_id" field.
  20607. func (m *LabelLogMutation) ResetLabelID() {
  20608. m.label_id = nil
  20609. m.addlabel_id = nil
  20610. }
  20611. // SetWxID sets the "wx_id" field.
  20612. func (m *LabelLogMutation) SetWxID(s string) {
  20613. m.wx_id = &s
  20614. }
  20615. // WxID returns the value of the "wx_id" field in the mutation.
  20616. func (m *LabelLogMutation) WxID() (r string, exists bool) {
  20617. v := m.wx_id
  20618. if v == nil {
  20619. return
  20620. }
  20621. return *v, true
  20622. }
  20623. // OldWxID returns the old "wx_id" field's value of the LabelLog entity.
  20624. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  20625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20626. func (m *LabelLogMutation) OldWxID(ctx context.Context) (v string, err error) {
  20627. if !m.op.Is(OpUpdateOne) {
  20628. return v, errors.New("OldWxID is only allowed on UpdateOne operations")
  20629. }
  20630. if m.id == nil || m.oldValue == nil {
  20631. return v, errors.New("OldWxID requires an ID field in the mutation")
  20632. }
  20633. oldValue, err := m.oldValue(ctx)
  20634. if err != nil {
  20635. return v, fmt.Errorf("querying old value for OldWxID: %w", err)
  20636. }
  20637. return oldValue.WxID, nil
  20638. }
  20639. // ResetWxID resets all changes to the "wx_id" field.
  20640. func (m *LabelLogMutation) ResetWxID() {
  20641. m.wx_id = nil
  20642. }
  20643. // SetOrganizationID sets the "organization_id" field.
  20644. func (m *LabelLogMutation) SetOrganizationID(u uint64) {
  20645. m.organization_id = &u
  20646. m.addorganization_id = nil
  20647. }
  20648. // OrganizationID returns the value of the "organization_id" field in the mutation.
  20649. func (m *LabelLogMutation) OrganizationID() (r uint64, exists bool) {
  20650. v := m.organization_id
  20651. if v == nil {
  20652. return
  20653. }
  20654. return *v, true
  20655. }
  20656. // OldOrganizationID returns the old "organization_id" field's value of the LabelLog entity.
  20657. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  20658. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20659. func (m *LabelLogMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  20660. if !m.op.Is(OpUpdateOne) {
  20661. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  20662. }
  20663. if m.id == nil || m.oldValue == nil {
  20664. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  20665. }
  20666. oldValue, err := m.oldValue(ctx)
  20667. if err != nil {
  20668. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  20669. }
  20670. return oldValue.OrganizationID, nil
  20671. }
  20672. // AddOrganizationID adds u to the "organization_id" field.
  20673. func (m *LabelLogMutation) AddOrganizationID(u int64) {
  20674. if m.addorganization_id != nil {
  20675. *m.addorganization_id += u
  20676. } else {
  20677. m.addorganization_id = &u
  20678. }
  20679. }
  20680. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  20681. func (m *LabelLogMutation) AddedOrganizationID() (r int64, exists bool) {
  20682. v := m.addorganization_id
  20683. if v == nil {
  20684. return
  20685. }
  20686. return *v, true
  20687. }
  20688. // ClearOrganizationID clears the value of the "organization_id" field.
  20689. func (m *LabelLogMutation) ClearOrganizationID() {
  20690. m.organization_id = nil
  20691. m.addorganization_id = nil
  20692. m.clearedFields[labellog.FieldOrganizationID] = struct{}{}
  20693. }
  20694. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  20695. func (m *LabelLogMutation) OrganizationIDCleared() bool {
  20696. _, ok := m.clearedFields[labellog.FieldOrganizationID]
  20697. return ok
  20698. }
  20699. // ResetOrganizationID resets all changes to the "organization_id" field.
  20700. func (m *LabelLogMutation) ResetOrganizationID() {
  20701. m.organization_id = nil
  20702. m.addorganization_id = nil
  20703. delete(m.clearedFields, labellog.FieldOrganizationID)
  20704. }
  20705. // Where appends a list predicates to the LabelLogMutation builder.
  20706. func (m *LabelLogMutation) Where(ps ...predicate.LabelLog) {
  20707. m.predicates = append(m.predicates, ps...)
  20708. }
  20709. // WhereP appends storage-level predicates to the LabelLogMutation builder. Using this method,
  20710. // users can use type-assertion to append predicates that do not depend on any generated package.
  20711. func (m *LabelLogMutation) WhereP(ps ...func(*sql.Selector)) {
  20712. p := make([]predicate.LabelLog, len(ps))
  20713. for i := range ps {
  20714. p[i] = ps[i]
  20715. }
  20716. m.Where(p...)
  20717. }
  20718. // Op returns the operation name.
  20719. func (m *LabelLogMutation) Op() Op {
  20720. return m.op
  20721. }
  20722. // SetOp allows setting the mutation operation.
  20723. func (m *LabelLogMutation) SetOp(op Op) {
  20724. m.op = op
  20725. }
  20726. // Type returns the node type of this mutation (LabelLog).
  20727. func (m *LabelLogMutation) Type() string {
  20728. return m.typ
  20729. }
  20730. // Fields returns all fields that were changed during this mutation. Note that in
  20731. // order to get all numeric fields that were incremented/decremented, call
  20732. // AddedFields().
  20733. func (m *LabelLogMutation) Fields() []string {
  20734. fields := make([]string, 0, 6)
  20735. if m.created_at != nil {
  20736. fields = append(fields, labellog.FieldCreatedAt)
  20737. }
  20738. if m.updated_at != nil {
  20739. fields = append(fields, labellog.FieldUpdatedAt)
  20740. }
  20741. if m.label_name != nil {
  20742. fields = append(fields, labellog.FieldLabelName)
  20743. }
  20744. if m.label_id != nil {
  20745. fields = append(fields, labellog.FieldLabelID)
  20746. }
  20747. if m.wx_id != nil {
  20748. fields = append(fields, labellog.FieldWxID)
  20749. }
  20750. if m.organization_id != nil {
  20751. fields = append(fields, labellog.FieldOrganizationID)
  20752. }
  20753. return fields
  20754. }
  20755. // Field returns the value of a field with the given name. The second boolean
  20756. // return value indicates that this field was not set, or was not defined in the
  20757. // schema.
  20758. func (m *LabelLogMutation) Field(name string) (ent.Value, bool) {
  20759. switch name {
  20760. case labellog.FieldCreatedAt:
  20761. return m.CreatedAt()
  20762. case labellog.FieldUpdatedAt:
  20763. return m.UpdatedAt()
  20764. case labellog.FieldLabelName:
  20765. return m.LabelName()
  20766. case labellog.FieldLabelID:
  20767. return m.LabelID()
  20768. case labellog.FieldWxID:
  20769. return m.WxID()
  20770. case labellog.FieldOrganizationID:
  20771. return m.OrganizationID()
  20772. }
  20773. return nil, false
  20774. }
  20775. // OldField returns the old value of the field from the database. An error is
  20776. // returned if the mutation operation is not UpdateOne, or the query to the
  20777. // database failed.
  20778. func (m *LabelLogMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20779. switch name {
  20780. case labellog.FieldCreatedAt:
  20781. return m.OldCreatedAt(ctx)
  20782. case labellog.FieldUpdatedAt:
  20783. return m.OldUpdatedAt(ctx)
  20784. case labellog.FieldLabelName:
  20785. return m.OldLabelName(ctx)
  20786. case labellog.FieldLabelID:
  20787. return m.OldLabelID(ctx)
  20788. case labellog.FieldWxID:
  20789. return m.OldWxID(ctx)
  20790. case labellog.FieldOrganizationID:
  20791. return m.OldOrganizationID(ctx)
  20792. }
  20793. return nil, fmt.Errorf("unknown LabelLog field %s", name)
  20794. }
  20795. // SetField sets the value of a field with the given name. It returns an error if
  20796. // the field is not defined in the schema, or if the type mismatched the field
  20797. // type.
  20798. func (m *LabelLogMutation) SetField(name string, value ent.Value) error {
  20799. switch name {
  20800. case labellog.FieldCreatedAt:
  20801. v, ok := value.(time.Time)
  20802. if !ok {
  20803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20804. }
  20805. m.SetCreatedAt(v)
  20806. return nil
  20807. case labellog.FieldUpdatedAt:
  20808. v, ok := value.(time.Time)
  20809. if !ok {
  20810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20811. }
  20812. m.SetUpdatedAt(v)
  20813. return nil
  20814. case labellog.FieldLabelName:
  20815. v, ok := value.(string)
  20816. if !ok {
  20817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20818. }
  20819. m.SetLabelName(v)
  20820. return nil
  20821. case labellog.FieldLabelID:
  20822. v, ok := value.(int)
  20823. if !ok {
  20824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20825. }
  20826. m.SetLabelID(v)
  20827. return nil
  20828. case labellog.FieldWxID:
  20829. v, ok := value.(string)
  20830. if !ok {
  20831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20832. }
  20833. m.SetWxID(v)
  20834. return nil
  20835. case labellog.FieldOrganizationID:
  20836. v, ok := value.(uint64)
  20837. if !ok {
  20838. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20839. }
  20840. m.SetOrganizationID(v)
  20841. return nil
  20842. }
  20843. return fmt.Errorf("unknown LabelLog field %s", name)
  20844. }
  20845. // AddedFields returns all numeric fields that were incremented/decremented during
  20846. // this mutation.
  20847. func (m *LabelLogMutation) AddedFields() []string {
  20848. var fields []string
  20849. if m.addlabel_id != nil {
  20850. fields = append(fields, labellog.FieldLabelID)
  20851. }
  20852. if m.addorganization_id != nil {
  20853. fields = append(fields, labellog.FieldOrganizationID)
  20854. }
  20855. return fields
  20856. }
  20857. // AddedField returns the numeric value that was incremented/decremented on a field
  20858. // with the given name. The second boolean return value indicates that this field
  20859. // was not set, or was not defined in the schema.
  20860. func (m *LabelLogMutation) AddedField(name string) (ent.Value, bool) {
  20861. switch name {
  20862. case labellog.FieldLabelID:
  20863. return m.AddedLabelID()
  20864. case labellog.FieldOrganizationID:
  20865. return m.AddedOrganizationID()
  20866. }
  20867. return nil, false
  20868. }
  20869. // AddField adds the value to the field with the given name. It returns an error if
  20870. // the field is not defined in the schema, or if the type mismatched the field
  20871. // type.
  20872. func (m *LabelLogMutation) AddField(name string, value ent.Value) error {
  20873. switch name {
  20874. case labellog.FieldLabelID:
  20875. v, ok := value.(int)
  20876. if !ok {
  20877. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20878. }
  20879. m.AddLabelID(v)
  20880. return nil
  20881. case labellog.FieldOrganizationID:
  20882. v, ok := value.(int64)
  20883. if !ok {
  20884. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20885. }
  20886. m.AddOrganizationID(v)
  20887. return nil
  20888. }
  20889. return fmt.Errorf("unknown LabelLog numeric field %s", name)
  20890. }
  20891. // ClearedFields returns all nullable fields that were cleared during this
  20892. // mutation.
  20893. func (m *LabelLogMutation) ClearedFields() []string {
  20894. var fields []string
  20895. if m.FieldCleared(labellog.FieldOrganizationID) {
  20896. fields = append(fields, labellog.FieldOrganizationID)
  20897. }
  20898. return fields
  20899. }
  20900. // FieldCleared returns a boolean indicating if a field with the given name was
  20901. // cleared in this mutation.
  20902. func (m *LabelLogMutation) FieldCleared(name string) bool {
  20903. _, ok := m.clearedFields[name]
  20904. return ok
  20905. }
  20906. // ClearField clears the value of the field with the given name. It returns an
  20907. // error if the field is not defined in the schema.
  20908. func (m *LabelLogMutation) ClearField(name string) error {
  20909. switch name {
  20910. case labellog.FieldOrganizationID:
  20911. m.ClearOrganizationID()
  20912. return nil
  20913. }
  20914. return fmt.Errorf("unknown LabelLog nullable field %s", name)
  20915. }
  20916. // ResetField resets all changes in the mutation for the field with the given name.
  20917. // It returns an error if the field is not defined in the schema.
  20918. func (m *LabelLogMutation) ResetField(name string) error {
  20919. switch name {
  20920. case labellog.FieldCreatedAt:
  20921. m.ResetCreatedAt()
  20922. return nil
  20923. case labellog.FieldUpdatedAt:
  20924. m.ResetUpdatedAt()
  20925. return nil
  20926. case labellog.FieldLabelName:
  20927. m.ResetLabelName()
  20928. return nil
  20929. case labellog.FieldLabelID:
  20930. m.ResetLabelID()
  20931. return nil
  20932. case labellog.FieldWxID:
  20933. m.ResetWxID()
  20934. return nil
  20935. case labellog.FieldOrganizationID:
  20936. m.ResetOrganizationID()
  20937. return nil
  20938. }
  20939. return fmt.Errorf("unknown LabelLog field %s", name)
  20940. }
  20941. // AddedEdges returns all edge names that were set/added in this mutation.
  20942. func (m *LabelLogMutation) AddedEdges() []string {
  20943. edges := make([]string, 0, 0)
  20944. return edges
  20945. }
  20946. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20947. // name in this mutation.
  20948. func (m *LabelLogMutation) AddedIDs(name string) []ent.Value {
  20949. return nil
  20950. }
  20951. // RemovedEdges returns all edge names that were removed in this mutation.
  20952. func (m *LabelLogMutation) RemovedEdges() []string {
  20953. edges := make([]string, 0, 0)
  20954. return edges
  20955. }
  20956. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20957. // the given name in this mutation.
  20958. func (m *LabelLogMutation) RemovedIDs(name string) []ent.Value {
  20959. return nil
  20960. }
  20961. // ClearedEdges returns all edge names that were cleared in this mutation.
  20962. func (m *LabelLogMutation) ClearedEdges() []string {
  20963. edges := make([]string, 0, 0)
  20964. return edges
  20965. }
  20966. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20967. // was cleared in this mutation.
  20968. func (m *LabelLogMutation) EdgeCleared(name string) bool {
  20969. return false
  20970. }
  20971. // ClearEdge clears the value of the edge with the given name. It returns an error
  20972. // if that edge is not defined in the schema.
  20973. func (m *LabelLogMutation) ClearEdge(name string) error {
  20974. return fmt.Errorf("unknown LabelLog unique edge %s", name)
  20975. }
  20976. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20977. // It returns an error if the edge is not defined in the schema.
  20978. func (m *LabelLogMutation) ResetEdge(name string) error {
  20979. return fmt.Errorf("unknown LabelLog edge %s", name)
  20980. }
  20981. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  20982. type LabelRelationshipMutation struct {
  20983. config
  20984. op Op
  20985. typ string
  20986. id *uint64
  20987. created_at *time.Time
  20988. updated_at *time.Time
  20989. status *uint8
  20990. addstatus *int8
  20991. deleted_at *time.Time
  20992. organization_id *uint64
  20993. addorganization_id *int64
  20994. clearedFields map[string]struct{}
  20995. contacts *uint64
  20996. clearedcontacts bool
  20997. labels *uint64
  20998. clearedlabels bool
  20999. done bool
  21000. oldValue func(context.Context) (*LabelRelationship, error)
  21001. predicates []predicate.LabelRelationship
  21002. }
  21003. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  21004. // labelrelationshipOption allows management of the mutation configuration using functional options.
  21005. type labelrelationshipOption func(*LabelRelationshipMutation)
  21006. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  21007. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  21008. m := &LabelRelationshipMutation{
  21009. config: c,
  21010. op: op,
  21011. typ: TypeLabelRelationship,
  21012. clearedFields: make(map[string]struct{}),
  21013. }
  21014. for _, opt := range opts {
  21015. opt(m)
  21016. }
  21017. return m
  21018. }
  21019. // withLabelRelationshipID sets the ID field of the mutation.
  21020. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  21021. return func(m *LabelRelationshipMutation) {
  21022. var (
  21023. err error
  21024. once sync.Once
  21025. value *LabelRelationship
  21026. )
  21027. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  21028. once.Do(func() {
  21029. if m.done {
  21030. err = errors.New("querying old values post mutation is not allowed")
  21031. } else {
  21032. value, err = m.Client().LabelRelationship.Get(ctx, id)
  21033. }
  21034. })
  21035. return value, err
  21036. }
  21037. m.id = &id
  21038. }
  21039. }
  21040. // withLabelRelationship sets the old LabelRelationship of the mutation.
  21041. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  21042. return func(m *LabelRelationshipMutation) {
  21043. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  21044. return node, nil
  21045. }
  21046. m.id = &node.ID
  21047. }
  21048. }
  21049. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21050. // executed in a transaction (ent.Tx), a transactional client is returned.
  21051. func (m LabelRelationshipMutation) Client() *Client {
  21052. client := &Client{config: m.config}
  21053. client.init()
  21054. return client
  21055. }
  21056. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21057. // it returns an error otherwise.
  21058. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  21059. if _, ok := m.driver.(*txDriver); !ok {
  21060. return nil, errors.New("ent: mutation is not running in a transaction")
  21061. }
  21062. tx := &Tx{config: m.config}
  21063. tx.init()
  21064. return tx, nil
  21065. }
  21066. // SetID sets the value of the id field. Note that this
  21067. // operation is only accepted on creation of LabelRelationship entities.
  21068. func (m *LabelRelationshipMutation) SetID(id uint64) {
  21069. m.id = &id
  21070. }
  21071. // ID returns the ID value in the mutation. Note that the ID is only available
  21072. // if it was provided to the builder or after it was returned from the database.
  21073. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  21074. if m.id == nil {
  21075. return
  21076. }
  21077. return *m.id, true
  21078. }
  21079. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21080. // That means, if the mutation is applied within a transaction with an isolation level such
  21081. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21082. // or updated by the mutation.
  21083. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  21084. switch {
  21085. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21086. id, exists := m.ID()
  21087. if exists {
  21088. return []uint64{id}, nil
  21089. }
  21090. fallthrough
  21091. case m.op.Is(OpUpdate | OpDelete):
  21092. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  21093. default:
  21094. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21095. }
  21096. }
  21097. // SetCreatedAt sets the "created_at" field.
  21098. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  21099. m.created_at = &t
  21100. }
  21101. // CreatedAt returns the value of the "created_at" field in the mutation.
  21102. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  21103. v := m.created_at
  21104. if v == nil {
  21105. return
  21106. }
  21107. return *v, true
  21108. }
  21109. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  21110. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  21111. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21112. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21113. if !m.op.Is(OpUpdateOne) {
  21114. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21115. }
  21116. if m.id == nil || m.oldValue == nil {
  21117. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21118. }
  21119. oldValue, err := m.oldValue(ctx)
  21120. if err != nil {
  21121. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21122. }
  21123. return oldValue.CreatedAt, nil
  21124. }
  21125. // ResetCreatedAt resets all changes to the "created_at" field.
  21126. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  21127. m.created_at = nil
  21128. }
  21129. // SetUpdatedAt sets the "updated_at" field.
  21130. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  21131. m.updated_at = &t
  21132. }
  21133. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21134. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  21135. v := m.updated_at
  21136. if v == nil {
  21137. return
  21138. }
  21139. return *v, true
  21140. }
  21141. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  21142. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  21143. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21144. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21145. if !m.op.Is(OpUpdateOne) {
  21146. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21147. }
  21148. if m.id == nil || m.oldValue == nil {
  21149. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21150. }
  21151. oldValue, err := m.oldValue(ctx)
  21152. if err != nil {
  21153. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21154. }
  21155. return oldValue.UpdatedAt, nil
  21156. }
  21157. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21158. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  21159. m.updated_at = nil
  21160. }
  21161. // SetStatus sets the "status" field.
  21162. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  21163. m.status = &u
  21164. m.addstatus = nil
  21165. }
  21166. // Status returns the value of the "status" field in the mutation.
  21167. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  21168. v := m.status
  21169. if v == nil {
  21170. return
  21171. }
  21172. return *v, true
  21173. }
  21174. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  21175. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  21176. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21177. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  21178. if !m.op.Is(OpUpdateOne) {
  21179. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  21180. }
  21181. if m.id == nil || m.oldValue == nil {
  21182. return v, errors.New("OldStatus requires an ID field in the mutation")
  21183. }
  21184. oldValue, err := m.oldValue(ctx)
  21185. if err != nil {
  21186. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  21187. }
  21188. return oldValue.Status, nil
  21189. }
  21190. // AddStatus adds u to the "status" field.
  21191. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  21192. if m.addstatus != nil {
  21193. *m.addstatus += u
  21194. } else {
  21195. m.addstatus = &u
  21196. }
  21197. }
  21198. // AddedStatus returns the value that was added to the "status" field in this mutation.
  21199. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  21200. v := m.addstatus
  21201. if v == nil {
  21202. return
  21203. }
  21204. return *v, true
  21205. }
  21206. // ClearStatus clears the value of the "status" field.
  21207. func (m *LabelRelationshipMutation) ClearStatus() {
  21208. m.status = nil
  21209. m.addstatus = nil
  21210. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  21211. }
  21212. // StatusCleared returns if the "status" field was cleared in this mutation.
  21213. func (m *LabelRelationshipMutation) StatusCleared() bool {
  21214. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  21215. return ok
  21216. }
  21217. // ResetStatus resets all changes to the "status" field.
  21218. func (m *LabelRelationshipMutation) ResetStatus() {
  21219. m.status = nil
  21220. m.addstatus = nil
  21221. delete(m.clearedFields, labelrelationship.FieldStatus)
  21222. }
  21223. // SetDeletedAt sets the "deleted_at" field.
  21224. func (m *LabelRelationshipMutation) SetDeletedAt(t time.Time) {
  21225. m.deleted_at = &t
  21226. }
  21227. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21228. func (m *LabelRelationshipMutation) DeletedAt() (r time.Time, exists bool) {
  21229. v := m.deleted_at
  21230. if v == nil {
  21231. return
  21232. }
  21233. return *v, true
  21234. }
  21235. // OldDeletedAt returns the old "deleted_at" field's value of the LabelRelationship entity.
  21236. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  21237. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21238. func (m *LabelRelationshipMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21239. if !m.op.Is(OpUpdateOne) {
  21240. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21241. }
  21242. if m.id == nil || m.oldValue == nil {
  21243. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21244. }
  21245. oldValue, err := m.oldValue(ctx)
  21246. if err != nil {
  21247. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21248. }
  21249. return oldValue.DeletedAt, nil
  21250. }
  21251. // ClearDeletedAt clears the value of the "deleted_at" field.
  21252. func (m *LabelRelationshipMutation) ClearDeletedAt() {
  21253. m.deleted_at = nil
  21254. m.clearedFields[labelrelationship.FieldDeletedAt] = struct{}{}
  21255. }
  21256. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21257. func (m *LabelRelationshipMutation) DeletedAtCleared() bool {
  21258. _, ok := m.clearedFields[labelrelationship.FieldDeletedAt]
  21259. return ok
  21260. }
  21261. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21262. func (m *LabelRelationshipMutation) ResetDeletedAt() {
  21263. m.deleted_at = nil
  21264. delete(m.clearedFields, labelrelationship.FieldDeletedAt)
  21265. }
  21266. // SetLabelID sets the "label_id" field.
  21267. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  21268. m.labels = &u
  21269. }
  21270. // LabelID returns the value of the "label_id" field in the mutation.
  21271. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  21272. v := m.labels
  21273. if v == nil {
  21274. return
  21275. }
  21276. return *v, true
  21277. }
  21278. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  21279. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  21280. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21281. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  21282. if !m.op.Is(OpUpdateOne) {
  21283. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  21284. }
  21285. if m.id == nil || m.oldValue == nil {
  21286. return v, errors.New("OldLabelID requires an ID field in the mutation")
  21287. }
  21288. oldValue, err := m.oldValue(ctx)
  21289. if err != nil {
  21290. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  21291. }
  21292. return oldValue.LabelID, nil
  21293. }
  21294. // ResetLabelID resets all changes to the "label_id" field.
  21295. func (m *LabelRelationshipMutation) ResetLabelID() {
  21296. m.labels = nil
  21297. }
  21298. // SetContactID sets the "contact_id" field.
  21299. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  21300. m.contacts = &u
  21301. }
  21302. // ContactID returns the value of the "contact_id" field in the mutation.
  21303. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  21304. v := m.contacts
  21305. if v == nil {
  21306. return
  21307. }
  21308. return *v, true
  21309. }
  21310. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  21311. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  21312. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21313. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  21314. if !m.op.Is(OpUpdateOne) {
  21315. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  21316. }
  21317. if m.id == nil || m.oldValue == nil {
  21318. return v, errors.New("OldContactID requires an ID field in the mutation")
  21319. }
  21320. oldValue, err := m.oldValue(ctx)
  21321. if err != nil {
  21322. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  21323. }
  21324. return oldValue.ContactID, nil
  21325. }
  21326. // ResetContactID resets all changes to the "contact_id" field.
  21327. func (m *LabelRelationshipMutation) ResetContactID() {
  21328. m.contacts = nil
  21329. }
  21330. // SetOrganizationID sets the "organization_id" field.
  21331. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  21332. m.organization_id = &u
  21333. m.addorganization_id = nil
  21334. }
  21335. // OrganizationID returns the value of the "organization_id" field in the mutation.
  21336. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  21337. v := m.organization_id
  21338. if v == nil {
  21339. return
  21340. }
  21341. return *v, true
  21342. }
  21343. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  21344. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  21345. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21346. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  21347. if !m.op.Is(OpUpdateOne) {
  21348. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  21349. }
  21350. if m.id == nil || m.oldValue == nil {
  21351. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  21352. }
  21353. oldValue, err := m.oldValue(ctx)
  21354. if err != nil {
  21355. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  21356. }
  21357. return oldValue.OrganizationID, nil
  21358. }
  21359. // AddOrganizationID adds u to the "organization_id" field.
  21360. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  21361. if m.addorganization_id != nil {
  21362. *m.addorganization_id += u
  21363. } else {
  21364. m.addorganization_id = &u
  21365. }
  21366. }
  21367. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  21368. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  21369. v := m.addorganization_id
  21370. if v == nil {
  21371. return
  21372. }
  21373. return *v, true
  21374. }
  21375. // ClearOrganizationID clears the value of the "organization_id" field.
  21376. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  21377. m.organization_id = nil
  21378. m.addorganization_id = nil
  21379. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  21380. }
  21381. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  21382. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  21383. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  21384. return ok
  21385. }
  21386. // ResetOrganizationID resets all changes to the "organization_id" field.
  21387. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  21388. m.organization_id = nil
  21389. m.addorganization_id = nil
  21390. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  21391. }
  21392. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  21393. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  21394. m.contacts = &id
  21395. }
  21396. // ClearContacts clears the "contacts" edge to the Contact entity.
  21397. func (m *LabelRelationshipMutation) ClearContacts() {
  21398. m.clearedcontacts = true
  21399. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  21400. }
  21401. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  21402. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  21403. return m.clearedcontacts
  21404. }
  21405. // ContactsID returns the "contacts" edge ID in the mutation.
  21406. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  21407. if m.contacts != nil {
  21408. return *m.contacts, true
  21409. }
  21410. return
  21411. }
  21412. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  21413. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21414. // ContactsID instead. It exists only for internal usage by the builders.
  21415. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  21416. if id := m.contacts; id != nil {
  21417. ids = append(ids, *id)
  21418. }
  21419. return
  21420. }
  21421. // ResetContacts resets all changes to the "contacts" edge.
  21422. func (m *LabelRelationshipMutation) ResetContacts() {
  21423. m.contacts = nil
  21424. m.clearedcontacts = false
  21425. }
  21426. // SetLabelsID sets the "labels" edge to the Label entity by id.
  21427. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  21428. m.labels = &id
  21429. }
  21430. // ClearLabels clears the "labels" edge to the Label entity.
  21431. func (m *LabelRelationshipMutation) ClearLabels() {
  21432. m.clearedlabels = true
  21433. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  21434. }
  21435. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  21436. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  21437. return m.clearedlabels
  21438. }
  21439. // LabelsID returns the "labels" edge ID in the mutation.
  21440. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  21441. if m.labels != nil {
  21442. return *m.labels, true
  21443. }
  21444. return
  21445. }
  21446. // LabelsIDs returns the "labels" edge IDs in the mutation.
  21447. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21448. // LabelsID instead. It exists only for internal usage by the builders.
  21449. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  21450. if id := m.labels; id != nil {
  21451. ids = append(ids, *id)
  21452. }
  21453. return
  21454. }
  21455. // ResetLabels resets all changes to the "labels" edge.
  21456. func (m *LabelRelationshipMutation) ResetLabels() {
  21457. m.labels = nil
  21458. m.clearedlabels = false
  21459. }
  21460. // Where appends a list predicates to the LabelRelationshipMutation builder.
  21461. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  21462. m.predicates = append(m.predicates, ps...)
  21463. }
  21464. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  21465. // users can use type-assertion to append predicates that do not depend on any generated package.
  21466. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  21467. p := make([]predicate.LabelRelationship, len(ps))
  21468. for i := range ps {
  21469. p[i] = ps[i]
  21470. }
  21471. m.Where(p...)
  21472. }
  21473. // Op returns the operation name.
  21474. func (m *LabelRelationshipMutation) Op() Op {
  21475. return m.op
  21476. }
  21477. // SetOp allows setting the mutation operation.
  21478. func (m *LabelRelationshipMutation) SetOp(op Op) {
  21479. m.op = op
  21480. }
  21481. // Type returns the node type of this mutation (LabelRelationship).
  21482. func (m *LabelRelationshipMutation) Type() string {
  21483. return m.typ
  21484. }
  21485. // Fields returns all fields that were changed during this mutation. Note that in
  21486. // order to get all numeric fields that were incremented/decremented, call
  21487. // AddedFields().
  21488. func (m *LabelRelationshipMutation) Fields() []string {
  21489. fields := make([]string, 0, 7)
  21490. if m.created_at != nil {
  21491. fields = append(fields, labelrelationship.FieldCreatedAt)
  21492. }
  21493. if m.updated_at != nil {
  21494. fields = append(fields, labelrelationship.FieldUpdatedAt)
  21495. }
  21496. if m.status != nil {
  21497. fields = append(fields, labelrelationship.FieldStatus)
  21498. }
  21499. if m.deleted_at != nil {
  21500. fields = append(fields, labelrelationship.FieldDeletedAt)
  21501. }
  21502. if m.labels != nil {
  21503. fields = append(fields, labelrelationship.FieldLabelID)
  21504. }
  21505. if m.contacts != nil {
  21506. fields = append(fields, labelrelationship.FieldContactID)
  21507. }
  21508. if m.organization_id != nil {
  21509. fields = append(fields, labelrelationship.FieldOrganizationID)
  21510. }
  21511. return fields
  21512. }
  21513. // Field returns the value of a field with the given name. The second boolean
  21514. // return value indicates that this field was not set, or was not defined in the
  21515. // schema.
  21516. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  21517. switch name {
  21518. case labelrelationship.FieldCreatedAt:
  21519. return m.CreatedAt()
  21520. case labelrelationship.FieldUpdatedAt:
  21521. return m.UpdatedAt()
  21522. case labelrelationship.FieldStatus:
  21523. return m.Status()
  21524. case labelrelationship.FieldDeletedAt:
  21525. return m.DeletedAt()
  21526. case labelrelationship.FieldLabelID:
  21527. return m.LabelID()
  21528. case labelrelationship.FieldContactID:
  21529. return m.ContactID()
  21530. case labelrelationship.FieldOrganizationID:
  21531. return m.OrganizationID()
  21532. }
  21533. return nil, false
  21534. }
  21535. // OldField returns the old value of the field from the database. An error is
  21536. // returned if the mutation operation is not UpdateOne, or the query to the
  21537. // database failed.
  21538. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21539. switch name {
  21540. case labelrelationship.FieldCreatedAt:
  21541. return m.OldCreatedAt(ctx)
  21542. case labelrelationship.FieldUpdatedAt:
  21543. return m.OldUpdatedAt(ctx)
  21544. case labelrelationship.FieldStatus:
  21545. return m.OldStatus(ctx)
  21546. case labelrelationship.FieldDeletedAt:
  21547. return m.OldDeletedAt(ctx)
  21548. case labelrelationship.FieldLabelID:
  21549. return m.OldLabelID(ctx)
  21550. case labelrelationship.FieldContactID:
  21551. return m.OldContactID(ctx)
  21552. case labelrelationship.FieldOrganizationID:
  21553. return m.OldOrganizationID(ctx)
  21554. }
  21555. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  21556. }
  21557. // SetField sets the value of a field with the given name. It returns an error if
  21558. // the field is not defined in the schema, or if the type mismatched the field
  21559. // type.
  21560. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  21561. switch name {
  21562. case labelrelationship.FieldCreatedAt:
  21563. v, ok := value.(time.Time)
  21564. if !ok {
  21565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21566. }
  21567. m.SetCreatedAt(v)
  21568. return nil
  21569. case labelrelationship.FieldUpdatedAt:
  21570. v, ok := value.(time.Time)
  21571. if !ok {
  21572. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21573. }
  21574. m.SetUpdatedAt(v)
  21575. return nil
  21576. case labelrelationship.FieldStatus:
  21577. v, ok := value.(uint8)
  21578. if !ok {
  21579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21580. }
  21581. m.SetStatus(v)
  21582. return nil
  21583. case labelrelationship.FieldDeletedAt:
  21584. v, ok := value.(time.Time)
  21585. if !ok {
  21586. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21587. }
  21588. m.SetDeletedAt(v)
  21589. return nil
  21590. case labelrelationship.FieldLabelID:
  21591. v, ok := value.(uint64)
  21592. if !ok {
  21593. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21594. }
  21595. m.SetLabelID(v)
  21596. return nil
  21597. case labelrelationship.FieldContactID:
  21598. v, ok := value.(uint64)
  21599. if !ok {
  21600. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21601. }
  21602. m.SetContactID(v)
  21603. return nil
  21604. case labelrelationship.FieldOrganizationID:
  21605. v, ok := value.(uint64)
  21606. if !ok {
  21607. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21608. }
  21609. m.SetOrganizationID(v)
  21610. return nil
  21611. }
  21612. return fmt.Errorf("unknown LabelRelationship field %s", name)
  21613. }
  21614. // AddedFields returns all numeric fields that were incremented/decremented during
  21615. // this mutation.
  21616. func (m *LabelRelationshipMutation) AddedFields() []string {
  21617. var fields []string
  21618. if m.addstatus != nil {
  21619. fields = append(fields, labelrelationship.FieldStatus)
  21620. }
  21621. if m.addorganization_id != nil {
  21622. fields = append(fields, labelrelationship.FieldOrganizationID)
  21623. }
  21624. return fields
  21625. }
  21626. // AddedField returns the numeric value that was incremented/decremented on a field
  21627. // with the given name. The second boolean return value indicates that this field
  21628. // was not set, or was not defined in the schema.
  21629. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  21630. switch name {
  21631. case labelrelationship.FieldStatus:
  21632. return m.AddedStatus()
  21633. case labelrelationship.FieldOrganizationID:
  21634. return m.AddedOrganizationID()
  21635. }
  21636. return nil, false
  21637. }
  21638. // AddField adds the value to the field with the given name. It returns an error if
  21639. // the field is not defined in the schema, or if the type mismatched the field
  21640. // type.
  21641. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  21642. switch name {
  21643. case labelrelationship.FieldStatus:
  21644. v, ok := value.(int8)
  21645. if !ok {
  21646. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21647. }
  21648. m.AddStatus(v)
  21649. return nil
  21650. case labelrelationship.FieldOrganizationID:
  21651. v, ok := value.(int64)
  21652. if !ok {
  21653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21654. }
  21655. m.AddOrganizationID(v)
  21656. return nil
  21657. }
  21658. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  21659. }
  21660. // ClearedFields returns all nullable fields that were cleared during this
  21661. // mutation.
  21662. func (m *LabelRelationshipMutation) ClearedFields() []string {
  21663. var fields []string
  21664. if m.FieldCleared(labelrelationship.FieldStatus) {
  21665. fields = append(fields, labelrelationship.FieldStatus)
  21666. }
  21667. if m.FieldCleared(labelrelationship.FieldDeletedAt) {
  21668. fields = append(fields, labelrelationship.FieldDeletedAt)
  21669. }
  21670. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  21671. fields = append(fields, labelrelationship.FieldOrganizationID)
  21672. }
  21673. return fields
  21674. }
  21675. // FieldCleared returns a boolean indicating if a field with the given name was
  21676. // cleared in this mutation.
  21677. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  21678. _, ok := m.clearedFields[name]
  21679. return ok
  21680. }
  21681. // ClearField clears the value of the field with the given name. It returns an
  21682. // error if the field is not defined in the schema.
  21683. func (m *LabelRelationshipMutation) ClearField(name string) error {
  21684. switch name {
  21685. case labelrelationship.FieldStatus:
  21686. m.ClearStatus()
  21687. return nil
  21688. case labelrelationship.FieldDeletedAt:
  21689. m.ClearDeletedAt()
  21690. return nil
  21691. case labelrelationship.FieldOrganizationID:
  21692. m.ClearOrganizationID()
  21693. return nil
  21694. }
  21695. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  21696. }
  21697. // ResetField resets all changes in the mutation for the field with the given name.
  21698. // It returns an error if the field is not defined in the schema.
  21699. func (m *LabelRelationshipMutation) ResetField(name string) error {
  21700. switch name {
  21701. case labelrelationship.FieldCreatedAt:
  21702. m.ResetCreatedAt()
  21703. return nil
  21704. case labelrelationship.FieldUpdatedAt:
  21705. m.ResetUpdatedAt()
  21706. return nil
  21707. case labelrelationship.FieldStatus:
  21708. m.ResetStatus()
  21709. return nil
  21710. case labelrelationship.FieldDeletedAt:
  21711. m.ResetDeletedAt()
  21712. return nil
  21713. case labelrelationship.FieldLabelID:
  21714. m.ResetLabelID()
  21715. return nil
  21716. case labelrelationship.FieldContactID:
  21717. m.ResetContactID()
  21718. return nil
  21719. case labelrelationship.FieldOrganizationID:
  21720. m.ResetOrganizationID()
  21721. return nil
  21722. }
  21723. return fmt.Errorf("unknown LabelRelationship field %s", name)
  21724. }
  21725. // AddedEdges returns all edge names that were set/added in this mutation.
  21726. func (m *LabelRelationshipMutation) AddedEdges() []string {
  21727. edges := make([]string, 0, 2)
  21728. if m.contacts != nil {
  21729. edges = append(edges, labelrelationship.EdgeContacts)
  21730. }
  21731. if m.labels != nil {
  21732. edges = append(edges, labelrelationship.EdgeLabels)
  21733. }
  21734. return edges
  21735. }
  21736. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21737. // name in this mutation.
  21738. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  21739. switch name {
  21740. case labelrelationship.EdgeContacts:
  21741. if id := m.contacts; id != nil {
  21742. return []ent.Value{*id}
  21743. }
  21744. case labelrelationship.EdgeLabels:
  21745. if id := m.labels; id != nil {
  21746. return []ent.Value{*id}
  21747. }
  21748. }
  21749. return nil
  21750. }
  21751. // RemovedEdges returns all edge names that were removed in this mutation.
  21752. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  21753. edges := make([]string, 0, 2)
  21754. return edges
  21755. }
  21756. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21757. // the given name in this mutation.
  21758. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  21759. return nil
  21760. }
  21761. // ClearedEdges returns all edge names that were cleared in this mutation.
  21762. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  21763. edges := make([]string, 0, 2)
  21764. if m.clearedcontacts {
  21765. edges = append(edges, labelrelationship.EdgeContacts)
  21766. }
  21767. if m.clearedlabels {
  21768. edges = append(edges, labelrelationship.EdgeLabels)
  21769. }
  21770. return edges
  21771. }
  21772. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21773. // was cleared in this mutation.
  21774. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  21775. switch name {
  21776. case labelrelationship.EdgeContacts:
  21777. return m.clearedcontacts
  21778. case labelrelationship.EdgeLabels:
  21779. return m.clearedlabels
  21780. }
  21781. return false
  21782. }
  21783. // ClearEdge clears the value of the edge with the given name. It returns an error
  21784. // if that edge is not defined in the schema.
  21785. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  21786. switch name {
  21787. case labelrelationship.EdgeContacts:
  21788. m.ClearContacts()
  21789. return nil
  21790. case labelrelationship.EdgeLabels:
  21791. m.ClearLabels()
  21792. return nil
  21793. }
  21794. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  21795. }
  21796. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21797. // It returns an error if the edge is not defined in the schema.
  21798. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  21799. switch name {
  21800. case labelrelationship.EdgeContacts:
  21801. m.ResetContacts()
  21802. return nil
  21803. case labelrelationship.EdgeLabels:
  21804. m.ResetLabels()
  21805. return nil
  21806. }
  21807. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  21808. }
  21809. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  21810. type LabelTaggingMutation struct {
  21811. config
  21812. op Op
  21813. typ string
  21814. id *uint64
  21815. created_at *time.Time
  21816. updated_at *time.Time
  21817. status *uint8
  21818. addstatus *int8
  21819. deleted_at *time.Time
  21820. organization_id *uint64
  21821. addorganization_id *int64
  21822. _type *int
  21823. add_type *int
  21824. conditions *string
  21825. action_label_add *[]uint64
  21826. appendaction_label_add []uint64
  21827. action_label_del *[]uint64
  21828. appendaction_label_del []uint64
  21829. clearedFields map[string]struct{}
  21830. done bool
  21831. oldValue func(context.Context) (*LabelTagging, error)
  21832. predicates []predicate.LabelTagging
  21833. }
  21834. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  21835. // labeltaggingOption allows management of the mutation configuration using functional options.
  21836. type labeltaggingOption func(*LabelTaggingMutation)
  21837. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  21838. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  21839. m := &LabelTaggingMutation{
  21840. config: c,
  21841. op: op,
  21842. typ: TypeLabelTagging,
  21843. clearedFields: make(map[string]struct{}),
  21844. }
  21845. for _, opt := range opts {
  21846. opt(m)
  21847. }
  21848. return m
  21849. }
  21850. // withLabelTaggingID sets the ID field of the mutation.
  21851. func withLabelTaggingID(id uint64) labeltaggingOption {
  21852. return func(m *LabelTaggingMutation) {
  21853. var (
  21854. err error
  21855. once sync.Once
  21856. value *LabelTagging
  21857. )
  21858. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  21859. once.Do(func() {
  21860. if m.done {
  21861. err = errors.New("querying old values post mutation is not allowed")
  21862. } else {
  21863. value, err = m.Client().LabelTagging.Get(ctx, id)
  21864. }
  21865. })
  21866. return value, err
  21867. }
  21868. m.id = &id
  21869. }
  21870. }
  21871. // withLabelTagging sets the old LabelTagging of the mutation.
  21872. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  21873. return func(m *LabelTaggingMutation) {
  21874. m.oldValue = func(context.Context) (*LabelTagging, error) {
  21875. return node, nil
  21876. }
  21877. m.id = &node.ID
  21878. }
  21879. }
  21880. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21881. // executed in a transaction (ent.Tx), a transactional client is returned.
  21882. func (m LabelTaggingMutation) Client() *Client {
  21883. client := &Client{config: m.config}
  21884. client.init()
  21885. return client
  21886. }
  21887. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21888. // it returns an error otherwise.
  21889. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  21890. if _, ok := m.driver.(*txDriver); !ok {
  21891. return nil, errors.New("ent: mutation is not running in a transaction")
  21892. }
  21893. tx := &Tx{config: m.config}
  21894. tx.init()
  21895. return tx, nil
  21896. }
  21897. // SetID sets the value of the id field. Note that this
  21898. // operation is only accepted on creation of LabelTagging entities.
  21899. func (m *LabelTaggingMutation) SetID(id uint64) {
  21900. m.id = &id
  21901. }
  21902. // ID returns the ID value in the mutation. Note that the ID is only available
  21903. // if it was provided to the builder or after it was returned from the database.
  21904. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  21905. if m.id == nil {
  21906. return
  21907. }
  21908. return *m.id, true
  21909. }
  21910. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21911. // That means, if the mutation is applied within a transaction with an isolation level such
  21912. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21913. // or updated by the mutation.
  21914. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  21915. switch {
  21916. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21917. id, exists := m.ID()
  21918. if exists {
  21919. return []uint64{id}, nil
  21920. }
  21921. fallthrough
  21922. case m.op.Is(OpUpdate | OpDelete):
  21923. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  21924. default:
  21925. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21926. }
  21927. }
  21928. // SetCreatedAt sets the "created_at" field.
  21929. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  21930. m.created_at = &t
  21931. }
  21932. // CreatedAt returns the value of the "created_at" field in the mutation.
  21933. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  21934. v := m.created_at
  21935. if v == nil {
  21936. return
  21937. }
  21938. return *v, true
  21939. }
  21940. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  21941. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  21942. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21943. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21944. if !m.op.Is(OpUpdateOne) {
  21945. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21946. }
  21947. if m.id == nil || m.oldValue == nil {
  21948. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21949. }
  21950. oldValue, err := m.oldValue(ctx)
  21951. if err != nil {
  21952. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21953. }
  21954. return oldValue.CreatedAt, nil
  21955. }
  21956. // ResetCreatedAt resets all changes to the "created_at" field.
  21957. func (m *LabelTaggingMutation) ResetCreatedAt() {
  21958. m.created_at = nil
  21959. }
  21960. // SetUpdatedAt sets the "updated_at" field.
  21961. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  21962. m.updated_at = &t
  21963. }
  21964. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21965. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  21966. v := m.updated_at
  21967. if v == nil {
  21968. return
  21969. }
  21970. return *v, true
  21971. }
  21972. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  21973. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  21974. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21975. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21976. if !m.op.Is(OpUpdateOne) {
  21977. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21978. }
  21979. if m.id == nil || m.oldValue == nil {
  21980. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21981. }
  21982. oldValue, err := m.oldValue(ctx)
  21983. if err != nil {
  21984. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21985. }
  21986. return oldValue.UpdatedAt, nil
  21987. }
  21988. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21989. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  21990. m.updated_at = nil
  21991. }
  21992. // SetStatus sets the "status" field.
  21993. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  21994. m.status = &u
  21995. m.addstatus = nil
  21996. }
  21997. // Status returns the value of the "status" field in the mutation.
  21998. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  21999. v := m.status
  22000. if v == nil {
  22001. return
  22002. }
  22003. return *v, true
  22004. }
  22005. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  22006. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  22007. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22008. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22009. if !m.op.Is(OpUpdateOne) {
  22010. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22011. }
  22012. if m.id == nil || m.oldValue == nil {
  22013. return v, errors.New("OldStatus requires an ID field in the mutation")
  22014. }
  22015. oldValue, err := m.oldValue(ctx)
  22016. if err != nil {
  22017. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22018. }
  22019. return oldValue.Status, nil
  22020. }
  22021. // AddStatus adds u to the "status" field.
  22022. func (m *LabelTaggingMutation) AddStatus(u int8) {
  22023. if m.addstatus != nil {
  22024. *m.addstatus += u
  22025. } else {
  22026. m.addstatus = &u
  22027. }
  22028. }
  22029. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22030. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  22031. v := m.addstatus
  22032. if v == nil {
  22033. return
  22034. }
  22035. return *v, true
  22036. }
  22037. // ClearStatus clears the value of the "status" field.
  22038. func (m *LabelTaggingMutation) ClearStatus() {
  22039. m.status = nil
  22040. m.addstatus = nil
  22041. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  22042. }
  22043. // StatusCleared returns if the "status" field was cleared in this mutation.
  22044. func (m *LabelTaggingMutation) StatusCleared() bool {
  22045. _, ok := m.clearedFields[labeltagging.FieldStatus]
  22046. return ok
  22047. }
  22048. // ResetStatus resets all changes to the "status" field.
  22049. func (m *LabelTaggingMutation) ResetStatus() {
  22050. m.status = nil
  22051. m.addstatus = nil
  22052. delete(m.clearedFields, labeltagging.FieldStatus)
  22053. }
  22054. // SetDeletedAt sets the "deleted_at" field.
  22055. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  22056. m.deleted_at = &t
  22057. }
  22058. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22059. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  22060. v := m.deleted_at
  22061. if v == nil {
  22062. return
  22063. }
  22064. return *v, true
  22065. }
  22066. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  22067. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  22068. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22069. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22070. if !m.op.Is(OpUpdateOne) {
  22071. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22072. }
  22073. if m.id == nil || m.oldValue == nil {
  22074. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22075. }
  22076. oldValue, err := m.oldValue(ctx)
  22077. if err != nil {
  22078. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22079. }
  22080. return oldValue.DeletedAt, nil
  22081. }
  22082. // ClearDeletedAt clears the value of the "deleted_at" field.
  22083. func (m *LabelTaggingMutation) ClearDeletedAt() {
  22084. m.deleted_at = nil
  22085. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  22086. }
  22087. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22088. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  22089. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  22090. return ok
  22091. }
  22092. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22093. func (m *LabelTaggingMutation) ResetDeletedAt() {
  22094. m.deleted_at = nil
  22095. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  22096. }
  22097. // SetOrganizationID sets the "organization_id" field.
  22098. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  22099. m.organization_id = &u
  22100. m.addorganization_id = nil
  22101. }
  22102. // OrganizationID returns the value of the "organization_id" field in the mutation.
  22103. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  22104. v := m.organization_id
  22105. if v == nil {
  22106. return
  22107. }
  22108. return *v, true
  22109. }
  22110. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  22111. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  22112. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22113. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  22114. if !m.op.Is(OpUpdateOne) {
  22115. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  22116. }
  22117. if m.id == nil || m.oldValue == nil {
  22118. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  22119. }
  22120. oldValue, err := m.oldValue(ctx)
  22121. if err != nil {
  22122. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  22123. }
  22124. return oldValue.OrganizationID, nil
  22125. }
  22126. // AddOrganizationID adds u to the "organization_id" field.
  22127. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  22128. if m.addorganization_id != nil {
  22129. *m.addorganization_id += u
  22130. } else {
  22131. m.addorganization_id = &u
  22132. }
  22133. }
  22134. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  22135. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  22136. v := m.addorganization_id
  22137. if v == nil {
  22138. return
  22139. }
  22140. return *v, true
  22141. }
  22142. // ResetOrganizationID resets all changes to the "organization_id" field.
  22143. func (m *LabelTaggingMutation) ResetOrganizationID() {
  22144. m.organization_id = nil
  22145. m.addorganization_id = nil
  22146. }
  22147. // SetType sets the "type" field.
  22148. func (m *LabelTaggingMutation) SetType(i int) {
  22149. m._type = &i
  22150. m.add_type = nil
  22151. }
  22152. // GetType returns the value of the "type" field in the mutation.
  22153. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  22154. v := m._type
  22155. if v == nil {
  22156. return
  22157. }
  22158. return *v, true
  22159. }
  22160. // OldType returns the old "type" field's value of the LabelTagging entity.
  22161. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  22162. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22163. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  22164. if !m.op.Is(OpUpdateOne) {
  22165. return v, errors.New("OldType is only allowed on UpdateOne operations")
  22166. }
  22167. if m.id == nil || m.oldValue == nil {
  22168. return v, errors.New("OldType requires an ID field in the mutation")
  22169. }
  22170. oldValue, err := m.oldValue(ctx)
  22171. if err != nil {
  22172. return v, fmt.Errorf("querying old value for OldType: %w", err)
  22173. }
  22174. return oldValue.Type, nil
  22175. }
  22176. // AddType adds i to the "type" field.
  22177. func (m *LabelTaggingMutation) AddType(i int) {
  22178. if m.add_type != nil {
  22179. *m.add_type += i
  22180. } else {
  22181. m.add_type = &i
  22182. }
  22183. }
  22184. // AddedType returns the value that was added to the "type" field in this mutation.
  22185. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  22186. v := m.add_type
  22187. if v == nil {
  22188. return
  22189. }
  22190. return *v, true
  22191. }
  22192. // ResetType resets all changes to the "type" field.
  22193. func (m *LabelTaggingMutation) ResetType() {
  22194. m._type = nil
  22195. m.add_type = nil
  22196. }
  22197. // SetConditions sets the "conditions" field.
  22198. func (m *LabelTaggingMutation) SetConditions(s string) {
  22199. m.conditions = &s
  22200. }
  22201. // Conditions returns the value of the "conditions" field in the mutation.
  22202. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  22203. v := m.conditions
  22204. if v == nil {
  22205. return
  22206. }
  22207. return *v, true
  22208. }
  22209. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  22210. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  22211. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22212. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  22213. if !m.op.Is(OpUpdateOne) {
  22214. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  22215. }
  22216. if m.id == nil || m.oldValue == nil {
  22217. return v, errors.New("OldConditions requires an ID field in the mutation")
  22218. }
  22219. oldValue, err := m.oldValue(ctx)
  22220. if err != nil {
  22221. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  22222. }
  22223. return oldValue.Conditions, nil
  22224. }
  22225. // ResetConditions resets all changes to the "conditions" field.
  22226. func (m *LabelTaggingMutation) ResetConditions() {
  22227. m.conditions = nil
  22228. }
  22229. // SetActionLabelAdd sets the "action_label_add" field.
  22230. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  22231. m.action_label_add = &u
  22232. m.appendaction_label_add = nil
  22233. }
  22234. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  22235. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  22236. v := m.action_label_add
  22237. if v == nil {
  22238. return
  22239. }
  22240. return *v, true
  22241. }
  22242. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  22243. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  22244. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22245. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  22246. if !m.op.Is(OpUpdateOne) {
  22247. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  22248. }
  22249. if m.id == nil || m.oldValue == nil {
  22250. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  22251. }
  22252. oldValue, err := m.oldValue(ctx)
  22253. if err != nil {
  22254. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  22255. }
  22256. return oldValue.ActionLabelAdd, nil
  22257. }
  22258. // AppendActionLabelAdd adds u to the "action_label_add" field.
  22259. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  22260. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  22261. }
  22262. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  22263. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  22264. if len(m.appendaction_label_add) == 0 {
  22265. return nil, false
  22266. }
  22267. return m.appendaction_label_add, true
  22268. }
  22269. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  22270. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  22271. m.action_label_add = nil
  22272. m.appendaction_label_add = nil
  22273. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  22274. }
  22275. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  22276. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  22277. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  22278. return ok
  22279. }
  22280. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  22281. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  22282. m.action_label_add = nil
  22283. m.appendaction_label_add = nil
  22284. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  22285. }
  22286. // SetActionLabelDel sets the "action_label_del" field.
  22287. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  22288. m.action_label_del = &u
  22289. m.appendaction_label_del = nil
  22290. }
  22291. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  22292. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  22293. v := m.action_label_del
  22294. if v == nil {
  22295. return
  22296. }
  22297. return *v, true
  22298. }
  22299. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  22300. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  22301. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22302. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  22303. if !m.op.Is(OpUpdateOne) {
  22304. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  22305. }
  22306. if m.id == nil || m.oldValue == nil {
  22307. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  22308. }
  22309. oldValue, err := m.oldValue(ctx)
  22310. if err != nil {
  22311. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  22312. }
  22313. return oldValue.ActionLabelDel, nil
  22314. }
  22315. // AppendActionLabelDel adds u to the "action_label_del" field.
  22316. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  22317. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  22318. }
  22319. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  22320. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  22321. if len(m.appendaction_label_del) == 0 {
  22322. return nil, false
  22323. }
  22324. return m.appendaction_label_del, true
  22325. }
  22326. // ClearActionLabelDel clears the value of the "action_label_del" field.
  22327. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  22328. m.action_label_del = nil
  22329. m.appendaction_label_del = nil
  22330. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  22331. }
  22332. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  22333. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  22334. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  22335. return ok
  22336. }
  22337. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  22338. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  22339. m.action_label_del = nil
  22340. m.appendaction_label_del = nil
  22341. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  22342. }
  22343. // Where appends a list predicates to the LabelTaggingMutation builder.
  22344. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  22345. m.predicates = append(m.predicates, ps...)
  22346. }
  22347. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  22348. // users can use type-assertion to append predicates that do not depend on any generated package.
  22349. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  22350. p := make([]predicate.LabelTagging, len(ps))
  22351. for i := range ps {
  22352. p[i] = ps[i]
  22353. }
  22354. m.Where(p...)
  22355. }
  22356. // Op returns the operation name.
  22357. func (m *LabelTaggingMutation) Op() Op {
  22358. return m.op
  22359. }
  22360. // SetOp allows setting the mutation operation.
  22361. func (m *LabelTaggingMutation) SetOp(op Op) {
  22362. m.op = op
  22363. }
  22364. // Type returns the node type of this mutation (LabelTagging).
  22365. func (m *LabelTaggingMutation) Type() string {
  22366. return m.typ
  22367. }
  22368. // Fields returns all fields that were changed during this mutation. Note that in
  22369. // order to get all numeric fields that were incremented/decremented, call
  22370. // AddedFields().
  22371. func (m *LabelTaggingMutation) Fields() []string {
  22372. fields := make([]string, 0, 9)
  22373. if m.created_at != nil {
  22374. fields = append(fields, labeltagging.FieldCreatedAt)
  22375. }
  22376. if m.updated_at != nil {
  22377. fields = append(fields, labeltagging.FieldUpdatedAt)
  22378. }
  22379. if m.status != nil {
  22380. fields = append(fields, labeltagging.FieldStatus)
  22381. }
  22382. if m.deleted_at != nil {
  22383. fields = append(fields, labeltagging.FieldDeletedAt)
  22384. }
  22385. if m.organization_id != nil {
  22386. fields = append(fields, labeltagging.FieldOrganizationID)
  22387. }
  22388. if m._type != nil {
  22389. fields = append(fields, labeltagging.FieldType)
  22390. }
  22391. if m.conditions != nil {
  22392. fields = append(fields, labeltagging.FieldConditions)
  22393. }
  22394. if m.action_label_add != nil {
  22395. fields = append(fields, labeltagging.FieldActionLabelAdd)
  22396. }
  22397. if m.action_label_del != nil {
  22398. fields = append(fields, labeltagging.FieldActionLabelDel)
  22399. }
  22400. return fields
  22401. }
  22402. // Field returns the value of a field with the given name. The second boolean
  22403. // return value indicates that this field was not set, or was not defined in the
  22404. // schema.
  22405. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  22406. switch name {
  22407. case labeltagging.FieldCreatedAt:
  22408. return m.CreatedAt()
  22409. case labeltagging.FieldUpdatedAt:
  22410. return m.UpdatedAt()
  22411. case labeltagging.FieldStatus:
  22412. return m.Status()
  22413. case labeltagging.FieldDeletedAt:
  22414. return m.DeletedAt()
  22415. case labeltagging.FieldOrganizationID:
  22416. return m.OrganizationID()
  22417. case labeltagging.FieldType:
  22418. return m.GetType()
  22419. case labeltagging.FieldConditions:
  22420. return m.Conditions()
  22421. case labeltagging.FieldActionLabelAdd:
  22422. return m.ActionLabelAdd()
  22423. case labeltagging.FieldActionLabelDel:
  22424. return m.ActionLabelDel()
  22425. }
  22426. return nil, false
  22427. }
  22428. // OldField returns the old value of the field from the database. An error is
  22429. // returned if the mutation operation is not UpdateOne, or the query to the
  22430. // database failed.
  22431. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22432. switch name {
  22433. case labeltagging.FieldCreatedAt:
  22434. return m.OldCreatedAt(ctx)
  22435. case labeltagging.FieldUpdatedAt:
  22436. return m.OldUpdatedAt(ctx)
  22437. case labeltagging.FieldStatus:
  22438. return m.OldStatus(ctx)
  22439. case labeltagging.FieldDeletedAt:
  22440. return m.OldDeletedAt(ctx)
  22441. case labeltagging.FieldOrganizationID:
  22442. return m.OldOrganizationID(ctx)
  22443. case labeltagging.FieldType:
  22444. return m.OldType(ctx)
  22445. case labeltagging.FieldConditions:
  22446. return m.OldConditions(ctx)
  22447. case labeltagging.FieldActionLabelAdd:
  22448. return m.OldActionLabelAdd(ctx)
  22449. case labeltagging.FieldActionLabelDel:
  22450. return m.OldActionLabelDel(ctx)
  22451. }
  22452. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  22453. }
  22454. // SetField sets the value of a field with the given name. It returns an error if
  22455. // the field is not defined in the schema, or if the type mismatched the field
  22456. // type.
  22457. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  22458. switch name {
  22459. case labeltagging.FieldCreatedAt:
  22460. v, ok := value.(time.Time)
  22461. if !ok {
  22462. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22463. }
  22464. m.SetCreatedAt(v)
  22465. return nil
  22466. case labeltagging.FieldUpdatedAt:
  22467. v, ok := value.(time.Time)
  22468. if !ok {
  22469. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22470. }
  22471. m.SetUpdatedAt(v)
  22472. return nil
  22473. case labeltagging.FieldStatus:
  22474. v, ok := value.(uint8)
  22475. if !ok {
  22476. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22477. }
  22478. m.SetStatus(v)
  22479. return nil
  22480. case labeltagging.FieldDeletedAt:
  22481. v, ok := value.(time.Time)
  22482. if !ok {
  22483. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22484. }
  22485. m.SetDeletedAt(v)
  22486. return nil
  22487. case labeltagging.FieldOrganizationID:
  22488. v, ok := value.(uint64)
  22489. if !ok {
  22490. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22491. }
  22492. m.SetOrganizationID(v)
  22493. return nil
  22494. case labeltagging.FieldType:
  22495. v, ok := value.(int)
  22496. if !ok {
  22497. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22498. }
  22499. m.SetType(v)
  22500. return nil
  22501. case labeltagging.FieldConditions:
  22502. v, ok := value.(string)
  22503. if !ok {
  22504. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22505. }
  22506. m.SetConditions(v)
  22507. return nil
  22508. case labeltagging.FieldActionLabelAdd:
  22509. v, ok := value.([]uint64)
  22510. if !ok {
  22511. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22512. }
  22513. m.SetActionLabelAdd(v)
  22514. return nil
  22515. case labeltagging.FieldActionLabelDel:
  22516. v, ok := value.([]uint64)
  22517. if !ok {
  22518. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22519. }
  22520. m.SetActionLabelDel(v)
  22521. return nil
  22522. }
  22523. return fmt.Errorf("unknown LabelTagging field %s", name)
  22524. }
  22525. // AddedFields returns all numeric fields that were incremented/decremented during
  22526. // this mutation.
  22527. func (m *LabelTaggingMutation) AddedFields() []string {
  22528. var fields []string
  22529. if m.addstatus != nil {
  22530. fields = append(fields, labeltagging.FieldStatus)
  22531. }
  22532. if m.addorganization_id != nil {
  22533. fields = append(fields, labeltagging.FieldOrganizationID)
  22534. }
  22535. if m.add_type != nil {
  22536. fields = append(fields, labeltagging.FieldType)
  22537. }
  22538. return fields
  22539. }
  22540. // AddedField returns the numeric value that was incremented/decremented on a field
  22541. // with the given name. The second boolean return value indicates that this field
  22542. // was not set, or was not defined in the schema.
  22543. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  22544. switch name {
  22545. case labeltagging.FieldStatus:
  22546. return m.AddedStatus()
  22547. case labeltagging.FieldOrganizationID:
  22548. return m.AddedOrganizationID()
  22549. case labeltagging.FieldType:
  22550. return m.AddedType()
  22551. }
  22552. return nil, false
  22553. }
  22554. // AddField adds the value to the field with the given name. It returns an error if
  22555. // the field is not defined in the schema, or if the type mismatched the field
  22556. // type.
  22557. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  22558. switch name {
  22559. case labeltagging.FieldStatus:
  22560. v, ok := value.(int8)
  22561. if !ok {
  22562. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22563. }
  22564. m.AddStatus(v)
  22565. return nil
  22566. case labeltagging.FieldOrganizationID:
  22567. v, ok := value.(int64)
  22568. if !ok {
  22569. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22570. }
  22571. m.AddOrganizationID(v)
  22572. return nil
  22573. case labeltagging.FieldType:
  22574. v, ok := value.(int)
  22575. if !ok {
  22576. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22577. }
  22578. m.AddType(v)
  22579. return nil
  22580. }
  22581. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  22582. }
  22583. // ClearedFields returns all nullable fields that were cleared during this
  22584. // mutation.
  22585. func (m *LabelTaggingMutation) ClearedFields() []string {
  22586. var fields []string
  22587. if m.FieldCleared(labeltagging.FieldStatus) {
  22588. fields = append(fields, labeltagging.FieldStatus)
  22589. }
  22590. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  22591. fields = append(fields, labeltagging.FieldDeletedAt)
  22592. }
  22593. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  22594. fields = append(fields, labeltagging.FieldActionLabelAdd)
  22595. }
  22596. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  22597. fields = append(fields, labeltagging.FieldActionLabelDel)
  22598. }
  22599. return fields
  22600. }
  22601. // FieldCleared returns a boolean indicating if a field with the given name was
  22602. // cleared in this mutation.
  22603. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  22604. _, ok := m.clearedFields[name]
  22605. return ok
  22606. }
  22607. // ClearField clears the value of the field with the given name. It returns an
  22608. // error if the field is not defined in the schema.
  22609. func (m *LabelTaggingMutation) ClearField(name string) error {
  22610. switch name {
  22611. case labeltagging.FieldStatus:
  22612. m.ClearStatus()
  22613. return nil
  22614. case labeltagging.FieldDeletedAt:
  22615. m.ClearDeletedAt()
  22616. return nil
  22617. case labeltagging.FieldActionLabelAdd:
  22618. m.ClearActionLabelAdd()
  22619. return nil
  22620. case labeltagging.FieldActionLabelDel:
  22621. m.ClearActionLabelDel()
  22622. return nil
  22623. }
  22624. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  22625. }
  22626. // ResetField resets all changes in the mutation for the field with the given name.
  22627. // It returns an error if the field is not defined in the schema.
  22628. func (m *LabelTaggingMutation) ResetField(name string) error {
  22629. switch name {
  22630. case labeltagging.FieldCreatedAt:
  22631. m.ResetCreatedAt()
  22632. return nil
  22633. case labeltagging.FieldUpdatedAt:
  22634. m.ResetUpdatedAt()
  22635. return nil
  22636. case labeltagging.FieldStatus:
  22637. m.ResetStatus()
  22638. return nil
  22639. case labeltagging.FieldDeletedAt:
  22640. m.ResetDeletedAt()
  22641. return nil
  22642. case labeltagging.FieldOrganizationID:
  22643. m.ResetOrganizationID()
  22644. return nil
  22645. case labeltagging.FieldType:
  22646. m.ResetType()
  22647. return nil
  22648. case labeltagging.FieldConditions:
  22649. m.ResetConditions()
  22650. return nil
  22651. case labeltagging.FieldActionLabelAdd:
  22652. m.ResetActionLabelAdd()
  22653. return nil
  22654. case labeltagging.FieldActionLabelDel:
  22655. m.ResetActionLabelDel()
  22656. return nil
  22657. }
  22658. return fmt.Errorf("unknown LabelTagging field %s", name)
  22659. }
  22660. // AddedEdges returns all edge names that were set/added in this mutation.
  22661. func (m *LabelTaggingMutation) AddedEdges() []string {
  22662. edges := make([]string, 0, 0)
  22663. return edges
  22664. }
  22665. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22666. // name in this mutation.
  22667. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  22668. return nil
  22669. }
  22670. // RemovedEdges returns all edge names that were removed in this mutation.
  22671. func (m *LabelTaggingMutation) RemovedEdges() []string {
  22672. edges := make([]string, 0, 0)
  22673. return edges
  22674. }
  22675. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22676. // the given name in this mutation.
  22677. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  22678. return nil
  22679. }
  22680. // ClearedEdges returns all edge names that were cleared in this mutation.
  22681. func (m *LabelTaggingMutation) ClearedEdges() []string {
  22682. edges := make([]string, 0, 0)
  22683. return edges
  22684. }
  22685. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22686. // was cleared in this mutation.
  22687. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  22688. return false
  22689. }
  22690. // ClearEdge clears the value of the edge with the given name. It returns an error
  22691. // if that edge is not defined in the schema.
  22692. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  22693. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  22694. }
  22695. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22696. // It returns an error if the edge is not defined in the schema.
  22697. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  22698. return fmt.Errorf("unknown LabelTagging edge %s", name)
  22699. }
  22700. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  22701. type MessageMutation struct {
  22702. config
  22703. op Op
  22704. typ string
  22705. id *int
  22706. wx_wxid *string
  22707. wxid *string
  22708. content *string
  22709. clearedFields map[string]struct{}
  22710. done bool
  22711. oldValue func(context.Context) (*Message, error)
  22712. predicates []predicate.Message
  22713. }
  22714. var _ ent.Mutation = (*MessageMutation)(nil)
  22715. // messageOption allows management of the mutation configuration using functional options.
  22716. type messageOption func(*MessageMutation)
  22717. // newMessageMutation creates new mutation for the Message entity.
  22718. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  22719. m := &MessageMutation{
  22720. config: c,
  22721. op: op,
  22722. typ: TypeMessage,
  22723. clearedFields: make(map[string]struct{}),
  22724. }
  22725. for _, opt := range opts {
  22726. opt(m)
  22727. }
  22728. return m
  22729. }
  22730. // withMessageID sets the ID field of the mutation.
  22731. func withMessageID(id int) messageOption {
  22732. return func(m *MessageMutation) {
  22733. var (
  22734. err error
  22735. once sync.Once
  22736. value *Message
  22737. )
  22738. m.oldValue = func(ctx context.Context) (*Message, error) {
  22739. once.Do(func() {
  22740. if m.done {
  22741. err = errors.New("querying old values post mutation is not allowed")
  22742. } else {
  22743. value, err = m.Client().Message.Get(ctx, id)
  22744. }
  22745. })
  22746. return value, err
  22747. }
  22748. m.id = &id
  22749. }
  22750. }
  22751. // withMessage sets the old Message of the mutation.
  22752. func withMessage(node *Message) messageOption {
  22753. return func(m *MessageMutation) {
  22754. m.oldValue = func(context.Context) (*Message, error) {
  22755. return node, nil
  22756. }
  22757. m.id = &node.ID
  22758. }
  22759. }
  22760. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22761. // executed in a transaction (ent.Tx), a transactional client is returned.
  22762. func (m MessageMutation) Client() *Client {
  22763. client := &Client{config: m.config}
  22764. client.init()
  22765. return client
  22766. }
  22767. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22768. // it returns an error otherwise.
  22769. func (m MessageMutation) Tx() (*Tx, error) {
  22770. if _, ok := m.driver.(*txDriver); !ok {
  22771. return nil, errors.New("ent: mutation is not running in a transaction")
  22772. }
  22773. tx := &Tx{config: m.config}
  22774. tx.init()
  22775. return tx, nil
  22776. }
  22777. // ID returns the ID value in the mutation. Note that the ID is only available
  22778. // if it was provided to the builder or after it was returned from the database.
  22779. func (m *MessageMutation) ID() (id int, exists bool) {
  22780. if m.id == nil {
  22781. return
  22782. }
  22783. return *m.id, true
  22784. }
  22785. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22786. // That means, if the mutation is applied within a transaction with an isolation level such
  22787. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22788. // or updated by the mutation.
  22789. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  22790. switch {
  22791. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22792. id, exists := m.ID()
  22793. if exists {
  22794. return []int{id}, nil
  22795. }
  22796. fallthrough
  22797. case m.op.Is(OpUpdate | OpDelete):
  22798. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  22799. default:
  22800. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22801. }
  22802. }
  22803. // SetWxWxid sets the "wx_wxid" field.
  22804. func (m *MessageMutation) SetWxWxid(s string) {
  22805. m.wx_wxid = &s
  22806. }
  22807. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  22808. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  22809. v := m.wx_wxid
  22810. if v == nil {
  22811. return
  22812. }
  22813. return *v, true
  22814. }
  22815. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  22816. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  22817. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22818. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  22819. if !m.op.Is(OpUpdateOne) {
  22820. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  22821. }
  22822. if m.id == nil || m.oldValue == nil {
  22823. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  22824. }
  22825. oldValue, err := m.oldValue(ctx)
  22826. if err != nil {
  22827. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  22828. }
  22829. return oldValue.WxWxid, nil
  22830. }
  22831. // ClearWxWxid clears the value of the "wx_wxid" field.
  22832. func (m *MessageMutation) ClearWxWxid() {
  22833. m.wx_wxid = nil
  22834. m.clearedFields[message.FieldWxWxid] = struct{}{}
  22835. }
  22836. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  22837. func (m *MessageMutation) WxWxidCleared() bool {
  22838. _, ok := m.clearedFields[message.FieldWxWxid]
  22839. return ok
  22840. }
  22841. // ResetWxWxid resets all changes to the "wx_wxid" field.
  22842. func (m *MessageMutation) ResetWxWxid() {
  22843. m.wx_wxid = nil
  22844. delete(m.clearedFields, message.FieldWxWxid)
  22845. }
  22846. // SetWxid sets the "wxid" field.
  22847. func (m *MessageMutation) SetWxid(s string) {
  22848. m.wxid = &s
  22849. }
  22850. // Wxid returns the value of the "wxid" field in the mutation.
  22851. func (m *MessageMutation) Wxid() (r string, exists bool) {
  22852. v := m.wxid
  22853. if v == nil {
  22854. return
  22855. }
  22856. return *v, true
  22857. }
  22858. // OldWxid returns the old "wxid" field's value of the Message entity.
  22859. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  22860. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22861. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  22862. if !m.op.Is(OpUpdateOne) {
  22863. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  22864. }
  22865. if m.id == nil || m.oldValue == nil {
  22866. return v, errors.New("OldWxid requires an ID field in the mutation")
  22867. }
  22868. oldValue, err := m.oldValue(ctx)
  22869. if err != nil {
  22870. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  22871. }
  22872. return oldValue.Wxid, nil
  22873. }
  22874. // ResetWxid resets all changes to the "wxid" field.
  22875. func (m *MessageMutation) ResetWxid() {
  22876. m.wxid = nil
  22877. }
  22878. // SetContent sets the "content" field.
  22879. func (m *MessageMutation) SetContent(s string) {
  22880. m.content = &s
  22881. }
  22882. // Content returns the value of the "content" field in the mutation.
  22883. func (m *MessageMutation) Content() (r string, exists bool) {
  22884. v := m.content
  22885. if v == nil {
  22886. return
  22887. }
  22888. return *v, true
  22889. }
  22890. // OldContent returns the old "content" field's value of the Message entity.
  22891. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  22892. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22893. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  22894. if !m.op.Is(OpUpdateOne) {
  22895. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  22896. }
  22897. if m.id == nil || m.oldValue == nil {
  22898. return v, errors.New("OldContent requires an ID field in the mutation")
  22899. }
  22900. oldValue, err := m.oldValue(ctx)
  22901. if err != nil {
  22902. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  22903. }
  22904. return oldValue.Content, nil
  22905. }
  22906. // ResetContent resets all changes to the "content" field.
  22907. func (m *MessageMutation) ResetContent() {
  22908. m.content = nil
  22909. }
  22910. // Where appends a list predicates to the MessageMutation builder.
  22911. func (m *MessageMutation) Where(ps ...predicate.Message) {
  22912. m.predicates = append(m.predicates, ps...)
  22913. }
  22914. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  22915. // users can use type-assertion to append predicates that do not depend on any generated package.
  22916. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  22917. p := make([]predicate.Message, len(ps))
  22918. for i := range ps {
  22919. p[i] = ps[i]
  22920. }
  22921. m.Where(p...)
  22922. }
  22923. // Op returns the operation name.
  22924. func (m *MessageMutation) Op() Op {
  22925. return m.op
  22926. }
  22927. // SetOp allows setting the mutation operation.
  22928. func (m *MessageMutation) SetOp(op Op) {
  22929. m.op = op
  22930. }
  22931. // Type returns the node type of this mutation (Message).
  22932. func (m *MessageMutation) Type() string {
  22933. return m.typ
  22934. }
  22935. // Fields returns all fields that were changed during this mutation. Note that in
  22936. // order to get all numeric fields that were incremented/decremented, call
  22937. // AddedFields().
  22938. func (m *MessageMutation) Fields() []string {
  22939. fields := make([]string, 0, 3)
  22940. if m.wx_wxid != nil {
  22941. fields = append(fields, message.FieldWxWxid)
  22942. }
  22943. if m.wxid != nil {
  22944. fields = append(fields, message.FieldWxid)
  22945. }
  22946. if m.content != nil {
  22947. fields = append(fields, message.FieldContent)
  22948. }
  22949. return fields
  22950. }
  22951. // Field returns the value of a field with the given name. The second boolean
  22952. // return value indicates that this field was not set, or was not defined in the
  22953. // schema.
  22954. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  22955. switch name {
  22956. case message.FieldWxWxid:
  22957. return m.WxWxid()
  22958. case message.FieldWxid:
  22959. return m.Wxid()
  22960. case message.FieldContent:
  22961. return m.Content()
  22962. }
  22963. return nil, false
  22964. }
  22965. // OldField returns the old value of the field from the database. An error is
  22966. // returned if the mutation operation is not UpdateOne, or the query to the
  22967. // database failed.
  22968. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22969. switch name {
  22970. case message.FieldWxWxid:
  22971. return m.OldWxWxid(ctx)
  22972. case message.FieldWxid:
  22973. return m.OldWxid(ctx)
  22974. case message.FieldContent:
  22975. return m.OldContent(ctx)
  22976. }
  22977. return nil, fmt.Errorf("unknown Message field %s", name)
  22978. }
  22979. // SetField sets the value of a field with the given name. It returns an error if
  22980. // the field is not defined in the schema, or if the type mismatched the field
  22981. // type.
  22982. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  22983. switch name {
  22984. case message.FieldWxWxid:
  22985. v, ok := value.(string)
  22986. if !ok {
  22987. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22988. }
  22989. m.SetWxWxid(v)
  22990. return nil
  22991. case message.FieldWxid:
  22992. v, ok := value.(string)
  22993. if !ok {
  22994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22995. }
  22996. m.SetWxid(v)
  22997. return nil
  22998. case message.FieldContent:
  22999. v, ok := value.(string)
  23000. if !ok {
  23001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23002. }
  23003. m.SetContent(v)
  23004. return nil
  23005. }
  23006. return fmt.Errorf("unknown Message field %s", name)
  23007. }
  23008. // AddedFields returns all numeric fields that were incremented/decremented during
  23009. // this mutation.
  23010. func (m *MessageMutation) AddedFields() []string {
  23011. return nil
  23012. }
  23013. // AddedField returns the numeric value that was incremented/decremented on a field
  23014. // with the given name. The second boolean return value indicates that this field
  23015. // was not set, or was not defined in the schema.
  23016. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  23017. return nil, false
  23018. }
  23019. // AddField adds the value to the field with the given name. It returns an error if
  23020. // the field is not defined in the schema, or if the type mismatched the field
  23021. // type.
  23022. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  23023. switch name {
  23024. }
  23025. return fmt.Errorf("unknown Message numeric field %s", name)
  23026. }
  23027. // ClearedFields returns all nullable fields that were cleared during this
  23028. // mutation.
  23029. func (m *MessageMutation) ClearedFields() []string {
  23030. var fields []string
  23031. if m.FieldCleared(message.FieldWxWxid) {
  23032. fields = append(fields, message.FieldWxWxid)
  23033. }
  23034. return fields
  23035. }
  23036. // FieldCleared returns a boolean indicating if a field with the given name was
  23037. // cleared in this mutation.
  23038. func (m *MessageMutation) FieldCleared(name string) bool {
  23039. _, ok := m.clearedFields[name]
  23040. return ok
  23041. }
  23042. // ClearField clears the value of the field with the given name. It returns an
  23043. // error if the field is not defined in the schema.
  23044. func (m *MessageMutation) ClearField(name string) error {
  23045. switch name {
  23046. case message.FieldWxWxid:
  23047. m.ClearWxWxid()
  23048. return nil
  23049. }
  23050. return fmt.Errorf("unknown Message nullable field %s", name)
  23051. }
  23052. // ResetField resets all changes in the mutation for the field with the given name.
  23053. // It returns an error if the field is not defined in the schema.
  23054. func (m *MessageMutation) ResetField(name string) error {
  23055. switch name {
  23056. case message.FieldWxWxid:
  23057. m.ResetWxWxid()
  23058. return nil
  23059. case message.FieldWxid:
  23060. m.ResetWxid()
  23061. return nil
  23062. case message.FieldContent:
  23063. m.ResetContent()
  23064. return nil
  23065. }
  23066. return fmt.Errorf("unknown Message field %s", name)
  23067. }
  23068. // AddedEdges returns all edge names that were set/added in this mutation.
  23069. func (m *MessageMutation) AddedEdges() []string {
  23070. edges := make([]string, 0, 0)
  23071. return edges
  23072. }
  23073. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23074. // name in this mutation.
  23075. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  23076. return nil
  23077. }
  23078. // RemovedEdges returns all edge names that were removed in this mutation.
  23079. func (m *MessageMutation) RemovedEdges() []string {
  23080. edges := make([]string, 0, 0)
  23081. return edges
  23082. }
  23083. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23084. // the given name in this mutation.
  23085. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  23086. return nil
  23087. }
  23088. // ClearedEdges returns all edge names that were cleared in this mutation.
  23089. func (m *MessageMutation) ClearedEdges() []string {
  23090. edges := make([]string, 0, 0)
  23091. return edges
  23092. }
  23093. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23094. // was cleared in this mutation.
  23095. func (m *MessageMutation) EdgeCleared(name string) bool {
  23096. return false
  23097. }
  23098. // ClearEdge clears the value of the edge with the given name. It returns an error
  23099. // if that edge is not defined in the schema.
  23100. func (m *MessageMutation) ClearEdge(name string) error {
  23101. return fmt.Errorf("unknown Message unique edge %s", name)
  23102. }
  23103. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23104. // It returns an error if the edge is not defined in the schema.
  23105. func (m *MessageMutation) ResetEdge(name string) error {
  23106. return fmt.Errorf("unknown Message edge %s", name)
  23107. }
  23108. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  23109. type MessageRecordsMutation struct {
  23110. config
  23111. op Op
  23112. typ string
  23113. id *uint64
  23114. created_at *time.Time
  23115. updated_at *time.Time
  23116. status *uint8
  23117. addstatus *int8
  23118. bot_wxid *string
  23119. contact_type *int
  23120. addcontact_type *int
  23121. contact_wxid *string
  23122. content_type *int
  23123. addcontent_type *int
  23124. content *string
  23125. meta *custom_types.Meta
  23126. error_detail *string
  23127. send_time *time.Time
  23128. source_type *int
  23129. addsource_type *int
  23130. organization_id *uint64
  23131. addorganization_id *int64
  23132. clearedFields map[string]struct{}
  23133. sop_stage *uint64
  23134. clearedsop_stage bool
  23135. sop_node *uint64
  23136. clearedsop_node bool
  23137. message_contact *uint64
  23138. clearedmessage_contact bool
  23139. done bool
  23140. oldValue func(context.Context) (*MessageRecords, error)
  23141. predicates []predicate.MessageRecords
  23142. }
  23143. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  23144. // messagerecordsOption allows management of the mutation configuration using functional options.
  23145. type messagerecordsOption func(*MessageRecordsMutation)
  23146. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  23147. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  23148. m := &MessageRecordsMutation{
  23149. config: c,
  23150. op: op,
  23151. typ: TypeMessageRecords,
  23152. clearedFields: make(map[string]struct{}),
  23153. }
  23154. for _, opt := range opts {
  23155. opt(m)
  23156. }
  23157. return m
  23158. }
  23159. // withMessageRecordsID sets the ID field of the mutation.
  23160. func withMessageRecordsID(id uint64) messagerecordsOption {
  23161. return func(m *MessageRecordsMutation) {
  23162. var (
  23163. err error
  23164. once sync.Once
  23165. value *MessageRecords
  23166. )
  23167. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  23168. once.Do(func() {
  23169. if m.done {
  23170. err = errors.New("querying old values post mutation is not allowed")
  23171. } else {
  23172. value, err = m.Client().MessageRecords.Get(ctx, id)
  23173. }
  23174. })
  23175. return value, err
  23176. }
  23177. m.id = &id
  23178. }
  23179. }
  23180. // withMessageRecords sets the old MessageRecords of the mutation.
  23181. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  23182. return func(m *MessageRecordsMutation) {
  23183. m.oldValue = func(context.Context) (*MessageRecords, error) {
  23184. return node, nil
  23185. }
  23186. m.id = &node.ID
  23187. }
  23188. }
  23189. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23190. // executed in a transaction (ent.Tx), a transactional client is returned.
  23191. func (m MessageRecordsMutation) Client() *Client {
  23192. client := &Client{config: m.config}
  23193. client.init()
  23194. return client
  23195. }
  23196. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23197. // it returns an error otherwise.
  23198. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  23199. if _, ok := m.driver.(*txDriver); !ok {
  23200. return nil, errors.New("ent: mutation is not running in a transaction")
  23201. }
  23202. tx := &Tx{config: m.config}
  23203. tx.init()
  23204. return tx, nil
  23205. }
  23206. // SetID sets the value of the id field. Note that this
  23207. // operation is only accepted on creation of MessageRecords entities.
  23208. func (m *MessageRecordsMutation) SetID(id uint64) {
  23209. m.id = &id
  23210. }
  23211. // ID returns the ID value in the mutation. Note that the ID is only available
  23212. // if it was provided to the builder or after it was returned from the database.
  23213. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  23214. if m.id == nil {
  23215. return
  23216. }
  23217. return *m.id, true
  23218. }
  23219. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23220. // That means, if the mutation is applied within a transaction with an isolation level such
  23221. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23222. // or updated by the mutation.
  23223. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  23224. switch {
  23225. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23226. id, exists := m.ID()
  23227. if exists {
  23228. return []uint64{id}, nil
  23229. }
  23230. fallthrough
  23231. case m.op.Is(OpUpdate | OpDelete):
  23232. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  23233. default:
  23234. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23235. }
  23236. }
  23237. // SetCreatedAt sets the "created_at" field.
  23238. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  23239. m.created_at = &t
  23240. }
  23241. // CreatedAt returns the value of the "created_at" field in the mutation.
  23242. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  23243. v := m.created_at
  23244. if v == nil {
  23245. return
  23246. }
  23247. return *v, true
  23248. }
  23249. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  23250. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  23251. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23252. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23253. if !m.op.Is(OpUpdateOne) {
  23254. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23255. }
  23256. if m.id == nil || m.oldValue == nil {
  23257. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23258. }
  23259. oldValue, err := m.oldValue(ctx)
  23260. if err != nil {
  23261. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23262. }
  23263. return oldValue.CreatedAt, nil
  23264. }
  23265. // ResetCreatedAt resets all changes to the "created_at" field.
  23266. func (m *MessageRecordsMutation) ResetCreatedAt() {
  23267. m.created_at = nil
  23268. }
  23269. // SetUpdatedAt sets the "updated_at" field.
  23270. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  23271. m.updated_at = &t
  23272. }
  23273. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23274. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  23275. v := m.updated_at
  23276. if v == nil {
  23277. return
  23278. }
  23279. return *v, true
  23280. }
  23281. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  23282. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  23283. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23284. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23285. if !m.op.Is(OpUpdateOne) {
  23286. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23287. }
  23288. if m.id == nil || m.oldValue == nil {
  23289. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23290. }
  23291. oldValue, err := m.oldValue(ctx)
  23292. if err != nil {
  23293. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23294. }
  23295. return oldValue.UpdatedAt, nil
  23296. }
  23297. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23298. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  23299. m.updated_at = nil
  23300. }
  23301. // SetStatus sets the "status" field.
  23302. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  23303. m.status = &u
  23304. m.addstatus = nil
  23305. }
  23306. // Status returns the value of the "status" field in the mutation.
  23307. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  23308. v := m.status
  23309. if v == nil {
  23310. return
  23311. }
  23312. return *v, true
  23313. }
  23314. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  23315. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  23316. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23317. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23318. if !m.op.Is(OpUpdateOne) {
  23319. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23320. }
  23321. if m.id == nil || m.oldValue == nil {
  23322. return v, errors.New("OldStatus requires an ID field in the mutation")
  23323. }
  23324. oldValue, err := m.oldValue(ctx)
  23325. if err != nil {
  23326. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23327. }
  23328. return oldValue.Status, nil
  23329. }
  23330. // AddStatus adds u to the "status" field.
  23331. func (m *MessageRecordsMutation) AddStatus(u int8) {
  23332. if m.addstatus != nil {
  23333. *m.addstatus += u
  23334. } else {
  23335. m.addstatus = &u
  23336. }
  23337. }
  23338. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23339. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  23340. v := m.addstatus
  23341. if v == nil {
  23342. return
  23343. }
  23344. return *v, true
  23345. }
  23346. // ClearStatus clears the value of the "status" field.
  23347. func (m *MessageRecordsMutation) ClearStatus() {
  23348. m.status = nil
  23349. m.addstatus = nil
  23350. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  23351. }
  23352. // StatusCleared returns if the "status" field was cleared in this mutation.
  23353. func (m *MessageRecordsMutation) StatusCleared() bool {
  23354. _, ok := m.clearedFields[messagerecords.FieldStatus]
  23355. return ok
  23356. }
  23357. // ResetStatus resets all changes to the "status" field.
  23358. func (m *MessageRecordsMutation) ResetStatus() {
  23359. m.status = nil
  23360. m.addstatus = nil
  23361. delete(m.clearedFields, messagerecords.FieldStatus)
  23362. }
  23363. // SetBotWxid sets the "bot_wxid" field.
  23364. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  23365. m.bot_wxid = &s
  23366. }
  23367. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  23368. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  23369. v := m.bot_wxid
  23370. if v == nil {
  23371. return
  23372. }
  23373. return *v, true
  23374. }
  23375. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  23376. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  23377. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23378. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  23379. if !m.op.Is(OpUpdateOne) {
  23380. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  23381. }
  23382. if m.id == nil || m.oldValue == nil {
  23383. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  23384. }
  23385. oldValue, err := m.oldValue(ctx)
  23386. if err != nil {
  23387. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  23388. }
  23389. return oldValue.BotWxid, nil
  23390. }
  23391. // ResetBotWxid resets all changes to the "bot_wxid" field.
  23392. func (m *MessageRecordsMutation) ResetBotWxid() {
  23393. m.bot_wxid = nil
  23394. }
  23395. // SetContactID sets the "contact_id" field.
  23396. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  23397. m.message_contact = &u
  23398. }
  23399. // ContactID returns the value of the "contact_id" field in the mutation.
  23400. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  23401. v := m.message_contact
  23402. if v == nil {
  23403. return
  23404. }
  23405. return *v, true
  23406. }
  23407. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  23408. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  23409. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23410. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  23411. if !m.op.Is(OpUpdateOne) {
  23412. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  23413. }
  23414. if m.id == nil || m.oldValue == nil {
  23415. return v, errors.New("OldContactID requires an ID field in the mutation")
  23416. }
  23417. oldValue, err := m.oldValue(ctx)
  23418. if err != nil {
  23419. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  23420. }
  23421. return oldValue.ContactID, nil
  23422. }
  23423. // ClearContactID clears the value of the "contact_id" field.
  23424. func (m *MessageRecordsMutation) ClearContactID() {
  23425. m.message_contact = nil
  23426. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  23427. }
  23428. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  23429. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  23430. _, ok := m.clearedFields[messagerecords.FieldContactID]
  23431. return ok
  23432. }
  23433. // ResetContactID resets all changes to the "contact_id" field.
  23434. func (m *MessageRecordsMutation) ResetContactID() {
  23435. m.message_contact = nil
  23436. delete(m.clearedFields, messagerecords.FieldContactID)
  23437. }
  23438. // SetContactType sets the "contact_type" field.
  23439. func (m *MessageRecordsMutation) SetContactType(i int) {
  23440. m.contact_type = &i
  23441. m.addcontact_type = nil
  23442. }
  23443. // ContactType returns the value of the "contact_type" field in the mutation.
  23444. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  23445. v := m.contact_type
  23446. if v == nil {
  23447. return
  23448. }
  23449. return *v, true
  23450. }
  23451. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  23452. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  23453. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23454. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  23455. if !m.op.Is(OpUpdateOne) {
  23456. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  23457. }
  23458. if m.id == nil || m.oldValue == nil {
  23459. return v, errors.New("OldContactType requires an ID field in the mutation")
  23460. }
  23461. oldValue, err := m.oldValue(ctx)
  23462. if err != nil {
  23463. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  23464. }
  23465. return oldValue.ContactType, nil
  23466. }
  23467. // AddContactType adds i to the "contact_type" field.
  23468. func (m *MessageRecordsMutation) AddContactType(i int) {
  23469. if m.addcontact_type != nil {
  23470. *m.addcontact_type += i
  23471. } else {
  23472. m.addcontact_type = &i
  23473. }
  23474. }
  23475. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  23476. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  23477. v := m.addcontact_type
  23478. if v == nil {
  23479. return
  23480. }
  23481. return *v, true
  23482. }
  23483. // ResetContactType resets all changes to the "contact_type" field.
  23484. func (m *MessageRecordsMutation) ResetContactType() {
  23485. m.contact_type = nil
  23486. m.addcontact_type = nil
  23487. }
  23488. // SetContactWxid sets the "contact_wxid" field.
  23489. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  23490. m.contact_wxid = &s
  23491. }
  23492. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  23493. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  23494. v := m.contact_wxid
  23495. if v == nil {
  23496. return
  23497. }
  23498. return *v, true
  23499. }
  23500. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  23501. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  23502. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23503. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  23504. if !m.op.Is(OpUpdateOne) {
  23505. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  23506. }
  23507. if m.id == nil || m.oldValue == nil {
  23508. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  23509. }
  23510. oldValue, err := m.oldValue(ctx)
  23511. if err != nil {
  23512. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  23513. }
  23514. return oldValue.ContactWxid, nil
  23515. }
  23516. // ResetContactWxid resets all changes to the "contact_wxid" field.
  23517. func (m *MessageRecordsMutation) ResetContactWxid() {
  23518. m.contact_wxid = nil
  23519. }
  23520. // SetContentType sets the "content_type" field.
  23521. func (m *MessageRecordsMutation) SetContentType(i int) {
  23522. m.content_type = &i
  23523. m.addcontent_type = nil
  23524. }
  23525. // ContentType returns the value of the "content_type" field in the mutation.
  23526. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  23527. v := m.content_type
  23528. if v == nil {
  23529. return
  23530. }
  23531. return *v, true
  23532. }
  23533. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  23534. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  23535. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23536. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  23537. if !m.op.Is(OpUpdateOne) {
  23538. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  23539. }
  23540. if m.id == nil || m.oldValue == nil {
  23541. return v, errors.New("OldContentType requires an ID field in the mutation")
  23542. }
  23543. oldValue, err := m.oldValue(ctx)
  23544. if err != nil {
  23545. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  23546. }
  23547. return oldValue.ContentType, nil
  23548. }
  23549. // AddContentType adds i to the "content_type" field.
  23550. func (m *MessageRecordsMutation) AddContentType(i int) {
  23551. if m.addcontent_type != nil {
  23552. *m.addcontent_type += i
  23553. } else {
  23554. m.addcontent_type = &i
  23555. }
  23556. }
  23557. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  23558. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  23559. v := m.addcontent_type
  23560. if v == nil {
  23561. return
  23562. }
  23563. return *v, true
  23564. }
  23565. // ResetContentType resets all changes to the "content_type" field.
  23566. func (m *MessageRecordsMutation) ResetContentType() {
  23567. m.content_type = nil
  23568. m.addcontent_type = nil
  23569. }
  23570. // SetContent sets the "content" field.
  23571. func (m *MessageRecordsMutation) SetContent(s string) {
  23572. m.content = &s
  23573. }
  23574. // Content returns the value of the "content" field in the mutation.
  23575. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  23576. v := m.content
  23577. if v == nil {
  23578. return
  23579. }
  23580. return *v, true
  23581. }
  23582. // OldContent returns the old "content" field's value of the MessageRecords entity.
  23583. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  23584. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23585. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  23586. if !m.op.Is(OpUpdateOne) {
  23587. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  23588. }
  23589. if m.id == nil || m.oldValue == nil {
  23590. return v, errors.New("OldContent requires an ID field in the mutation")
  23591. }
  23592. oldValue, err := m.oldValue(ctx)
  23593. if err != nil {
  23594. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  23595. }
  23596. return oldValue.Content, nil
  23597. }
  23598. // ResetContent resets all changes to the "content" field.
  23599. func (m *MessageRecordsMutation) ResetContent() {
  23600. m.content = nil
  23601. }
  23602. // SetMeta sets the "meta" field.
  23603. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  23604. m.meta = &ct
  23605. }
  23606. // Meta returns the value of the "meta" field in the mutation.
  23607. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  23608. v := m.meta
  23609. if v == nil {
  23610. return
  23611. }
  23612. return *v, true
  23613. }
  23614. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  23615. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  23616. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23617. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  23618. if !m.op.Is(OpUpdateOne) {
  23619. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  23620. }
  23621. if m.id == nil || m.oldValue == nil {
  23622. return v, errors.New("OldMeta requires an ID field in the mutation")
  23623. }
  23624. oldValue, err := m.oldValue(ctx)
  23625. if err != nil {
  23626. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  23627. }
  23628. return oldValue.Meta, nil
  23629. }
  23630. // ClearMeta clears the value of the "meta" field.
  23631. func (m *MessageRecordsMutation) ClearMeta() {
  23632. m.meta = nil
  23633. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  23634. }
  23635. // MetaCleared returns if the "meta" field was cleared in this mutation.
  23636. func (m *MessageRecordsMutation) MetaCleared() bool {
  23637. _, ok := m.clearedFields[messagerecords.FieldMeta]
  23638. return ok
  23639. }
  23640. // ResetMeta resets all changes to the "meta" field.
  23641. func (m *MessageRecordsMutation) ResetMeta() {
  23642. m.meta = nil
  23643. delete(m.clearedFields, messagerecords.FieldMeta)
  23644. }
  23645. // SetErrorDetail sets the "error_detail" field.
  23646. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  23647. m.error_detail = &s
  23648. }
  23649. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  23650. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  23651. v := m.error_detail
  23652. if v == nil {
  23653. return
  23654. }
  23655. return *v, true
  23656. }
  23657. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  23658. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  23659. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23660. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  23661. if !m.op.Is(OpUpdateOne) {
  23662. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  23663. }
  23664. if m.id == nil || m.oldValue == nil {
  23665. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  23666. }
  23667. oldValue, err := m.oldValue(ctx)
  23668. if err != nil {
  23669. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  23670. }
  23671. return oldValue.ErrorDetail, nil
  23672. }
  23673. // ResetErrorDetail resets all changes to the "error_detail" field.
  23674. func (m *MessageRecordsMutation) ResetErrorDetail() {
  23675. m.error_detail = nil
  23676. }
  23677. // SetSendTime sets the "send_time" field.
  23678. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  23679. m.send_time = &t
  23680. }
  23681. // SendTime returns the value of the "send_time" field in the mutation.
  23682. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  23683. v := m.send_time
  23684. if v == nil {
  23685. return
  23686. }
  23687. return *v, true
  23688. }
  23689. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  23690. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  23691. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23692. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  23693. if !m.op.Is(OpUpdateOne) {
  23694. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  23695. }
  23696. if m.id == nil || m.oldValue == nil {
  23697. return v, errors.New("OldSendTime requires an ID field in the mutation")
  23698. }
  23699. oldValue, err := m.oldValue(ctx)
  23700. if err != nil {
  23701. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  23702. }
  23703. return oldValue.SendTime, nil
  23704. }
  23705. // ClearSendTime clears the value of the "send_time" field.
  23706. func (m *MessageRecordsMutation) ClearSendTime() {
  23707. m.send_time = nil
  23708. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  23709. }
  23710. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  23711. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  23712. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  23713. return ok
  23714. }
  23715. // ResetSendTime resets all changes to the "send_time" field.
  23716. func (m *MessageRecordsMutation) ResetSendTime() {
  23717. m.send_time = nil
  23718. delete(m.clearedFields, messagerecords.FieldSendTime)
  23719. }
  23720. // SetSourceType sets the "source_type" field.
  23721. func (m *MessageRecordsMutation) SetSourceType(i int) {
  23722. m.source_type = &i
  23723. m.addsource_type = nil
  23724. }
  23725. // SourceType returns the value of the "source_type" field in the mutation.
  23726. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  23727. v := m.source_type
  23728. if v == nil {
  23729. return
  23730. }
  23731. return *v, true
  23732. }
  23733. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  23734. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  23735. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23736. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  23737. if !m.op.Is(OpUpdateOne) {
  23738. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  23739. }
  23740. if m.id == nil || m.oldValue == nil {
  23741. return v, errors.New("OldSourceType requires an ID field in the mutation")
  23742. }
  23743. oldValue, err := m.oldValue(ctx)
  23744. if err != nil {
  23745. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  23746. }
  23747. return oldValue.SourceType, nil
  23748. }
  23749. // AddSourceType adds i to the "source_type" field.
  23750. func (m *MessageRecordsMutation) AddSourceType(i int) {
  23751. if m.addsource_type != nil {
  23752. *m.addsource_type += i
  23753. } else {
  23754. m.addsource_type = &i
  23755. }
  23756. }
  23757. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  23758. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  23759. v := m.addsource_type
  23760. if v == nil {
  23761. return
  23762. }
  23763. return *v, true
  23764. }
  23765. // ResetSourceType resets all changes to the "source_type" field.
  23766. func (m *MessageRecordsMutation) ResetSourceType() {
  23767. m.source_type = nil
  23768. m.addsource_type = nil
  23769. }
  23770. // SetSourceID sets the "source_id" field.
  23771. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  23772. m.sop_stage = &u
  23773. }
  23774. // SourceID returns the value of the "source_id" field in the mutation.
  23775. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  23776. v := m.sop_stage
  23777. if v == nil {
  23778. return
  23779. }
  23780. return *v, true
  23781. }
  23782. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  23783. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  23784. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23785. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  23786. if !m.op.Is(OpUpdateOne) {
  23787. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  23788. }
  23789. if m.id == nil || m.oldValue == nil {
  23790. return v, errors.New("OldSourceID requires an ID field in the mutation")
  23791. }
  23792. oldValue, err := m.oldValue(ctx)
  23793. if err != nil {
  23794. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  23795. }
  23796. return oldValue.SourceID, nil
  23797. }
  23798. // ClearSourceID clears the value of the "source_id" field.
  23799. func (m *MessageRecordsMutation) ClearSourceID() {
  23800. m.sop_stage = nil
  23801. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  23802. }
  23803. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  23804. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  23805. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  23806. return ok
  23807. }
  23808. // ResetSourceID resets all changes to the "source_id" field.
  23809. func (m *MessageRecordsMutation) ResetSourceID() {
  23810. m.sop_stage = nil
  23811. delete(m.clearedFields, messagerecords.FieldSourceID)
  23812. }
  23813. // SetSubSourceID sets the "sub_source_id" field.
  23814. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  23815. m.sop_node = &u
  23816. }
  23817. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  23818. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  23819. v := m.sop_node
  23820. if v == nil {
  23821. return
  23822. }
  23823. return *v, true
  23824. }
  23825. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  23826. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  23827. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23828. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  23829. if !m.op.Is(OpUpdateOne) {
  23830. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  23831. }
  23832. if m.id == nil || m.oldValue == nil {
  23833. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  23834. }
  23835. oldValue, err := m.oldValue(ctx)
  23836. if err != nil {
  23837. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  23838. }
  23839. return oldValue.SubSourceID, nil
  23840. }
  23841. // ClearSubSourceID clears the value of the "sub_source_id" field.
  23842. func (m *MessageRecordsMutation) ClearSubSourceID() {
  23843. m.sop_node = nil
  23844. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  23845. }
  23846. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  23847. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  23848. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  23849. return ok
  23850. }
  23851. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  23852. func (m *MessageRecordsMutation) ResetSubSourceID() {
  23853. m.sop_node = nil
  23854. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  23855. }
  23856. // SetOrganizationID sets the "organization_id" field.
  23857. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  23858. m.organization_id = &u
  23859. m.addorganization_id = nil
  23860. }
  23861. // OrganizationID returns the value of the "organization_id" field in the mutation.
  23862. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  23863. v := m.organization_id
  23864. if v == nil {
  23865. return
  23866. }
  23867. return *v, true
  23868. }
  23869. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  23870. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  23871. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23872. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  23873. if !m.op.Is(OpUpdateOne) {
  23874. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  23875. }
  23876. if m.id == nil || m.oldValue == nil {
  23877. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  23878. }
  23879. oldValue, err := m.oldValue(ctx)
  23880. if err != nil {
  23881. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  23882. }
  23883. return oldValue.OrganizationID, nil
  23884. }
  23885. // AddOrganizationID adds u to the "organization_id" field.
  23886. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  23887. if m.addorganization_id != nil {
  23888. *m.addorganization_id += u
  23889. } else {
  23890. m.addorganization_id = &u
  23891. }
  23892. }
  23893. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  23894. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  23895. v := m.addorganization_id
  23896. if v == nil {
  23897. return
  23898. }
  23899. return *v, true
  23900. }
  23901. // ClearOrganizationID clears the value of the "organization_id" field.
  23902. func (m *MessageRecordsMutation) ClearOrganizationID() {
  23903. m.organization_id = nil
  23904. m.addorganization_id = nil
  23905. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  23906. }
  23907. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  23908. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  23909. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  23910. return ok
  23911. }
  23912. // ResetOrganizationID resets all changes to the "organization_id" field.
  23913. func (m *MessageRecordsMutation) ResetOrganizationID() {
  23914. m.organization_id = nil
  23915. m.addorganization_id = nil
  23916. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  23917. }
  23918. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  23919. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  23920. m.sop_stage = &id
  23921. }
  23922. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  23923. func (m *MessageRecordsMutation) ClearSopStage() {
  23924. m.clearedsop_stage = true
  23925. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  23926. }
  23927. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  23928. func (m *MessageRecordsMutation) SopStageCleared() bool {
  23929. return m.SourceIDCleared() || m.clearedsop_stage
  23930. }
  23931. // SopStageID returns the "sop_stage" edge ID in the mutation.
  23932. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  23933. if m.sop_stage != nil {
  23934. return *m.sop_stage, true
  23935. }
  23936. return
  23937. }
  23938. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  23939. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  23940. // SopStageID instead. It exists only for internal usage by the builders.
  23941. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  23942. if id := m.sop_stage; id != nil {
  23943. ids = append(ids, *id)
  23944. }
  23945. return
  23946. }
  23947. // ResetSopStage resets all changes to the "sop_stage" edge.
  23948. func (m *MessageRecordsMutation) ResetSopStage() {
  23949. m.sop_stage = nil
  23950. m.clearedsop_stage = false
  23951. }
  23952. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  23953. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  23954. m.sop_node = &id
  23955. }
  23956. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  23957. func (m *MessageRecordsMutation) ClearSopNode() {
  23958. m.clearedsop_node = true
  23959. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  23960. }
  23961. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  23962. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  23963. return m.SubSourceIDCleared() || m.clearedsop_node
  23964. }
  23965. // SopNodeID returns the "sop_node" edge ID in the mutation.
  23966. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  23967. if m.sop_node != nil {
  23968. return *m.sop_node, true
  23969. }
  23970. return
  23971. }
  23972. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  23973. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  23974. // SopNodeID instead. It exists only for internal usage by the builders.
  23975. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  23976. if id := m.sop_node; id != nil {
  23977. ids = append(ids, *id)
  23978. }
  23979. return
  23980. }
  23981. // ResetSopNode resets all changes to the "sop_node" edge.
  23982. func (m *MessageRecordsMutation) ResetSopNode() {
  23983. m.sop_node = nil
  23984. m.clearedsop_node = false
  23985. }
  23986. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  23987. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  23988. m.message_contact = &id
  23989. }
  23990. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  23991. func (m *MessageRecordsMutation) ClearMessageContact() {
  23992. m.clearedmessage_contact = true
  23993. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  23994. }
  23995. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  23996. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  23997. return m.ContactIDCleared() || m.clearedmessage_contact
  23998. }
  23999. // MessageContactID returns the "message_contact" edge ID in the mutation.
  24000. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  24001. if m.message_contact != nil {
  24002. return *m.message_contact, true
  24003. }
  24004. return
  24005. }
  24006. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  24007. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  24008. // MessageContactID instead. It exists only for internal usage by the builders.
  24009. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  24010. if id := m.message_contact; id != nil {
  24011. ids = append(ids, *id)
  24012. }
  24013. return
  24014. }
  24015. // ResetMessageContact resets all changes to the "message_contact" edge.
  24016. func (m *MessageRecordsMutation) ResetMessageContact() {
  24017. m.message_contact = nil
  24018. m.clearedmessage_contact = false
  24019. }
  24020. // Where appends a list predicates to the MessageRecordsMutation builder.
  24021. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  24022. m.predicates = append(m.predicates, ps...)
  24023. }
  24024. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  24025. // users can use type-assertion to append predicates that do not depend on any generated package.
  24026. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  24027. p := make([]predicate.MessageRecords, len(ps))
  24028. for i := range ps {
  24029. p[i] = ps[i]
  24030. }
  24031. m.Where(p...)
  24032. }
  24033. // Op returns the operation name.
  24034. func (m *MessageRecordsMutation) Op() Op {
  24035. return m.op
  24036. }
  24037. // SetOp allows setting the mutation operation.
  24038. func (m *MessageRecordsMutation) SetOp(op Op) {
  24039. m.op = op
  24040. }
  24041. // Type returns the node type of this mutation (MessageRecords).
  24042. func (m *MessageRecordsMutation) Type() string {
  24043. return m.typ
  24044. }
  24045. // Fields returns all fields that were changed during this mutation. Note that in
  24046. // order to get all numeric fields that were incremented/decremented, call
  24047. // AddedFields().
  24048. func (m *MessageRecordsMutation) Fields() []string {
  24049. fields := make([]string, 0, 16)
  24050. if m.created_at != nil {
  24051. fields = append(fields, messagerecords.FieldCreatedAt)
  24052. }
  24053. if m.updated_at != nil {
  24054. fields = append(fields, messagerecords.FieldUpdatedAt)
  24055. }
  24056. if m.status != nil {
  24057. fields = append(fields, messagerecords.FieldStatus)
  24058. }
  24059. if m.bot_wxid != nil {
  24060. fields = append(fields, messagerecords.FieldBotWxid)
  24061. }
  24062. if m.message_contact != nil {
  24063. fields = append(fields, messagerecords.FieldContactID)
  24064. }
  24065. if m.contact_type != nil {
  24066. fields = append(fields, messagerecords.FieldContactType)
  24067. }
  24068. if m.contact_wxid != nil {
  24069. fields = append(fields, messagerecords.FieldContactWxid)
  24070. }
  24071. if m.content_type != nil {
  24072. fields = append(fields, messagerecords.FieldContentType)
  24073. }
  24074. if m.content != nil {
  24075. fields = append(fields, messagerecords.FieldContent)
  24076. }
  24077. if m.meta != nil {
  24078. fields = append(fields, messagerecords.FieldMeta)
  24079. }
  24080. if m.error_detail != nil {
  24081. fields = append(fields, messagerecords.FieldErrorDetail)
  24082. }
  24083. if m.send_time != nil {
  24084. fields = append(fields, messagerecords.FieldSendTime)
  24085. }
  24086. if m.source_type != nil {
  24087. fields = append(fields, messagerecords.FieldSourceType)
  24088. }
  24089. if m.sop_stage != nil {
  24090. fields = append(fields, messagerecords.FieldSourceID)
  24091. }
  24092. if m.sop_node != nil {
  24093. fields = append(fields, messagerecords.FieldSubSourceID)
  24094. }
  24095. if m.organization_id != nil {
  24096. fields = append(fields, messagerecords.FieldOrganizationID)
  24097. }
  24098. return fields
  24099. }
  24100. // Field returns the value of a field with the given name. The second boolean
  24101. // return value indicates that this field was not set, or was not defined in the
  24102. // schema.
  24103. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  24104. switch name {
  24105. case messagerecords.FieldCreatedAt:
  24106. return m.CreatedAt()
  24107. case messagerecords.FieldUpdatedAt:
  24108. return m.UpdatedAt()
  24109. case messagerecords.FieldStatus:
  24110. return m.Status()
  24111. case messagerecords.FieldBotWxid:
  24112. return m.BotWxid()
  24113. case messagerecords.FieldContactID:
  24114. return m.ContactID()
  24115. case messagerecords.FieldContactType:
  24116. return m.ContactType()
  24117. case messagerecords.FieldContactWxid:
  24118. return m.ContactWxid()
  24119. case messagerecords.FieldContentType:
  24120. return m.ContentType()
  24121. case messagerecords.FieldContent:
  24122. return m.Content()
  24123. case messagerecords.FieldMeta:
  24124. return m.Meta()
  24125. case messagerecords.FieldErrorDetail:
  24126. return m.ErrorDetail()
  24127. case messagerecords.FieldSendTime:
  24128. return m.SendTime()
  24129. case messagerecords.FieldSourceType:
  24130. return m.SourceType()
  24131. case messagerecords.FieldSourceID:
  24132. return m.SourceID()
  24133. case messagerecords.FieldSubSourceID:
  24134. return m.SubSourceID()
  24135. case messagerecords.FieldOrganizationID:
  24136. return m.OrganizationID()
  24137. }
  24138. return nil, false
  24139. }
  24140. // OldField returns the old value of the field from the database. An error is
  24141. // returned if the mutation operation is not UpdateOne, or the query to the
  24142. // database failed.
  24143. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24144. switch name {
  24145. case messagerecords.FieldCreatedAt:
  24146. return m.OldCreatedAt(ctx)
  24147. case messagerecords.FieldUpdatedAt:
  24148. return m.OldUpdatedAt(ctx)
  24149. case messagerecords.FieldStatus:
  24150. return m.OldStatus(ctx)
  24151. case messagerecords.FieldBotWxid:
  24152. return m.OldBotWxid(ctx)
  24153. case messagerecords.FieldContactID:
  24154. return m.OldContactID(ctx)
  24155. case messagerecords.FieldContactType:
  24156. return m.OldContactType(ctx)
  24157. case messagerecords.FieldContactWxid:
  24158. return m.OldContactWxid(ctx)
  24159. case messagerecords.FieldContentType:
  24160. return m.OldContentType(ctx)
  24161. case messagerecords.FieldContent:
  24162. return m.OldContent(ctx)
  24163. case messagerecords.FieldMeta:
  24164. return m.OldMeta(ctx)
  24165. case messagerecords.FieldErrorDetail:
  24166. return m.OldErrorDetail(ctx)
  24167. case messagerecords.FieldSendTime:
  24168. return m.OldSendTime(ctx)
  24169. case messagerecords.FieldSourceType:
  24170. return m.OldSourceType(ctx)
  24171. case messagerecords.FieldSourceID:
  24172. return m.OldSourceID(ctx)
  24173. case messagerecords.FieldSubSourceID:
  24174. return m.OldSubSourceID(ctx)
  24175. case messagerecords.FieldOrganizationID:
  24176. return m.OldOrganizationID(ctx)
  24177. }
  24178. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  24179. }
  24180. // SetField sets the value of a field with the given name. It returns an error if
  24181. // the field is not defined in the schema, or if the type mismatched the field
  24182. // type.
  24183. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  24184. switch name {
  24185. case messagerecords.FieldCreatedAt:
  24186. v, ok := value.(time.Time)
  24187. if !ok {
  24188. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24189. }
  24190. m.SetCreatedAt(v)
  24191. return nil
  24192. case messagerecords.FieldUpdatedAt:
  24193. v, ok := value.(time.Time)
  24194. if !ok {
  24195. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24196. }
  24197. m.SetUpdatedAt(v)
  24198. return nil
  24199. case messagerecords.FieldStatus:
  24200. v, ok := value.(uint8)
  24201. if !ok {
  24202. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24203. }
  24204. m.SetStatus(v)
  24205. return nil
  24206. case messagerecords.FieldBotWxid:
  24207. v, ok := value.(string)
  24208. if !ok {
  24209. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24210. }
  24211. m.SetBotWxid(v)
  24212. return nil
  24213. case messagerecords.FieldContactID:
  24214. v, ok := value.(uint64)
  24215. if !ok {
  24216. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24217. }
  24218. m.SetContactID(v)
  24219. return nil
  24220. case messagerecords.FieldContactType:
  24221. v, ok := value.(int)
  24222. if !ok {
  24223. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24224. }
  24225. m.SetContactType(v)
  24226. return nil
  24227. case messagerecords.FieldContactWxid:
  24228. v, ok := value.(string)
  24229. if !ok {
  24230. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24231. }
  24232. m.SetContactWxid(v)
  24233. return nil
  24234. case messagerecords.FieldContentType:
  24235. v, ok := value.(int)
  24236. if !ok {
  24237. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24238. }
  24239. m.SetContentType(v)
  24240. return nil
  24241. case messagerecords.FieldContent:
  24242. v, ok := value.(string)
  24243. if !ok {
  24244. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24245. }
  24246. m.SetContent(v)
  24247. return nil
  24248. case messagerecords.FieldMeta:
  24249. v, ok := value.(custom_types.Meta)
  24250. if !ok {
  24251. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24252. }
  24253. m.SetMeta(v)
  24254. return nil
  24255. case messagerecords.FieldErrorDetail:
  24256. v, ok := value.(string)
  24257. if !ok {
  24258. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24259. }
  24260. m.SetErrorDetail(v)
  24261. return nil
  24262. case messagerecords.FieldSendTime:
  24263. v, ok := value.(time.Time)
  24264. if !ok {
  24265. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24266. }
  24267. m.SetSendTime(v)
  24268. return nil
  24269. case messagerecords.FieldSourceType:
  24270. v, ok := value.(int)
  24271. if !ok {
  24272. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24273. }
  24274. m.SetSourceType(v)
  24275. return nil
  24276. case messagerecords.FieldSourceID:
  24277. v, ok := value.(uint64)
  24278. if !ok {
  24279. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24280. }
  24281. m.SetSourceID(v)
  24282. return nil
  24283. case messagerecords.FieldSubSourceID:
  24284. v, ok := value.(uint64)
  24285. if !ok {
  24286. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24287. }
  24288. m.SetSubSourceID(v)
  24289. return nil
  24290. case messagerecords.FieldOrganizationID:
  24291. v, ok := value.(uint64)
  24292. if !ok {
  24293. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24294. }
  24295. m.SetOrganizationID(v)
  24296. return nil
  24297. }
  24298. return fmt.Errorf("unknown MessageRecords field %s", name)
  24299. }
  24300. // AddedFields returns all numeric fields that were incremented/decremented during
  24301. // this mutation.
  24302. func (m *MessageRecordsMutation) AddedFields() []string {
  24303. var fields []string
  24304. if m.addstatus != nil {
  24305. fields = append(fields, messagerecords.FieldStatus)
  24306. }
  24307. if m.addcontact_type != nil {
  24308. fields = append(fields, messagerecords.FieldContactType)
  24309. }
  24310. if m.addcontent_type != nil {
  24311. fields = append(fields, messagerecords.FieldContentType)
  24312. }
  24313. if m.addsource_type != nil {
  24314. fields = append(fields, messagerecords.FieldSourceType)
  24315. }
  24316. if m.addorganization_id != nil {
  24317. fields = append(fields, messagerecords.FieldOrganizationID)
  24318. }
  24319. return fields
  24320. }
  24321. // AddedField returns the numeric value that was incremented/decremented on a field
  24322. // with the given name. The second boolean return value indicates that this field
  24323. // was not set, or was not defined in the schema.
  24324. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  24325. switch name {
  24326. case messagerecords.FieldStatus:
  24327. return m.AddedStatus()
  24328. case messagerecords.FieldContactType:
  24329. return m.AddedContactType()
  24330. case messagerecords.FieldContentType:
  24331. return m.AddedContentType()
  24332. case messagerecords.FieldSourceType:
  24333. return m.AddedSourceType()
  24334. case messagerecords.FieldOrganizationID:
  24335. return m.AddedOrganizationID()
  24336. }
  24337. return nil, false
  24338. }
  24339. // AddField adds the value to the field with the given name. It returns an error if
  24340. // the field is not defined in the schema, or if the type mismatched the field
  24341. // type.
  24342. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  24343. switch name {
  24344. case messagerecords.FieldStatus:
  24345. v, ok := value.(int8)
  24346. if !ok {
  24347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24348. }
  24349. m.AddStatus(v)
  24350. return nil
  24351. case messagerecords.FieldContactType:
  24352. v, ok := value.(int)
  24353. if !ok {
  24354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24355. }
  24356. m.AddContactType(v)
  24357. return nil
  24358. case messagerecords.FieldContentType:
  24359. v, ok := value.(int)
  24360. if !ok {
  24361. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24362. }
  24363. m.AddContentType(v)
  24364. return nil
  24365. case messagerecords.FieldSourceType:
  24366. v, ok := value.(int)
  24367. if !ok {
  24368. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24369. }
  24370. m.AddSourceType(v)
  24371. return nil
  24372. case messagerecords.FieldOrganizationID:
  24373. v, ok := value.(int64)
  24374. if !ok {
  24375. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24376. }
  24377. m.AddOrganizationID(v)
  24378. return nil
  24379. }
  24380. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  24381. }
  24382. // ClearedFields returns all nullable fields that were cleared during this
  24383. // mutation.
  24384. func (m *MessageRecordsMutation) ClearedFields() []string {
  24385. var fields []string
  24386. if m.FieldCleared(messagerecords.FieldStatus) {
  24387. fields = append(fields, messagerecords.FieldStatus)
  24388. }
  24389. if m.FieldCleared(messagerecords.FieldContactID) {
  24390. fields = append(fields, messagerecords.FieldContactID)
  24391. }
  24392. if m.FieldCleared(messagerecords.FieldMeta) {
  24393. fields = append(fields, messagerecords.FieldMeta)
  24394. }
  24395. if m.FieldCleared(messagerecords.FieldSendTime) {
  24396. fields = append(fields, messagerecords.FieldSendTime)
  24397. }
  24398. if m.FieldCleared(messagerecords.FieldSourceID) {
  24399. fields = append(fields, messagerecords.FieldSourceID)
  24400. }
  24401. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  24402. fields = append(fields, messagerecords.FieldSubSourceID)
  24403. }
  24404. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  24405. fields = append(fields, messagerecords.FieldOrganizationID)
  24406. }
  24407. return fields
  24408. }
  24409. // FieldCleared returns a boolean indicating if a field with the given name was
  24410. // cleared in this mutation.
  24411. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  24412. _, ok := m.clearedFields[name]
  24413. return ok
  24414. }
  24415. // ClearField clears the value of the field with the given name. It returns an
  24416. // error if the field is not defined in the schema.
  24417. func (m *MessageRecordsMutation) ClearField(name string) error {
  24418. switch name {
  24419. case messagerecords.FieldStatus:
  24420. m.ClearStatus()
  24421. return nil
  24422. case messagerecords.FieldContactID:
  24423. m.ClearContactID()
  24424. return nil
  24425. case messagerecords.FieldMeta:
  24426. m.ClearMeta()
  24427. return nil
  24428. case messagerecords.FieldSendTime:
  24429. m.ClearSendTime()
  24430. return nil
  24431. case messagerecords.FieldSourceID:
  24432. m.ClearSourceID()
  24433. return nil
  24434. case messagerecords.FieldSubSourceID:
  24435. m.ClearSubSourceID()
  24436. return nil
  24437. case messagerecords.FieldOrganizationID:
  24438. m.ClearOrganizationID()
  24439. return nil
  24440. }
  24441. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  24442. }
  24443. // ResetField resets all changes in the mutation for the field with the given name.
  24444. // It returns an error if the field is not defined in the schema.
  24445. func (m *MessageRecordsMutation) ResetField(name string) error {
  24446. switch name {
  24447. case messagerecords.FieldCreatedAt:
  24448. m.ResetCreatedAt()
  24449. return nil
  24450. case messagerecords.FieldUpdatedAt:
  24451. m.ResetUpdatedAt()
  24452. return nil
  24453. case messagerecords.FieldStatus:
  24454. m.ResetStatus()
  24455. return nil
  24456. case messagerecords.FieldBotWxid:
  24457. m.ResetBotWxid()
  24458. return nil
  24459. case messagerecords.FieldContactID:
  24460. m.ResetContactID()
  24461. return nil
  24462. case messagerecords.FieldContactType:
  24463. m.ResetContactType()
  24464. return nil
  24465. case messagerecords.FieldContactWxid:
  24466. m.ResetContactWxid()
  24467. return nil
  24468. case messagerecords.FieldContentType:
  24469. m.ResetContentType()
  24470. return nil
  24471. case messagerecords.FieldContent:
  24472. m.ResetContent()
  24473. return nil
  24474. case messagerecords.FieldMeta:
  24475. m.ResetMeta()
  24476. return nil
  24477. case messagerecords.FieldErrorDetail:
  24478. m.ResetErrorDetail()
  24479. return nil
  24480. case messagerecords.FieldSendTime:
  24481. m.ResetSendTime()
  24482. return nil
  24483. case messagerecords.FieldSourceType:
  24484. m.ResetSourceType()
  24485. return nil
  24486. case messagerecords.FieldSourceID:
  24487. m.ResetSourceID()
  24488. return nil
  24489. case messagerecords.FieldSubSourceID:
  24490. m.ResetSubSourceID()
  24491. return nil
  24492. case messagerecords.FieldOrganizationID:
  24493. m.ResetOrganizationID()
  24494. return nil
  24495. }
  24496. return fmt.Errorf("unknown MessageRecords field %s", name)
  24497. }
  24498. // AddedEdges returns all edge names that were set/added in this mutation.
  24499. func (m *MessageRecordsMutation) AddedEdges() []string {
  24500. edges := make([]string, 0, 3)
  24501. if m.sop_stage != nil {
  24502. edges = append(edges, messagerecords.EdgeSopStage)
  24503. }
  24504. if m.sop_node != nil {
  24505. edges = append(edges, messagerecords.EdgeSopNode)
  24506. }
  24507. if m.message_contact != nil {
  24508. edges = append(edges, messagerecords.EdgeMessageContact)
  24509. }
  24510. return edges
  24511. }
  24512. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24513. // name in this mutation.
  24514. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  24515. switch name {
  24516. case messagerecords.EdgeSopStage:
  24517. if id := m.sop_stage; id != nil {
  24518. return []ent.Value{*id}
  24519. }
  24520. case messagerecords.EdgeSopNode:
  24521. if id := m.sop_node; id != nil {
  24522. return []ent.Value{*id}
  24523. }
  24524. case messagerecords.EdgeMessageContact:
  24525. if id := m.message_contact; id != nil {
  24526. return []ent.Value{*id}
  24527. }
  24528. }
  24529. return nil
  24530. }
  24531. // RemovedEdges returns all edge names that were removed in this mutation.
  24532. func (m *MessageRecordsMutation) RemovedEdges() []string {
  24533. edges := make([]string, 0, 3)
  24534. return edges
  24535. }
  24536. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24537. // the given name in this mutation.
  24538. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  24539. return nil
  24540. }
  24541. // ClearedEdges returns all edge names that were cleared in this mutation.
  24542. func (m *MessageRecordsMutation) ClearedEdges() []string {
  24543. edges := make([]string, 0, 3)
  24544. if m.clearedsop_stage {
  24545. edges = append(edges, messagerecords.EdgeSopStage)
  24546. }
  24547. if m.clearedsop_node {
  24548. edges = append(edges, messagerecords.EdgeSopNode)
  24549. }
  24550. if m.clearedmessage_contact {
  24551. edges = append(edges, messagerecords.EdgeMessageContact)
  24552. }
  24553. return edges
  24554. }
  24555. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24556. // was cleared in this mutation.
  24557. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  24558. switch name {
  24559. case messagerecords.EdgeSopStage:
  24560. return m.clearedsop_stage
  24561. case messagerecords.EdgeSopNode:
  24562. return m.clearedsop_node
  24563. case messagerecords.EdgeMessageContact:
  24564. return m.clearedmessage_contact
  24565. }
  24566. return false
  24567. }
  24568. // ClearEdge clears the value of the edge with the given name. It returns an error
  24569. // if that edge is not defined in the schema.
  24570. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  24571. switch name {
  24572. case messagerecords.EdgeSopStage:
  24573. m.ClearSopStage()
  24574. return nil
  24575. case messagerecords.EdgeSopNode:
  24576. m.ClearSopNode()
  24577. return nil
  24578. case messagerecords.EdgeMessageContact:
  24579. m.ClearMessageContact()
  24580. return nil
  24581. }
  24582. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  24583. }
  24584. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24585. // It returns an error if the edge is not defined in the schema.
  24586. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  24587. switch name {
  24588. case messagerecords.EdgeSopStage:
  24589. m.ResetSopStage()
  24590. return nil
  24591. case messagerecords.EdgeSopNode:
  24592. m.ResetSopNode()
  24593. return nil
  24594. case messagerecords.EdgeMessageContact:
  24595. m.ResetMessageContact()
  24596. return nil
  24597. }
  24598. return fmt.Errorf("unknown MessageRecords edge %s", name)
  24599. }
  24600. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  24601. type MsgMutation struct {
  24602. config
  24603. op Op
  24604. typ string
  24605. id *uint64
  24606. created_at *time.Time
  24607. updated_at *time.Time
  24608. deleted_at *time.Time
  24609. status *uint8
  24610. addstatus *int8
  24611. fromwxid *string
  24612. toid *string
  24613. msgtype *int32
  24614. addmsgtype *int32
  24615. msg *string
  24616. batch_no *string
  24617. cc *string
  24618. phone *string
  24619. clearedFields map[string]struct{}
  24620. done bool
  24621. oldValue func(context.Context) (*Msg, error)
  24622. predicates []predicate.Msg
  24623. }
  24624. var _ ent.Mutation = (*MsgMutation)(nil)
  24625. // msgOption allows management of the mutation configuration using functional options.
  24626. type msgOption func(*MsgMutation)
  24627. // newMsgMutation creates new mutation for the Msg entity.
  24628. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  24629. m := &MsgMutation{
  24630. config: c,
  24631. op: op,
  24632. typ: TypeMsg,
  24633. clearedFields: make(map[string]struct{}),
  24634. }
  24635. for _, opt := range opts {
  24636. opt(m)
  24637. }
  24638. return m
  24639. }
  24640. // withMsgID sets the ID field of the mutation.
  24641. func withMsgID(id uint64) msgOption {
  24642. return func(m *MsgMutation) {
  24643. var (
  24644. err error
  24645. once sync.Once
  24646. value *Msg
  24647. )
  24648. m.oldValue = func(ctx context.Context) (*Msg, error) {
  24649. once.Do(func() {
  24650. if m.done {
  24651. err = errors.New("querying old values post mutation is not allowed")
  24652. } else {
  24653. value, err = m.Client().Msg.Get(ctx, id)
  24654. }
  24655. })
  24656. return value, err
  24657. }
  24658. m.id = &id
  24659. }
  24660. }
  24661. // withMsg sets the old Msg of the mutation.
  24662. func withMsg(node *Msg) msgOption {
  24663. return func(m *MsgMutation) {
  24664. m.oldValue = func(context.Context) (*Msg, error) {
  24665. return node, nil
  24666. }
  24667. m.id = &node.ID
  24668. }
  24669. }
  24670. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24671. // executed in a transaction (ent.Tx), a transactional client is returned.
  24672. func (m MsgMutation) Client() *Client {
  24673. client := &Client{config: m.config}
  24674. client.init()
  24675. return client
  24676. }
  24677. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24678. // it returns an error otherwise.
  24679. func (m MsgMutation) Tx() (*Tx, error) {
  24680. if _, ok := m.driver.(*txDriver); !ok {
  24681. return nil, errors.New("ent: mutation is not running in a transaction")
  24682. }
  24683. tx := &Tx{config: m.config}
  24684. tx.init()
  24685. return tx, nil
  24686. }
  24687. // SetID sets the value of the id field. Note that this
  24688. // operation is only accepted on creation of Msg entities.
  24689. func (m *MsgMutation) SetID(id uint64) {
  24690. m.id = &id
  24691. }
  24692. // ID returns the ID value in the mutation. Note that the ID is only available
  24693. // if it was provided to the builder or after it was returned from the database.
  24694. func (m *MsgMutation) ID() (id uint64, exists bool) {
  24695. if m.id == nil {
  24696. return
  24697. }
  24698. return *m.id, true
  24699. }
  24700. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24701. // That means, if the mutation is applied within a transaction with an isolation level such
  24702. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24703. // or updated by the mutation.
  24704. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  24705. switch {
  24706. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24707. id, exists := m.ID()
  24708. if exists {
  24709. return []uint64{id}, nil
  24710. }
  24711. fallthrough
  24712. case m.op.Is(OpUpdate | OpDelete):
  24713. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  24714. default:
  24715. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24716. }
  24717. }
  24718. // SetCreatedAt sets the "created_at" field.
  24719. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  24720. m.created_at = &t
  24721. }
  24722. // CreatedAt returns the value of the "created_at" field in the mutation.
  24723. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  24724. v := m.created_at
  24725. if v == nil {
  24726. return
  24727. }
  24728. return *v, true
  24729. }
  24730. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  24731. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  24732. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24733. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24734. if !m.op.Is(OpUpdateOne) {
  24735. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24736. }
  24737. if m.id == nil || m.oldValue == nil {
  24738. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24739. }
  24740. oldValue, err := m.oldValue(ctx)
  24741. if err != nil {
  24742. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24743. }
  24744. return oldValue.CreatedAt, nil
  24745. }
  24746. // ResetCreatedAt resets all changes to the "created_at" field.
  24747. func (m *MsgMutation) ResetCreatedAt() {
  24748. m.created_at = nil
  24749. }
  24750. // SetUpdatedAt sets the "updated_at" field.
  24751. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  24752. m.updated_at = &t
  24753. }
  24754. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24755. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  24756. v := m.updated_at
  24757. if v == nil {
  24758. return
  24759. }
  24760. return *v, true
  24761. }
  24762. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  24763. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  24764. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24765. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24766. if !m.op.Is(OpUpdateOne) {
  24767. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24768. }
  24769. if m.id == nil || m.oldValue == nil {
  24770. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24771. }
  24772. oldValue, err := m.oldValue(ctx)
  24773. if err != nil {
  24774. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24775. }
  24776. return oldValue.UpdatedAt, nil
  24777. }
  24778. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24779. func (m *MsgMutation) ResetUpdatedAt() {
  24780. m.updated_at = nil
  24781. }
  24782. // SetDeletedAt sets the "deleted_at" field.
  24783. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  24784. m.deleted_at = &t
  24785. }
  24786. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  24787. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  24788. v := m.deleted_at
  24789. if v == nil {
  24790. return
  24791. }
  24792. return *v, true
  24793. }
  24794. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  24795. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  24796. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24797. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  24798. if !m.op.Is(OpUpdateOne) {
  24799. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  24800. }
  24801. if m.id == nil || m.oldValue == nil {
  24802. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  24803. }
  24804. oldValue, err := m.oldValue(ctx)
  24805. if err != nil {
  24806. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  24807. }
  24808. return oldValue.DeletedAt, nil
  24809. }
  24810. // ClearDeletedAt clears the value of the "deleted_at" field.
  24811. func (m *MsgMutation) ClearDeletedAt() {
  24812. m.deleted_at = nil
  24813. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  24814. }
  24815. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  24816. func (m *MsgMutation) DeletedAtCleared() bool {
  24817. _, ok := m.clearedFields[msg.FieldDeletedAt]
  24818. return ok
  24819. }
  24820. // ResetDeletedAt resets all changes to the "deleted_at" field.
  24821. func (m *MsgMutation) ResetDeletedAt() {
  24822. m.deleted_at = nil
  24823. delete(m.clearedFields, msg.FieldDeletedAt)
  24824. }
  24825. // SetStatus sets the "status" field.
  24826. func (m *MsgMutation) SetStatus(u uint8) {
  24827. m.status = &u
  24828. m.addstatus = nil
  24829. }
  24830. // Status returns the value of the "status" field in the mutation.
  24831. func (m *MsgMutation) Status() (r uint8, exists bool) {
  24832. v := m.status
  24833. if v == nil {
  24834. return
  24835. }
  24836. return *v, true
  24837. }
  24838. // OldStatus returns the old "status" field's value of the Msg entity.
  24839. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  24840. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24841. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  24842. if !m.op.Is(OpUpdateOne) {
  24843. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  24844. }
  24845. if m.id == nil || m.oldValue == nil {
  24846. return v, errors.New("OldStatus requires an ID field in the mutation")
  24847. }
  24848. oldValue, err := m.oldValue(ctx)
  24849. if err != nil {
  24850. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  24851. }
  24852. return oldValue.Status, nil
  24853. }
  24854. // AddStatus adds u to the "status" field.
  24855. func (m *MsgMutation) AddStatus(u int8) {
  24856. if m.addstatus != nil {
  24857. *m.addstatus += u
  24858. } else {
  24859. m.addstatus = &u
  24860. }
  24861. }
  24862. // AddedStatus returns the value that was added to the "status" field in this mutation.
  24863. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  24864. v := m.addstatus
  24865. if v == nil {
  24866. return
  24867. }
  24868. return *v, true
  24869. }
  24870. // ClearStatus clears the value of the "status" field.
  24871. func (m *MsgMutation) ClearStatus() {
  24872. m.status = nil
  24873. m.addstatus = nil
  24874. m.clearedFields[msg.FieldStatus] = struct{}{}
  24875. }
  24876. // StatusCleared returns if the "status" field was cleared in this mutation.
  24877. func (m *MsgMutation) StatusCleared() bool {
  24878. _, ok := m.clearedFields[msg.FieldStatus]
  24879. return ok
  24880. }
  24881. // ResetStatus resets all changes to the "status" field.
  24882. func (m *MsgMutation) ResetStatus() {
  24883. m.status = nil
  24884. m.addstatus = nil
  24885. delete(m.clearedFields, msg.FieldStatus)
  24886. }
  24887. // SetFromwxid sets the "fromwxid" field.
  24888. func (m *MsgMutation) SetFromwxid(s string) {
  24889. m.fromwxid = &s
  24890. }
  24891. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  24892. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  24893. v := m.fromwxid
  24894. if v == nil {
  24895. return
  24896. }
  24897. return *v, true
  24898. }
  24899. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  24900. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  24901. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24902. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  24903. if !m.op.Is(OpUpdateOne) {
  24904. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  24905. }
  24906. if m.id == nil || m.oldValue == nil {
  24907. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  24908. }
  24909. oldValue, err := m.oldValue(ctx)
  24910. if err != nil {
  24911. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  24912. }
  24913. return oldValue.Fromwxid, nil
  24914. }
  24915. // ClearFromwxid clears the value of the "fromwxid" field.
  24916. func (m *MsgMutation) ClearFromwxid() {
  24917. m.fromwxid = nil
  24918. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  24919. }
  24920. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  24921. func (m *MsgMutation) FromwxidCleared() bool {
  24922. _, ok := m.clearedFields[msg.FieldFromwxid]
  24923. return ok
  24924. }
  24925. // ResetFromwxid resets all changes to the "fromwxid" field.
  24926. func (m *MsgMutation) ResetFromwxid() {
  24927. m.fromwxid = nil
  24928. delete(m.clearedFields, msg.FieldFromwxid)
  24929. }
  24930. // SetToid sets the "toid" field.
  24931. func (m *MsgMutation) SetToid(s string) {
  24932. m.toid = &s
  24933. }
  24934. // Toid returns the value of the "toid" field in the mutation.
  24935. func (m *MsgMutation) Toid() (r string, exists bool) {
  24936. v := m.toid
  24937. if v == nil {
  24938. return
  24939. }
  24940. return *v, true
  24941. }
  24942. // OldToid returns the old "toid" field's value of the Msg entity.
  24943. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  24944. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24945. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  24946. if !m.op.Is(OpUpdateOne) {
  24947. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  24948. }
  24949. if m.id == nil || m.oldValue == nil {
  24950. return v, errors.New("OldToid requires an ID field in the mutation")
  24951. }
  24952. oldValue, err := m.oldValue(ctx)
  24953. if err != nil {
  24954. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  24955. }
  24956. return oldValue.Toid, nil
  24957. }
  24958. // ClearToid clears the value of the "toid" field.
  24959. func (m *MsgMutation) ClearToid() {
  24960. m.toid = nil
  24961. m.clearedFields[msg.FieldToid] = struct{}{}
  24962. }
  24963. // ToidCleared returns if the "toid" field was cleared in this mutation.
  24964. func (m *MsgMutation) ToidCleared() bool {
  24965. _, ok := m.clearedFields[msg.FieldToid]
  24966. return ok
  24967. }
  24968. // ResetToid resets all changes to the "toid" field.
  24969. func (m *MsgMutation) ResetToid() {
  24970. m.toid = nil
  24971. delete(m.clearedFields, msg.FieldToid)
  24972. }
  24973. // SetMsgtype sets the "msgtype" field.
  24974. func (m *MsgMutation) SetMsgtype(i int32) {
  24975. m.msgtype = &i
  24976. m.addmsgtype = nil
  24977. }
  24978. // Msgtype returns the value of the "msgtype" field in the mutation.
  24979. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  24980. v := m.msgtype
  24981. if v == nil {
  24982. return
  24983. }
  24984. return *v, true
  24985. }
  24986. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  24987. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  24988. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24989. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  24990. if !m.op.Is(OpUpdateOne) {
  24991. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  24992. }
  24993. if m.id == nil || m.oldValue == nil {
  24994. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  24995. }
  24996. oldValue, err := m.oldValue(ctx)
  24997. if err != nil {
  24998. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  24999. }
  25000. return oldValue.Msgtype, nil
  25001. }
  25002. // AddMsgtype adds i to the "msgtype" field.
  25003. func (m *MsgMutation) AddMsgtype(i int32) {
  25004. if m.addmsgtype != nil {
  25005. *m.addmsgtype += i
  25006. } else {
  25007. m.addmsgtype = &i
  25008. }
  25009. }
  25010. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  25011. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  25012. v := m.addmsgtype
  25013. if v == nil {
  25014. return
  25015. }
  25016. return *v, true
  25017. }
  25018. // ClearMsgtype clears the value of the "msgtype" field.
  25019. func (m *MsgMutation) ClearMsgtype() {
  25020. m.msgtype = nil
  25021. m.addmsgtype = nil
  25022. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  25023. }
  25024. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  25025. func (m *MsgMutation) MsgtypeCleared() bool {
  25026. _, ok := m.clearedFields[msg.FieldMsgtype]
  25027. return ok
  25028. }
  25029. // ResetMsgtype resets all changes to the "msgtype" field.
  25030. func (m *MsgMutation) ResetMsgtype() {
  25031. m.msgtype = nil
  25032. m.addmsgtype = nil
  25033. delete(m.clearedFields, msg.FieldMsgtype)
  25034. }
  25035. // SetMsg sets the "msg" field.
  25036. func (m *MsgMutation) SetMsg(s string) {
  25037. m.msg = &s
  25038. }
  25039. // Msg returns the value of the "msg" field in the mutation.
  25040. func (m *MsgMutation) Msg() (r string, exists bool) {
  25041. v := m.msg
  25042. if v == nil {
  25043. return
  25044. }
  25045. return *v, true
  25046. }
  25047. // OldMsg returns the old "msg" field's value of the Msg entity.
  25048. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  25049. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25050. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  25051. if !m.op.Is(OpUpdateOne) {
  25052. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  25053. }
  25054. if m.id == nil || m.oldValue == nil {
  25055. return v, errors.New("OldMsg requires an ID field in the mutation")
  25056. }
  25057. oldValue, err := m.oldValue(ctx)
  25058. if err != nil {
  25059. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  25060. }
  25061. return oldValue.Msg, nil
  25062. }
  25063. // ClearMsg clears the value of the "msg" field.
  25064. func (m *MsgMutation) ClearMsg() {
  25065. m.msg = nil
  25066. m.clearedFields[msg.FieldMsg] = struct{}{}
  25067. }
  25068. // MsgCleared returns if the "msg" field was cleared in this mutation.
  25069. func (m *MsgMutation) MsgCleared() bool {
  25070. _, ok := m.clearedFields[msg.FieldMsg]
  25071. return ok
  25072. }
  25073. // ResetMsg resets all changes to the "msg" field.
  25074. func (m *MsgMutation) ResetMsg() {
  25075. m.msg = nil
  25076. delete(m.clearedFields, msg.FieldMsg)
  25077. }
  25078. // SetBatchNo sets the "batch_no" field.
  25079. func (m *MsgMutation) SetBatchNo(s string) {
  25080. m.batch_no = &s
  25081. }
  25082. // BatchNo returns the value of the "batch_no" field in the mutation.
  25083. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  25084. v := m.batch_no
  25085. if v == nil {
  25086. return
  25087. }
  25088. return *v, true
  25089. }
  25090. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  25091. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  25092. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25093. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  25094. if !m.op.Is(OpUpdateOne) {
  25095. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  25096. }
  25097. if m.id == nil || m.oldValue == nil {
  25098. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  25099. }
  25100. oldValue, err := m.oldValue(ctx)
  25101. if err != nil {
  25102. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  25103. }
  25104. return oldValue.BatchNo, nil
  25105. }
  25106. // ClearBatchNo clears the value of the "batch_no" field.
  25107. func (m *MsgMutation) ClearBatchNo() {
  25108. m.batch_no = nil
  25109. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  25110. }
  25111. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  25112. func (m *MsgMutation) BatchNoCleared() bool {
  25113. _, ok := m.clearedFields[msg.FieldBatchNo]
  25114. return ok
  25115. }
  25116. // ResetBatchNo resets all changes to the "batch_no" field.
  25117. func (m *MsgMutation) ResetBatchNo() {
  25118. m.batch_no = nil
  25119. delete(m.clearedFields, msg.FieldBatchNo)
  25120. }
  25121. // SetCc sets the "cc" field.
  25122. func (m *MsgMutation) SetCc(s string) {
  25123. m.cc = &s
  25124. }
  25125. // Cc returns the value of the "cc" field in the mutation.
  25126. func (m *MsgMutation) Cc() (r string, exists bool) {
  25127. v := m.cc
  25128. if v == nil {
  25129. return
  25130. }
  25131. return *v, true
  25132. }
  25133. // OldCc returns the old "cc" field's value of the Msg entity.
  25134. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  25135. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25136. func (m *MsgMutation) OldCc(ctx context.Context) (v string, err error) {
  25137. if !m.op.Is(OpUpdateOne) {
  25138. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  25139. }
  25140. if m.id == nil || m.oldValue == nil {
  25141. return v, errors.New("OldCc requires an ID field in the mutation")
  25142. }
  25143. oldValue, err := m.oldValue(ctx)
  25144. if err != nil {
  25145. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  25146. }
  25147. return oldValue.Cc, nil
  25148. }
  25149. // ResetCc resets all changes to the "cc" field.
  25150. func (m *MsgMutation) ResetCc() {
  25151. m.cc = nil
  25152. }
  25153. // SetPhone sets the "phone" field.
  25154. func (m *MsgMutation) SetPhone(s string) {
  25155. m.phone = &s
  25156. }
  25157. // Phone returns the value of the "phone" field in the mutation.
  25158. func (m *MsgMutation) Phone() (r string, exists bool) {
  25159. v := m.phone
  25160. if v == nil {
  25161. return
  25162. }
  25163. return *v, true
  25164. }
  25165. // OldPhone returns the old "phone" field's value of the Msg entity.
  25166. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  25167. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25168. func (m *MsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  25169. if !m.op.Is(OpUpdateOne) {
  25170. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  25171. }
  25172. if m.id == nil || m.oldValue == nil {
  25173. return v, errors.New("OldPhone requires an ID field in the mutation")
  25174. }
  25175. oldValue, err := m.oldValue(ctx)
  25176. if err != nil {
  25177. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  25178. }
  25179. return oldValue.Phone, nil
  25180. }
  25181. // ResetPhone resets all changes to the "phone" field.
  25182. func (m *MsgMutation) ResetPhone() {
  25183. m.phone = nil
  25184. }
  25185. // Where appends a list predicates to the MsgMutation builder.
  25186. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  25187. m.predicates = append(m.predicates, ps...)
  25188. }
  25189. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  25190. // users can use type-assertion to append predicates that do not depend on any generated package.
  25191. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  25192. p := make([]predicate.Msg, len(ps))
  25193. for i := range ps {
  25194. p[i] = ps[i]
  25195. }
  25196. m.Where(p...)
  25197. }
  25198. // Op returns the operation name.
  25199. func (m *MsgMutation) Op() Op {
  25200. return m.op
  25201. }
  25202. // SetOp allows setting the mutation operation.
  25203. func (m *MsgMutation) SetOp(op Op) {
  25204. m.op = op
  25205. }
  25206. // Type returns the node type of this mutation (Msg).
  25207. func (m *MsgMutation) Type() string {
  25208. return m.typ
  25209. }
  25210. // Fields returns all fields that were changed during this mutation. Note that in
  25211. // order to get all numeric fields that were incremented/decremented, call
  25212. // AddedFields().
  25213. func (m *MsgMutation) Fields() []string {
  25214. fields := make([]string, 0, 11)
  25215. if m.created_at != nil {
  25216. fields = append(fields, msg.FieldCreatedAt)
  25217. }
  25218. if m.updated_at != nil {
  25219. fields = append(fields, msg.FieldUpdatedAt)
  25220. }
  25221. if m.deleted_at != nil {
  25222. fields = append(fields, msg.FieldDeletedAt)
  25223. }
  25224. if m.status != nil {
  25225. fields = append(fields, msg.FieldStatus)
  25226. }
  25227. if m.fromwxid != nil {
  25228. fields = append(fields, msg.FieldFromwxid)
  25229. }
  25230. if m.toid != nil {
  25231. fields = append(fields, msg.FieldToid)
  25232. }
  25233. if m.msgtype != nil {
  25234. fields = append(fields, msg.FieldMsgtype)
  25235. }
  25236. if m.msg != nil {
  25237. fields = append(fields, msg.FieldMsg)
  25238. }
  25239. if m.batch_no != nil {
  25240. fields = append(fields, msg.FieldBatchNo)
  25241. }
  25242. if m.cc != nil {
  25243. fields = append(fields, msg.FieldCc)
  25244. }
  25245. if m.phone != nil {
  25246. fields = append(fields, msg.FieldPhone)
  25247. }
  25248. return fields
  25249. }
  25250. // Field returns the value of a field with the given name. The second boolean
  25251. // return value indicates that this field was not set, or was not defined in the
  25252. // schema.
  25253. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  25254. switch name {
  25255. case msg.FieldCreatedAt:
  25256. return m.CreatedAt()
  25257. case msg.FieldUpdatedAt:
  25258. return m.UpdatedAt()
  25259. case msg.FieldDeletedAt:
  25260. return m.DeletedAt()
  25261. case msg.FieldStatus:
  25262. return m.Status()
  25263. case msg.FieldFromwxid:
  25264. return m.Fromwxid()
  25265. case msg.FieldToid:
  25266. return m.Toid()
  25267. case msg.FieldMsgtype:
  25268. return m.Msgtype()
  25269. case msg.FieldMsg:
  25270. return m.Msg()
  25271. case msg.FieldBatchNo:
  25272. return m.BatchNo()
  25273. case msg.FieldCc:
  25274. return m.Cc()
  25275. case msg.FieldPhone:
  25276. return m.Phone()
  25277. }
  25278. return nil, false
  25279. }
  25280. // OldField returns the old value of the field from the database. An error is
  25281. // returned if the mutation operation is not UpdateOne, or the query to the
  25282. // database failed.
  25283. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25284. switch name {
  25285. case msg.FieldCreatedAt:
  25286. return m.OldCreatedAt(ctx)
  25287. case msg.FieldUpdatedAt:
  25288. return m.OldUpdatedAt(ctx)
  25289. case msg.FieldDeletedAt:
  25290. return m.OldDeletedAt(ctx)
  25291. case msg.FieldStatus:
  25292. return m.OldStatus(ctx)
  25293. case msg.FieldFromwxid:
  25294. return m.OldFromwxid(ctx)
  25295. case msg.FieldToid:
  25296. return m.OldToid(ctx)
  25297. case msg.FieldMsgtype:
  25298. return m.OldMsgtype(ctx)
  25299. case msg.FieldMsg:
  25300. return m.OldMsg(ctx)
  25301. case msg.FieldBatchNo:
  25302. return m.OldBatchNo(ctx)
  25303. case msg.FieldCc:
  25304. return m.OldCc(ctx)
  25305. case msg.FieldPhone:
  25306. return m.OldPhone(ctx)
  25307. }
  25308. return nil, fmt.Errorf("unknown Msg field %s", name)
  25309. }
  25310. // SetField sets the value of a field with the given name. It returns an error if
  25311. // the field is not defined in the schema, or if the type mismatched the field
  25312. // type.
  25313. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  25314. switch name {
  25315. case msg.FieldCreatedAt:
  25316. v, ok := value.(time.Time)
  25317. if !ok {
  25318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25319. }
  25320. m.SetCreatedAt(v)
  25321. return nil
  25322. case msg.FieldUpdatedAt:
  25323. v, ok := value.(time.Time)
  25324. if !ok {
  25325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25326. }
  25327. m.SetUpdatedAt(v)
  25328. return nil
  25329. case msg.FieldDeletedAt:
  25330. v, ok := value.(time.Time)
  25331. if !ok {
  25332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25333. }
  25334. m.SetDeletedAt(v)
  25335. return nil
  25336. case msg.FieldStatus:
  25337. v, ok := value.(uint8)
  25338. if !ok {
  25339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25340. }
  25341. m.SetStatus(v)
  25342. return nil
  25343. case msg.FieldFromwxid:
  25344. v, ok := value.(string)
  25345. if !ok {
  25346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25347. }
  25348. m.SetFromwxid(v)
  25349. return nil
  25350. case msg.FieldToid:
  25351. v, ok := value.(string)
  25352. if !ok {
  25353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25354. }
  25355. m.SetToid(v)
  25356. return nil
  25357. case msg.FieldMsgtype:
  25358. v, ok := value.(int32)
  25359. if !ok {
  25360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25361. }
  25362. m.SetMsgtype(v)
  25363. return nil
  25364. case msg.FieldMsg:
  25365. v, ok := value.(string)
  25366. if !ok {
  25367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25368. }
  25369. m.SetMsg(v)
  25370. return nil
  25371. case msg.FieldBatchNo:
  25372. v, ok := value.(string)
  25373. if !ok {
  25374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25375. }
  25376. m.SetBatchNo(v)
  25377. return nil
  25378. case msg.FieldCc:
  25379. v, ok := value.(string)
  25380. if !ok {
  25381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25382. }
  25383. m.SetCc(v)
  25384. return nil
  25385. case msg.FieldPhone:
  25386. v, ok := value.(string)
  25387. if !ok {
  25388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25389. }
  25390. m.SetPhone(v)
  25391. return nil
  25392. }
  25393. return fmt.Errorf("unknown Msg field %s", name)
  25394. }
  25395. // AddedFields returns all numeric fields that were incremented/decremented during
  25396. // this mutation.
  25397. func (m *MsgMutation) AddedFields() []string {
  25398. var fields []string
  25399. if m.addstatus != nil {
  25400. fields = append(fields, msg.FieldStatus)
  25401. }
  25402. if m.addmsgtype != nil {
  25403. fields = append(fields, msg.FieldMsgtype)
  25404. }
  25405. return fields
  25406. }
  25407. // AddedField returns the numeric value that was incremented/decremented on a field
  25408. // with the given name. The second boolean return value indicates that this field
  25409. // was not set, or was not defined in the schema.
  25410. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  25411. switch name {
  25412. case msg.FieldStatus:
  25413. return m.AddedStatus()
  25414. case msg.FieldMsgtype:
  25415. return m.AddedMsgtype()
  25416. }
  25417. return nil, false
  25418. }
  25419. // AddField adds the value to the field with the given name. It returns an error if
  25420. // the field is not defined in the schema, or if the type mismatched the field
  25421. // type.
  25422. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  25423. switch name {
  25424. case msg.FieldStatus:
  25425. v, ok := value.(int8)
  25426. if !ok {
  25427. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25428. }
  25429. m.AddStatus(v)
  25430. return nil
  25431. case msg.FieldMsgtype:
  25432. v, ok := value.(int32)
  25433. if !ok {
  25434. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25435. }
  25436. m.AddMsgtype(v)
  25437. return nil
  25438. }
  25439. return fmt.Errorf("unknown Msg numeric field %s", name)
  25440. }
  25441. // ClearedFields returns all nullable fields that were cleared during this
  25442. // mutation.
  25443. func (m *MsgMutation) ClearedFields() []string {
  25444. var fields []string
  25445. if m.FieldCleared(msg.FieldDeletedAt) {
  25446. fields = append(fields, msg.FieldDeletedAt)
  25447. }
  25448. if m.FieldCleared(msg.FieldStatus) {
  25449. fields = append(fields, msg.FieldStatus)
  25450. }
  25451. if m.FieldCleared(msg.FieldFromwxid) {
  25452. fields = append(fields, msg.FieldFromwxid)
  25453. }
  25454. if m.FieldCleared(msg.FieldToid) {
  25455. fields = append(fields, msg.FieldToid)
  25456. }
  25457. if m.FieldCleared(msg.FieldMsgtype) {
  25458. fields = append(fields, msg.FieldMsgtype)
  25459. }
  25460. if m.FieldCleared(msg.FieldMsg) {
  25461. fields = append(fields, msg.FieldMsg)
  25462. }
  25463. if m.FieldCleared(msg.FieldBatchNo) {
  25464. fields = append(fields, msg.FieldBatchNo)
  25465. }
  25466. return fields
  25467. }
  25468. // FieldCleared returns a boolean indicating if a field with the given name was
  25469. // cleared in this mutation.
  25470. func (m *MsgMutation) FieldCleared(name string) bool {
  25471. _, ok := m.clearedFields[name]
  25472. return ok
  25473. }
  25474. // ClearField clears the value of the field with the given name. It returns an
  25475. // error if the field is not defined in the schema.
  25476. func (m *MsgMutation) ClearField(name string) error {
  25477. switch name {
  25478. case msg.FieldDeletedAt:
  25479. m.ClearDeletedAt()
  25480. return nil
  25481. case msg.FieldStatus:
  25482. m.ClearStatus()
  25483. return nil
  25484. case msg.FieldFromwxid:
  25485. m.ClearFromwxid()
  25486. return nil
  25487. case msg.FieldToid:
  25488. m.ClearToid()
  25489. return nil
  25490. case msg.FieldMsgtype:
  25491. m.ClearMsgtype()
  25492. return nil
  25493. case msg.FieldMsg:
  25494. m.ClearMsg()
  25495. return nil
  25496. case msg.FieldBatchNo:
  25497. m.ClearBatchNo()
  25498. return nil
  25499. }
  25500. return fmt.Errorf("unknown Msg nullable field %s", name)
  25501. }
  25502. // ResetField resets all changes in the mutation for the field with the given name.
  25503. // It returns an error if the field is not defined in the schema.
  25504. func (m *MsgMutation) ResetField(name string) error {
  25505. switch name {
  25506. case msg.FieldCreatedAt:
  25507. m.ResetCreatedAt()
  25508. return nil
  25509. case msg.FieldUpdatedAt:
  25510. m.ResetUpdatedAt()
  25511. return nil
  25512. case msg.FieldDeletedAt:
  25513. m.ResetDeletedAt()
  25514. return nil
  25515. case msg.FieldStatus:
  25516. m.ResetStatus()
  25517. return nil
  25518. case msg.FieldFromwxid:
  25519. m.ResetFromwxid()
  25520. return nil
  25521. case msg.FieldToid:
  25522. m.ResetToid()
  25523. return nil
  25524. case msg.FieldMsgtype:
  25525. m.ResetMsgtype()
  25526. return nil
  25527. case msg.FieldMsg:
  25528. m.ResetMsg()
  25529. return nil
  25530. case msg.FieldBatchNo:
  25531. m.ResetBatchNo()
  25532. return nil
  25533. case msg.FieldCc:
  25534. m.ResetCc()
  25535. return nil
  25536. case msg.FieldPhone:
  25537. m.ResetPhone()
  25538. return nil
  25539. }
  25540. return fmt.Errorf("unknown Msg field %s", name)
  25541. }
  25542. // AddedEdges returns all edge names that were set/added in this mutation.
  25543. func (m *MsgMutation) AddedEdges() []string {
  25544. edges := make([]string, 0, 0)
  25545. return edges
  25546. }
  25547. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25548. // name in this mutation.
  25549. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  25550. return nil
  25551. }
  25552. // RemovedEdges returns all edge names that were removed in this mutation.
  25553. func (m *MsgMutation) RemovedEdges() []string {
  25554. edges := make([]string, 0, 0)
  25555. return edges
  25556. }
  25557. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25558. // the given name in this mutation.
  25559. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  25560. return nil
  25561. }
  25562. // ClearedEdges returns all edge names that were cleared in this mutation.
  25563. func (m *MsgMutation) ClearedEdges() []string {
  25564. edges := make([]string, 0, 0)
  25565. return edges
  25566. }
  25567. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25568. // was cleared in this mutation.
  25569. func (m *MsgMutation) EdgeCleared(name string) bool {
  25570. return false
  25571. }
  25572. // ClearEdge clears the value of the edge with the given name. It returns an error
  25573. // if that edge is not defined in the schema.
  25574. func (m *MsgMutation) ClearEdge(name string) error {
  25575. return fmt.Errorf("unknown Msg unique edge %s", name)
  25576. }
  25577. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25578. // It returns an error if the edge is not defined in the schema.
  25579. func (m *MsgMutation) ResetEdge(name string) error {
  25580. return fmt.Errorf("unknown Msg edge %s", name)
  25581. }
  25582. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  25583. type PayRechargeMutation struct {
  25584. config
  25585. op Op
  25586. typ string
  25587. id *uint64
  25588. created_at *time.Time
  25589. updated_at *time.Time
  25590. deleted_at *time.Time
  25591. user_id *string
  25592. number *float32
  25593. addnumber *float32
  25594. status *int
  25595. addstatus *int
  25596. money *float32
  25597. addmoney *float32
  25598. out_trade_no *string
  25599. organization_id *uint64
  25600. addorganization_id *int64
  25601. clearedFields map[string]struct{}
  25602. done bool
  25603. oldValue func(context.Context) (*PayRecharge, error)
  25604. predicates []predicate.PayRecharge
  25605. }
  25606. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  25607. // payrechargeOption allows management of the mutation configuration using functional options.
  25608. type payrechargeOption func(*PayRechargeMutation)
  25609. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  25610. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  25611. m := &PayRechargeMutation{
  25612. config: c,
  25613. op: op,
  25614. typ: TypePayRecharge,
  25615. clearedFields: make(map[string]struct{}),
  25616. }
  25617. for _, opt := range opts {
  25618. opt(m)
  25619. }
  25620. return m
  25621. }
  25622. // withPayRechargeID sets the ID field of the mutation.
  25623. func withPayRechargeID(id uint64) payrechargeOption {
  25624. return func(m *PayRechargeMutation) {
  25625. var (
  25626. err error
  25627. once sync.Once
  25628. value *PayRecharge
  25629. )
  25630. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  25631. once.Do(func() {
  25632. if m.done {
  25633. err = errors.New("querying old values post mutation is not allowed")
  25634. } else {
  25635. value, err = m.Client().PayRecharge.Get(ctx, id)
  25636. }
  25637. })
  25638. return value, err
  25639. }
  25640. m.id = &id
  25641. }
  25642. }
  25643. // withPayRecharge sets the old PayRecharge of the mutation.
  25644. func withPayRecharge(node *PayRecharge) payrechargeOption {
  25645. return func(m *PayRechargeMutation) {
  25646. m.oldValue = func(context.Context) (*PayRecharge, error) {
  25647. return node, nil
  25648. }
  25649. m.id = &node.ID
  25650. }
  25651. }
  25652. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25653. // executed in a transaction (ent.Tx), a transactional client is returned.
  25654. func (m PayRechargeMutation) Client() *Client {
  25655. client := &Client{config: m.config}
  25656. client.init()
  25657. return client
  25658. }
  25659. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25660. // it returns an error otherwise.
  25661. func (m PayRechargeMutation) Tx() (*Tx, error) {
  25662. if _, ok := m.driver.(*txDriver); !ok {
  25663. return nil, errors.New("ent: mutation is not running in a transaction")
  25664. }
  25665. tx := &Tx{config: m.config}
  25666. tx.init()
  25667. return tx, nil
  25668. }
  25669. // SetID sets the value of the id field. Note that this
  25670. // operation is only accepted on creation of PayRecharge entities.
  25671. func (m *PayRechargeMutation) SetID(id uint64) {
  25672. m.id = &id
  25673. }
  25674. // ID returns the ID value in the mutation. Note that the ID is only available
  25675. // if it was provided to the builder or after it was returned from the database.
  25676. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  25677. if m.id == nil {
  25678. return
  25679. }
  25680. return *m.id, true
  25681. }
  25682. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  25683. // That means, if the mutation is applied within a transaction with an isolation level such
  25684. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  25685. // or updated by the mutation.
  25686. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  25687. switch {
  25688. case m.op.Is(OpUpdateOne | OpDeleteOne):
  25689. id, exists := m.ID()
  25690. if exists {
  25691. return []uint64{id}, nil
  25692. }
  25693. fallthrough
  25694. case m.op.Is(OpUpdate | OpDelete):
  25695. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  25696. default:
  25697. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  25698. }
  25699. }
  25700. // SetCreatedAt sets the "created_at" field.
  25701. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  25702. m.created_at = &t
  25703. }
  25704. // CreatedAt returns the value of the "created_at" field in the mutation.
  25705. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  25706. v := m.created_at
  25707. if v == nil {
  25708. return
  25709. }
  25710. return *v, true
  25711. }
  25712. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  25713. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  25714. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25715. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  25716. if !m.op.Is(OpUpdateOne) {
  25717. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  25718. }
  25719. if m.id == nil || m.oldValue == nil {
  25720. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  25721. }
  25722. oldValue, err := m.oldValue(ctx)
  25723. if err != nil {
  25724. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  25725. }
  25726. return oldValue.CreatedAt, nil
  25727. }
  25728. // ResetCreatedAt resets all changes to the "created_at" field.
  25729. func (m *PayRechargeMutation) ResetCreatedAt() {
  25730. m.created_at = nil
  25731. }
  25732. // SetUpdatedAt sets the "updated_at" field.
  25733. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  25734. m.updated_at = &t
  25735. }
  25736. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  25737. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  25738. v := m.updated_at
  25739. if v == nil {
  25740. return
  25741. }
  25742. return *v, true
  25743. }
  25744. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  25745. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  25746. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25747. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25748. if !m.op.Is(OpUpdateOne) {
  25749. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25750. }
  25751. if m.id == nil || m.oldValue == nil {
  25752. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  25753. }
  25754. oldValue, err := m.oldValue(ctx)
  25755. if err != nil {
  25756. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  25757. }
  25758. return oldValue.UpdatedAt, nil
  25759. }
  25760. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25761. func (m *PayRechargeMutation) ResetUpdatedAt() {
  25762. m.updated_at = nil
  25763. }
  25764. // SetDeletedAt sets the "deleted_at" field.
  25765. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  25766. m.deleted_at = &t
  25767. }
  25768. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25769. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  25770. v := m.deleted_at
  25771. if v == nil {
  25772. return
  25773. }
  25774. return *v, true
  25775. }
  25776. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  25777. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  25778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25779. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25780. if !m.op.Is(OpUpdateOne) {
  25781. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25782. }
  25783. if m.id == nil || m.oldValue == nil {
  25784. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25785. }
  25786. oldValue, err := m.oldValue(ctx)
  25787. if err != nil {
  25788. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25789. }
  25790. return oldValue.DeletedAt, nil
  25791. }
  25792. // ClearDeletedAt clears the value of the "deleted_at" field.
  25793. func (m *PayRechargeMutation) ClearDeletedAt() {
  25794. m.deleted_at = nil
  25795. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  25796. }
  25797. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25798. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  25799. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  25800. return ok
  25801. }
  25802. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25803. func (m *PayRechargeMutation) ResetDeletedAt() {
  25804. m.deleted_at = nil
  25805. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  25806. }
  25807. // SetUserID sets the "user_id" field.
  25808. func (m *PayRechargeMutation) SetUserID(s string) {
  25809. m.user_id = &s
  25810. }
  25811. // UserID returns the value of the "user_id" field in the mutation.
  25812. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  25813. v := m.user_id
  25814. if v == nil {
  25815. return
  25816. }
  25817. return *v, true
  25818. }
  25819. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  25820. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  25821. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25822. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  25823. if !m.op.Is(OpUpdateOne) {
  25824. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  25825. }
  25826. if m.id == nil || m.oldValue == nil {
  25827. return v, errors.New("OldUserID requires an ID field in the mutation")
  25828. }
  25829. oldValue, err := m.oldValue(ctx)
  25830. if err != nil {
  25831. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  25832. }
  25833. return oldValue.UserID, nil
  25834. }
  25835. // ResetUserID resets all changes to the "user_id" field.
  25836. func (m *PayRechargeMutation) ResetUserID() {
  25837. m.user_id = nil
  25838. }
  25839. // SetNumber sets the "number" field.
  25840. func (m *PayRechargeMutation) SetNumber(f float32) {
  25841. m.number = &f
  25842. m.addnumber = nil
  25843. }
  25844. // Number returns the value of the "number" field in the mutation.
  25845. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  25846. v := m.number
  25847. if v == nil {
  25848. return
  25849. }
  25850. return *v, true
  25851. }
  25852. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  25853. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  25854. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25855. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  25856. if !m.op.Is(OpUpdateOne) {
  25857. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  25858. }
  25859. if m.id == nil || m.oldValue == nil {
  25860. return v, errors.New("OldNumber requires an ID field in the mutation")
  25861. }
  25862. oldValue, err := m.oldValue(ctx)
  25863. if err != nil {
  25864. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  25865. }
  25866. return oldValue.Number, nil
  25867. }
  25868. // AddNumber adds f to the "number" field.
  25869. func (m *PayRechargeMutation) AddNumber(f float32) {
  25870. if m.addnumber != nil {
  25871. *m.addnumber += f
  25872. } else {
  25873. m.addnumber = &f
  25874. }
  25875. }
  25876. // AddedNumber returns the value that was added to the "number" field in this mutation.
  25877. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  25878. v := m.addnumber
  25879. if v == nil {
  25880. return
  25881. }
  25882. return *v, true
  25883. }
  25884. // ResetNumber resets all changes to the "number" field.
  25885. func (m *PayRechargeMutation) ResetNumber() {
  25886. m.number = nil
  25887. m.addnumber = nil
  25888. }
  25889. // SetStatus sets the "status" field.
  25890. func (m *PayRechargeMutation) SetStatus(i int) {
  25891. m.status = &i
  25892. m.addstatus = nil
  25893. }
  25894. // Status returns the value of the "status" field in the mutation.
  25895. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  25896. v := m.status
  25897. if v == nil {
  25898. return
  25899. }
  25900. return *v, true
  25901. }
  25902. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  25903. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  25904. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25905. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  25906. if !m.op.Is(OpUpdateOne) {
  25907. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  25908. }
  25909. if m.id == nil || m.oldValue == nil {
  25910. return v, errors.New("OldStatus requires an ID field in the mutation")
  25911. }
  25912. oldValue, err := m.oldValue(ctx)
  25913. if err != nil {
  25914. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  25915. }
  25916. return oldValue.Status, nil
  25917. }
  25918. // AddStatus adds i to the "status" field.
  25919. func (m *PayRechargeMutation) AddStatus(i int) {
  25920. if m.addstatus != nil {
  25921. *m.addstatus += i
  25922. } else {
  25923. m.addstatus = &i
  25924. }
  25925. }
  25926. // AddedStatus returns the value that was added to the "status" field in this mutation.
  25927. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  25928. v := m.addstatus
  25929. if v == nil {
  25930. return
  25931. }
  25932. return *v, true
  25933. }
  25934. // ClearStatus clears the value of the "status" field.
  25935. func (m *PayRechargeMutation) ClearStatus() {
  25936. m.status = nil
  25937. m.addstatus = nil
  25938. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  25939. }
  25940. // StatusCleared returns if the "status" field was cleared in this mutation.
  25941. func (m *PayRechargeMutation) StatusCleared() bool {
  25942. _, ok := m.clearedFields[payrecharge.FieldStatus]
  25943. return ok
  25944. }
  25945. // ResetStatus resets all changes to the "status" field.
  25946. func (m *PayRechargeMutation) ResetStatus() {
  25947. m.status = nil
  25948. m.addstatus = nil
  25949. delete(m.clearedFields, payrecharge.FieldStatus)
  25950. }
  25951. // SetMoney sets the "money" field.
  25952. func (m *PayRechargeMutation) SetMoney(f float32) {
  25953. m.money = &f
  25954. m.addmoney = nil
  25955. }
  25956. // Money returns the value of the "money" field in the mutation.
  25957. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  25958. v := m.money
  25959. if v == nil {
  25960. return
  25961. }
  25962. return *v, true
  25963. }
  25964. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  25965. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  25966. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25967. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  25968. if !m.op.Is(OpUpdateOne) {
  25969. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  25970. }
  25971. if m.id == nil || m.oldValue == nil {
  25972. return v, errors.New("OldMoney requires an ID field in the mutation")
  25973. }
  25974. oldValue, err := m.oldValue(ctx)
  25975. if err != nil {
  25976. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  25977. }
  25978. return oldValue.Money, nil
  25979. }
  25980. // AddMoney adds f to the "money" field.
  25981. func (m *PayRechargeMutation) AddMoney(f float32) {
  25982. if m.addmoney != nil {
  25983. *m.addmoney += f
  25984. } else {
  25985. m.addmoney = &f
  25986. }
  25987. }
  25988. // AddedMoney returns the value that was added to the "money" field in this mutation.
  25989. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  25990. v := m.addmoney
  25991. if v == nil {
  25992. return
  25993. }
  25994. return *v, true
  25995. }
  25996. // ClearMoney clears the value of the "money" field.
  25997. func (m *PayRechargeMutation) ClearMoney() {
  25998. m.money = nil
  25999. m.addmoney = nil
  26000. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  26001. }
  26002. // MoneyCleared returns if the "money" field was cleared in this mutation.
  26003. func (m *PayRechargeMutation) MoneyCleared() bool {
  26004. _, ok := m.clearedFields[payrecharge.FieldMoney]
  26005. return ok
  26006. }
  26007. // ResetMoney resets all changes to the "money" field.
  26008. func (m *PayRechargeMutation) ResetMoney() {
  26009. m.money = nil
  26010. m.addmoney = nil
  26011. delete(m.clearedFields, payrecharge.FieldMoney)
  26012. }
  26013. // SetOutTradeNo sets the "out_trade_no" field.
  26014. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  26015. m.out_trade_no = &s
  26016. }
  26017. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  26018. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  26019. v := m.out_trade_no
  26020. if v == nil {
  26021. return
  26022. }
  26023. return *v, true
  26024. }
  26025. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  26026. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  26027. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26028. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  26029. if !m.op.Is(OpUpdateOne) {
  26030. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  26031. }
  26032. if m.id == nil || m.oldValue == nil {
  26033. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  26034. }
  26035. oldValue, err := m.oldValue(ctx)
  26036. if err != nil {
  26037. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  26038. }
  26039. return oldValue.OutTradeNo, nil
  26040. }
  26041. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  26042. func (m *PayRechargeMutation) ClearOutTradeNo() {
  26043. m.out_trade_no = nil
  26044. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  26045. }
  26046. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  26047. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  26048. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  26049. return ok
  26050. }
  26051. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  26052. func (m *PayRechargeMutation) ResetOutTradeNo() {
  26053. m.out_trade_no = nil
  26054. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  26055. }
  26056. // SetOrganizationID sets the "organization_id" field.
  26057. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  26058. m.organization_id = &u
  26059. m.addorganization_id = nil
  26060. }
  26061. // OrganizationID returns the value of the "organization_id" field in the mutation.
  26062. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  26063. v := m.organization_id
  26064. if v == nil {
  26065. return
  26066. }
  26067. return *v, true
  26068. }
  26069. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  26070. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  26071. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26072. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  26073. if !m.op.Is(OpUpdateOne) {
  26074. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  26075. }
  26076. if m.id == nil || m.oldValue == nil {
  26077. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  26078. }
  26079. oldValue, err := m.oldValue(ctx)
  26080. if err != nil {
  26081. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  26082. }
  26083. return oldValue.OrganizationID, nil
  26084. }
  26085. // AddOrganizationID adds u to the "organization_id" field.
  26086. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  26087. if m.addorganization_id != nil {
  26088. *m.addorganization_id += u
  26089. } else {
  26090. m.addorganization_id = &u
  26091. }
  26092. }
  26093. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  26094. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  26095. v := m.addorganization_id
  26096. if v == nil {
  26097. return
  26098. }
  26099. return *v, true
  26100. }
  26101. // ResetOrganizationID resets all changes to the "organization_id" field.
  26102. func (m *PayRechargeMutation) ResetOrganizationID() {
  26103. m.organization_id = nil
  26104. m.addorganization_id = nil
  26105. }
  26106. // Where appends a list predicates to the PayRechargeMutation builder.
  26107. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  26108. m.predicates = append(m.predicates, ps...)
  26109. }
  26110. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  26111. // users can use type-assertion to append predicates that do not depend on any generated package.
  26112. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  26113. p := make([]predicate.PayRecharge, len(ps))
  26114. for i := range ps {
  26115. p[i] = ps[i]
  26116. }
  26117. m.Where(p...)
  26118. }
  26119. // Op returns the operation name.
  26120. func (m *PayRechargeMutation) Op() Op {
  26121. return m.op
  26122. }
  26123. // SetOp allows setting the mutation operation.
  26124. func (m *PayRechargeMutation) SetOp(op Op) {
  26125. m.op = op
  26126. }
  26127. // Type returns the node type of this mutation (PayRecharge).
  26128. func (m *PayRechargeMutation) Type() string {
  26129. return m.typ
  26130. }
  26131. // Fields returns all fields that were changed during this mutation. Note that in
  26132. // order to get all numeric fields that were incremented/decremented, call
  26133. // AddedFields().
  26134. func (m *PayRechargeMutation) Fields() []string {
  26135. fields := make([]string, 0, 9)
  26136. if m.created_at != nil {
  26137. fields = append(fields, payrecharge.FieldCreatedAt)
  26138. }
  26139. if m.updated_at != nil {
  26140. fields = append(fields, payrecharge.FieldUpdatedAt)
  26141. }
  26142. if m.deleted_at != nil {
  26143. fields = append(fields, payrecharge.FieldDeletedAt)
  26144. }
  26145. if m.user_id != nil {
  26146. fields = append(fields, payrecharge.FieldUserID)
  26147. }
  26148. if m.number != nil {
  26149. fields = append(fields, payrecharge.FieldNumber)
  26150. }
  26151. if m.status != nil {
  26152. fields = append(fields, payrecharge.FieldStatus)
  26153. }
  26154. if m.money != nil {
  26155. fields = append(fields, payrecharge.FieldMoney)
  26156. }
  26157. if m.out_trade_no != nil {
  26158. fields = append(fields, payrecharge.FieldOutTradeNo)
  26159. }
  26160. if m.organization_id != nil {
  26161. fields = append(fields, payrecharge.FieldOrganizationID)
  26162. }
  26163. return fields
  26164. }
  26165. // Field returns the value of a field with the given name. The second boolean
  26166. // return value indicates that this field was not set, or was not defined in the
  26167. // schema.
  26168. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  26169. switch name {
  26170. case payrecharge.FieldCreatedAt:
  26171. return m.CreatedAt()
  26172. case payrecharge.FieldUpdatedAt:
  26173. return m.UpdatedAt()
  26174. case payrecharge.FieldDeletedAt:
  26175. return m.DeletedAt()
  26176. case payrecharge.FieldUserID:
  26177. return m.UserID()
  26178. case payrecharge.FieldNumber:
  26179. return m.Number()
  26180. case payrecharge.FieldStatus:
  26181. return m.Status()
  26182. case payrecharge.FieldMoney:
  26183. return m.Money()
  26184. case payrecharge.FieldOutTradeNo:
  26185. return m.OutTradeNo()
  26186. case payrecharge.FieldOrganizationID:
  26187. return m.OrganizationID()
  26188. }
  26189. return nil, false
  26190. }
  26191. // OldField returns the old value of the field from the database. An error is
  26192. // returned if the mutation operation is not UpdateOne, or the query to the
  26193. // database failed.
  26194. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26195. switch name {
  26196. case payrecharge.FieldCreatedAt:
  26197. return m.OldCreatedAt(ctx)
  26198. case payrecharge.FieldUpdatedAt:
  26199. return m.OldUpdatedAt(ctx)
  26200. case payrecharge.FieldDeletedAt:
  26201. return m.OldDeletedAt(ctx)
  26202. case payrecharge.FieldUserID:
  26203. return m.OldUserID(ctx)
  26204. case payrecharge.FieldNumber:
  26205. return m.OldNumber(ctx)
  26206. case payrecharge.FieldStatus:
  26207. return m.OldStatus(ctx)
  26208. case payrecharge.FieldMoney:
  26209. return m.OldMoney(ctx)
  26210. case payrecharge.FieldOutTradeNo:
  26211. return m.OldOutTradeNo(ctx)
  26212. case payrecharge.FieldOrganizationID:
  26213. return m.OldOrganizationID(ctx)
  26214. }
  26215. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  26216. }
  26217. // SetField sets the value of a field with the given name. It returns an error if
  26218. // the field is not defined in the schema, or if the type mismatched the field
  26219. // type.
  26220. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  26221. switch name {
  26222. case payrecharge.FieldCreatedAt:
  26223. v, ok := value.(time.Time)
  26224. if !ok {
  26225. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26226. }
  26227. m.SetCreatedAt(v)
  26228. return nil
  26229. case payrecharge.FieldUpdatedAt:
  26230. v, ok := value.(time.Time)
  26231. if !ok {
  26232. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26233. }
  26234. m.SetUpdatedAt(v)
  26235. return nil
  26236. case payrecharge.FieldDeletedAt:
  26237. v, ok := value.(time.Time)
  26238. if !ok {
  26239. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26240. }
  26241. m.SetDeletedAt(v)
  26242. return nil
  26243. case payrecharge.FieldUserID:
  26244. v, ok := value.(string)
  26245. if !ok {
  26246. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26247. }
  26248. m.SetUserID(v)
  26249. return nil
  26250. case payrecharge.FieldNumber:
  26251. v, ok := value.(float32)
  26252. if !ok {
  26253. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26254. }
  26255. m.SetNumber(v)
  26256. return nil
  26257. case payrecharge.FieldStatus:
  26258. v, ok := value.(int)
  26259. if !ok {
  26260. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26261. }
  26262. m.SetStatus(v)
  26263. return nil
  26264. case payrecharge.FieldMoney:
  26265. v, ok := value.(float32)
  26266. if !ok {
  26267. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26268. }
  26269. m.SetMoney(v)
  26270. return nil
  26271. case payrecharge.FieldOutTradeNo:
  26272. v, ok := value.(string)
  26273. if !ok {
  26274. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26275. }
  26276. m.SetOutTradeNo(v)
  26277. return nil
  26278. case payrecharge.FieldOrganizationID:
  26279. v, ok := value.(uint64)
  26280. if !ok {
  26281. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26282. }
  26283. m.SetOrganizationID(v)
  26284. return nil
  26285. }
  26286. return fmt.Errorf("unknown PayRecharge field %s", name)
  26287. }
  26288. // AddedFields returns all numeric fields that were incremented/decremented during
  26289. // this mutation.
  26290. func (m *PayRechargeMutation) AddedFields() []string {
  26291. var fields []string
  26292. if m.addnumber != nil {
  26293. fields = append(fields, payrecharge.FieldNumber)
  26294. }
  26295. if m.addstatus != nil {
  26296. fields = append(fields, payrecharge.FieldStatus)
  26297. }
  26298. if m.addmoney != nil {
  26299. fields = append(fields, payrecharge.FieldMoney)
  26300. }
  26301. if m.addorganization_id != nil {
  26302. fields = append(fields, payrecharge.FieldOrganizationID)
  26303. }
  26304. return fields
  26305. }
  26306. // AddedField returns the numeric value that was incremented/decremented on a field
  26307. // with the given name. The second boolean return value indicates that this field
  26308. // was not set, or was not defined in the schema.
  26309. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  26310. switch name {
  26311. case payrecharge.FieldNumber:
  26312. return m.AddedNumber()
  26313. case payrecharge.FieldStatus:
  26314. return m.AddedStatus()
  26315. case payrecharge.FieldMoney:
  26316. return m.AddedMoney()
  26317. case payrecharge.FieldOrganizationID:
  26318. return m.AddedOrganizationID()
  26319. }
  26320. return nil, false
  26321. }
  26322. // AddField adds the value to the field with the given name. It returns an error if
  26323. // the field is not defined in the schema, or if the type mismatched the field
  26324. // type.
  26325. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  26326. switch name {
  26327. case payrecharge.FieldNumber:
  26328. v, ok := value.(float32)
  26329. if !ok {
  26330. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26331. }
  26332. m.AddNumber(v)
  26333. return nil
  26334. case payrecharge.FieldStatus:
  26335. v, ok := value.(int)
  26336. if !ok {
  26337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26338. }
  26339. m.AddStatus(v)
  26340. return nil
  26341. case payrecharge.FieldMoney:
  26342. v, ok := value.(float32)
  26343. if !ok {
  26344. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26345. }
  26346. m.AddMoney(v)
  26347. return nil
  26348. case payrecharge.FieldOrganizationID:
  26349. v, ok := value.(int64)
  26350. if !ok {
  26351. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26352. }
  26353. m.AddOrganizationID(v)
  26354. return nil
  26355. }
  26356. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  26357. }
  26358. // ClearedFields returns all nullable fields that were cleared during this
  26359. // mutation.
  26360. func (m *PayRechargeMutation) ClearedFields() []string {
  26361. var fields []string
  26362. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  26363. fields = append(fields, payrecharge.FieldDeletedAt)
  26364. }
  26365. if m.FieldCleared(payrecharge.FieldStatus) {
  26366. fields = append(fields, payrecharge.FieldStatus)
  26367. }
  26368. if m.FieldCleared(payrecharge.FieldMoney) {
  26369. fields = append(fields, payrecharge.FieldMoney)
  26370. }
  26371. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  26372. fields = append(fields, payrecharge.FieldOutTradeNo)
  26373. }
  26374. return fields
  26375. }
  26376. // FieldCleared returns a boolean indicating if a field with the given name was
  26377. // cleared in this mutation.
  26378. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  26379. _, ok := m.clearedFields[name]
  26380. return ok
  26381. }
  26382. // ClearField clears the value of the field with the given name. It returns an
  26383. // error if the field is not defined in the schema.
  26384. func (m *PayRechargeMutation) ClearField(name string) error {
  26385. switch name {
  26386. case payrecharge.FieldDeletedAt:
  26387. m.ClearDeletedAt()
  26388. return nil
  26389. case payrecharge.FieldStatus:
  26390. m.ClearStatus()
  26391. return nil
  26392. case payrecharge.FieldMoney:
  26393. m.ClearMoney()
  26394. return nil
  26395. case payrecharge.FieldOutTradeNo:
  26396. m.ClearOutTradeNo()
  26397. return nil
  26398. }
  26399. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  26400. }
  26401. // ResetField resets all changes in the mutation for the field with the given name.
  26402. // It returns an error if the field is not defined in the schema.
  26403. func (m *PayRechargeMutation) ResetField(name string) error {
  26404. switch name {
  26405. case payrecharge.FieldCreatedAt:
  26406. m.ResetCreatedAt()
  26407. return nil
  26408. case payrecharge.FieldUpdatedAt:
  26409. m.ResetUpdatedAt()
  26410. return nil
  26411. case payrecharge.FieldDeletedAt:
  26412. m.ResetDeletedAt()
  26413. return nil
  26414. case payrecharge.FieldUserID:
  26415. m.ResetUserID()
  26416. return nil
  26417. case payrecharge.FieldNumber:
  26418. m.ResetNumber()
  26419. return nil
  26420. case payrecharge.FieldStatus:
  26421. m.ResetStatus()
  26422. return nil
  26423. case payrecharge.FieldMoney:
  26424. m.ResetMoney()
  26425. return nil
  26426. case payrecharge.FieldOutTradeNo:
  26427. m.ResetOutTradeNo()
  26428. return nil
  26429. case payrecharge.FieldOrganizationID:
  26430. m.ResetOrganizationID()
  26431. return nil
  26432. }
  26433. return fmt.Errorf("unknown PayRecharge field %s", name)
  26434. }
  26435. // AddedEdges returns all edge names that were set/added in this mutation.
  26436. func (m *PayRechargeMutation) AddedEdges() []string {
  26437. edges := make([]string, 0, 0)
  26438. return edges
  26439. }
  26440. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26441. // name in this mutation.
  26442. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  26443. return nil
  26444. }
  26445. // RemovedEdges returns all edge names that were removed in this mutation.
  26446. func (m *PayRechargeMutation) RemovedEdges() []string {
  26447. edges := make([]string, 0, 0)
  26448. return edges
  26449. }
  26450. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26451. // the given name in this mutation.
  26452. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  26453. return nil
  26454. }
  26455. // ClearedEdges returns all edge names that were cleared in this mutation.
  26456. func (m *PayRechargeMutation) ClearedEdges() []string {
  26457. edges := make([]string, 0, 0)
  26458. return edges
  26459. }
  26460. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26461. // was cleared in this mutation.
  26462. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  26463. return false
  26464. }
  26465. // ClearEdge clears the value of the edge with the given name. It returns an error
  26466. // if that edge is not defined in the schema.
  26467. func (m *PayRechargeMutation) ClearEdge(name string) error {
  26468. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  26469. }
  26470. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26471. // It returns an error if the edge is not defined in the schema.
  26472. func (m *PayRechargeMutation) ResetEdge(name string) error {
  26473. return fmt.Errorf("unknown PayRecharge edge %s", name)
  26474. }
  26475. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  26476. type ServerMutation struct {
  26477. config
  26478. op Op
  26479. typ string
  26480. id *uint64
  26481. created_at *time.Time
  26482. updated_at *time.Time
  26483. status *uint8
  26484. addstatus *int8
  26485. deleted_at *time.Time
  26486. name *string
  26487. public_ip *string
  26488. private_ip *string
  26489. admin_port *string
  26490. clearedFields map[string]struct{}
  26491. wxs map[uint64]struct{}
  26492. removedwxs map[uint64]struct{}
  26493. clearedwxs bool
  26494. done bool
  26495. oldValue func(context.Context) (*Server, error)
  26496. predicates []predicate.Server
  26497. }
  26498. var _ ent.Mutation = (*ServerMutation)(nil)
  26499. // serverOption allows management of the mutation configuration using functional options.
  26500. type serverOption func(*ServerMutation)
  26501. // newServerMutation creates new mutation for the Server entity.
  26502. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  26503. m := &ServerMutation{
  26504. config: c,
  26505. op: op,
  26506. typ: TypeServer,
  26507. clearedFields: make(map[string]struct{}),
  26508. }
  26509. for _, opt := range opts {
  26510. opt(m)
  26511. }
  26512. return m
  26513. }
  26514. // withServerID sets the ID field of the mutation.
  26515. func withServerID(id uint64) serverOption {
  26516. return func(m *ServerMutation) {
  26517. var (
  26518. err error
  26519. once sync.Once
  26520. value *Server
  26521. )
  26522. m.oldValue = func(ctx context.Context) (*Server, error) {
  26523. once.Do(func() {
  26524. if m.done {
  26525. err = errors.New("querying old values post mutation is not allowed")
  26526. } else {
  26527. value, err = m.Client().Server.Get(ctx, id)
  26528. }
  26529. })
  26530. return value, err
  26531. }
  26532. m.id = &id
  26533. }
  26534. }
  26535. // withServer sets the old Server of the mutation.
  26536. func withServer(node *Server) serverOption {
  26537. return func(m *ServerMutation) {
  26538. m.oldValue = func(context.Context) (*Server, error) {
  26539. return node, nil
  26540. }
  26541. m.id = &node.ID
  26542. }
  26543. }
  26544. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26545. // executed in a transaction (ent.Tx), a transactional client is returned.
  26546. func (m ServerMutation) Client() *Client {
  26547. client := &Client{config: m.config}
  26548. client.init()
  26549. return client
  26550. }
  26551. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26552. // it returns an error otherwise.
  26553. func (m ServerMutation) Tx() (*Tx, error) {
  26554. if _, ok := m.driver.(*txDriver); !ok {
  26555. return nil, errors.New("ent: mutation is not running in a transaction")
  26556. }
  26557. tx := &Tx{config: m.config}
  26558. tx.init()
  26559. return tx, nil
  26560. }
  26561. // SetID sets the value of the id field. Note that this
  26562. // operation is only accepted on creation of Server entities.
  26563. func (m *ServerMutation) SetID(id uint64) {
  26564. m.id = &id
  26565. }
  26566. // ID returns the ID value in the mutation. Note that the ID is only available
  26567. // if it was provided to the builder or after it was returned from the database.
  26568. func (m *ServerMutation) ID() (id uint64, exists bool) {
  26569. if m.id == nil {
  26570. return
  26571. }
  26572. return *m.id, true
  26573. }
  26574. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26575. // That means, if the mutation is applied within a transaction with an isolation level such
  26576. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26577. // or updated by the mutation.
  26578. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  26579. switch {
  26580. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26581. id, exists := m.ID()
  26582. if exists {
  26583. return []uint64{id}, nil
  26584. }
  26585. fallthrough
  26586. case m.op.Is(OpUpdate | OpDelete):
  26587. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  26588. default:
  26589. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26590. }
  26591. }
  26592. // SetCreatedAt sets the "created_at" field.
  26593. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  26594. m.created_at = &t
  26595. }
  26596. // CreatedAt returns the value of the "created_at" field in the mutation.
  26597. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  26598. v := m.created_at
  26599. if v == nil {
  26600. return
  26601. }
  26602. return *v, true
  26603. }
  26604. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  26605. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  26606. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26607. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26608. if !m.op.Is(OpUpdateOne) {
  26609. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26610. }
  26611. if m.id == nil || m.oldValue == nil {
  26612. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26613. }
  26614. oldValue, err := m.oldValue(ctx)
  26615. if err != nil {
  26616. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26617. }
  26618. return oldValue.CreatedAt, nil
  26619. }
  26620. // ResetCreatedAt resets all changes to the "created_at" field.
  26621. func (m *ServerMutation) ResetCreatedAt() {
  26622. m.created_at = nil
  26623. }
  26624. // SetUpdatedAt sets the "updated_at" field.
  26625. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  26626. m.updated_at = &t
  26627. }
  26628. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26629. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  26630. v := m.updated_at
  26631. if v == nil {
  26632. return
  26633. }
  26634. return *v, true
  26635. }
  26636. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  26637. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  26638. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26639. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26640. if !m.op.Is(OpUpdateOne) {
  26641. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26642. }
  26643. if m.id == nil || m.oldValue == nil {
  26644. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26645. }
  26646. oldValue, err := m.oldValue(ctx)
  26647. if err != nil {
  26648. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26649. }
  26650. return oldValue.UpdatedAt, nil
  26651. }
  26652. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26653. func (m *ServerMutation) ResetUpdatedAt() {
  26654. m.updated_at = nil
  26655. }
  26656. // SetStatus sets the "status" field.
  26657. func (m *ServerMutation) SetStatus(u uint8) {
  26658. m.status = &u
  26659. m.addstatus = nil
  26660. }
  26661. // Status returns the value of the "status" field in the mutation.
  26662. func (m *ServerMutation) Status() (r uint8, exists bool) {
  26663. v := m.status
  26664. if v == nil {
  26665. return
  26666. }
  26667. return *v, true
  26668. }
  26669. // OldStatus returns the old "status" field's value of the Server entity.
  26670. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  26671. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26672. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  26673. if !m.op.Is(OpUpdateOne) {
  26674. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26675. }
  26676. if m.id == nil || m.oldValue == nil {
  26677. return v, errors.New("OldStatus requires an ID field in the mutation")
  26678. }
  26679. oldValue, err := m.oldValue(ctx)
  26680. if err != nil {
  26681. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26682. }
  26683. return oldValue.Status, nil
  26684. }
  26685. // AddStatus adds u to the "status" field.
  26686. func (m *ServerMutation) AddStatus(u int8) {
  26687. if m.addstatus != nil {
  26688. *m.addstatus += u
  26689. } else {
  26690. m.addstatus = &u
  26691. }
  26692. }
  26693. // AddedStatus returns the value that was added to the "status" field in this mutation.
  26694. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  26695. v := m.addstatus
  26696. if v == nil {
  26697. return
  26698. }
  26699. return *v, true
  26700. }
  26701. // ClearStatus clears the value of the "status" field.
  26702. func (m *ServerMutation) ClearStatus() {
  26703. m.status = nil
  26704. m.addstatus = nil
  26705. m.clearedFields[server.FieldStatus] = struct{}{}
  26706. }
  26707. // StatusCleared returns if the "status" field was cleared in this mutation.
  26708. func (m *ServerMutation) StatusCleared() bool {
  26709. _, ok := m.clearedFields[server.FieldStatus]
  26710. return ok
  26711. }
  26712. // ResetStatus resets all changes to the "status" field.
  26713. func (m *ServerMutation) ResetStatus() {
  26714. m.status = nil
  26715. m.addstatus = nil
  26716. delete(m.clearedFields, server.FieldStatus)
  26717. }
  26718. // SetDeletedAt sets the "deleted_at" field.
  26719. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  26720. m.deleted_at = &t
  26721. }
  26722. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26723. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  26724. v := m.deleted_at
  26725. if v == nil {
  26726. return
  26727. }
  26728. return *v, true
  26729. }
  26730. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  26731. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  26732. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26733. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26734. if !m.op.Is(OpUpdateOne) {
  26735. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26736. }
  26737. if m.id == nil || m.oldValue == nil {
  26738. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26739. }
  26740. oldValue, err := m.oldValue(ctx)
  26741. if err != nil {
  26742. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26743. }
  26744. return oldValue.DeletedAt, nil
  26745. }
  26746. // ClearDeletedAt clears the value of the "deleted_at" field.
  26747. func (m *ServerMutation) ClearDeletedAt() {
  26748. m.deleted_at = nil
  26749. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  26750. }
  26751. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26752. func (m *ServerMutation) DeletedAtCleared() bool {
  26753. _, ok := m.clearedFields[server.FieldDeletedAt]
  26754. return ok
  26755. }
  26756. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26757. func (m *ServerMutation) ResetDeletedAt() {
  26758. m.deleted_at = nil
  26759. delete(m.clearedFields, server.FieldDeletedAt)
  26760. }
  26761. // SetName sets the "name" field.
  26762. func (m *ServerMutation) SetName(s string) {
  26763. m.name = &s
  26764. }
  26765. // Name returns the value of the "name" field in the mutation.
  26766. func (m *ServerMutation) Name() (r string, exists bool) {
  26767. v := m.name
  26768. if v == nil {
  26769. return
  26770. }
  26771. return *v, true
  26772. }
  26773. // OldName returns the old "name" field's value of the Server entity.
  26774. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  26775. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26776. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  26777. if !m.op.Is(OpUpdateOne) {
  26778. return v, errors.New("OldName is only allowed on UpdateOne operations")
  26779. }
  26780. if m.id == nil || m.oldValue == nil {
  26781. return v, errors.New("OldName requires an ID field in the mutation")
  26782. }
  26783. oldValue, err := m.oldValue(ctx)
  26784. if err != nil {
  26785. return v, fmt.Errorf("querying old value for OldName: %w", err)
  26786. }
  26787. return oldValue.Name, nil
  26788. }
  26789. // ResetName resets all changes to the "name" field.
  26790. func (m *ServerMutation) ResetName() {
  26791. m.name = nil
  26792. }
  26793. // SetPublicIP sets the "public_ip" field.
  26794. func (m *ServerMutation) SetPublicIP(s string) {
  26795. m.public_ip = &s
  26796. }
  26797. // PublicIP returns the value of the "public_ip" field in the mutation.
  26798. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  26799. v := m.public_ip
  26800. if v == nil {
  26801. return
  26802. }
  26803. return *v, true
  26804. }
  26805. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  26806. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  26807. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26808. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  26809. if !m.op.Is(OpUpdateOne) {
  26810. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  26811. }
  26812. if m.id == nil || m.oldValue == nil {
  26813. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  26814. }
  26815. oldValue, err := m.oldValue(ctx)
  26816. if err != nil {
  26817. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  26818. }
  26819. return oldValue.PublicIP, nil
  26820. }
  26821. // ResetPublicIP resets all changes to the "public_ip" field.
  26822. func (m *ServerMutation) ResetPublicIP() {
  26823. m.public_ip = nil
  26824. }
  26825. // SetPrivateIP sets the "private_ip" field.
  26826. func (m *ServerMutation) SetPrivateIP(s string) {
  26827. m.private_ip = &s
  26828. }
  26829. // PrivateIP returns the value of the "private_ip" field in the mutation.
  26830. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  26831. v := m.private_ip
  26832. if v == nil {
  26833. return
  26834. }
  26835. return *v, true
  26836. }
  26837. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  26838. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  26839. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26840. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  26841. if !m.op.Is(OpUpdateOne) {
  26842. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  26843. }
  26844. if m.id == nil || m.oldValue == nil {
  26845. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  26846. }
  26847. oldValue, err := m.oldValue(ctx)
  26848. if err != nil {
  26849. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  26850. }
  26851. return oldValue.PrivateIP, nil
  26852. }
  26853. // ResetPrivateIP resets all changes to the "private_ip" field.
  26854. func (m *ServerMutation) ResetPrivateIP() {
  26855. m.private_ip = nil
  26856. }
  26857. // SetAdminPort sets the "admin_port" field.
  26858. func (m *ServerMutation) SetAdminPort(s string) {
  26859. m.admin_port = &s
  26860. }
  26861. // AdminPort returns the value of the "admin_port" field in the mutation.
  26862. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  26863. v := m.admin_port
  26864. if v == nil {
  26865. return
  26866. }
  26867. return *v, true
  26868. }
  26869. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  26870. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  26871. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26872. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  26873. if !m.op.Is(OpUpdateOne) {
  26874. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  26875. }
  26876. if m.id == nil || m.oldValue == nil {
  26877. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  26878. }
  26879. oldValue, err := m.oldValue(ctx)
  26880. if err != nil {
  26881. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  26882. }
  26883. return oldValue.AdminPort, nil
  26884. }
  26885. // ResetAdminPort resets all changes to the "admin_port" field.
  26886. func (m *ServerMutation) ResetAdminPort() {
  26887. m.admin_port = nil
  26888. }
  26889. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  26890. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  26891. if m.wxs == nil {
  26892. m.wxs = make(map[uint64]struct{})
  26893. }
  26894. for i := range ids {
  26895. m.wxs[ids[i]] = struct{}{}
  26896. }
  26897. }
  26898. // ClearWxs clears the "wxs" edge to the Wx entity.
  26899. func (m *ServerMutation) ClearWxs() {
  26900. m.clearedwxs = true
  26901. }
  26902. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  26903. func (m *ServerMutation) WxsCleared() bool {
  26904. return m.clearedwxs
  26905. }
  26906. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  26907. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  26908. if m.removedwxs == nil {
  26909. m.removedwxs = make(map[uint64]struct{})
  26910. }
  26911. for i := range ids {
  26912. delete(m.wxs, ids[i])
  26913. m.removedwxs[ids[i]] = struct{}{}
  26914. }
  26915. }
  26916. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  26917. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  26918. for id := range m.removedwxs {
  26919. ids = append(ids, id)
  26920. }
  26921. return
  26922. }
  26923. // WxsIDs returns the "wxs" edge IDs in the mutation.
  26924. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  26925. for id := range m.wxs {
  26926. ids = append(ids, id)
  26927. }
  26928. return
  26929. }
  26930. // ResetWxs resets all changes to the "wxs" edge.
  26931. func (m *ServerMutation) ResetWxs() {
  26932. m.wxs = nil
  26933. m.clearedwxs = false
  26934. m.removedwxs = nil
  26935. }
  26936. // Where appends a list predicates to the ServerMutation builder.
  26937. func (m *ServerMutation) Where(ps ...predicate.Server) {
  26938. m.predicates = append(m.predicates, ps...)
  26939. }
  26940. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  26941. // users can use type-assertion to append predicates that do not depend on any generated package.
  26942. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  26943. p := make([]predicate.Server, len(ps))
  26944. for i := range ps {
  26945. p[i] = ps[i]
  26946. }
  26947. m.Where(p...)
  26948. }
  26949. // Op returns the operation name.
  26950. func (m *ServerMutation) Op() Op {
  26951. return m.op
  26952. }
  26953. // SetOp allows setting the mutation operation.
  26954. func (m *ServerMutation) SetOp(op Op) {
  26955. m.op = op
  26956. }
  26957. // Type returns the node type of this mutation (Server).
  26958. func (m *ServerMutation) Type() string {
  26959. return m.typ
  26960. }
  26961. // Fields returns all fields that were changed during this mutation. Note that in
  26962. // order to get all numeric fields that were incremented/decremented, call
  26963. // AddedFields().
  26964. func (m *ServerMutation) Fields() []string {
  26965. fields := make([]string, 0, 8)
  26966. if m.created_at != nil {
  26967. fields = append(fields, server.FieldCreatedAt)
  26968. }
  26969. if m.updated_at != nil {
  26970. fields = append(fields, server.FieldUpdatedAt)
  26971. }
  26972. if m.status != nil {
  26973. fields = append(fields, server.FieldStatus)
  26974. }
  26975. if m.deleted_at != nil {
  26976. fields = append(fields, server.FieldDeletedAt)
  26977. }
  26978. if m.name != nil {
  26979. fields = append(fields, server.FieldName)
  26980. }
  26981. if m.public_ip != nil {
  26982. fields = append(fields, server.FieldPublicIP)
  26983. }
  26984. if m.private_ip != nil {
  26985. fields = append(fields, server.FieldPrivateIP)
  26986. }
  26987. if m.admin_port != nil {
  26988. fields = append(fields, server.FieldAdminPort)
  26989. }
  26990. return fields
  26991. }
  26992. // Field returns the value of a field with the given name. The second boolean
  26993. // return value indicates that this field was not set, or was not defined in the
  26994. // schema.
  26995. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  26996. switch name {
  26997. case server.FieldCreatedAt:
  26998. return m.CreatedAt()
  26999. case server.FieldUpdatedAt:
  27000. return m.UpdatedAt()
  27001. case server.FieldStatus:
  27002. return m.Status()
  27003. case server.FieldDeletedAt:
  27004. return m.DeletedAt()
  27005. case server.FieldName:
  27006. return m.Name()
  27007. case server.FieldPublicIP:
  27008. return m.PublicIP()
  27009. case server.FieldPrivateIP:
  27010. return m.PrivateIP()
  27011. case server.FieldAdminPort:
  27012. return m.AdminPort()
  27013. }
  27014. return nil, false
  27015. }
  27016. // OldField returns the old value of the field from the database. An error is
  27017. // returned if the mutation operation is not UpdateOne, or the query to the
  27018. // database failed.
  27019. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27020. switch name {
  27021. case server.FieldCreatedAt:
  27022. return m.OldCreatedAt(ctx)
  27023. case server.FieldUpdatedAt:
  27024. return m.OldUpdatedAt(ctx)
  27025. case server.FieldStatus:
  27026. return m.OldStatus(ctx)
  27027. case server.FieldDeletedAt:
  27028. return m.OldDeletedAt(ctx)
  27029. case server.FieldName:
  27030. return m.OldName(ctx)
  27031. case server.FieldPublicIP:
  27032. return m.OldPublicIP(ctx)
  27033. case server.FieldPrivateIP:
  27034. return m.OldPrivateIP(ctx)
  27035. case server.FieldAdminPort:
  27036. return m.OldAdminPort(ctx)
  27037. }
  27038. return nil, fmt.Errorf("unknown Server field %s", name)
  27039. }
  27040. // SetField sets the value of a field with the given name. It returns an error if
  27041. // the field is not defined in the schema, or if the type mismatched the field
  27042. // type.
  27043. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  27044. switch name {
  27045. case server.FieldCreatedAt:
  27046. v, ok := value.(time.Time)
  27047. if !ok {
  27048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27049. }
  27050. m.SetCreatedAt(v)
  27051. return nil
  27052. case server.FieldUpdatedAt:
  27053. v, ok := value.(time.Time)
  27054. if !ok {
  27055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27056. }
  27057. m.SetUpdatedAt(v)
  27058. return nil
  27059. case server.FieldStatus:
  27060. v, ok := value.(uint8)
  27061. if !ok {
  27062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27063. }
  27064. m.SetStatus(v)
  27065. return nil
  27066. case server.FieldDeletedAt:
  27067. v, ok := value.(time.Time)
  27068. if !ok {
  27069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27070. }
  27071. m.SetDeletedAt(v)
  27072. return nil
  27073. case server.FieldName:
  27074. v, ok := value.(string)
  27075. if !ok {
  27076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27077. }
  27078. m.SetName(v)
  27079. return nil
  27080. case server.FieldPublicIP:
  27081. v, ok := value.(string)
  27082. if !ok {
  27083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27084. }
  27085. m.SetPublicIP(v)
  27086. return nil
  27087. case server.FieldPrivateIP:
  27088. v, ok := value.(string)
  27089. if !ok {
  27090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27091. }
  27092. m.SetPrivateIP(v)
  27093. return nil
  27094. case server.FieldAdminPort:
  27095. v, ok := value.(string)
  27096. if !ok {
  27097. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27098. }
  27099. m.SetAdminPort(v)
  27100. return nil
  27101. }
  27102. return fmt.Errorf("unknown Server field %s", name)
  27103. }
  27104. // AddedFields returns all numeric fields that were incremented/decremented during
  27105. // this mutation.
  27106. func (m *ServerMutation) AddedFields() []string {
  27107. var fields []string
  27108. if m.addstatus != nil {
  27109. fields = append(fields, server.FieldStatus)
  27110. }
  27111. return fields
  27112. }
  27113. // AddedField returns the numeric value that was incremented/decremented on a field
  27114. // with the given name. The second boolean return value indicates that this field
  27115. // was not set, or was not defined in the schema.
  27116. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  27117. switch name {
  27118. case server.FieldStatus:
  27119. return m.AddedStatus()
  27120. }
  27121. return nil, false
  27122. }
  27123. // AddField adds the value to the field with the given name. It returns an error if
  27124. // the field is not defined in the schema, or if the type mismatched the field
  27125. // type.
  27126. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  27127. switch name {
  27128. case server.FieldStatus:
  27129. v, ok := value.(int8)
  27130. if !ok {
  27131. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27132. }
  27133. m.AddStatus(v)
  27134. return nil
  27135. }
  27136. return fmt.Errorf("unknown Server numeric field %s", name)
  27137. }
  27138. // ClearedFields returns all nullable fields that were cleared during this
  27139. // mutation.
  27140. func (m *ServerMutation) ClearedFields() []string {
  27141. var fields []string
  27142. if m.FieldCleared(server.FieldStatus) {
  27143. fields = append(fields, server.FieldStatus)
  27144. }
  27145. if m.FieldCleared(server.FieldDeletedAt) {
  27146. fields = append(fields, server.FieldDeletedAt)
  27147. }
  27148. return fields
  27149. }
  27150. // FieldCleared returns a boolean indicating if a field with the given name was
  27151. // cleared in this mutation.
  27152. func (m *ServerMutation) FieldCleared(name string) bool {
  27153. _, ok := m.clearedFields[name]
  27154. return ok
  27155. }
  27156. // ClearField clears the value of the field with the given name. It returns an
  27157. // error if the field is not defined in the schema.
  27158. func (m *ServerMutation) ClearField(name string) error {
  27159. switch name {
  27160. case server.FieldStatus:
  27161. m.ClearStatus()
  27162. return nil
  27163. case server.FieldDeletedAt:
  27164. m.ClearDeletedAt()
  27165. return nil
  27166. }
  27167. return fmt.Errorf("unknown Server nullable field %s", name)
  27168. }
  27169. // ResetField resets all changes in the mutation for the field with the given name.
  27170. // It returns an error if the field is not defined in the schema.
  27171. func (m *ServerMutation) ResetField(name string) error {
  27172. switch name {
  27173. case server.FieldCreatedAt:
  27174. m.ResetCreatedAt()
  27175. return nil
  27176. case server.FieldUpdatedAt:
  27177. m.ResetUpdatedAt()
  27178. return nil
  27179. case server.FieldStatus:
  27180. m.ResetStatus()
  27181. return nil
  27182. case server.FieldDeletedAt:
  27183. m.ResetDeletedAt()
  27184. return nil
  27185. case server.FieldName:
  27186. m.ResetName()
  27187. return nil
  27188. case server.FieldPublicIP:
  27189. m.ResetPublicIP()
  27190. return nil
  27191. case server.FieldPrivateIP:
  27192. m.ResetPrivateIP()
  27193. return nil
  27194. case server.FieldAdminPort:
  27195. m.ResetAdminPort()
  27196. return nil
  27197. }
  27198. return fmt.Errorf("unknown Server field %s", name)
  27199. }
  27200. // AddedEdges returns all edge names that were set/added in this mutation.
  27201. func (m *ServerMutation) AddedEdges() []string {
  27202. edges := make([]string, 0, 1)
  27203. if m.wxs != nil {
  27204. edges = append(edges, server.EdgeWxs)
  27205. }
  27206. return edges
  27207. }
  27208. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27209. // name in this mutation.
  27210. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  27211. switch name {
  27212. case server.EdgeWxs:
  27213. ids := make([]ent.Value, 0, len(m.wxs))
  27214. for id := range m.wxs {
  27215. ids = append(ids, id)
  27216. }
  27217. return ids
  27218. }
  27219. return nil
  27220. }
  27221. // RemovedEdges returns all edge names that were removed in this mutation.
  27222. func (m *ServerMutation) RemovedEdges() []string {
  27223. edges := make([]string, 0, 1)
  27224. if m.removedwxs != nil {
  27225. edges = append(edges, server.EdgeWxs)
  27226. }
  27227. return edges
  27228. }
  27229. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27230. // the given name in this mutation.
  27231. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  27232. switch name {
  27233. case server.EdgeWxs:
  27234. ids := make([]ent.Value, 0, len(m.removedwxs))
  27235. for id := range m.removedwxs {
  27236. ids = append(ids, id)
  27237. }
  27238. return ids
  27239. }
  27240. return nil
  27241. }
  27242. // ClearedEdges returns all edge names that were cleared in this mutation.
  27243. func (m *ServerMutation) ClearedEdges() []string {
  27244. edges := make([]string, 0, 1)
  27245. if m.clearedwxs {
  27246. edges = append(edges, server.EdgeWxs)
  27247. }
  27248. return edges
  27249. }
  27250. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27251. // was cleared in this mutation.
  27252. func (m *ServerMutation) EdgeCleared(name string) bool {
  27253. switch name {
  27254. case server.EdgeWxs:
  27255. return m.clearedwxs
  27256. }
  27257. return false
  27258. }
  27259. // ClearEdge clears the value of the edge with the given name. It returns an error
  27260. // if that edge is not defined in the schema.
  27261. func (m *ServerMutation) ClearEdge(name string) error {
  27262. switch name {
  27263. }
  27264. return fmt.Errorf("unknown Server unique edge %s", name)
  27265. }
  27266. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27267. // It returns an error if the edge is not defined in the schema.
  27268. func (m *ServerMutation) ResetEdge(name string) error {
  27269. switch name {
  27270. case server.EdgeWxs:
  27271. m.ResetWxs()
  27272. return nil
  27273. }
  27274. return fmt.Errorf("unknown Server edge %s", name)
  27275. }
  27276. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  27277. type SopNodeMutation struct {
  27278. config
  27279. op Op
  27280. typ string
  27281. id *uint64
  27282. created_at *time.Time
  27283. updated_at *time.Time
  27284. status *uint8
  27285. addstatus *int8
  27286. deleted_at *time.Time
  27287. parent_id *uint64
  27288. addparent_id *int64
  27289. name *string
  27290. condition_type *int
  27291. addcondition_type *int
  27292. condition_list *[]string
  27293. appendcondition_list []string
  27294. no_reply_condition *uint64
  27295. addno_reply_condition *int64
  27296. no_reply_unit *string
  27297. action_message *[]custom_types.Action
  27298. appendaction_message []custom_types.Action
  27299. action_label_add *[]uint64
  27300. appendaction_label_add []uint64
  27301. action_label_del *[]uint64
  27302. appendaction_label_del []uint64
  27303. action_forward **custom_types.ActionForward
  27304. clearedFields map[string]struct{}
  27305. sop_stage *uint64
  27306. clearedsop_stage bool
  27307. node_messages map[uint64]struct{}
  27308. removednode_messages map[uint64]struct{}
  27309. clearednode_messages bool
  27310. done bool
  27311. oldValue func(context.Context) (*SopNode, error)
  27312. predicates []predicate.SopNode
  27313. }
  27314. var _ ent.Mutation = (*SopNodeMutation)(nil)
  27315. // sopnodeOption allows management of the mutation configuration using functional options.
  27316. type sopnodeOption func(*SopNodeMutation)
  27317. // newSopNodeMutation creates new mutation for the SopNode entity.
  27318. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  27319. m := &SopNodeMutation{
  27320. config: c,
  27321. op: op,
  27322. typ: TypeSopNode,
  27323. clearedFields: make(map[string]struct{}),
  27324. }
  27325. for _, opt := range opts {
  27326. opt(m)
  27327. }
  27328. return m
  27329. }
  27330. // withSopNodeID sets the ID field of the mutation.
  27331. func withSopNodeID(id uint64) sopnodeOption {
  27332. return func(m *SopNodeMutation) {
  27333. var (
  27334. err error
  27335. once sync.Once
  27336. value *SopNode
  27337. )
  27338. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  27339. once.Do(func() {
  27340. if m.done {
  27341. err = errors.New("querying old values post mutation is not allowed")
  27342. } else {
  27343. value, err = m.Client().SopNode.Get(ctx, id)
  27344. }
  27345. })
  27346. return value, err
  27347. }
  27348. m.id = &id
  27349. }
  27350. }
  27351. // withSopNode sets the old SopNode of the mutation.
  27352. func withSopNode(node *SopNode) sopnodeOption {
  27353. return func(m *SopNodeMutation) {
  27354. m.oldValue = func(context.Context) (*SopNode, error) {
  27355. return node, nil
  27356. }
  27357. m.id = &node.ID
  27358. }
  27359. }
  27360. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27361. // executed in a transaction (ent.Tx), a transactional client is returned.
  27362. func (m SopNodeMutation) Client() *Client {
  27363. client := &Client{config: m.config}
  27364. client.init()
  27365. return client
  27366. }
  27367. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27368. // it returns an error otherwise.
  27369. func (m SopNodeMutation) Tx() (*Tx, error) {
  27370. if _, ok := m.driver.(*txDriver); !ok {
  27371. return nil, errors.New("ent: mutation is not running in a transaction")
  27372. }
  27373. tx := &Tx{config: m.config}
  27374. tx.init()
  27375. return tx, nil
  27376. }
  27377. // SetID sets the value of the id field. Note that this
  27378. // operation is only accepted on creation of SopNode entities.
  27379. func (m *SopNodeMutation) SetID(id uint64) {
  27380. m.id = &id
  27381. }
  27382. // ID returns the ID value in the mutation. Note that the ID is only available
  27383. // if it was provided to the builder or after it was returned from the database.
  27384. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  27385. if m.id == nil {
  27386. return
  27387. }
  27388. return *m.id, true
  27389. }
  27390. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27391. // That means, if the mutation is applied within a transaction with an isolation level such
  27392. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27393. // or updated by the mutation.
  27394. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  27395. switch {
  27396. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27397. id, exists := m.ID()
  27398. if exists {
  27399. return []uint64{id}, nil
  27400. }
  27401. fallthrough
  27402. case m.op.Is(OpUpdate | OpDelete):
  27403. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  27404. default:
  27405. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27406. }
  27407. }
  27408. // SetCreatedAt sets the "created_at" field.
  27409. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  27410. m.created_at = &t
  27411. }
  27412. // CreatedAt returns the value of the "created_at" field in the mutation.
  27413. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  27414. v := m.created_at
  27415. if v == nil {
  27416. return
  27417. }
  27418. return *v, true
  27419. }
  27420. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  27421. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27422. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27423. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27424. if !m.op.Is(OpUpdateOne) {
  27425. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27426. }
  27427. if m.id == nil || m.oldValue == nil {
  27428. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27429. }
  27430. oldValue, err := m.oldValue(ctx)
  27431. if err != nil {
  27432. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27433. }
  27434. return oldValue.CreatedAt, nil
  27435. }
  27436. // ResetCreatedAt resets all changes to the "created_at" field.
  27437. func (m *SopNodeMutation) ResetCreatedAt() {
  27438. m.created_at = nil
  27439. }
  27440. // SetUpdatedAt sets the "updated_at" field.
  27441. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  27442. m.updated_at = &t
  27443. }
  27444. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27445. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  27446. v := m.updated_at
  27447. if v == nil {
  27448. return
  27449. }
  27450. return *v, true
  27451. }
  27452. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  27453. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27454. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27455. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27456. if !m.op.Is(OpUpdateOne) {
  27457. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27458. }
  27459. if m.id == nil || m.oldValue == nil {
  27460. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27461. }
  27462. oldValue, err := m.oldValue(ctx)
  27463. if err != nil {
  27464. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27465. }
  27466. return oldValue.UpdatedAt, nil
  27467. }
  27468. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27469. func (m *SopNodeMutation) ResetUpdatedAt() {
  27470. m.updated_at = nil
  27471. }
  27472. // SetStatus sets the "status" field.
  27473. func (m *SopNodeMutation) SetStatus(u uint8) {
  27474. m.status = &u
  27475. m.addstatus = nil
  27476. }
  27477. // Status returns the value of the "status" field in the mutation.
  27478. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  27479. v := m.status
  27480. if v == nil {
  27481. return
  27482. }
  27483. return *v, true
  27484. }
  27485. // OldStatus returns the old "status" field's value of the SopNode entity.
  27486. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27487. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27488. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  27489. if !m.op.Is(OpUpdateOne) {
  27490. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  27491. }
  27492. if m.id == nil || m.oldValue == nil {
  27493. return v, errors.New("OldStatus requires an ID field in the mutation")
  27494. }
  27495. oldValue, err := m.oldValue(ctx)
  27496. if err != nil {
  27497. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  27498. }
  27499. return oldValue.Status, nil
  27500. }
  27501. // AddStatus adds u to the "status" field.
  27502. func (m *SopNodeMutation) AddStatus(u int8) {
  27503. if m.addstatus != nil {
  27504. *m.addstatus += u
  27505. } else {
  27506. m.addstatus = &u
  27507. }
  27508. }
  27509. // AddedStatus returns the value that was added to the "status" field in this mutation.
  27510. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  27511. v := m.addstatus
  27512. if v == nil {
  27513. return
  27514. }
  27515. return *v, true
  27516. }
  27517. // ClearStatus clears the value of the "status" field.
  27518. func (m *SopNodeMutation) ClearStatus() {
  27519. m.status = nil
  27520. m.addstatus = nil
  27521. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  27522. }
  27523. // StatusCleared returns if the "status" field was cleared in this mutation.
  27524. func (m *SopNodeMutation) StatusCleared() bool {
  27525. _, ok := m.clearedFields[sopnode.FieldStatus]
  27526. return ok
  27527. }
  27528. // ResetStatus resets all changes to the "status" field.
  27529. func (m *SopNodeMutation) ResetStatus() {
  27530. m.status = nil
  27531. m.addstatus = nil
  27532. delete(m.clearedFields, sopnode.FieldStatus)
  27533. }
  27534. // SetDeletedAt sets the "deleted_at" field.
  27535. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  27536. m.deleted_at = &t
  27537. }
  27538. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  27539. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  27540. v := m.deleted_at
  27541. if v == nil {
  27542. return
  27543. }
  27544. return *v, true
  27545. }
  27546. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  27547. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27548. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27549. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  27550. if !m.op.Is(OpUpdateOne) {
  27551. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  27552. }
  27553. if m.id == nil || m.oldValue == nil {
  27554. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  27555. }
  27556. oldValue, err := m.oldValue(ctx)
  27557. if err != nil {
  27558. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  27559. }
  27560. return oldValue.DeletedAt, nil
  27561. }
  27562. // ClearDeletedAt clears the value of the "deleted_at" field.
  27563. func (m *SopNodeMutation) ClearDeletedAt() {
  27564. m.deleted_at = nil
  27565. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  27566. }
  27567. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  27568. func (m *SopNodeMutation) DeletedAtCleared() bool {
  27569. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  27570. return ok
  27571. }
  27572. // ResetDeletedAt resets all changes to the "deleted_at" field.
  27573. func (m *SopNodeMutation) ResetDeletedAt() {
  27574. m.deleted_at = nil
  27575. delete(m.clearedFields, sopnode.FieldDeletedAt)
  27576. }
  27577. // SetStageID sets the "stage_id" field.
  27578. func (m *SopNodeMutation) SetStageID(u uint64) {
  27579. m.sop_stage = &u
  27580. }
  27581. // StageID returns the value of the "stage_id" field in the mutation.
  27582. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  27583. v := m.sop_stage
  27584. if v == nil {
  27585. return
  27586. }
  27587. return *v, true
  27588. }
  27589. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  27590. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27591. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27592. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  27593. if !m.op.Is(OpUpdateOne) {
  27594. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  27595. }
  27596. if m.id == nil || m.oldValue == nil {
  27597. return v, errors.New("OldStageID requires an ID field in the mutation")
  27598. }
  27599. oldValue, err := m.oldValue(ctx)
  27600. if err != nil {
  27601. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  27602. }
  27603. return oldValue.StageID, nil
  27604. }
  27605. // ResetStageID resets all changes to the "stage_id" field.
  27606. func (m *SopNodeMutation) ResetStageID() {
  27607. m.sop_stage = nil
  27608. }
  27609. // SetParentID sets the "parent_id" field.
  27610. func (m *SopNodeMutation) SetParentID(u uint64) {
  27611. m.parent_id = &u
  27612. m.addparent_id = nil
  27613. }
  27614. // ParentID returns the value of the "parent_id" field in the mutation.
  27615. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  27616. v := m.parent_id
  27617. if v == nil {
  27618. return
  27619. }
  27620. return *v, true
  27621. }
  27622. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  27623. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27624. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27625. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  27626. if !m.op.Is(OpUpdateOne) {
  27627. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  27628. }
  27629. if m.id == nil || m.oldValue == nil {
  27630. return v, errors.New("OldParentID requires an ID field in the mutation")
  27631. }
  27632. oldValue, err := m.oldValue(ctx)
  27633. if err != nil {
  27634. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  27635. }
  27636. return oldValue.ParentID, nil
  27637. }
  27638. // AddParentID adds u to the "parent_id" field.
  27639. func (m *SopNodeMutation) AddParentID(u int64) {
  27640. if m.addparent_id != nil {
  27641. *m.addparent_id += u
  27642. } else {
  27643. m.addparent_id = &u
  27644. }
  27645. }
  27646. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  27647. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  27648. v := m.addparent_id
  27649. if v == nil {
  27650. return
  27651. }
  27652. return *v, true
  27653. }
  27654. // ResetParentID resets all changes to the "parent_id" field.
  27655. func (m *SopNodeMutation) ResetParentID() {
  27656. m.parent_id = nil
  27657. m.addparent_id = nil
  27658. }
  27659. // SetName sets the "name" field.
  27660. func (m *SopNodeMutation) SetName(s string) {
  27661. m.name = &s
  27662. }
  27663. // Name returns the value of the "name" field in the mutation.
  27664. func (m *SopNodeMutation) Name() (r string, exists bool) {
  27665. v := m.name
  27666. if v == nil {
  27667. return
  27668. }
  27669. return *v, true
  27670. }
  27671. // OldName returns the old "name" field's value of the SopNode entity.
  27672. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27673. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27674. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  27675. if !m.op.Is(OpUpdateOne) {
  27676. return v, errors.New("OldName is only allowed on UpdateOne operations")
  27677. }
  27678. if m.id == nil || m.oldValue == nil {
  27679. return v, errors.New("OldName requires an ID field in the mutation")
  27680. }
  27681. oldValue, err := m.oldValue(ctx)
  27682. if err != nil {
  27683. return v, fmt.Errorf("querying old value for OldName: %w", err)
  27684. }
  27685. return oldValue.Name, nil
  27686. }
  27687. // ResetName resets all changes to the "name" field.
  27688. func (m *SopNodeMutation) ResetName() {
  27689. m.name = nil
  27690. }
  27691. // SetConditionType sets the "condition_type" field.
  27692. func (m *SopNodeMutation) SetConditionType(i int) {
  27693. m.condition_type = &i
  27694. m.addcondition_type = nil
  27695. }
  27696. // ConditionType returns the value of the "condition_type" field in the mutation.
  27697. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  27698. v := m.condition_type
  27699. if v == nil {
  27700. return
  27701. }
  27702. return *v, true
  27703. }
  27704. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  27705. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27706. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27707. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  27708. if !m.op.Is(OpUpdateOne) {
  27709. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  27710. }
  27711. if m.id == nil || m.oldValue == nil {
  27712. return v, errors.New("OldConditionType requires an ID field in the mutation")
  27713. }
  27714. oldValue, err := m.oldValue(ctx)
  27715. if err != nil {
  27716. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  27717. }
  27718. return oldValue.ConditionType, nil
  27719. }
  27720. // AddConditionType adds i to the "condition_type" field.
  27721. func (m *SopNodeMutation) AddConditionType(i int) {
  27722. if m.addcondition_type != nil {
  27723. *m.addcondition_type += i
  27724. } else {
  27725. m.addcondition_type = &i
  27726. }
  27727. }
  27728. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  27729. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  27730. v := m.addcondition_type
  27731. if v == nil {
  27732. return
  27733. }
  27734. return *v, true
  27735. }
  27736. // ResetConditionType resets all changes to the "condition_type" field.
  27737. func (m *SopNodeMutation) ResetConditionType() {
  27738. m.condition_type = nil
  27739. m.addcondition_type = nil
  27740. }
  27741. // SetConditionList sets the "condition_list" field.
  27742. func (m *SopNodeMutation) SetConditionList(s []string) {
  27743. m.condition_list = &s
  27744. m.appendcondition_list = nil
  27745. }
  27746. // ConditionList returns the value of the "condition_list" field in the mutation.
  27747. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  27748. v := m.condition_list
  27749. if v == nil {
  27750. return
  27751. }
  27752. return *v, true
  27753. }
  27754. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  27755. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27756. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27757. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  27758. if !m.op.Is(OpUpdateOne) {
  27759. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  27760. }
  27761. if m.id == nil || m.oldValue == nil {
  27762. return v, errors.New("OldConditionList requires an ID field in the mutation")
  27763. }
  27764. oldValue, err := m.oldValue(ctx)
  27765. if err != nil {
  27766. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  27767. }
  27768. return oldValue.ConditionList, nil
  27769. }
  27770. // AppendConditionList adds s to the "condition_list" field.
  27771. func (m *SopNodeMutation) AppendConditionList(s []string) {
  27772. m.appendcondition_list = append(m.appendcondition_list, s...)
  27773. }
  27774. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  27775. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  27776. if len(m.appendcondition_list) == 0 {
  27777. return nil, false
  27778. }
  27779. return m.appendcondition_list, true
  27780. }
  27781. // ClearConditionList clears the value of the "condition_list" field.
  27782. func (m *SopNodeMutation) ClearConditionList() {
  27783. m.condition_list = nil
  27784. m.appendcondition_list = nil
  27785. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  27786. }
  27787. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  27788. func (m *SopNodeMutation) ConditionListCleared() bool {
  27789. _, ok := m.clearedFields[sopnode.FieldConditionList]
  27790. return ok
  27791. }
  27792. // ResetConditionList resets all changes to the "condition_list" field.
  27793. func (m *SopNodeMutation) ResetConditionList() {
  27794. m.condition_list = nil
  27795. m.appendcondition_list = nil
  27796. delete(m.clearedFields, sopnode.FieldConditionList)
  27797. }
  27798. // SetNoReplyCondition sets the "no_reply_condition" field.
  27799. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  27800. m.no_reply_condition = &u
  27801. m.addno_reply_condition = nil
  27802. }
  27803. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  27804. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  27805. v := m.no_reply_condition
  27806. if v == nil {
  27807. return
  27808. }
  27809. return *v, true
  27810. }
  27811. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  27812. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27814. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  27815. if !m.op.Is(OpUpdateOne) {
  27816. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  27817. }
  27818. if m.id == nil || m.oldValue == nil {
  27819. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  27820. }
  27821. oldValue, err := m.oldValue(ctx)
  27822. if err != nil {
  27823. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  27824. }
  27825. return oldValue.NoReplyCondition, nil
  27826. }
  27827. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  27828. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  27829. if m.addno_reply_condition != nil {
  27830. *m.addno_reply_condition += u
  27831. } else {
  27832. m.addno_reply_condition = &u
  27833. }
  27834. }
  27835. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  27836. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  27837. v := m.addno_reply_condition
  27838. if v == nil {
  27839. return
  27840. }
  27841. return *v, true
  27842. }
  27843. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  27844. func (m *SopNodeMutation) ResetNoReplyCondition() {
  27845. m.no_reply_condition = nil
  27846. m.addno_reply_condition = nil
  27847. }
  27848. // SetNoReplyUnit sets the "no_reply_unit" field.
  27849. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  27850. m.no_reply_unit = &s
  27851. }
  27852. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  27853. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  27854. v := m.no_reply_unit
  27855. if v == nil {
  27856. return
  27857. }
  27858. return *v, true
  27859. }
  27860. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  27861. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27862. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27863. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  27864. if !m.op.Is(OpUpdateOne) {
  27865. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  27866. }
  27867. if m.id == nil || m.oldValue == nil {
  27868. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  27869. }
  27870. oldValue, err := m.oldValue(ctx)
  27871. if err != nil {
  27872. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  27873. }
  27874. return oldValue.NoReplyUnit, nil
  27875. }
  27876. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  27877. func (m *SopNodeMutation) ResetNoReplyUnit() {
  27878. m.no_reply_unit = nil
  27879. }
  27880. // SetActionMessage sets the "action_message" field.
  27881. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  27882. m.action_message = &ct
  27883. m.appendaction_message = nil
  27884. }
  27885. // ActionMessage returns the value of the "action_message" field in the mutation.
  27886. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  27887. v := m.action_message
  27888. if v == nil {
  27889. return
  27890. }
  27891. return *v, true
  27892. }
  27893. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  27894. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27895. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27896. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  27897. if !m.op.Is(OpUpdateOne) {
  27898. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  27899. }
  27900. if m.id == nil || m.oldValue == nil {
  27901. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  27902. }
  27903. oldValue, err := m.oldValue(ctx)
  27904. if err != nil {
  27905. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  27906. }
  27907. return oldValue.ActionMessage, nil
  27908. }
  27909. // AppendActionMessage adds ct to the "action_message" field.
  27910. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  27911. m.appendaction_message = append(m.appendaction_message, ct...)
  27912. }
  27913. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  27914. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  27915. if len(m.appendaction_message) == 0 {
  27916. return nil, false
  27917. }
  27918. return m.appendaction_message, true
  27919. }
  27920. // ClearActionMessage clears the value of the "action_message" field.
  27921. func (m *SopNodeMutation) ClearActionMessage() {
  27922. m.action_message = nil
  27923. m.appendaction_message = nil
  27924. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  27925. }
  27926. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  27927. func (m *SopNodeMutation) ActionMessageCleared() bool {
  27928. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  27929. return ok
  27930. }
  27931. // ResetActionMessage resets all changes to the "action_message" field.
  27932. func (m *SopNodeMutation) ResetActionMessage() {
  27933. m.action_message = nil
  27934. m.appendaction_message = nil
  27935. delete(m.clearedFields, sopnode.FieldActionMessage)
  27936. }
  27937. // SetActionLabelAdd sets the "action_label_add" field.
  27938. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  27939. m.action_label_add = &u
  27940. m.appendaction_label_add = nil
  27941. }
  27942. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  27943. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  27944. v := m.action_label_add
  27945. if v == nil {
  27946. return
  27947. }
  27948. return *v, true
  27949. }
  27950. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  27951. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27952. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27953. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  27954. if !m.op.Is(OpUpdateOne) {
  27955. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  27956. }
  27957. if m.id == nil || m.oldValue == nil {
  27958. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  27959. }
  27960. oldValue, err := m.oldValue(ctx)
  27961. if err != nil {
  27962. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  27963. }
  27964. return oldValue.ActionLabelAdd, nil
  27965. }
  27966. // AppendActionLabelAdd adds u to the "action_label_add" field.
  27967. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  27968. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  27969. }
  27970. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  27971. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  27972. if len(m.appendaction_label_add) == 0 {
  27973. return nil, false
  27974. }
  27975. return m.appendaction_label_add, true
  27976. }
  27977. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  27978. func (m *SopNodeMutation) ClearActionLabelAdd() {
  27979. m.action_label_add = nil
  27980. m.appendaction_label_add = nil
  27981. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  27982. }
  27983. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  27984. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  27985. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  27986. return ok
  27987. }
  27988. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  27989. func (m *SopNodeMutation) ResetActionLabelAdd() {
  27990. m.action_label_add = nil
  27991. m.appendaction_label_add = nil
  27992. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  27993. }
  27994. // SetActionLabelDel sets the "action_label_del" field.
  27995. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  27996. m.action_label_del = &u
  27997. m.appendaction_label_del = nil
  27998. }
  27999. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  28000. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  28001. v := m.action_label_del
  28002. if v == nil {
  28003. return
  28004. }
  28005. return *v, true
  28006. }
  28007. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  28008. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28009. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28010. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  28011. if !m.op.Is(OpUpdateOne) {
  28012. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  28013. }
  28014. if m.id == nil || m.oldValue == nil {
  28015. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  28016. }
  28017. oldValue, err := m.oldValue(ctx)
  28018. if err != nil {
  28019. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  28020. }
  28021. return oldValue.ActionLabelDel, nil
  28022. }
  28023. // AppendActionLabelDel adds u to the "action_label_del" field.
  28024. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  28025. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  28026. }
  28027. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  28028. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  28029. if len(m.appendaction_label_del) == 0 {
  28030. return nil, false
  28031. }
  28032. return m.appendaction_label_del, true
  28033. }
  28034. // ClearActionLabelDel clears the value of the "action_label_del" field.
  28035. func (m *SopNodeMutation) ClearActionLabelDel() {
  28036. m.action_label_del = nil
  28037. m.appendaction_label_del = nil
  28038. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  28039. }
  28040. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  28041. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  28042. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  28043. return ok
  28044. }
  28045. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  28046. func (m *SopNodeMutation) ResetActionLabelDel() {
  28047. m.action_label_del = nil
  28048. m.appendaction_label_del = nil
  28049. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  28050. }
  28051. // SetActionForward sets the "action_forward" field.
  28052. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  28053. m.action_forward = &ctf
  28054. }
  28055. // ActionForward returns the value of the "action_forward" field in the mutation.
  28056. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  28057. v := m.action_forward
  28058. if v == nil {
  28059. return
  28060. }
  28061. return *v, true
  28062. }
  28063. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  28064. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28065. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28066. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  28067. if !m.op.Is(OpUpdateOne) {
  28068. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  28069. }
  28070. if m.id == nil || m.oldValue == nil {
  28071. return v, errors.New("OldActionForward requires an ID field in the mutation")
  28072. }
  28073. oldValue, err := m.oldValue(ctx)
  28074. if err != nil {
  28075. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  28076. }
  28077. return oldValue.ActionForward, nil
  28078. }
  28079. // ClearActionForward clears the value of the "action_forward" field.
  28080. func (m *SopNodeMutation) ClearActionForward() {
  28081. m.action_forward = nil
  28082. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  28083. }
  28084. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  28085. func (m *SopNodeMutation) ActionForwardCleared() bool {
  28086. _, ok := m.clearedFields[sopnode.FieldActionForward]
  28087. return ok
  28088. }
  28089. // ResetActionForward resets all changes to the "action_forward" field.
  28090. func (m *SopNodeMutation) ResetActionForward() {
  28091. m.action_forward = nil
  28092. delete(m.clearedFields, sopnode.FieldActionForward)
  28093. }
  28094. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  28095. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  28096. m.sop_stage = &id
  28097. }
  28098. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  28099. func (m *SopNodeMutation) ClearSopStage() {
  28100. m.clearedsop_stage = true
  28101. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  28102. }
  28103. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  28104. func (m *SopNodeMutation) SopStageCleared() bool {
  28105. return m.clearedsop_stage
  28106. }
  28107. // SopStageID returns the "sop_stage" edge ID in the mutation.
  28108. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  28109. if m.sop_stage != nil {
  28110. return *m.sop_stage, true
  28111. }
  28112. return
  28113. }
  28114. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  28115. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  28116. // SopStageID instead. It exists only for internal usage by the builders.
  28117. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  28118. if id := m.sop_stage; id != nil {
  28119. ids = append(ids, *id)
  28120. }
  28121. return
  28122. }
  28123. // ResetSopStage resets all changes to the "sop_stage" edge.
  28124. func (m *SopNodeMutation) ResetSopStage() {
  28125. m.sop_stage = nil
  28126. m.clearedsop_stage = false
  28127. }
  28128. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  28129. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  28130. if m.node_messages == nil {
  28131. m.node_messages = make(map[uint64]struct{})
  28132. }
  28133. for i := range ids {
  28134. m.node_messages[ids[i]] = struct{}{}
  28135. }
  28136. }
  28137. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  28138. func (m *SopNodeMutation) ClearNodeMessages() {
  28139. m.clearednode_messages = true
  28140. }
  28141. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  28142. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  28143. return m.clearednode_messages
  28144. }
  28145. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  28146. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  28147. if m.removednode_messages == nil {
  28148. m.removednode_messages = make(map[uint64]struct{})
  28149. }
  28150. for i := range ids {
  28151. delete(m.node_messages, ids[i])
  28152. m.removednode_messages[ids[i]] = struct{}{}
  28153. }
  28154. }
  28155. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  28156. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  28157. for id := range m.removednode_messages {
  28158. ids = append(ids, id)
  28159. }
  28160. return
  28161. }
  28162. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  28163. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  28164. for id := range m.node_messages {
  28165. ids = append(ids, id)
  28166. }
  28167. return
  28168. }
  28169. // ResetNodeMessages resets all changes to the "node_messages" edge.
  28170. func (m *SopNodeMutation) ResetNodeMessages() {
  28171. m.node_messages = nil
  28172. m.clearednode_messages = false
  28173. m.removednode_messages = nil
  28174. }
  28175. // Where appends a list predicates to the SopNodeMutation builder.
  28176. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  28177. m.predicates = append(m.predicates, ps...)
  28178. }
  28179. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  28180. // users can use type-assertion to append predicates that do not depend on any generated package.
  28181. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  28182. p := make([]predicate.SopNode, len(ps))
  28183. for i := range ps {
  28184. p[i] = ps[i]
  28185. }
  28186. m.Where(p...)
  28187. }
  28188. // Op returns the operation name.
  28189. func (m *SopNodeMutation) Op() Op {
  28190. return m.op
  28191. }
  28192. // SetOp allows setting the mutation operation.
  28193. func (m *SopNodeMutation) SetOp(op Op) {
  28194. m.op = op
  28195. }
  28196. // Type returns the node type of this mutation (SopNode).
  28197. func (m *SopNodeMutation) Type() string {
  28198. return m.typ
  28199. }
  28200. // Fields returns all fields that were changed during this mutation. Note that in
  28201. // order to get all numeric fields that were incremented/decremented, call
  28202. // AddedFields().
  28203. func (m *SopNodeMutation) Fields() []string {
  28204. fields := make([]string, 0, 15)
  28205. if m.created_at != nil {
  28206. fields = append(fields, sopnode.FieldCreatedAt)
  28207. }
  28208. if m.updated_at != nil {
  28209. fields = append(fields, sopnode.FieldUpdatedAt)
  28210. }
  28211. if m.status != nil {
  28212. fields = append(fields, sopnode.FieldStatus)
  28213. }
  28214. if m.deleted_at != nil {
  28215. fields = append(fields, sopnode.FieldDeletedAt)
  28216. }
  28217. if m.sop_stage != nil {
  28218. fields = append(fields, sopnode.FieldStageID)
  28219. }
  28220. if m.parent_id != nil {
  28221. fields = append(fields, sopnode.FieldParentID)
  28222. }
  28223. if m.name != nil {
  28224. fields = append(fields, sopnode.FieldName)
  28225. }
  28226. if m.condition_type != nil {
  28227. fields = append(fields, sopnode.FieldConditionType)
  28228. }
  28229. if m.condition_list != nil {
  28230. fields = append(fields, sopnode.FieldConditionList)
  28231. }
  28232. if m.no_reply_condition != nil {
  28233. fields = append(fields, sopnode.FieldNoReplyCondition)
  28234. }
  28235. if m.no_reply_unit != nil {
  28236. fields = append(fields, sopnode.FieldNoReplyUnit)
  28237. }
  28238. if m.action_message != nil {
  28239. fields = append(fields, sopnode.FieldActionMessage)
  28240. }
  28241. if m.action_label_add != nil {
  28242. fields = append(fields, sopnode.FieldActionLabelAdd)
  28243. }
  28244. if m.action_label_del != nil {
  28245. fields = append(fields, sopnode.FieldActionLabelDel)
  28246. }
  28247. if m.action_forward != nil {
  28248. fields = append(fields, sopnode.FieldActionForward)
  28249. }
  28250. return fields
  28251. }
  28252. // Field returns the value of a field with the given name. The second boolean
  28253. // return value indicates that this field was not set, or was not defined in the
  28254. // schema.
  28255. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  28256. switch name {
  28257. case sopnode.FieldCreatedAt:
  28258. return m.CreatedAt()
  28259. case sopnode.FieldUpdatedAt:
  28260. return m.UpdatedAt()
  28261. case sopnode.FieldStatus:
  28262. return m.Status()
  28263. case sopnode.FieldDeletedAt:
  28264. return m.DeletedAt()
  28265. case sopnode.FieldStageID:
  28266. return m.StageID()
  28267. case sopnode.FieldParentID:
  28268. return m.ParentID()
  28269. case sopnode.FieldName:
  28270. return m.Name()
  28271. case sopnode.FieldConditionType:
  28272. return m.ConditionType()
  28273. case sopnode.FieldConditionList:
  28274. return m.ConditionList()
  28275. case sopnode.FieldNoReplyCondition:
  28276. return m.NoReplyCondition()
  28277. case sopnode.FieldNoReplyUnit:
  28278. return m.NoReplyUnit()
  28279. case sopnode.FieldActionMessage:
  28280. return m.ActionMessage()
  28281. case sopnode.FieldActionLabelAdd:
  28282. return m.ActionLabelAdd()
  28283. case sopnode.FieldActionLabelDel:
  28284. return m.ActionLabelDel()
  28285. case sopnode.FieldActionForward:
  28286. return m.ActionForward()
  28287. }
  28288. return nil, false
  28289. }
  28290. // OldField returns the old value of the field from the database. An error is
  28291. // returned if the mutation operation is not UpdateOne, or the query to the
  28292. // database failed.
  28293. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  28294. switch name {
  28295. case sopnode.FieldCreatedAt:
  28296. return m.OldCreatedAt(ctx)
  28297. case sopnode.FieldUpdatedAt:
  28298. return m.OldUpdatedAt(ctx)
  28299. case sopnode.FieldStatus:
  28300. return m.OldStatus(ctx)
  28301. case sopnode.FieldDeletedAt:
  28302. return m.OldDeletedAt(ctx)
  28303. case sopnode.FieldStageID:
  28304. return m.OldStageID(ctx)
  28305. case sopnode.FieldParentID:
  28306. return m.OldParentID(ctx)
  28307. case sopnode.FieldName:
  28308. return m.OldName(ctx)
  28309. case sopnode.FieldConditionType:
  28310. return m.OldConditionType(ctx)
  28311. case sopnode.FieldConditionList:
  28312. return m.OldConditionList(ctx)
  28313. case sopnode.FieldNoReplyCondition:
  28314. return m.OldNoReplyCondition(ctx)
  28315. case sopnode.FieldNoReplyUnit:
  28316. return m.OldNoReplyUnit(ctx)
  28317. case sopnode.FieldActionMessage:
  28318. return m.OldActionMessage(ctx)
  28319. case sopnode.FieldActionLabelAdd:
  28320. return m.OldActionLabelAdd(ctx)
  28321. case sopnode.FieldActionLabelDel:
  28322. return m.OldActionLabelDel(ctx)
  28323. case sopnode.FieldActionForward:
  28324. return m.OldActionForward(ctx)
  28325. }
  28326. return nil, fmt.Errorf("unknown SopNode field %s", name)
  28327. }
  28328. // SetField sets the value of a field with the given name. It returns an error if
  28329. // the field is not defined in the schema, or if the type mismatched the field
  28330. // type.
  28331. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  28332. switch name {
  28333. case sopnode.FieldCreatedAt:
  28334. v, ok := value.(time.Time)
  28335. if !ok {
  28336. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28337. }
  28338. m.SetCreatedAt(v)
  28339. return nil
  28340. case sopnode.FieldUpdatedAt:
  28341. v, ok := value.(time.Time)
  28342. if !ok {
  28343. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28344. }
  28345. m.SetUpdatedAt(v)
  28346. return nil
  28347. case sopnode.FieldStatus:
  28348. v, ok := value.(uint8)
  28349. if !ok {
  28350. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28351. }
  28352. m.SetStatus(v)
  28353. return nil
  28354. case sopnode.FieldDeletedAt:
  28355. v, ok := value.(time.Time)
  28356. if !ok {
  28357. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28358. }
  28359. m.SetDeletedAt(v)
  28360. return nil
  28361. case sopnode.FieldStageID:
  28362. v, ok := value.(uint64)
  28363. if !ok {
  28364. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28365. }
  28366. m.SetStageID(v)
  28367. return nil
  28368. case sopnode.FieldParentID:
  28369. v, ok := value.(uint64)
  28370. if !ok {
  28371. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28372. }
  28373. m.SetParentID(v)
  28374. return nil
  28375. case sopnode.FieldName:
  28376. v, ok := value.(string)
  28377. if !ok {
  28378. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28379. }
  28380. m.SetName(v)
  28381. return nil
  28382. case sopnode.FieldConditionType:
  28383. v, ok := value.(int)
  28384. if !ok {
  28385. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28386. }
  28387. m.SetConditionType(v)
  28388. return nil
  28389. case sopnode.FieldConditionList:
  28390. v, ok := value.([]string)
  28391. if !ok {
  28392. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28393. }
  28394. m.SetConditionList(v)
  28395. return nil
  28396. case sopnode.FieldNoReplyCondition:
  28397. v, ok := value.(uint64)
  28398. if !ok {
  28399. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28400. }
  28401. m.SetNoReplyCondition(v)
  28402. return nil
  28403. case sopnode.FieldNoReplyUnit:
  28404. v, ok := value.(string)
  28405. if !ok {
  28406. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28407. }
  28408. m.SetNoReplyUnit(v)
  28409. return nil
  28410. case sopnode.FieldActionMessage:
  28411. v, ok := value.([]custom_types.Action)
  28412. if !ok {
  28413. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28414. }
  28415. m.SetActionMessage(v)
  28416. return nil
  28417. case sopnode.FieldActionLabelAdd:
  28418. v, ok := value.([]uint64)
  28419. if !ok {
  28420. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28421. }
  28422. m.SetActionLabelAdd(v)
  28423. return nil
  28424. case sopnode.FieldActionLabelDel:
  28425. v, ok := value.([]uint64)
  28426. if !ok {
  28427. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28428. }
  28429. m.SetActionLabelDel(v)
  28430. return nil
  28431. case sopnode.FieldActionForward:
  28432. v, ok := value.(*custom_types.ActionForward)
  28433. if !ok {
  28434. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28435. }
  28436. m.SetActionForward(v)
  28437. return nil
  28438. }
  28439. return fmt.Errorf("unknown SopNode field %s", name)
  28440. }
  28441. // AddedFields returns all numeric fields that were incremented/decremented during
  28442. // this mutation.
  28443. func (m *SopNodeMutation) AddedFields() []string {
  28444. var fields []string
  28445. if m.addstatus != nil {
  28446. fields = append(fields, sopnode.FieldStatus)
  28447. }
  28448. if m.addparent_id != nil {
  28449. fields = append(fields, sopnode.FieldParentID)
  28450. }
  28451. if m.addcondition_type != nil {
  28452. fields = append(fields, sopnode.FieldConditionType)
  28453. }
  28454. if m.addno_reply_condition != nil {
  28455. fields = append(fields, sopnode.FieldNoReplyCondition)
  28456. }
  28457. return fields
  28458. }
  28459. // AddedField returns the numeric value that was incremented/decremented on a field
  28460. // with the given name. The second boolean return value indicates that this field
  28461. // was not set, or was not defined in the schema.
  28462. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  28463. switch name {
  28464. case sopnode.FieldStatus:
  28465. return m.AddedStatus()
  28466. case sopnode.FieldParentID:
  28467. return m.AddedParentID()
  28468. case sopnode.FieldConditionType:
  28469. return m.AddedConditionType()
  28470. case sopnode.FieldNoReplyCondition:
  28471. return m.AddedNoReplyCondition()
  28472. }
  28473. return nil, false
  28474. }
  28475. // AddField adds the value to the field with the given name. It returns an error if
  28476. // the field is not defined in the schema, or if the type mismatched the field
  28477. // type.
  28478. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  28479. switch name {
  28480. case sopnode.FieldStatus:
  28481. v, ok := value.(int8)
  28482. if !ok {
  28483. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28484. }
  28485. m.AddStatus(v)
  28486. return nil
  28487. case sopnode.FieldParentID:
  28488. v, ok := value.(int64)
  28489. if !ok {
  28490. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28491. }
  28492. m.AddParentID(v)
  28493. return nil
  28494. case sopnode.FieldConditionType:
  28495. v, ok := value.(int)
  28496. if !ok {
  28497. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28498. }
  28499. m.AddConditionType(v)
  28500. return nil
  28501. case sopnode.FieldNoReplyCondition:
  28502. v, ok := value.(int64)
  28503. if !ok {
  28504. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28505. }
  28506. m.AddNoReplyCondition(v)
  28507. return nil
  28508. }
  28509. return fmt.Errorf("unknown SopNode numeric field %s", name)
  28510. }
  28511. // ClearedFields returns all nullable fields that were cleared during this
  28512. // mutation.
  28513. func (m *SopNodeMutation) ClearedFields() []string {
  28514. var fields []string
  28515. if m.FieldCleared(sopnode.FieldStatus) {
  28516. fields = append(fields, sopnode.FieldStatus)
  28517. }
  28518. if m.FieldCleared(sopnode.FieldDeletedAt) {
  28519. fields = append(fields, sopnode.FieldDeletedAt)
  28520. }
  28521. if m.FieldCleared(sopnode.FieldConditionList) {
  28522. fields = append(fields, sopnode.FieldConditionList)
  28523. }
  28524. if m.FieldCleared(sopnode.FieldActionMessage) {
  28525. fields = append(fields, sopnode.FieldActionMessage)
  28526. }
  28527. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  28528. fields = append(fields, sopnode.FieldActionLabelAdd)
  28529. }
  28530. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  28531. fields = append(fields, sopnode.FieldActionLabelDel)
  28532. }
  28533. if m.FieldCleared(sopnode.FieldActionForward) {
  28534. fields = append(fields, sopnode.FieldActionForward)
  28535. }
  28536. return fields
  28537. }
  28538. // FieldCleared returns a boolean indicating if a field with the given name was
  28539. // cleared in this mutation.
  28540. func (m *SopNodeMutation) FieldCleared(name string) bool {
  28541. _, ok := m.clearedFields[name]
  28542. return ok
  28543. }
  28544. // ClearField clears the value of the field with the given name. It returns an
  28545. // error if the field is not defined in the schema.
  28546. func (m *SopNodeMutation) ClearField(name string) error {
  28547. switch name {
  28548. case sopnode.FieldStatus:
  28549. m.ClearStatus()
  28550. return nil
  28551. case sopnode.FieldDeletedAt:
  28552. m.ClearDeletedAt()
  28553. return nil
  28554. case sopnode.FieldConditionList:
  28555. m.ClearConditionList()
  28556. return nil
  28557. case sopnode.FieldActionMessage:
  28558. m.ClearActionMessage()
  28559. return nil
  28560. case sopnode.FieldActionLabelAdd:
  28561. m.ClearActionLabelAdd()
  28562. return nil
  28563. case sopnode.FieldActionLabelDel:
  28564. m.ClearActionLabelDel()
  28565. return nil
  28566. case sopnode.FieldActionForward:
  28567. m.ClearActionForward()
  28568. return nil
  28569. }
  28570. return fmt.Errorf("unknown SopNode nullable field %s", name)
  28571. }
  28572. // ResetField resets all changes in the mutation for the field with the given name.
  28573. // It returns an error if the field is not defined in the schema.
  28574. func (m *SopNodeMutation) ResetField(name string) error {
  28575. switch name {
  28576. case sopnode.FieldCreatedAt:
  28577. m.ResetCreatedAt()
  28578. return nil
  28579. case sopnode.FieldUpdatedAt:
  28580. m.ResetUpdatedAt()
  28581. return nil
  28582. case sopnode.FieldStatus:
  28583. m.ResetStatus()
  28584. return nil
  28585. case sopnode.FieldDeletedAt:
  28586. m.ResetDeletedAt()
  28587. return nil
  28588. case sopnode.FieldStageID:
  28589. m.ResetStageID()
  28590. return nil
  28591. case sopnode.FieldParentID:
  28592. m.ResetParentID()
  28593. return nil
  28594. case sopnode.FieldName:
  28595. m.ResetName()
  28596. return nil
  28597. case sopnode.FieldConditionType:
  28598. m.ResetConditionType()
  28599. return nil
  28600. case sopnode.FieldConditionList:
  28601. m.ResetConditionList()
  28602. return nil
  28603. case sopnode.FieldNoReplyCondition:
  28604. m.ResetNoReplyCondition()
  28605. return nil
  28606. case sopnode.FieldNoReplyUnit:
  28607. m.ResetNoReplyUnit()
  28608. return nil
  28609. case sopnode.FieldActionMessage:
  28610. m.ResetActionMessage()
  28611. return nil
  28612. case sopnode.FieldActionLabelAdd:
  28613. m.ResetActionLabelAdd()
  28614. return nil
  28615. case sopnode.FieldActionLabelDel:
  28616. m.ResetActionLabelDel()
  28617. return nil
  28618. case sopnode.FieldActionForward:
  28619. m.ResetActionForward()
  28620. return nil
  28621. }
  28622. return fmt.Errorf("unknown SopNode field %s", name)
  28623. }
  28624. // AddedEdges returns all edge names that were set/added in this mutation.
  28625. func (m *SopNodeMutation) AddedEdges() []string {
  28626. edges := make([]string, 0, 2)
  28627. if m.sop_stage != nil {
  28628. edges = append(edges, sopnode.EdgeSopStage)
  28629. }
  28630. if m.node_messages != nil {
  28631. edges = append(edges, sopnode.EdgeNodeMessages)
  28632. }
  28633. return edges
  28634. }
  28635. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  28636. // name in this mutation.
  28637. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  28638. switch name {
  28639. case sopnode.EdgeSopStage:
  28640. if id := m.sop_stage; id != nil {
  28641. return []ent.Value{*id}
  28642. }
  28643. case sopnode.EdgeNodeMessages:
  28644. ids := make([]ent.Value, 0, len(m.node_messages))
  28645. for id := range m.node_messages {
  28646. ids = append(ids, id)
  28647. }
  28648. return ids
  28649. }
  28650. return nil
  28651. }
  28652. // RemovedEdges returns all edge names that were removed in this mutation.
  28653. func (m *SopNodeMutation) RemovedEdges() []string {
  28654. edges := make([]string, 0, 2)
  28655. if m.removednode_messages != nil {
  28656. edges = append(edges, sopnode.EdgeNodeMessages)
  28657. }
  28658. return edges
  28659. }
  28660. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  28661. // the given name in this mutation.
  28662. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  28663. switch name {
  28664. case sopnode.EdgeNodeMessages:
  28665. ids := make([]ent.Value, 0, len(m.removednode_messages))
  28666. for id := range m.removednode_messages {
  28667. ids = append(ids, id)
  28668. }
  28669. return ids
  28670. }
  28671. return nil
  28672. }
  28673. // ClearedEdges returns all edge names that were cleared in this mutation.
  28674. func (m *SopNodeMutation) ClearedEdges() []string {
  28675. edges := make([]string, 0, 2)
  28676. if m.clearedsop_stage {
  28677. edges = append(edges, sopnode.EdgeSopStage)
  28678. }
  28679. if m.clearednode_messages {
  28680. edges = append(edges, sopnode.EdgeNodeMessages)
  28681. }
  28682. return edges
  28683. }
  28684. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28685. // was cleared in this mutation.
  28686. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  28687. switch name {
  28688. case sopnode.EdgeSopStage:
  28689. return m.clearedsop_stage
  28690. case sopnode.EdgeNodeMessages:
  28691. return m.clearednode_messages
  28692. }
  28693. return false
  28694. }
  28695. // ClearEdge clears the value of the edge with the given name. It returns an error
  28696. // if that edge is not defined in the schema.
  28697. func (m *SopNodeMutation) ClearEdge(name string) error {
  28698. switch name {
  28699. case sopnode.EdgeSopStage:
  28700. m.ClearSopStage()
  28701. return nil
  28702. }
  28703. return fmt.Errorf("unknown SopNode unique edge %s", name)
  28704. }
  28705. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28706. // It returns an error if the edge is not defined in the schema.
  28707. func (m *SopNodeMutation) ResetEdge(name string) error {
  28708. switch name {
  28709. case sopnode.EdgeSopStage:
  28710. m.ResetSopStage()
  28711. return nil
  28712. case sopnode.EdgeNodeMessages:
  28713. m.ResetNodeMessages()
  28714. return nil
  28715. }
  28716. return fmt.Errorf("unknown SopNode edge %s", name)
  28717. }
  28718. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  28719. type SopStageMutation struct {
  28720. config
  28721. op Op
  28722. typ string
  28723. id *uint64
  28724. created_at *time.Time
  28725. updated_at *time.Time
  28726. status *uint8
  28727. addstatus *int8
  28728. deleted_at *time.Time
  28729. name *string
  28730. condition_type *int
  28731. addcondition_type *int
  28732. condition_operator *int
  28733. addcondition_operator *int
  28734. condition_list *[]custom_types.Condition
  28735. appendcondition_list []custom_types.Condition
  28736. action_message *[]custom_types.Action
  28737. appendaction_message []custom_types.Action
  28738. action_label_add *[]uint64
  28739. appendaction_label_add []uint64
  28740. action_label_del *[]uint64
  28741. appendaction_label_del []uint64
  28742. action_forward **custom_types.ActionForward
  28743. index_sort *int
  28744. addindex_sort *int
  28745. clearedFields map[string]struct{}
  28746. sop_task *uint64
  28747. clearedsop_task bool
  28748. stage_nodes map[uint64]struct{}
  28749. removedstage_nodes map[uint64]struct{}
  28750. clearedstage_nodes bool
  28751. stage_messages map[uint64]struct{}
  28752. removedstage_messages map[uint64]struct{}
  28753. clearedstage_messages bool
  28754. done bool
  28755. oldValue func(context.Context) (*SopStage, error)
  28756. predicates []predicate.SopStage
  28757. }
  28758. var _ ent.Mutation = (*SopStageMutation)(nil)
  28759. // sopstageOption allows management of the mutation configuration using functional options.
  28760. type sopstageOption func(*SopStageMutation)
  28761. // newSopStageMutation creates new mutation for the SopStage entity.
  28762. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  28763. m := &SopStageMutation{
  28764. config: c,
  28765. op: op,
  28766. typ: TypeSopStage,
  28767. clearedFields: make(map[string]struct{}),
  28768. }
  28769. for _, opt := range opts {
  28770. opt(m)
  28771. }
  28772. return m
  28773. }
  28774. // withSopStageID sets the ID field of the mutation.
  28775. func withSopStageID(id uint64) sopstageOption {
  28776. return func(m *SopStageMutation) {
  28777. var (
  28778. err error
  28779. once sync.Once
  28780. value *SopStage
  28781. )
  28782. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  28783. once.Do(func() {
  28784. if m.done {
  28785. err = errors.New("querying old values post mutation is not allowed")
  28786. } else {
  28787. value, err = m.Client().SopStage.Get(ctx, id)
  28788. }
  28789. })
  28790. return value, err
  28791. }
  28792. m.id = &id
  28793. }
  28794. }
  28795. // withSopStage sets the old SopStage of the mutation.
  28796. func withSopStage(node *SopStage) sopstageOption {
  28797. return func(m *SopStageMutation) {
  28798. m.oldValue = func(context.Context) (*SopStage, error) {
  28799. return node, nil
  28800. }
  28801. m.id = &node.ID
  28802. }
  28803. }
  28804. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28805. // executed in a transaction (ent.Tx), a transactional client is returned.
  28806. func (m SopStageMutation) Client() *Client {
  28807. client := &Client{config: m.config}
  28808. client.init()
  28809. return client
  28810. }
  28811. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28812. // it returns an error otherwise.
  28813. func (m SopStageMutation) Tx() (*Tx, error) {
  28814. if _, ok := m.driver.(*txDriver); !ok {
  28815. return nil, errors.New("ent: mutation is not running in a transaction")
  28816. }
  28817. tx := &Tx{config: m.config}
  28818. tx.init()
  28819. return tx, nil
  28820. }
  28821. // SetID sets the value of the id field. Note that this
  28822. // operation is only accepted on creation of SopStage entities.
  28823. func (m *SopStageMutation) SetID(id uint64) {
  28824. m.id = &id
  28825. }
  28826. // ID returns the ID value in the mutation. Note that the ID is only available
  28827. // if it was provided to the builder or after it was returned from the database.
  28828. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  28829. if m.id == nil {
  28830. return
  28831. }
  28832. return *m.id, true
  28833. }
  28834. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28835. // That means, if the mutation is applied within a transaction with an isolation level such
  28836. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28837. // or updated by the mutation.
  28838. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  28839. switch {
  28840. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28841. id, exists := m.ID()
  28842. if exists {
  28843. return []uint64{id}, nil
  28844. }
  28845. fallthrough
  28846. case m.op.Is(OpUpdate | OpDelete):
  28847. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  28848. default:
  28849. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28850. }
  28851. }
  28852. // SetCreatedAt sets the "created_at" field.
  28853. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  28854. m.created_at = &t
  28855. }
  28856. // CreatedAt returns the value of the "created_at" field in the mutation.
  28857. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  28858. v := m.created_at
  28859. if v == nil {
  28860. return
  28861. }
  28862. return *v, true
  28863. }
  28864. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  28865. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28866. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28867. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  28868. if !m.op.Is(OpUpdateOne) {
  28869. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  28870. }
  28871. if m.id == nil || m.oldValue == nil {
  28872. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  28873. }
  28874. oldValue, err := m.oldValue(ctx)
  28875. if err != nil {
  28876. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  28877. }
  28878. return oldValue.CreatedAt, nil
  28879. }
  28880. // ResetCreatedAt resets all changes to the "created_at" field.
  28881. func (m *SopStageMutation) ResetCreatedAt() {
  28882. m.created_at = nil
  28883. }
  28884. // SetUpdatedAt sets the "updated_at" field.
  28885. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  28886. m.updated_at = &t
  28887. }
  28888. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  28889. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  28890. v := m.updated_at
  28891. if v == nil {
  28892. return
  28893. }
  28894. return *v, true
  28895. }
  28896. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  28897. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28898. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28899. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  28900. if !m.op.Is(OpUpdateOne) {
  28901. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  28902. }
  28903. if m.id == nil || m.oldValue == nil {
  28904. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  28905. }
  28906. oldValue, err := m.oldValue(ctx)
  28907. if err != nil {
  28908. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  28909. }
  28910. return oldValue.UpdatedAt, nil
  28911. }
  28912. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28913. func (m *SopStageMutation) ResetUpdatedAt() {
  28914. m.updated_at = nil
  28915. }
  28916. // SetStatus sets the "status" field.
  28917. func (m *SopStageMutation) SetStatus(u uint8) {
  28918. m.status = &u
  28919. m.addstatus = nil
  28920. }
  28921. // Status returns the value of the "status" field in the mutation.
  28922. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  28923. v := m.status
  28924. if v == nil {
  28925. return
  28926. }
  28927. return *v, true
  28928. }
  28929. // OldStatus returns the old "status" field's value of the SopStage entity.
  28930. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28931. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28932. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  28933. if !m.op.Is(OpUpdateOne) {
  28934. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  28935. }
  28936. if m.id == nil || m.oldValue == nil {
  28937. return v, errors.New("OldStatus requires an ID field in the mutation")
  28938. }
  28939. oldValue, err := m.oldValue(ctx)
  28940. if err != nil {
  28941. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  28942. }
  28943. return oldValue.Status, nil
  28944. }
  28945. // AddStatus adds u to the "status" field.
  28946. func (m *SopStageMutation) AddStatus(u int8) {
  28947. if m.addstatus != nil {
  28948. *m.addstatus += u
  28949. } else {
  28950. m.addstatus = &u
  28951. }
  28952. }
  28953. // AddedStatus returns the value that was added to the "status" field in this mutation.
  28954. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  28955. v := m.addstatus
  28956. if v == nil {
  28957. return
  28958. }
  28959. return *v, true
  28960. }
  28961. // ClearStatus clears the value of the "status" field.
  28962. func (m *SopStageMutation) ClearStatus() {
  28963. m.status = nil
  28964. m.addstatus = nil
  28965. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  28966. }
  28967. // StatusCleared returns if the "status" field was cleared in this mutation.
  28968. func (m *SopStageMutation) StatusCleared() bool {
  28969. _, ok := m.clearedFields[sopstage.FieldStatus]
  28970. return ok
  28971. }
  28972. // ResetStatus resets all changes to the "status" field.
  28973. func (m *SopStageMutation) ResetStatus() {
  28974. m.status = nil
  28975. m.addstatus = nil
  28976. delete(m.clearedFields, sopstage.FieldStatus)
  28977. }
  28978. // SetDeletedAt sets the "deleted_at" field.
  28979. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  28980. m.deleted_at = &t
  28981. }
  28982. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  28983. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  28984. v := m.deleted_at
  28985. if v == nil {
  28986. return
  28987. }
  28988. return *v, true
  28989. }
  28990. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  28991. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28992. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28993. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  28994. if !m.op.Is(OpUpdateOne) {
  28995. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  28996. }
  28997. if m.id == nil || m.oldValue == nil {
  28998. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  28999. }
  29000. oldValue, err := m.oldValue(ctx)
  29001. if err != nil {
  29002. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  29003. }
  29004. return oldValue.DeletedAt, nil
  29005. }
  29006. // ClearDeletedAt clears the value of the "deleted_at" field.
  29007. func (m *SopStageMutation) ClearDeletedAt() {
  29008. m.deleted_at = nil
  29009. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  29010. }
  29011. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  29012. func (m *SopStageMutation) DeletedAtCleared() bool {
  29013. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  29014. return ok
  29015. }
  29016. // ResetDeletedAt resets all changes to the "deleted_at" field.
  29017. func (m *SopStageMutation) ResetDeletedAt() {
  29018. m.deleted_at = nil
  29019. delete(m.clearedFields, sopstage.FieldDeletedAt)
  29020. }
  29021. // SetTaskID sets the "task_id" field.
  29022. func (m *SopStageMutation) SetTaskID(u uint64) {
  29023. m.sop_task = &u
  29024. }
  29025. // TaskID returns the value of the "task_id" field in the mutation.
  29026. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  29027. v := m.sop_task
  29028. if v == nil {
  29029. return
  29030. }
  29031. return *v, true
  29032. }
  29033. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  29034. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  29035. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29036. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  29037. if !m.op.Is(OpUpdateOne) {
  29038. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  29039. }
  29040. if m.id == nil || m.oldValue == nil {
  29041. return v, errors.New("OldTaskID requires an ID field in the mutation")
  29042. }
  29043. oldValue, err := m.oldValue(ctx)
  29044. if err != nil {
  29045. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  29046. }
  29047. return oldValue.TaskID, nil
  29048. }
  29049. // ResetTaskID resets all changes to the "task_id" field.
  29050. func (m *SopStageMutation) ResetTaskID() {
  29051. m.sop_task = nil
  29052. }
  29053. // SetName sets the "name" field.
  29054. func (m *SopStageMutation) SetName(s string) {
  29055. m.name = &s
  29056. }
  29057. // Name returns the value of the "name" field in the mutation.
  29058. func (m *SopStageMutation) Name() (r string, exists bool) {
  29059. v := m.name
  29060. if v == nil {
  29061. return
  29062. }
  29063. return *v, true
  29064. }
  29065. // OldName returns the old "name" field's value of the SopStage entity.
  29066. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  29067. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29068. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  29069. if !m.op.Is(OpUpdateOne) {
  29070. return v, errors.New("OldName is only allowed on UpdateOne operations")
  29071. }
  29072. if m.id == nil || m.oldValue == nil {
  29073. return v, errors.New("OldName requires an ID field in the mutation")
  29074. }
  29075. oldValue, err := m.oldValue(ctx)
  29076. if err != nil {
  29077. return v, fmt.Errorf("querying old value for OldName: %w", err)
  29078. }
  29079. return oldValue.Name, nil
  29080. }
  29081. // ResetName resets all changes to the "name" field.
  29082. func (m *SopStageMutation) ResetName() {
  29083. m.name = nil
  29084. }
  29085. // SetConditionType sets the "condition_type" field.
  29086. func (m *SopStageMutation) SetConditionType(i int) {
  29087. m.condition_type = &i
  29088. m.addcondition_type = nil
  29089. }
  29090. // ConditionType returns the value of the "condition_type" field in the mutation.
  29091. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  29092. v := m.condition_type
  29093. if v == nil {
  29094. return
  29095. }
  29096. return *v, true
  29097. }
  29098. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  29099. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  29100. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29101. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  29102. if !m.op.Is(OpUpdateOne) {
  29103. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  29104. }
  29105. if m.id == nil || m.oldValue == nil {
  29106. return v, errors.New("OldConditionType requires an ID field in the mutation")
  29107. }
  29108. oldValue, err := m.oldValue(ctx)
  29109. if err != nil {
  29110. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  29111. }
  29112. return oldValue.ConditionType, nil
  29113. }
  29114. // AddConditionType adds i to the "condition_type" field.
  29115. func (m *SopStageMutation) AddConditionType(i int) {
  29116. if m.addcondition_type != nil {
  29117. *m.addcondition_type += i
  29118. } else {
  29119. m.addcondition_type = &i
  29120. }
  29121. }
  29122. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  29123. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  29124. v := m.addcondition_type
  29125. if v == nil {
  29126. return
  29127. }
  29128. return *v, true
  29129. }
  29130. // ResetConditionType resets all changes to the "condition_type" field.
  29131. func (m *SopStageMutation) ResetConditionType() {
  29132. m.condition_type = nil
  29133. m.addcondition_type = nil
  29134. }
  29135. // SetConditionOperator sets the "condition_operator" field.
  29136. func (m *SopStageMutation) SetConditionOperator(i int) {
  29137. m.condition_operator = &i
  29138. m.addcondition_operator = nil
  29139. }
  29140. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  29141. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  29142. v := m.condition_operator
  29143. if v == nil {
  29144. return
  29145. }
  29146. return *v, true
  29147. }
  29148. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  29149. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  29150. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29151. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  29152. if !m.op.Is(OpUpdateOne) {
  29153. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  29154. }
  29155. if m.id == nil || m.oldValue == nil {
  29156. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  29157. }
  29158. oldValue, err := m.oldValue(ctx)
  29159. if err != nil {
  29160. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  29161. }
  29162. return oldValue.ConditionOperator, nil
  29163. }
  29164. // AddConditionOperator adds i to the "condition_operator" field.
  29165. func (m *SopStageMutation) AddConditionOperator(i int) {
  29166. if m.addcondition_operator != nil {
  29167. *m.addcondition_operator += i
  29168. } else {
  29169. m.addcondition_operator = &i
  29170. }
  29171. }
  29172. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  29173. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  29174. v := m.addcondition_operator
  29175. if v == nil {
  29176. return
  29177. }
  29178. return *v, true
  29179. }
  29180. // ResetConditionOperator resets all changes to the "condition_operator" field.
  29181. func (m *SopStageMutation) ResetConditionOperator() {
  29182. m.condition_operator = nil
  29183. m.addcondition_operator = nil
  29184. }
  29185. // SetConditionList sets the "condition_list" field.
  29186. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  29187. m.condition_list = &ct
  29188. m.appendcondition_list = nil
  29189. }
  29190. // ConditionList returns the value of the "condition_list" field in the mutation.
  29191. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  29192. v := m.condition_list
  29193. if v == nil {
  29194. return
  29195. }
  29196. return *v, true
  29197. }
  29198. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  29199. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  29200. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29201. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  29202. if !m.op.Is(OpUpdateOne) {
  29203. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  29204. }
  29205. if m.id == nil || m.oldValue == nil {
  29206. return v, errors.New("OldConditionList requires an ID field in the mutation")
  29207. }
  29208. oldValue, err := m.oldValue(ctx)
  29209. if err != nil {
  29210. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  29211. }
  29212. return oldValue.ConditionList, nil
  29213. }
  29214. // AppendConditionList adds ct to the "condition_list" field.
  29215. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  29216. m.appendcondition_list = append(m.appendcondition_list, ct...)
  29217. }
  29218. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  29219. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  29220. if len(m.appendcondition_list) == 0 {
  29221. return nil, false
  29222. }
  29223. return m.appendcondition_list, true
  29224. }
  29225. // ResetConditionList resets all changes to the "condition_list" field.
  29226. func (m *SopStageMutation) ResetConditionList() {
  29227. m.condition_list = nil
  29228. m.appendcondition_list = nil
  29229. }
  29230. // SetActionMessage sets the "action_message" field.
  29231. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  29232. m.action_message = &ct
  29233. m.appendaction_message = nil
  29234. }
  29235. // ActionMessage returns the value of the "action_message" field in the mutation.
  29236. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  29237. v := m.action_message
  29238. if v == nil {
  29239. return
  29240. }
  29241. return *v, true
  29242. }
  29243. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  29244. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  29245. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29246. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  29247. if !m.op.Is(OpUpdateOne) {
  29248. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  29249. }
  29250. if m.id == nil || m.oldValue == nil {
  29251. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  29252. }
  29253. oldValue, err := m.oldValue(ctx)
  29254. if err != nil {
  29255. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  29256. }
  29257. return oldValue.ActionMessage, nil
  29258. }
  29259. // AppendActionMessage adds ct to the "action_message" field.
  29260. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  29261. m.appendaction_message = append(m.appendaction_message, ct...)
  29262. }
  29263. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  29264. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  29265. if len(m.appendaction_message) == 0 {
  29266. return nil, false
  29267. }
  29268. return m.appendaction_message, true
  29269. }
  29270. // ClearActionMessage clears the value of the "action_message" field.
  29271. func (m *SopStageMutation) ClearActionMessage() {
  29272. m.action_message = nil
  29273. m.appendaction_message = nil
  29274. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  29275. }
  29276. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  29277. func (m *SopStageMutation) ActionMessageCleared() bool {
  29278. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  29279. return ok
  29280. }
  29281. // ResetActionMessage resets all changes to the "action_message" field.
  29282. func (m *SopStageMutation) ResetActionMessage() {
  29283. m.action_message = nil
  29284. m.appendaction_message = nil
  29285. delete(m.clearedFields, sopstage.FieldActionMessage)
  29286. }
  29287. // SetActionLabelAdd sets the "action_label_add" field.
  29288. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  29289. m.action_label_add = &u
  29290. m.appendaction_label_add = nil
  29291. }
  29292. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  29293. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  29294. v := m.action_label_add
  29295. if v == nil {
  29296. return
  29297. }
  29298. return *v, true
  29299. }
  29300. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  29301. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  29302. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29303. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  29304. if !m.op.Is(OpUpdateOne) {
  29305. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  29306. }
  29307. if m.id == nil || m.oldValue == nil {
  29308. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  29309. }
  29310. oldValue, err := m.oldValue(ctx)
  29311. if err != nil {
  29312. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  29313. }
  29314. return oldValue.ActionLabelAdd, nil
  29315. }
  29316. // AppendActionLabelAdd adds u to the "action_label_add" field.
  29317. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  29318. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  29319. }
  29320. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  29321. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  29322. if len(m.appendaction_label_add) == 0 {
  29323. return nil, false
  29324. }
  29325. return m.appendaction_label_add, true
  29326. }
  29327. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  29328. func (m *SopStageMutation) ClearActionLabelAdd() {
  29329. m.action_label_add = nil
  29330. m.appendaction_label_add = nil
  29331. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  29332. }
  29333. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  29334. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  29335. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  29336. return ok
  29337. }
  29338. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  29339. func (m *SopStageMutation) ResetActionLabelAdd() {
  29340. m.action_label_add = nil
  29341. m.appendaction_label_add = nil
  29342. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  29343. }
  29344. // SetActionLabelDel sets the "action_label_del" field.
  29345. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  29346. m.action_label_del = &u
  29347. m.appendaction_label_del = nil
  29348. }
  29349. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  29350. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  29351. v := m.action_label_del
  29352. if v == nil {
  29353. return
  29354. }
  29355. return *v, true
  29356. }
  29357. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  29358. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  29359. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29360. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  29361. if !m.op.Is(OpUpdateOne) {
  29362. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  29363. }
  29364. if m.id == nil || m.oldValue == nil {
  29365. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  29366. }
  29367. oldValue, err := m.oldValue(ctx)
  29368. if err != nil {
  29369. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  29370. }
  29371. return oldValue.ActionLabelDel, nil
  29372. }
  29373. // AppendActionLabelDel adds u to the "action_label_del" field.
  29374. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  29375. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  29376. }
  29377. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  29378. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  29379. if len(m.appendaction_label_del) == 0 {
  29380. return nil, false
  29381. }
  29382. return m.appendaction_label_del, true
  29383. }
  29384. // ClearActionLabelDel clears the value of the "action_label_del" field.
  29385. func (m *SopStageMutation) ClearActionLabelDel() {
  29386. m.action_label_del = nil
  29387. m.appendaction_label_del = nil
  29388. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  29389. }
  29390. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  29391. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  29392. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  29393. return ok
  29394. }
  29395. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  29396. func (m *SopStageMutation) ResetActionLabelDel() {
  29397. m.action_label_del = nil
  29398. m.appendaction_label_del = nil
  29399. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  29400. }
  29401. // SetActionForward sets the "action_forward" field.
  29402. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  29403. m.action_forward = &ctf
  29404. }
  29405. // ActionForward returns the value of the "action_forward" field in the mutation.
  29406. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  29407. v := m.action_forward
  29408. if v == nil {
  29409. return
  29410. }
  29411. return *v, true
  29412. }
  29413. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  29414. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  29415. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29416. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  29417. if !m.op.Is(OpUpdateOne) {
  29418. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  29419. }
  29420. if m.id == nil || m.oldValue == nil {
  29421. return v, errors.New("OldActionForward requires an ID field in the mutation")
  29422. }
  29423. oldValue, err := m.oldValue(ctx)
  29424. if err != nil {
  29425. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  29426. }
  29427. return oldValue.ActionForward, nil
  29428. }
  29429. // ClearActionForward clears the value of the "action_forward" field.
  29430. func (m *SopStageMutation) ClearActionForward() {
  29431. m.action_forward = nil
  29432. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  29433. }
  29434. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  29435. func (m *SopStageMutation) ActionForwardCleared() bool {
  29436. _, ok := m.clearedFields[sopstage.FieldActionForward]
  29437. return ok
  29438. }
  29439. // ResetActionForward resets all changes to the "action_forward" field.
  29440. func (m *SopStageMutation) ResetActionForward() {
  29441. m.action_forward = nil
  29442. delete(m.clearedFields, sopstage.FieldActionForward)
  29443. }
  29444. // SetIndexSort sets the "index_sort" field.
  29445. func (m *SopStageMutation) SetIndexSort(i int) {
  29446. m.index_sort = &i
  29447. m.addindex_sort = nil
  29448. }
  29449. // IndexSort returns the value of the "index_sort" field in the mutation.
  29450. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  29451. v := m.index_sort
  29452. if v == nil {
  29453. return
  29454. }
  29455. return *v, true
  29456. }
  29457. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  29458. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  29459. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29460. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  29461. if !m.op.Is(OpUpdateOne) {
  29462. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  29463. }
  29464. if m.id == nil || m.oldValue == nil {
  29465. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  29466. }
  29467. oldValue, err := m.oldValue(ctx)
  29468. if err != nil {
  29469. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  29470. }
  29471. return oldValue.IndexSort, nil
  29472. }
  29473. // AddIndexSort adds i to the "index_sort" field.
  29474. func (m *SopStageMutation) AddIndexSort(i int) {
  29475. if m.addindex_sort != nil {
  29476. *m.addindex_sort += i
  29477. } else {
  29478. m.addindex_sort = &i
  29479. }
  29480. }
  29481. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  29482. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  29483. v := m.addindex_sort
  29484. if v == nil {
  29485. return
  29486. }
  29487. return *v, true
  29488. }
  29489. // ClearIndexSort clears the value of the "index_sort" field.
  29490. func (m *SopStageMutation) ClearIndexSort() {
  29491. m.index_sort = nil
  29492. m.addindex_sort = nil
  29493. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  29494. }
  29495. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  29496. func (m *SopStageMutation) IndexSortCleared() bool {
  29497. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  29498. return ok
  29499. }
  29500. // ResetIndexSort resets all changes to the "index_sort" field.
  29501. func (m *SopStageMutation) ResetIndexSort() {
  29502. m.index_sort = nil
  29503. m.addindex_sort = nil
  29504. delete(m.clearedFields, sopstage.FieldIndexSort)
  29505. }
  29506. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  29507. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  29508. m.sop_task = &id
  29509. }
  29510. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  29511. func (m *SopStageMutation) ClearSopTask() {
  29512. m.clearedsop_task = true
  29513. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  29514. }
  29515. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  29516. func (m *SopStageMutation) SopTaskCleared() bool {
  29517. return m.clearedsop_task
  29518. }
  29519. // SopTaskID returns the "sop_task" edge ID in the mutation.
  29520. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  29521. if m.sop_task != nil {
  29522. return *m.sop_task, true
  29523. }
  29524. return
  29525. }
  29526. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  29527. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  29528. // SopTaskID instead. It exists only for internal usage by the builders.
  29529. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  29530. if id := m.sop_task; id != nil {
  29531. ids = append(ids, *id)
  29532. }
  29533. return
  29534. }
  29535. // ResetSopTask resets all changes to the "sop_task" edge.
  29536. func (m *SopStageMutation) ResetSopTask() {
  29537. m.sop_task = nil
  29538. m.clearedsop_task = false
  29539. }
  29540. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  29541. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  29542. if m.stage_nodes == nil {
  29543. m.stage_nodes = make(map[uint64]struct{})
  29544. }
  29545. for i := range ids {
  29546. m.stage_nodes[ids[i]] = struct{}{}
  29547. }
  29548. }
  29549. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  29550. func (m *SopStageMutation) ClearStageNodes() {
  29551. m.clearedstage_nodes = true
  29552. }
  29553. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  29554. func (m *SopStageMutation) StageNodesCleared() bool {
  29555. return m.clearedstage_nodes
  29556. }
  29557. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  29558. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  29559. if m.removedstage_nodes == nil {
  29560. m.removedstage_nodes = make(map[uint64]struct{})
  29561. }
  29562. for i := range ids {
  29563. delete(m.stage_nodes, ids[i])
  29564. m.removedstage_nodes[ids[i]] = struct{}{}
  29565. }
  29566. }
  29567. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  29568. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  29569. for id := range m.removedstage_nodes {
  29570. ids = append(ids, id)
  29571. }
  29572. return
  29573. }
  29574. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  29575. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  29576. for id := range m.stage_nodes {
  29577. ids = append(ids, id)
  29578. }
  29579. return
  29580. }
  29581. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  29582. func (m *SopStageMutation) ResetStageNodes() {
  29583. m.stage_nodes = nil
  29584. m.clearedstage_nodes = false
  29585. m.removedstage_nodes = nil
  29586. }
  29587. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  29588. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  29589. if m.stage_messages == nil {
  29590. m.stage_messages = make(map[uint64]struct{})
  29591. }
  29592. for i := range ids {
  29593. m.stage_messages[ids[i]] = struct{}{}
  29594. }
  29595. }
  29596. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  29597. func (m *SopStageMutation) ClearStageMessages() {
  29598. m.clearedstage_messages = true
  29599. }
  29600. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  29601. func (m *SopStageMutation) StageMessagesCleared() bool {
  29602. return m.clearedstage_messages
  29603. }
  29604. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  29605. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  29606. if m.removedstage_messages == nil {
  29607. m.removedstage_messages = make(map[uint64]struct{})
  29608. }
  29609. for i := range ids {
  29610. delete(m.stage_messages, ids[i])
  29611. m.removedstage_messages[ids[i]] = struct{}{}
  29612. }
  29613. }
  29614. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  29615. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  29616. for id := range m.removedstage_messages {
  29617. ids = append(ids, id)
  29618. }
  29619. return
  29620. }
  29621. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  29622. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  29623. for id := range m.stage_messages {
  29624. ids = append(ids, id)
  29625. }
  29626. return
  29627. }
  29628. // ResetStageMessages resets all changes to the "stage_messages" edge.
  29629. func (m *SopStageMutation) ResetStageMessages() {
  29630. m.stage_messages = nil
  29631. m.clearedstage_messages = false
  29632. m.removedstage_messages = nil
  29633. }
  29634. // Where appends a list predicates to the SopStageMutation builder.
  29635. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  29636. m.predicates = append(m.predicates, ps...)
  29637. }
  29638. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  29639. // users can use type-assertion to append predicates that do not depend on any generated package.
  29640. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  29641. p := make([]predicate.SopStage, len(ps))
  29642. for i := range ps {
  29643. p[i] = ps[i]
  29644. }
  29645. m.Where(p...)
  29646. }
  29647. // Op returns the operation name.
  29648. func (m *SopStageMutation) Op() Op {
  29649. return m.op
  29650. }
  29651. // SetOp allows setting the mutation operation.
  29652. func (m *SopStageMutation) SetOp(op Op) {
  29653. m.op = op
  29654. }
  29655. // Type returns the node type of this mutation (SopStage).
  29656. func (m *SopStageMutation) Type() string {
  29657. return m.typ
  29658. }
  29659. // Fields returns all fields that were changed during this mutation. Note that in
  29660. // order to get all numeric fields that were incremented/decremented, call
  29661. // AddedFields().
  29662. func (m *SopStageMutation) Fields() []string {
  29663. fields := make([]string, 0, 14)
  29664. if m.created_at != nil {
  29665. fields = append(fields, sopstage.FieldCreatedAt)
  29666. }
  29667. if m.updated_at != nil {
  29668. fields = append(fields, sopstage.FieldUpdatedAt)
  29669. }
  29670. if m.status != nil {
  29671. fields = append(fields, sopstage.FieldStatus)
  29672. }
  29673. if m.deleted_at != nil {
  29674. fields = append(fields, sopstage.FieldDeletedAt)
  29675. }
  29676. if m.sop_task != nil {
  29677. fields = append(fields, sopstage.FieldTaskID)
  29678. }
  29679. if m.name != nil {
  29680. fields = append(fields, sopstage.FieldName)
  29681. }
  29682. if m.condition_type != nil {
  29683. fields = append(fields, sopstage.FieldConditionType)
  29684. }
  29685. if m.condition_operator != nil {
  29686. fields = append(fields, sopstage.FieldConditionOperator)
  29687. }
  29688. if m.condition_list != nil {
  29689. fields = append(fields, sopstage.FieldConditionList)
  29690. }
  29691. if m.action_message != nil {
  29692. fields = append(fields, sopstage.FieldActionMessage)
  29693. }
  29694. if m.action_label_add != nil {
  29695. fields = append(fields, sopstage.FieldActionLabelAdd)
  29696. }
  29697. if m.action_label_del != nil {
  29698. fields = append(fields, sopstage.FieldActionLabelDel)
  29699. }
  29700. if m.action_forward != nil {
  29701. fields = append(fields, sopstage.FieldActionForward)
  29702. }
  29703. if m.index_sort != nil {
  29704. fields = append(fields, sopstage.FieldIndexSort)
  29705. }
  29706. return fields
  29707. }
  29708. // Field returns the value of a field with the given name. The second boolean
  29709. // return value indicates that this field was not set, or was not defined in the
  29710. // schema.
  29711. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  29712. switch name {
  29713. case sopstage.FieldCreatedAt:
  29714. return m.CreatedAt()
  29715. case sopstage.FieldUpdatedAt:
  29716. return m.UpdatedAt()
  29717. case sopstage.FieldStatus:
  29718. return m.Status()
  29719. case sopstage.FieldDeletedAt:
  29720. return m.DeletedAt()
  29721. case sopstage.FieldTaskID:
  29722. return m.TaskID()
  29723. case sopstage.FieldName:
  29724. return m.Name()
  29725. case sopstage.FieldConditionType:
  29726. return m.ConditionType()
  29727. case sopstage.FieldConditionOperator:
  29728. return m.ConditionOperator()
  29729. case sopstage.FieldConditionList:
  29730. return m.ConditionList()
  29731. case sopstage.FieldActionMessage:
  29732. return m.ActionMessage()
  29733. case sopstage.FieldActionLabelAdd:
  29734. return m.ActionLabelAdd()
  29735. case sopstage.FieldActionLabelDel:
  29736. return m.ActionLabelDel()
  29737. case sopstage.FieldActionForward:
  29738. return m.ActionForward()
  29739. case sopstage.FieldIndexSort:
  29740. return m.IndexSort()
  29741. }
  29742. return nil, false
  29743. }
  29744. // OldField returns the old value of the field from the database. An error is
  29745. // returned if the mutation operation is not UpdateOne, or the query to the
  29746. // database failed.
  29747. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29748. switch name {
  29749. case sopstage.FieldCreatedAt:
  29750. return m.OldCreatedAt(ctx)
  29751. case sopstage.FieldUpdatedAt:
  29752. return m.OldUpdatedAt(ctx)
  29753. case sopstage.FieldStatus:
  29754. return m.OldStatus(ctx)
  29755. case sopstage.FieldDeletedAt:
  29756. return m.OldDeletedAt(ctx)
  29757. case sopstage.FieldTaskID:
  29758. return m.OldTaskID(ctx)
  29759. case sopstage.FieldName:
  29760. return m.OldName(ctx)
  29761. case sopstage.FieldConditionType:
  29762. return m.OldConditionType(ctx)
  29763. case sopstage.FieldConditionOperator:
  29764. return m.OldConditionOperator(ctx)
  29765. case sopstage.FieldConditionList:
  29766. return m.OldConditionList(ctx)
  29767. case sopstage.FieldActionMessage:
  29768. return m.OldActionMessage(ctx)
  29769. case sopstage.FieldActionLabelAdd:
  29770. return m.OldActionLabelAdd(ctx)
  29771. case sopstage.FieldActionLabelDel:
  29772. return m.OldActionLabelDel(ctx)
  29773. case sopstage.FieldActionForward:
  29774. return m.OldActionForward(ctx)
  29775. case sopstage.FieldIndexSort:
  29776. return m.OldIndexSort(ctx)
  29777. }
  29778. return nil, fmt.Errorf("unknown SopStage field %s", name)
  29779. }
  29780. // SetField sets the value of a field with the given name. It returns an error if
  29781. // the field is not defined in the schema, or if the type mismatched the field
  29782. // type.
  29783. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  29784. switch name {
  29785. case sopstage.FieldCreatedAt:
  29786. v, ok := value.(time.Time)
  29787. if !ok {
  29788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29789. }
  29790. m.SetCreatedAt(v)
  29791. return nil
  29792. case sopstage.FieldUpdatedAt:
  29793. v, ok := value.(time.Time)
  29794. if !ok {
  29795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29796. }
  29797. m.SetUpdatedAt(v)
  29798. return nil
  29799. case sopstage.FieldStatus:
  29800. v, ok := value.(uint8)
  29801. if !ok {
  29802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29803. }
  29804. m.SetStatus(v)
  29805. return nil
  29806. case sopstage.FieldDeletedAt:
  29807. v, ok := value.(time.Time)
  29808. if !ok {
  29809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29810. }
  29811. m.SetDeletedAt(v)
  29812. return nil
  29813. case sopstage.FieldTaskID:
  29814. v, ok := value.(uint64)
  29815. if !ok {
  29816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29817. }
  29818. m.SetTaskID(v)
  29819. return nil
  29820. case sopstage.FieldName:
  29821. v, ok := value.(string)
  29822. if !ok {
  29823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29824. }
  29825. m.SetName(v)
  29826. return nil
  29827. case sopstage.FieldConditionType:
  29828. v, ok := value.(int)
  29829. if !ok {
  29830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29831. }
  29832. m.SetConditionType(v)
  29833. return nil
  29834. case sopstage.FieldConditionOperator:
  29835. v, ok := value.(int)
  29836. if !ok {
  29837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29838. }
  29839. m.SetConditionOperator(v)
  29840. return nil
  29841. case sopstage.FieldConditionList:
  29842. v, ok := value.([]custom_types.Condition)
  29843. if !ok {
  29844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29845. }
  29846. m.SetConditionList(v)
  29847. return nil
  29848. case sopstage.FieldActionMessage:
  29849. v, ok := value.([]custom_types.Action)
  29850. if !ok {
  29851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29852. }
  29853. m.SetActionMessage(v)
  29854. return nil
  29855. case sopstage.FieldActionLabelAdd:
  29856. v, ok := value.([]uint64)
  29857. if !ok {
  29858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29859. }
  29860. m.SetActionLabelAdd(v)
  29861. return nil
  29862. case sopstage.FieldActionLabelDel:
  29863. v, ok := value.([]uint64)
  29864. if !ok {
  29865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29866. }
  29867. m.SetActionLabelDel(v)
  29868. return nil
  29869. case sopstage.FieldActionForward:
  29870. v, ok := value.(*custom_types.ActionForward)
  29871. if !ok {
  29872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29873. }
  29874. m.SetActionForward(v)
  29875. return nil
  29876. case sopstage.FieldIndexSort:
  29877. v, ok := value.(int)
  29878. if !ok {
  29879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29880. }
  29881. m.SetIndexSort(v)
  29882. return nil
  29883. }
  29884. return fmt.Errorf("unknown SopStage field %s", name)
  29885. }
  29886. // AddedFields returns all numeric fields that were incremented/decremented during
  29887. // this mutation.
  29888. func (m *SopStageMutation) AddedFields() []string {
  29889. var fields []string
  29890. if m.addstatus != nil {
  29891. fields = append(fields, sopstage.FieldStatus)
  29892. }
  29893. if m.addcondition_type != nil {
  29894. fields = append(fields, sopstage.FieldConditionType)
  29895. }
  29896. if m.addcondition_operator != nil {
  29897. fields = append(fields, sopstage.FieldConditionOperator)
  29898. }
  29899. if m.addindex_sort != nil {
  29900. fields = append(fields, sopstage.FieldIndexSort)
  29901. }
  29902. return fields
  29903. }
  29904. // AddedField returns the numeric value that was incremented/decremented on a field
  29905. // with the given name. The second boolean return value indicates that this field
  29906. // was not set, or was not defined in the schema.
  29907. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  29908. switch name {
  29909. case sopstage.FieldStatus:
  29910. return m.AddedStatus()
  29911. case sopstage.FieldConditionType:
  29912. return m.AddedConditionType()
  29913. case sopstage.FieldConditionOperator:
  29914. return m.AddedConditionOperator()
  29915. case sopstage.FieldIndexSort:
  29916. return m.AddedIndexSort()
  29917. }
  29918. return nil, false
  29919. }
  29920. // AddField adds the value to the field with the given name. It returns an error if
  29921. // the field is not defined in the schema, or if the type mismatched the field
  29922. // type.
  29923. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  29924. switch name {
  29925. case sopstage.FieldStatus:
  29926. v, ok := value.(int8)
  29927. if !ok {
  29928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29929. }
  29930. m.AddStatus(v)
  29931. return nil
  29932. case sopstage.FieldConditionType:
  29933. v, ok := value.(int)
  29934. if !ok {
  29935. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29936. }
  29937. m.AddConditionType(v)
  29938. return nil
  29939. case sopstage.FieldConditionOperator:
  29940. v, ok := value.(int)
  29941. if !ok {
  29942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29943. }
  29944. m.AddConditionOperator(v)
  29945. return nil
  29946. case sopstage.FieldIndexSort:
  29947. v, ok := value.(int)
  29948. if !ok {
  29949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29950. }
  29951. m.AddIndexSort(v)
  29952. return nil
  29953. }
  29954. return fmt.Errorf("unknown SopStage numeric field %s", name)
  29955. }
  29956. // ClearedFields returns all nullable fields that were cleared during this
  29957. // mutation.
  29958. func (m *SopStageMutation) ClearedFields() []string {
  29959. var fields []string
  29960. if m.FieldCleared(sopstage.FieldStatus) {
  29961. fields = append(fields, sopstage.FieldStatus)
  29962. }
  29963. if m.FieldCleared(sopstage.FieldDeletedAt) {
  29964. fields = append(fields, sopstage.FieldDeletedAt)
  29965. }
  29966. if m.FieldCleared(sopstage.FieldActionMessage) {
  29967. fields = append(fields, sopstage.FieldActionMessage)
  29968. }
  29969. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  29970. fields = append(fields, sopstage.FieldActionLabelAdd)
  29971. }
  29972. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  29973. fields = append(fields, sopstage.FieldActionLabelDel)
  29974. }
  29975. if m.FieldCleared(sopstage.FieldActionForward) {
  29976. fields = append(fields, sopstage.FieldActionForward)
  29977. }
  29978. if m.FieldCleared(sopstage.FieldIndexSort) {
  29979. fields = append(fields, sopstage.FieldIndexSort)
  29980. }
  29981. return fields
  29982. }
  29983. // FieldCleared returns a boolean indicating if a field with the given name was
  29984. // cleared in this mutation.
  29985. func (m *SopStageMutation) FieldCleared(name string) bool {
  29986. _, ok := m.clearedFields[name]
  29987. return ok
  29988. }
  29989. // ClearField clears the value of the field with the given name. It returns an
  29990. // error if the field is not defined in the schema.
  29991. func (m *SopStageMutation) ClearField(name string) error {
  29992. switch name {
  29993. case sopstage.FieldStatus:
  29994. m.ClearStatus()
  29995. return nil
  29996. case sopstage.FieldDeletedAt:
  29997. m.ClearDeletedAt()
  29998. return nil
  29999. case sopstage.FieldActionMessage:
  30000. m.ClearActionMessage()
  30001. return nil
  30002. case sopstage.FieldActionLabelAdd:
  30003. m.ClearActionLabelAdd()
  30004. return nil
  30005. case sopstage.FieldActionLabelDel:
  30006. m.ClearActionLabelDel()
  30007. return nil
  30008. case sopstage.FieldActionForward:
  30009. m.ClearActionForward()
  30010. return nil
  30011. case sopstage.FieldIndexSort:
  30012. m.ClearIndexSort()
  30013. return nil
  30014. }
  30015. return fmt.Errorf("unknown SopStage nullable field %s", name)
  30016. }
  30017. // ResetField resets all changes in the mutation for the field with the given name.
  30018. // It returns an error if the field is not defined in the schema.
  30019. func (m *SopStageMutation) ResetField(name string) error {
  30020. switch name {
  30021. case sopstage.FieldCreatedAt:
  30022. m.ResetCreatedAt()
  30023. return nil
  30024. case sopstage.FieldUpdatedAt:
  30025. m.ResetUpdatedAt()
  30026. return nil
  30027. case sopstage.FieldStatus:
  30028. m.ResetStatus()
  30029. return nil
  30030. case sopstage.FieldDeletedAt:
  30031. m.ResetDeletedAt()
  30032. return nil
  30033. case sopstage.FieldTaskID:
  30034. m.ResetTaskID()
  30035. return nil
  30036. case sopstage.FieldName:
  30037. m.ResetName()
  30038. return nil
  30039. case sopstage.FieldConditionType:
  30040. m.ResetConditionType()
  30041. return nil
  30042. case sopstage.FieldConditionOperator:
  30043. m.ResetConditionOperator()
  30044. return nil
  30045. case sopstage.FieldConditionList:
  30046. m.ResetConditionList()
  30047. return nil
  30048. case sopstage.FieldActionMessage:
  30049. m.ResetActionMessage()
  30050. return nil
  30051. case sopstage.FieldActionLabelAdd:
  30052. m.ResetActionLabelAdd()
  30053. return nil
  30054. case sopstage.FieldActionLabelDel:
  30055. m.ResetActionLabelDel()
  30056. return nil
  30057. case sopstage.FieldActionForward:
  30058. m.ResetActionForward()
  30059. return nil
  30060. case sopstage.FieldIndexSort:
  30061. m.ResetIndexSort()
  30062. return nil
  30063. }
  30064. return fmt.Errorf("unknown SopStage field %s", name)
  30065. }
  30066. // AddedEdges returns all edge names that were set/added in this mutation.
  30067. func (m *SopStageMutation) AddedEdges() []string {
  30068. edges := make([]string, 0, 3)
  30069. if m.sop_task != nil {
  30070. edges = append(edges, sopstage.EdgeSopTask)
  30071. }
  30072. if m.stage_nodes != nil {
  30073. edges = append(edges, sopstage.EdgeStageNodes)
  30074. }
  30075. if m.stage_messages != nil {
  30076. edges = append(edges, sopstage.EdgeStageMessages)
  30077. }
  30078. return edges
  30079. }
  30080. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  30081. // name in this mutation.
  30082. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  30083. switch name {
  30084. case sopstage.EdgeSopTask:
  30085. if id := m.sop_task; id != nil {
  30086. return []ent.Value{*id}
  30087. }
  30088. case sopstage.EdgeStageNodes:
  30089. ids := make([]ent.Value, 0, len(m.stage_nodes))
  30090. for id := range m.stage_nodes {
  30091. ids = append(ids, id)
  30092. }
  30093. return ids
  30094. case sopstage.EdgeStageMessages:
  30095. ids := make([]ent.Value, 0, len(m.stage_messages))
  30096. for id := range m.stage_messages {
  30097. ids = append(ids, id)
  30098. }
  30099. return ids
  30100. }
  30101. return nil
  30102. }
  30103. // RemovedEdges returns all edge names that were removed in this mutation.
  30104. func (m *SopStageMutation) RemovedEdges() []string {
  30105. edges := make([]string, 0, 3)
  30106. if m.removedstage_nodes != nil {
  30107. edges = append(edges, sopstage.EdgeStageNodes)
  30108. }
  30109. if m.removedstage_messages != nil {
  30110. edges = append(edges, sopstage.EdgeStageMessages)
  30111. }
  30112. return edges
  30113. }
  30114. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  30115. // the given name in this mutation.
  30116. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  30117. switch name {
  30118. case sopstage.EdgeStageNodes:
  30119. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  30120. for id := range m.removedstage_nodes {
  30121. ids = append(ids, id)
  30122. }
  30123. return ids
  30124. case sopstage.EdgeStageMessages:
  30125. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  30126. for id := range m.removedstage_messages {
  30127. ids = append(ids, id)
  30128. }
  30129. return ids
  30130. }
  30131. return nil
  30132. }
  30133. // ClearedEdges returns all edge names that were cleared in this mutation.
  30134. func (m *SopStageMutation) ClearedEdges() []string {
  30135. edges := make([]string, 0, 3)
  30136. if m.clearedsop_task {
  30137. edges = append(edges, sopstage.EdgeSopTask)
  30138. }
  30139. if m.clearedstage_nodes {
  30140. edges = append(edges, sopstage.EdgeStageNodes)
  30141. }
  30142. if m.clearedstage_messages {
  30143. edges = append(edges, sopstage.EdgeStageMessages)
  30144. }
  30145. return edges
  30146. }
  30147. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30148. // was cleared in this mutation.
  30149. func (m *SopStageMutation) EdgeCleared(name string) bool {
  30150. switch name {
  30151. case sopstage.EdgeSopTask:
  30152. return m.clearedsop_task
  30153. case sopstage.EdgeStageNodes:
  30154. return m.clearedstage_nodes
  30155. case sopstage.EdgeStageMessages:
  30156. return m.clearedstage_messages
  30157. }
  30158. return false
  30159. }
  30160. // ClearEdge clears the value of the edge with the given name. It returns an error
  30161. // if that edge is not defined in the schema.
  30162. func (m *SopStageMutation) ClearEdge(name string) error {
  30163. switch name {
  30164. case sopstage.EdgeSopTask:
  30165. m.ClearSopTask()
  30166. return nil
  30167. }
  30168. return fmt.Errorf("unknown SopStage unique edge %s", name)
  30169. }
  30170. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30171. // It returns an error if the edge is not defined in the schema.
  30172. func (m *SopStageMutation) ResetEdge(name string) error {
  30173. switch name {
  30174. case sopstage.EdgeSopTask:
  30175. m.ResetSopTask()
  30176. return nil
  30177. case sopstage.EdgeStageNodes:
  30178. m.ResetStageNodes()
  30179. return nil
  30180. case sopstage.EdgeStageMessages:
  30181. m.ResetStageMessages()
  30182. return nil
  30183. }
  30184. return fmt.Errorf("unknown SopStage edge %s", name)
  30185. }
  30186. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  30187. type SopTaskMutation struct {
  30188. config
  30189. op Op
  30190. typ string
  30191. id *uint64
  30192. created_at *time.Time
  30193. updated_at *time.Time
  30194. status *uint8
  30195. addstatus *int8
  30196. deleted_at *time.Time
  30197. name *string
  30198. bot_wxid_list *[]string
  30199. appendbot_wxid_list []string
  30200. _type *int
  30201. add_type *int
  30202. plan_start_time *time.Time
  30203. plan_end_time *time.Time
  30204. creator_id *string
  30205. organization_id *uint64
  30206. addorganization_id *int64
  30207. token *[]string
  30208. appendtoken []string
  30209. clearedFields map[string]struct{}
  30210. task_stages map[uint64]struct{}
  30211. removedtask_stages map[uint64]struct{}
  30212. clearedtask_stages bool
  30213. done bool
  30214. oldValue func(context.Context) (*SopTask, error)
  30215. predicates []predicate.SopTask
  30216. }
  30217. var _ ent.Mutation = (*SopTaskMutation)(nil)
  30218. // soptaskOption allows management of the mutation configuration using functional options.
  30219. type soptaskOption func(*SopTaskMutation)
  30220. // newSopTaskMutation creates new mutation for the SopTask entity.
  30221. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  30222. m := &SopTaskMutation{
  30223. config: c,
  30224. op: op,
  30225. typ: TypeSopTask,
  30226. clearedFields: make(map[string]struct{}),
  30227. }
  30228. for _, opt := range opts {
  30229. opt(m)
  30230. }
  30231. return m
  30232. }
  30233. // withSopTaskID sets the ID field of the mutation.
  30234. func withSopTaskID(id uint64) soptaskOption {
  30235. return func(m *SopTaskMutation) {
  30236. var (
  30237. err error
  30238. once sync.Once
  30239. value *SopTask
  30240. )
  30241. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  30242. once.Do(func() {
  30243. if m.done {
  30244. err = errors.New("querying old values post mutation is not allowed")
  30245. } else {
  30246. value, err = m.Client().SopTask.Get(ctx, id)
  30247. }
  30248. })
  30249. return value, err
  30250. }
  30251. m.id = &id
  30252. }
  30253. }
  30254. // withSopTask sets the old SopTask of the mutation.
  30255. func withSopTask(node *SopTask) soptaskOption {
  30256. return func(m *SopTaskMutation) {
  30257. m.oldValue = func(context.Context) (*SopTask, error) {
  30258. return node, nil
  30259. }
  30260. m.id = &node.ID
  30261. }
  30262. }
  30263. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30264. // executed in a transaction (ent.Tx), a transactional client is returned.
  30265. func (m SopTaskMutation) Client() *Client {
  30266. client := &Client{config: m.config}
  30267. client.init()
  30268. return client
  30269. }
  30270. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30271. // it returns an error otherwise.
  30272. func (m SopTaskMutation) Tx() (*Tx, error) {
  30273. if _, ok := m.driver.(*txDriver); !ok {
  30274. return nil, errors.New("ent: mutation is not running in a transaction")
  30275. }
  30276. tx := &Tx{config: m.config}
  30277. tx.init()
  30278. return tx, nil
  30279. }
  30280. // SetID sets the value of the id field. Note that this
  30281. // operation is only accepted on creation of SopTask entities.
  30282. func (m *SopTaskMutation) SetID(id uint64) {
  30283. m.id = &id
  30284. }
  30285. // ID returns the ID value in the mutation. Note that the ID is only available
  30286. // if it was provided to the builder or after it was returned from the database.
  30287. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  30288. if m.id == nil {
  30289. return
  30290. }
  30291. return *m.id, true
  30292. }
  30293. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30294. // That means, if the mutation is applied within a transaction with an isolation level such
  30295. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30296. // or updated by the mutation.
  30297. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  30298. switch {
  30299. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30300. id, exists := m.ID()
  30301. if exists {
  30302. return []uint64{id}, nil
  30303. }
  30304. fallthrough
  30305. case m.op.Is(OpUpdate | OpDelete):
  30306. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  30307. default:
  30308. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30309. }
  30310. }
  30311. // SetCreatedAt sets the "created_at" field.
  30312. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  30313. m.created_at = &t
  30314. }
  30315. // CreatedAt returns the value of the "created_at" field in the mutation.
  30316. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  30317. v := m.created_at
  30318. if v == nil {
  30319. return
  30320. }
  30321. return *v, true
  30322. }
  30323. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  30324. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  30325. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30326. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  30327. if !m.op.Is(OpUpdateOne) {
  30328. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  30329. }
  30330. if m.id == nil || m.oldValue == nil {
  30331. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  30332. }
  30333. oldValue, err := m.oldValue(ctx)
  30334. if err != nil {
  30335. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  30336. }
  30337. return oldValue.CreatedAt, nil
  30338. }
  30339. // ResetCreatedAt resets all changes to the "created_at" field.
  30340. func (m *SopTaskMutation) ResetCreatedAt() {
  30341. m.created_at = nil
  30342. }
  30343. // SetUpdatedAt sets the "updated_at" field.
  30344. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  30345. m.updated_at = &t
  30346. }
  30347. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  30348. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  30349. v := m.updated_at
  30350. if v == nil {
  30351. return
  30352. }
  30353. return *v, true
  30354. }
  30355. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  30356. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  30357. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30358. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  30359. if !m.op.Is(OpUpdateOne) {
  30360. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  30361. }
  30362. if m.id == nil || m.oldValue == nil {
  30363. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  30364. }
  30365. oldValue, err := m.oldValue(ctx)
  30366. if err != nil {
  30367. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  30368. }
  30369. return oldValue.UpdatedAt, nil
  30370. }
  30371. // ResetUpdatedAt resets all changes to the "updated_at" field.
  30372. func (m *SopTaskMutation) ResetUpdatedAt() {
  30373. m.updated_at = nil
  30374. }
  30375. // SetStatus sets the "status" field.
  30376. func (m *SopTaskMutation) SetStatus(u uint8) {
  30377. m.status = &u
  30378. m.addstatus = nil
  30379. }
  30380. // Status returns the value of the "status" field in the mutation.
  30381. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  30382. v := m.status
  30383. if v == nil {
  30384. return
  30385. }
  30386. return *v, true
  30387. }
  30388. // OldStatus returns the old "status" field's value of the SopTask entity.
  30389. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  30390. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30391. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  30392. if !m.op.Is(OpUpdateOne) {
  30393. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  30394. }
  30395. if m.id == nil || m.oldValue == nil {
  30396. return v, errors.New("OldStatus requires an ID field in the mutation")
  30397. }
  30398. oldValue, err := m.oldValue(ctx)
  30399. if err != nil {
  30400. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  30401. }
  30402. return oldValue.Status, nil
  30403. }
  30404. // AddStatus adds u to the "status" field.
  30405. func (m *SopTaskMutation) AddStatus(u int8) {
  30406. if m.addstatus != nil {
  30407. *m.addstatus += u
  30408. } else {
  30409. m.addstatus = &u
  30410. }
  30411. }
  30412. // AddedStatus returns the value that was added to the "status" field in this mutation.
  30413. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  30414. v := m.addstatus
  30415. if v == nil {
  30416. return
  30417. }
  30418. return *v, true
  30419. }
  30420. // ClearStatus clears the value of the "status" field.
  30421. func (m *SopTaskMutation) ClearStatus() {
  30422. m.status = nil
  30423. m.addstatus = nil
  30424. m.clearedFields[soptask.FieldStatus] = struct{}{}
  30425. }
  30426. // StatusCleared returns if the "status" field was cleared in this mutation.
  30427. func (m *SopTaskMutation) StatusCleared() bool {
  30428. _, ok := m.clearedFields[soptask.FieldStatus]
  30429. return ok
  30430. }
  30431. // ResetStatus resets all changes to the "status" field.
  30432. func (m *SopTaskMutation) ResetStatus() {
  30433. m.status = nil
  30434. m.addstatus = nil
  30435. delete(m.clearedFields, soptask.FieldStatus)
  30436. }
  30437. // SetDeletedAt sets the "deleted_at" field.
  30438. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  30439. m.deleted_at = &t
  30440. }
  30441. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  30442. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  30443. v := m.deleted_at
  30444. if v == nil {
  30445. return
  30446. }
  30447. return *v, true
  30448. }
  30449. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  30450. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  30451. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30452. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  30453. if !m.op.Is(OpUpdateOne) {
  30454. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  30455. }
  30456. if m.id == nil || m.oldValue == nil {
  30457. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  30458. }
  30459. oldValue, err := m.oldValue(ctx)
  30460. if err != nil {
  30461. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  30462. }
  30463. return oldValue.DeletedAt, nil
  30464. }
  30465. // ClearDeletedAt clears the value of the "deleted_at" field.
  30466. func (m *SopTaskMutation) ClearDeletedAt() {
  30467. m.deleted_at = nil
  30468. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  30469. }
  30470. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  30471. func (m *SopTaskMutation) DeletedAtCleared() bool {
  30472. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  30473. return ok
  30474. }
  30475. // ResetDeletedAt resets all changes to the "deleted_at" field.
  30476. func (m *SopTaskMutation) ResetDeletedAt() {
  30477. m.deleted_at = nil
  30478. delete(m.clearedFields, soptask.FieldDeletedAt)
  30479. }
  30480. // SetName sets the "name" field.
  30481. func (m *SopTaskMutation) SetName(s string) {
  30482. m.name = &s
  30483. }
  30484. // Name returns the value of the "name" field in the mutation.
  30485. func (m *SopTaskMutation) Name() (r string, exists bool) {
  30486. v := m.name
  30487. if v == nil {
  30488. return
  30489. }
  30490. return *v, true
  30491. }
  30492. // OldName returns the old "name" field's value of the SopTask entity.
  30493. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  30494. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30495. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  30496. if !m.op.Is(OpUpdateOne) {
  30497. return v, errors.New("OldName is only allowed on UpdateOne operations")
  30498. }
  30499. if m.id == nil || m.oldValue == nil {
  30500. return v, errors.New("OldName requires an ID field in the mutation")
  30501. }
  30502. oldValue, err := m.oldValue(ctx)
  30503. if err != nil {
  30504. return v, fmt.Errorf("querying old value for OldName: %w", err)
  30505. }
  30506. return oldValue.Name, nil
  30507. }
  30508. // ResetName resets all changes to the "name" field.
  30509. func (m *SopTaskMutation) ResetName() {
  30510. m.name = nil
  30511. }
  30512. // SetBotWxidList sets the "bot_wxid_list" field.
  30513. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  30514. m.bot_wxid_list = &s
  30515. m.appendbot_wxid_list = nil
  30516. }
  30517. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  30518. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  30519. v := m.bot_wxid_list
  30520. if v == nil {
  30521. return
  30522. }
  30523. return *v, true
  30524. }
  30525. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  30526. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  30527. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30528. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  30529. if !m.op.Is(OpUpdateOne) {
  30530. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  30531. }
  30532. if m.id == nil || m.oldValue == nil {
  30533. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  30534. }
  30535. oldValue, err := m.oldValue(ctx)
  30536. if err != nil {
  30537. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  30538. }
  30539. return oldValue.BotWxidList, nil
  30540. }
  30541. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  30542. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  30543. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  30544. }
  30545. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  30546. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  30547. if len(m.appendbot_wxid_list) == 0 {
  30548. return nil, false
  30549. }
  30550. return m.appendbot_wxid_list, true
  30551. }
  30552. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  30553. func (m *SopTaskMutation) ClearBotWxidList() {
  30554. m.bot_wxid_list = nil
  30555. m.appendbot_wxid_list = nil
  30556. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  30557. }
  30558. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  30559. func (m *SopTaskMutation) BotWxidListCleared() bool {
  30560. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  30561. return ok
  30562. }
  30563. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  30564. func (m *SopTaskMutation) ResetBotWxidList() {
  30565. m.bot_wxid_list = nil
  30566. m.appendbot_wxid_list = nil
  30567. delete(m.clearedFields, soptask.FieldBotWxidList)
  30568. }
  30569. // SetType sets the "type" field.
  30570. func (m *SopTaskMutation) SetType(i int) {
  30571. m._type = &i
  30572. m.add_type = nil
  30573. }
  30574. // GetType returns the value of the "type" field in the mutation.
  30575. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  30576. v := m._type
  30577. if v == nil {
  30578. return
  30579. }
  30580. return *v, true
  30581. }
  30582. // OldType returns the old "type" field's value of the SopTask entity.
  30583. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  30584. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30585. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  30586. if !m.op.Is(OpUpdateOne) {
  30587. return v, errors.New("OldType is only allowed on UpdateOne operations")
  30588. }
  30589. if m.id == nil || m.oldValue == nil {
  30590. return v, errors.New("OldType requires an ID field in the mutation")
  30591. }
  30592. oldValue, err := m.oldValue(ctx)
  30593. if err != nil {
  30594. return v, fmt.Errorf("querying old value for OldType: %w", err)
  30595. }
  30596. return oldValue.Type, nil
  30597. }
  30598. // AddType adds i to the "type" field.
  30599. func (m *SopTaskMutation) AddType(i int) {
  30600. if m.add_type != nil {
  30601. *m.add_type += i
  30602. } else {
  30603. m.add_type = &i
  30604. }
  30605. }
  30606. // AddedType returns the value that was added to the "type" field in this mutation.
  30607. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  30608. v := m.add_type
  30609. if v == nil {
  30610. return
  30611. }
  30612. return *v, true
  30613. }
  30614. // ResetType resets all changes to the "type" field.
  30615. func (m *SopTaskMutation) ResetType() {
  30616. m._type = nil
  30617. m.add_type = nil
  30618. }
  30619. // SetPlanStartTime sets the "plan_start_time" field.
  30620. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  30621. m.plan_start_time = &t
  30622. }
  30623. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  30624. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  30625. v := m.plan_start_time
  30626. if v == nil {
  30627. return
  30628. }
  30629. return *v, true
  30630. }
  30631. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  30632. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  30633. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30634. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  30635. if !m.op.Is(OpUpdateOne) {
  30636. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  30637. }
  30638. if m.id == nil || m.oldValue == nil {
  30639. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  30640. }
  30641. oldValue, err := m.oldValue(ctx)
  30642. if err != nil {
  30643. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  30644. }
  30645. return oldValue.PlanStartTime, nil
  30646. }
  30647. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  30648. func (m *SopTaskMutation) ClearPlanStartTime() {
  30649. m.plan_start_time = nil
  30650. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  30651. }
  30652. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  30653. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  30654. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  30655. return ok
  30656. }
  30657. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  30658. func (m *SopTaskMutation) ResetPlanStartTime() {
  30659. m.plan_start_time = nil
  30660. delete(m.clearedFields, soptask.FieldPlanStartTime)
  30661. }
  30662. // SetPlanEndTime sets the "plan_end_time" field.
  30663. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  30664. m.plan_end_time = &t
  30665. }
  30666. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  30667. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  30668. v := m.plan_end_time
  30669. if v == nil {
  30670. return
  30671. }
  30672. return *v, true
  30673. }
  30674. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  30675. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  30676. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30677. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  30678. if !m.op.Is(OpUpdateOne) {
  30679. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  30680. }
  30681. if m.id == nil || m.oldValue == nil {
  30682. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  30683. }
  30684. oldValue, err := m.oldValue(ctx)
  30685. if err != nil {
  30686. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  30687. }
  30688. return oldValue.PlanEndTime, nil
  30689. }
  30690. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  30691. func (m *SopTaskMutation) ClearPlanEndTime() {
  30692. m.plan_end_time = nil
  30693. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  30694. }
  30695. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  30696. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  30697. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  30698. return ok
  30699. }
  30700. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  30701. func (m *SopTaskMutation) ResetPlanEndTime() {
  30702. m.plan_end_time = nil
  30703. delete(m.clearedFields, soptask.FieldPlanEndTime)
  30704. }
  30705. // SetCreatorID sets the "creator_id" field.
  30706. func (m *SopTaskMutation) SetCreatorID(s string) {
  30707. m.creator_id = &s
  30708. }
  30709. // CreatorID returns the value of the "creator_id" field in the mutation.
  30710. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  30711. v := m.creator_id
  30712. if v == nil {
  30713. return
  30714. }
  30715. return *v, true
  30716. }
  30717. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  30718. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  30719. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30720. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  30721. if !m.op.Is(OpUpdateOne) {
  30722. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  30723. }
  30724. if m.id == nil || m.oldValue == nil {
  30725. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  30726. }
  30727. oldValue, err := m.oldValue(ctx)
  30728. if err != nil {
  30729. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  30730. }
  30731. return oldValue.CreatorID, nil
  30732. }
  30733. // ClearCreatorID clears the value of the "creator_id" field.
  30734. func (m *SopTaskMutation) ClearCreatorID() {
  30735. m.creator_id = nil
  30736. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  30737. }
  30738. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  30739. func (m *SopTaskMutation) CreatorIDCleared() bool {
  30740. _, ok := m.clearedFields[soptask.FieldCreatorID]
  30741. return ok
  30742. }
  30743. // ResetCreatorID resets all changes to the "creator_id" field.
  30744. func (m *SopTaskMutation) ResetCreatorID() {
  30745. m.creator_id = nil
  30746. delete(m.clearedFields, soptask.FieldCreatorID)
  30747. }
  30748. // SetOrganizationID sets the "organization_id" field.
  30749. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  30750. m.organization_id = &u
  30751. m.addorganization_id = nil
  30752. }
  30753. // OrganizationID returns the value of the "organization_id" field in the mutation.
  30754. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  30755. v := m.organization_id
  30756. if v == nil {
  30757. return
  30758. }
  30759. return *v, true
  30760. }
  30761. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  30762. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  30763. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30764. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  30765. if !m.op.Is(OpUpdateOne) {
  30766. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  30767. }
  30768. if m.id == nil || m.oldValue == nil {
  30769. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  30770. }
  30771. oldValue, err := m.oldValue(ctx)
  30772. if err != nil {
  30773. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  30774. }
  30775. return oldValue.OrganizationID, nil
  30776. }
  30777. // AddOrganizationID adds u to the "organization_id" field.
  30778. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  30779. if m.addorganization_id != nil {
  30780. *m.addorganization_id += u
  30781. } else {
  30782. m.addorganization_id = &u
  30783. }
  30784. }
  30785. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  30786. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  30787. v := m.addorganization_id
  30788. if v == nil {
  30789. return
  30790. }
  30791. return *v, true
  30792. }
  30793. // ClearOrganizationID clears the value of the "organization_id" field.
  30794. func (m *SopTaskMutation) ClearOrganizationID() {
  30795. m.organization_id = nil
  30796. m.addorganization_id = nil
  30797. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  30798. }
  30799. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  30800. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  30801. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  30802. return ok
  30803. }
  30804. // ResetOrganizationID resets all changes to the "organization_id" field.
  30805. func (m *SopTaskMutation) ResetOrganizationID() {
  30806. m.organization_id = nil
  30807. m.addorganization_id = nil
  30808. delete(m.clearedFields, soptask.FieldOrganizationID)
  30809. }
  30810. // SetToken sets the "token" field.
  30811. func (m *SopTaskMutation) SetToken(s []string) {
  30812. m.token = &s
  30813. m.appendtoken = nil
  30814. }
  30815. // Token returns the value of the "token" field in the mutation.
  30816. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  30817. v := m.token
  30818. if v == nil {
  30819. return
  30820. }
  30821. return *v, true
  30822. }
  30823. // OldToken returns the old "token" field's value of the SopTask entity.
  30824. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  30825. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30826. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  30827. if !m.op.Is(OpUpdateOne) {
  30828. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  30829. }
  30830. if m.id == nil || m.oldValue == nil {
  30831. return v, errors.New("OldToken requires an ID field in the mutation")
  30832. }
  30833. oldValue, err := m.oldValue(ctx)
  30834. if err != nil {
  30835. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  30836. }
  30837. return oldValue.Token, nil
  30838. }
  30839. // AppendToken adds s to the "token" field.
  30840. func (m *SopTaskMutation) AppendToken(s []string) {
  30841. m.appendtoken = append(m.appendtoken, s...)
  30842. }
  30843. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  30844. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  30845. if len(m.appendtoken) == 0 {
  30846. return nil, false
  30847. }
  30848. return m.appendtoken, true
  30849. }
  30850. // ClearToken clears the value of the "token" field.
  30851. func (m *SopTaskMutation) ClearToken() {
  30852. m.token = nil
  30853. m.appendtoken = nil
  30854. m.clearedFields[soptask.FieldToken] = struct{}{}
  30855. }
  30856. // TokenCleared returns if the "token" field was cleared in this mutation.
  30857. func (m *SopTaskMutation) TokenCleared() bool {
  30858. _, ok := m.clearedFields[soptask.FieldToken]
  30859. return ok
  30860. }
  30861. // ResetToken resets all changes to the "token" field.
  30862. func (m *SopTaskMutation) ResetToken() {
  30863. m.token = nil
  30864. m.appendtoken = nil
  30865. delete(m.clearedFields, soptask.FieldToken)
  30866. }
  30867. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  30868. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  30869. if m.task_stages == nil {
  30870. m.task_stages = make(map[uint64]struct{})
  30871. }
  30872. for i := range ids {
  30873. m.task_stages[ids[i]] = struct{}{}
  30874. }
  30875. }
  30876. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  30877. func (m *SopTaskMutation) ClearTaskStages() {
  30878. m.clearedtask_stages = true
  30879. }
  30880. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  30881. func (m *SopTaskMutation) TaskStagesCleared() bool {
  30882. return m.clearedtask_stages
  30883. }
  30884. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  30885. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  30886. if m.removedtask_stages == nil {
  30887. m.removedtask_stages = make(map[uint64]struct{})
  30888. }
  30889. for i := range ids {
  30890. delete(m.task_stages, ids[i])
  30891. m.removedtask_stages[ids[i]] = struct{}{}
  30892. }
  30893. }
  30894. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  30895. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  30896. for id := range m.removedtask_stages {
  30897. ids = append(ids, id)
  30898. }
  30899. return
  30900. }
  30901. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  30902. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  30903. for id := range m.task_stages {
  30904. ids = append(ids, id)
  30905. }
  30906. return
  30907. }
  30908. // ResetTaskStages resets all changes to the "task_stages" edge.
  30909. func (m *SopTaskMutation) ResetTaskStages() {
  30910. m.task_stages = nil
  30911. m.clearedtask_stages = false
  30912. m.removedtask_stages = nil
  30913. }
  30914. // Where appends a list predicates to the SopTaskMutation builder.
  30915. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  30916. m.predicates = append(m.predicates, ps...)
  30917. }
  30918. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  30919. // users can use type-assertion to append predicates that do not depend on any generated package.
  30920. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  30921. p := make([]predicate.SopTask, len(ps))
  30922. for i := range ps {
  30923. p[i] = ps[i]
  30924. }
  30925. m.Where(p...)
  30926. }
  30927. // Op returns the operation name.
  30928. func (m *SopTaskMutation) Op() Op {
  30929. return m.op
  30930. }
  30931. // SetOp allows setting the mutation operation.
  30932. func (m *SopTaskMutation) SetOp(op Op) {
  30933. m.op = op
  30934. }
  30935. // Type returns the node type of this mutation (SopTask).
  30936. func (m *SopTaskMutation) Type() string {
  30937. return m.typ
  30938. }
  30939. // Fields returns all fields that were changed during this mutation. Note that in
  30940. // order to get all numeric fields that were incremented/decremented, call
  30941. // AddedFields().
  30942. func (m *SopTaskMutation) Fields() []string {
  30943. fields := make([]string, 0, 12)
  30944. if m.created_at != nil {
  30945. fields = append(fields, soptask.FieldCreatedAt)
  30946. }
  30947. if m.updated_at != nil {
  30948. fields = append(fields, soptask.FieldUpdatedAt)
  30949. }
  30950. if m.status != nil {
  30951. fields = append(fields, soptask.FieldStatus)
  30952. }
  30953. if m.deleted_at != nil {
  30954. fields = append(fields, soptask.FieldDeletedAt)
  30955. }
  30956. if m.name != nil {
  30957. fields = append(fields, soptask.FieldName)
  30958. }
  30959. if m.bot_wxid_list != nil {
  30960. fields = append(fields, soptask.FieldBotWxidList)
  30961. }
  30962. if m._type != nil {
  30963. fields = append(fields, soptask.FieldType)
  30964. }
  30965. if m.plan_start_time != nil {
  30966. fields = append(fields, soptask.FieldPlanStartTime)
  30967. }
  30968. if m.plan_end_time != nil {
  30969. fields = append(fields, soptask.FieldPlanEndTime)
  30970. }
  30971. if m.creator_id != nil {
  30972. fields = append(fields, soptask.FieldCreatorID)
  30973. }
  30974. if m.organization_id != nil {
  30975. fields = append(fields, soptask.FieldOrganizationID)
  30976. }
  30977. if m.token != nil {
  30978. fields = append(fields, soptask.FieldToken)
  30979. }
  30980. return fields
  30981. }
  30982. // Field returns the value of a field with the given name. The second boolean
  30983. // return value indicates that this field was not set, or was not defined in the
  30984. // schema.
  30985. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  30986. switch name {
  30987. case soptask.FieldCreatedAt:
  30988. return m.CreatedAt()
  30989. case soptask.FieldUpdatedAt:
  30990. return m.UpdatedAt()
  30991. case soptask.FieldStatus:
  30992. return m.Status()
  30993. case soptask.FieldDeletedAt:
  30994. return m.DeletedAt()
  30995. case soptask.FieldName:
  30996. return m.Name()
  30997. case soptask.FieldBotWxidList:
  30998. return m.BotWxidList()
  30999. case soptask.FieldType:
  31000. return m.GetType()
  31001. case soptask.FieldPlanStartTime:
  31002. return m.PlanStartTime()
  31003. case soptask.FieldPlanEndTime:
  31004. return m.PlanEndTime()
  31005. case soptask.FieldCreatorID:
  31006. return m.CreatorID()
  31007. case soptask.FieldOrganizationID:
  31008. return m.OrganizationID()
  31009. case soptask.FieldToken:
  31010. return m.Token()
  31011. }
  31012. return nil, false
  31013. }
  31014. // OldField returns the old value of the field from the database. An error is
  31015. // returned if the mutation operation is not UpdateOne, or the query to the
  31016. // database failed.
  31017. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  31018. switch name {
  31019. case soptask.FieldCreatedAt:
  31020. return m.OldCreatedAt(ctx)
  31021. case soptask.FieldUpdatedAt:
  31022. return m.OldUpdatedAt(ctx)
  31023. case soptask.FieldStatus:
  31024. return m.OldStatus(ctx)
  31025. case soptask.FieldDeletedAt:
  31026. return m.OldDeletedAt(ctx)
  31027. case soptask.FieldName:
  31028. return m.OldName(ctx)
  31029. case soptask.FieldBotWxidList:
  31030. return m.OldBotWxidList(ctx)
  31031. case soptask.FieldType:
  31032. return m.OldType(ctx)
  31033. case soptask.FieldPlanStartTime:
  31034. return m.OldPlanStartTime(ctx)
  31035. case soptask.FieldPlanEndTime:
  31036. return m.OldPlanEndTime(ctx)
  31037. case soptask.FieldCreatorID:
  31038. return m.OldCreatorID(ctx)
  31039. case soptask.FieldOrganizationID:
  31040. return m.OldOrganizationID(ctx)
  31041. case soptask.FieldToken:
  31042. return m.OldToken(ctx)
  31043. }
  31044. return nil, fmt.Errorf("unknown SopTask field %s", name)
  31045. }
  31046. // SetField sets the value of a field with the given name. It returns an error if
  31047. // the field is not defined in the schema, or if the type mismatched the field
  31048. // type.
  31049. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  31050. switch name {
  31051. case soptask.FieldCreatedAt:
  31052. v, ok := value.(time.Time)
  31053. if !ok {
  31054. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31055. }
  31056. m.SetCreatedAt(v)
  31057. return nil
  31058. case soptask.FieldUpdatedAt:
  31059. v, ok := value.(time.Time)
  31060. if !ok {
  31061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31062. }
  31063. m.SetUpdatedAt(v)
  31064. return nil
  31065. case soptask.FieldStatus:
  31066. v, ok := value.(uint8)
  31067. if !ok {
  31068. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31069. }
  31070. m.SetStatus(v)
  31071. return nil
  31072. case soptask.FieldDeletedAt:
  31073. v, ok := value.(time.Time)
  31074. if !ok {
  31075. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31076. }
  31077. m.SetDeletedAt(v)
  31078. return nil
  31079. case soptask.FieldName:
  31080. v, ok := value.(string)
  31081. if !ok {
  31082. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31083. }
  31084. m.SetName(v)
  31085. return nil
  31086. case soptask.FieldBotWxidList:
  31087. v, ok := value.([]string)
  31088. if !ok {
  31089. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31090. }
  31091. m.SetBotWxidList(v)
  31092. return nil
  31093. case soptask.FieldType:
  31094. v, ok := value.(int)
  31095. if !ok {
  31096. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31097. }
  31098. m.SetType(v)
  31099. return nil
  31100. case soptask.FieldPlanStartTime:
  31101. v, ok := value.(time.Time)
  31102. if !ok {
  31103. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31104. }
  31105. m.SetPlanStartTime(v)
  31106. return nil
  31107. case soptask.FieldPlanEndTime:
  31108. v, ok := value.(time.Time)
  31109. if !ok {
  31110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31111. }
  31112. m.SetPlanEndTime(v)
  31113. return nil
  31114. case soptask.FieldCreatorID:
  31115. v, ok := value.(string)
  31116. if !ok {
  31117. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31118. }
  31119. m.SetCreatorID(v)
  31120. return nil
  31121. case soptask.FieldOrganizationID:
  31122. v, ok := value.(uint64)
  31123. if !ok {
  31124. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31125. }
  31126. m.SetOrganizationID(v)
  31127. return nil
  31128. case soptask.FieldToken:
  31129. v, ok := value.([]string)
  31130. if !ok {
  31131. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31132. }
  31133. m.SetToken(v)
  31134. return nil
  31135. }
  31136. return fmt.Errorf("unknown SopTask field %s", name)
  31137. }
  31138. // AddedFields returns all numeric fields that were incremented/decremented during
  31139. // this mutation.
  31140. func (m *SopTaskMutation) AddedFields() []string {
  31141. var fields []string
  31142. if m.addstatus != nil {
  31143. fields = append(fields, soptask.FieldStatus)
  31144. }
  31145. if m.add_type != nil {
  31146. fields = append(fields, soptask.FieldType)
  31147. }
  31148. if m.addorganization_id != nil {
  31149. fields = append(fields, soptask.FieldOrganizationID)
  31150. }
  31151. return fields
  31152. }
  31153. // AddedField returns the numeric value that was incremented/decremented on a field
  31154. // with the given name. The second boolean return value indicates that this field
  31155. // was not set, or was not defined in the schema.
  31156. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  31157. switch name {
  31158. case soptask.FieldStatus:
  31159. return m.AddedStatus()
  31160. case soptask.FieldType:
  31161. return m.AddedType()
  31162. case soptask.FieldOrganizationID:
  31163. return m.AddedOrganizationID()
  31164. }
  31165. return nil, false
  31166. }
  31167. // AddField adds the value to the field with the given name. It returns an error if
  31168. // the field is not defined in the schema, or if the type mismatched the field
  31169. // type.
  31170. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  31171. switch name {
  31172. case soptask.FieldStatus:
  31173. v, ok := value.(int8)
  31174. if !ok {
  31175. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31176. }
  31177. m.AddStatus(v)
  31178. return nil
  31179. case soptask.FieldType:
  31180. v, ok := value.(int)
  31181. if !ok {
  31182. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31183. }
  31184. m.AddType(v)
  31185. return nil
  31186. case soptask.FieldOrganizationID:
  31187. v, ok := value.(int64)
  31188. if !ok {
  31189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31190. }
  31191. m.AddOrganizationID(v)
  31192. return nil
  31193. }
  31194. return fmt.Errorf("unknown SopTask numeric field %s", name)
  31195. }
  31196. // ClearedFields returns all nullable fields that were cleared during this
  31197. // mutation.
  31198. func (m *SopTaskMutation) ClearedFields() []string {
  31199. var fields []string
  31200. if m.FieldCleared(soptask.FieldStatus) {
  31201. fields = append(fields, soptask.FieldStatus)
  31202. }
  31203. if m.FieldCleared(soptask.FieldDeletedAt) {
  31204. fields = append(fields, soptask.FieldDeletedAt)
  31205. }
  31206. if m.FieldCleared(soptask.FieldBotWxidList) {
  31207. fields = append(fields, soptask.FieldBotWxidList)
  31208. }
  31209. if m.FieldCleared(soptask.FieldPlanStartTime) {
  31210. fields = append(fields, soptask.FieldPlanStartTime)
  31211. }
  31212. if m.FieldCleared(soptask.FieldPlanEndTime) {
  31213. fields = append(fields, soptask.FieldPlanEndTime)
  31214. }
  31215. if m.FieldCleared(soptask.FieldCreatorID) {
  31216. fields = append(fields, soptask.FieldCreatorID)
  31217. }
  31218. if m.FieldCleared(soptask.FieldOrganizationID) {
  31219. fields = append(fields, soptask.FieldOrganizationID)
  31220. }
  31221. if m.FieldCleared(soptask.FieldToken) {
  31222. fields = append(fields, soptask.FieldToken)
  31223. }
  31224. return fields
  31225. }
  31226. // FieldCleared returns a boolean indicating if a field with the given name was
  31227. // cleared in this mutation.
  31228. func (m *SopTaskMutation) FieldCleared(name string) bool {
  31229. _, ok := m.clearedFields[name]
  31230. return ok
  31231. }
  31232. // ClearField clears the value of the field with the given name. It returns an
  31233. // error if the field is not defined in the schema.
  31234. func (m *SopTaskMutation) ClearField(name string) error {
  31235. switch name {
  31236. case soptask.FieldStatus:
  31237. m.ClearStatus()
  31238. return nil
  31239. case soptask.FieldDeletedAt:
  31240. m.ClearDeletedAt()
  31241. return nil
  31242. case soptask.FieldBotWxidList:
  31243. m.ClearBotWxidList()
  31244. return nil
  31245. case soptask.FieldPlanStartTime:
  31246. m.ClearPlanStartTime()
  31247. return nil
  31248. case soptask.FieldPlanEndTime:
  31249. m.ClearPlanEndTime()
  31250. return nil
  31251. case soptask.FieldCreatorID:
  31252. m.ClearCreatorID()
  31253. return nil
  31254. case soptask.FieldOrganizationID:
  31255. m.ClearOrganizationID()
  31256. return nil
  31257. case soptask.FieldToken:
  31258. m.ClearToken()
  31259. return nil
  31260. }
  31261. return fmt.Errorf("unknown SopTask nullable field %s", name)
  31262. }
  31263. // ResetField resets all changes in the mutation for the field with the given name.
  31264. // It returns an error if the field is not defined in the schema.
  31265. func (m *SopTaskMutation) ResetField(name string) error {
  31266. switch name {
  31267. case soptask.FieldCreatedAt:
  31268. m.ResetCreatedAt()
  31269. return nil
  31270. case soptask.FieldUpdatedAt:
  31271. m.ResetUpdatedAt()
  31272. return nil
  31273. case soptask.FieldStatus:
  31274. m.ResetStatus()
  31275. return nil
  31276. case soptask.FieldDeletedAt:
  31277. m.ResetDeletedAt()
  31278. return nil
  31279. case soptask.FieldName:
  31280. m.ResetName()
  31281. return nil
  31282. case soptask.FieldBotWxidList:
  31283. m.ResetBotWxidList()
  31284. return nil
  31285. case soptask.FieldType:
  31286. m.ResetType()
  31287. return nil
  31288. case soptask.FieldPlanStartTime:
  31289. m.ResetPlanStartTime()
  31290. return nil
  31291. case soptask.FieldPlanEndTime:
  31292. m.ResetPlanEndTime()
  31293. return nil
  31294. case soptask.FieldCreatorID:
  31295. m.ResetCreatorID()
  31296. return nil
  31297. case soptask.FieldOrganizationID:
  31298. m.ResetOrganizationID()
  31299. return nil
  31300. case soptask.FieldToken:
  31301. m.ResetToken()
  31302. return nil
  31303. }
  31304. return fmt.Errorf("unknown SopTask field %s", name)
  31305. }
  31306. // AddedEdges returns all edge names that were set/added in this mutation.
  31307. func (m *SopTaskMutation) AddedEdges() []string {
  31308. edges := make([]string, 0, 1)
  31309. if m.task_stages != nil {
  31310. edges = append(edges, soptask.EdgeTaskStages)
  31311. }
  31312. return edges
  31313. }
  31314. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31315. // name in this mutation.
  31316. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  31317. switch name {
  31318. case soptask.EdgeTaskStages:
  31319. ids := make([]ent.Value, 0, len(m.task_stages))
  31320. for id := range m.task_stages {
  31321. ids = append(ids, id)
  31322. }
  31323. return ids
  31324. }
  31325. return nil
  31326. }
  31327. // RemovedEdges returns all edge names that were removed in this mutation.
  31328. func (m *SopTaskMutation) RemovedEdges() []string {
  31329. edges := make([]string, 0, 1)
  31330. if m.removedtask_stages != nil {
  31331. edges = append(edges, soptask.EdgeTaskStages)
  31332. }
  31333. return edges
  31334. }
  31335. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31336. // the given name in this mutation.
  31337. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  31338. switch name {
  31339. case soptask.EdgeTaskStages:
  31340. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  31341. for id := range m.removedtask_stages {
  31342. ids = append(ids, id)
  31343. }
  31344. return ids
  31345. }
  31346. return nil
  31347. }
  31348. // ClearedEdges returns all edge names that were cleared in this mutation.
  31349. func (m *SopTaskMutation) ClearedEdges() []string {
  31350. edges := make([]string, 0, 1)
  31351. if m.clearedtask_stages {
  31352. edges = append(edges, soptask.EdgeTaskStages)
  31353. }
  31354. return edges
  31355. }
  31356. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31357. // was cleared in this mutation.
  31358. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  31359. switch name {
  31360. case soptask.EdgeTaskStages:
  31361. return m.clearedtask_stages
  31362. }
  31363. return false
  31364. }
  31365. // ClearEdge clears the value of the edge with the given name. It returns an error
  31366. // if that edge is not defined in the schema.
  31367. func (m *SopTaskMutation) ClearEdge(name string) error {
  31368. switch name {
  31369. }
  31370. return fmt.Errorf("unknown SopTask unique edge %s", name)
  31371. }
  31372. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31373. // It returns an error if the edge is not defined in the schema.
  31374. func (m *SopTaskMutation) ResetEdge(name string) error {
  31375. switch name {
  31376. case soptask.EdgeTaskStages:
  31377. m.ResetTaskStages()
  31378. return nil
  31379. }
  31380. return fmt.Errorf("unknown SopTask edge %s", name)
  31381. }
  31382. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  31383. type TokenMutation struct {
  31384. config
  31385. op Op
  31386. typ string
  31387. id *uint64
  31388. created_at *time.Time
  31389. updated_at *time.Time
  31390. deleted_at *time.Time
  31391. expire_at *time.Time
  31392. token *string
  31393. mac *string
  31394. organization_id *uint64
  31395. addorganization_id *int64
  31396. custom_agent_base *string
  31397. custom_agent_key *string
  31398. openai_base *string
  31399. openai_key *string
  31400. clearedFields map[string]struct{}
  31401. agent *uint64
  31402. clearedagent bool
  31403. done bool
  31404. oldValue func(context.Context) (*Token, error)
  31405. predicates []predicate.Token
  31406. }
  31407. var _ ent.Mutation = (*TokenMutation)(nil)
  31408. // tokenOption allows management of the mutation configuration using functional options.
  31409. type tokenOption func(*TokenMutation)
  31410. // newTokenMutation creates new mutation for the Token entity.
  31411. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  31412. m := &TokenMutation{
  31413. config: c,
  31414. op: op,
  31415. typ: TypeToken,
  31416. clearedFields: make(map[string]struct{}),
  31417. }
  31418. for _, opt := range opts {
  31419. opt(m)
  31420. }
  31421. return m
  31422. }
  31423. // withTokenID sets the ID field of the mutation.
  31424. func withTokenID(id uint64) tokenOption {
  31425. return func(m *TokenMutation) {
  31426. var (
  31427. err error
  31428. once sync.Once
  31429. value *Token
  31430. )
  31431. m.oldValue = func(ctx context.Context) (*Token, error) {
  31432. once.Do(func() {
  31433. if m.done {
  31434. err = errors.New("querying old values post mutation is not allowed")
  31435. } else {
  31436. value, err = m.Client().Token.Get(ctx, id)
  31437. }
  31438. })
  31439. return value, err
  31440. }
  31441. m.id = &id
  31442. }
  31443. }
  31444. // withToken sets the old Token of the mutation.
  31445. func withToken(node *Token) tokenOption {
  31446. return func(m *TokenMutation) {
  31447. m.oldValue = func(context.Context) (*Token, error) {
  31448. return node, nil
  31449. }
  31450. m.id = &node.ID
  31451. }
  31452. }
  31453. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31454. // executed in a transaction (ent.Tx), a transactional client is returned.
  31455. func (m TokenMutation) Client() *Client {
  31456. client := &Client{config: m.config}
  31457. client.init()
  31458. return client
  31459. }
  31460. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31461. // it returns an error otherwise.
  31462. func (m TokenMutation) Tx() (*Tx, error) {
  31463. if _, ok := m.driver.(*txDriver); !ok {
  31464. return nil, errors.New("ent: mutation is not running in a transaction")
  31465. }
  31466. tx := &Tx{config: m.config}
  31467. tx.init()
  31468. return tx, nil
  31469. }
  31470. // SetID sets the value of the id field. Note that this
  31471. // operation is only accepted on creation of Token entities.
  31472. func (m *TokenMutation) SetID(id uint64) {
  31473. m.id = &id
  31474. }
  31475. // ID returns the ID value in the mutation. Note that the ID is only available
  31476. // if it was provided to the builder or after it was returned from the database.
  31477. func (m *TokenMutation) ID() (id uint64, exists bool) {
  31478. if m.id == nil {
  31479. return
  31480. }
  31481. return *m.id, true
  31482. }
  31483. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31484. // That means, if the mutation is applied within a transaction with an isolation level such
  31485. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  31486. // or updated by the mutation.
  31487. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  31488. switch {
  31489. case m.op.Is(OpUpdateOne | OpDeleteOne):
  31490. id, exists := m.ID()
  31491. if exists {
  31492. return []uint64{id}, nil
  31493. }
  31494. fallthrough
  31495. case m.op.Is(OpUpdate | OpDelete):
  31496. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  31497. default:
  31498. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  31499. }
  31500. }
  31501. // SetCreatedAt sets the "created_at" field.
  31502. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  31503. m.created_at = &t
  31504. }
  31505. // CreatedAt returns the value of the "created_at" field in the mutation.
  31506. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  31507. v := m.created_at
  31508. if v == nil {
  31509. return
  31510. }
  31511. return *v, true
  31512. }
  31513. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  31514. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  31515. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31516. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31517. if !m.op.Is(OpUpdateOne) {
  31518. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31519. }
  31520. if m.id == nil || m.oldValue == nil {
  31521. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31522. }
  31523. oldValue, err := m.oldValue(ctx)
  31524. if err != nil {
  31525. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31526. }
  31527. return oldValue.CreatedAt, nil
  31528. }
  31529. // ResetCreatedAt resets all changes to the "created_at" field.
  31530. func (m *TokenMutation) ResetCreatedAt() {
  31531. m.created_at = nil
  31532. }
  31533. // SetUpdatedAt sets the "updated_at" field.
  31534. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  31535. m.updated_at = &t
  31536. }
  31537. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31538. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  31539. v := m.updated_at
  31540. if v == nil {
  31541. return
  31542. }
  31543. return *v, true
  31544. }
  31545. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  31546. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  31547. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31548. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31549. if !m.op.Is(OpUpdateOne) {
  31550. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31551. }
  31552. if m.id == nil || m.oldValue == nil {
  31553. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31554. }
  31555. oldValue, err := m.oldValue(ctx)
  31556. if err != nil {
  31557. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31558. }
  31559. return oldValue.UpdatedAt, nil
  31560. }
  31561. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31562. func (m *TokenMutation) ResetUpdatedAt() {
  31563. m.updated_at = nil
  31564. }
  31565. // SetDeletedAt sets the "deleted_at" field.
  31566. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  31567. m.deleted_at = &t
  31568. }
  31569. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  31570. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  31571. v := m.deleted_at
  31572. if v == nil {
  31573. return
  31574. }
  31575. return *v, true
  31576. }
  31577. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  31578. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  31579. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31580. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  31581. if !m.op.Is(OpUpdateOne) {
  31582. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  31583. }
  31584. if m.id == nil || m.oldValue == nil {
  31585. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  31586. }
  31587. oldValue, err := m.oldValue(ctx)
  31588. if err != nil {
  31589. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  31590. }
  31591. return oldValue.DeletedAt, nil
  31592. }
  31593. // ClearDeletedAt clears the value of the "deleted_at" field.
  31594. func (m *TokenMutation) ClearDeletedAt() {
  31595. m.deleted_at = nil
  31596. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  31597. }
  31598. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  31599. func (m *TokenMutation) DeletedAtCleared() bool {
  31600. _, ok := m.clearedFields[token.FieldDeletedAt]
  31601. return ok
  31602. }
  31603. // ResetDeletedAt resets all changes to the "deleted_at" field.
  31604. func (m *TokenMutation) ResetDeletedAt() {
  31605. m.deleted_at = nil
  31606. delete(m.clearedFields, token.FieldDeletedAt)
  31607. }
  31608. // SetExpireAt sets the "expire_at" field.
  31609. func (m *TokenMutation) SetExpireAt(t time.Time) {
  31610. m.expire_at = &t
  31611. }
  31612. // ExpireAt returns the value of the "expire_at" field in the mutation.
  31613. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  31614. v := m.expire_at
  31615. if v == nil {
  31616. return
  31617. }
  31618. return *v, true
  31619. }
  31620. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  31621. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  31622. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31623. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  31624. if !m.op.Is(OpUpdateOne) {
  31625. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  31626. }
  31627. if m.id == nil || m.oldValue == nil {
  31628. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  31629. }
  31630. oldValue, err := m.oldValue(ctx)
  31631. if err != nil {
  31632. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  31633. }
  31634. return oldValue.ExpireAt, nil
  31635. }
  31636. // ClearExpireAt clears the value of the "expire_at" field.
  31637. func (m *TokenMutation) ClearExpireAt() {
  31638. m.expire_at = nil
  31639. m.clearedFields[token.FieldExpireAt] = struct{}{}
  31640. }
  31641. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  31642. func (m *TokenMutation) ExpireAtCleared() bool {
  31643. _, ok := m.clearedFields[token.FieldExpireAt]
  31644. return ok
  31645. }
  31646. // ResetExpireAt resets all changes to the "expire_at" field.
  31647. func (m *TokenMutation) ResetExpireAt() {
  31648. m.expire_at = nil
  31649. delete(m.clearedFields, token.FieldExpireAt)
  31650. }
  31651. // SetToken sets the "token" field.
  31652. func (m *TokenMutation) SetToken(s string) {
  31653. m.token = &s
  31654. }
  31655. // Token returns the value of the "token" field in the mutation.
  31656. func (m *TokenMutation) Token() (r string, exists bool) {
  31657. v := m.token
  31658. if v == nil {
  31659. return
  31660. }
  31661. return *v, true
  31662. }
  31663. // OldToken returns the old "token" field's value of the Token entity.
  31664. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  31665. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31666. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  31667. if !m.op.Is(OpUpdateOne) {
  31668. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  31669. }
  31670. if m.id == nil || m.oldValue == nil {
  31671. return v, errors.New("OldToken requires an ID field in the mutation")
  31672. }
  31673. oldValue, err := m.oldValue(ctx)
  31674. if err != nil {
  31675. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  31676. }
  31677. return oldValue.Token, nil
  31678. }
  31679. // ClearToken clears the value of the "token" field.
  31680. func (m *TokenMutation) ClearToken() {
  31681. m.token = nil
  31682. m.clearedFields[token.FieldToken] = struct{}{}
  31683. }
  31684. // TokenCleared returns if the "token" field was cleared in this mutation.
  31685. func (m *TokenMutation) TokenCleared() bool {
  31686. _, ok := m.clearedFields[token.FieldToken]
  31687. return ok
  31688. }
  31689. // ResetToken resets all changes to the "token" field.
  31690. func (m *TokenMutation) ResetToken() {
  31691. m.token = nil
  31692. delete(m.clearedFields, token.FieldToken)
  31693. }
  31694. // SetMAC sets the "mac" field.
  31695. func (m *TokenMutation) SetMAC(s string) {
  31696. m.mac = &s
  31697. }
  31698. // MAC returns the value of the "mac" field in the mutation.
  31699. func (m *TokenMutation) MAC() (r string, exists bool) {
  31700. v := m.mac
  31701. if v == nil {
  31702. return
  31703. }
  31704. return *v, true
  31705. }
  31706. // OldMAC returns the old "mac" field's value of the Token entity.
  31707. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  31708. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31709. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  31710. if !m.op.Is(OpUpdateOne) {
  31711. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  31712. }
  31713. if m.id == nil || m.oldValue == nil {
  31714. return v, errors.New("OldMAC requires an ID field in the mutation")
  31715. }
  31716. oldValue, err := m.oldValue(ctx)
  31717. if err != nil {
  31718. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  31719. }
  31720. return oldValue.MAC, nil
  31721. }
  31722. // ClearMAC clears the value of the "mac" field.
  31723. func (m *TokenMutation) ClearMAC() {
  31724. m.mac = nil
  31725. m.clearedFields[token.FieldMAC] = struct{}{}
  31726. }
  31727. // MACCleared returns if the "mac" field was cleared in this mutation.
  31728. func (m *TokenMutation) MACCleared() bool {
  31729. _, ok := m.clearedFields[token.FieldMAC]
  31730. return ok
  31731. }
  31732. // ResetMAC resets all changes to the "mac" field.
  31733. func (m *TokenMutation) ResetMAC() {
  31734. m.mac = nil
  31735. delete(m.clearedFields, token.FieldMAC)
  31736. }
  31737. // SetOrganizationID sets the "organization_id" field.
  31738. func (m *TokenMutation) SetOrganizationID(u uint64) {
  31739. m.organization_id = &u
  31740. m.addorganization_id = nil
  31741. }
  31742. // OrganizationID returns the value of the "organization_id" field in the mutation.
  31743. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  31744. v := m.organization_id
  31745. if v == nil {
  31746. return
  31747. }
  31748. return *v, true
  31749. }
  31750. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  31751. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  31752. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31753. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  31754. if !m.op.Is(OpUpdateOne) {
  31755. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  31756. }
  31757. if m.id == nil || m.oldValue == nil {
  31758. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  31759. }
  31760. oldValue, err := m.oldValue(ctx)
  31761. if err != nil {
  31762. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  31763. }
  31764. return oldValue.OrganizationID, nil
  31765. }
  31766. // AddOrganizationID adds u to the "organization_id" field.
  31767. func (m *TokenMutation) AddOrganizationID(u int64) {
  31768. if m.addorganization_id != nil {
  31769. *m.addorganization_id += u
  31770. } else {
  31771. m.addorganization_id = &u
  31772. }
  31773. }
  31774. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  31775. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  31776. v := m.addorganization_id
  31777. if v == nil {
  31778. return
  31779. }
  31780. return *v, true
  31781. }
  31782. // ResetOrganizationID resets all changes to the "organization_id" field.
  31783. func (m *TokenMutation) ResetOrganizationID() {
  31784. m.organization_id = nil
  31785. m.addorganization_id = nil
  31786. }
  31787. // SetAgentID sets the "agent_id" field.
  31788. func (m *TokenMutation) SetAgentID(u uint64) {
  31789. m.agent = &u
  31790. }
  31791. // AgentID returns the value of the "agent_id" field in the mutation.
  31792. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  31793. v := m.agent
  31794. if v == nil {
  31795. return
  31796. }
  31797. return *v, true
  31798. }
  31799. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  31800. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  31801. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31802. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  31803. if !m.op.Is(OpUpdateOne) {
  31804. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  31805. }
  31806. if m.id == nil || m.oldValue == nil {
  31807. return v, errors.New("OldAgentID requires an ID field in the mutation")
  31808. }
  31809. oldValue, err := m.oldValue(ctx)
  31810. if err != nil {
  31811. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  31812. }
  31813. return oldValue.AgentID, nil
  31814. }
  31815. // ResetAgentID resets all changes to the "agent_id" field.
  31816. func (m *TokenMutation) ResetAgentID() {
  31817. m.agent = nil
  31818. }
  31819. // SetCustomAgentBase sets the "custom_agent_base" field.
  31820. func (m *TokenMutation) SetCustomAgentBase(s string) {
  31821. m.custom_agent_base = &s
  31822. }
  31823. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  31824. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  31825. v := m.custom_agent_base
  31826. if v == nil {
  31827. return
  31828. }
  31829. return *v, true
  31830. }
  31831. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  31832. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  31833. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31834. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  31835. if !m.op.Is(OpUpdateOne) {
  31836. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  31837. }
  31838. if m.id == nil || m.oldValue == nil {
  31839. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  31840. }
  31841. oldValue, err := m.oldValue(ctx)
  31842. if err != nil {
  31843. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  31844. }
  31845. return oldValue.CustomAgentBase, nil
  31846. }
  31847. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  31848. func (m *TokenMutation) ClearCustomAgentBase() {
  31849. m.custom_agent_base = nil
  31850. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  31851. }
  31852. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  31853. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  31854. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  31855. return ok
  31856. }
  31857. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  31858. func (m *TokenMutation) ResetCustomAgentBase() {
  31859. m.custom_agent_base = nil
  31860. delete(m.clearedFields, token.FieldCustomAgentBase)
  31861. }
  31862. // SetCustomAgentKey sets the "custom_agent_key" field.
  31863. func (m *TokenMutation) SetCustomAgentKey(s string) {
  31864. m.custom_agent_key = &s
  31865. }
  31866. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  31867. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  31868. v := m.custom_agent_key
  31869. if v == nil {
  31870. return
  31871. }
  31872. return *v, true
  31873. }
  31874. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  31875. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  31876. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31877. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  31878. if !m.op.Is(OpUpdateOne) {
  31879. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  31880. }
  31881. if m.id == nil || m.oldValue == nil {
  31882. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  31883. }
  31884. oldValue, err := m.oldValue(ctx)
  31885. if err != nil {
  31886. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  31887. }
  31888. return oldValue.CustomAgentKey, nil
  31889. }
  31890. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  31891. func (m *TokenMutation) ClearCustomAgentKey() {
  31892. m.custom_agent_key = nil
  31893. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  31894. }
  31895. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  31896. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  31897. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  31898. return ok
  31899. }
  31900. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  31901. func (m *TokenMutation) ResetCustomAgentKey() {
  31902. m.custom_agent_key = nil
  31903. delete(m.clearedFields, token.FieldCustomAgentKey)
  31904. }
  31905. // SetOpenaiBase sets the "openai_base" field.
  31906. func (m *TokenMutation) SetOpenaiBase(s string) {
  31907. m.openai_base = &s
  31908. }
  31909. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  31910. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  31911. v := m.openai_base
  31912. if v == nil {
  31913. return
  31914. }
  31915. return *v, true
  31916. }
  31917. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  31918. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  31919. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31920. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  31921. if !m.op.Is(OpUpdateOne) {
  31922. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  31923. }
  31924. if m.id == nil || m.oldValue == nil {
  31925. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  31926. }
  31927. oldValue, err := m.oldValue(ctx)
  31928. if err != nil {
  31929. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  31930. }
  31931. return oldValue.OpenaiBase, nil
  31932. }
  31933. // ClearOpenaiBase clears the value of the "openai_base" field.
  31934. func (m *TokenMutation) ClearOpenaiBase() {
  31935. m.openai_base = nil
  31936. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  31937. }
  31938. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  31939. func (m *TokenMutation) OpenaiBaseCleared() bool {
  31940. _, ok := m.clearedFields[token.FieldOpenaiBase]
  31941. return ok
  31942. }
  31943. // ResetOpenaiBase resets all changes to the "openai_base" field.
  31944. func (m *TokenMutation) ResetOpenaiBase() {
  31945. m.openai_base = nil
  31946. delete(m.clearedFields, token.FieldOpenaiBase)
  31947. }
  31948. // SetOpenaiKey sets the "openai_key" field.
  31949. func (m *TokenMutation) SetOpenaiKey(s string) {
  31950. m.openai_key = &s
  31951. }
  31952. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  31953. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  31954. v := m.openai_key
  31955. if v == nil {
  31956. return
  31957. }
  31958. return *v, true
  31959. }
  31960. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  31961. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  31962. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31963. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  31964. if !m.op.Is(OpUpdateOne) {
  31965. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  31966. }
  31967. if m.id == nil || m.oldValue == nil {
  31968. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  31969. }
  31970. oldValue, err := m.oldValue(ctx)
  31971. if err != nil {
  31972. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  31973. }
  31974. return oldValue.OpenaiKey, nil
  31975. }
  31976. // ClearOpenaiKey clears the value of the "openai_key" field.
  31977. func (m *TokenMutation) ClearOpenaiKey() {
  31978. m.openai_key = nil
  31979. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  31980. }
  31981. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  31982. func (m *TokenMutation) OpenaiKeyCleared() bool {
  31983. _, ok := m.clearedFields[token.FieldOpenaiKey]
  31984. return ok
  31985. }
  31986. // ResetOpenaiKey resets all changes to the "openai_key" field.
  31987. func (m *TokenMutation) ResetOpenaiKey() {
  31988. m.openai_key = nil
  31989. delete(m.clearedFields, token.FieldOpenaiKey)
  31990. }
  31991. // ClearAgent clears the "agent" edge to the Agent entity.
  31992. func (m *TokenMutation) ClearAgent() {
  31993. m.clearedagent = true
  31994. m.clearedFields[token.FieldAgentID] = struct{}{}
  31995. }
  31996. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  31997. func (m *TokenMutation) AgentCleared() bool {
  31998. return m.clearedagent
  31999. }
  32000. // AgentIDs returns the "agent" edge IDs in the mutation.
  32001. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  32002. // AgentID instead. It exists only for internal usage by the builders.
  32003. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  32004. if id := m.agent; id != nil {
  32005. ids = append(ids, *id)
  32006. }
  32007. return
  32008. }
  32009. // ResetAgent resets all changes to the "agent" edge.
  32010. func (m *TokenMutation) ResetAgent() {
  32011. m.agent = nil
  32012. m.clearedagent = false
  32013. }
  32014. // Where appends a list predicates to the TokenMutation builder.
  32015. func (m *TokenMutation) Where(ps ...predicate.Token) {
  32016. m.predicates = append(m.predicates, ps...)
  32017. }
  32018. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  32019. // users can use type-assertion to append predicates that do not depend on any generated package.
  32020. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  32021. p := make([]predicate.Token, len(ps))
  32022. for i := range ps {
  32023. p[i] = ps[i]
  32024. }
  32025. m.Where(p...)
  32026. }
  32027. // Op returns the operation name.
  32028. func (m *TokenMutation) Op() Op {
  32029. return m.op
  32030. }
  32031. // SetOp allows setting the mutation operation.
  32032. func (m *TokenMutation) SetOp(op Op) {
  32033. m.op = op
  32034. }
  32035. // Type returns the node type of this mutation (Token).
  32036. func (m *TokenMutation) Type() string {
  32037. return m.typ
  32038. }
  32039. // Fields returns all fields that were changed during this mutation. Note that in
  32040. // order to get all numeric fields that were incremented/decremented, call
  32041. // AddedFields().
  32042. func (m *TokenMutation) Fields() []string {
  32043. fields := make([]string, 0, 12)
  32044. if m.created_at != nil {
  32045. fields = append(fields, token.FieldCreatedAt)
  32046. }
  32047. if m.updated_at != nil {
  32048. fields = append(fields, token.FieldUpdatedAt)
  32049. }
  32050. if m.deleted_at != nil {
  32051. fields = append(fields, token.FieldDeletedAt)
  32052. }
  32053. if m.expire_at != nil {
  32054. fields = append(fields, token.FieldExpireAt)
  32055. }
  32056. if m.token != nil {
  32057. fields = append(fields, token.FieldToken)
  32058. }
  32059. if m.mac != nil {
  32060. fields = append(fields, token.FieldMAC)
  32061. }
  32062. if m.organization_id != nil {
  32063. fields = append(fields, token.FieldOrganizationID)
  32064. }
  32065. if m.agent != nil {
  32066. fields = append(fields, token.FieldAgentID)
  32067. }
  32068. if m.custom_agent_base != nil {
  32069. fields = append(fields, token.FieldCustomAgentBase)
  32070. }
  32071. if m.custom_agent_key != nil {
  32072. fields = append(fields, token.FieldCustomAgentKey)
  32073. }
  32074. if m.openai_base != nil {
  32075. fields = append(fields, token.FieldOpenaiBase)
  32076. }
  32077. if m.openai_key != nil {
  32078. fields = append(fields, token.FieldOpenaiKey)
  32079. }
  32080. return fields
  32081. }
  32082. // Field returns the value of a field with the given name. The second boolean
  32083. // return value indicates that this field was not set, or was not defined in the
  32084. // schema.
  32085. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  32086. switch name {
  32087. case token.FieldCreatedAt:
  32088. return m.CreatedAt()
  32089. case token.FieldUpdatedAt:
  32090. return m.UpdatedAt()
  32091. case token.FieldDeletedAt:
  32092. return m.DeletedAt()
  32093. case token.FieldExpireAt:
  32094. return m.ExpireAt()
  32095. case token.FieldToken:
  32096. return m.Token()
  32097. case token.FieldMAC:
  32098. return m.MAC()
  32099. case token.FieldOrganizationID:
  32100. return m.OrganizationID()
  32101. case token.FieldAgentID:
  32102. return m.AgentID()
  32103. case token.FieldCustomAgentBase:
  32104. return m.CustomAgentBase()
  32105. case token.FieldCustomAgentKey:
  32106. return m.CustomAgentKey()
  32107. case token.FieldOpenaiBase:
  32108. return m.OpenaiBase()
  32109. case token.FieldOpenaiKey:
  32110. return m.OpenaiKey()
  32111. }
  32112. return nil, false
  32113. }
  32114. // OldField returns the old value of the field from the database. An error is
  32115. // returned if the mutation operation is not UpdateOne, or the query to the
  32116. // database failed.
  32117. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  32118. switch name {
  32119. case token.FieldCreatedAt:
  32120. return m.OldCreatedAt(ctx)
  32121. case token.FieldUpdatedAt:
  32122. return m.OldUpdatedAt(ctx)
  32123. case token.FieldDeletedAt:
  32124. return m.OldDeletedAt(ctx)
  32125. case token.FieldExpireAt:
  32126. return m.OldExpireAt(ctx)
  32127. case token.FieldToken:
  32128. return m.OldToken(ctx)
  32129. case token.FieldMAC:
  32130. return m.OldMAC(ctx)
  32131. case token.FieldOrganizationID:
  32132. return m.OldOrganizationID(ctx)
  32133. case token.FieldAgentID:
  32134. return m.OldAgentID(ctx)
  32135. case token.FieldCustomAgentBase:
  32136. return m.OldCustomAgentBase(ctx)
  32137. case token.FieldCustomAgentKey:
  32138. return m.OldCustomAgentKey(ctx)
  32139. case token.FieldOpenaiBase:
  32140. return m.OldOpenaiBase(ctx)
  32141. case token.FieldOpenaiKey:
  32142. return m.OldOpenaiKey(ctx)
  32143. }
  32144. return nil, fmt.Errorf("unknown Token field %s", name)
  32145. }
  32146. // SetField sets the value of a field with the given name. It returns an error if
  32147. // the field is not defined in the schema, or if the type mismatched the field
  32148. // type.
  32149. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  32150. switch name {
  32151. case token.FieldCreatedAt:
  32152. v, ok := value.(time.Time)
  32153. if !ok {
  32154. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32155. }
  32156. m.SetCreatedAt(v)
  32157. return nil
  32158. case token.FieldUpdatedAt:
  32159. v, ok := value.(time.Time)
  32160. if !ok {
  32161. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32162. }
  32163. m.SetUpdatedAt(v)
  32164. return nil
  32165. case token.FieldDeletedAt:
  32166. v, ok := value.(time.Time)
  32167. if !ok {
  32168. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32169. }
  32170. m.SetDeletedAt(v)
  32171. return nil
  32172. case token.FieldExpireAt:
  32173. v, ok := value.(time.Time)
  32174. if !ok {
  32175. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32176. }
  32177. m.SetExpireAt(v)
  32178. return nil
  32179. case token.FieldToken:
  32180. v, ok := value.(string)
  32181. if !ok {
  32182. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32183. }
  32184. m.SetToken(v)
  32185. return nil
  32186. case token.FieldMAC:
  32187. v, ok := value.(string)
  32188. if !ok {
  32189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32190. }
  32191. m.SetMAC(v)
  32192. return nil
  32193. case token.FieldOrganizationID:
  32194. v, ok := value.(uint64)
  32195. if !ok {
  32196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32197. }
  32198. m.SetOrganizationID(v)
  32199. return nil
  32200. case token.FieldAgentID:
  32201. v, ok := value.(uint64)
  32202. if !ok {
  32203. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32204. }
  32205. m.SetAgentID(v)
  32206. return nil
  32207. case token.FieldCustomAgentBase:
  32208. v, ok := value.(string)
  32209. if !ok {
  32210. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32211. }
  32212. m.SetCustomAgentBase(v)
  32213. return nil
  32214. case token.FieldCustomAgentKey:
  32215. v, ok := value.(string)
  32216. if !ok {
  32217. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32218. }
  32219. m.SetCustomAgentKey(v)
  32220. return nil
  32221. case token.FieldOpenaiBase:
  32222. v, ok := value.(string)
  32223. if !ok {
  32224. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32225. }
  32226. m.SetOpenaiBase(v)
  32227. return nil
  32228. case token.FieldOpenaiKey:
  32229. v, ok := value.(string)
  32230. if !ok {
  32231. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32232. }
  32233. m.SetOpenaiKey(v)
  32234. return nil
  32235. }
  32236. return fmt.Errorf("unknown Token field %s", name)
  32237. }
  32238. // AddedFields returns all numeric fields that were incremented/decremented during
  32239. // this mutation.
  32240. func (m *TokenMutation) AddedFields() []string {
  32241. var fields []string
  32242. if m.addorganization_id != nil {
  32243. fields = append(fields, token.FieldOrganizationID)
  32244. }
  32245. return fields
  32246. }
  32247. // AddedField returns the numeric value that was incremented/decremented on a field
  32248. // with the given name. The second boolean return value indicates that this field
  32249. // was not set, or was not defined in the schema.
  32250. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  32251. switch name {
  32252. case token.FieldOrganizationID:
  32253. return m.AddedOrganizationID()
  32254. }
  32255. return nil, false
  32256. }
  32257. // AddField adds the value to the field with the given name. It returns an error if
  32258. // the field is not defined in the schema, or if the type mismatched the field
  32259. // type.
  32260. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  32261. switch name {
  32262. case token.FieldOrganizationID:
  32263. v, ok := value.(int64)
  32264. if !ok {
  32265. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32266. }
  32267. m.AddOrganizationID(v)
  32268. return nil
  32269. }
  32270. return fmt.Errorf("unknown Token numeric field %s", name)
  32271. }
  32272. // ClearedFields returns all nullable fields that were cleared during this
  32273. // mutation.
  32274. func (m *TokenMutation) ClearedFields() []string {
  32275. var fields []string
  32276. if m.FieldCleared(token.FieldDeletedAt) {
  32277. fields = append(fields, token.FieldDeletedAt)
  32278. }
  32279. if m.FieldCleared(token.FieldExpireAt) {
  32280. fields = append(fields, token.FieldExpireAt)
  32281. }
  32282. if m.FieldCleared(token.FieldToken) {
  32283. fields = append(fields, token.FieldToken)
  32284. }
  32285. if m.FieldCleared(token.FieldMAC) {
  32286. fields = append(fields, token.FieldMAC)
  32287. }
  32288. if m.FieldCleared(token.FieldCustomAgentBase) {
  32289. fields = append(fields, token.FieldCustomAgentBase)
  32290. }
  32291. if m.FieldCleared(token.FieldCustomAgentKey) {
  32292. fields = append(fields, token.FieldCustomAgentKey)
  32293. }
  32294. if m.FieldCleared(token.FieldOpenaiBase) {
  32295. fields = append(fields, token.FieldOpenaiBase)
  32296. }
  32297. if m.FieldCleared(token.FieldOpenaiKey) {
  32298. fields = append(fields, token.FieldOpenaiKey)
  32299. }
  32300. return fields
  32301. }
  32302. // FieldCleared returns a boolean indicating if a field with the given name was
  32303. // cleared in this mutation.
  32304. func (m *TokenMutation) FieldCleared(name string) bool {
  32305. _, ok := m.clearedFields[name]
  32306. return ok
  32307. }
  32308. // ClearField clears the value of the field with the given name. It returns an
  32309. // error if the field is not defined in the schema.
  32310. func (m *TokenMutation) ClearField(name string) error {
  32311. switch name {
  32312. case token.FieldDeletedAt:
  32313. m.ClearDeletedAt()
  32314. return nil
  32315. case token.FieldExpireAt:
  32316. m.ClearExpireAt()
  32317. return nil
  32318. case token.FieldToken:
  32319. m.ClearToken()
  32320. return nil
  32321. case token.FieldMAC:
  32322. m.ClearMAC()
  32323. return nil
  32324. case token.FieldCustomAgentBase:
  32325. m.ClearCustomAgentBase()
  32326. return nil
  32327. case token.FieldCustomAgentKey:
  32328. m.ClearCustomAgentKey()
  32329. return nil
  32330. case token.FieldOpenaiBase:
  32331. m.ClearOpenaiBase()
  32332. return nil
  32333. case token.FieldOpenaiKey:
  32334. m.ClearOpenaiKey()
  32335. return nil
  32336. }
  32337. return fmt.Errorf("unknown Token nullable field %s", name)
  32338. }
  32339. // ResetField resets all changes in the mutation for the field with the given name.
  32340. // It returns an error if the field is not defined in the schema.
  32341. func (m *TokenMutation) ResetField(name string) error {
  32342. switch name {
  32343. case token.FieldCreatedAt:
  32344. m.ResetCreatedAt()
  32345. return nil
  32346. case token.FieldUpdatedAt:
  32347. m.ResetUpdatedAt()
  32348. return nil
  32349. case token.FieldDeletedAt:
  32350. m.ResetDeletedAt()
  32351. return nil
  32352. case token.FieldExpireAt:
  32353. m.ResetExpireAt()
  32354. return nil
  32355. case token.FieldToken:
  32356. m.ResetToken()
  32357. return nil
  32358. case token.FieldMAC:
  32359. m.ResetMAC()
  32360. return nil
  32361. case token.FieldOrganizationID:
  32362. m.ResetOrganizationID()
  32363. return nil
  32364. case token.FieldAgentID:
  32365. m.ResetAgentID()
  32366. return nil
  32367. case token.FieldCustomAgentBase:
  32368. m.ResetCustomAgentBase()
  32369. return nil
  32370. case token.FieldCustomAgentKey:
  32371. m.ResetCustomAgentKey()
  32372. return nil
  32373. case token.FieldOpenaiBase:
  32374. m.ResetOpenaiBase()
  32375. return nil
  32376. case token.FieldOpenaiKey:
  32377. m.ResetOpenaiKey()
  32378. return nil
  32379. }
  32380. return fmt.Errorf("unknown Token field %s", name)
  32381. }
  32382. // AddedEdges returns all edge names that were set/added in this mutation.
  32383. func (m *TokenMutation) AddedEdges() []string {
  32384. edges := make([]string, 0, 1)
  32385. if m.agent != nil {
  32386. edges = append(edges, token.EdgeAgent)
  32387. }
  32388. return edges
  32389. }
  32390. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32391. // name in this mutation.
  32392. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  32393. switch name {
  32394. case token.EdgeAgent:
  32395. if id := m.agent; id != nil {
  32396. return []ent.Value{*id}
  32397. }
  32398. }
  32399. return nil
  32400. }
  32401. // RemovedEdges returns all edge names that were removed in this mutation.
  32402. func (m *TokenMutation) RemovedEdges() []string {
  32403. edges := make([]string, 0, 1)
  32404. return edges
  32405. }
  32406. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32407. // the given name in this mutation.
  32408. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  32409. return nil
  32410. }
  32411. // ClearedEdges returns all edge names that were cleared in this mutation.
  32412. func (m *TokenMutation) ClearedEdges() []string {
  32413. edges := make([]string, 0, 1)
  32414. if m.clearedagent {
  32415. edges = append(edges, token.EdgeAgent)
  32416. }
  32417. return edges
  32418. }
  32419. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32420. // was cleared in this mutation.
  32421. func (m *TokenMutation) EdgeCleared(name string) bool {
  32422. switch name {
  32423. case token.EdgeAgent:
  32424. return m.clearedagent
  32425. }
  32426. return false
  32427. }
  32428. // ClearEdge clears the value of the edge with the given name. It returns an error
  32429. // if that edge is not defined in the schema.
  32430. func (m *TokenMutation) ClearEdge(name string) error {
  32431. switch name {
  32432. case token.EdgeAgent:
  32433. m.ClearAgent()
  32434. return nil
  32435. }
  32436. return fmt.Errorf("unknown Token unique edge %s", name)
  32437. }
  32438. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32439. // It returns an error if the edge is not defined in the schema.
  32440. func (m *TokenMutation) ResetEdge(name string) error {
  32441. switch name {
  32442. case token.EdgeAgent:
  32443. m.ResetAgent()
  32444. return nil
  32445. }
  32446. return fmt.Errorf("unknown Token edge %s", name)
  32447. }
  32448. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  32449. type TutorialMutation struct {
  32450. config
  32451. op Op
  32452. typ string
  32453. id *uint64
  32454. created_at *time.Time
  32455. updated_at *time.Time
  32456. deleted_at *time.Time
  32457. index *int
  32458. addindex *int
  32459. title *string
  32460. content *string
  32461. organization_id *uint64
  32462. addorganization_id *int64
  32463. clearedFields map[string]struct{}
  32464. employee *uint64
  32465. clearedemployee bool
  32466. done bool
  32467. oldValue func(context.Context) (*Tutorial, error)
  32468. predicates []predicate.Tutorial
  32469. }
  32470. var _ ent.Mutation = (*TutorialMutation)(nil)
  32471. // tutorialOption allows management of the mutation configuration using functional options.
  32472. type tutorialOption func(*TutorialMutation)
  32473. // newTutorialMutation creates new mutation for the Tutorial entity.
  32474. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  32475. m := &TutorialMutation{
  32476. config: c,
  32477. op: op,
  32478. typ: TypeTutorial,
  32479. clearedFields: make(map[string]struct{}),
  32480. }
  32481. for _, opt := range opts {
  32482. opt(m)
  32483. }
  32484. return m
  32485. }
  32486. // withTutorialID sets the ID field of the mutation.
  32487. func withTutorialID(id uint64) tutorialOption {
  32488. return func(m *TutorialMutation) {
  32489. var (
  32490. err error
  32491. once sync.Once
  32492. value *Tutorial
  32493. )
  32494. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  32495. once.Do(func() {
  32496. if m.done {
  32497. err = errors.New("querying old values post mutation is not allowed")
  32498. } else {
  32499. value, err = m.Client().Tutorial.Get(ctx, id)
  32500. }
  32501. })
  32502. return value, err
  32503. }
  32504. m.id = &id
  32505. }
  32506. }
  32507. // withTutorial sets the old Tutorial of the mutation.
  32508. func withTutorial(node *Tutorial) tutorialOption {
  32509. return func(m *TutorialMutation) {
  32510. m.oldValue = func(context.Context) (*Tutorial, error) {
  32511. return node, nil
  32512. }
  32513. m.id = &node.ID
  32514. }
  32515. }
  32516. // Client returns a new `ent.Client` from the mutation. If the mutation was
  32517. // executed in a transaction (ent.Tx), a transactional client is returned.
  32518. func (m TutorialMutation) Client() *Client {
  32519. client := &Client{config: m.config}
  32520. client.init()
  32521. return client
  32522. }
  32523. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  32524. // it returns an error otherwise.
  32525. func (m TutorialMutation) Tx() (*Tx, error) {
  32526. if _, ok := m.driver.(*txDriver); !ok {
  32527. return nil, errors.New("ent: mutation is not running in a transaction")
  32528. }
  32529. tx := &Tx{config: m.config}
  32530. tx.init()
  32531. return tx, nil
  32532. }
  32533. // SetID sets the value of the id field. Note that this
  32534. // operation is only accepted on creation of Tutorial entities.
  32535. func (m *TutorialMutation) SetID(id uint64) {
  32536. m.id = &id
  32537. }
  32538. // ID returns the ID value in the mutation. Note that the ID is only available
  32539. // if it was provided to the builder or after it was returned from the database.
  32540. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  32541. if m.id == nil {
  32542. return
  32543. }
  32544. return *m.id, true
  32545. }
  32546. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32547. // That means, if the mutation is applied within a transaction with an isolation level such
  32548. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32549. // or updated by the mutation.
  32550. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  32551. switch {
  32552. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32553. id, exists := m.ID()
  32554. if exists {
  32555. return []uint64{id}, nil
  32556. }
  32557. fallthrough
  32558. case m.op.Is(OpUpdate | OpDelete):
  32559. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  32560. default:
  32561. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32562. }
  32563. }
  32564. // SetCreatedAt sets the "created_at" field.
  32565. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  32566. m.created_at = &t
  32567. }
  32568. // CreatedAt returns the value of the "created_at" field in the mutation.
  32569. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  32570. v := m.created_at
  32571. if v == nil {
  32572. return
  32573. }
  32574. return *v, true
  32575. }
  32576. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  32577. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  32578. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32579. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32580. if !m.op.Is(OpUpdateOne) {
  32581. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32582. }
  32583. if m.id == nil || m.oldValue == nil {
  32584. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32585. }
  32586. oldValue, err := m.oldValue(ctx)
  32587. if err != nil {
  32588. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32589. }
  32590. return oldValue.CreatedAt, nil
  32591. }
  32592. // ResetCreatedAt resets all changes to the "created_at" field.
  32593. func (m *TutorialMutation) ResetCreatedAt() {
  32594. m.created_at = nil
  32595. }
  32596. // SetUpdatedAt sets the "updated_at" field.
  32597. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  32598. m.updated_at = &t
  32599. }
  32600. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32601. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  32602. v := m.updated_at
  32603. if v == nil {
  32604. return
  32605. }
  32606. return *v, true
  32607. }
  32608. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  32609. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  32610. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32611. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32612. if !m.op.Is(OpUpdateOne) {
  32613. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32614. }
  32615. if m.id == nil || m.oldValue == nil {
  32616. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32617. }
  32618. oldValue, err := m.oldValue(ctx)
  32619. if err != nil {
  32620. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32621. }
  32622. return oldValue.UpdatedAt, nil
  32623. }
  32624. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32625. func (m *TutorialMutation) ResetUpdatedAt() {
  32626. m.updated_at = nil
  32627. }
  32628. // SetDeletedAt sets the "deleted_at" field.
  32629. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  32630. m.deleted_at = &t
  32631. }
  32632. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  32633. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  32634. v := m.deleted_at
  32635. if v == nil {
  32636. return
  32637. }
  32638. return *v, true
  32639. }
  32640. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  32641. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  32642. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32643. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  32644. if !m.op.Is(OpUpdateOne) {
  32645. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  32646. }
  32647. if m.id == nil || m.oldValue == nil {
  32648. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  32649. }
  32650. oldValue, err := m.oldValue(ctx)
  32651. if err != nil {
  32652. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  32653. }
  32654. return oldValue.DeletedAt, nil
  32655. }
  32656. // ClearDeletedAt clears the value of the "deleted_at" field.
  32657. func (m *TutorialMutation) ClearDeletedAt() {
  32658. m.deleted_at = nil
  32659. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  32660. }
  32661. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  32662. func (m *TutorialMutation) DeletedAtCleared() bool {
  32663. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  32664. return ok
  32665. }
  32666. // ResetDeletedAt resets all changes to the "deleted_at" field.
  32667. func (m *TutorialMutation) ResetDeletedAt() {
  32668. m.deleted_at = nil
  32669. delete(m.clearedFields, tutorial.FieldDeletedAt)
  32670. }
  32671. // SetEmployeeID sets the "employee_id" field.
  32672. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  32673. m.employee = &u
  32674. }
  32675. // EmployeeID returns the value of the "employee_id" field in the mutation.
  32676. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  32677. v := m.employee
  32678. if v == nil {
  32679. return
  32680. }
  32681. return *v, true
  32682. }
  32683. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  32684. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  32685. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32686. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  32687. if !m.op.Is(OpUpdateOne) {
  32688. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  32689. }
  32690. if m.id == nil || m.oldValue == nil {
  32691. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  32692. }
  32693. oldValue, err := m.oldValue(ctx)
  32694. if err != nil {
  32695. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  32696. }
  32697. return oldValue.EmployeeID, nil
  32698. }
  32699. // ResetEmployeeID resets all changes to the "employee_id" field.
  32700. func (m *TutorialMutation) ResetEmployeeID() {
  32701. m.employee = nil
  32702. }
  32703. // SetIndex sets the "index" field.
  32704. func (m *TutorialMutation) SetIndex(i int) {
  32705. m.index = &i
  32706. m.addindex = nil
  32707. }
  32708. // Index returns the value of the "index" field in the mutation.
  32709. func (m *TutorialMutation) Index() (r int, exists bool) {
  32710. v := m.index
  32711. if v == nil {
  32712. return
  32713. }
  32714. return *v, true
  32715. }
  32716. // OldIndex returns the old "index" field's value of the Tutorial entity.
  32717. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  32718. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32719. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  32720. if !m.op.Is(OpUpdateOne) {
  32721. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  32722. }
  32723. if m.id == nil || m.oldValue == nil {
  32724. return v, errors.New("OldIndex requires an ID field in the mutation")
  32725. }
  32726. oldValue, err := m.oldValue(ctx)
  32727. if err != nil {
  32728. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  32729. }
  32730. return oldValue.Index, nil
  32731. }
  32732. // AddIndex adds i to the "index" field.
  32733. func (m *TutorialMutation) AddIndex(i int) {
  32734. if m.addindex != nil {
  32735. *m.addindex += i
  32736. } else {
  32737. m.addindex = &i
  32738. }
  32739. }
  32740. // AddedIndex returns the value that was added to the "index" field in this mutation.
  32741. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  32742. v := m.addindex
  32743. if v == nil {
  32744. return
  32745. }
  32746. return *v, true
  32747. }
  32748. // ResetIndex resets all changes to the "index" field.
  32749. func (m *TutorialMutation) ResetIndex() {
  32750. m.index = nil
  32751. m.addindex = nil
  32752. }
  32753. // SetTitle sets the "title" field.
  32754. func (m *TutorialMutation) SetTitle(s string) {
  32755. m.title = &s
  32756. }
  32757. // Title returns the value of the "title" field in the mutation.
  32758. func (m *TutorialMutation) Title() (r string, exists bool) {
  32759. v := m.title
  32760. if v == nil {
  32761. return
  32762. }
  32763. return *v, true
  32764. }
  32765. // OldTitle returns the old "title" field's value of the Tutorial entity.
  32766. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  32767. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32768. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  32769. if !m.op.Is(OpUpdateOne) {
  32770. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  32771. }
  32772. if m.id == nil || m.oldValue == nil {
  32773. return v, errors.New("OldTitle requires an ID field in the mutation")
  32774. }
  32775. oldValue, err := m.oldValue(ctx)
  32776. if err != nil {
  32777. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  32778. }
  32779. return oldValue.Title, nil
  32780. }
  32781. // ResetTitle resets all changes to the "title" field.
  32782. func (m *TutorialMutation) ResetTitle() {
  32783. m.title = nil
  32784. }
  32785. // SetContent sets the "content" field.
  32786. func (m *TutorialMutation) SetContent(s string) {
  32787. m.content = &s
  32788. }
  32789. // Content returns the value of the "content" field in the mutation.
  32790. func (m *TutorialMutation) Content() (r string, exists bool) {
  32791. v := m.content
  32792. if v == nil {
  32793. return
  32794. }
  32795. return *v, true
  32796. }
  32797. // OldContent returns the old "content" field's value of the Tutorial entity.
  32798. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  32799. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32800. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  32801. if !m.op.Is(OpUpdateOne) {
  32802. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  32803. }
  32804. if m.id == nil || m.oldValue == nil {
  32805. return v, errors.New("OldContent requires an ID field in the mutation")
  32806. }
  32807. oldValue, err := m.oldValue(ctx)
  32808. if err != nil {
  32809. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  32810. }
  32811. return oldValue.Content, nil
  32812. }
  32813. // ResetContent resets all changes to the "content" field.
  32814. func (m *TutorialMutation) ResetContent() {
  32815. m.content = nil
  32816. }
  32817. // SetOrganizationID sets the "organization_id" field.
  32818. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  32819. m.organization_id = &u
  32820. m.addorganization_id = nil
  32821. }
  32822. // OrganizationID returns the value of the "organization_id" field in the mutation.
  32823. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  32824. v := m.organization_id
  32825. if v == nil {
  32826. return
  32827. }
  32828. return *v, true
  32829. }
  32830. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  32831. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  32832. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32833. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  32834. if !m.op.Is(OpUpdateOne) {
  32835. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  32836. }
  32837. if m.id == nil || m.oldValue == nil {
  32838. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  32839. }
  32840. oldValue, err := m.oldValue(ctx)
  32841. if err != nil {
  32842. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  32843. }
  32844. return oldValue.OrganizationID, nil
  32845. }
  32846. // AddOrganizationID adds u to the "organization_id" field.
  32847. func (m *TutorialMutation) AddOrganizationID(u int64) {
  32848. if m.addorganization_id != nil {
  32849. *m.addorganization_id += u
  32850. } else {
  32851. m.addorganization_id = &u
  32852. }
  32853. }
  32854. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  32855. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  32856. v := m.addorganization_id
  32857. if v == nil {
  32858. return
  32859. }
  32860. return *v, true
  32861. }
  32862. // ResetOrganizationID resets all changes to the "organization_id" field.
  32863. func (m *TutorialMutation) ResetOrganizationID() {
  32864. m.organization_id = nil
  32865. m.addorganization_id = nil
  32866. }
  32867. // ClearEmployee clears the "employee" edge to the Employee entity.
  32868. func (m *TutorialMutation) ClearEmployee() {
  32869. m.clearedemployee = true
  32870. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  32871. }
  32872. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  32873. func (m *TutorialMutation) EmployeeCleared() bool {
  32874. return m.clearedemployee
  32875. }
  32876. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  32877. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  32878. // EmployeeID instead. It exists only for internal usage by the builders.
  32879. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  32880. if id := m.employee; id != nil {
  32881. ids = append(ids, *id)
  32882. }
  32883. return
  32884. }
  32885. // ResetEmployee resets all changes to the "employee" edge.
  32886. func (m *TutorialMutation) ResetEmployee() {
  32887. m.employee = nil
  32888. m.clearedemployee = false
  32889. }
  32890. // Where appends a list predicates to the TutorialMutation builder.
  32891. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  32892. m.predicates = append(m.predicates, ps...)
  32893. }
  32894. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  32895. // users can use type-assertion to append predicates that do not depend on any generated package.
  32896. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  32897. p := make([]predicate.Tutorial, len(ps))
  32898. for i := range ps {
  32899. p[i] = ps[i]
  32900. }
  32901. m.Where(p...)
  32902. }
  32903. // Op returns the operation name.
  32904. func (m *TutorialMutation) Op() Op {
  32905. return m.op
  32906. }
  32907. // SetOp allows setting the mutation operation.
  32908. func (m *TutorialMutation) SetOp(op Op) {
  32909. m.op = op
  32910. }
  32911. // Type returns the node type of this mutation (Tutorial).
  32912. func (m *TutorialMutation) Type() string {
  32913. return m.typ
  32914. }
  32915. // Fields returns all fields that were changed during this mutation. Note that in
  32916. // order to get all numeric fields that were incremented/decremented, call
  32917. // AddedFields().
  32918. func (m *TutorialMutation) Fields() []string {
  32919. fields := make([]string, 0, 8)
  32920. if m.created_at != nil {
  32921. fields = append(fields, tutorial.FieldCreatedAt)
  32922. }
  32923. if m.updated_at != nil {
  32924. fields = append(fields, tutorial.FieldUpdatedAt)
  32925. }
  32926. if m.deleted_at != nil {
  32927. fields = append(fields, tutorial.FieldDeletedAt)
  32928. }
  32929. if m.employee != nil {
  32930. fields = append(fields, tutorial.FieldEmployeeID)
  32931. }
  32932. if m.index != nil {
  32933. fields = append(fields, tutorial.FieldIndex)
  32934. }
  32935. if m.title != nil {
  32936. fields = append(fields, tutorial.FieldTitle)
  32937. }
  32938. if m.content != nil {
  32939. fields = append(fields, tutorial.FieldContent)
  32940. }
  32941. if m.organization_id != nil {
  32942. fields = append(fields, tutorial.FieldOrganizationID)
  32943. }
  32944. return fields
  32945. }
  32946. // Field returns the value of a field with the given name. The second boolean
  32947. // return value indicates that this field was not set, or was not defined in the
  32948. // schema.
  32949. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  32950. switch name {
  32951. case tutorial.FieldCreatedAt:
  32952. return m.CreatedAt()
  32953. case tutorial.FieldUpdatedAt:
  32954. return m.UpdatedAt()
  32955. case tutorial.FieldDeletedAt:
  32956. return m.DeletedAt()
  32957. case tutorial.FieldEmployeeID:
  32958. return m.EmployeeID()
  32959. case tutorial.FieldIndex:
  32960. return m.Index()
  32961. case tutorial.FieldTitle:
  32962. return m.Title()
  32963. case tutorial.FieldContent:
  32964. return m.Content()
  32965. case tutorial.FieldOrganizationID:
  32966. return m.OrganizationID()
  32967. }
  32968. return nil, false
  32969. }
  32970. // OldField returns the old value of the field from the database. An error is
  32971. // returned if the mutation operation is not UpdateOne, or the query to the
  32972. // database failed.
  32973. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  32974. switch name {
  32975. case tutorial.FieldCreatedAt:
  32976. return m.OldCreatedAt(ctx)
  32977. case tutorial.FieldUpdatedAt:
  32978. return m.OldUpdatedAt(ctx)
  32979. case tutorial.FieldDeletedAt:
  32980. return m.OldDeletedAt(ctx)
  32981. case tutorial.FieldEmployeeID:
  32982. return m.OldEmployeeID(ctx)
  32983. case tutorial.FieldIndex:
  32984. return m.OldIndex(ctx)
  32985. case tutorial.FieldTitle:
  32986. return m.OldTitle(ctx)
  32987. case tutorial.FieldContent:
  32988. return m.OldContent(ctx)
  32989. case tutorial.FieldOrganizationID:
  32990. return m.OldOrganizationID(ctx)
  32991. }
  32992. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  32993. }
  32994. // SetField sets the value of a field with the given name. It returns an error if
  32995. // the field is not defined in the schema, or if the type mismatched the field
  32996. // type.
  32997. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  32998. switch name {
  32999. case tutorial.FieldCreatedAt:
  33000. v, ok := value.(time.Time)
  33001. if !ok {
  33002. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33003. }
  33004. m.SetCreatedAt(v)
  33005. return nil
  33006. case tutorial.FieldUpdatedAt:
  33007. v, ok := value.(time.Time)
  33008. if !ok {
  33009. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33010. }
  33011. m.SetUpdatedAt(v)
  33012. return nil
  33013. case tutorial.FieldDeletedAt:
  33014. v, ok := value.(time.Time)
  33015. if !ok {
  33016. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33017. }
  33018. m.SetDeletedAt(v)
  33019. return nil
  33020. case tutorial.FieldEmployeeID:
  33021. v, ok := value.(uint64)
  33022. if !ok {
  33023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33024. }
  33025. m.SetEmployeeID(v)
  33026. return nil
  33027. case tutorial.FieldIndex:
  33028. v, ok := value.(int)
  33029. if !ok {
  33030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33031. }
  33032. m.SetIndex(v)
  33033. return nil
  33034. case tutorial.FieldTitle:
  33035. v, ok := value.(string)
  33036. if !ok {
  33037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33038. }
  33039. m.SetTitle(v)
  33040. return nil
  33041. case tutorial.FieldContent:
  33042. v, ok := value.(string)
  33043. if !ok {
  33044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33045. }
  33046. m.SetContent(v)
  33047. return nil
  33048. case tutorial.FieldOrganizationID:
  33049. v, ok := value.(uint64)
  33050. if !ok {
  33051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33052. }
  33053. m.SetOrganizationID(v)
  33054. return nil
  33055. }
  33056. return fmt.Errorf("unknown Tutorial field %s", name)
  33057. }
  33058. // AddedFields returns all numeric fields that were incremented/decremented during
  33059. // this mutation.
  33060. func (m *TutorialMutation) AddedFields() []string {
  33061. var fields []string
  33062. if m.addindex != nil {
  33063. fields = append(fields, tutorial.FieldIndex)
  33064. }
  33065. if m.addorganization_id != nil {
  33066. fields = append(fields, tutorial.FieldOrganizationID)
  33067. }
  33068. return fields
  33069. }
  33070. // AddedField returns the numeric value that was incremented/decremented on a field
  33071. // with the given name. The second boolean return value indicates that this field
  33072. // was not set, or was not defined in the schema.
  33073. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  33074. switch name {
  33075. case tutorial.FieldIndex:
  33076. return m.AddedIndex()
  33077. case tutorial.FieldOrganizationID:
  33078. return m.AddedOrganizationID()
  33079. }
  33080. return nil, false
  33081. }
  33082. // AddField adds the value to the field with the given name. It returns an error if
  33083. // the field is not defined in the schema, or if the type mismatched the field
  33084. // type.
  33085. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  33086. switch name {
  33087. case tutorial.FieldIndex:
  33088. v, ok := value.(int)
  33089. if !ok {
  33090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33091. }
  33092. m.AddIndex(v)
  33093. return nil
  33094. case tutorial.FieldOrganizationID:
  33095. v, ok := value.(int64)
  33096. if !ok {
  33097. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33098. }
  33099. m.AddOrganizationID(v)
  33100. return nil
  33101. }
  33102. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  33103. }
  33104. // ClearedFields returns all nullable fields that were cleared during this
  33105. // mutation.
  33106. func (m *TutorialMutation) ClearedFields() []string {
  33107. var fields []string
  33108. if m.FieldCleared(tutorial.FieldDeletedAt) {
  33109. fields = append(fields, tutorial.FieldDeletedAt)
  33110. }
  33111. return fields
  33112. }
  33113. // FieldCleared returns a boolean indicating if a field with the given name was
  33114. // cleared in this mutation.
  33115. func (m *TutorialMutation) FieldCleared(name string) bool {
  33116. _, ok := m.clearedFields[name]
  33117. return ok
  33118. }
  33119. // ClearField clears the value of the field with the given name. It returns an
  33120. // error if the field is not defined in the schema.
  33121. func (m *TutorialMutation) ClearField(name string) error {
  33122. switch name {
  33123. case tutorial.FieldDeletedAt:
  33124. m.ClearDeletedAt()
  33125. return nil
  33126. }
  33127. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  33128. }
  33129. // ResetField resets all changes in the mutation for the field with the given name.
  33130. // It returns an error if the field is not defined in the schema.
  33131. func (m *TutorialMutation) ResetField(name string) error {
  33132. switch name {
  33133. case tutorial.FieldCreatedAt:
  33134. m.ResetCreatedAt()
  33135. return nil
  33136. case tutorial.FieldUpdatedAt:
  33137. m.ResetUpdatedAt()
  33138. return nil
  33139. case tutorial.FieldDeletedAt:
  33140. m.ResetDeletedAt()
  33141. return nil
  33142. case tutorial.FieldEmployeeID:
  33143. m.ResetEmployeeID()
  33144. return nil
  33145. case tutorial.FieldIndex:
  33146. m.ResetIndex()
  33147. return nil
  33148. case tutorial.FieldTitle:
  33149. m.ResetTitle()
  33150. return nil
  33151. case tutorial.FieldContent:
  33152. m.ResetContent()
  33153. return nil
  33154. case tutorial.FieldOrganizationID:
  33155. m.ResetOrganizationID()
  33156. return nil
  33157. }
  33158. return fmt.Errorf("unknown Tutorial field %s", name)
  33159. }
  33160. // AddedEdges returns all edge names that were set/added in this mutation.
  33161. func (m *TutorialMutation) AddedEdges() []string {
  33162. edges := make([]string, 0, 1)
  33163. if m.employee != nil {
  33164. edges = append(edges, tutorial.EdgeEmployee)
  33165. }
  33166. return edges
  33167. }
  33168. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33169. // name in this mutation.
  33170. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  33171. switch name {
  33172. case tutorial.EdgeEmployee:
  33173. if id := m.employee; id != nil {
  33174. return []ent.Value{*id}
  33175. }
  33176. }
  33177. return nil
  33178. }
  33179. // RemovedEdges returns all edge names that were removed in this mutation.
  33180. func (m *TutorialMutation) RemovedEdges() []string {
  33181. edges := make([]string, 0, 1)
  33182. return edges
  33183. }
  33184. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33185. // the given name in this mutation.
  33186. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  33187. return nil
  33188. }
  33189. // ClearedEdges returns all edge names that were cleared in this mutation.
  33190. func (m *TutorialMutation) ClearedEdges() []string {
  33191. edges := make([]string, 0, 1)
  33192. if m.clearedemployee {
  33193. edges = append(edges, tutorial.EdgeEmployee)
  33194. }
  33195. return edges
  33196. }
  33197. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33198. // was cleared in this mutation.
  33199. func (m *TutorialMutation) EdgeCleared(name string) bool {
  33200. switch name {
  33201. case tutorial.EdgeEmployee:
  33202. return m.clearedemployee
  33203. }
  33204. return false
  33205. }
  33206. // ClearEdge clears the value of the edge with the given name. It returns an error
  33207. // if that edge is not defined in the schema.
  33208. func (m *TutorialMutation) ClearEdge(name string) error {
  33209. switch name {
  33210. case tutorial.EdgeEmployee:
  33211. m.ClearEmployee()
  33212. return nil
  33213. }
  33214. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  33215. }
  33216. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33217. // It returns an error if the edge is not defined in the schema.
  33218. func (m *TutorialMutation) ResetEdge(name string) error {
  33219. switch name {
  33220. case tutorial.EdgeEmployee:
  33221. m.ResetEmployee()
  33222. return nil
  33223. }
  33224. return fmt.Errorf("unknown Tutorial edge %s", name)
  33225. }
  33226. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  33227. type UsageDetailMutation struct {
  33228. config
  33229. op Op
  33230. typ string
  33231. id *uint64
  33232. created_at *time.Time
  33233. updated_at *time.Time
  33234. status *uint8
  33235. addstatus *int8
  33236. _type *int
  33237. add_type *int
  33238. bot_id *string
  33239. receiver_id *string
  33240. app *int
  33241. addapp *int
  33242. session_id *uint64
  33243. addsession_id *int64
  33244. request *string
  33245. response *string
  33246. original_data *custom_types.OriginalData
  33247. total_tokens *uint64
  33248. addtotal_tokens *int64
  33249. prompt_tokens *uint64
  33250. addprompt_tokens *int64
  33251. completion_tokens *uint64
  33252. addcompletion_tokens *int64
  33253. organization_id *uint64
  33254. addorganization_id *int64
  33255. model *string
  33256. credits *float64
  33257. addcredits *float64
  33258. clearedFields map[string]struct{}
  33259. done bool
  33260. oldValue func(context.Context) (*UsageDetail, error)
  33261. predicates []predicate.UsageDetail
  33262. }
  33263. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  33264. // usagedetailOption allows management of the mutation configuration using functional options.
  33265. type usagedetailOption func(*UsageDetailMutation)
  33266. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  33267. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  33268. m := &UsageDetailMutation{
  33269. config: c,
  33270. op: op,
  33271. typ: TypeUsageDetail,
  33272. clearedFields: make(map[string]struct{}),
  33273. }
  33274. for _, opt := range opts {
  33275. opt(m)
  33276. }
  33277. return m
  33278. }
  33279. // withUsageDetailID sets the ID field of the mutation.
  33280. func withUsageDetailID(id uint64) usagedetailOption {
  33281. return func(m *UsageDetailMutation) {
  33282. var (
  33283. err error
  33284. once sync.Once
  33285. value *UsageDetail
  33286. )
  33287. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  33288. once.Do(func() {
  33289. if m.done {
  33290. err = errors.New("querying old values post mutation is not allowed")
  33291. } else {
  33292. value, err = m.Client().UsageDetail.Get(ctx, id)
  33293. }
  33294. })
  33295. return value, err
  33296. }
  33297. m.id = &id
  33298. }
  33299. }
  33300. // withUsageDetail sets the old UsageDetail of the mutation.
  33301. func withUsageDetail(node *UsageDetail) usagedetailOption {
  33302. return func(m *UsageDetailMutation) {
  33303. m.oldValue = func(context.Context) (*UsageDetail, error) {
  33304. return node, nil
  33305. }
  33306. m.id = &node.ID
  33307. }
  33308. }
  33309. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33310. // executed in a transaction (ent.Tx), a transactional client is returned.
  33311. func (m UsageDetailMutation) Client() *Client {
  33312. client := &Client{config: m.config}
  33313. client.init()
  33314. return client
  33315. }
  33316. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33317. // it returns an error otherwise.
  33318. func (m UsageDetailMutation) Tx() (*Tx, error) {
  33319. if _, ok := m.driver.(*txDriver); !ok {
  33320. return nil, errors.New("ent: mutation is not running in a transaction")
  33321. }
  33322. tx := &Tx{config: m.config}
  33323. tx.init()
  33324. return tx, nil
  33325. }
  33326. // SetID sets the value of the id field. Note that this
  33327. // operation is only accepted on creation of UsageDetail entities.
  33328. func (m *UsageDetailMutation) SetID(id uint64) {
  33329. m.id = &id
  33330. }
  33331. // ID returns the ID value in the mutation. Note that the ID is only available
  33332. // if it was provided to the builder or after it was returned from the database.
  33333. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  33334. if m.id == nil {
  33335. return
  33336. }
  33337. return *m.id, true
  33338. }
  33339. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33340. // That means, if the mutation is applied within a transaction with an isolation level such
  33341. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33342. // or updated by the mutation.
  33343. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  33344. switch {
  33345. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33346. id, exists := m.ID()
  33347. if exists {
  33348. return []uint64{id}, nil
  33349. }
  33350. fallthrough
  33351. case m.op.Is(OpUpdate | OpDelete):
  33352. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  33353. default:
  33354. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  33355. }
  33356. }
  33357. // SetCreatedAt sets the "created_at" field.
  33358. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  33359. m.created_at = &t
  33360. }
  33361. // CreatedAt returns the value of the "created_at" field in the mutation.
  33362. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  33363. v := m.created_at
  33364. if v == nil {
  33365. return
  33366. }
  33367. return *v, true
  33368. }
  33369. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  33370. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33371. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33372. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  33373. if !m.op.Is(OpUpdateOne) {
  33374. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  33375. }
  33376. if m.id == nil || m.oldValue == nil {
  33377. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  33378. }
  33379. oldValue, err := m.oldValue(ctx)
  33380. if err != nil {
  33381. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  33382. }
  33383. return oldValue.CreatedAt, nil
  33384. }
  33385. // ResetCreatedAt resets all changes to the "created_at" field.
  33386. func (m *UsageDetailMutation) ResetCreatedAt() {
  33387. m.created_at = nil
  33388. }
  33389. // SetUpdatedAt sets the "updated_at" field.
  33390. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  33391. m.updated_at = &t
  33392. }
  33393. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  33394. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  33395. v := m.updated_at
  33396. if v == nil {
  33397. return
  33398. }
  33399. return *v, true
  33400. }
  33401. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  33402. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33403. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33404. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  33405. if !m.op.Is(OpUpdateOne) {
  33406. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  33407. }
  33408. if m.id == nil || m.oldValue == nil {
  33409. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  33410. }
  33411. oldValue, err := m.oldValue(ctx)
  33412. if err != nil {
  33413. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  33414. }
  33415. return oldValue.UpdatedAt, nil
  33416. }
  33417. // ResetUpdatedAt resets all changes to the "updated_at" field.
  33418. func (m *UsageDetailMutation) ResetUpdatedAt() {
  33419. m.updated_at = nil
  33420. }
  33421. // SetStatus sets the "status" field.
  33422. func (m *UsageDetailMutation) SetStatus(u uint8) {
  33423. m.status = &u
  33424. m.addstatus = nil
  33425. }
  33426. // Status returns the value of the "status" field in the mutation.
  33427. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  33428. v := m.status
  33429. if v == nil {
  33430. return
  33431. }
  33432. return *v, true
  33433. }
  33434. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  33435. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33436. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33437. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  33438. if !m.op.Is(OpUpdateOne) {
  33439. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  33440. }
  33441. if m.id == nil || m.oldValue == nil {
  33442. return v, errors.New("OldStatus requires an ID field in the mutation")
  33443. }
  33444. oldValue, err := m.oldValue(ctx)
  33445. if err != nil {
  33446. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  33447. }
  33448. return oldValue.Status, nil
  33449. }
  33450. // AddStatus adds u to the "status" field.
  33451. func (m *UsageDetailMutation) AddStatus(u int8) {
  33452. if m.addstatus != nil {
  33453. *m.addstatus += u
  33454. } else {
  33455. m.addstatus = &u
  33456. }
  33457. }
  33458. // AddedStatus returns the value that was added to the "status" field in this mutation.
  33459. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  33460. v := m.addstatus
  33461. if v == nil {
  33462. return
  33463. }
  33464. return *v, true
  33465. }
  33466. // ClearStatus clears the value of the "status" field.
  33467. func (m *UsageDetailMutation) ClearStatus() {
  33468. m.status = nil
  33469. m.addstatus = nil
  33470. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  33471. }
  33472. // StatusCleared returns if the "status" field was cleared in this mutation.
  33473. func (m *UsageDetailMutation) StatusCleared() bool {
  33474. _, ok := m.clearedFields[usagedetail.FieldStatus]
  33475. return ok
  33476. }
  33477. // ResetStatus resets all changes to the "status" field.
  33478. func (m *UsageDetailMutation) ResetStatus() {
  33479. m.status = nil
  33480. m.addstatus = nil
  33481. delete(m.clearedFields, usagedetail.FieldStatus)
  33482. }
  33483. // SetType sets the "type" field.
  33484. func (m *UsageDetailMutation) SetType(i int) {
  33485. m._type = &i
  33486. m.add_type = nil
  33487. }
  33488. // GetType returns the value of the "type" field in the mutation.
  33489. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  33490. v := m._type
  33491. if v == nil {
  33492. return
  33493. }
  33494. return *v, true
  33495. }
  33496. // OldType returns the old "type" field's value of the UsageDetail entity.
  33497. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33498. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33499. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  33500. if !m.op.Is(OpUpdateOne) {
  33501. return v, errors.New("OldType is only allowed on UpdateOne operations")
  33502. }
  33503. if m.id == nil || m.oldValue == nil {
  33504. return v, errors.New("OldType requires an ID field in the mutation")
  33505. }
  33506. oldValue, err := m.oldValue(ctx)
  33507. if err != nil {
  33508. return v, fmt.Errorf("querying old value for OldType: %w", err)
  33509. }
  33510. return oldValue.Type, nil
  33511. }
  33512. // AddType adds i to the "type" field.
  33513. func (m *UsageDetailMutation) AddType(i int) {
  33514. if m.add_type != nil {
  33515. *m.add_type += i
  33516. } else {
  33517. m.add_type = &i
  33518. }
  33519. }
  33520. // AddedType returns the value that was added to the "type" field in this mutation.
  33521. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  33522. v := m.add_type
  33523. if v == nil {
  33524. return
  33525. }
  33526. return *v, true
  33527. }
  33528. // ClearType clears the value of the "type" field.
  33529. func (m *UsageDetailMutation) ClearType() {
  33530. m._type = nil
  33531. m.add_type = nil
  33532. m.clearedFields[usagedetail.FieldType] = struct{}{}
  33533. }
  33534. // TypeCleared returns if the "type" field was cleared in this mutation.
  33535. func (m *UsageDetailMutation) TypeCleared() bool {
  33536. _, ok := m.clearedFields[usagedetail.FieldType]
  33537. return ok
  33538. }
  33539. // ResetType resets all changes to the "type" field.
  33540. func (m *UsageDetailMutation) ResetType() {
  33541. m._type = nil
  33542. m.add_type = nil
  33543. delete(m.clearedFields, usagedetail.FieldType)
  33544. }
  33545. // SetBotID sets the "bot_id" field.
  33546. func (m *UsageDetailMutation) SetBotID(s string) {
  33547. m.bot_id = &s
  33548. }
  33549. // BotID returns the value of the "bot_id" field in the mutation.
  33550. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  33551. v := m.bot_id
  33552. if v == nil {
  33553. return
  33554. }
  33555. return *v, true
  33556. }
  33557. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  33558. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33559. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33560. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  33561. if !m.op.Is(OpUpdateOne) {
  33562. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  33563. }
  33564. if m.id == nil || m.oldValue == nil {
  33565. return v, errors.New("OldBotID requires an ID field in the mutation")
  33566. }
  33567. oldValue, err := m.oldValue(ctx)
  33568. if err != nil {
  33569. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  33570. }
  33571. return oldValue.BotID, nil
  33572. }
  33573. // ResetBotID resets all changes to the "bot_id" field.
  33574. func (m *UsageDetailMutation) ResetBotID() {
  33575. m.bot_id = nil
  33576. }
  33577. // SetReceiverID sets the "receiver_id" field.
  33578. func (m *UsageDetailMutation) SetReceiverID(s string) {
  33579. m.receiver_id = &s
  33580. }
  33581. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  33582. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  33583. v := m.receiver_id
  33584. if v == nil {
  33585. return
  33586. }
  33587. return *v, true
  33588. }
  33589. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  33590. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33591. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33592. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  33593. if !m.op.Is(OpUpdateOne) {
  33594. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  33595. }
  33596. if m.id == nil || m.oldValue == nil {
  33597. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  33598. }
  33599. oldValue, err := m.oldValue(ctx)
  33600. if err != nil {
  33601. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  33602. }
  33603. return oldValue.ReceiverID, nil
  33604. }
  33605. // ResetReceiverID resets all changes to the "receiver_id" field.
  33606. func (m *UsageDetailMutation) ResetReceiverID() {
  33607. m.receiver_id = nil
  33608. }
  33609. // SetApp sets the "app" field.
  33610. func (m *UsageDetailMutation) SetApp(i int) {
  33611. m.app = &i
  33612. m.addapp = nil
  33613. }
  33614. // App returns the value of the "app" field in the mutation.
  33615. func (m *UsageDetailMutation) App() (r int, exists bool) {
  33616. v := m.app
  33617. if v == nil {
  33618. return
  33619. }
  33620. return *v, true
  33621. }
  33622. // OldApp returns the old "app" field's value of the UsageDetail entity.
  33623. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33624. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33625. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  33626. if !m.op.Is(OpUpdateOne) {
  33627. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  33628. }
  33629. if m.id == nil || m.oldValue == nil {
  33630. return v, errors.New("OldApp requires an ID field in the mutation")
  33631. }
  33632. oldValue, err := m.oldValue(ctx)
  33633. if err != nil {
  33634. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  33635. }
  33636. return oldValue.App, nil
  33637. }
  33638. // AddApp adds i to the "app" field.
  33639. func (m *UsageDetailMutation) AddApp(i int) {
  33640. if m.addapp != nil {
  33641. *m.addapp += i
  33642. } else {
  33643. m.addapp = &i
  33644. }
  33645. }
  33646. // AddedApp returns the value that was added to the "app" field in this mutation.
  33647. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  33648. v := m.addapp
  33649. if v == nil {
  33650. return
  33651. }
  33652. return *v, true
  33653. }
  33654. // ClearApp clears the value of the "app" field.
  33655. func (m *UsageDetailMutation) ClearApp() {
  33656. m.app = nil
  33657. m.addapp = nil
  33658. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  33659. }
  33660. // AppCleared returns if the "app" field was cleared in this mutation.
  33661. func (m *UsageDetailMutation) AppCleared() bool {
  33662. _, ok := m.clearedFields[usagedetail.FieldApp]
  33663. return ok
  33664. }
  33665. // ResetApp resets all changes to the "app" field.
  33666. func (m *UsageDetailMutation) ResetApp() {
  33667. m.app = nil
  33668. m.addapp = nil
  33669. delete(m.clearedFields, usagedetail.FieldApp)
  33670. }
  33671. // SetSessionID sets the "session_id" field.
  33672. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  33673. m.session_id = &u
  33674. m.addsession_id = nil
  33675. }
  33676. // SessionID returns the value of the "session_id" field in the mutation.
  33677. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  33678. v := m.session_id
  33679. if v == nil {
  33680. return
  33681. }
  33682. return *v, true
  33683. }
  33684. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  33685. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33686. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33687. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  33688. if !m.op.Is(OpUpdateOne) {
  33689. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  33690. }
  33691. if m.id == nil || m.oldValue == nil {
  33692. return v, errors.New("OldSessionID requires an ID field in the mutation")
  33693. }
  33694. oldValue, err := m.oldValue(ctx)
  33695. if err != nil {
  33696. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  33697. }
  33698. return oldValue.SessionID, nil
  33699. }
  33700. // AddSessionID adds u to the "session_id" field.
  33701. func (m *UsageDetailMutation) AddSessionID(u int64) {
  33702. if m.addsession_id != nil {
  33703. *m.addsession_id += u
  33704. } else {
  33705. m.addsession_id = &u
  33706. }
  33707. }
  33708. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  33709. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  33710. v := m.addsession_id
  33711. if v == nil {
  33712. return
  33713. }
  33714. return *v, true
  33715. }
  33716. // ClearSessionID clears the value of the "session_id" field.
  33717. func (m *UsageDetailMutation) ClearSessionID() {
  33718. m.session_id = nil
  33719. m.addsession_id = nil
  33720. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  33721. }
  33722. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  33723. func (m *UsageDetailMutation) SessionIDCleared() bool {
  33724. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  33725. return ok
  33726. }
  33727. // ResetSessionID resets all changes to the "session_id" field.
  33728. func (m *UsageDetailMutation) ResetSessionID() {
  33729. m.session_id = nil
  33730. m.addsession_id = nil
  33731. delete(m.clearedFields, usagedetail.FieldSessionID)
  33732. }
  33733. // SetRequest sets the "request" field.
  33734. func (m *UsageDetailMutation) SetRequest(s string) {
  33735. m.request = &s
  33736. }
  33737. // Request returns the value of the "request" field in the mutation.
  33738. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  33739. v := m.request
  33740. if v == nil {
  33741. return
  33742. }
  33743. return *v, true
  33744. }
  33745. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  33746. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33747. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33748. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  33749. if !m.op.Is(OpUpdateOne) {
  33750. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  33751. }
  33752. if m.id == nil || m.oldValue == nil {
  33753. return v, errors.New("OldRequest requires an ID field in the mutation")
  33754. }
  33755. oldValue, err := m.oldValue(ctx)
  33756. if err != nil {
  33757. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  33758. }
  33759. return oldValue.Request, nil
  33760. }
  33761. // ResetRequest resets all changes to the "request" field.
  33762. func (m *UsageDetailMutation) ResetRequest() {
  33763. m.request = nil
  33764. }
  33765. // SetResponse sets the "response" field.
  33766. func (m *UsageDetailMutation) SetResponse(s string) {
  33767. m.response = &s
  33768. }
  33769. // Response returns the value of the "response" field in the mutation.
  33770. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  33771. v := m.response
  33772. if v == nil {
  33773. return
  33774. }
  33775. return *v, true
  33776. }
  33777. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  33778. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33780. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  33781. if !m.op.Is(OpUpdateOne) {
  33782. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  33783. }
  33784. if m.id == nil || m.oldValue == nil {
  33785. return v, errors.New("OldResponse requires an ID field in the mutation")
  33786. }
  33787. oldValue, err := m.oldValue(ctx)
  33788. if err != nil {
  33789. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  33790. }
  33791. return oldValue.Response, nil
  33792. }
  33793. // ResetResponse resets all changes to the "response" field.
  33794. func (m *UsageDetailMutation) ResetResponse() {
  33795. m.response = nil
  33796. }
  33797. // SetOriginalData sets the "original_data" field.
  33798. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  33799. m.original_data = &ctd
  33800. }
  33801. // OriginalData returns the value of the "original_data" field in the mutation.
  33802. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  33803. v := m.original_data
  33804. if v == nil {
  33805. return
  33806. }
  33807. return *v, true
  33808. }
  33809. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  33810. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33811. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33812. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  33813. if !m.op.Is(OpUpdateOne) {
  33814. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  33815. }
  33816. if m.id == nil || m.oldValue == nil {
  33817. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  33818. }
  33819. oldValue, err := m.oldValue(ctx)
  33820. if err != nil {
  33821. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  33822. }
  33823. return oldValue.OriginalData, nil
  33824. }
  33825. // ResetOriginalData resets all changes to the "original_data" field.
  33826. func (m *UsageDetailMutation) ResetOriginalData() {
  33827. m.original_data = nil
  33828. }
  33829. // SetTotalTokens sets the "total_tokens" field.
  33830. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  33831. m.total_tokens = &u
  33832. m.addtotal_tokens = nil
  33833. }
  33834. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  33835. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  33836. v := m.total_tokens
  33837. if v == nil {
  33838. return
  33839. }
  33840. return *v, true
  33841. }
  33842. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  33843. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33845. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  33846. if !m.op.Is(OpUpdateOne) {
  33847. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  33848. }
  33849. if m.id == nil || m.oldValue == nil {
  33850. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  33851. }
  33852. oldValue, err := m.oldValue(ctx)
  33853. if err != nil {
  33854. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  33855. }
  33856. return oldValue.TotalTokens, nil
  33857. }
  33858. // AddTotalTokens adds u to the "total_tokens" field.
  33859. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  33860. if m.addtotal_tokens != nil {
  33861. *m.addtotal_tokens += u
  33862. } else {
  33863. m.addtotal_tokens = &u
  33864. }
  33865. }
  33866. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  33867. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  33868. v := m.addtotal_tokens
  33869. if v == nil {
  33870. return
  33871. }
  33872. return *v, true
  33873. }
  33874. // ClearTotalTokens clears the value of the "total_tokens" field.
  33875. func (m *UsageDetailMutation) ClearTotalTokens() {
  33876. m.total_tokens = nil
  33877. m.addtotal_tokens = nil
  33878. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  33879. }
  33880. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  33881. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  33882. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  33883. return ok
  33884. }
  33885. // ResetTotalTokens resets all changes to the "total_tokens" field.
  33886. func (m *UsageDetailMutation) ResetTotalTokens() {
  33887. m.total_tokens = nil
  33888. m.addtotal_tokens = nil
  33889. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  33890. }
  33891. // SetPromptTokens sets the "prompt_tokens" field.
  33892. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  33893. m.prompt_tokens = &u
  33894. m.addprompt_tokens = nil
  33895. }
  33896. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  33897. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  33898. v := m.prompt_tokens
  33899. if v == nil {
  33900. return
  33901. }
  33902. return *v, true
  33903. }
  33904. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  33905. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33907. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  33908. if !m.op.Is(OpUpdateOne) {
  33909. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  33910. }
  33911. if m.id == nil || m.oldValue == nil {
  33912. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  33913. }
  33914. oldValue, err := m.oldValue(ctx)
  33915. if err != nil {
  33916. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  33917. }
  33918. return oldValue.PromptTokens, nil
  33919. }
  33920. // AddPromptTokens adds u to the "prompt_tokens" field.
  33921. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  33922. if m.addprompt_tokens != nil {
  33923. *m.addprompt_tokens += u
  33924. } else {
  33925. m.addprompt_tokens = &u
  33926. }
  33927. }
  33928. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  33929. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  33930. v := m.addprompt_tokens
  33931. if v == nil {
  33932. return
  33933. }
  33934. return *v, true
  33935. }
  33936. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  33937. func (m *UsageDetailMutation) ClearPromptTokens() {
  33938. m.prompt_tokens = nil
  33939. m.addprompt_tokens = nil
  33940. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  33941. }
  33942. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  33943. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  33944. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  33945. return ok
  33946. }
  33947. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  33948. func (m *UsageDetailMutation) ResetPromptTokens() {
  33949. m.prompt_tokens = nil
  33950. m.addprompt_tokens = nil
  33951. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  33952. }
  33953. // SetCompletionTokens sets the "completion_tokens" field.
  33954. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  33955. m.completion_tokens = &u
  33956. m.addcompletion_tokens = nil
  33957. }
  33958. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  33959. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  33960. v := m.completion_tokens
  33961. if v == nil {
  33962. return
  33963. }
  33964. return *v, true
  33965. }
  33966. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  33967. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33968. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33969. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  33970. if !m.op.Is(OpUpdateOne) {
  33971. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  33972. }
  33973. if m.id == nil || m.oldValue == nil {
  33974. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  33975. }
  33976. oldValue, err := m.oldValue(ctx)
  33977. if err != nil {
  33978. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  33979. }
  33980. return oldValue.CompletionTokens, nil
  33981. }
  33982. // AddCompletionTokens adds u to the "completion_tokens" field.
  33983. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  33984. if m.addcompletion_tokens != nil {
  33985. *m.addcompletion_tokens += u
  33986. } else {
  33987. m.addcompletion_tokens = &u
  33988. }
  33989. }
  33990. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  33991. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  33992. v := m.addcompletion_tokens
  33993. if v == nil {
  33994. return
  33995. }
  33996. return *v, true
  33997. }
  33998. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  33999. func (m *UsageDetailMutation) ClearCompletionTokens() {
  34000. m.completion_tokens = nil
  34001. m.addcompletion_tokens = nil
  34002. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  34003. }
  34004. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  34005. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  34006. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  34007. return ok
  34008. }
  34009. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  34010. func (m *UsageDetailMutation) ResetCompletionTokens() {
  34011. m.completion_tokens = nil
  34012. m.addcompletion_tokens = nil
  34013. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  34014. }
  34015. // SetOrganizationID sets the "organization_id" field.
  34016. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  34017. m.organization_id = &u
  34018. m.addorganization_id = nil
  34019. }
  34020. // OrganizationID returns the value of the "organization_id" field in the mutation.
  34021. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  34022. v := m.organization_id
  34023. if v == nil {
  34024. return
  34025. }
  34026. return *v, true
  34027. }
  34028. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  34029. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34030. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34031. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  34032. if !m.op.Is(OpUpdateOne) {
  34033. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  34034. }
  34035. if m.id == nil || m.oldValue == nil {
  34036. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  34037. }
  34038. oldValue, err := m.oldValue(ctx)
  34039. if err != nil {
  34040. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  34041. }
  34042. return oldValue.OrganizationID, nil
  34043. }
  34044. // AddOrganizationID adds u to the "organization_id" field.
  34045. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  34046. if m.addorganization_id != nil {
  34047. *m.addorganization_id += u
  34048. } else {
  34049. m.addorganization_id = &u
  34050. }
  34051. }
  34052. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  34053. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  34054. v := m.addorganization_id
  34055. if v == nil {
  34056. return
  34057. }
  34058. return *v, true
  34059. }
  34060. // ClearOrganizationID clears the value of the "organization_id" field.
  34061. func (m *UsageDetailMutation) ClearOrganizationID() {
  34062. m.organization_id = nil
  34063. m.addorganization_id = nil
  34064. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  34065. }
  34066. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  34067. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  34068. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  34069. return ok
  34070. }
  34071. // ResetOrganizationID resets all changes to the "organization_id" field.
  34072. func (m *UsageDetailMutation) ResetOrganizationID() {
  34073. m.organization_id = nil
  34074. m.addorganization_id = nil
  34075. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  34076. }
  34077. // SetModel sets the "model" field.
  34078. func (m *UsageDetailMutation) SetModel(s string) {
  34079. m.model = &s
  34080. }
  34081. // Model returns the value of the "model" field in the mutation.
  34082. func (m *UsageDetailMutation) Model() (r string, exists bool) {
  34083. v := m.model
  34084. if v == nil {
  34085. return
  34086. }
  34087. return *v, true
  34088. }
  34089. // OldModel returns the old "model" field's value of the UsageDetail entity.
  34090. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34091. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34092. func (m *UsageDetailMutation) OldModel(ctx context.Context) (v string, err error) {
  34093. if !m.op.Is(OpUpdateOne) {
  34094. return v, errors.New("OldModel is only allowed on UpdateOne operations")
  34095. }
  34096. if m.id == nil || m.oldValue == nil {
  34097. return v, errors.New("OldModel requires an ID field in the mutation")
  34098. }
  34099. oldValue, err := m.oldValue(ctx)
  34100. if err != nil {
  34101. return v, fmt.Errorf("querying old value for OldModel: %w", err)
  34102. }
  34103. return oldValue.Model, nil
  34104. }
  34105. // ClearModel clears the value of the "model" field.
  34106. func (m *UsageDetailMutation) ClearModel() {
  34107. m.model = nil
  34108. m.clearedFields[usagedetail.FieldModel] = struct{}{}
  34109. }
  34110. // ModelCleared returns if the "model" field was cleared in this mutation.
  34111. func (m *UsageDetailMutation) ModelCleared() bool {
  34112. _, ok := m.clearedFields[usagedetail.FieldModel]
  34113. return ok
  34114. }
  34115. // ResetModel resets all changes to the "model" field.
  34116. func (m *UsageDetailMutation) ResetModel() {
  34117. m.model = nil
  34118. delete(m.clearedFields, usagedetail.FieldModel)
  34119. }
  34120. // SetCredits sets the "credits" field.
  34121. func (m *UsageDetailMutation) SetCredits(f float64) {
  34122. m.credits = &f
  34123. m.addcredits = nil
  34124. }
  34125. // Credits returns the value of the "credits" field in the mutation.
  34126. func (m *UsageDetailMutation) Credits() (r float64, exists bool) {
  34127. v := m.credits
  34128. if v == nil {
  34129. return
  34130. }
  34131. return *v, true
  34132. }
  34133. // OldCredits returns the old "credits" field's value of the UsageDetail entity.
  34134. // If the UsageDetail 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 *UsageDetailMutation) OldCredits(ctx context.Context) (v float64, err error) {
  34137. if !m.op.Is(OpUpdateOne) {
  34138. return v, errors.New("OldCredits is only allowed on UpdateOne operations")
  34139. }
  34140. if m.id == nil || m.oldValue == nil {
  34141. return v, errors.New("OldCredits 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 OldCredits: %w", err)
  34146. }
  34147. return oldValue.Credits, nil
  34148. }
  34149. // AddCredits adds f to the "credits" field.
  34150. func (m *UsageDetailMutation) AddCredits(f float64) {
  34151. if m.addcredits != nil {
  34152. *m.addcredits += f
  34153. } else {
  34154. m.addcredits = &f
  34155. }
  34156. }
  34157. // AddedCredits returns the value that was added to the "credits" field in this mutation.
  34158. func (m *UsageDetailMutation) AddedCredits() (r float64, exists bool) {
  34159. v := m.addcredits
  34160. if v == nil {
  34161. return
  34162. }
  34163. return *v, true
  34164. }
  34165. // ClearCredits clears the value of the "credits" field.
  34166. func (m *UsageDetailMutation) ClearCredits() {
  34167. m.credits = nil
  34168. m.addcredits = nil
  34169. m.clearedFields[usagedetail.FieldCredits] = struct{}{}
  34170. }
  34171. // CreditsCleared returns if the "credits" field was cleared in this mutation.
  34172. func (m *UsageDetailMutation) CreditsCleared() bool {
  34173. _, ok := m.clearedFields[usagedetail.FieldCredits]
  34174. return ok
  34175. }
  34176. // ResetCredits resets all changes to the "credits" field.
  34177. func (m *UsageDetailMutation) ResetCredits() {
  34178. m.credits = nil
  34179. m.addcredits = nil
  34180. delete(m.clearedFields, usagedetail.FieldCredits)
  34181. }
  34182. // Where appends a list predicates to the UsageDetailMutation builder.
  34183. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  34184. m.predicates = append(m.predicates, ps...)
  34185. }
  34186. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  34187. // users can use type-assertion to append predicates that do not depend on any generated package.
  34188. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  34189. p := make([]predicate.UsageDetail, len(ps))
  34190. for i := range ps {
  34191. p[i] = ps[i]
  34192. }
  34193. m.Where(p...)
  34194. }
  34195. // Op returns the operation name.
  34196. func (m *UsageDetailMutation) Op() Op {
  34197. return m.op
  34198. }
  34199. // SetOp allows setting the mutation operation.
  34200. func (m *UsageDetailMutation) SetOp(op Op) {
  34201. m.op = op
  34202. }
  34203. // Type returns the node type of this mutation (UsageDetail).
  34204. func (m *UsageDetailMutation) Type() string {
  34205. return m.typ
  34206. }
  34207. // Fields returns all fields that were changed during this mutation. Note that in
  34208. // order to get all numeric fields that were incremented/decremented, call
  34209. // AddedFields().
  34210. func (m *UsageDetailMutation) Fields() []string {
  34211. fields := make([]string, 0, 17)
  34212. if m.created_at != nil {
  34213. fields = append(fields, usagedetail.FieldCreatedAt)
  34214. }
  34215. if m.updated_at != nil {
  34216. fields = append(fields, usagedetail.FieldUpdatedAt)
  34217. }
  34218. if m.status != nil {
  34219. fields = append(fields, usagedetail.FieldStatus)
  34220. }
  34221. if m._type != nil {
  34222. fields = append(fields, usagedetail.FieldType)
  34223. }
  34224. if m.bot_id != nil {
  34225. fields = append(fields, usagedetail.FieldBotID)
  34226. }
  34227. if m.receiver_id != nil {
  34228. fields = append(fields, usagedetail.FieldReceiverID)
  34229. }
  34230. if m.app != nil {
  34231. fields = append(fields, usagedetail.FieldApp)
  34232. }
  34233. if m.session_id != nil {
  34234. fields = append(fields, usagedetail.FieldSessionID)
  34235. }
  34236. if m.request != nil {
  34237. fields = append(fields, usagedetail.FieldRequest)
  34238. }
  34239. if m.response != nil {
  34240. fields = append(fields, usagedetail.FieldResponse)
  34241. }
  34242. if m.original_data != nil {
  34243. fields = append(fields, usagedetail.FieldOriginalData)
  34244. }
  34245. if m.total_tokens != nil {
  34246. fields = append(fields, usagedetail.FieldTotalTokens)
  34247. }
  34248. if m.prompt_tokens != nil {
  34249. fields = append(fields, usagedetail.FieldPromptTokens)
  34250. }
  34251. if m.completion_tokens != nil {
  34252. fields = append(fields, usagedetail.FieldCompletionTokens)
  34253. }
  34254. if m.organization_id != nil {
  34255. fields = append(fields, usagedetail.FieldOrganizationID)
  34256. }
  34257. if m.model != nil {
  34258. fields = append(fields, usagedetail.FieldModel)
  34259. }
  34260. if m.credits != nil {
  34261. fields = append(fields, usagedetail.FieldCredits)
  34262. }
  34263. return fields
  34264. }
  34265. // Field returns the value of a field with the given name. The second boolean
  34266. // return value indicates that this field was not set, or was not defined in the
  34267. // schema.
  34268. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  34269. switch name {
  34270. case usagedetail.FieldCreatedAt:
  34271. return m.CreatedAt()
  34272. case usagedetail.FieldUpdatedAt:
  34273. return m.UpdatedAt()
  34274. case usagedetail.FieldStatus:
  34275. return m.Status()
  34276. case usagedetail.FieldType:
  34277. return m.GetType()
  34278. case usagedetail.FieldBotID:
  34279. return m.BotID()
  34280. case usagedetail.FieldReceiverID:
  34281. return m.ReceiverID()
  34282. case usagedetail.FieldApp:
  34283. return m.App()
  34284. case usagedetail.FieldSessionID:
  34285. return m.SessionID()
  34286. case usagedetail.FieldRequest:
  34287. return m.Request()
  34288. case usagedetail.FieldResponse:
  34289. return m.Response()
  34290. case usagedetail.FieldOriginalData:
  34291. return m.OriginalData()
  34292. case usagedetail.FieldTotalTokens:
  34293. return m.TotalTokens()
  34294. case usagedetail.FieldPromptTokens:
  34295. return m.PromptTokens()
  34296. case usagedetail.FieldCompletionTokens:
  34297. return m.CompletionTokens()
  34298. case usagedetail.FieldOrganizationID:
  34299. return m.OrganizationID()
  34300. case usagedetail.FieldModel:
  34301. return m.Model()
  34302. case usagedetail.FieldCredits:
  34303. return m.Credits()
  34304. }
  34305. return nil, false
  34306. }
  34307. // OldField returns the old value of the field from the database. An error is
  34308. // returned if the mutation operation is not UpdateOne, or the query to the
  34309. // database failed.
  34310. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34311. switch name {
  34312. case usagedetail.FieldCreatedAt:
  34313. return m.OldCreatedAt(ctx)
  34314. case usagedetail.FieldUpdatedAt:
  34315. return m.OldUpdatedAt(ctx)
  34316. case usagedetail.FieldStatus:
  34317. return m.OldStatus(ctx)
  34318. case usagedetail.FieldType:
  34319. return m.OldType(ctx)
  34320. case usagedetail.FieldBotID:
  34321. return m.OldBotID(ctx)
  34322. case usagedetail.FieldReceiverID:
  34323. return m.OldReceiverID(ctx)
  34324. case usagedetail.FieldApp:
  34325. return m.OldApp(ctx)
  34326. case usagedetail.FieldSessionID:
  34327. return m.OldSessionID(ctx)
  34328. case usagedetail.FieldRequest:
  34329. return m.OldRequest(ctx)
  34330. case usagedetail.FieldResponse:
  34331. return m.OldResponse(ctx)
  34332. case usagedetail.FieldOriginalData:
  34333. return m.OldOriginalData(ctx)
  34334. case usagedetail.FieldTotalTokens:
  34335. return m.OldTotalTokens(ctx)
  34336. case usagedetail.FieldPromptTokens:
  34337. return m.OldPromptTokens(ctx)
  34338. case usagedetail.FieldCompletionTokens:
  34339. return m.OldCompletionTokens(ctx)
  34340. case usagedetail.FieldOrganizationID:
  34341. return m.OldOrganizationID(ctx)
  34342. case usagedetail.FieldModel:
  34343. return m.OldModel(ctx)
  34344. case usagedetail.FieldCredits:
  34345. return m.OldCredits(ctx)
  34346. }
  34347. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  34348. }
  34349. // SetField sets the value of a field with the given name. It returns an error if
  34350. // the field is not defined in the schema, or if the type mismatched the field
  34351. // type.
  34352. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  34353. switch name {
  34354. case usagedetail.FieldCreatedAt:
  34355. v, ok := value.(time.Time)
  34356. if !ok {
  34357. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34358. }
  34359. m.SetCreatedAt(v)
  34360. return nil
  34361. case usagedetail.FieldUpdatedAt:
  34362. v, ok := value.(time.Time)
  34363. if !ok {
  34364. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34365. }
  34366. m.SetUpdatedAt(v)
  34367. return nil
  34368. case usagedetail.FieldStatus:
  34369. v, ok := value.(uint8)
  34370. if !ok {
  34371. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34372. }
  34373. m.SetStatus(v)
  34374. return nil
  34375. case usagedetail.FieldType:
  34376. v, ok := value.(int)
  34377. if !ok {
  34378. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34379. }
  34380. m.SetType(v)
  34381. return nil
  34382. case usagedetail.FieldBotID:
  34383. v, ok := value.(string)
  34384. if !ok {
  34385. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34386. }
  34387. m.SetBotID(v)
  34388. return nil
  34389. case usagedetail.FieldReceiverID:
  34390. v, ok := value.(string)
  34391. if !ok {
  34392. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34393. }
  34394. m.SetReceiverID(v)
  34395. return nil
  34396. case usagedetail.FieldApp:
  34397. v, ok := value.(int)
  34398. if !ok {
  34399. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34400. }
  34401. m.SetApp(v)
  34402. return nil
  34403. case usagedetail.FieldSessionID:
  34404. v, ok := value.(uint64)
  34405. if !ok {
  34406. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34407. }
  34408. m.SetSessionID(v)
  34409. return nil
  34410. case usagedetail.FieldRequest:
  34411. v, ok := value.(string)
  34412. if !ok {
  34413. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34414. }
  34415. m.SetRequest(v)
  34416. return nil
  34417. case usagedetail.FieldResponse:
  34418. v, ok := value.(string)
  34419. if !ok {
  34420. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34421. }
  34422. m.SetResponse(v)
  34423. return nil
  34424. case usagedetail.FieldOriginalData:
  34425. v, ok := value.(custom_types.OriginalData)
  34426. if !ok {
  34427. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34428. }
  34429. m.SetOriginalData(v)
  34430. return nil
  34431. case usagedetail.FieldTotalTokens:
  34432. v, ok := value.(uint64)
  34433. if !ok {
  34434. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34435. }
  34436. m.SetTotalTokens(v)
  34437. return nil
  34438. case usagedetail.FieldPromptTokens:
  34439. v, ok := value.(uint64)
  34440. if !ok {
  34441. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34442. }
  34443. m.SetPromptTokens(v)
  34444. return nil
  34445. case usagedetail.FieldCompletionTokens:
  34446. v, ok := value.(uint64)
  34447. if !ok {
  34448. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34449. }
  34450. m.SetCompletionTokens(v)
  34451. return nil
  34452. case usagedetail.FieldOrganizationID:
  34453. v, ok := value.(uint64)
  34454. if !ok {
  34455. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34456. }
  34457. m.SetOrganizationID(v)
  34458. return nil
  34459. case usagedetail.FieldModel:
  34460. v, ok := value.(string)
  34461. if !ok {
  34462. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34463. }
  34464. m.SetModel(v)
  34465. return nil
  34466. case usagedetail.FieldCredits:
  34467. v, ok := value.(float64)
  34468. if !ok {
  34469. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34470. }
  34471. m.SetCredits(v)
  34472. return nil
  34473. }
  34474. return fmt.Errorf("unknown UsageDetail field %s", name)
  34475. }
  34476. // AddedFields returns all numeric fields that were incremented/decremented during
  34477. // this mutation.
  34478. func (m *UsageDetailMutation) AddedFields() []string {
  34479. var fields []string
  34480. if m.addstatus != nil {
  34481. fields = append(fields, usagedetail.FieldStatus)
  34482. }
  34483. if m.add_type != nil {
  34484. fields = append(fields, usagedetail.FieldType)
  34485. }
  34486. if m.addapp != nil {
  34487. fields = append(fields, usagedetail.FieldApp)
  34488. }
  34489. if m.addsession_id != nil {
  34490. fields = append(fields, usagedetail.FieldSessionID)
  34491. }
  34492. if m.addtotal_tokens != nil {
  34493. fields = append(fields, usagedetail.FieldTotalTokens)
  34494. }
  34495. if m.addprompt_tokens != nil {
  34496. fields = append(fields, usagedetail.FieldPromptTokens)
  34497. }
  34498. if m.addcompletion_tokens != nil {
  34499. fields = append(fields, usagedetail.FieldCompletionTokens)
  34500. }
  34501. if m.addorganization_id != nil {
  34502. fields = append(fields, usagedetail.FieldOrganizationID)
  34503. }
  34504. if m.addcredits != nil {
  34505. fields = append(fields, usagedetail.FieldCredits)
  34506. }
  34507. return fields
  34508. }
  34509. // AddedField returns the numeric value that was incremented/decremented on a field
  34510. // with the given name. The second boolean return value indicates that this field
  34511. // was not set, or was not defined in the schema.
  34512. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  34513. switch name {
  34514. case usagedetail.FieldStatus:
  34515. return m.AddedStatus()
  34516. case usagedetail.FieldType:
  34517. return m.AddedType()
  34518. case usagedetail.FieldApp:
  34519. return m.AddedApp()
  34520. case usagedetail.FieldSessionID:
  34521. return m.AddedSessionID()
  34522. case usagedetail.FieldTotalTokens:
  34523. return m.AddedTotalTokens()
  34524. case usagedetail.FieldPromptTokens:
  34525. return m.AddedPromptTokens()
  34526. case usagedetail.FieldCompletionTokens:
  34527. return m.AddedCompletionTokens()
  34528. case usagedetail.FieldOrganizationID:
  34529. return m.AddedOrganizationID()
  34530. case usagedetail.FieldCredits:
  34531. return m.AddedCredits()
  34532. }
  34533. return nil, false
  34534. }
  34535. // AddField adds the value to the field with the given name. It returns an error if
  34536. // the field is not defined in the schema, or if the type mismatched the field
  34537. // type.
  34538. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  34539. switch name {
  34540. case usagedetail.FieldStatus:
  34541. v, ok := value.(int8)
  34542. if !ok {
  34543. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34544. }
  34545. m.AddStatus(v)
  34546. return nil
  34547. case usagedetail.FieldType:
  34548. v, ok := value.(int)
  34549. if !ok {
  34550. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34551. }
  34552. m.AddType(v)
  34553. return nil
  34554. case usagedetail.FieldApp:
  34555. v, ok := value.(int)
  34556. if !ok {
  34557. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34558. }
  34559. m.AddApp(v)
  34560. return nil
  34561. case usagedetail.FieldSessionID:
  34562. v, ok := value.(int64)
  34563. if !ok {
  34564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34565. }
  34566. m.AddSessionID(v)
  34567. return nil
  34568. case usagedetail.FieldTotalTokens:
  34569. v, ok := value.(int64)
  34570. if !ok {
  34571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34572. }
  34573. m.AddTotalTokens(v)
  34574. return nil
  34575. case usagedetail.FieldPromptTokens:
  34576. v, ok := value.(int64)
  34577. if !ok {
  34578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34579. }
  34580. m.AddPromptTokens(v)
  34581. return nil
  34582. case usagedetail.FieldCompletionTokens:
  34583. v, ok := value.(int64)
  34584. if !ok {
  34585. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34586. }
  34587. m.AddCompletionTokens(v)
  34588. return nil
  34589. case usagedetail.FieldOrganizationID:
  34590. v, ok := value.(int64)
  34591. if !ok {
  34592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34593. }
  34594. m.AddOrganizationID(v)
  34595. return nil
  34596. case usagedetail.FieldCredits:
  34597. v, ok := value.(float64)
  34598. if !ok {
  34599. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34600. }
  34601. m.AddCredits(v)
  34602. return nil
  34603. }
  34604. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  34605. }
  34606. // ClearedFields returns all nullable fields that were cleared during this
  34607. // mutation.
  34608. func (m *UsageDetailMutation) ClearedFields() []string {
  34609. var fields []string
  34610. if m.FieldCleared(usagedetail.FieldStatus) {
  34611. fields = append(fields, usagedetail.FieldStatus)
  34612. }
  34613. if m.FieldCleared(usagedetail.FieldType) {
  34614. fields = append(fields, usagedetail.FieldType)
  34615. }
  34616. if m.FieldCleared(usagedetail.FieldApp) {
  34617. fields = append(fields, usagedetail.FieldApp)
  34618. }
  34619. if m.FieldCleared(usagedetail.FieldSessionID) {
  34620. fields = append(fields, usagedetail.FieldSessionID)
  34621. }
  34622. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  34623. fields = append(fields, usagedetail.FieldTotalTokens)
  34624. }
  34625. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  34626. fields = append(fields, usagedetail.FieldPromptTokens)
  34627. }
  34628. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  34629. fields = append(fields, usagedetail.FieldCompletionTokens)
  34630. }
  34631. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  34632. fields = append(fields, usagedetail.FieldOrganizationID)
  34633. }
  34634. if m.FieldCleared(usagedetail.FieldModel) {
  34635. fields = append(fields, usagedetail.FieldModel)
  34636. }
  34637. if m.FieldCleared(usagedetail.FieldCredits) {
  34638. fields = append(fields, usagedetail.FieldCredits)
  34639. }
  34640. return fields
  34641. }
  34642. // FieldCleared returns a boolean indicating if a field with the given name was
  34643. // cleared in this mutation.
  34644. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  34645. _, ok := m.clearedFields[name]
  34646. return ok
  34647. }
  34648. // ClearField clears the value of the field with the given name. It returns an
  34649. // error if the field is not defined in the schema.
  34650. func (m *UsageDetailMutation) ClearField(name string) error {
  34651. switch name {
  34652. case usagedetail.FieldStatus:
  34653. m.ClearStatus()
  34654. return nil
  34655. case usagedetail.FieldType:
  34656. m.ClearType()
  34657. return nil
  34658. case usagedetail.FieldApp:
  34659. m.ClearApp()
  34660. return nil
  34661. case usagedetail.FieldSessionID:
  34662. m.ClearSessionID()
  34663. return nil
  34664. case usagedetail.FieldTotalTokens:
  34665. m.ClearTotalTokens()
  34666. return nil
  34667. case usagedetail.FieldPromptTokens:
  34668. m.ClearPromptTokens()
  34669. return nil
  34670. case usagedetail.FieldCompletionTokens:
  34671. m.ClearCompletionTokens()
  34672. return nil
  34673. case usagedetail.FieldOrganizationID:
  34674. m.ClearOrganizationID()
  34675. return nil
  34676. case usagedetail.FieldModel:
  34677. m.ClearModel()
  34678. return nil
  34679. case usagedetail.FieldCredits:
  34680. m.ClearCredits()
  34681. return nil
  34682. }
  34683. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  34684. }
  34685. // ResetField resets all changes in the mutation for the field with the given name.
  34686. // It returns an error if the field is not defined in the schema.
  34687. func (m *UsageDetailMutation) ResetField(name string) error {
  34688. switch name {
  34689. case usagedetail.FieldCreatedAt:
  34690. m.ResetCreatedAt()
  34691. return nil
  34692. case usagedetail.FieldUpdatedAt:
  34693. m.ResetUpdatedAt()
  34694. return nil
  34695. case usagedetail.FieldStatus:
  34696. m.ResetStatus()
  34697. return nil
  34698. case usagedetail.FieldType:
  34699. m.ResetType()
  34700. return nil
  34701. case usagedetail.FieldBotID:
  34702. m.ResetBotID()
  34703. return nil
  34704. case usagedetail.FieldReceiverID:
  34705. m.ResetReceiverID()
  34706. return nil
  34707. case usagedetail.FieldApp:
  34708. m.ResetApp()
  34709. return nil
  34710. case usagedetail.FieldSessionID:
  34711. m.ResetSessionID()
  34712. return nil
  34713. case usagedetail.FieldRequest:
  34714. m.ResetRequest()
  34715. return nil
  34716. case usagedetail.FieldResponse:
  34717. m.ResetResponse()
  34718. return nil
  34719. case usagedetail.FieldOriginalData:
  34720. m.ResetOriginalData()
  34721. return nil
  34722. case usagedetail.FieldTotalTokens:
  34723. m.ResetTotalTokens()
  34724. return nil
  34725. case usagedetail.FieldPromptTokens:
  34726. m.ResetPromptTokens()
  34727. return nil
  34728. case usagedetail.FieldCompletionTokens:
  34729. m.ResetCompletionTokens()
  34730. return nil
  34731. case usagedetail.FieldOrganizationID:
  34732. m.ResetOrganizationID()
  34733. return nil
  34734. case usagedetail.FieldModel:
  34735. m.ResetModel()
  34736. return nil
  34737. case usagedetail.FieldCredits:
  34738. m.ResetCredits()
  34739. return nil
  34740. }
  34741. return fmt.Errorf("unknown UsageDetail field %s", name)
  34742. }
  34743. // AddedEdges returns all edge names that were set/added in this mutation.
  34744. func (m *UsageDetailMutation) AddedEdges() []string {
  34745. edges := make([]string, 0, 0)
  34746. return edges
  34747. }
  34748. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  34749. // name in this mutation.
  34750. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  34751. return nil
  34752. }
  34753. // RemovedEdges returns all edge names that were removed in this mutation.
  34754. func (m *UsageDetailMutation) RemovedEdges() []string {
  34755. edges := make([]string, 0, 0)
  34756. return edges
  34757. }
  34758. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  34759. // the given name in this mutation.
  34760. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  34761. return nil
  34762. }
  34763. // ClearedEdges returns all edge names that were cleared in this mutation.
  34764. func (m *UsageDetailMutation) ClearedEdges() []string {
  34765. edges := make([]string, 0, 0)
  34766. return edges
  34767. }
  34768. // EdgeCleared returns a boolean which indicates if the edge with the given name
  34769. // was cleared in this mutation.
  34770. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  34771. return false
  34772. }
  34773. // ClearEdge clears the value of the edge with the given name. It returns an error
  34774. // if that edge is not defined in the schema.
  34775. func (m *UsageDetailMutation) ClearEdge(name string) error {
  34776. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  34777. }
  34778. // ResetEdge resets all changes to the edge with the given name in this mutation.
  34779. // It returns an error if the edge is not defined in the schema.
  34780. func (m *UsageDetailMutation) ResetEdge(name string) error {
  34781. return fmt.Errorf("unknown UsageDetail edge %s", name)
  34782. }
  34783. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  34784. type UsageStatisticDayMutation struct {
  34785. config
  34786. op Op
  34787. typ string
  34788. id *uint64
  34789. created_at *time.Time
  34790. updated_at *time.Time
  34791. status *uint8
  34792. addstatus *int8
  34793. deleted_at *time.Time
  34794. addtime *uint64
  34795. addaddtime *int64
  34796. _type *int
  34797. add_type *int
  34798. bot_id *string
  34799. organization_id *uint64
  34800. addorganization_id *int64
  34801. ai_response *uint64
  34802. addai_response *int64
  34803. sop_run *uint64
  34804. addsop_run *int64
  34805. total_friend *uint64
  34806. addtotal_friend *int64
  34807. total_group *uint64
  34808. addtotal_group *int64
  34809. account_balance *uint64
  34810. addaccount_balance *int64
  34811. consume_token *uint64
  34812. addconsume_token *int64
  34813. active_user *uint64
  34814. addactive_user *int64
  34815. new_user *int64
  34816. addnew_user *int64
  34817. label_dist *[]custom_types.LabelDist
  34818. appendlabel_dist []custom_types.LabelDist
  34819. consume_coin *float64
  34820. addconsume_coin *float64
  34821. clearedFields map[string]struct{}
  34822. done bool
  34823. oldValue func(context.Context) (*UsageStatisticDay, error)
  34824. predicates []predicate.UsageStatisticDay
  34825. }
  34826. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  34827. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  34828. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  34829. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  34830. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  34831. m := &UsageStatisticDayMutation{
  34832. config: c,
  34833. op: op,
  34834. typ: TypeUsageStatisticDay,
  34835. clearedFields: make(map[string]struct{}),
  34836. }
  34837. for _, opt := range opts {
  34838. opt(m)
  34839. }
  34840. return m
  34841. }
  34842. // withUsageStatisticDayID sets the ID field of the mutation.
  34843. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  34844. return func(m *UsageStatisticDayMutation) {
  34845. var (
  34846. err error
  34847. once sync.Once
  34848. value *UsageStatisticDay
  34849. )
  34850. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  34851. once.Do(func() {
  34852. if m.done {
  34853. err = errors.New("querying old values post mutation is not allowed")
  34854. } else {
  34855. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  34856. }
  34857. })
  34858. return value, err
  34859. }
  34860. m.id = &id
  34861. }
  34862. }
  34863. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  34864. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  34865. return func(m *UsageStatisticDayMutation) {
  34866. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  34867. return node, nil
  34868. }
  34869. m.id = &node.ID
  34870. }
  34871. }
  34872. // Client returns a new `ent.Client` from the mutation. If the mutation was
  34873. // executed in a transaction (ent.Tx), a transactional client is returned.
  34874. func (m UsageStatisticDayMutation) Client() *Client {
  34875. client := &Client{config: m.config}
  34876. client.init()
  34877. return client
  34878. }
  34879. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  34880. // it returns an error otherwise.
  34881. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  34882. if _, ok := m.driver.(*txDriver); !ok {
  34883. return nil, errors.New("ent: mutation is not running in a transaction")
  34884. }
  34885. tx := &Tx{config: m.config}
  34886. tx.init()
  34887. return tx, nil
  34888. }
  34889. // SetID sets the value of the id field. Note that this
  34890. // operation is only accepted on creation of UsageStatisticDay entities.
  34891. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  34892. m.id = &id
  34893. }
  34894. // ID returns the ID value in the mutation. Note that the ID is only available
  34895. // if it was provided to the builder or after it was returned from the database.
  34896. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  34897. if m.id == nil {
  34898. return
  34899. }
  34900. return *m.id, true
  34901. }
  34902. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  34903. // That means, if the mutation is applied within a transaction with an isolation level such
  34904. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  34905. // or updated by the mutation.
  34906. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  34907. switch {
  34908. case m.op.Is(OpUpdateOne | OpDeleteOne):
  34909. id, exists := m.ID()
  34910. if exists {
  34911. return []uint64{id}, nil
  34912. }
  34913. fallthrough
  34914. case m.op.Is(OpUpdate | OpDelete):
  34915. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  34916. default:
  34917. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  34918. }
  34919. }
  34920. // SetCreatedAt sets the "created_at" field.
  34921. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  34922. m.created_at = &t
  34923. }
  34924. // CreatedAt returns the value of the "created_at" field in the mutation.
  34925. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  34926. v := m.created_at
  34927. if v == nil {
  34928. return
  34929. }
  34930. return *v, true
  34931. }
  34932. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  34933. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34934. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34935. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  34936. if !m.op.Is(OpUpdateOne) {
  34937. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  34938. }
  34939. if m.id == nil || m.oldValue == nil {
  34940. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  34941. }
  34942. oldValue, err := m.oldValue(ctx)
  34943. if err != nil {
  34944. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  34945. }
  34946. return oldValue.CreatedAt, nil
  34947. }
  34948. // ResetCreatedAt resets all changes to the "created_at" field.
  34949. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  34950. m.created_at = nil
  34951. }
  34952. // SetUpdatedAt sets the "updated_at" field.
  34953. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  34954. m.updated_at = &t
  34955. }
  34956. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  34957. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  34958. v := m.updated_at
  34959. if v == nil {
  34960. return
  34961. }
  34962. return *v, true
  34963. }
  34964. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  34965. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34966. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34967. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  34968. if !m.op.Is(OpUpdateOne) {
  34969. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  34970. }
  34971. if m.id == nil || m.oldValue == nil {
  34972. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  34973. }
  34974. oldValue, err := m.oldValue(ctx)
  34975. if err != nil {
  34976. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  34977. }
  34978. return oldValue.UpdatedAt, nil
  34979. }
  34980. // ResetUpdatedAt resets all changes to the "updated_at" field.
  34981. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  34982. m.updated_at = nil
  34983. }
  34984. // SetStatus sets the "status" field.
  34985. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  34986. m.status = &u
  34987. m.addstatus = nil
  34988. }
  34989. // Status returns the value of the "status" field in the mutation.
  34990. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  34991. v := m.status
  34992. if v == nil {
  34993. return
  34994. }
  34995. return *v, true
  34996. }
  34997. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  34998. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34999. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35000. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  35001. if !m.op.Is(OpUpdateOne) {
  35002. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  35003. }
  35004. if m.id == nil || m.oldValue == nil {
  35005. return v, errors.New("OldStatus requires an ID field in the mutation")
  35006. }
  35007. oldValue, err := m.oldValue(ctx)
  35008. if err != nil {
  35009. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  35010. }
  35011. return oldValue.Status, nil
  35012. }
  35013. // AddStatus adds u to the "status" field.
  35014. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  35015. if m.addstatus != nil {
  35016. *m.addstatus += u
  35017. } else {
  35018. m.addstatus = &u
  35019. }
  35020. }
  35021. // AddedStatus returns the value that was added to the "status" field in this mutation.
  35022. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  35023. v := m.addstatus
  35024. if v == nil {
  35025. return
  35026. }
  35027. return *v, true
  35028. }
  35029. // ClearStatus clears the value of the "status" field.
  35030. func (m *UsageStatisticDayMutation) ClearStatus() {
  35031. m.status = nil
  35032. m.addstatus = nil
  35033. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  35034. }
  35035. // StatusCleared returns if the "status" field was cleared in this mutation.
  35036. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  35037. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  35038. return ok
  35039. }
  35040. // ResetStatus resets all changes to the "status" field.
  35041. func (m *UsageStatisticDayMutation) ResetStatus() {
  35042. m.status = nil
  35043. m.addstatus = nil
  35044. delete(m.clearedFields, usagestatisticday.FieldStatus)
  35045. }
  35046. // SetDeletedAt sets the "deleted_at" field.
  35047. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  35048. m.deleted_at = &t
  35049. }
  35050. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  35051. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  35052. v := m.deleted_at
  35053. if v == nil {
  35054. return
  35055. }
  35056. return *v, true
  35057. }
  35058. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  35059. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  35060. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35061. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  35062. if !m.op.Is(OpUpdateOne) {
  35063. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  35064. }
  35065. if m.id == nil || m.oldValue == nil {
  35066. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  35067. }
  35068. oldValue, err := m.oldValue(ctx)
  35069. if err != nil {
  35070. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  35071. }
  35072. return oldValue.DeletedAt, nil
  35073. }
  35074. // ClearDeletedAt clears the value of the "deleted_at" field.
  35075. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  35076. m.deleted_at = nil
  35077. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  35078. }
  35079. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  35080. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  35081. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  35082. return ok
  35083. }
  35084. // ResetDeletedAt resets all changes to the "deleted_at" field.
  35085. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  35086. m.deleted_at = nil
  35087. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  35088. }
  35089. // SetAddtime sets the "addtime" field.
  35090. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  35091. m.addtime = &u
  35092. m.addaddtime = nil
  35093. }
  35094. // Addtime returns the value of the "addtime" field in the mutation.
  35095. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  35096. v := m.addtime
  35097. if v == nil {
  35098. return
  35099. }
  35100. return *v, true
  35101. }
  35102. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  35103. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  35104. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35105. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  35106. if !m.op.Is(OpUpdateOne) {
  35107. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  35108. }
  35109. if m.id == nil || m.oldValue == nil {
  35110. return v, errors.New("OldAddtime requires an ID field in the mutation")
  35111. }
  35112. oldValue, err := m.oldValue(ctx)
  35113. if err != nil {
  35114. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  35115. }
  35116. return oldValue.Addtime, nil
  35117. }
  35118. // AddAddtime adds u to the "addtime" field.
  35119. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  35120. if m.addaddtime != nil {
  35121. *m.addaddtime += u
  35122. } else {
  35123. m.addaddtime = &u
  35124. }
  35125. }
  35126. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  35127. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  35128. v := m.addaddtime
  35129. if v == nil {
  35130. return
  35131. }
  35132. return *v, true
  35133. }
  35134. // ResetAddtime resets all changes to the "addtime" field.
  35135. func (m *UsageStatisticDayMutation) ResetAddtime() {
  35136. m.addtime = nil
  35137. m.addaddtime = nil
  35138. }
  35139. // SetType sets the "type" field.
  35140. func (m *UsageStatisticDayMutation) SetType(i int) {
  35141. m._type = &i
  35142. m.add_type = nil
  35143. }
  35144. // GetType returns the value of the "type" field in the mutation.
  35145. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  35146. v := m._type
  35147. if v == nil {
  35148. return
  35149. }
  35150. return *v, true
  35151. }
  35152. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  35153. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  35154. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35155. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  35156. if !m.op.Is(OpUpdateOne) {
  35157. return v, errors.New("OldType is only allowed on UpdateOne operations")
  35158. }
  35159. if m.id == nil || m.oldValue == nil {
  35160. return v, errors.New("OldType requires an ID field in the mutation")
  35161. }
  35162. oldValue, err := m.oldValue(ctx)
  35163. if err != nil {
  35164. return v, fmt.Errorf("querying old value for OldType: %w", err)
  35165. }
  35166. return oldValue.Type, nil
  35167. }
  35168. // AddType adds i to the "type" field.
  35169. func (m *UsageStatisticDayMutation) AddType(i int) {
  35170. if m.add_type != nil {
  35171. *m.add_type += i
  35172. } else {
  35173. m.add_type = &i
  35174. }
  35175. }
  35176. // AddedType returns the value that was added to the "type" field in this mutation.
  35177. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  35178. v := m.add_type
  35179. if v == nil {
  35180. return
  35181. }
  35182. return *v, true
  35183. }
  35184. // ResetType resets all changes to the "type" field.
  35185. func (m *UsageStatisticDayMutation) ResetType() {
  35186. m._type = nil
  35187. m.add_type = nil
  35188. }
  35189. // SetBotID sets the "bot_id" field.
  35190. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  35191. m.bot_id = &s
  35192. }
  35193. // BotID returns the value of the "bot_id" field in the mutation.
  35194. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  35195. v := m.bot_id
  35196. if v == nil {
  35197. return
  35198. }
  35199. return *v, true
  35200. }
  35201. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  35202. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  35203. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35204. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  35205. if !m.op.Is(OpUpdateOne) {
  35206. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  35207. }
  35208. if m.id == nil || m.oldValue == nil {
  35209. return v, errors.New("OldBotID requires an ID field in the mutation")
  35210. }
  35211. oldValue, err := m.oldValue(ctx)
  35212. if err != nil {
  35213. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  35214. }
  35215. return oldValue.BotID, nil
  35216. }
  35217. // ClearBotID clears the value of the "bot_id" field.
  35218. func (m *UsageStatisticDayMutation) ClearBotID() {
  35219. m.bot_id = nil
  35220. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  35221. }
  35222. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  35223. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  35224. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  35225. return ok
  35226. }
  35227. // ResetBotID resets all changes to the "bot_id" field.
  35228. func (m *UsageStatisticDayMutation) ResetBotID() {
  35229. m.bot_id = nil
  35230. delete(m.clearedFields, usagestatisticday.FieldBotID)
  35231. }
  35232. // SetOrganizationID sets the "organization_id" field.
  35233. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  35234. m.organization_id = &u
  35235. m.addorganization_id = nil
  35236. }
  35237. // OrganizationID returns the value of the "organization_id" field in the mutation.
  35238. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  35239. v := m.organization_id
  35240. if v == nil {
  35241. return
  35242. }
  35243. return *v, true
  35244. }
  35245. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  35246. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  35247. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35248. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  35249. if !m.op.Is(OpUpdateOne) {
  35250. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  35251. }
  35252. if m.id == nil || m.oldValue == nil {
  35253. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  35254. }
  35255. oldValue, err := m.oldValue(ctx)
  35256. if err != nil {
  35257. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  35258. }
  35259. return oldValue.OrganizationID, nil
  35260. }
  35261. // AddOrganizationID adds u to the "organization_id" field.
  35262. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  35263. if m.addorganization_id != nil {
  35264. *m.addorganization_id += u
  35265. } else {
  35266. m.addorganization_id = &u
  35267. }
  35268. }
  35269. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  35270. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  35271. v := m.addorganization_id
  35272. if v == nil {
  35273. return
  35274. }
  35275. return *v, true
  35276. }
  35277. // ClearOrganizationID clears the value of the "organization_id" field.
  35278. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  35279. m.organization_id = nil
  35280. m.addorganization_id = nil
  35281. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  35282. }
  35283. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  35284. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  35285. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  35286. return ok
  35287. }
  35288. // ResetOrganizationID resets all changes to the "organization_id" field.
  35289. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  35290. m.organization_id = nil
  35291. m.addorganization_id = nil
  35292. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  35293. }
  35294. // SetAiResponse sets the "ai_response" field.
  35295. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  35296. m.ai_response = &u
  35297. m.addai_response = nil
  35298. }
  35299. // AiResponse returns the value of the "ai_response" field in the mutation.
  35300. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  35301. v := m.ai_response
  35302. if v == nil {
  35303. return
  35304. }
  35305. return *v, true
  35306. }
  35307. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  35308. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  35309. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35310. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  35311. if !m.op.Is(OpUpdateOne) {
  35312. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  35313. }
  35314. if m.id == nil || m.oldValue == nil {
  35315. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  35316. }
  35317. oldValue, err := m.oldValue(ctx)
  35318. if err != nil {
  35319. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  35320. }
  35321. return oldValue.AiResponse, nil
  35322. }
  35323. // AddAiResponse adds u to the "ai_response" field.
  35324. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  35325. if m.addai_response != nil {
  35326. *m.addai_response += u
  35327. } else {
  35328. m.addai_response = &u
  35329. }
  35330. }
  35331. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  35332. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  35333. v := m.addai_response
  35334. if v == nil {
  35335. return
  35336. }
  35337. return *v, true
  35338. }
  35339. // ResetAiResponse resets all changes to the "ai_response" field.
  35340. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  35341. m.ai_response = nil
  35342. m.addai_response = nil
  35343. }
  35344. // SetSopRun sets the "sop_run" field.
  35345. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  35346. m.sop_run = &u
  35347. m.addsop_run = nil
  35348. }
  35349. // SopRun returns the value of the "sop_run" field in the mutation.
  35350. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  35351. v := m.sop_run
  35352. if v == nil {
  35353. return
  35354. }
  35355. return *v, true
  35356. }
  35357. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  35358. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  35359. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35360. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  35361. if !m.op.Is(OpUpdateOne) {
  35362. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  35363. }
  35364. if m.id == nil || m.oldValue == nil {
  35365. return v, errors.New("OldSopRun requires an ID field in the mutation")
  35366. }
  35367. oldValue, err := m.oldValue(ctx)
  35368. if err != nil {
  35369. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  35370. }
  35371. return oldValue.SopRun, nil
  35372. }
  35373. // AddSopRun adds u to the "sop_run" field.
  35374. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  35375. if m.addsop_run != nil {
  35376. *m.addsop_run += u
  35377. } else {
  35378. m.addsop_run = &u
  35379. }
  35380. }
  35381. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  35382. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  35383. v := m.addsop_run
  35384. if v == nil {
  35385. return
  35386. }
  35387. return *v, true
  35388. }
  35389. // ResetSopRun resets all changes to the "sop_run" field.
  35390. func (m *UsageStatisticDayMutation) ResetSopRun() {
  35391. m.sop_run = nil
  35392. m.addsop_run = nil
  35393. }
  35394. // SetTotalFriend sets the "total_friend" field.
  35395. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  35396. m.total_friend = &u
  35397. m.addtotal_friend = nil
  35398. }
  35399. // TotalFriend returns the value of the "total_friend" field in the mutation.
  35400. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  35401. v := m.total_friend
  35402. if v == nil {
  35403. return
  35404. }
  35405. return *v, true
  35406. }
  35407. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  35408. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  35409. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35410. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  35411. if !m.op.Is(OpUpdateOne) {
  35412. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  35413. }
  35414. if m.id == nil || m.oldValue == nil {
  35415. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  35416. }
  35417. oldValue, err := m.oldValue(ctx)
  35418. if err != nil {
  35419. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  35420. }
  35421. return oldValue.TotalFriend, nil
  35422. }
  35423. // AddTotalFriend adds u to the "total_friend" field.
  35424. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  35425. if m.addtotal_friend != nil {
  35426. *m.addtotal_friend += u
  35427. } else {
  35428. m.addtotal_friend = &u
  35429. }
  35430. }
  35431. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  35432. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  35433. v := m.addtotal_friend
  35434. if v == nil {
  35435. return
  35436. }
  35437. return *v, true
  35438. }
  35439. // ResetTotalFriend resets all changes to the "total_friend" field.
  35440. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  35441. m.total_friend = nil
  35442. m.addtotal_friend = nil
  35443. }
  35444. // SetTotalGroup sets the "total_group" field.
  35445. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  35446. m.total_group = &u
  35447. m.addtotal_group = nil
  35448. }
  35449. // TotalGroup returns the value of the "total_group" field in the mutation.
  35450. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  35451. v := m.total_group
  35452. if v == nil {
  35453. return
  35454. }
  35455. return *v, true
  35456. }
  35457. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  35458. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  35459. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35460. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  35461. if !m.op.Is(OpUpdateOne) {
  35462. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  35463. }
  35464. if m.id == nil || m.oldValue == nil {
  35465. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  35466. }
  35467. oldValue, err := m.oldValue(ctx)
  35468. if err != nil {
  35469. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  35470. }
  35471. return oldValue.TotalGroup, nil
  35472. }
  35473. // AddTotalGroup adds u to the "total_group" field.
  35474. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  35475. if m.addtotal_group != nil {
  35476. *m.addtotal_group += u
  35477. } else {
  35478. m.addtotal_group = &u
  35479. }
  35480. }
  35481. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  35482. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  35483. v := m.addtotal_group
  35484. if v == nil {
  35485. return
  35486. }
  35487. return *v, true
  35488. }
  35489. // ResetTotalGroup resets all changes to the "total_group" field.
  35490. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  35491. m.total_group = nil
  35492. m.addtotal_group = nil
  35493. }
  35494. // SetAccountBalance sets the "account_balance" field.
  35495. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  35496. m.account_balance = &u
  35497. m.addaccount_balance = nil
  35498. }
  35499. // AccountBalance returns the value of the "account_balance" field in the mutation.
  35500. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  35501. v := m.account_balance
  35502. if v == nil {
  35503. return
  35504. }
  35505. return *v, true
  35506. }
  35507. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  35508. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  35509. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35510. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  35511. if !m.op.Is(OpUpdateOne) {
  35512. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  35513. }
  35514. if m.id == nil || m.oldValue == nil {
  35515. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  35516. }
  35517. oldValue, err := m.oldValue(ctx)
  35518. if err != nil {
  35519. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  35520. }
  35521. return oldValue.AccountBalance, nil
  35522. }
  35523. // AddAccountBalance adds u to the "account_balance" field.
  35524. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  35525. if m.addaccount_balance != nil {
  35526. *m.addaccount_balance += u
  35527. } else {
  35528. m.addaccount_balance = &u
  35529. }
  35530. }
  35531. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  35532. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  35533. v := m.addaccount_balance
  35534. if v == nil {
  35535. return
  35536. }
  35537. return *v, true
  35538. }
  35539. // ResetAccountBalance resets all changes to the "account_balance" field.
  35540. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  35541. m.account_balance = nil
  35542. m.addaccount_balance = nil
  35543. }
  35544. // SetConsumeToken sets the "consume_token" field.
  35545. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  35546. m.consume_token = &u
  35547. m.addconsume_token = nil
  35548. }
  35549. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  35550. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  35551. v := m.consume_token
  35552. if v == nil {
  35553. return
  35554. }
  35555. return *v, true
  35556. }
  35557. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  35558. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  35559. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35560. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  35561. if !m.op.Is(OpUpdateOne) {
  35562. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  35563. }
  35564. if m.id == nil || m.oldValue == nil {
  35565. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  35566. }
  35567. oldValue, err := m.oldValue(ctx)
  35568. if err != nil {
  35569. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  35570. }
  35571. return oldValue.ConsumeToken, nil
  35572. }
  35573. // AddConsumeToken adds u to the "consume_token" field.
  35574. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  35575. if m.addconsume_token != nil {
  35576. *m.addconsume_token += u
  35577. } else {
  35578. m.addconsume_token = &u
  35579. }
  35580. }
  35581. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  35582. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  35583. v := m.addconsume_token
  35584. if v == nil {
  35585. return
  35586. }
  35587. return *v, true
  35588. }
  35589. // ResetConsumeToken resets all changes to the "consume_token" field.
  35590. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  35591. m.consume_token = nil
  35592. m.addconsume_token = nil
  35593. }
  35594. // SetActiveUser sets the "active_user" field.
  35595. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  35596. m.active_user = &u
  35597. m.addactive_user = nil
  35598. }
  35599. // ActiveUser returns the value of the "active_user" field in the mutation.
  35600. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  35601. v := m.active_user
  35602. if v == nil {
  35603. return
  35604. }
  35605. return *v, true
  35606. }
  35607. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  35608. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  35609. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35610. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  35611. if !m.op.Is(OpUpdateOne) {
  35612. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  35613. }
  35614. if m.id == nil || m.oldValue == nil {
  35615. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  35616. }
  35617. oldValue, err := m.oldValue(ctx)
  35618. if err != nil {
  35619. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  35620. }
  35621. return oldValue.ActiveUser, nil
  35622. }
  35623. // AddActiveUser adds u to the "active_user" field.
  35624. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  35625. if m.addactive_user != nil {
  35626. *m.addactive_user += u
  35627. } else {
  35628. m.addactive_user = &u
  35629. }
  35630. }
  35631. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  35632. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  35633. v := m.addactive_user
  35634. if v == nil {
  35635. return
  35636. }
  35637. return *v, true
  35638. }
  35639. // ResetActiveUser resets all changes to the "active_user" field.
  35640. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  35641. m.active_user = nil
  35642. m.addactive_user = nil
  35643. }
  35644. // SetNewUser sets the "new_user" field.
  35645. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  35646. m.new_user = &i
  35647. m.addnew_user = nil
  35648. }
  35649. // NewUser returns the value of the "new_user" field in the mutation.
  35650. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  35651. v := m.new_user
  35652. if v == nil {
  35653. return
  35654. }
  35655. return *v, true
  35656. }
  35657. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  35658. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  35659. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35660. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  35661. if !m.op.Is(OpUpdateOne) {
  35662. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  35663. }
  35664. if m.id == nil || m.oldValue == nil {
  35665. return v, errors.New("OldNewUser requires an ID field in the mutation")
  35666. }
  35667. oldValue, err := m.oldValue(ctx)
  35668. if err != nil {
  35669. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  35670. }
  35671. return oldValue.NewUser, nil
  35672. }
  35673. // AddNewUser adds i to the "new_user" field.
  35674. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  35675. if m.addnew_user != nil {
  35676. *m.addnew_user += i
  35677. } else {
  35678. m.addnew_user = &i
  35679. }
  35680. }
  35681. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  35682. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  35683. v := m.addnew_user
  35684. if v == nil {
  35685. return
  35686. }
  35687. return *v, true
  35688. }
  35689. // ResetNewUser resets all changes to the "new_user" field.
  35690. func (m *UsageStatisticDayMutation) ResetNewUser() {
  35691. m.new_user = nil
  35692. m.addnew_user = nil
  35693. }
  35694. // SetLabelDist sets the "label_dist" field.
  35695. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  35696. m.label_dist = &ctd
  35697. m.appendlabel_dist = nil
  35698. }
  35699. // LabelDist returns the value of the "label_dist" field in the mutation.
  35700. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  35701. v := m.label_dist
  35702. if v == nil {
  35703. return
  35704. }
  35705. return *v, true
  35706. }
  35707. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  35708. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  35709. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35710. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  35711. if !m.op.Is(OpUpdateOne) {
  35712. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  35713. }
  35714. if m.id == nil || m.oldValue == nil {
  35715. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  35716. }
  35717. oldValue, err := m.oldValue(ctx)
  35718. if err != nil {
  35719. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  35720. }
  35721. return oldValue.LabelDist, nil
  35722. }
  35723. // AppendLabelDist adds ctd to the "label_dist" field.
  35724. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  35725. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  35726. }
  35727. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  35728. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  35729. if len(m.appendlabel_dist) == 0 {
  35730. return nil, false
  35731. }
  35732. return m.appendlabel_dist, true
  35733. }
  35734. // ResetLabelDist resets all changes to the "label_dist" field.
  35735. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  35736. m.label_dist = nil
  35737. m.appendlabel_dist = nil
  35738. }
  35739. // SetConsumeCoin sets the "consume_coin" field.
  35740. func (m *UsageStatisticDayMutation) SetConsumeCoin(f float64) {
  35741. m.consume_coin = &f
  35742. m.addconsume_coin = nil
  35743. }
  35744. // ConsumeCoin returns the value of the "consume_coin" field in the mutation.
  35745. func (m *UsageStatisticDayMutation) ConsumeCoin() (r float64, exists bool) {
  35746. v := m.consume_coin
  35747. if v == nil {
  35748. return
  35749. }
  35750. return *v, true
  35751. }
  35752. // OldConsumeCoin returns the old "consume_coin" field's value of the UsageStatisticDay entity.
  35753. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  35754. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35755. func (m *UsageStatisticDayMutation) OldConsumeCoin(ctx context.Context) (v float64, err error) {
  35756. if !m.op.Is(OpUpdateOne) {
  35757. return v, errors.New("OldConsumeCoin is only allowed on UpdateOne operations")
  35758. }
  35759. if m.id == nil || m.oldValue == nil {
  35760. return v, errors.New("OldConsumeCoin requires an ID field in the mutation")
  35761. }
  35762. oldValue, err := m.oldValue(ctx)
  35763. if err != nil {
  35764. return v, fmt.Errorf("querying old value for OldConsumeCoin: %w", err)
  35765. }
  35766. return oldValue.ConsumeCoin, nil
  35767. }
  35768. // AddConsumeCoin adds f to the "consume_coin" field.
  35769. func (m *UsageStatisticDayMutation) AddConsumeCoin(f float64) {
  35770. if m.addconsume_coin != nil {
  35771. *m.addconsume_coin += f
  35772. } else {
  35773. m.addconsume_coin = &f
  35774. }
  35775. }
  35776. // AddedConsumeCoin returns the value that was added to the "consume_coin" field in this mutation.
  35777. func (m *UsageStatisticDayMutation) AddedConsumeCoin() (r float64, exists bool) {
  35778. v := m.addconsume_coin
  35779. if v == nil {
  35780. return
  35781. }
  35782. return *v, true
  35783. }
  35784. // ClearConsumeCoin clears the value of the "consume_coin" field.
  35785. func (m *UsageStatisticDayMutation) ClearConsumeCoin() {
  35786. m.consume_coin = nil
  35787. m.addconsume_coin = nil
  35788. m.clearedFields[usagestatisticday.FieldConsumeCoin] = struct{}{}
  35789. }
  35790. // ConsumeCoinCleared returns if the "consume_coin" field was cleared in this mutation.
  35791. func (m *UsageStatisticDayMutation) ConsumeCoinCleared() bool {
  35792. _, ok := m.clearedFields[usagestatisticday.FieldConsumeCoin]
  35793. return ok
  35794. }
  35795. // ResetConsumeCoin resets all changes to the "consume_coin" field.
  35796. func (m *UsageStatisticDayMutation) ResetConsumeCoin() {
  35797. m.consume_coin = nil
  35798. m.addconsume_coin = nil
  35799. delete(m.clearedFields, usagestatisticday.FieldConsumeCoin)
  35800. }
  35801. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  35802. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  35803. m.predicates = append(m.predicates, ps...)
  35804. }
  35805. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  35806. // users can use type-assertion to append predicates that do not depend on any generated package.
  35807. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  35808. p := make([]predicate.UsageStatisticDay, len(ps))
  35809. for i := range ps {
  35810. p[i] = ps[i]
  35811. }
  35812. m.Where(p...)
  35813. }
  35814. // Op returns the operation name.
  35815. func (m *UsageStatisticDayMutation) Op() Op {
  35816. return m.op
  35817. }
  35818. // SetOp allows setting the mutation operation.
  35819. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  35820. m.op = op
  35821. }
  35822. // Type returns the node type of this mutation (UsageStatisticDay).
  35823. func (m *UsageStatisticDayMutation) Type() string {
  35824. return m.typ
  35825. }
  35826. // Fields returns all fields that were changed during this mutation. Note that in
  35827. // order to get all numeric fields that were incremented/decremented, call
  35828. // AddedFields().
  35829. func (m *UsageStatisticDayMutation) Fields() []string {
  35830. fields := make([]string, 0, 18)
  35831. if m.created_at != nil {
  35832. fields = append(fields, usagestatisticday.FieldCreatedAt)
  35833. }
  35834. if m.updated_at != nil {
  35835. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  35836. }
  35837. if m.status != nil {
  35838. fields = append(fields, usagestatisticday.FieldStatus)
  35839. }
  35840. if m.deleted_at != nil {
  35841. fields = append(fields, usagestatisticday.FieldDeletedAt)
  35842. }
  35843. if m.addtime != nil {
  35844. fields = append(fields, usagestatisticday.FieldAddtime)
  35845. }
  35846. if m._type != nil {
  35847. fields = append(fields, usagestatisticday.FieldType)
  35848. }
  35849. if m.bot_id != nil {
  35850. fields = append(fields, usagestatisticday.FieldBotID)
  35851. }
  35852. if m.organization_id != nil {
  35853. fields = append(fields, usagestatisticday.FieldOrganizationID)
  35854. }
  35855. if m.ai_response != nil {
  35856. fields = append(fields, usagestatisticday.FieldAiResponse)
  35857. }
  35858. if m.sop_run != nil {
  35859. fields = append(fields, usagestatisticday.FieldSopRun)
  35860. }
  35861. if m.total_friend != nil {
  35862. fields = append(fields, usagestatisticday.FieldTotalFriend)
  35863. }
  35864. if m.total_group != nil {
  35865. fields = append(fields, usagestatisticday.FieldTotalGroup)
  35866. }
  35867. if m.account_balance != nil {
  35868. fields = append(fields, usagestatisticday.FieldAccountBalance)
  35869. }
  35870. if m.consume_token != nil {
  35871. fields = append(fields, usagestatisticday.FieldConsumeToken)
  35872. }
  35873. if m.active_user != nil {
  35874. fields = append(fields, usagestatisticday.FieldActiveUser)
  35875. }
  35876. if m.new_user != nil {
  35877. fields = append(fields, usagestatisticday.FieldNewUser)
  35878. }
  35879. if m.label_dist != nil {
  35880. fields = append(fields, usagestatisticday.FieldLabelDist)
  35881. }
  35882. if m.consume_coin != nil {
  35883. fields = append(fields, usagestatisticday.FieldConsumeCoin)
  35884. }
  35885. return fields
  35886. }
  35887. // Field returns the value of a field with the given name. The second boolean
  35888. // return value indicates that this field was not set, or was not defined in the
  35889. // schema.
  35890. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  35891. switch name {
  35892. case usagestatisticday.FieldCreatedAt:
  35893. return m.CreatedAt()
  35894. case usagestatisticday.FieldUpdatedAt:
  35895. return m.UpdatedAt()
  35896. case usagestatisticday.FieldStatus:
  35897. return m.Status()
  35898. case usagestatisticday.FieldDeletedAt:
  35899. return m.DeletedAt()
  35900. case usagestatisticday.FieldAddtime:
  35901. return m.Addtime()
  35902. case usagestatisticday.FieldType:
  35903. return m.GetType()
  35904. case usagestatisticday.FieldBotID:
  35905. return m.BotID()
  35906. case usagestatisticday.FieldOrganizationID:
  35907. return m.OrganizationID()
  35908. case usagestatisticday.FieldAiResponse:
  35909. return m.AiResponse()
  35910. case usagestatisticday.FieldSopRun:
  35911. return m.SopRun()
  35912. case usagestatisticday.FieldTotalFriend:
  35913. return m.TotalFriend()
  35914. case usagestatisticday.FieldTotalGroup:
  35915. return m.TotalGroup()
  35916. case usagestatisticday.FieldAccountBalance:
  35917. return m.AccountBalance()
  35918. case usagestatisticday.FieldConsumeToken:
  35919. return m.ConsumeToken()
  35920. case usagestatisticday.FieldActiveUser:
  35921. return m.ActiveUser()
  35922. case usagestatisticday.FieldNewUser:
  35923. return m.NewUser()
  35924. case usagestatisticday.FieldLabelDist:
  35925. return m.LabelDist()
  35926. case usagestatisticday.FieldConsumeCoin:
  35927. return m.ConsumeCoin()
  35928. }
  35929. return nil, false
  35930. }
  35931. // OldField returns the old value of the field from the database. An error is
  35932. // returned if the mutation operation is not UpdateOne, or the query to the
  35933. // database failed.
  35934. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  35935. switch name {
  35936. case usagestatisticday.FieldCreatedAt:
  35937. return m.OldCreatedAt(ctx)
  35938. case usagestatisticday.FieldUpdatedAt:
  35939. return m.OldUpdatedAt(ctx)
  35940. case usagestatisticday.FieldStatus:
  35941. return m.OldStatus(ctx)
  35942. case usagestatisticday.FieldDeletedAt:
  35943. return m.OldDeletedAt(ctx)
  35944. case usagestatisticday.FieldAddtime:
  35945. return m.OldAddtime(ctx)
  35946. case usagestatisticday.FieldType:
  35947. return m.OldType(ctx)
  35948. case usagestatisticday.FieldBotID:
  35949. return m.OldBotID(ctx)
  35950. case usagestatisticday.FieldOrganizationID:
  35951. return m.OldOrganizationID(ctx)
  35952. case usagestatisticday.FieldAiResponse:
  35953. return m.OldAiResponse(ctx)
  35954. case usagestatisticday.FieldSopRun:
  35955. return m.OldSopRun(ctx)
  35956. case usagestatisticday.FieldTotalFriend:
  35957. return m.OldTotalFriend(ctx)
  35958. case usagestatisticday.FieldTotalGroup:
  35959. return m.OldTotalGroup(ctx)
  35960. case usagestatisticday.FieldAccountBalance:
  35961. return m.OldAccountBalance(ctx)
  35962. case usagestatisticday.FieldConsumeToken:
  35963. return m.OldConsumeToken(ctx)
  35964. case usagestatisticday.FieldActiveUser:
  35965. return m.OldActiveUser(ctx)
  35966. case usagestatisticday.FieldNewUser:
  35967. return m.OldNewUser(ctx)
  35968. case usagestatisticday.FieldLabelDist:
  35969. return m.OldLabelDist(ctx)
  35970. case usagestatisticday.FieldConsumeCoin:
  35971. return m.OldConsumeCoin(ctx)
  35972. }
  35973. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  35974. }
  35975. // SetField sets the value of a field with the given name. It returns an error if
  35976. // the field is not defined in the schema, or if the type mismatched the field
  35977. // type.
  35978. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  35979. switch name {
  35980. case usagestatisticday.FieldCreatedAt:
  35981. v, ok := value.(time.Time)
  35982. if !ok {
  35983. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35984. }
  35985. m.SetCreatedAt(v)
  35986. return nil
  35987. case usagestatisticday.FieldUpdatedAt:
  35988. v, ok := value.(time.Time)
  35989. if !ok {
  35990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35991. }
  35992. m.SetUpdatedAt(v)
  35993. return nil
  35994. case usagestatisticday.FieldStatus:
  35995. v, ok := value.(uint8)
  35996. if !ok {
  35997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35998. }
  35999. m.SetStatus(v)
  36000. return nil
  36001. case usagestatisticday.FieldDeletedAt:
  36002. v, ok := value.(time.Time)
  36003. if !ok {
  36004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36005. }
  36006. m.SetDeletedAt(v)
  36007. return nil
  36008. case usagestatisticday.FieldAddtime:
  36009. v, ok := value.(uint64)
  36010. if !ok {
  36011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36012. }
  36013. m.SetAddtime(v)
  36014. return nil
  36015. case usagestatisticday.FieldType:
  36016. v, ok := value.(int)
  36017. if !ok {
  36018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36019. }
  36020. m.SetType(v)
  36021. return nil
  36022. case usagestatisticday.FieldBotID:
  36023. v, ok := value.(string)
  36024. if !ok {
  36025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36026. }
  36027. m.SetBotID(v)
  36028. return nil
  36029. case usagestatisticday.FieldOrganizationID:
  36030. v, ok := value.(uint64)
  36031. if !ok {
  36032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36033. }
  36034. m.SetOrganizationID(v)
  36035. return nil
  36036. case usagestatisticday.FieldAiResponse:
  36037. v, ok := value.(uint64)
  36038. if !ok {
  36039. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36040. }
  36041. m.SetAiResponse(v)
  36042. return nil
  36043. case usagestatisticday.FieldSopRun:
  36044. v, ok := value.(uint64)
  36045. if !ok {
  36046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36047. }
  36048. m.SetSopRun(v)
  36049. return nil
  36050. case usagestatisticday.FieldTotalFriend:
  36051. v, ok := value.(uint64)
  36052. if !ok {
  36053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36054. }
  36055. m.SetTotalFriend(v)
  36056. return nil
  36057. case usagestatisticday.FieldTotalGroup:
  36058. v, ok := value.(uint64)
  36059. if !ok {
  36060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36061. }
  36062. m.SetTotalGroup(v)
  36063. return nil
  36064. case usagestatisticday.FieldAccountBalance:
  36065. v, ok := value.(uint64)
  36066. if !ok {
  36067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36068. }
  36069. m.SetAccountBalance(v)
  36070. return nil
  36071. case usagestatisticday.FieldConsumeToken:
  36072. v, ok := value.(uint64)
  36073. if !ok {
  36074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36075. }
  36076. m.SetConsumeToken(v)
  36077. return nil
  36078. case usagestatisticday.FieldActiveUser:
  36079. v, ok := value.(uint64)
  36080. if !ok {
  36081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36082. }
  36083. m.SetActiveUser(v)
  36084. return nil
  36085. case usagestatisticday.FieldNewUser:
  36086. v, ok := value.(int64)
  36087. if !ok {
  36088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36089. }
  36090. m.SetNewUser(v)
  36091. return nil
  36092. case usagestatisticday.FieldLabelDist:
  36093. v, ok := value.([]custom_types.LabelDist)
  36094. if !ok {
  36095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36096. }
  36097. m.SetLabelDist(v)
  36098. return nil
  36099. case usagestatisticday.FieldConsumeCoin:
  36100. v, ok := value.(float64)
  36101. if !ok {
  36102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36103. }
  36104. m.SetConsumeCoin(v)
  36105. return nil
  36106. }
  36107. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  36108. }
  36109. // AddedFields returns all numeric fields that were incremented/decremented during
  36110. // this mutation.
  36111. func (m *UsageStatisticDayMutation) AddedFields() []string {
  36112. var fields []string
  36113. if m.addstatus != nil {
  36114. fields = append(fields, usagestatisticday.FieldStatus)
  36115. }
  36116. if m.addaddtime != nil {
  36117. fields = append(fields, usagestatisticday.FieldAddtime)
  36118. }
  36119. if m.add_type != nil {
  36120. fields = append(fields, usagestatisticday.FieldType)
  36121. }
  36122. if m.addorganization_id != nil {
  36123. fields = append(fields, usagestatisticday.FieldOrganizationID)
  36124. }
  36125. if m.addai_response != nil {
  36126. fields = append(fields, usagestatisticday.FieldAiResponse)
  36127. }
  36128. if m.addsop_run != nil {
  36129. fields = append(fields, usagestatisticday.FieldSopRun)
  36130. }
  36131. if m.addtotal_friend != nil {
  36132. fields = append(fields, usagestatisticday.FieldTotalFriend)
  36133. }
  36134. if m.addtotal_group != nil {
  36135. fields = append(fields, usagestatisticday.FieldTotalGroup)
  36136. }
  36137. if m.addaccount_balance != nil {
  36138. fields = append(fields, usagestatisticday.FieldAccountBalance)
  36139. }
  36140. if m.addconsume_token != nil {
  36141. fields = append(fields, usagestatisticday.FieldConsumeToken)
  36142. }
  36143. if m.addactive_user != nil {
  36144. fields = append(fields, usagestatisticday.FieldActiveUser)
  36145. }
  36146. if m.addnew_user != nil {
  36147. fields = append(fields, usagestatisticday.FieldNewUser)
  36148. }
  36149. if m.addconsume_coin != nil {
  36150. fields = append(fields, usagestatisticday.FieldConsumeCoin)
  36151. }
  36152. return fields
  36153. }
  36154. // AddedField returns the numeric value that was incremented/decremented on a field
  36155. // with the given name. The second boolean return value indicates that this field
  36156. // was not set, or was not defined in the schema.
  36157. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  36158. switch name {
  36159. case usagestatisticday.FieldStatus:
  36160. return m.AddedStatus()
  36161. case usagestatisticday.FieldAddtime:
  36162. return m.AddedAddtime()
  36163. case usagestatisticday.FieldType:
  36164. return m.AddedType()
  36165. case usagestatisticday.FieldOrganizationID:
  36166. return m.AddedOrganizationID()
  36167. case usagestatisticday.FieldAiResponse:
  36168. return m.AddedAiResponse()
  36169. case usagestatisticday.FieldSopRun:
  36170. return m.AddedSopRun()
  36171. case usagestatisticday.FieldTotalFriend:
  36172. return m.AddedTotalFriend()
  36173. case usagestatisticday.FieldTotalGroup:
  36174. return m.AddedTotalGroup()
  36175. case usagestatisticday.FieldAccountBalance:
  36176. return m.AddedAccountBalance()
  36177. case usagestatisticday.FieldConsumeToken:
  36178. return m.AddedConsumeToken()
  36179. case usagestatisticday.FieldActiveUser:
  36180. return m.AddedActiveUser()
  36181. case usagestatisticday.FieldNewUser:
  36182. return m.AddedNewUser()
  36183. case usagestatisticday.FieldConsumeCoin:
  36184. return m.AddedConsumeCoin()
  36185. }
  36186. return nil, false
  36187. }
  36188. // AddField adds the value to the field with the given name. It returns an error if
  36189. // the field is not defined in the schema, or if the type mismatched the field
  36190. // type.
  36191. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  36192. switch name {
  36193. case usagestatisticday.FieldStatus:
  36194. v, ok := value.(int8)
  36195. if !ok {
  36196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36197. }
  36198. m.AddStatus(v)
  36199. return nil
  36200. case usagestatisticday.FieldAddtime:
  36201. v, ok := value.(int64)
  36202. if !ok {
  36203. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36204. }
  36205. m.AddAddtime(v)
  36206. return nil
  36207. case usagestatisticday.FieldType:
  36208. v, ok := value.(int)
  36209. if !ok {
  36210. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36211. }
  36212. m.AddType(v)
  36213. return nil
  36214. case usagestatisticday.FieldOrganizationID:
  36215. v, ok := value.(int64)
  36216. if !ok {
  36217. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36218. }
  36219. m.AddOrganizationID(v)
  36220. return nil
  36221. case usagestatisticday.FieldAiResponse:
  36222. v, ok := value.(int64)
  36223. if !ok {
  36224. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36225. }
  36226. m.AddAiResponse(v)
  36227. return nil
  36228. case usagestatisticday.FieldSopRun:
  36229. v, ok := value.(int64)
  36230. if !ok {
  36231. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36232. }
  36233. m.AddSopRun(v)
  36234. return nil
  36235. case usagestatisticday.FieldTotalFriend:
  36236. v, ok := value.(int64)
  36237. if !ok {
  36238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36239. }
  36240. m.AddTotalFriend(v)
  36241. return nil
  36242. case usagestatisticday.FieldTotalGroup:
  36243. v, ok := value.(int64)
  36244. if !ok {
  36245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36246. }
  36247. m.AddTotalGroup(v)
  36248. return nil
  36249. case usagestatisticday.FieldAccountBalance:
  36250. v, ok := value.(int64)
  36251. if !ok {
  36252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36253. }
  36254. m.AddAccountBalance(v)
  36255. return nil
  36256. case usagestatisticday.FieldConsumeToken:
  36257. v, ok := value.(int64)
  36258. if !ok {
  36259. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36260. }
  36261. m.AddConsumeToken(v)
  36262. return nil
  36263. case usagestatisticday.FieldActiveUser:
  36264. v, ok := value.(int64)
  36265. if !ok {
  36266. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36267. }
  36268. m.AddActiveUser(v)
  36269. return nil
  36270. case usagestatisticday.FieldNewUser:
  36271. v, ok := value.(int64)
  36272. if !ok {
  36273. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36274. }
  36275. m.AddNewUser(v)
  36276. return nil
  36277. case usagestatisticday.FieldConsumeCoin:
  36278. v, ok := value.(float64)
  36279. if !ok {
  36280. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36281. }
  36282. m.AddConsumeCoin(v)
  36283. return nil
  36284. }
  36285. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  36286. }
  36287. // ClearedFields returns all nullable fields that were cleared during this
  36288. // mutation.
  36289. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  36290. var fields []string
  36291. if m.FieldCleared(usagestatisticday.FieldStatus) {
  36292. fields = append(fields, usagestatisticday.FieldStatus)
  36293. }
  36294. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  36295. fields = append(fields, usagestatisticday.FieldDeletedAt)
  36296. }
  36297. if m.FieldCleared(usagestatisticday.FieldBotID) {
  36298. fields = append(fields, usagestatisticday.FieldBotID)
  36299. }
  36300. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  36301. fields = append(fields, usagestatisticday.FieldOrganizationID)
  36302. }
  36303. if m.FieldCleared(usagestatisticday.FieldConsumeCoin) {
  36304. fields = append(fields, usagestatisticday.FieldConsumeCoin)
  36305. }
  36306. return fields
  36307. }
  36308. // FieldCleared returns a boolean indicating if a field with the given name was
  36309. // cleared in this mutation.
  36310. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  36311. _, ok := m.clearedFields[name]
  36312. return ok
  36313. }
  36314. // ClearField clears the value of the field with the given name. It returns an
  36315. // error if the field is not defined in the schema.
  36316. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  36317. switch name {
  36318. case usagestatisticday.FieldStatus:
  36319. m.ClearStatus()
  36320. return nil
  36321. case usagestatisticday.FieldDeletedAt:
  36322. m.ClearDeletedAt()
  36323. return nil
  36324. case usagestatisticday.FieldBotID:
  36325. m.ClearBotID()
  36326. return nil
  36327. case usagestatisticday.FieldOrganizationID:
  36328. m.ClearOrganizationID()
  36329. return nil
  36330. case usagestatisticday.FieldConsumeCoin:
  36331. m.ClearConsumeCoin()
  36332. return nil
  36333. }
  36334. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  36335. }
  36336. // ResetField resets all changes in the mutation for the field with the given name.
  36337. // It returns an error if the field is not defined in the schema.
  36338. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  36339. switch name {
  36340. case usagestatisticday.FieldCreatedAt:
  36341. m.ResetCreatedAt()
  36342. return nil
  36343. case usagestatisticday.FieldUpdatedAt:
  36344. m.ResetUpdatedAt()
  36345. return nil
  36346. case usagestatisticday.FieldStatus:
  36347. m.ResetStatus()
  36348. return nil
  36349. case usagestatisticday.FieldDeletedAt:
  36350. m.ResetDeletedAt()
  36351. return nil
  36352. case usagestatisticday.FieldAddtime:
  36353. m.ResetAddtime()
  36354. return nil
  36355. case usagestatisticday.FieldType:
  36356. m.ResetType()
  36357. return nil
  36358. case usagestatisticday.FieldBotID:
  36359. m.ResetBotID()
  36360. return nil
  36361. case usagestatisticday.FieldOrganizationID:
  36362. m.ResetOrganizationID()
  36363. return nil
  36364. case usagestatisticday.FieldAiResponse:
  36365. m.ResetAiResponse()
  36366. return nil
  36367. case usagestatisticday.FieldSopRun:
  36368. m.ResetSopRun()
  36369. return nil
  36370. case usagestatisticday.FieldTotalFriend:
  36371. m.ResetTotalFriend()
  36372. return nil
  36373. case usagestatisticday.FieldTotalGroup:
  36374. m.ResetTotalGroup()
  36375. return nil
  36376. case usagestatisticday.FieldAccountBalance:
  36377. m.ResetAccountBalance()
  36378. return nil
  36379. case usagestatisticday.FieldConsumeToken:
  36380. m.ResetConsumeToken()
  36381. return nil
  36382. case usagestatisticday.FieldActiveUser:
  36383. m.ResetActiveUser()
  36384. return nil
  36385. case usagestatisticday.FieldNewUser:
  36386. m.ResetNewUser()
  36387. return nil
  36388. case usagestatisticday.FieldLabelDist:
  36389. m.ResetLabelDist()
  36390. return nil
  36391. case usagestatisticday.FieldConsumeCoin:
  36392. m.ResetConsumeCoin()
  36393. return nil
  36394. }
  36395. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  36396. }
  36397. // AddedEdges returns all edge names that were set/added in this mutation.
  36398. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  36399. edges := make([]string, 0, 0)
  36400. return edges
  36401. }
  36402. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  36403. // name in this mutation.
  36404. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  36405. return nil
  36406. }
  36407. // RemovedEdges returns all edge names that were removed in this mutation.
  36408. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  36409. edges := make([]string, 0, 0)
  36410. return edges
  36411. }
  36412. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  36413. // the given name in this mutation.
  36414. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  36415. return nil
  36416. }
  36417. // ClearedEdges returns all edge names that were cleared in this mutation.
  36418. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  36419. edges := make([]string, 0, 0)
  36420. return edges
  36421. }
  36422. // EdgeCleared returns a boolean which indicates if the edge with the given name
  36423. // was cleared in this mutation.
  36424. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  36425. return false
  36426. }
  36427. // ClearEdge clears the value of the edge with the given name. It returns an error
  36428. // if that edge is not defined in the schema.
  36429. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  36430. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  36431. }
  36432. // ResetEdge resets all changes to the edge with the given name in this mutation.
  36433. // It returns an error if the edge is not defined in the schema.
  36434. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  36435. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  36436. }
  36437. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  36438. type UsageStatisticHourMutation struct {
  36439. config
  36440. op Op
  36441. typ string
  36442. id *uint64
  36443. created_at *time.Time
  36444. updated_at *time.Time
  36445. status *uint8
  36446. addstatus *int8
  36447. deleted_at *time.Time
  36448. addtime *uint64
  36449. addaddtime *int64
  36450. _type *int
  36451. add_type *int
  36452. bot_id *string
  36453. organization_id *uint64
  36454. addorganization_id *int64
  36455. ai_response *uint64
  36456. addai_response *int64
  36457. sop_run *uint64
  36458. addsop_run *int64
  36459. total_friend *uint64
  36460. addtotal_friend *int64
  36461. total_group *uint64
  36462. addtotal_group *int64
  36463. account_balance *uint64
  36464. addaccount_balance *int64
  36465. consume_token *uint64
  36466. addconsume_token *int64
  36467. active_user *uint64
  36468. addactive_user *int64
  36469. new_user *int64
  36470. addnew_user *int64
  36471. label_dist *[]custom_types.LabelDist
  36472. appendlabel_dist []custom_types.LabelDist
  36473. consume_coin *float64
  36474. addconsume_coin *float64
  36475. clearedFields map[string]struct{}
  36476. done bool
  36477. oldValue func(context.Context) (*UsageStatisticHour, error)
  36478. predicates []predicate.UsageStatisticHour
  36479. }
  36480. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  36481. // usagestatistichourOption allows management of the mutation configuration using functional options.
  36482. type usagestatistichourOption func(*UsageStatisticHourMutation)
  36483. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  36484. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  36485. m := &UsageStatisticHourMutation{
  36486. config: c,
  36487. op: op,
  36488. typ: TypeUsageStatisticHour,
  36489. clearedFields: make(map[string]struct{}),
  36490. }
  36491. for _, opt := range opts {
  36492. opt(m)
  36493. }
  36494. return m
  36495. }
  36496. // withUsageStatisticHourID sets the ID field of the mutation.
  36497. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  36498. return func(m *UsageStatisticHourMutation) {
  36499. var (
  36500. err error
  36501. once sync.Once
  36502. value *UsageStatisticHour
  36503. )
  36504. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  36505. once.Do(func() {
  36506. if m.done {
  36507. err = errors.New("querying old values post mutation is not allowed")
  36508. } else {
  36509. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  36510. }
  36511. })
  36512. return value, err
  36513. }
  36514. m.id = &id
  36515. }
  36516. }
  36517. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  36518. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  36519. return func(m *UsageStatisticHourMutation) {
  36520. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  36521. return node, nil
  36522. }
  36523. m.id = &node.ID
  36524. }
  36525. }
  36526. // Client returns a new `ent.Client` from the mutation. If the mutation was
  36527. // executed in a transaction (ent.Tx), a transactional client is returned.
  36528. func (m UsageStatisticHourMutation) Client() *Client {
  36529. client := &Client{config: m.config}
  36530. client.init()
  36531. return client
  36532. }
  36533. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  36534. // it returns an error otherwise.
  36535. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  36536. if _, ok := m.driver.(*txDriver); !ok {
  36537. return nil, errors.New("ent: mutation is not running in a transaction")
  36538. }
  36539. tx := &Tx{config: m.config}
  36540. tx.init()
  36541. return tx, nil
  36542. }
  36543. // SetID sets the value of the id field. Note that this
  36544. // operation is only accepted on creation of UsageStatisticHour entities.
  36545. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  36546. m.id = &id
  36547. }
  36548. // ID returns the ID value in the mutation. Note that the ID is only available
  36549. // if it was provided to the builder or after it was returned from the database.
  36550. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  36551. if m.id == nil {
  36552. return
  36553. }
  36554. return *m.id, true
  36555. }
  36556. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36557. // That means, if the mutation is applied within a transaction with an isolation level such
  36558. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36559. // or updated by the mutation.
  36560. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  36561. switch {
  36562. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36563. id, exists := m.ID()
  36564. if exists {
  36565. return []uint64{id}, nil
  36566. }
  36567. fallthrough
  36568. case m.op.Is(OpUpdate | OpDelete):
  36569. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  36570. default:
  36571. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36572. }
  36573. }
  36574. // SetCreatedAt sets the "created_at" field.
  36575. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  36576. m.created_at = &t
  36577. }
  36578. // CreatedAt returns the value of the "created_at" field in the mutation.
  36579. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  36580. v := m.created_at
  36581. if v == nil {
  36582. return
  36583. }
  36584. return *v, true
  36585. }
  36586. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  36587. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36588. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36589. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36590. if !m.op.Is(OpUpdateOne) {
  36591. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36592. }
  36593. if m.id == nil || m.oldValue == nil {
  36594. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36595. }
  36596. oldValue, err := m.oldValue(ctx)
  36597. if err != nil {
  36598. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36599. }
  36600. return oldValue.CreatedAt, nil
  36601. }
  36602. // ResetCreatedAt resets all changes to the "created_at" field.
  36603. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  36604. m.created_at = nil
  36605. }
  36606. // SetUpdatedAt sets the "updated_at" field.
  36607. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  36608. m.updated_at = &t
  36609. }
  36610. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36611. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  36612. v := m.updated_at
  36613. if v == nil {
  36614. return
  36615. }
  36616. return *v, true
  36617. }
  36618. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  36619. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36621. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36622. if !m.op.Is(OpUpdateOne) {
  36623. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36624. }
  36625. if m.id == nil || m.oldValue == nil {
  36626. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36627. }
  36628. oldValue, err := m.oldValue(ctx)
  36629. if err != nil {
  36630. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36631. }
  36632. return oldValue.UpdatedAt, nil
  36633. }
  36634. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36635. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  36636. m.updated_at = nil
  36637. }
  36638. // SetStatus sets the "status" field.
  36639. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  36640. m.status = &u
  36641. m.addstatus = nil
  36642. }
  36643. // Status returns the value of the "status" field in the mutation.
  36644. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  36645. v := m.status
  36646. if v == nil {
  36647. return
  36648. }
  36649. return *v, true
  36650. }
  36651. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  36652. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36654. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  36655. if !m.op.Is(OpUpdateOne) {
  36656. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  36657. }
  36658. if m.id == nil || m.oldValue == nil {
  36659. return v, errors.New("OldStatus requires an ID field in the mutation")
  36660. }
  36661. oldValue, err := m.oldValue(ctx)
  36662. if err != nil {
  36663. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  36664. }
  36665. return oldValue.Status, nil
  36666. }
  36667. // AddStatus adds u to the "status" field.
  36668. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  36669. if m.addstatus != nil {
  36670. *m.addstatus += u
  36671. } else {
  36672. m.addstatus = &u
  36673. }
  36674. }
  36675. // AddedStatus returns the value that was added to the "status" field in this mutation.
  36676. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  36677. v := m.addstatus
  36678. if v == nil {
  36679. return
  36680. }
  36681. return *v, true
  36682. }
  36683. // ClearStatus clears the value of the "status" field.
  36684. func (m *UsageStatisticHourMutation) ClearStatus() {
  36685. m.status = nil
  36686. m.addstatus = nil
  36687. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  36688. }
  36689. // StatusCleared returns if the "status" field was cleared in this mutation.
  36690. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  36691. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  36692. return ok
  36693. }
  36694. // ResetStatus resets all changes to the "status" field.
  36695. func (m *UsageStatisticHourMutation) ResetStatus() {
  36696. m.status = nil
  36697. m.addstatus = nil
  36698. delete(m.clearedFields, usagestatistichour.FieldStatus)
  36699. }
  36700. // SetDeletedAt sets the "deleted_at" field.
  36701. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  36702. m.deleted_at = &t
  36703. }
  36704. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  36705. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  36706. v := m.deleted_at
  36707. if v == nil {
  36708. return
  36709. }
  36710. return *v, true
  36711. }
  36712. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  36713. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36714. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36715. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  36716. if !m.op.Is(OpUpdateOne) {
  36717. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  36718. }
  36719. if m.id == nil || m.oldValue == nil {
  36720. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  36721. }
  36722. oldValue, err := m.oldValue(ctx)
  36723. if err != nil {
  36724. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  36725. }
  36726. return oldValue.DeletedAt, nil
  36727. }
  36728. // ClearDeletedAt clears the value of the "deleted_at" field.
  36729. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  36730. m.deleted_at = nil
  36731. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  36732. }
  36733. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  36734. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  36735. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  36736. return ok
  36737. }
  36738. // ResetDeletedAt resets all changes to the "deleted_at" field.
  36739. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  36740. m.deleted_at = nil
  36741. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  36742. }
  36743. // SetAddtime sets the "addtime" field.
  36744. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  36745. m.addtime = &u
  36746. m.addaddtime = nil
  36747. }
  36748. // Addtime returns the value of the "addtime" field in the mutation.
  36749. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  36750. v := m.addtime
  36751. if v == nil {
  36752. return
  36753. }
  36754. return *v, true
  36755. }
  36756. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  36757. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36758. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36759. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  36760. if !m.op.Is(OpUpdateOne) {
  36761. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  36762. }
  36763. if m.id == nil || m.oldValue == nil {
  36764. return v, errors.New("OldAddtime requires an ID field in the mutation")
  36765. }
  36766. oldValue, err := m.oldValue(ctx)
  36767. if err != nil {
  36768. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  36769. }
  36770. return oldValue.Addtime, nil
  36771. }
  36772. // AddAddtime adds u to the "addtime" field.
  36773. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  36774. if m.addaddtime != nil {
  36775. *m.addaddtime += u
  36776. } else {
  36777. m.addaddtime = &u
  36778. }
  36779. }
  36780. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  36781. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  36782. v := m.addaddtime
  36783. if v == nil {
  36784. return
  36785. }
  36786. return *v, true
  36787. }
  36788. // ResetAddtime resets all changes to the "addtime" field.
  36789. func (m *UsageStatisticHourMutation) ResetAddtime() {
  36790. m.addtime = nil
  36791. m.addaddtime = nil
  36792. }
  36793. // SetType sets the "type" field.
  36794. func (m *UsageStatisticHourMutation) SetType(i int) {
  36795. m._type = &i
  36796. m.add_type = nil
  36797. }
  36798. // GetType returns the value of the "type" field in the mutation.
  36799. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  36800. v := m._type
  36801. if v == nil {
  36802. return
  36803. }
  36804. return *v, true
  36805. }
  36806. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  36807. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36808. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36809. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  36810. if !m.op.Is(OpUpdateOne) {
  36811. return v, errors.New("OldType is only allowed on UpdateOne operations")
  36812. }
  36813. if m.id == nil || m.oldValue == nil {
  36814. return v, errors.New("OldType requires an ID field in the mutation")
  36815. }
  36816. oldValue, err := m.oldValue(ctx)
  36817. if err != nil {
  36818. return v, fmt.Errorf("querying old value for OldType: %w", err)
  36819. }
  36820. return oldValue.Type, nil
  36821. }
  36822. // AddType adds i to the "type" field.
  36823. func (m *UsageStatisticHourMutation) AddType(i int) {
  36824. if m.add_type != nil {
  36825. *m.add_type += i
  36826. } else {
  36827. m.add_type = &i
  36828. }
  36829. }
  36830. // AddedType returns the value that was added to the "type" field in this mutation.
  36831. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  36832. v := m.add_type
  36833. if v == nil {
  36834. return
  36835. }
  36836. return *v, true
  36837. }
  36838. // ResetType resets all changes to the "type" field.
  36839. func (m *UsageStatisticHourMutation) ResetType() {
  36840. m._type = nil
  36841. m.add_type = nil
  36842. }
  36843. // SetBotID sets the "bot_id" field.
  36844. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  36845. m.bot_id = &s
  36846. }
  36847. // BotID returns the value of the "bot_id" field in the mutation.
  36848. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  36849. v := m.bot_id
  36850. if v == nil {
  36851. return
  36852. }
  36853. return *v, true
  36854. }
  36855. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  36856. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36857. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36858. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  36859. if !m.op.Is(OpUpdateOne) {
  36860. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  36861. }
  36862. if m.id == nil || m.oldValue == nil {
  36863. return v, errors.New("OldBotID requires an ID field in the mutation")
  36864. }
  36865. oldValue, err := m.oldValue(ctx)
  36866. if err != nil {
  36867. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  36868. }
  36869. return oldValue.BotID, nil
  36870. }
  36871. // ClearBotID clears the value of the "bot_id" field.
  36872. func (m *UsageStatisticHourMutation) ClearBotID() {
  36873. m.bot_id = nil
  36874. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  36875. }
  36876. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  36877. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  36878. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  36879. return ok
  36880. }
  36881. // ResetBotID resets all changes to the "bot_id" field.
  36882. func (m *UsageStatisticHourMutation) ResetBotID() {
  36883. m.bot_id = nil
  36884. delete(m.clearedFields, usagestatistichour.FieldBotID)
  36885. }
  36886. // SetOrganizationID sets the "organization_id" field.
  36887. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  36888. m.organization_id = &u
  36889. m.addorganization_id = nil
  36890. }
  36891. // OrganizationID returns the value of the "organization_id" field in the mutation.
  36892. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  36893. v := m.organization_id
  36894. if v == nil {
  36895. return
  36896. }
  36897. return *v, true
  36898. }
  36899. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  36900. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36901. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36902. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  36903. if !m.op.Is(OpUpdateOne) {
  36904. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  36905. }
  36906. if m.id == nil || m.oldValue == nil {
  36907. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  36908. }
  36909. oldValue, err := m.oldValue(ctx)
  36910. if err != nil {
  36911. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  36912. }
  36913. return oldValue.OrganizationID, nil
  36914. }
  36915. // AddOrganizationID adds u to the "organization_id" field.
  36916. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  36917. if m.addorganization_id != nil {
  36918. *m.addorganization_id += u
  36919. } else {
  36920. m.addorganization_id = &u
  36921. }
  36922. }
  36923. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  36924. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  36925. v := m.addorganization_id
  36926. if v == nil {
  36927. return
  36928. }
  36929. return *v, true
  36930. }
  36931. // ClearOrganizationID clears the value of the "organization_id" field.
  36932. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  36933. m.organization_id = nil
  36934. m.addorganization_id = nil
  36935. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  36936. }
  36937. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  36938. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  36939. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  36940. return ok
  36941. }
  36942. // ResetOrganizationID resets all changes to the "organization_id" field.
  36943. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  36944. m.organization_id = nil
  36945. m.addorganization_id = nil
  36946. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  36947. }
  36948. // SetAiResponse sets the "ai_response" field.
  36949. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  36950. m.ai_response = &u
  36951. m.addai_response = nil
  36952. }
  36953. // AiResponse returns the value of the "ai_response" field in the mutation.
  36954. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  36955. v := m.ai_response
  36956. if v == nil {
  36957. return
  36958. }
  36959. return *v, true
  36960. }
  36961. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  36962. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36963. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36964. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  36965. if !m.op.Is(OpUpdateOne) {
  36966. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  36967. }
  36968. if m.id == nil || m.oldValue == nil {
  36969. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  36970. }
  36971. oldValue, err := m.oldValue(ctx)
  36972. if err != nil {
  36973. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  36974. }
  36975. return oldValue.AiResponse, nil
  36976. }
  36977. // AddAiResponse adds u to the "ai_response" field.
  36978. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  36979. if m.addai_response != nil {
  36980. *m.addai_response += u
  36981. } else {
  36982. m.addai_response = &u
  36983. }
  36984. }
  36985. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  36986. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  36987. v := m.addai_response
  36988. if v == nil {
  36989. return
  36990. }
  36991. return *v, true
  36992. }
  36993. // ResetAiResponse resets all changes to the "ai_response" field.
  36994. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  36995. m.ai_response = nil
  36996. m.addai_response = nil
  36997. }
  36998. // SetSopRun sets the "sop_run" field.
  36999. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  37000. m.sop_run = &u
  37001. m.addsop_run = nil
  37002. }
  37003. // SopRun returns the value of the "sop_run" field in the mutation.
  37004. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  37005. v := m.sop_run
  37006. if v == nil {
  37007. return
  37008. }
  37009. return *v, true
  37010. }
  37011. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  37012. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37013. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37014. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  37015. if !m.op.Is(OpUpdateOne) {
  37016. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  37017. }
  37018. if m.id == nil || m.oldValue == nil {
  37019. return v, errors.New("OldSopRun requires an ID field in the mutation")
  37020. }
  37021. oldValue, err := m.oldValue(ctx)
  37022. if err != nil {
  37023. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  37024. }
  37025. return oldValue.SopRun, nil
  37026. }
  37027. // AddSopRun adds u to the "sop_run" field.
  37028. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  37029. if m.addsop_run != nil {
  37030. *m.addsop_run += u
  37031. } else {
  37032. m.addsop_run = &u
  37033. }
  37034. }
  37035. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  37036. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  37037. v := m.addsop_run
  37038. if v == nil {
  37039. return
  37040. }
  37041. return *v, true
  37042. }
  37043. // ResetSopRun resets all changes to the "sop_run" field.
  37044. func (m *UsageStatisticHourMutation) ResetSopRun() {
  37045. m.sop_run = nil
  37046. m.addsop_run = nil
  37047. }
  37048. // SetTotalFriend sets the "total_friend" field.
  37049. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  37050. m.total_friend = &u
  37051. m.addtotal_friend = nil
  37052. }
  37053. // TotalFriend returns the value of the "total_friend" field in the mutation.
  37054. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  37055. v := m.total_friend
  37056. if v == nil {
  37057. return
  37058. }
  37059. return *v, true
  37060. }
  37061. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  37062. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37063. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37064. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  37065. if !m.op.Is(OpUpdateOne) {
  37066. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  37067. }
  37068. if m.id == nil || m.oldValue == nil {
  37069. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  37070. }
  37071. oldValue, err := m.oldValue(ctx)
  37072. if err != nil {
  37073. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  37074. }
  37075. return oldValue.TotalFriend, nil
  37076. }
  37077. // AddTotalFriend adds u to the "total_friend" field.
  37078. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  37079. if m.addtotal_friend != nil {
  37080. *m.addtotal_friend += u
  37081. } else {
  37082. m.addtotal_friend = &u
  37083. }
  37084. }
  37085. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  37086. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  37087. v := m.addtotal_friend
  37088. if v == nil {
  37089. return
  37090. }
  37091. return *v, true
  37092. }
  37093. // ResetTotalFriend resets all changes to the "total_friend" field.
  37094. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  37095. m.total_friend = nil
  37096. m.addtotal_friend = nil
  37097. }
  37098. // SetTotalGroup sets the "total_group" field.
  37099. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  37100. m.total_group = &u
  37101. m.addtotal_group = nil
  37102. }
  37103. // TotalGroup returns the value of the "total_group" field in the mutation.
  37104. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  37105. v := m.total_group
  37106. if v == nil {
  37107. return
  37108. }
  37109. return *v, true
  37110. }
  37111. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  37112. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37113. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37114. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  37115. if !m.op.Is(OpUpdateOne) {
  37116. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  37117. }
  37118. if m.id == nil || m.oldValue == nil {
  37119. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  37120. }
  37121. oldValue, err := m.oldValue(ctx)
  37122. if err != nil {
  37123. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  37124. }
  37125. return oldValue.TotalGroup, nil
  37126. }
  37127. // AddTotalGroup adds u to the "total_group" field.
  37128. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  37129. if m.addtotal_group != nil {
  37130. *m.addtotal_group += u
  37131. } else {
  37132. m.addtotal_group = &u
  37133. }
  37134. }
  37135. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  37136. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  37137. v := m.addtotal_group
  37138. if v == nil {
  37139. return
  37140. }
  37141. return *v, true
  37142. }
  37143. // ResetTotalGroup resets all changes to the "total_group" field.
  37144. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  37145. m.total_group = nil
  37146. m.addtotal_group = nil
  37147. }
  37148. // SetAccountBalance sets the "account_balance" field.
  37149. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  37150. m.account_balance = &u
  37151. m.addaccount_balance = nil
  37152. }
  37153. // AccountBalance returns the value of the "account_balance" field in the mutation.
  37154. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  37155. v := m.account_balance
  37156. if v == nil {
  37157. return
  37158. }
  37159. return *v, true
  37160. }
  37161. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  37162. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37163. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37164. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  37165. if !m.op.Is(OpUpdateOne) {
  37166. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  37167. }
  37168. if m.id == nil || m.oldValue == nil {
  37169. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  37170. }
  37171. oldValue, err := m.oldValue(ctx)
  37172. if err != nil {
  37173. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  37174. }
  37175. return oldValue.AccountBalance, nil
  37176. }
  37177. // AddAccountBalance adds u to the "account_balance" field.
  37178. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  37179. if m.addaccount_balance != nil {
  37180. *m.addaccount_balance += u
  37181. } else {
  37182. m.addaccount_balance = &u
  37183. }
  37184. }
  37185. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  37186. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  37187. v := m.addaccount_balance
  37188. if v == nil {
  37189. return
  37190. }
  37191. return *v, true
  37192. }
  37193. // ResetAccountBalance resets all changes to the "account_balance" field.
  37194. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  37195. m.account_balance = nil
  37196. m.addaccount_balance = nil
  37197. }
  37198. // SetConsumeToken sets the "consume_token" field.
  37199. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  37200. m.consume_token = &u
  37201. m.addconsume_token = nil
  37202. }
  37203. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  37204. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  37205. v := m.consume_token
  37206. if v == nil {
  37207. return
  37208. }
  37209. return *v, true
  37210. }
  37211. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  37212. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37213. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37214. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  37215. if !m.op.Is(OpUpdateOne) {
  37216. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  37217. }
  37218. if m.id == nil || m.oldValue == nil {
  37219. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  37220. }
  37221. oldValue, err := m.oldValue(ctx)
  37222. if err != nil {
  37223. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  37224. }
  37225. return oldValue.ConsumeToken, nil
  37226. }
  37227. // AddConsumeToken adds u to the "consume_token" field.
  37228. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  37229. if m.addconsume_token != nil {
  37230. *m.addconsume_token += u
  37231. } else {
  37232. m.addconsume_token = &u
  37233. }
  37234. }
  37235. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  37236. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  37237. v := m.addconsume_token
  37238. if v == nil {
  37239. return
  37240. }
  37241. return *v, true
  37242. }
  37243. // ResetConsumeToken resets all changes to the "consume_token" field.
  37244. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  37245. m.consume_token = nil
  37246. m.addconsume_token = nil
  37247. }
  37248. // SetActiveUser sets the "active_user" field.
  37249. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  37250. m.active_user = &u
  37251. m.addactive_user = nil
  37252. }
  37253. // ActiveUser returns the value of the "active_user" field in the mutation.
  37254. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  37255. v := m.active_user
  37256. if v == nil {
  37257. return
  37258. }
  37259. return *v, true
  37260. }
  37261. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  37262. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37263. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37264. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  37265. if !m.op.Is(OpUpdateOne) {
  37266. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  37267. }
  37268. if m.id == nil || m.oldValue == nil {
  37269. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  37270. }
  37271. oldValue, err := m.oldValue(ctx)
  37272. if err != nil {
  37273. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  37274. }
  37275. return oldValue.ActiveUser, nil
  37276. }
  37277. // AddActiveUser adds u to the "active_user" field.
  37278. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  37279. if m.addactive_user != nil {
  37280. *m.addactive_user += u
  37281. } else {
  37282. m.addactive_user = &u
  37283. }
  37284. }
  37285. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  37286. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  37287. v := m.addactive_user
  37288. if v == nil {
  37289. return
  37290. }
  37291. return *v, true
  37292. }
  37293. // ResetActiveUser resets all changes to the "active_user" field.
  37294. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  37295. m.active_user = nil
  37296. m.addactive_user = nil
  37297. }
  37298. // SetNewUser sets the "new_user" field.
  37299. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  37300. m.new_user = &i
  37301. m.addnew_user = nil
  37302. }
  37303. // NewUser returns the value of the "new_user" field in the mutation.
  37304. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  37305. v := m.new_user
  37306. if v == nil {
  37307. return
  37308. }
  37309. return *v, true
  37310. }
  37311. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  37312. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37313. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37314. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  37315. if !m.op.Is(OpUpdateOne) {
  37316. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  37317. }
  37318. if m.id == nil || m.oldValue == nil {
  37319. return v, errors.New("OldNewUser requires an ID field in the mutation")
  37320. }
  37321. oldValue, err := m.oldValue(ctx)
  37322. if err != nil {
  37323. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  37324. }
  37325. return oldValue.NewUser, nil
  37326. }
  37327. // AddNewUser adds i to the "new_user" field.
  37328. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  37329. if m.addnew_user != nil {
  37330. *m.addnew_user += i
  37331. } else {
  37332. m.addnew_user = &i
  37333. }
  37334. }
  37335. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  37336. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  37337. v := m.addnew_user
  37338. if v == nil {
  37339. return
  37340. }
  37341. return *v, true
  37342. }
  37343. // ResetNewUser resets all changes to the "new_user" field.
  37344. func (m *UsageStatisticHourMutation) ResetNewUser() {
  37345. m.new_user = nil
  37346. m.addnew_user = nil
  37347. }
  37348. // SetLabelDist sets the "label_dist" field.
  37349. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  37350. m.label_dist = &ctd
  37351. m.appendlabel_dist = nil
  37352. }
  37353. // LabelDist returns the value of the "label_dist" field in the mutation.
  37354. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  37355. v := m.label_dist
  37356. if v == nil {
  37357. return
  37358. }
  37359. return *v, true
  37360. }
  37361. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  37362. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37363. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37364. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  37365. if !m.op.Is(OpUpdateOne) {
  37366. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  37367. }
  37368. if m.id == nil || m.oldValue == nil {
  37369. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  37370. }
  37371. oldValue, err := m.oldValue(ctx)
  37372. if err != nil {
  37373. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  37374. }
  37375. return oldValue.LabelDist, nil
  37376. }
  37377. // AppendLabelDist adds ctd to the "label_dist" field.
  37378. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  37379. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  37380. }
  37381. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  37382. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  37383. if len(m.appendlabel_dist) == 0 {
  37384. return nil, false
  37385. }
  37386. return m.appendlabel_dist, true
  37387. }
  37388. // ResetLabelDist resets all changes to the "label_dist" field.
  37389. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  37390. m.label_dist = nil
  37391. m.appendlabel_dist = nil
  37392. }
  37393. // SetConsumeCoin sets the "consume_coin" field.
  37394. func (m *UsageStatisticHourMutation) SetConsumeCoin(f float64) {
  37395. m.consume_coin = &f
  37396. m.addconsume_coin = nil
  37397. }
  37398. // ConsumeCoin returns the value of the "consume_coin" field in the mutation.
  37399. func (m *UsageStatisticHourMutation) ConsumeCoin() (r float64, exists bool) {
  37400. v := m.consume_coin
  37401. if v == nil {
  37402. return
  37403. }
  37404. return *v, true
  37405. }
  37406. // OldConsumeCoin returns the old "consume_coin" field's value of the UsageStatisticHour entity.
  37407. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37408. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37409. func (m *UsageStatisticHourMutation) OldConsumeCoin(ctx context.Context) (v float64, err error) {
  37410. if !m.op.Is(OpUpdateOne) {
  37411. return v, errors.New("OldConsumeCoin is only allowed on UpdateOne operations")
  37412. }
  37413. if m.id == nil || m.oldValue == nil {
  37414. return v, errors.New("OldConsumeCoin requires an ID field in the mutation")
  37415. }
  37416. oldValue, err := m.oldValue(ctx)
  37417. if err != nil {
  37418. return v, fmt.Errorf("querying old value for OldConsumeCoin: %w", err)
  37419. }
  37420. return oldValue.ConsumeCoin, nil
  37421. }
  37422. // AddConsumeCoin adds f to the "consume_coin" field.
  37423. func (m *UsageStatisticHourMutation) AddConsumeCoin(f float64) {
  37424. if m.addconsume_coin != nil {
  37425. *m.addconsume_coin += f
  37426. } else {
  37427. m.addconsume_coin = &f
  37428. }
  37429. }
  37430. // AddedConsumeCoin returns the value that was added to the "consume_coin" field in this mutation.
  37431. func (m *UsageStatisticHourMutation) AddedConsumeCoin() (r float64, exists bool) {
  37432. v := m.addconsume_coin
  37433. if v == nil {
  37434. return
  37435. }
  37436. return *v, true
  37437. }
  37438. // ClearConsumeCoin clears the value of the "consume_coin" field.
  37439. func (m *UsageStatisticHourMutation) ClearConsumeCoin() {
  37440. m.consume_coin = nil
  37441. m.addconsume_coin = nil
  37442. m.clearedFields[usagestatistichour.FieldConsumeCoin] = struct{}{}
  37443. }
  37444. // ConsumeCoinCleared returns if the "consume_coin" field was cleared in this mutation.
  37445. func (m *UsageStatisticHourMutation) ConsumeCoinCleared() bool {
  37446. _, ok := m.clearedFields[usagestatistichour.FieldConsumeCoin]
  37447. return ok
  37448. }
  37449. // ResetConsumeCoin resets all changes to the "consume_coin" field.
  37450. func (m *UsageStatisticHourMutation) ResetConsumeCoin() {
  37451. m.consume_coin = nil
  37452. m.addconsume_coin = nil
  37453. delete(m.clearedFields, usagestatistichour.FieldConsumeCoin)
  37454. }
  37455. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  37456. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  37457. m.predicates = append(m.predicates, ps...)
  37458. }
  37459. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  37460. // users can use type-assertion to append predicates that do not depend on any generated package.
  37461. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  37462. p := make([]predicate.UsageStatisticHour, len(ps))
  37463. for i := range ps {
  37464. p[i] = ps[i]
  37465. }
  37466. m.Where(p...)
  37467. }
  37468. // Op returns the operation name.
  37469. func (m *UsageStatisticHourMutation) Op() Op {
  37470. return m.op
  37471. }
  37472. // SetOp allows setting the mutation operation.
  37473. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  37474. m.op = op
  37475. }
  37476. // Type returns the node type of this mutation (UsageStatisticHour).
  37477. func (m *UsageStatisticHourMutation) Type() string {
  37478. return m.typ
  37479. }
  37480. // Fields returns all fields that were changed during this mutation. Note that in
  37481. // order to get all numeric fields that were incremented/decremented, call
  37482. // AddedFields().
  37483. func (m *UsageStatisticHourMutation) Fields() []string {
  37484. fields := make([]string, 0, 18)
  37485. if m.created_at != nil {
  37486. fields = append(fields, usagestatistichour.FieldCreatedAt)
  37487. }
  37488. if m.updated_at != nil {
  37489. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  37490. }
  37491. if m.status != nil {
  37492. fields = append(fields, usagestatistichour.FieldStatus)
  37493. }
  37494. if m.deleted_at != nil {
  37495. fields = append(fields, usagestatistichour.FieldDeletedAt)
  37496. }
  37497. if m.addtime != nil {
  37498. fields = append(fields, usagestatistichour.FieldAddtime)
  37499. }
  37500. if m._type != nil {
  37501. fields = append(fields, usagestatistichour.FieldType)
  37502. }
  37503. if m.bot_id != nil {
  37504. fields = append(fields, usagestatistichour.FieldBotID)
  37505. }
  37506. if m.organization_id != nil {
  37507. fields = append(fields, usagestatistichour.FieldOrganizationID)
  37508. }
  37509. if m.ai_response != nil {
  37510. fields = append(fields, usagestatistichour.FieldAiResponse)
  37511. }
  37512. if m.sop_run != nil {
  37513. fields = append(fields, usagestatistichour.FieldSopRun)
  37514. }
  37515. if m.total_friend != nil {
  37516. fields = append(fields, usagestatistichour.FieldTotalFriend)
  37517. }
  37518. if m.total_group != nil {
  37519. fields = append(fields, usagestatistichour.FieldTotalGroup)
  37520. }
  37521. if m.account_balance != nil {
  37522. fields = append(fields, usagestatistichour.FieldAccountBalance)
  37523. }
  37524. if m.consume_token != nil {
  37525. fields = append(fields, usagestatistichour.FieldConsumeToken)
  37526. }
  37527. if m.active_user != nil {
  37528. fields = append(fields, usagestatistichour.FieldActiveUser)
  37529. }
  37530. if m.new_user != nil {
  37531. fields = append(fields, usagestatistichour.FieldNewUser)
  37532. }
  37533. if m.label_dist != nil {
  37534. fields = append(fields, usagestatistichour.FieldLabelDist)
  37535. }
  37536. if m.consume_coin != nil {
  37537. fields = append(fields, usagestatistichour.FieldConsumeCoin)
  37538. }
  37539. return fields
  37540. }
  37541. // Field returns the value of a field with the given name. The second boolean
  37542. // return value indicates that this field was not set, or was not defined in the
  37543. // schema.
  37544. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  37545. switch name {
  37546. case usagestatistichour.FieldCreatedAt:
  37547. return m.CreatedAt()
  37548. case usagestatistichour.FieldUpdatedAt:
  37549. return m.UpdatedAt()
  37550. case usagestatistichour.FieldStatus:
  37551. return m.Status()
  37552. case usagestatistichour.FieldDeletedAt:
  37553. return m.DeletedAt()
  37554. case usagestatistichour.FieldAddtime:
  37555. return m.Addtime()
  37556. case usagestatistichour.FieldType:
  37557. return m.GetType()
  37558. case usagestatistichour.FieldBotID:
  37559. return m.BotID()
  37560. case usagestatistichour.FieldOrganizationID:
  37561. return m.OrganizationID()
  37562. case usagestatistichour.FieldAiResponse:
  37563. return m.AiResponse()
  37564. case usagestatistichour.FieldSopRun:
  37565. return m.SopRun()
  37566. case usagestatistichour.FieldTotalFriend:
  37567. return m.TotalFriend()
  37568. case usagestatistichour.FieldTotalGroup:
  37569. return m.TotalGroup()
  37570. case usagestatistichour.FieldAccountBalance:
  37571. return m.AccountBalance()
  37572. case usagestatistichour.FieldConsumeToken:
  37573. return m.ConsumeToken()
  37574. case usagestatistichour.FieldActiveUser:
  37575. return m.ActiveUser()
  37576. case usagestatistichour.FieldNewUser:
  37577. return m.NewUser()
  37578. case usagestatistichour.FieldLabelDist:
  37579. return m.LabelDist()
  37580. case usagestatistichour.FieldConsumeCoin:
  37581. return m.ConsumeCoin()
  37582. }
  37583. return nil, false
  37584. }
  37585. // OldField returns the old value of the field from the database. An error is
  37586. // returned if the mutation operation is not UpdateOne, or the query to the
  37587. // database failed.
  37588. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37589. switch name {
  37590. case usagestatistichour.FieldCreatedAt:
  37591. return m.OldCreatedAt(ctx)
  37592. case usagestatistichour.FieldUpdatedAt:
  37593. return m.OldUpdatedAt(ctx)
  37594. case usagestatistichour.FieldStatus:
  37595. return m.OldStatus(ctx)
  37596. case usagestatistichour.FieldDeletedAt:
  37597. return m.OldDeletedAt(ctx)
  37598. case usagestatistichour.FieldAddtime:
  37599. return m.OldAddtime(ctx)
  37600. case usagestatistichour.FieldType:
  37601. return m.OldType(ctx)
  37602. case usagestatistichour.FieldBotID:
  37603. return m.OldBotID(ctx)
  37604. case usagestatistichour.FieldOrganizationID:
  37605. return m.OldOrganizationID(ctx)
  37606. case usagestatistichour.FieldAiResponse:
  37607. return m.OldAiResponse(ctx)
  37608. case usagestatistichour.FieldSopRun:
  37609. return m.OldSopRun(ctx)
  37610. case usagestatistichour.FieldTotalFriend:
  37611. return m.OldTotalFriend(ctx)
  37612. case usagestatistichour.FieldTotalGroup:
  37613. return m.OldTotalGroup(ctx)
  37614. case usagestatistichour.FieldAccountBalance:
  37615. return m.OldAccountBalance(ctx)
  37616. case usagestatistichour.FieldConsumeToken:
  37617. return m.OldConsumeToken(ctx)
  37618. case usagestatistichour.FieldActiveUser:
  37619. return m.OldActiveUser(ctx)
  37620. case usagestatistichour.FieldNewUser:
  37621. return m.OldNewUser(ctx)
  37622. case usagestatistichour.FieldLabelDist:
  37623. return m.OldLabelDist(ctx)
  37624. case usagestatistichour.FieldConsumeCoin:
  37625. return m.OldConsumeCoin(ctx)
  37626. }
  37627. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  37628. }
  37629. // SetField sets the value of a field with the given name. It returns an error if
  37630. // the field is not defined in the schema, or if the type mismatched the field
  37631. // type.
  37632. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  37633. switch name {
  37634. case usagestatistichour.FieldCreatedAt:
  37635. v, ok := value.(time.Time)
  37636. if !ok {
  37637. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37638. }
  37639. m.SetCreatedAt(v)
  37640. return nil
  37641. case usagestatistichour.FieldUpdatedAt:
  37642. v, ok := value.(time.Time)
  37643. if !ok {
  37644. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37645. }
  37646. m.SetUpdatedAt(v)
  37647. return nil
  37648. case usagestatistichour.FieldStatus:
  37649. v, ok := value.(uint8)
  37650. if !ok {
  37651. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37652. }
  37653. m.SetStatus(v)
  37654. return nil
  37655. case usagestatistichour.FieldDeletedAt:
  37656. v, ok := value.(time.Time)
  37657. if !ok {
  37658. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37659. }
  37660. m.SetDeletedAt(v)
  37661. return nil
  37662. case usagestatistichour.FieldAddtime:
  37663. v, ok := value.(uint64)
  37664. if !ok {
  37665. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37666. }
  37667. m.SetAddtime(v)
  37668. return nil
  37669. case usagestatistichour.FieldType:
  37670. v, ok := value.(int)
  37671. if !ok {
  37672. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37673. }
  37674. m.SetType(v)
  37675. return nil
  37676. case usagestatistichour.FieldBotID:
  37677. v, ok := value.(string)
  37678. if !ok {
  37679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37680. }
  37681. m.SetBotID(v)
  37682. return nil
  37683. case usagestatistichour.FieldOrganizationID:
  37684. v, ok := value.(uint64)
  37685. if !ok {
  37686. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37687. }
  37688. m.SetOrganizationID(v)
  37689. return nil
  37690. case usagestatistichour.FieldAiResponse:
  37691. v, ok := value.(uint64)
  37692. if !ok {
  37693. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37694. }
  37695. m.SetAiResponse(v)
  37696. return nil
  37697. case usagestatistichour.FieldSopRun:
  37698. v, ok := value.(uint64)
  37699. if !ok {
  37700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37701. }
  37702. m.SetSopRun(v)
  37703. return nil
  37704. case usagestatistichour.FieldTotalFriend:
  37705. v, ok := value.(uint64)
  37706. if !ok {
  37707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37708. }
  37709. m.SetTotalFriend(v)
  37710. return nil
  37711. case usagestatistichour.FieldTotalGroup:
  37712. v, ok := value.(uint64)
  37713. if !ok {
  37714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37715. }
  37716. m.SetTotalGroup(v)
  37717. return nil
  37718. case usagestatistichour.FieldAccountBalance:
  37719. v, ok := value.(uint64)
  37720. if !ok {
  37721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37722. }
  37723. m.SetAccountBalance(v)
  37724. return nil
  37725. case usagestatistichour.FieldConsumeToken:
  37726. v, ok := value.(uint64)
  37727. if !ok {
  37728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37729. }
  37730. m.SetConsumeToken(v)
  37731. return nil
  37732. case usagestatistichour.FieldActiveUser:
  37733. v, ok := value.(uint64)
  37734. if !ok {
  37735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37736. }
  37737. m.SetActiveUser(v)
  37738. return nil
  37739. case usagestatistichour.FieldNewUser:
  37740. v, ok := value.(int64)
  37741. if !ok {
  37742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37743. }
  37744. m.SetNewUser(v)
  37745. return nil
  37746. case usagestatistichour.FieldLabelDist:
  37747. v, ok := value.([]custom_types.LabelDist)
  37748. if !ok {
  37749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37750. }
  37751. m.SetLabelDist(v)
  37752. return nil
  37753. case usagestatistichour.FieldConsumeCoin:
  37754. v, ok := value.(float64)
  37755. if !ok {
  37756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37757. }
  37758. m.SetConsumeCoin(v)
  37759. return nil
  37760. }
  37761. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  37762. }
  37763. // AddedFields returns all numeric fields that were incremented/decremented during
  37764. // this mutation.
  37765. func (m *UsageStatisticHourMutation) AddedFields() []string {
  37766. var fields []string
  37767. if m.addstatus != nil {
  37768. fields = append(fields, usagestatistichour.FieldStatus)
  37769. }
  37770. if m.addaddtime != nil {
  37771. fields = append(fields, usagestatistichour.FieldAddtime)
  37772. }
  37773. if m.add_type != nil {
  37774. fields = append(fields, usagestatistichour.FieldType)
  37775. }
  37776. if m.addorganization_id != nil {
  37777. fields = append(fields, usagestatistichour.FieldOrganizationID)
  37778. }
  37779. if m.addai_response != nil {
  37780. fields = append(fields, usagestatistichour.FieldAiResponse)
  37781. }
  37782. if m.addsop_run != nil {
  37783. fields = append(fields, usagestatistichour.FieldSopRun)
  37784. }
  37785. if m.addtotal_friend != nil {
  37786. fields = append(fields, usagestatistichour.FieldTotalFriend)
  37787. }
  37788. if m.addtotal_group != nil {
  37789. fields = append(fields, usagestatistichour.FieldTotalGroup)
  37790. }
  37791. if m.addaccount_balance != nil {
  37792. fields = append(fields, usagestatistichour.FieldAccountBalance)
  37793. }
  37794. if m.addconsume_token != nil {
  37795. fields = append(fields, usagestatistichour.FieldConsumeToken)
  37796. }
  37797. if m.addactive_user != nil {
  37798. fields = append(fields, usagestatistichour.FieldActiveUser)
  37799. }
  37800. if m.addnew_user != nil {
  37801. fields = append(fields, usagestatistichour.FieldNewUser)
  37802. }
  37803. if m.addconsume_coin != nil {
  37804. fields = append(fields, usagestatistichour.FieldConsumeCoin)
  37805. }
  37806. return fields
  37807. }
  37808. // AddedField returns the numeric value that was incremented/decremented on a field
  37809. // with the given name. The second boolean return value indicates that this field
  37810. // was not set, or was not defined in the schema.
  37811. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  37812. switch name {
  37813. case usagestatistichour.FieldStatus:
  37814. return m.AddedStatus()
  37815. case usagestatistichour.FieldAddtime:
  37816. return m.AddedAddtime()
  37817. case usagestatistichour.FieldType:
  37818. return m.AddedType()
  37819. case usagestatistichour.FieldOrganizationID:
  37820. return m.AddedOrganizationID()
  37821. case usagestatistichour.FieldAiResponse:
  37822. return m.AddedAiResponse()
  37823. case usagestatistichour.FieldSopRun:
  37824. return m.AddedSopRun()
  37825. case usagestatistichour.FieldTotalFriend:
  37826. return m.AddedTotalFriend()
  37827. case usagestatistichour.FieldTotalGroup:
  37828. return m.AddedTotalGroup()
  37829. case usagestatistichour.FieldAccountBalance:
  37830. return m.AddedAccountBalance()
  37831. case usagestatistichour.FieldConsumeToken:
  37832. return m.AddedConsumeToken()
  37833. case usagestatistichour.FieldActiveUser:
  37834. return m.AddedActiveUser()
  37835. case usagestatistichour.FieldNewUser:
  37836. return m.AddedNewUser()
  37837. case usagestatistichour.FieldConsumeCoin:
  37838. return m.AddedConsumeCoin()
  37839. }
  37840. return nil, false
  37841. }
  37842. // AddField adds the value to the field with the given name. It returns an error if
  37843. // the field is not defined in the schema, or if the type mismatched the field
  37844. // type.
  37845. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  37846. switch name {
  37847. case usagestatistichour.FieldStatus:
  37848. v, ok := value.(int8)
  37849. if !ok {
  37850. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37851. }
  37852. m.AddStatus(v)
  37853. return nil
  37854. case usagestatistichour.FieldAddtime:
  37855. v, ok := value.(int64)
  37856. if !ok {
  37857. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37858. }
  37859. m.AddAddtime(v)
  37860. return nil
  37861. case usagestatistichour.FieldType:
  37862. v, ok := value.(int)
  37863. if !ok {
  37864. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37865. }
  37866. m.AddType(v)
  37867. return nil
  37868. case usagestatistichour.FieldOrganizationID:
  37869. v, ok := value.(int64)
  37870. if !ok {
  37871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37872. }
  37873. m.AddOrganizationID(v)
  37874. return nil
  37875. case usagestatistichour.FieldAiResponse:
  37876. v, ok := value.(int64)
  37877. if !ok {
  37878. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37879. }
  37880. m.AddAiResponse(v)
  37881. return nil
  37882. case usagestatistichour.FieldSopRun:
  37883. v, ok := value.(int64)
  37884. if !ok {
  37885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37886. }
  37887. m.AddSopRun(v)
  37888. return nil
  37889. case usagestatistichour.FieldTotalFriend:
  37890. v, ok := value.(int64)
  37891. if !ok {
  37892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37893. }
  37894. m.AddTotalFriend(v)
  37895. return nil
  37896. case usagestatistichour.FieldTotalGroup:
  37897. v, ok := value.(int64)
  37898. if !ok {
  37899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37900. }
  37901. m.AddTotalGroup(v)
  37902. return nil
  37903. case usagestatistichour.FieldAccountBalance:
  37904. v, ok := value.(int64)
  37905. if !ok {
  37906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37907. }
  37908. m.AddAccountBalance(v)
  37909. return nil
  37910. case usagestatistichour.FieldConsumeToken:
  37911. v, ok := value.(int64)
  37912. if !ok {
  37913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37914. }
  37915. m.AddConsumeToken(v)
  37916. return nil
  37917. case usagestatistichour.FieldActiveUser:
  37918. v, ok := value.(int64)
  37919. if !ok {
  37920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37921. }
  37922. m.AddActiveUser(v)
  37923. return nil
  37924. case usagestatistichour.FieldNewUser:
  37925. v, ok := value.(int64)
  37926. if !ok {
  37927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37928. }
  37929. m.AddNewUser(v)
  37930. return nil
  37931. case usagestatistichour.FieldConsumeCoin:
  37932. v, ok := value.(float64)
  37933. if !ok {
  37934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37935. }
  37936. m.AddConsumeCoin(v)
  37937. return nil
  37938. }
  37939. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  37940. }
  37941. // ClearedFields returns all nullable fields that were cleared during this
  37942. // mutation.
  37943. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  37944. var fields []string
  37945. if m.FieldCleared(usagestatistichour.FieldStatus) {
  37946. fields = append(fields, usagestatistichour.FieldStatus)
  37947. }
  37948. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  37949. fields = append(fields, usagestatistichour.FieldDeletedAt)
  37950. }
  37951. if m.FieldCleared(usagestatistichour.FieldBotID) {
  37952. fields = append(fields, usagestatistichour.FieldBotID)
  37953. }
  37954. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  37955. fields = append(fields, usagestatistichour.FieldOrganizationID)
  37956. }
  37957. if m.FieldCleared(usagestatistichour.FieldConsumeCoin) {
  37958. fields = append(fields, usagestatistichour.FieldConsumeCoin)
  37959. }
  37960. return fields
  37961. }
  37962. // FieldCleared returns a boolean indicating if a field with the given name was
  37963. // cleared in this mutation.
  37964. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  37965. _, ok := m.clearedFields[name]
  37966. return ok
  37967. }
  37968. // ClearField clears the value of the field with the given name. It returns an
  37969. // error if the field is not defined in the schema.
  37970. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  37971. switch name {
  37972. case usagestatistichour.FieldStatus:
  37973. m.ClearStatus()
  37974. return nil
  37975. case usagestatistichour.FieldDeletedAt:
  37976. m.ClearDeletedAt()
  37977. return nil
  37978. case usagestatistichour.FieldBotID:
  37979. m.ClearBotID()
  37980. return nil
  37981. case usagestatistichour.FieldOrganizationID:
  37982. m.ClearOrganizationID()
  37983. return nil
  37984. case usagestatistichour.FieldConsumeCoin:
  37985. m.ClearConsumeCoin()
  37986. return nil
  37987. }
  37988. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  37989. }
  37990. // ResetField resets all changes in the mutation for the field with the given name.
  37991. // It returns an error if the field is not defined in the schema.
  37992. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  37993. switch name {
  37994. case usagestatistichour.FieldCreatedAt:
  37995. m.ResetCreatedAt()
  37996. return nil
  37997. case usagestatistichour.FieldUpdatedAt:
  37998. m.ResetUpdatedAt()
  37999. return nil
  38000. case usagestatistichour.FieldStatus:
  38001. m.ResetStatus()
  38002. return nil
  38003. case usagestatistichour.FieldDeletedAt:
  38004. m.ResetDeletedAt()
  38005. return nil
  38006. case usagestatistichour.FieldAddtime:
  38007. m.ResetAddtime()
  38008. return nil
  38009. case usagestatistichour.FieldType:
  38010. m.ResetType()
  38011. return nil
  38012. case usagestatistichour.FieldBotID:
  38013. m.ResetBotID()
  38014. return nil
  38015. case usagestatistichour.FieldOrganizationID:
  38016. m.ResetOrganizationID()
  38017. return nil
  38018. case usagestatistichour.FieldAiResponse:
  38019. m.ResetAiResponse()
  38020. return nil
  38021. case usagestatistichour.FieldSopRun:
  38022. m.ResetSopRun()
  38023. return nil
  38024. case usagestatistichour.FieldTotalFriend:
  38025. m.ResetTotalFriend()
  38026. return nil
  38027. case usagestatistichour.FieldTotalGroup:
  38028. m.ResetTotalGroup()
  38029. return nil
  38030. case usagestatistichour.FieldAccountBalance:
  38031. m.ResetAccountBalance()
  38032. return nil
  38033. case usagestatistichour.FieldConsumeToken:
  38034. m.ResetConsumeToken()
  38035. return nil
  38036. case usagestatistichour.FieldActiveUser:
  38037. m.ResetActiveUser()
  38038. return nil
  38039. case usagestatistichour.FieldNewUser:
  38040. m.ResetNewUser()
  38041. return nil
  38042. case usagestatistichour.FieldLabelDist:
  38043. m.ResetLabelDist()
  38044. return nil
  38045. case usagestatistichour.FieldConsumeCoin:
  38046. m.ResetConsumeCoin()
  38047. return nil
  38048. }
  38049. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  38050. }
  38051. // AddedEdges returns all edge names that were set/added in this mutation.
  38052. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  38053. edges := make([]string, 0, 0)
  38054. return edges
  38055. }
  38056. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  38057. // name in this mutation.
  38058. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  38059. return nil
  38060. }
  38061. // RemovedEdges returns all edge names that were removed in this mutation.
  38062. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  38063. edges := make([]string, 0, 0)
  38064. return edges
  38065. }
  38066. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  38067. // the given name in this mutation.
  38068. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  38069. return nil
  38070. }
  38071. // ClearedEdges returns all edge names that were cleared in this mutation.
  38072. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  38073. edges := make([]string, 0, 0)
  38074. return edges
  38075. }
  38076. // EdgeCleared returns a boolean which indicates if the edge with the given name
  38077. // was cleared in this mutation.
  38078. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  38079. return false
  38080. }
  38081. // ClearEdge clears the value of the edge with the given name. It returns an error
  38082. // if that edge is not defined in the schema.
  38083. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  38084. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  38085. }
  38086. // ResetEdge resets all changes to the edge with the given name in this mutation.
  38087. // It returns an error if the edge is not defined in the schema.
  38088. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  38089. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  38090. }
  38091. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  38092. type UsageStatisticMonthMutation struct {
  38093. config
  38094. op Op
  38095. typ string
  38096. id *uint64
  38097. created_at *time.Time
  38098. updated_at *time.Time
  38099. status *uint8
  38100. addstatus *int8
  38101. deleted_at *time.Time
  38102. addtime *uint64
  38103. addaddtime *int64
  38104. _type *int
  38105. add_type *int
  38106. bot_id *string
  38107. organization_id *uint64
  38108. addorganization_id *int64
  38109. ai_response *uint64
  38110. addai_response *int64
  38111. sop_run *uint64
  38112. addsop_run *int64
  38113. total_friend *uint64
  38114. addtotal_friend *int64
  38115. total_group *uint64
  38116. addtotal_group *int64
  38117. account_balance *uint64
  38118. addaccount_balance *int64
  38119. consume_token *uint64
  38120. addconsume_token *int64
  38121. active_user *uint64
  38122. addactive_user *int64
  38123. new_user *int64
  38124. addnew_user *int64
  38125. label_dist *[]custom_types.LabelDist
  38126. appendlabel_dist []custom_types.LabelDist
  38127. consume_coin *float64
  38128. addconsume_coin *float64
  38129. clearedFields map[string]struct{}
  38130. done bool
  38131. oldValue func(context.Context) (*UsageStatisticMonth, error)
  38132. predicates []predicate.UsageStatisticMonth
  38133. }
  38134. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  38135. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  38136. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  38137. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  38138. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  38139. m := &UsageStatisticMonthMutation{
  38140. config: c,
  38141. op: op,
  38142. typ: TypeUsageStatisticMonth,
  38143. clearedFields: make(map[string]struct{}),
  38144. }
  38145. for _, opt := range opts {
  38146. opt(m)
  38147. }
  38148. return m
  38149. }
  38150. // withUsageStatisticMonthID sets the ID field of the mutation.
  38151. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  38152. return func(m *UsageStatisticMonthMutation) {
  38153. var (
  38154. err error
  38155. once sync.Once
  38156. value *UsageStatisticMonth
  38157. )
  38158. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  38159. once.Do(func() {
  38160. if m.done {
  38161. err = errors.New("querying old values post mutation is not allowed")
  38162. } else {
  38163. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  38164. }
  38165. })
  38166. return value, err
  38167. }
  38168. m.id = &id
  38169. }
  38170. }
  38171. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  38172. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  38173. return func(m *UsageStatisticMonthMutation) {
  38174. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  38175. return node, nil
  38176. }
  38177. m.id = &node.ID
  38178. }
  38179. }
  38180. // Client returns a new `ent.Client` from the mutation. If the mutation was
  38181. // executed in a transaction (ent.Tx), a transactional client is returned.
  38182. func (m UsageStatisticMonthMutation) Client() *Client {
  38183. client := &Client{config: m.config}
  38184. client.init()
  38185. return client
  38186. }
  38187. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  38188. // it returns an error otherwise.
  38189. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  38190. if _, ok := m.driver.(*txDriver); !ok {
  38191. return nil, errors.New("ent: mutation is not running in a transaction")
  38192. }
  38193. tx := &Tx{config: m.config}
  38194. tx.init()
  38195. return tx, nil
  38196. }
  38197. // SetID sets the value of the id field. Note that this
  38198. // operation is only accepted on creation of UsageStatisticMonth entities.
  38199. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  38200. m.id = &id
  38201. }
  38202. // ID returns the ID value in the mutation. Note that the ID is only available
  38203. // if it was provided to the builder or after it was returned from the database.
  38204. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  38205. if m.id == nil {
  38206. return
  38207. }
  38208. return *m.id, true
  38209. }
  38210. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  38211. // That means, if the mutation is applied within a transaction with an isolation level such
  38212. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  38213. // or updated by the mutation.
  38214. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  38215. switch {
  38216. case m.op.Is(OpUpdateOne | OpDeleteOne):
  38217. id, exists := m.ID()
  38218. if exists {
  38219. return []uint64{id}, nil
  38220. }
  38221. fallthrough
  38222. case m.op.Is(OpUpdate | OpDelete):
  38223. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  38224. default:
  38225. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  38226. }
  38227. }
  38228. // SetCreatedAt sets the "created_at" field.
  38229. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  38230. m.created_at = &t
  38231. }
  38232. // CreatedAt returns the value of the "created_at" field in the mutation.
  38233. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  38234. v := m.created_at
  38235. if v == nil {
  38236. return
  38237. }
  38238. return *v, true
  38239. }
  38240. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  38241. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  38242. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38243. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  38244. if !m.op.Is(OpUpdateOne) {
  38245. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  38246. }
  38247. if m.id == nil || m.oldValue == nil {
  38248. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  38249. }
  38250. oldValue, err := m.oldValue(ctx)
  38251. if err != nil {
  38252. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  38253. }
  38254. return oldValue.CreatedAt, nil
  38255. }
  38256. // ResetCreatedAt resets all changes to the "created_at" field.
  38257. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  38258. m.created_at = nil
  38259. }
  38260. // SetUpdatedAt sets the "updated_at" field.
  38261. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  38262. m.updated_at = &t
  38263. }
  38264. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  38265. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  38266. v := m.updated_at
  38267. if v == nil {
  38268. return
  38269. }
  38270. return *v, true
  38271. }
  38272. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  38273. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  38274. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38275. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  38276. if !m.op.Is(OpUpdateOne) {
  38277. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  38278. }
  38279. if m.id == nil || m.oldValue == nil {
  38280. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  38281. }
  38282. oldValue, err := m.oldValue(ctx)
  38283. if err != nil {
  38284. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  38285. }
  38286. return oldValue.UpdatedAt, nil
  38287. }
  38288. // ResetUpdatedAt resets all changes to the "updated_at" field.
  38289. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  38290. m.updated_at = nil
  38291. }
  38292. // SetStatus sets the "status" field.
  38293. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  38294. m.status = &u
  38295. m.addstatus = nil
  38296. }
  38297. // Status returns the value of the "status" field in the mutation.
  38298. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  38299. v := m.status
  38300. if v == nil {
  38301. return
  38302. }
  38303. return *v, true
  38304. }
  38305. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  38306. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  38307. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38308. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  38309. if !m.op.Is(OpUpdateOne) {
  38310. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  38311. }
  38312. if m.id == nil || m.oldValue == nil {
  38313. return v, errors.New("OldStatus requires an ID field in the mutation")
  38314. }
  38315. oldValue, err := m.oldValue(ctx)
  38316. if err != nil {
  38317. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  38318. }
  38319. return oldValue.Status, nil
  38320. }
  38321. // AddStatus adds u to the "status" field.
  38322. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  38323. if m.addstatus != nil {
  38324. *m.addstatus += u
  38325. } else {
  38326. m.addstatus = &u
  38327. }
  38328. }
  38329. // AddedStatus returns the value that was added to the "status" field in this mutation.
  38330. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  38331. v := m.addstatus
  38332. if v == nil {
  38333. return
  38334. }
  38335. return *v, true
  38336. }
  38337. // ClearStatus clears the value of the "status" field.
  38338. func (m *UsageStatisticMonthMutation) ClearStatus() {
  38339. m.status = nil
  38340. m.addstatus = nil
  38341. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  38342. }
  38343. // StatusCleared returns if the "status" field was cleared in this mutation.
  38344. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  38345. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  38346. return ok
  38347. }
  38348. // ResetStatus resets all changes to the "status" field.
  38349. func (m *UsageStatisticMonthMutation) ResetStatus() {
  38350. m.status = nil
  38351. m.addstatus = nil
  38352. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  38353. }
  38354. // SetDeletedAt sets the "deleted_at" field.
  38355. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  38356. m.deleted_at = &t
  38357. }
  38358. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  38359. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  38360. v := m.deleted_at
  38361. if v == nil {
  38362. return
  38363. }
  38364. return *v, true
  38365. }
  38366. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  38367. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  38368. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38369. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  38370. if !m.op.Is(OpUpdateOne) {
  38371. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  38372. }
  38373. if m.id == nil || m.oldValue == nil {
  38374. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  38375. }
  38376. oldValue, err := m.oldValue(ctx)
  38377. if err != nil {
  38378. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  38379. }
  38380. return oldValue.DeletedAt, nil
  38381. }
  38382. // ClearDeletedAt clears the value of the "deleted_at" field.
  38383. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  38384. m.deleted_at = nil
  38385. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  38386. }
  38387. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  38388. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  38389. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  38390. return ok
  38391. }
  38392. // ResetDeletedAt resets all changes to the "deleted_at" field.
  38393. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  38394. m.deleted_at = nil
  38395. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  38396. }
  38397. // SetAddtime sets the "addtime" field.
  38398. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  38399. m.addtime = &u
  38400. m.addaddtime = nil
  38401. }
  38402. // Addtime returns the value of the "addtime" field in the mutation.
  38403. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  38404. v := m.addtime
  38405. if v == nil {
  38406. return
  38407. }
  38408. return *v, true
  38409. }
  38410. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  38411. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  38412. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38413. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  38414. if !m.op.Is(OpUpdateOne) {
  38415. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  38416. }
  38417. if m.id == nil || m.oldValue == nil {
  38418. return v, errors.New("OldAddtime requires an ID field in the mutation")
  38419. }
  38420. oldValue, err := m.oldValue(ctx)
  38421. if err != nil {
  38422. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  38423. }
  38424. return oldValue.Addtime, nil
  38425. }
  38426. // AddAddtime adds u to the "addtime" field.
  38427. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  38428. if m.addaddtime != nil {
  38429. *m.addaddtime += u
  38430. } else {
  38431. m.addaddtime = &u
  38432. }
  38433. }
  38434. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  38435. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  38436. v := m.addaddtime
  38437. if v == nil {
  38438. return
  38439. }
  38440. return *v, true
  38441. }
  38442. // ResetAddtime resets all changes to the "addtime" field.
  38443. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  38444. m.addtime = nil
  38445. m.addaddtime = nil
  38446. }
  38447. // SetType sets the "type" field.
  38448. func (m *UsageStatisticMonthMutation) SetType(i int) {
  38449. m._type = &i
  38450. m.add_type = nil
  38451. }
  38452. // GetType returns the value of the "type" field in the mutation.
  38453. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  38454. v := m._type
  38455. if v == nil {
  38456. return
  38457. }
  38458. return *v, true
  38459. }
  38460. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  38461. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  38462. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38463. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  38464. if !m.op.Is(OpUpdateOne) {
  38465. return v, errors.New("OldType is only allowed on UpdateOne operations")
  38466. }
  38467. if m.id == nil || m.oldValue == nil {
  38468. return v, errors.New("OldType requires an ID field in the mutation")
  38469. }
  38470. oldValue, err := m.oldValue(ctx)
  38471. if err != nil {
  38472. return v, fmt.Errorf("querying old value for OldType: %w", err)
  38473. }
  38474. return oldValue.Type, nil
  38475. }
  38476. // AddType adds i to the "type" field.
  38477. func (m *UsageStatisticMonthMutation) AddType(i int) {
  38478. if m.add_type != nil {
  38479. *m.add_type += i
  38480. } else {
  38481. m.add_type = &i
  38482. }
  38483. }
  38484. // AddedType returns the value that was added to the "type" field in this mutation.
  38485. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  38486. v := m.add_type
  38487. if v == nil {
  38488. return
  38489. }
  38490. return *v, true
  38491. }
  38492. // ResetType resets all changes to the "type" field.
  38493. func (m *UsageStatisticMonthMutation) ResetType() {
  38494. m._type = nil
  38495. m.add_type = nil
  38496. }
  38497. // SetBotID sets the "bot_id" field.
  38498. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  38499. m.bot_id = &s
  38500. }
  38501. // BotID returns the value of the "bot_id" field in the mutation.
  38502. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  38503. v := m.bot_id
  38504. if v == nil {
  38505. return
  38506. }
  38507. return *v, true
  38508. }
  38509. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  38510. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  38511. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38512. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  38513. if !m.op.Is(OpUpdateOne) {
  38514. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  38515. }
  38516. if m.id == nil || m.oldValue == nil {
  38517. return v, errors.New("OldBotID requires an ID field in the mutation")
  38518. }
  38519. oldValue, err := m.oldValue(ctx)
  38520. if err != nil {
  38521. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  38522. }
  38523. return oldValue.BotID, nil
  38524. }
  38525. // ClearBotID clears the value of the "bot_id" field.
  38526. func (m *UsageStatisticMonthMutation) ClearBotID() {
  38527. m.bot_id = nil
  38528. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  38529. }
  38530. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  38531. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  38532. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  38533. return ok
  38534. }
  38535. // ResetBotID resets all changes to the "bot_id" field.
  38536. func (m *UsageStatisticMonthMutation) ResetBotID() {
  38537. m.bot_id = nil
  38538. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  38539. }
  38540. // SetOrganizationID sets the "organization_id" field.
  38541. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  38542. m.organization_id = &u
  38543. m.addorganization_id = nil
  38544. }
  38545. // OrganizationID returns the value of the "organization_id" field in the mutation.
  38546. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  38547. v := m.organization_id
  38548. if v == nil {
  38549. return
  38550. }
  38551. return *v, true
  38552. }
  38553. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  38554. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  38555. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38556. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  38557. if !m.op.Is(OpUpdateOne) {
  38558. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  38559. }
  38560. if m.id == nil || m.oldValue == nil {
  38561. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  38562. }
  38563. oldValue, err := m.oldValue(ctx)
  38564. if err != nil {
  38565. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  38566. }
  38567. return oldValue.OrganizationID, nil
  38568. }
  38569. // AddOrganizationID adds u to the "organization_id" field.
  38570. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  38571. if m.addorganization_id != nil {
  38572. *m.addorganization_id += u
  38573. } else {
  38574. m.addorganization_id = &u
  38575. }
  38576. }
  38577. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  38578. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  38579. v := m.addorganization_id
  38580. if v == nil {
  38581. return
  38582. }
  38583. return *v, true
  38584. }
  38585. // ClearOrganizationID clears the value of the "organization_id" field.
  38586. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  38587. m.organization_id = nil
  38588. m.addorganization_id = nil
  38589. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  38590. }
  38591. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  38592. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  38593. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  38594. return ok
  38595. }
  38596. // ResetOrganizationID resets all changes to the "organization_id" field.
  38597. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  38598. m.organization_id = nil
  38599. m.addorganization_id = nil
  38600. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  38601. }
  38602. // SetAiResponse sets the "ai_response" field.
  38603. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  38604. m.ai_response = &u
  38605. m.addai_response = nil
  38606. }
  38607. // AiResponse returns the value of the "ai_response" field in the mutation.
  38608. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  38609. v := m.ai_response
  38610. if v == nil {
  38611. return
  38612. }
  38613. return *v, true
  38614. }
  38615. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  38616. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  38617. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38618. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  38619. if !m.op.Is(OpUpdateOne) {
  38620. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  38621. }
  38622. if m.id == nil || m.oldValue == nil {
  38623. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  38624. }
  38625. oldValue, err := m.oldValue(ctx)
  38626. if err != nil {
  38627. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  38628. }
  38629. return oldValue.AiResponse, nil
  38630. }
  38631. // AddAiResponse adds u to the "ai_response" field.
  38632. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  38633. if m.addai_response != nil {
  38634. *m.addai_response += u
  38635. } else {
  38636. m.addai_response = &u
  38637. }
  38638. }
  38639. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  38640. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  38641. v := m.addai_response
  38642. if v == nil {
  38643. return
  38644. }
  38645. return *v, true
  38646. }
  38647. // ResetAiResponse resets all changes to the "ai_response" field.
  38648. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  38649. m.ai_response = nil
  38650. m.addai_response = nil
  38651. }
  38652. // SetSopRun sets the "sop_run" field.
  38653. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  38654. m.sop_run = &u
  38655. m.addsop_run = nil
  38656. }
  38657. // SopRun returns the value of the "sop_run" field in the mutation.
  38658. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  38659. v := m.sop_run
  38660. if v == nil {
  38661. return
  38662. }
  38663. return *v, true
  38664. }
  38665. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  38666. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  38667. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38668. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  38669. if !m.op.Is(OpUpdateOne) {
  38670. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  38671. }
  38672. if m.id == nil || m.oldValue == nil {
  38673. return v, errors.New("OldSopRun requires an ID field in the mutation")
  38674. }
  38675. oldValue, err := m.oldValue(ctx)
  38676. if err != nil {
  38677. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  38678. }
  38679. return oldValue.SopRun, nil
  38680. }
  38681. // AddSopRun adds u to the "sop_run" field.
  38682. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  38683. if m.addsop_run != nil {
  38684. *m.addsop_run += u
  38685. } else {
  38686. m.addsop_run = &u
  38687. }
  38688. }
  38689. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  38690. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  38691. v := m.addsop_run
  38692. if v == nil {
  38693. return
  38694. }
  38695. return *v, true
  38696. }
  38697. // ResetSopRun resets all changes to the "sop_run" field.
  38698. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  38699. m.sop_run = nil
  38700. m.addsop_run = nil
  38701. }
  38702. // SetTotalFriend sets the "total_friend" field.
  38703. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  38704. m.total_friend = &u
  38705. m.addtotal_friend = nil
  38706. }
  38707. // TotalFriend returns the value of the "total_friend" field in the mutation.
  38708. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  38709. v := m.total_friend
  38710. if v == nil {
  38711. return
  38712. }
  38713. return *v, true
  38714. }
  38715. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  38716. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  38717. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38718. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  38719. if !m.op.Is(OpUpdateOne) {
  38720. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  38721. }
  38722. if m.id == nil || m.oldValue == nil {
  38723. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  38724. }
  38725. oldValue, err := m.oldValue(ctx)
  38726. if err != nil {
  38727. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  38728. }
  38729. return oldValue.TotalFriend, nil
  38730. }
  38731. // AddTotalFriend adds u to the "total_friend" field.
  38732. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  38733. if m.addtotal_friend != nil {
  38734. *m.addtotal_friend += u
  38735. } else {
  38736. m.addtotal_friend = &u
  38737. }
  38738. }
  38739. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  38740. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  38741. v := m.addtotal_friend
  38742. if v == nil {
  38743. return
  38744. }
  38745. return *v, true
  38746. }
  38747. // ResetTotalFriend resets all changes to the "total_friend" field.
  38748. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  38749. m.total_friend = nil
  38750. m.addtotal_friend = nil
  38751. }
  38752. // SetTotalGroup sets the "total_group" field.
  38753. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  38754. m.total_group = &u
  38755. m.addtotal_group = nil
  38756. }
  38757. // TotalGroup returns the value of the "total_group" field in the mutation.
  38758. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  38759. v := m.total_group
  38760. if v == nil {
  38761. return
  38762. }
  38763. return *v, true
  38764. }
  38765. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  38766. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  38767. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38768. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  38769. if !m.op.Is(OpUpdateOne) {
  38770. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  38771. }
  38772. if m.id == nil || m.oldValue == nil {
  38773. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  38774. }
  38775. oldValue, err := m.oldValue(ctx)
  38776. if err != nil {
  38777. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  38778. }
  38779. return oldValue.TotalGroup, nil
  38780. }
  38781. // AddTotalGroup adds u to the "total_group" field.
  38782. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  38783. if m.addtotal_group != nil {
  38784. *m.addtotal_group += u
  38785. } else {
  38786. m.addtotal_group = &u
  38787. }
  38788. }
  38789. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  38790. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  38791. v := m.addtotal_group
  38792. if v == nil {
  38793. return
  38794. }
  38795. return *v, true
  38796. }
  38797. // ResetTotalGroup resets all changes to the "total_group" field.
  38798. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  38799. m.total_group = nil
  38800. m.addtotal_group = nil
  38801. }
  38802. // SetAccountBalance sets the "account_balance" field.
  38803. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  38804. m.account_balance = &u
  38805. m.addaccount_balance = nil
  38806. }
  38807. // AccountBalance returns the value of the "account_balance" field in the mutation.
  38808. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  38809. v := m.account_balance
  38810. if v == nil {
  38811. return
  38812. }
  38813. return *v, true
  38814. }
  38815. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  38816. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  38817. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38818. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  38819. if !m.op.Is(OpUpdateOne) {
  38820. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  38821. }
  38822. if m.id == nil || m.oldValue == nil {
  38823. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  38824. }
  38825. oldValue, err := m.oldValue(ctx)
  38826. if err != nil {
  38827. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  38828. }
  38829. return oldValue.AccountBalance, nil
  38830. }
  38831. // AddAccountBalance adds u to the "account_balance" field.
  38832. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  38833. if m.addaccount_balance != nil {
  38834. *m.addaccount_balance += u
  38835. } else {
  38836. m.addaccount_balance = &u
  38837. }
  38838. }
  38839. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  38840. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  38841. v := m.addaccount_balance
  38842. if v == nil {
  38843. return
  38844. }
  38845. return *v, true
  38846. }
  38847. // ResetAccountBalance resets all changes to the "account_balance" field.
  38848. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  38849. m.account_balance = nil
  38850. m.addaccount_balance = nil
  38851. }
  38852. // SetConsumeToken sets the "consume_token" field.
  38853. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  38854. m.consume_token = &u
  38855. m.addconsume_token = nil
  38856. }
  38857. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  38858. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  38859. v := m.consume_token
  38860. if v == nil {
  38861. return
  38862. }
  38863. return *v, true
  38864. }
  38865. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  38866. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  38867. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38868. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  38869. if !m.op.Is(OpUpdateOne) {
  38870. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  38871. }
  38872. if m.id == nil || m.oldValue == nil {
  38873. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  38874. }
  38875. oldValue, err := m.oldValue(ctx)
  38876. if err != nil {
  38877. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  38878. }
  38879. return oldValue.ConsumeToken, nil
  38880. }
  38881. // AddConsumeToken adds u to the "consume_token" field.
  38882. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  38883. if m.addconsume_token != nil {
  38884. *m.addconsume_token += u
  38885. } else {
  38886. m.addconsume_token = &u
  38887. }
  38888. }
  38889. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  38890. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  38891. v := m.addconsume_token
  38892. if v == nil {
  38893. return
  38894. }
  38895. return *v, true
  38896. }
  38897. // ResetConsumeToken resets all changes to the "consume_token" field.
  38898. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  38899. m.consume_token = nil
  38900. m.addconsume_token = nil
  38901. }
  38902. // SetActiveUser sets the "active_user" field.
  38903. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  38904. m.active_user = &u
  38905. m.addactive_user = nil
  38906. }
  38907. // ActiveUser returns the value of the "active_user" field in the mutation.
  38908. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  38909. v := m.active_user
  38910. if v == nil {
  38911. return
  38912. }
  38913. return *v, true
  38914. }
  38915. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  38916. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  38917. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38918. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  38919. if !m.op.Is(OpUpdateOne) {
  38920. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  38921. }
  38922. if m.id == nil || m.oldValue == nil {
  38923. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  38924. }
  38925. oldValue, err := m.oldValue(ctx)
  38926. if err != nil {
  38927. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  38928. }
  38929. return oldValue.ActiveUser, nil
  38930. }
  38931. // AddActiveUser adds u to the "active_user" field.
  38932. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  38933. if m.addactive_user != nil {
  38934. *m.addactive_user += u
  38935. } else {
  38936. m.addactive_user = &u
  38937. }
  38938. }
  38939. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  38940. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  38941. v := m.addactive_user
  38942. if v == nil {
  38943. return
  38944. }
  38945. return *v, true
  38946. }
  38947. // ResetActiveUser resets all changes to the "active_user" field.
  38948. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  38949. m.active_user = nil
  38950. m.addactive_user = nil
  38951. }
  38952. // SetNewUser sets the "new_user" field.
  38953. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  38954. m.new_user = &i
  38955. m.addnew_user = nil
  38956. }
  38957. // NewUser returns the value of the "new_user" field in the mutation.
  38958. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  38959. v := m.new_user
  38960. if v == nil {
  38961. return
  38962. }
  38963. return *v, true
  38964. }
  38965. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  38966. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  38967. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38968. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  38969. if !m.op.Is(OpUpdateOne) {
  38970. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  38971. }
  38972. if m.id == nil || m.oldValue == nil {
  38973. return v, errors.New("OldNewUser requires an ID field in the mutation")
  38974. }
  38975. oldValue, err := m.oldValue(ctx)
  38976. if err != nil {
  38977. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  38978. }
  38979. return oldValue.NewUser, nil
  38980. }
  38981. // AddNewUser adds i to the "new_user" field.
  38982. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  38983. if m.addnew_user != nil {
  38984. *m.addnew_user += i
  38985. } else {
  38986. m.addnew_user = &i
  38987. }
  38988. }
  38989. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  38990. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  38991. v := m.addnew_user
  38992. if v == nil {
  38993. return
  38994. }
  38995. return *v, true
  38996. }
  38997. // ResetNewUser resets all changes to the "new_user" field.
  38998. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  38999. m.new_user = nil
  39000. m.addnew_user = nil
  39001. }
  39002. // SetLabelDist sets the "label_dist" field.
  39003. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  39004. m.label_dist = &ctd
  39005. m.appendlabel_dist = nil
  39006. }
  39007. // LabelDist returns the value of the "label_dist" field in the mutation.
  39008. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  39009. v := m.label_dist
  39010. if v == nil {
  39011. return
  39012. }
  39013. return *v, true
  39014. }
  39015. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  39016. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39017. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39018. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  39019. if !m.op.Is(OpUpdateOne) {
  39020. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  39021. }
  39022. if m.id == nil || m.oldValue == nil {
  39023. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  39024. }
  39025. oldValue, err := m.oldValue(ctx)
  39026. if err != nil {
  39027. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  39028. }
  39029. return oldValue.LabelDist, nil
  39030. }
  39031. // AppendLabelDist adds ctd to the "label_dist" field.
  39032. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  39033. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  39034. }
  39035. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  39036. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  39037. if len(m.appendlabel_dist) == 0 {
  39038. return nil, false
  39039. }
  39040. return m.appendlabel_dist, true
  39041. }
  39042. // ResetLabelDist resets all changes to the "label_dist" field.
  39043. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  39044. m.label_dist = nil
  39045. m.appendlabel_dist = nil
  39046. }
  39047. // SetConsumeCoin sets the "consume_coin" field.
  39048. func (m *UsageStatisticMonthMutation) SetConsumeCoin(f float64) {
  39049. m.consume_coin = &f
  39050. m.addconsume_coin = nil
  39051. }
  39052. // ConsumeCoin returns the value of the "consume_coin" field in the mutation.
  39053. func (m *UsageStatisticMonthMutation) ConsumeCoin() (r float64, exists bool) {
  39054. v := m.consume_coin
  39055. if v == nil {
  39056. return
  39057. }
  39058. return *v, true
  39059. }
  39060. // OldConsumeCoin returns the old "consume_coin" field's value of the UsageStatisticMonth entity.
  39061. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39062. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39063. func (m *UsageStatisticMonthMutation) OldConsumeCoin(ctx context.Context) (v float64, err error) {
  39064. if !m.op.Is(OpUpdateOne) {
  39065. return v, errors.New("OldConsumeCoin is only allowed on UpdateOne operations")
  39066. }
  39067. if m.id == nil || m.oldValue == nil {
  39068. return v, errors.New("OldConsumeCoin requires an ID field in the mutation")
  39069. }
  39070. oldValue, err := m.oldValue(ctx)
  39071. if err != nil {
  39072. return v, fmt.Errorf("querying old value for OldConsumeCoin: %w", err)
  39073. }
  39074. return oldValue.ConsumeCoin, nil
  39075. }
  39076. // AddConsumeCoin adds f to the "consume_coin" field.
  39077. func (m *UsageStatisticMonthMutation) AddConsumeCoin(f float64) {
  39078. if m.addconsume_coin != nil {
  39079. *m.addconsume_coin += f
  39080. } else {
  39081. m.addconsume_coin = &f
  39082. }
  39083. }
  39084. // AddedConsumeCoin returns the value that was added to the "consume_coin" field in this mutation.
  39085. func (m *UsageStatisticMonthMutation) AddedConsumeCoin() (r float64, exists bool) {
  39086. v := m.addconsume_coin
  39087. if v == nil {
  39088. return
  39089. }
  39090. return *v, true
  39091. }
  39092. // ClearConsumeCoin clears the value of the "consume_coin" field.
  39093. func (m *UsageStatisticMonthMutation) ClearConsumeCoin() {
  39094. m.consume_coin = nil
  39095. m.addconsume_coin = nil
  39096. m.clearedFields[usagestatisticmonth.FieldConsumeCoin] = struct{}{}
  39097. }
  39098. // ConsumeCoinCleared returns if the "consume_coin" field was cleared in this mutation.
  39099. func (m *UsageStatisticMonthMutation) ConsumeCoinCleared() bool {
  39100. _, ok := m.clearedFields[usagestatisticmonth.FieldConsumeCoin]
  39101. return ok
  39102. }
  39103. // ResetConsumeCoin resets all changes to the "consume_coin" field.
  39104. func (m *UsageStatisticMonthMutation) ResetConsumeCoin() {
  39105. m.consume_coin = nil
  39106. m.addconsume_coin = nil
  39107. delete(m.clearedFields, usagestatisticmonth.FieldConsumeCoin)
  39108. }
  39109. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  39110. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  39111. m.predicates = append(m.predicates, ps...)
  39112. }
  39113. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  39114. // users can use type-assertion to append predicates that do not depend on any generated package.
  39115. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  39116. p := make([]predicate.UsageStatisticMonth, len(ps))
  39117. for i := range ps {
  39118. p[i] = ps[i]
  39119. }
  39120. m.Where(p...)
  39121. }
  39122. // Op returns the operation name.
  39123. func (m *UsageStatisticMonthMutation) Op() Op {
  39124. return m.op
  39125. }
  39126. // SetOp allows setting the mutation operation.
  39127. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  39128. m.op = op
  39129. }
  39130. // Type returns the node type of this mutation (UsageStatisticMonth).
  39131. func (m *UsageStatisticMonthMutation) Type() string {
  39132. return m.typ
  39133. }
  39134. // Fields returns all fields that were changed during this mutation. Note that in
  39135. // order to get all numeric fields that were incremented/decremented, call
  39136. // AddedFields().
  39137. func (m *UsageStatisticMonthMutation) Fields() []string {
  39138. fields := make([]string, 0, 18)
  39139. if m.created_at != nil {
  39140. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  39141. }
  39142. if m.updated_at != nil {
  39143. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  39144. }
  39145. if m.status != nil {
  39146. fields = append(fields, usagestatisticmonth.FieldStatus)
  39147. }
  39148. if m.deleted_at != nil {
  39149. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  39150. }
  39151. if m.addtime != nil {
  39152. fields = append(fields, usagestatisticmonth.FieldAddtime)
  39153. }
  39154. if m._type != nil {
  39155. fields = append(fields, usagestatisticmonth.FieldType)
  39156. }
  39157. if m.bot_id != nil {
  39158. fields = append(fields, usagestatisticmonth.FieldBotID)
  39159. }
  39160. if m.organization_id != nil {
  39161. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  39162. }
  39163. if m.ai_response != nil {
  39164. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  39165. }
  39166. if m.sop_run != nil {
  39167. fields = append(fields, usagestatisticmonth.FieldSopRun)
  39168. }
  39169. if m.total_friend != nil {
  39170. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  39171. }
  39172. if m.total_group != nil {
  39173. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  39174. }
  39175. if m.account_balance != nil {
  39176. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  39177. }
  39178. if m.consume_token != nil {
  39179. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  39180. }
  39181. if m.active_user != nil {
  39182. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  39183. }
  39184. if m.new_user != nil {
  39185. fields = append(fields, usagestatisticmonth.FieldNewUser)
  39186. }
  39187. if m.label_dist != nil {
  39188. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  39189. }
  39190. if m.consume_coin != nil {
  39191. fields = append(fields, usagestatisticmonth.FieldConsumeCoin)
  39192. }
  39193. return fields
  39194. }
  39195. // Field returns the value of a field with the given name. The second boolean
  39196. // return value indicates that this field was not set, or was not defined in the
  39197. // schema.
  39198. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  39199. switch name {
  39200. case usagestatisticmonth.FieldCreatedAt:
  39201. return m.CreatedAt()
  39202. case usagestatisticmonth.FieldUpdatedAt:
  39203. return m.UpdatedAt()
  39204. case usagestatisticmonth.FieldStatus:
  39205. return m.Status()
  39206. case usagestatisticmonth.FieldDeletedAt:
  39207. return m.DeletedAt()
  39208. case usagestatisticmonth.FieldAddtime:
  39209. return m.Addtime()
  39210. case usagestatisticmonth.FieldType:
  39211. return m.GetType()
  39212. case usagestatisticmonth.FieldBotID:
  39213. return m.BotID()
  39214. case usagestatisticmonth.FieldOrganizationID:
  39215. return m.OrganizationID()
  39216. case usagestatisticmonth.FieldAiResponse:
  39217. return m.AiResponse()
  39218. case usagestatisticmonth.FieldSopRun:
  39219. return m.SopRun()
  39220. case usagestatisticmonth.FieldTotalFriend:
  39221. return m.TotalFriend()
  39222. case usagestatisticmonth.FieldTotalGroup:
  39223. return m.TotalGroup()
  39224. case usagestatisticmonth.FieldAccountBalance:
  39225. return m.AccountBalance()
  39226. case usagestatisticmonth.FieldConsumeToken:
  39227. return m.ConsumeToken()
  39228. case usagestatisticmonth.FieldActiveUser:
  39229. return m.ActiveUser()
  39230. case usagestatisticmonth.FieldNewUser:
  39231. return m.NewUser()
  39232. case usagestatisticmonth.FieldLabelDist:
  39233. return m.LabelDist()
  39234. case usagestatisticmonth.FieldConsumeCoin:
  39235. return m.ConsumeCoin()
  39236. }
  39237. return nil, false
  39238. }
  39239. // OldField returns the old value of the field from the database. An error is
  39240. // returned if the mutation operation is not UpdateOne, or the query to the
  39241. // database failed.
  39242. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  39243. switch name {
  39244. case usagestatisticmonth.FieldCreatedAt:
  39245. return m.OldCreatedAt(ctx)
  39246. case usagestatisticmonth.FieldUpdatedAt:
  39247. return m.OldUpdatedAt(ctx)
  39248. case usagestatisticmonth.FieldStatus:
  39249. return m.OldStatus(ctx)
  39250. case usagestatisticmonth.FieldDeletedAt:
  39251. return m.OldDeletedAt(ctx)
  39252. case usagestatisticmonth.FieldAddtime:
  39253. return m.OldAddtime(ctx)
  39254. case usagestatisticmonth.FieldType:
  39255. return m.OldType(ctx)
  39256. case usagestatisticmonth.FieldBotID:
  39257. return m.OldBotID(ctx)
  39258. case usagestatisticmonth.FieldOrganizationID:
  39259. return m.OldOrganizationID(ctx)
  39260. case usagestatisticmonth.FieldAiResponse:
  39261. return m.OldAiResponse(ctx)
  39262. case usagestatisticmonth.FieldSopRun:
  39263. return m.OldSopRun(ctx)
  39264. case usagestatisticmonth.FieldTotalFriend:
  39265. return m.OldTotalFriend(ctx)
  39266. case usagestatisticmonth.FieldTotalGroup:
  39267. return m.OldTotalGroup(ctx)
  39268. case usagestatisticmonth.FieldAccountBalance:
  39269. return m.OldAccountBalance(ctx)
  39270. case usagestatisticmonth.FieldConsumeToken:
  39271. return m.OldConsumeToken(ctx)
  39272. case usagestatisticmonth.FieldActiveUser:
  39273. return m.OldActiveUser(ctx)
  39274. case usagestatisticmonth.FieldNewUser:
  39275. return m.OldNewUser(ctx)
  39276. case usagestatisticmonth.FieldLabelDist:
  39277. return m.OldLabelDist(ctx)
  39278. case usagestatisticmonth.FieldConsumeCoin:
  39279. return m.OldConsumeCoin(ctx)
  39280. }
  39281. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  39282. }
  39283. // SetField sets the value of a field with the given name. It returns an error if
  39284. // the field is not defined in the schema, or if the type mismatched the field
  39285. // type.
  39286. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  39287. switch name {
  39288. case usagestatisticmonth.FieldCreatedAt:
  39289. v, ok := value.(time.Time)
  39290. if !ok {
  39291. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39292. }
  39293. m.SetCreatedAt(v)
  39294. return nil
  39295. case usagestatisticmonth.FieldUpdatedAt:
  39296. v, ok := value.(time.Time)
  39297. if !ok {
  39298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39299. }
  39300. m.SetUpdatedAt(v)
  39301. return nil
  39302. case usagestatisticmonth.FieldStatus:
  39303. v, ok := value.(uint8)
  39304. if !ok {
  39305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39306. }
  39307. m.SetStatus(v)
  39308. return nil
  39309. case usagestatisticmonth.FieldDeletedAt:
  39310. v, ok := value.(time.Time)
  39311. if !ok {
  39312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39313. }
  39314. m.SetDeletedAt(v)
  39315. return nil
  39316. case usagestatisticmonth.FieldAddtime:
  39317. v, ok := value.(uint64)
  39318. if !ok {
  39319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39320. }
  39321. m.SetAddtime(v)
  39322. return nil
  39323. case usagestatisticmonth.FieldType:
  39324. v, ok := value.(int)
  39325. if !ok {
  39326. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39327. }
  39328. m.SetType(v)
  39329. return nil
  39330. case usagestatisticmonth.FieldBotID:
  39331. v, ok := value.(string)
  39332. if !ok {
  39333. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39334. }
  39335. m.SetBotID(v)
  39336. return nil
  39337. case usagestatisticmonth.FieldOrganizationID:
  39338. v, ok := value.(uint64)
  39339. if !ok {
  39340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39341. }
  39342. m.SetOrganizationID(v)
  39343. return nil
  39344. case usagestatisticmonth.FieldAiResponse:
  39345. v, ok := value.(uint64)
  39346. if !ok {
  39347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39348. }
  39349. m.SetAiResponse(v)
  39350. return nil
  39351. case usagestatisticmonth.FieldSopRun:
  39352. v, ok := value.(uint64)
  39353. if !ok {
  39354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39355. }
  39356. m.SetSopRun(v)
  39357. return nil
  39358. case usagestatisticmonth.FieldTotalFriend:
  39359. v, ok := value.(uint64)
  39360. if !ok {
  39361. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39362. }
  39363. m.SetTotalFriend(v)
  39364. return nil
  39365. case usagestatisticmonth.FieldTotalGroup:
  39366. v, ok := value.(uint64)
  39367. if !ok {
  39368. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39369. }
  39370. m.SetTotalGroup(v)
  39371. return nil
  39372. case usagestatisticmonth.FieldAccountBalance:
  39373. v, ok := value.(uint64)
  39374. if !ok {
  39375. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39376. }
  39377. m.SetAccountBalance(v)
  39378. return nil
  39379. case usagestatisticmonth.FieldConsumeToken:
  39380. v, ok := value.(uint64)
  39381. if !ok {
  39382. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39383. }
  39384. m.SetConsumeToken(v)
  39385. return nil
  39386. case usagestatisticmonth.FieldActiveUser:
  39387. v, ok := value.(uint64)
  39388. if !ok {
  39389. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39390. }
  39391. m.SetActiveUser(v)
  39392. return nil
  39393. case usagestatisticmonth.FieldNewUser:
  39394. v, ok := value.(int64)
  39395. if !ok {
  39396. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39397. }
  39398. m.SetNewUser(v)
  39399. return nil
  39400. case usagestatisticmonth.FieldLabelDist:
  39401. v, ok := value.([]custom_types.LabelDist)
  39402. if !ok {
  39403. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39404. }
  39405. m.SetLabelDist(v)
  39406. return nil
  39407. case usagestatisticmonth.FieldConsumeCoin:
  39408. v, ok := value.(float64)
  39409. if !ok {
  39410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39411. }
  39412. m.SetConsumeCoin(v)
  39413. return nil
  39414. }
  39415. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  39416. }
  39417. // AddedFields returns all numeric fields that were incremented/decremented during
  39418. // this mutation.
  39419. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  39420. var fields []string
  39421. if m.addstatus != nil {
  39422. fields = append(fields, usagestatisticmonth.FieldStatus)
  39423. }
  39424. if m.addaddtime != nil {
  39425. fields = append(fields, usagestatisticmonth.FieldAddtime)
  39426. }
  39427. if m.add_type != nil {
  39428. fields = append(fields, usagestatisticmonth.FieldType)
  39429. }
  39430. if m.addorganization_id != nil {
  39431. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  39432. }
  39433. if m.addai_response != nil {
  39434. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  39435. }
  39436. if m.addsop_run != nil {
  39437. fields = append(fields, usagestatisticmonth.FieldSopRun)
  39438. }
  39439. if m.addtotal_friend != nil {
  39440. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  39441. }
  39442. if m.addtotal_group != nil {
  39443. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  39444. }
  39445. if m.addaccount_balance != nil {
  39446. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  39447. }
  39448. if m.addconsume_token != nil {
  39449. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  39450. }
  39451. if m.addactive_user != nil {
  39452. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  39453. }
  39454. if m.addnew_user != nil {
  39455. fields = append(fields, usagestatisticmonth.FieldNewUser)
  39456. }
  39457. if m.addconsume_coin != nil {
  39458. fields = append(fields, usagestatisticmonth.FieldConsumeCoin)
  39459. }
  39460. return fields
  39461. }
  39462. // AddedField returns the numeric value that was incremented/decremented on a field
  39463. // with the given name. The second boolean return value indicates that this field
  39464. // was not set, or was not defined in the schema.
  39465. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  39466. switch name {
  39467. case usagestatisticmonth.FieldStatus:
  39468. return m.AddedStatus()
  39469. case usagestatisticmonth.FieldAddtime:
  39470. return m.AddedAddtime()
  39471. case usagestatisticmonth.FieldType:
  39472. return m.AddedType()
  39473. case usagestatisticmonth.FieldOrganizationID:
  39474. return m.AddedOrganizationID()
  39475. case usagestatisticmonth.FieldAiResponse:
  39476. return m.AddedAiResponse()
  39477. case usagestatisticmonth.FieldSopRun:
  39478. return m.AddedSopRun()
  39479. case usagestatisticmonth.FieldTotalFriend:
  39480. return m.AddedTotalFriend()
  39481. case usagestatisticmonth.FieldTotalGroup:
  39482. return m.AddedTotalGroup()
  39483. case usagestatisticmonth.FieldAccountBalance:
  39484. return m.AddedAccountBalance()
  39485. case usagestatisticmonth.FieldConsumeToken:
  39486. return m.AddedConsumeToken()
  39487. case usagestatisticmonth.FieldActiveUser:
  39488. return m.AddedActiveUser()
  39489. case usagestatisticmonth.FieldNewUser:
  39490. return m.AddedNewUser()
  39491. case usagestatisticmonth.FieldConsumeCoin:
  39492. return m.AddedConsumeCoin()
  39493. }
  39494. return nil, false
  39495. }
  39496. // AddField adds the value to the field with the given name. It returns an error if
  39497. // the field is not defined in the schema, or if the type mismatched the field
  39498. // type.
  39499. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  39500. switch name {
  39501. case usagestatisticmonth.FieldStatus:
  39502. v, ok := value.(int8)
  39503. if !ok {
  39504. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39505. }
  39506. m.AddStatus(v)
  39507. return nil
  39508. case usagestatisticmonth.FieldAddtime:
  39509. v, ok := value.(int64)
  39510. if !ok {
  39511. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39512. }
  39513. m.AddAddtime(v)
  39514. return nil
  39515. case usagestatisticmonth.FieldType:
  39516. v, ok := value.(int)
  39517. if !ok {
  39518. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39519. }
  39520. m.AddType(v)
  39521. return nil
  39522. case usagestatisticmonth.FieldOrganizationID:
  39523. v, ok := value.(int64)
  39524. if !ok {
  39525. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39526. }
  39527. m.AddOrganizationID(v)
  39528. return nil
  39529. case usagestatisticmonth.FieldAiResponse:
  39530. v, ok := value.(int64)
  39531. if !ok {
  39532. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39533. }
  39534. m.AddAiResponse(v)
  39535. return nil
  39536. case usagestatisticmonth.FieldSopRun:
  39537. v, ok := value.(int64)
  39538. if !ok {
  39539. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39540. }
  39541. m.AddSopRun(v)
  39542. return nil
  39543. case usagestatisticmonth.FieldTotalFriend:
  39544. v, ok := value.(int64)
  39545. if !ok {
  39546. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39547. }
  39548. m.AddTotalFriend(v)
  39549. return nil
  39550. case usagestatisticmonth.FieldTotalGroup:
  39551. v, ok := value.(int64)
  39552. if !ok {
  39553. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39554. }
  39555. m.AddTotalGroup(v)
  39556. return nil
  39557. case usagestatisticmonth.FieldAccountBalance:
  39558. v, ok := value.(int64)
  39559. if !ok {
  39560. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39561. }
  39562. m.AddAccountBalance(v)
  39563. return nil
  39564. case usagestatisticmonth.FieldConsumeToken:
  39565. v, ok := value.(int64)
  39566. if !ok {
  39567. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39568. }
  39569. m.AddConsumeToken(v)
  39570. return nil
  39571. case usagestatisticmonth.FieldActiveUser:
  39572. v, ok := value.(int64)
  39573. if !ok {
  39574. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39575. }
  39576. m.AddActiveUser(v)
  39577. return nil
  39578. case usagestatisticmonth.FieldNewUser:
  39579. v, ok := value.(int64)
  39580. if !ok {
  39581. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39582. }
  39583. m.AddNewUser(v)
  39584. return nil
  39585. case usagestatisticmonth.FieldConsumeCoin:
  39586. v, ok := value.(float64)
  39587. if !ok {
  39588. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39589. }
  39590. m.AddConsumeCoin(v)
  39591. return nil
  39592. }
  39593. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  39594. }
  39595. // ClearedFields returns all nullable fields that were cleared during this
  39596. // mutation.
  39597. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  39598. var fields []string
  39599. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  39600. fields = append(fields, usagestatisticmonth.FieldStatus)
  39601. }
  39602. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  39603. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  39604. }
  39605. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  39606. fields = append(fields, usagestatisticmonth.FieldBotID)
  39607. }
  39608. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  39609. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  39610. }
  39611. if m.FieldCleared(usagestatisticmonth.FieldConsumeCoin) {
  39612. fields = append(fields, usagestatisticmonth.FieldConsumeCoin)
  39613. }
  39614. return fields
  39615. }
  39616. // FieldCleared returns a boolean indicating if a field with the given name was
  39617. // cleared in this mutation.
  39618. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  39619. _, ok := m.clearedFields[name]
  39620. return ok
  39621. }
  39622. // ClearField clears the value of the field with the given name. It returns an
  39623. // error if the field is not defined in the schema.
  39624. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  39625. switch name {
  39626. case usagestatisticmonth.FieldStatus:
  39627. m.ClearStatus()
  39628. return nil
  39629. case usagestatisticmonth.FieldDeletedAt:
  39630. m.ClearDeletedAt()
  39631. return nil
  39632. case usagestatisticmonth.FieldBotID:
  39633. m.ClearBotID()
  39634. return nil
  39635. case usagestatisticmonth.FieldOrganizationID:
  39636. m.ClearOrganizationID()
  39637. return nil
  39638. case usagestatisticmonth.FieldConsumeCoin:
  39639. m.ClearConsumeCoin()
  39640. return nil
  39641. }
  39642. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  39643. }
  39644. // ResetField resets all changes in the mutation for the field with the given name.
  39645. // It returns an error if the field is not defined in the schema.
  39646. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  39647. switch name {
  39648. case usagestatisticmonth.FieldCreatedAt:
  39649. m.ResetCreatedAt()
  39650. return nil
  39651. case usagestatisticmonth.FieldUpdatedAt:
  39652. m.ResetUpdatedAt()
  39653. return nil
  39654. case usagestatisticmonth.FieldStatus:
  39655. m.ResetStatus()
  39656. return nil
  39657. case usagestatisticmonth.FieldDeletedAt:
  39658. m.ResetDeletedAt()
  39659. return nil
  39660. case usagestatisticmonth.FieldAddtime:
  39661. m.ResetAddtime()
  39662. return nil
  39663. case usagestatisticmonth.FieldType:
  39664. m.ResetType()
  39665. return nil
  39666. case usagestatisticmonth.FieldBotID:
  39667. m.ResetBotID()
  39668. return nil
  39669. case usagestatisticmonth.FieldOrganizationID:
  39670. m.ResetOrganizationID()
  39671. return nil
  39672. case usagestatisticmonth.FieldAiResponse:
  39673. m.ResetAiResponse()
  39674. return nil
  39675. case usagestatisticmonth.FieldSopRun:
  39676. m.ResetSopRun()
  39677. return nil
  39678. case usagestatisticmonth.FieldTotalFriend:
  39679. m.ResetTotalFriend()
  39680. return nil
  39681. case usagestatisticmonth.FieldTotalGroup:
  39682. m.ResetTotalGroup()
  39683. return nil
  39684. case usagestatisticmonth.FieldAccountBalance:
  39685. m.ResetAccountBalance()
  39686. return nil
  39687. case usagestatisticmonth.FieldConsumeToken:
  39688. m.ResetConsumeToken()
  39689. return nil
  39690. case usagestatisticmonth.FieldActiveUser:
  39691. m.ResetActiveUser()
  39692. return nil
  39693. case usagestatisticmonth.FieldNewUser:
  39694. m.ResetNewUser()
  39695. return nil
  39696. case usagestatisticmonth.FieldLabelDist:
  39697. m.ResetLabelDist()
  39698. return nil
  39699. case usagestatisticmonth.FieldConsumeCoin:
  39700. m.ResetConsumeCoin()
  39701. return nil
  39702. }
  39703. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  39704. }
  39705. // AddedEdges returns all edge names that were set/added in this mutation.
  39706. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  39707. edges := make([]string, 0, 0)
  39708. return edges
  39709. }
  39710. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  39711. // name in this mutation.
  39712. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  39713. return nil
  39714. }
  39715. // RemovedEdges returns all edge names that were removed in this mutation.
  39716. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  39717. edges := make([]string, 0, 0)
  39718. return edges
  39719. }
  39720. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39721. // the given name in this mutation.
  39722. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  39723. return nil
  39724. }
  39725. // ClearedEdges returns all edge names that were cleared in this mutation.
  39726. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  39727. edges := make([]string, 0, 0)
  39728. return edges
  39729. }
  39730. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39731. // was cleared in this mutation.
  39732. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  39733. return false
  39734. }
  39735. // ClearEdge clears the value of the edge with the given name. It returns an error
  39736. // if that edge is not defined in the schema.
  39737. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  39738. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  39739. }
  39740. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39741. // It returns an error if the edge is not defined in the schema.
  39742. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  39743. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  39744. }
  39745. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  39746. type UsageTotalMutation struct {
  39747. config
  39748. op Op
  39749. typ string
  39750. id *uint64
  39751. created_at *time.Time
  39752. updated_at *time.Time
  39753. status *uint8
  39754. addstatus *int8
  39755. _type *int
  39756. add_type *int
  39757. bot_id *string
  39758. total_tokens *uint64
  39759. addtotal_tokens *int64
  39760. credits *float64
  39761. addcredits *float64
  39762. start_index *uint64
  39763. addstart_index *int64
  39764. end_index *uint64
  39765. addend_index *int64
  39766. organization_id *uint64
  39767. addorganization_id *int64
  39768. clearedFields map[string]struct{}
  39769. done bool
  39770. oldValue func(context.Context) (*UsageTotal, error)
  39771. predicates []predicate.UsageTotal
  39772. }
  39773. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  39774. // usagetotalOption allows management of the mutation configuration using functional options.
  39775. type usagetotalOption func(*UsageTotalMutation)
  39776. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  39777. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  39778. m := &UsageTotalMutation{
  39779. config: c,
  39780. op: op,
  39781. typ: TypeUsageTotal,
  39782. clearedFields: make(map[string]struct{}),
  39783. }
  39784. for _, opt := range opts {
  39785. opt(m)
  39786. }
  39787. return m
  39788. }
  39789. // withUsageTotalID sets the ID field of the mutation.
  39790. func withUsageTotalID(id uint64) usagetotalOption {
  39791. return func(m *UsageTotalMutation) {
  39792. var (
  39793. err error
  39794. once sync.Once
  39795. value *UsageTotal
  39796. )
  39797. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  39798. once.Do(func() {
  39799. if m.done {
  39800. err = errors.New("querying old values post mutation is not allowed")
  39801. } else {
  39802. value, err = m.Client().UsageTotal.Get(ctx, id)
  39803. }
  39804. })
  39805. return value, err
  39806. }
  39807. m.id = &id
  39808. }
  39809. }
  39810. // withUsageTotal sets the old UsageTotal of the mutation.
  39811. func withUsageTotal(node *UsageTotal) usagetotalOption {
  39812. return func(m *UsageTotalMutation) {
  39813. m.oldValue = func(context.Context) (*UsageTotal, error) {
  39814. return node, nil
  39815. }
  39816. m.id = &node.ID
  39817. }
  39818. }
  39819. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39820. // executed in a transaction (ent.Tx), a transactional client is returned.
  39821. func (m UsageTotalMutation) Client() *Client {
  39822. client := &Client{config: m.config}
  39823. client.init()
  39824. return client
  39825. }
  39826. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39827. // it returns an error otherwise.
  39828. func (m UsageTotalMutation) Tx() (*Tx, error) {
  39829. if _, ok := m.driver.(*txDriver); !ok {
  39830. return nil, errors.New("ent: mutation is not running in a transaction")
  39831. }
  39832. tx := &Tx{config: m.config}
  39833. tx.init()
  39834. return tx, nil
  39835. }
  39836. // SetID sets the value of the id field. Note that this
  39837. // operation is only accepted on creation of UsageTotal entities.
  39838. func (m *UsageTotalMutation) SetID(id uint64) {
  39839. m.id = &id
  39840. }
  39841. // ID returns the ID value in the mutation. Note that the ID is only available
  39842. // if it was provided to the builder or after it was returned from the database.
  39843. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  39844. if m.id == nil {
  39845. return
  39846. }
  39847. return *m.id, true
  39848. }
  39849. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39850. // That means, if the mutation is applied within a transaction with an isolation level such
  39851. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39852. // or updated by the mutation.
  39853. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  39854. switch {
  39855. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39856. id, exists := m.ID()
  39857. if exists {
  39858. return []uint64{id}, nil
  39859. }
  39860. fallthrough
  39861. case m.op.Is(OpUpdate | OpDelete):
  39862. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  39863. default:
  39864. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39865. }
  39866. }
  39867. // SetCreatedAt sets the "created_at" field.
  39868. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  39869. m.created_at = &t
  39870. }
  39871. // CreatedAt returns the value of the "created_at" field in the mutation.
  39872. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  39873. v := m.created_at
  39874. if v == nil {
  39875. return
  39876. }
  39877. return *v, true
  39878. }
  39879. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  39880. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  39881. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39882. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39883. if !m.op.Is(OpUpdateOne) {
  39884. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39885. }
  39886. if m.id == nil || m.oldValue == nil {
  39887. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39888. }
  39889. oldValue, err := m.oldValue(ctx)
  39890. if err != nil {
  39891. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39892. }
  39893. return oldValue.CreatedAt, nil
  39894. }
  39895. // ResetCreatedAt resets all changes to the "created_at" field.
  39896. func (m *UsageTotalMutation) ResetCreatedAt() {
  39897. m.created_at = nil
  39898. }
  39899. // SetUpdatedAt sets the "updated_at" field.
  39900. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  39901. m.updated_at = &t
  39902. }
  39903. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  39904. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  39905. v := m.updated_at
  39906. if v == nil {
  39907. return
  39908. }
  39909. return *v, true
  39910. }
  39911. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  39912. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  39913. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39914. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  39915. if !m.op.Is(OpUpdateOne) {
  39916. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  39917. }
  39918. if m.id == nil || m.oldValue == nil {
  39919. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  39920. }
  39921. oldValue, err := m.oldValue(ctx)
  39922. if err != nil {
  39923. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  39924. }
  39925. return oldValue.UpdatedAt, nil
  39926. }
  39927. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39928. func (m *UsageTotalMutation) ResetUpdatedAt() {
  39929. m.updated_at = nil
  39930. }
  39931. // SetStatus sets the "status" field.
  39932. func (m *UsageTotalMutation) SetStatus(u uint8) {
  39933. m.status = &u
  39934. m.addstatus = nil
  39935. }
  39936. // Status returns the value of the "status" field in the mutation.
  39937. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  39938. v := m.status
  39939. if v == nil {
  39940. return
  39941. }
  39942. return *v, true
  39943. }
  39944. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  39945. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  39946. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39947. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  39948. if !m.op.Is(OpUpdateOne) {
  39949. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  39950. }
  39951. if m.id == nil || m.oldValue == nil {
  39952. return v, errors.New("OldStatus requires an ID field in the mutation")
  39953. }
  39954. oldValue, err := m.oldValue(ctx)
  39955. if err != nil {
  39956. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  39957. }
  39958. return oldValue.Status, nil
  39959. }
  39960. // AddStatus adds u to the "status" field.
  39961. func (m *UsageTotalMutation) AddStatus(u int8) {
  39962. if m.addstatus != nil {
  39963. *m.addstatus += u
  39964. } else {
  39965. m.addstatus = &u
  39966. }
  39967. }
  39968. // AddedStatus returns the value that was added to the "status" field in this mutation.
  39969. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  39970. v := m.addstatus
  39971. if v == nil {
  39972. return
  39973. }
  39974. return *v, true
  39975. }
  39976. // ClearStatus clears the value of the "status" field.
  39977. func (m *UsageTotalMutation) ClearStatus() {
  39978. m.status = nil
  39979. m.addstatus = nil
  39980. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  39981. }
  39982. // StatusCleared returns if the "status" field was cleared in this mutation.
  39983. func (m *UsageTotalMutation) StatusCleared() bool {
  39984. _, ok := m.clearedFields[usagetotal.FieldStatus]
  39985. return ok
  39986. }
  39987. // ResetStatus resets all changes to the "status" field.
  39988. func (m *UsageTotalMutation) ResetStatus() {
  39989. m.status = nil
  39990. m.addstatus = nil
  39991. delete(m.clearedFields, usagetotal.FieldStatus)
  39992. }
  39993. // SetType sets the "type" field.
  39994. func (m *UsageTotalMutation) SetType(i int) {
  39995. m._type = &i
  39996. m.add_type = nil
  39997. }
  39998. // GetType returns the value of the "type" field in the mutation.
  39999. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  40000. v := m._type
  40001. if v == nil {
  40002. return
  40003. }
  40004. return *v, true
  40005. }
  40006. // OldType returns the old "type" field's value of the UsageTotal entity.
  40007. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  40008. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40009. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  40010. if !m.op.Is(OpUpdateOne) {
  40011. return v, errors.New("OldType is only allowed on UpdateOne operations")
  40012. }
  40013. if m.id == nil || m.oldValue == nil {
  40014. return v, errors.New("OldType requires an ID field in the mutation")
  40015. }
  40016. oldValue, err := m.oldValue(ctx)
  40017. if err != nil {
  40018. return v, fmt.Errorf("querying old value for OldType: %w", err)
  40019. }
  40020. return oldValue.Type, nil
  40021. }
  40022. // AddType adds i to the "type" field.
  40023. func (m *UsageTotalMutation) AddType(i int) {
  40024. if m.add_type != nil {
  40025. *m.add_type += i
  40026. } else {
  40027. m.add_type = &i
  40028. }
  40029. }
  40030. // AddedType returns the value that was added to the "type" field in this mutation.
  40031. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  40032. v := m.add_type
  40033. if v == nil {
  40034. return
  40035. }
  40036. return *v, true
  40037. }
  40038. // ClearType clears the value of the "type" field.
  40039. func (m *UsageTotalMutation) ClearType() {
  40040. m._type = nil
  40041. m.add_type = nil
  40042. m.clearedFields[usagetotal.FieldType] = struct{}{}
  40043. }
  40044. // TypeCleared returns if the "type" field was cleared in this mutation.
  40045. func (m *UsageTotalMutation) TypeCleared() bool {
  40046. _, ok := m.clearedFields[usagetotal.FieldType]
  40047. return ok
  40048. }
  40049. // ResetType resets all changes to the "type" field.
  40050. func (m *UsageTotalMutation) ResetType() {
  40051. m._type = nil
  40052. m.add_type = nil
  40053. delete(m.clearedFields, usagetotal.FieldType)
  40054. }
  40055. // SetBotID sets the "bot_id" field.
  40056. func (m *UsageTotalMutation) SetBotID(s string) {
  40057. m.bot_id = &s
  40058. }
  40059. // BotID returns the value of the "bot_id" field in the mutation.
  40060. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  40061. v := m.bot_id
  40062. if v == nil {
  40063. return
  40064. }
  40065. return *v, true
  40066. }
  40067. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  40068. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  40069. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40070. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  40071. if !m.op.Is(OpUpdateOne) {
  40072. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  40073. }
  40074. if m.id == nil || m.oldValue == nil {
  40075. return v, errors.New("OldBotID requires an ID field in the mutation")
  40076. }
  40077. oldValue, err := m.oldValue(ctx)
  40078. if err != nil {
  40079. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  40080. }
  40081. return oldValue.BotID, nil
  40082. }
  40083. // ResetBotID resets all changes to the "bot_id" field.
  40084. func (m *UsageTotalMutation) ResetBotID() {
  40085. m.bot_id = nil
  40086. }
  40087. // SetTotalTokens sets the "total_tokens" field.
  40088. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  40089. m.total_tokens = &u
  40090. m.addtotal_tokens = nil
  40091. }
  40092. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  40093. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  40094. v := m.total_tokens
  40095. if v == nil {
  40096. return
  40097. }
  40098. return *v, true
  40099. }
  40100. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  40101. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  40102. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40103. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  40104. if !m.op.Is(OpUpdateOne) {
  40105. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  40106. }
  40107. if m.id == nil || m.oldValue == nil {
  40108. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  40109. }
  40110. oldValue, err := m.oldValue(ctx)
  40111. if err != nil {
  40112. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  40113. }
  40114. return oldValue.TotalTokens, nil
  40115. }
  40116. // AddTotalTokens adds u to the "total_tokens" field.
  40117. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  40118. if m.addtotal_tokens != nil {
  40119. *m.addtotal_tokens += u
  40120. } else {
  40121. m.addtotal_tokens = &u
  40122. }
  40123. }
  40124. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  40125. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  40126. v := m.addtotal_tokens
  40127. if v == nil {
  40128. return
  40129. }
  40130. return *v, true
  40131. }
  40132. // ClearTotalTokens clears the value of the "total_tokens" field.
  40133. func (m *UsageTotalMutation) ClearTotalTokens() {
  40134. m.total_tokens = nil
  40135. m.addtotal_tokens = nil
  40136. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  40137. }
  40138. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  40139. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  40140. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  40141. return ok
  40142. }
  40143. // ResetTotalTokens resets all changes to the "total_tokens" field.
  40144. func (m *UsageTotalMutation) ResetTotalTokens() {
  40145. m.total_tokens = nil
  40146. m.addtotal_tokens = nil
  40147. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  40148. }
  40149. // SetCredits sets the "credits" field.
  40150. func (m *UsageTotalMutation) SetCredits(f float64) {
  40151. m.credits = &f
  40152. m.addcredits = nil
  40153. }
  40154. // Credits returns the value of the "credits" field in the mutation.
  40155. func (m *UsageTotalMutation) Credits() (r float64, exists bool) {
  40156. v := m.credits
  40157. if v == nil {
  40158. return
  40159. }
  40160. return *v, true
  40161. }
  40162. // OldCredits returns the old "credits" field's value of the UsageTotal entity.
  40163. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  40164. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40165. func (m *UsageTotalMutation) OldCredits(ctx context.Context) (v float64, err error) {
  40166. if !m.op.Is(OpUpdateOne) {
  40167. return v, errors.New("OldCredits is only allowed on UpdateOne operations")
  40168. }
  40169. if m.id == nil || m.oldValue == nil {
  40170. return v, errors.New("OldCredits requires an ID field in the mutation")
  40171. }
  40172. oldValue, err := m.oldValue(ctx)
  40173. if err != nil {
  40174. return v, fmt.Errorf("querying old value for OldCredits: %w", err)
  40175. }
  40176. return oldValue.Credits, nil
  40177. }
  40178. // AddCredits adds f to the "credits" field.
  40179. func (m *UsageTotalMutation) AddCredits(f float64) {
  40180. if m.addcredits != nil {
  40181. *m.addcredits += f
  40182. } else {
  40183. m.addcredits = &f
  40184. }
  40185. }
  40186. // AddedCredits returns the value that was added to the "credits" field in this mutation.
  40187. func (m *UsageTotalMutation) AddedCredits() (r float64, exists bool) {
  40188. v := m.addcredits
  40189. if v == nil {
  40190. return
  40191. }
  40192. return *v, true
  40193. }
  40194. // ClearCredits clears the value of the "credits" field.
  40195. func (m *UsageTotalMutation) ClearCredits() {
  40196. m.credits = nil
  40197. m.addcredits = nil
  40198. m.clearedFields[usagetotal.FieldCredits] = struct{}{}
  40199. }
  40200. // CreditsCleared returns if the "credits" field was cleared in this mutation.
  40201. func (m *UsageTotalMutation) CreditsCleared() bool {
  40202. _, ok := m.clearedFields[usagetotal.FieldCredits]
  40203. return ok
  40204. }
  40205. // ResetCredits resets all changes to the "credits" field.
  40206. func (m *UsageTotalMutation) ResetCredits() {
  40207. m.credits = nil
  40208. m.addcredits = nil
  40209. delete(m.clearedFields, usagetotal.FieldCredits)
  40210. }
  40211. // SetStartIndex sets the "start_index" field.
  40212. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  40213. m.start_index = &u
  40214. m.addstart_index = nil
  40215. }
  40216. // StartIndex returns the value of the "start_index" field in the mutation.
  40217. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  40218. v := m.start_index
  40219. if v == nil {
  40220. return
  40221. }
  40222. return *v, true
  40223. }
  40224. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  40225. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  40226. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40227. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  40228. if !m.op.Is(OpUpdateOne) {
  40229. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  40230. }
  40231. if m.id == nil || m.oldValue == nil {
  40232. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  40233. }
  40234. oldValue, err := m.oldValue(ctx)
  40235. if err != nil {
  40236. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  40237. }
  40238. return oldValue.StartIndex, nil
  40239. }
  40240. // AddStartIndex adds u to the "start_index" field.
  40241. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  40242. if m.addstart_index != nil {
  40243. *m.addstart_index += u
  40244. } else {
  40245. m.addstart_index = &u
  40246. }
  40247. }
  40248. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  40249. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  40250. v := m.addstart_index
  40251. if v == nil {
  40252. return
  40253. }
  40254. return *v, true
  40255. }
  40256. // ClearStartIndex clears the value of the "start_index" field.
  40257. func (m *UsageTotalMutation) ClearStartIndex() {
  40258. m.start_index = nil
  40259. m.addstart_index = nil
  40260. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  40261. }
  40262. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  40263. func (m *UsageTotalMutation) StartIndexCleared() bool {
  40264. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  40265. return ok
  40266. }
  40267. // ResetStartIndex resets all changes to the "start_index" field.
  40268. func (m *UsageTotalMutation) ResetStartIndex() {
  40269. m.start_index = nil
  40270. m.addstart_index = nil
  40271. delete(m.clearedFields, usagetotal.FieldStartIndex)
  40272. }
  40273. // SetEndIndex sets the "end_index" field.
  40274. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  40275. m.end_index = &u
  40276. m.addend_index = nil
  40277. }
  40278. // EndIndex returns the value of the "end_index" field in the mutation.
  40279. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  40280. v := m.end_index
  40281. if v == nil {
  40282. return
  40283. }
  40284. return *v, true
  40285. }
  40286. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  40287. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  40288. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40289. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  40290. if !m.op.Is(OpUpdateOne) {
  40291. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  40292. }
  40293. if m.id == nil || m.oldValue == nil {
  40294. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  40295. }
  40296. oldValue, err := m.oldValue(ctx)
  40297. if err != nil {
  40298. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  40299. }
  40300. return oldValue.EndIndex, nil
  40301. }
  40302. // AddEndIndex adds u to the "end_index" field.
  40303. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  40304. if m.addend_index != nil {
  40305. *m.addend_index += u
  40306. } else {
  40307. m.addend_index = &u
  40308. }
  40309. }
  40310. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  40311. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  40312. v := m.addend_index
  40313. if v == nil {
  40314. return
  40315. }
  40316. return *v, true
  40317. }
  40318. // ClearEndIndex clears the value of the "end_index" field.
  40319. func (m *UsageTotalMutation) ClearEndIndex() {
  40320. m.end_index = nil
  40321. m.addend_index = nil
  40322. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  40323. }
  40324. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  40325. func (m *UsageTotalMutation) EndIndexCleared() bool {
  40326. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  40327. return ok
  40328. }
  40329. // ResetEndIndex resets all changes to the "end_index" field.
  40330. func (m *UsageTotalMutation) ResetEndIndex() {
  40331. m.end_index = nil
  40332. m.addend_index = nil
  40333. delete(m.clearedFields, usagetotal.FieldEndIndex)
  40334. }
  40335. // SetOrganizationID sets the "organization_id" field.
  40336. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  40337. m.organization_id = &u
  40338. m.addorganization_id = nil
  40339. }
  40340. // OrganizationID returns the value of the "organization_id" field in the mutation.
  40341. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  40342. v := m.organization_id
  40343. if v == nil {
  40344. return
  40345. }
  40346. return *v, true
  40347. }
  40348. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  40349. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  40350. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40351. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  40352. if !m.op.Is(OpUpdateOne) {
  40353. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  40354. }
  40355. if m.id == nil || m.oldValue == nil {
  40356. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  40357. }
  40358. oldValue, err := m.oldValue(ctx)
  40359. if err != nil {
  40360. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  40361. }
  40362. return oldValue.OrganizationID, nil
  40363. }
  40364. // AddOrganizationID adds u to the "organization_id" field.
  40365. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  40366. if m.addorganization_id != nil {
  40367. *m.addorganization_id += u
  40368. } else {
  40369. m.addorganization_id = &u
  40370. }
  40371. }
  40372. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  40373. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  40374. v := m.addorganization_id
  40375. if v == nil {
  40376. return
  40377. }
  40378. return *v, true
  40379. }
  40380. // ClearOrganizationID clears the value of the "organization_id" field.
  40381. func (m *UsageTotalMutation) ClearOrganizationID() {
  40382. m.organization_id = nil
  40383. m.addorganization_id = nil
  40384. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  40385. }
  40386. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  40387. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  40388. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  40389. return ok
  40390. }
  40391. // ResetOrganizationID resets all changes to the "organization_id" field.
  40392. func (m *UsageTotalMutation) ResetOrganizationID() {
  40393. m.organization_id = nil
  40394. m.addorganization_id = nil
  40395. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  40396. }
  40397. // Where appends a list predicates to the UsageTotalMutation builder.
  40398. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  40399. m.predicates = append(m.predicates, ps...)
  40400. }
  40401. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  40402. // users can use type-assertion to append predicates that do not depend on any generated package.
  40403. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  40404. p := make([]predicate.UsageTotal, len(ps))
  40405. for i := range ps {
  40406. p[i] = ps[i]
  40407. }
  40408. m.Where(p...)
  40409. }
  40410. // Op returns the operation name.
  40411. func (m *UsageTotalMutation) Op() Op {
  40412. return m.op
  40413. }
  40414. // SetOp allows setting the mutation operation.
  40415. func (m *UsageTotalMutation) SetOp(op Op) {
  40416. m.op = op
  40417. }
  40418. // Type returns the node type of this mutation (UsageTotal).
  40419. func (m *UsageTotalMutation) Type() string {
  40420. return m.typ
  40421. }
  40422. // Fields returns all fields that were changed during this mutation. Note that in
  40423. // order to get all numeric fields that were incremented/decremented, call
  40424. // AddedFields().
  40425. func (m *UsageTotalMutation) Fields() []string {
  40426. fields := make([]string, 0, 10)
  40427. if m.created_at != nil {
  40428. fields = append(fields, usagetotal.FieldCreatedAt)
  40429. }
  40430. if m.updated_at != nil {
  40431. fields = append(fields, usagetotal.FieldUpdatedAt)
  40432. }
  40433. if m.status != nil {
  40434. fields = append(fields, usagetotal.FieldStatus)
  40435. }
  40436. if m._type != nil {
  40437. fields = append(fields, usagetotal.FieldType)
  40438. }
  40439. if m.bot_id != nil {
  40440. fields = append(fields, usagetotal.FieldBotID)
  40441. }
  40442. if m.total_tokens != nil {
  40443. fields = append(fields, usagetotal.FieldTotalTokens)
  40444. }
  40445. if m.credits != nil {
  40446. fields = append(fields, usagetotal.FieldCredits)
  40447. }
  40448. if m.start_index != nil {
  40449. fields = append(fields, usagetotal.FieldStartIndex)
  40450. }
  40451. if m.end_index != nil {
  40452. fields = append(fields, usagetotal.FieldEndIndex)
  40453. }
  40454. if m.organization_id != nil {
  40455. fields = append(fields, usagetotal.FieldOrganizationID)
  40456. }
  40457. return fields
  40458. }
  40459. // Field returns the value of a field with the given name. The second boolean
  40460. // return value indicates that this field was not set, or was not defined in the
  40461. // schema.
  40462. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  40463. switch name {
  40464. case usagetotal.FieldCreatedAt:
  40465. return m.CreatedAt()
  40466. case usagetotal.FieldUpdatedAt:
  40467. return m.UpdatedAt()
  40468. case usagetotal.FieldStatus:
  40469. return m.Status()
  40470. case usagetotal.FieldType:
  40471. return m.GetType()
  40472. case usagetotal.FieldBotID:
  40473. return m.BotID()
  40474. case usagetotal.FieldTotalTokens:
  40475. return m.TotalTokens()
  40476. case usagetotal.FieldCredits:
  40477. return m.Credits()
  40478. case usagetotal.FieldStartIndex:
  40479. return m.StartIndex()
  40480. case usagetotal.FieldEndIndex:
  40481. return m.EndIndex()
  40482. case usagetotal.FieldOrganizationID:
  40483. return m.OrganizationID()
  40484. }
  40485. return nil, false
  40486. }
  40487. // OldField returns the old value of the field from the database. An error is
  40488. // returned if the mutation operation is not UpdateOne, or the query to the
  40489. // database failed.
  40490. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  40491. switch name {
  40492. case usagetotal.FieldCreatedAt:
  40493. return m.OldCreatedAt(ctx)
  40494. case usagetotal.FieldUpdatedAt:
  40495. return m.OldUpdatedAt(ctx)
  40496. case usagetotal.FieldStatus:
  40497. return m.OldStatus(ctx)
  40498. case usagetotal.FieldType:
  40499. return m.OldType(ctx)
  40500. case usagetotal.FieldBotID:
  40501. return m.OldBotID(ctx)
  40502. case usagetotal.FieldTotalTokens:
  40503. return m.OldTotalTokens(ctx)
  40504. case usagetotal.FieldCredits:
  40505. return m.OldCredits(ctx)
  40506. case usagetotal.FieldStartIndex:
  40507. return m.OldStartIndex(ctx)
  40508. case usagetotal.FieldEndIndex:
  40509. return m.OldEndIndex(ctx)
  40510. case usagetotal.FieldOrganizationID:
  40511. return m.OldOrganizationID(ctx)
  40512. }
  40513. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  40514. }
  40515. // SetField sets the value of a field with the given name. It returns an error if
  40516. // the field is not defined in the schema, or if the type mismatched the field
  40517. // type.
  40518. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  40519. switch name {
  40520. case usagetotal.FieldCreatedAt:
  40521. v, ok := value.(time.Time)
  40522. if !ok {
  40523. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40524. }
  40525. m.SetCreatedAt(v)
  40526. return nil
  40527. case usagetotal.FieldUpdatedAt:
  40528. v, ok := value.(time.Time)
  40529. if !ok {
  40530. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40531. }
  40532. m.SetUpdatedAt(v)
  40533. return nil
  40534. case usagetotal.FieldStatus:
  40535. v, ok := value.(uint8)
  40536. if !ok {
  40537. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40538. }
  40539. m.SetStatus(v)
  40540. return nil
  40541. case usagetotal.FieldType:
  40542. v, ok := value.(int)
  40543. if !ok {
  40544. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40545. }
  40546. m.SetType(v)
  40547. return nil
  40548. case usagetotal.FieldBotID:
  40549. v, ok := value.(string)
  40550. if !ok {
  40551. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40552. }
  40553. m.SetBotID(v)
  40554. return nil
  40555. case usagetotal.FieldTotalTokens:
  40556. v, ok := value.(uint64)
  40557. if !ok {
  40558. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40559. }
  40560. m.SetTotalTokens(v)
  40561. return nil
  40562. case usagetotal.FieldCredits:
  40563. v, ok := value.(float64)
  40564. if !ok {
  40565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40566. }
  40567. m.SetCredits(v)
  40568. return nil
  40569. case usagetotal.FieldStartIndex:
  40570. v, ok := value.(uint64)
  40571. if !ok {
  40572. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40573. }
  40574. m.SetStartIndex(v)
  40575. return nil
  40576. case usagetotal.FieldEndIndex:
  40577. v, ok := value.(uint64)
  40578. if !ok {
  40579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40580. }
  40581. m.SetEndIndex(v)
  40582. return nil
  40583. case usagetotal.FieldOrganizationID:
  40584. v, ok := value.(uint64)
  40585. if !ok {
  40586. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40587. }
  40588. m.SetOrganizationID(v)
  40589. return nil
  40590. }
  40591. return fmt.Errorf("unknown UsageTotal field %s", name)
  40592. }
  40593. // AddedFields returns all numeric fields that were incremented/decremented during
  40594. // this mutation.
  40595. func (m *UsageTotalMutation) AddedFields() []string {
  40596. var fields []string
  40597. if m.addstatus != nil {
  40598. fields = append(fields, usagetotal.FieldStatus)
  40599. }
  40600. if m.add_type != nil {
  40601. fields = append(fields, usagetotal.FieldType)
  40602. }
  40603. if m.addtotal_tokens != nil {
  40604. fields = append(fields, usagetotal.FieldTotalTokens)
  40605. }
  40606. if m.addcredits != nil {
  40607. fields = append(fields, usagetotal.FieldCredits)
  40608. }
  40609. if m.addstart_index != nil {
  40610. fields = append(fields, usagetotal.FieldStartIndex)
  40611. }
  40612. if m.addend_index != nil {
  40613. fields = append(fields, usagetotal.FieldEndIndex)
  40614. }
  40615. if m.addorganization_id != nil {
  40616. fields = append(fields, usagetotal.FieldOrganizationID)
  40617. }
  40618. return fields
  40619. }
  40620. // AddedField returns the numeric value that was incremented/decremented on a field
  40621. // with the given name. The second boolean return value indicates that this field
  40622. // was not set, or was not defined in the schema.
  40623. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  40624. switch name {
  40625. case usagetotal.FieldStatus:
  40626. return m.AddedStatus()
  40627. case usagetotal.FieldType:
  40628. return m.AddedType()
  40629. case usagetotal.FieldTotalTokens:
  40630. return m.AddedTotalTokens()
  40631. case usagetotal.FieldCredits:
  40632. return m.AddedCredits()
  40633. case usagetotal.FieldStartIndex:
  40634. return m.AddedStartIndex()
  40635. case usagetotal.FieldEndIndex:
  40636. return m.AddedEndIndex()
  40637. case usagetotal.FieldOrganizationID:
  40638. return m.AddedOrganizationID()
  40639. }
  40640. return nil, false
  40641. }
  40642. // AddField adds the value to the field with the given name. It returns an error if
  40643. // the field is not defined in the schema, or if the type mismatched the field
  40644. // type.
  40645. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  40646. switch name {
  40647. case usagetotal.FieldStatus:
  40648. v, ok := value.(int8)
  40649. if !ok {
  40650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40651. }
  40652. m.AddStatus(v)
  40653. return nil
  40654. case usagetotal.FieldType:
  40655. v, ok := value.(int)
  40656. if !ok {
  40657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40658. }
  40659. m.AddType(v)
  40660. return nil
  40661. case usagetotal.FieldTotalTokens:
  40662. v, ok := value.(int64)
  40663. if !ok {
  40664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40665. }
  40666. m.AddTotalTokens(v)
  40667. return nil
  40668. case usagetotal.FieldCredits:
  40669. v, ok := value.(float64)
  40670. if !ok {
  40671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40672. }
  40673. m.AddCredits(v)
  40674. return nil
  40675. case usagetotal.FieldStartIndex:
  40676. v, ok := value.(int64)
  40677. if !ok {
  40678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40679. }
  40680. m.AddStartIndex(v)
  40681. return nil
  40682. case usagetotal.FieldEndIndex:
  40683. v, ok := value.(int64)
  40684. if !ok {
  40685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40686. }
  40687. m.AddEndIndex(v)
  40688. return nil
  40689. case usagetotal.FieldOrganizationID:
  40690. v, ok := value.(int64)
  40691. if !ok {
  40692. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40693. }
  40694. m.AddOrganizationID(v)
  40695. return nil
  40696. }
  40697. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  40698. }
  40699. // ClearedFields returns all nullable fields that were cleared during this
  40700. // mutation.
  40701. func (m *UsageTotalMutation) ClearedFields() []string {
  40702. var fields []string
  40703. if m.FieldCleared(usagetotal.FieldStatus) {
  40704. fields = append(fields, usagetotal.FieldStatus)
  40705. }
  40706. if m.FieldCleared(usagetotal.FieldType) {
  40707. fields = append(fields, usagetotal.FieldType)
  40708. }
  40709. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  40710. fields = append(fields, usagetotal.FieldTotalTokens)
  40711. }
  40712. if m.FieldCleared(usagetotal.FieldCredits) {
  40713. fields = append(fields, usagetotal.FieldCredits)
  40714. }
  40715. if m.FieldCleared(usagetotal.FieldStartIndex) {
  40716. fields = append(fields, usagetotal.FieldStartIndex)
  40717. }
  40718. if m.FieldCleared(usagetotal.FieldEndIndex) {
  40719. fields = append(fields, usagetotal.FieldEndIndex)
  40720. }
  40721. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  40722. fields = append(fields, usagetotal.FieldOrganizationID)
  40723. }
  40724. return fields
  40725. }
  40726. // FieldCleared returns a boolean indicating if a field with the given name was
  40727. // cleared in this mutation.
  40728. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  40729. _, ok := m.clearedFields[name]
  40730. return ok
  40731. }
  40732. // ClearField clears the value of the field with the given name. It returns an
  40733. // error if the field is not defined in the schema.
  40734. func (m *UsageTotalMutation) ClearField(name string) error {
  40735. switch name {
  40736. case usagetotal.FieldStatus:
  40737. m.ClearStatus()
  40738. return nil
  40739. case usagetotal.FieldType:
  40740. m.ClearType()
  40741. return nil
  40742. case usagetotal.FieldTotalTokens:
  40743. m.ClearTotalTokens()
  40744. return nil
  40745. case usagetotal.FieldCredits:
  40746. m.ClearCredits()
  40747. return nil
  40748. case usagetotal.FieldStartIndex:
  40749. m.ClearStartIndex()
  40750. return nil
  40751. case usagetotal.FieldEndIndex:
  40752. m.ClearEndIndex()
  40753. return nil
  40754. case usagetotal.FieldOrganizationID:
  40755. m.ClearOrganizationID()
  40756. return nil
  40757. }
  40758. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  40759. }
  40760. // ResetField resets all changes in the mutation for the field with the given name.
  40761. // It returns an error if the field is not defined in the schema.
  40762. func (m *UsageTotalMutation) ResetField(name string) error {
  40763. switch name {
  40764. case usagetotal.FieldCreatedAt:
  40765. m.ResetCreatedAt()
  40766. return nil
  40767. case usagetotal.FieldUpdatedAt:
  40768. m.ResetUpdatedAt()
  40769. return nil
  40770. case usagetotal.FieldStatus:
  40771. m.ResetStatus()
  40772. return nil
  40773. case usagetotal.FieldType:
  40774. m.ResetType()
  40775. return nil
  40776. case usagetotal.FieldBotID:
  40777. m.ResetBotID()
  40778. return nil
  40779. case usagetotal.FieldTotalTokens:
  40780. m.ResetTotalTokens()
  40781. return nil
  40782. case usagetotal.FieldCredits:
  40783. m.ResetCredits()
  40784. return nil
  40785. case usagetotal.FieldStartIndex:
  40786. m.ResetStartIndex()
  40787. return nil
  40788. case usagetotal.FieldEndIndex:
  40789. m.ResetEndIndex()
  40790. return nil
  40791. case usagetotal.FieldOrganizationID:
  40792. m.ResetOrganizationID()
  40793. return nil
  40794. }
  40795. return fmt.Errorf("unknown UsageTotal field %s", name)
  40796. }
  40797. // AddedEdges returns all edge names that were set/added in this mutation.
  40798. func (m *UsageTotalMutation) AddedEdges() []string {
  40799. edges := make([]string, 0, 0)
  40800. return edges
  40801. }
  40802. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  40803. // name in this mutation.
  40804. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  40805. return nil
  40806. }
  40807. // RemovedEdges returns all edge names that were removed in this mutation.
  40808. func (m *UsageTotalMutation) RemovedEdges() []string {
  40809. edges := make([]string, 0, 0)
  40810. return edges
  40811. }
  40812. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  40813. // the given name in this mutation.
  40814. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  40815. return nil
  40816. }
  40817. // ClearedEdges returns all edge names that were cleared in this mutation.
  40818. func (m *UsageTotalMutation) ClearedEdges() []string {
  40819. edges := make([]string, 0, 0)
  40820. return edges
  40821. }
  40822. // EdgeCleared returns a boolean which indicates if the edge with the given name
  40823. // was cleared in this mutation.
  40824. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  40825. return false
  40826. }
  40827. // ClearEdge clears the value of the edge with the given name. It returns an error
  40828. // if that edge is not defined in the schema.
  40829. func (m *UsageTotalMutation) ClearEdge(name string) error {
  40830. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  40831. }
  40832. // ResetEdge resets all changes to the edge with the given name in this mutation.
  40833. // It returns an error if the edge is not defined in the schema.
  40834. func (m *UsageTotalMutation) ResetEdge(name string) error {
  40835. return fmt.Errorf("unknown UsageTotal edge %s", name)
  40836. }
  40837. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  40838. type WhatsappMutation struct {
  40839. config
  40840. op Op
  40841. typ string
  40842. id *uint64
  40843. created_at *time.Time
  40844. updated_at *time.Time
  40845. status *uint8
  40846. addstatus *int8
  40847. deleted_at *time.Time
  40848. wa_id *string
  40849. wa_name *string
  40850. callback *string
  40851. account *string
  40852. cc *string
  40853. phone *string
  40854. cc_phone *string
  40855. phone_name *string
  40856. phone_status *int8
  40857. addphone_status *int8
  40858. organization_id *uint64
  40859. addorganization_id *int64
  40860. api_base *string
  40861. api_key *string
  40862. allow_list *[]string
  40863. appendallow_list []string
  40864. group_allow_list *[]string
  40865. appendgroup_allow_list []string
  40866. block_list *[]string
  40867. appendblock_list []string
  40868. group_block_list *[]string
  40869. appendgroup_block_list []string
  40870. clearedFields map[string]struct{}
  40871. agent *uint64
  40872. clearedagent bool
  40873. done bool
  40874. oldValue func(context.Context) (*Whatsapp, error)
  40875. predicates []predicate.Whatsapp
  40876. }
  40877. var _ ent.Mutation = (*WhatsappMutation)(nil)
  40878. // whatsappOption allows management of the mutation configuration using functional options.
  40879. type whatsappOption func(*WhatsappMutation)
  40880. // newWhatsappMutation creates new mutation for the Whatsapp entity.
  40881. func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
  40882. m := &WhatsappMutation{
  40883. config: c,
  40884. op: op,
  40885. typ: TypeWhatsapp,
  40886. clearedFields: make(map[string]struct{}),
  40887. }
  40888. for _, opt := range opts {
  40889. opt(m)
  40890. }
  40891. return m
  40892. }
  40893. // withWhatsappID sets the ID field of the mutation.
  40894. func withWhatsappID(id uint64) whatsappOption {
  40895. return func(m *WhatsappMutation) {
  40896. var (
  40897. err error
  40898. once sync.Once
  40899. value *Whatsapp
  40900. )
  40901. m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
  40902. once.Do(func() {
  40903. if m.done {
  40904. err = errors.New("querying old values post mutation is not allowed")
  40905. } else {
  40906. value, err = m.Client().Whatsapp.Get(ctx, id)
  40907. }
  40908. })
  40909. return value, err
  40910. }
  40911. m.id = &id
  40912. }
  40913. }
  40914. // withWhatsapp sets the old Whatsapp of the mutation.
  40915. func withWhatsapp(node *Whatsapp) whatsappOption {
  40916. return func(m *WhatsappMutation) {
  40917. m.oldValue = func(context.Context) (*Whatsapp, error) {
  40918. return node, nil
  40919. }
  40920. m.id = &node.ID
  40921. }
  40922. }
  40923. // Client returns a new `ent.Client` from the mutation. If the mutation was
  40924. // executed in a transaction (ent.Tx), a transactional client is returned.
  40925. func (m WhatsappMutation) Client() *Client {
  40926. client := &Client{config: m.config}
  40927. client.init()
  40928. return client
  40929. }
  40930. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  40931. // it returns an error otherwise.
  40932. func (m WhatsappMutation) Tx() (*Tx, error) {
  40933. if _, ok := m.driver.(*txDriver); !ok {
  40934. return nil, errors.New("ent: mutation is not running in a transaction")
  40935. }
  40936. tx := &Tx{config: m.config}
  40937. tx.init()
  40938. return tx, nil
  40939. }
  40940. // SetID sets the value of the id field. Note that this
  40941. // operation is only accepted on creation of Whatsapp entities.
  40942. func (m *WhatsappMutation) SetID(id uint64) {
  40943. m.id = &id
  40944. }
  40945. // ID returns the ID value in the mutation. Note that the ID is only available
  40946. // if it was provided to the builder or after it was returned from the database.
  40947. func (m *WhatsappMutation) ID() (id uint64, exists bool) {
  40948. if m.id == nil {
  40949. return
  40950. }
  40951. return *m.id, true
  40952. }
  40953. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  40954. // That means, if the mutation is applied within a transaction with an isolation level such
  40955. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  40956. // or updated by the mutation.
  40957. func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
  40958. switch {
  40959. case m.op.Is(OpUpdateOne | OpDeleteOne):
  40960. id, exists := m.ID()
  40961. if exists {
  40962. return []uint64{id}, nil
  40963. }
  40964. fallthrough
  40965. case m.op.Is(OpUpdate | OpDelete):
  40966. return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
  40967. default:
  40968. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  40969. }
  40970. }
  40971. // SetCreatedAt sets the "created_at" field.
  40972. func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
  40973. m.created_at = &t
  40974. }
  40975. // CreatedAt returns the value of the "created_at" field in the mutation.
  40976. func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
  40977. v := m.created_at
  40978. if v == nil {
  40979. return
  40980. }
  40981. return *v, true
  40982. }
  40983. // OldCreatedAt returns the old "created_at" field's value of the Whatsapp entity.
  40984. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40985. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40986. func (m *WhatsappMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  40987. if !m.op.Is(OpUpdateOne) {
  40988. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  40989. }
  40990. if m.id == nil || m.oldValue == nil {
  40991. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  40992. }
  40993. oldValue, err := m.oldValue(ctx)
  40994. if err != nil {
  40995. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  40996. }
  40997. return oldValue.CreatedAt, nil
  40998. }
  40999. // ResetCreatedAt resets all changes to the "created_at" field.
  41000. func (m *WhatsappMutation) ResetCreatedAt() {
  41001. m.created_at = nil
  41002. }
  41003. // SetUpdatedAt sets the "updated_at" field.
  41004. func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
  41005. m.updated_at = &t
  41006. }
  41007. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  41008. func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
  41009. v := m.updated_at
  41010. if v == nil {
  41011. return
  41012. }
  41013. return *v, true
  41014. }
  41015. // OldUpdatedAt returns the old "updated_at" field's value of the Whatsapp entity.
  41016. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41017. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41018. func (m *WhatsappMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  41019. if !m.op.Is(OpUpdateOne) {
  41020. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  41021. }
  41022. if m.id == nil || m.oldValue == nil {
  41023. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  41024. }
  41025. oldValue, err := m.oldValue(ctx)
  41026. if err != nil {
  41027. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  41028. }
  41029. return oldValue.UpdatedAt, nil
  41030. }
  41031. // ResetUpdatedAt resets all changes to the "updated_at" field.
  41032. func (m *WhatsappMutation) ResetUpdatedAt() {
  41033. m.updated_at = nil
  41034. }
  41035. // SetStatus sets the "status" field.
  41036. func (m *WhatsappMutation) SetStatus(u uint8) {
  41037. m.status = &u
  41038. m.addstatus = nil
  41039. }
  41040. // Status returns the value of the "status" field in the mutation.
  41041. func (m *WhatsappMutation) Status() (r uint8, exists bool) {
  41042. v := m.status
  41043. if v == nil {
  41044. return
  41045. }
  41046. return *v, true
  41047. }
  41048. // OldStatus returns the old "status" field's value of the Whatsapp entity.
  41049. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41050. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41051. func (m *WhatsappMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  41052. if !m.op.Is(OpUpdateOne) {
  41053. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  41054. }
  41055. if m.id == nil || m.oldValue == nil {
  41056. return v, errors.New("OldStatus requires an ID field in the mutation")
  41057. }
  41058. oldValue, err := m.oldValue(ctx)
  41059. if err != nil {
  41060. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  41061. }
  41062. return oldValue.Status, nil
  41063. }
  41064. // AddStatus adds u to the "status" field.
  41065. func (m *WhatsappMutation) AddStatus(u int8) {
  41066. if m.addstatus != nil {
  41067. *m.addstatus += u
  41068. } else {
  41069. m.addstatus = &u
  41070. }
  41071. }
  41072. // AddedStatus returns the value that was added to the "status" field in this mutation.
  41073. func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
  41074. v := m.addstatus
  41075. if v == nil {
  41076. return
  41077. }
  41078. return *v, true
  41079. }
  41080. // ClearStatus clears the value of the "status" field.
  41081. func (m *WhatsappMutation) ClearStatus() {
  41082. m.status = nil
  41083. m.addstatus = nil
  41084. m.clearedFields[whatsapp.FieldStatus] = struct{}{}
  41085. }
  41086. // StatusCleared returns if the "status" field was cleared in this mutation.
  41087. func (m *WhatsappMutation) StatusCleared() bool {
  41088. _, ok := m.clearedFields[whatsapp.FieldStatus]
  41089. return ok
  41090. }
  41091. // ResetStatus resets all changes to the "status" field.
  41092. func (m *WhatsappMutation) ResetStatus() {
  41093. m.status = nil
  41094. m.addstatus = nil
  41095. delete(m.clearedFields, whatsapp.FieldStatus)
  41096. }
  41097. // SetDeletedAt sets the "deleted_at" field.
  41098. func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
  41099. m.deleted_at = &t
  41100. }
  41101. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  41102. func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
  41103. v := m.deleted_at
  41104. if v == nil {
  41105. return
  41106. }
  41107. return *v, true
  41108. }
  41109. // OldDeletedAt returns the old "deleted_at" field's value of the Whatsapp entity.
  41110. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41111. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41112. func (m *WhatsappMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  41113. if !m.op.Is(OpUpdateOne) {
  41114. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  41115. }
  41116. if m.id == nil || m.oldValue == nil {
  41117. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  41118. }
  41119. oldValue, err := m.oldValue(ctx)
  41120. if err != nil {
  41121. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  41122. }
  41123. return oldValue.DeletedAt, nil
  41124. }
  41125. // ClearDeletedAt clears the value of the "deleted_at" field.
  41126. func (m *WhatsappMutation) ClearDeletedAt() {
  41127. m.deleted_at = nil
  41128. m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
  41129. }
  41130. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  41131. func (m *WhatsappMutation) DeletedAtCleared() bool {
  41132. _, ok := m.clearedFields[whatsapp.FieldDeletedAt]
  41133. return ok
  41134. }
  41135. // ResetDeletedAt resets all changes to the "deleted_at" field.
  41136. func (m *WhatsappMutation) ResetDeletedAt() {
  41137. m.deleted_at = nil
  41138. delete(m.clearedFields, whatsapp.FieldDeletedAt)
  41139. }
  41140. // SetWaID sets the "wa_id" field.
  41141. func (m *WhatsappMutation) SetWaID(s string) {
  41142. m.wa_id = &s
  41143. }
  41144. // WaID returns the value of the "wa_id" field in the mutation.
  41145. func (m *WhatsappMutation) WaID() (r string, exists bool) {
  41146. v := m.wa_id
  41147. if v == nil {
  41148. return
  41149. }
  41150. return *v, true
  41151. }
  41152. // OldWaID returns the old "wa_id" field's value of the Whatsapp entity.
  41153. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41154. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41155. func (m *WhatsappMutation) OldWaID(ctx context.Context) (v string, err error) {
  41156. if !m.op.Is(OpUpdateOne) {
  41157. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  41158. }
  41159. if m.id == nil || m.oldValue == nil {
  41160. return v, errors.New("OldWaID requires an ID field in the mutation")
  41161. }
  41162. oldValue, err := m.oldValue(ctx)
  41163. if err != nil {
  41164. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  41165. }
  41166. return oldValue.WaID, nil
  41167. }
  41168. // ClearWaID clears the value of the "wa_id" field.
  41169. func (m *WhatsappMutation) ClearWaID() {
  41170. m.wa_id = nil
  41171. m.clearedFields[whatsapp.FieldWaID] = struct{}{}
  41172. }
  41173. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  41174. func (m *WhatsappMutation) WaIDCleared() bool {
  41175. _, ok := m.clearedFields[whatsapp.FieldWaID]
  41176. return ok
  41177. }
  41178. // ResetWaID resets all changes to the "wa_id" field.
  41179. func (m *WhatsappMutation) ResetWaID() {
  41180. m.wa_id = nil
  41181. delete(m.clearedFields, whatsapp.FieldWaID)
  41182. }
  41183. // SetWaName sets the "wa_name" field.
  41184. func (m *WhatsappMutation) SetWaName(s string) {
  41185. m.wa_name = &s
  41186. }
  41187. // WaName returns the value of the "wa_name" field in the mutation.
  41188. func (m *WhatsappMutation) WaName() (r string, exists bool) {
  41189. v := m.wa_name
  41190. if v == nil {
  41191. return
  41192. }
  41193. return *v, true
  41194. }
  41195. // OldWaName returns the old "wa_name" field's value of the Whatsapp entity.
  41196. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41197. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41198. func (m *WhatsappMutation) OldWaName(ctx context.Context) (v string, err error) {
  41199. if !m.op.Is(OpUpdateOne) {
  41200. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  41201. }
  41202. if m.id == nil || m.oldValue == nil {
  41203. return v, errors.New("OldWaName requires an ID field in the mutation")
  41204. }
  41205. oldValue, err := m.oldValue(ctx)
  41206. if err != nil {
  41207. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  41208. }
  41209. return oldValue.WaName, nil
  41210. }
  41211. // ClearWaName clears the value of the "wa_name" field.
  41212. func (m *WhatsappMutation) ClearWaName() {
  41213. m.wa_name = nil
  41214. m.clearedFields[whatsapp.FieldWaName] = struct{}{}
  41215. }
  41216. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  41217. func (m *WhatsappMutation) WaNameCleared() bool {
  41218. _, ok := m.clearedFields[whatsapp.FieldWaName]
  41219. return ok
  41220. }
  41221. // ResetWaName resets all changes to the "wa_name" field.
  41222. func (m *WhatsappMutation) ResetWaName() {
  41223. m.wa_name = nil
  41224. delete(m.clearedFields, whatsapp.FieldWaName)
  41225. }
  41226. // SetCallback sets the "callback" field.
  41227. func (m *WhatsappMutation) SetCallback(s string) {
  41228. m.callback = &s
  41229. }
  41230. // Callback returns the value of the "callback" field in the mutation.
  41231. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  41232. v := m.callback
  41233. if v == nil {
  41234. return
  41235. }
  41236. return *v, true
  41237. }
  41238. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  41239. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41240. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41241. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  41242. if !m.op.Is(OpUpdateOne) {
  41243. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  41244. }
  41245. if m.id == nil || m.oldValue == nil {
  41246. return v, errors.New("OldCallback requires an ID field in the mutation")
  41247. }
  41248. oldValue, err := m.oldValue(ctx)
  41249. if err != nil {
  41250. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  41251. }
  41252. return oldValue.Callback, nil
  41253. }
  41254. // ClearCallback clears the value of the "callback" field.
  41255. func (m *WhatsappMutation) ClearCallback() {
  41256. m.callback = nil
  41257. m.clearedFields[whatsapp.FieldCallback] = struct{}{}
  41258. }
  41259. // CallbackCleared returns if the "callback" field was cleared in this mutation.
  41260. func (m *WhatsappMutation) CallbackCleared() bool {
  41261. _, ok := m.clearedFields[whatsapp.FieldCallback]
  41262. return ok
  41263. }
  41264. // ResetCallback resets all changes to the "callback" field.
  41265. func (m *WhatsappMutation) ResetCallback() {
  41266. m.callback = nil
  41267. delete(m.clearedFields, whatsapp.FieldCallback)
  41268. }
  41269. // SetAgentID sets the "agent_id" field.
  41270. func (m *WhatsappMutation) SetAgentID(u uint64) {
  41271. m.agent = &u
  41272. }
  41273. // AgentID returns the value of the "agent_id" field in the mutation.
  41274. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  41275. v := m.agent
  41276. if v == nil {
  41277. return
  41278. }
  41279. return *v, true
  41280. }
  41281. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  41282. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41283. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41284. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  41285. if !m.op.Is(OpUpdateOne) {
  41286. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  41287. }
  41288. if m.id == nil || m.oldValue == nil {
  41289. return v, errors.New("OldAgentID requires an ID field in the mutation")
  41290. }
  41291. oldValue, err := m.oldValue(ctx)
  41292. if err != nil {
  41293. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  41294. }
  41295. return oldValue.AgentID, nil
  41296. }
  41297. // ResetAgentID resets all changes to the "agent_id" field.
  41298. func (m *WhatsappMutation) ResetAgentID() {
  41299. m.agent = nil
  41300. }
  41301. // SetAccount sets the "account" field.
  41302. func (m *WhatsappMutation) SetAccount(s string) {
  41303. m.account = &s
  41304. }
  41305. // Account returns the value of the "account" field in the mutation.
  41306. func (m *WhatsappMutation) Account() (r string, exists bool) {
  41307. v := m.account
  41308. if v == nil {
  41309. return
  41310. }
  41311. return *v, true
  41312. }
  41313. // OldAccount returns the old "account" field's value of the Whatsapp entity.
  41314. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41316. func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error) {
  41317. if !m.op.Is(OpUpdateOne) {
  41318. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  41319. }
  41320. if m.id == nil || m.oldValue == nil {
  41321. return v, errors.New("OldAccount requires an ID field in the mutation")
  41322. }
  41323. oldValue, err := m.oldValue(ctx)
  41324. if err != nil {
  41325. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  41326. }
  41327. return oldValue.Account, nil
  41328. }
  41329. // ClearAccount clears the value of the "account" field.
  41330. func (m *WhatsappMutation) ClearAccount() {
  41331. m.account = nil
  41332. m.clearedFields[whatsapp.FieldAccount] = struct{}{}
  41333. }
  41334. // AccountCleared returns if the "account" field was cleared in this mutation.
  41335. func (m *WhatsappMutation) AccountCleared() bool {
  41336. _, ok := m.clearedFields[whatsapp.FieldAccount]
  41337. return ok
  41338. }
  41339. // ResetAccount resets all changes to the "account" field.
  41340. func (m *WhatsappMutation) ResetAccount() {
  41341. m.account = nil
  41342. delete(m.clearedFields, whatsapp.FieldAccount)
  41343. }
  41344. // SetCc sets the "cc" field.
  41345. func (m *WhatsappMutation) SetCc(s string) {
  41346. m.cc = &s
  41347. }
  41348. // Cc returns the value of the "cc" field in the mutation.
  41349. func (m *WhatsappMutation) Cc() (r string, exists bool) {
  41350. v := m.cc
  41351. if v == nil {
  41352. return
  41353. }
  41354. return *v, true
  41355. }
  41356. // OldCc returns the old "cc" field's value of the Whatsapp entity.
  41357. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41358. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41359. func (m *WhatsappMutation) OldCc(ctx context.Context) (v string, err error) {
  41360. if !m.op.Is(OpUpdateOne) {
  41361. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  41362. }
  41363. if m.id == nil || m.oldValue == nil {
  41364. return v, errors.New("OldCc requires an ID field in the mutation")
  41365. }
  41366. oldValue, err := m.oldValue(ctx)
  41367. if err != nil {
  41368. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  41369. }
  41370. return oldValue.Cc, nil
  41371. }
  41372. // ResetCc resets all changes to the "cc" field.
  41373. func (m *WhatsappMutation) ResetCc() {
  41374. m.cc = nil
  41375. }
  41376. // SetPhone sets the "phone" field.
  41377. func (m *WhatsappMutation) SetPhone(s string) {
  41378. m.phone = &s
  41379. }
  41380. // Phone returns the value of the "phone" field in the mutation.
  41381. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  41382. v := m.phone
  41383. if v == nil {
  41384. return
  41385. }
  41386. return *v, true
  41387. }
  41388. // OldPhone returns the old "phone" field's value of the Whatsapp entity.
  41389. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41390. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41391. func (m *WhatsappMutation) OldPhone(ctx context.Context) (v string, err error) {
  41392. if !m.op.Is(OpUpdateOne) {
  41393. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  41394. }
  41395. if m.id == nil || m.oldValue == nil {
  41396. return v, errors.New("OldPhone requires an ID field in the mutation")
  41397. }
  41398. oldValue, err := m.oldValue(ctx)
  41399. if err != nil {
  41400. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  41401. }
  41402. return oldValue.Phone, nil
  41403. }
  41404. // ResetPhone resets all changes to the "phone" field.
  41405. func (m *WhatsappMutation) ResetPhone() {
  41406. m.phone = nil
  41407. }
  41408. // SetCcPhone sets the "cc_phone" field.
  41409. func (m *WhatsappMutation) SetCcPhone(s string) {
  41410. m.cc_phone = &s
  41411. }
  41412. // CcPhone returns the value of the "cc_phone" field in the mutation.
  41413. func (m *WhatsappMutation) CcPhone() (r string, exists bool) {
  41414. v := m.cc_phone
  41415. if v == nil {
  41416. return
  41417. }
  41418. return *v, true
  41419. }
  41420. // OldCcPhone returns the old "cc_phone" field's value of the Whatsapp entity.
  41421. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41422. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41423. func (m *WhatsappMutation) OldCcPhone(ctx context.Context) (v string, err error) {
  41424. if !m.op.Is(OpUpdateOne) {
  41425. return v, errors.New("OldCcPhone is only allowed on UpdateOne operations")
  41426. }
  41427. if m.id == nil || m.oldValue == nil {
  41428. return v, errors.New("OldCcPhone requires an ID field in the mutation")
  41429. }
  41430. oldValue, err := m.oldValue(ctx)
  41431. if err != nil {
  41432. return v, fmt.Errorf("querying old value for OldCcPhone: %w", err)
  41433. }
  41434. return oldValue.CcPhone, nil
  41435. }
  41436. // ResetCcPhone resets all changes to the "cc_phone" field.
  41437. func (m *WhatsappMutation) ResetCcPhone() {
  41438. m.cc_phone = nil
  41439. }
  41440. // SetPhoneName sets the "phone_name" field.
  41441. func (m *WhatsappMutation) SetPhoneName(s string) {
  41442. m.phone_name = &s
  41443. }
  41444. // PhoneName returns the value of the "phone_name" field in the mutation.
  41445. func (m *WhatsappMutation) PhoneName() (r string, exists bool) {
  41446. v := m.phone_name
  41447. if v == nil {
  41448. return
  41449. }
  41450. return *v, true
  41451. }
  41452. // OldPhoneName returns the old "phone_name" field's value of the Whatsapp entity.
  41453. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41454. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41455. func (m *WhatsappMutation) OldPhoneName(ctx context.Context) (v string, err error) {
  41456. if !m.op.Is(OpUpdateOne) {
  41457. return v, errors.New("OldPhoneName is only allowed on UpdateOne operations")
  41458. }
  41459. if m.id == nil || m.oldValue == nil {
  41460. return v, errors.New("OldPhoneName requires an ID field in the mutation")
  41461. }
  41462. oldValue, err := m.oldValue(ctx)
  41463. if err != nil {
  41464. return v, fmt.Errorf("querying old value for OldPhoneName: %w", err)
  41465. }
  41466. return oldValue.PhoneName, nil
  41467. }
  41468. // ResetPhoneName resets all changes to the "phone_name" field.
  41469. func (m *WhatsappMutation) ResetPhoneName() {
  41470. m.phone_name = nil
  41471. }
  41472. // SetPhoneStatus sets the "phone_status" field.
  41473. func (m *WhatsappMutation) SetPhoneStatus(i int8) {
  41474. m.phone_status = &i
  41475. m.addphone_status = nil
  41476. }
  41477. // PhoneStatus returns the value of the "phone_status" field in the mutation.
  41478. func (m *WhatsappMutation) PhoneStatus() (r int8, exists bool) {
  41479. v := m.phone_status
  41480. if v == nil {
  41481. return
  41482. }
  41483. return *v, true
  41484. }
  41485. // OldPhoneStatus returns the old "phone_status" field's value of the Whatsapp entity.
  41486. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41487. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41488. func (m *WhatsappMutation) OldPhoneStatus(ctx context.Context) (v int8, err error) {
  41489. if !m.op.Is(OpUpdateOne) {
  41490. return v, errors.New("OldPhoneStatus is only allowed on UpdateOne operations")
  41491. }
  41492. if m.id == nil || m.oldValue == nil {
  41493. return v, errors.New("OldPhoneStatus requires an ID field in the mutation")
  41494. }
  41495. oldValue, err := m.oldValue(ctx)
  41496. if err != nil {
  41497. return v, fmt.Errorf("querying old value for OldPhoneStatus: %w", err)
  41498. }
  41499. return oldValue.PhoneStatus, nil
  41500. }
  41501. // AddPhoneStatus adds i to the "phone_status" field.
  41502. func (m *WhatsappMutation) AddPhoneStatus(i int8) {
  41503. if m.addphone_status != nil {
  41504. *m.addphone_status += i
  41505. } else {
  41506. m.addphone_status = &i
  41507. }
  41508. }
  41509. // AddedPhoneStatus returns the value that was added to the "phone_status" field in this mutation.
  41510. func (m *WhatsappMutation) AddedPhoneStatus() (r int8, exists bool) {
  41511. v := m.addphone_status
  41512. if v == nil {
  41513. return
  41514. }
  41515. return *v, true
  41516. }
  41517. // ResetPhoneStatus resets all changes to the "phone_status" field.
  41518. func (m *WhatsappMutation) ResetPhoneStatus() {
  41519. m.phone_status = nil
  41520. m.addphone_status = nil
  41521. }
  41522. // SetOrganizationID sets the "organization_id" field.
  41523. func (m *WhatsappMutation) SetOrganizationID(u uint64) {
  41524. m.organization_id = &u
  41525. m.addorganization_id = nil
  41526. }
  41527. // OrganizationID returns the value of the "organization_id" field in the mutation.
  41528. func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
  41529. v := m.organization_id
  41530. if v == nil {
  41531. return
  41532. }
  41533. return *v, true
  41534. }
  41535. // OldOrganizationID returns the old "organization_id" field's value of the Whatsapp entity.
  41536. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41537. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41538. func (m *WhatsappMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  41539. if !m.op.Is(OpUpdateOne) {
  41540. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  41541. }
  41542. if m.id == nil || m.oldValue == nil {
  41543. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  41544. }
  41545. oldValue, err := m.oldValue(ctx)
  41546. if err != nil {
  41547. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  41548. }
  41549. return oldValue.OrganizationID, nil
  41550. }
  41551. // AddOrganizationID adds u to the "organization_id" field.
  41552. func (m *WhatsappMutation) AddOrganizationID(u int64) {
  41553. if m.addorganization_id != nil {
  41554. *m.addorganization_id += u
  41555. } else {
  41556. m.addorganization_id = &u
  41557. }
  41558. }
  41559. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  41560. func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
  41561. v := m.addorganization_id
  41562. if v == nil {
  41563. return
  41564. }
  41565. return *v, true
  41566. }
  41567. // ClearOrganizationID clears the value of the "organization_id" field.
  41568. func (m *WhatsappMutation) ClearOrganizationID() {
  41569. m.organization_id = nil
  41570. m.addorganization_id = nil
  41571. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  41572. }
  41573. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  41574. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  41575. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  41576. return ok
  41577. }
  41578. // ResetOrganizationID resets all changes to the "organization_id" field.
  41579. func (m *WhatsappMutation) ResetOrganizationID() {
  41580. m.organization_id = nil
  41581. m.addorganization_id = nil
  41582. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  41583. }
  41584. // SetAPIBase sets the "api_base" field.
  41585. func (m *WhatsappMutation) SetAPIBase(s string) {
  41586. m.api_base = &s
  41587. }
  41588. // APIBase returns the value of the "api_base" field in the mutation.
  41589. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  41590. v := m.api_base
  41591. if v == nil {
  41592. return
  41593. }
  41594. return *v, true
  41595. }
  41596. // OldAPIBase returns the old "api_base" field's value of the Whatsapp entity.
  41597. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41598. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41599. func (m *WhatsappMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  41600. if !m.op.Is(OpUpdateOne) {
  41601. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  41602. }
  41603. if m.id == nil || m.oldValue == nil {
  41604. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  41605. }
  41606. oldValue, err := m.oldValue(ctx)
  41607. if err != nil {
  41608. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  41609. }
  41610. return oldValue.APIBase, nil
  41611. }
  41612. // ClearAPIBase clears the value of the "api_base" field.
  41613. func (m *WhatsappMutation) ClearAPIBase() {
  41614. m.api_base = nil
  41615. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  41616. }
  41617. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  41618. func (m *WhatsappMutation) APIBaseCleared() bool {
  41619. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  41620. return ok
  41621. }
  41622. // ResetAPIBase resets all changes to the "api_base" field.
  41623. func (m *WhatsappMutation) ResetAPIBase() {
  41624. m.api_base = nil
  41625. delete(m.clearedFields, whatsapp.FieldAPIBase)
  41626. }
  41627. // SetAPIKey sets the "api_key" field.
  41628. func (m *WhatsappMutation) SetAPIKey(s string) {
  41629. m.api_key = &s
  41630. }
  41631. // APIKey returns the value of the "api_key" field in the mutation.
  41632. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  41633. v := m.api_key
  41634. if v == nil {
  41635. return
  41636. }
  41637. return *v, true
  41638. }
  41639. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  41640. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41641. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41642. func (m *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  41643. if !m.op.Is(OpUpdateOne) {
  41644. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  41645. }
  41646. if m.id == nil || m.oldValue == nil {
  41647. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  41648. }
  41649. oldValue, err := m.oldValue(ctx)
  41650. if err != nil {
  41651. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  41652. }
  41653. return oldValue.APIKey, nil
  41654. }
  41655. // ClearAPIKey clears the value of the "api_key" field.
  41656. func (m *WhatsappMutation) ClearAPIKey() {
  41657. m.api_key = nil
  41658. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  41659. }
  41660. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  41661. func (m *WhatsappMutation) APIKeyCleared() bool {
  41662. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  41663. return ok
  41664. }
  41665. // ResetAPIKey resets all changes to the "api_key" field.
  41666. func (m *WhatsappMutation) ResetAPIKey() {
  41667. m.api_key = nil
  41668. delete(m.clearedFields, whatsapp.FieldAPIKey)
  41669. }
  41670. // SetAllowList sets the "allow_list" field.
  41671. func (m *WhatsappMutation) SetAllowList(s []string) {
  41672. m.allow_list = &s
  41673. m.appendallow_list = nil
  41674. }
  41675. // AllowList returns the value of the "allow_list" field in the mutation.
  41676. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  41677. v := m.allow_list
  41678. if v == nil {
  41679. return
  41680. }
  41681. return *v, true
  41682. }
  41683. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  41684. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41685. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41686. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  41687. if !m.op.Is(OpUpdateOne) {
  41688. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  41689. }
  41690. if m.id == nil || m.oldValue == nil {
  41691. return v, errors.New("OldAllowList requires an ID field in the mutation")
  41692. }
  41693. oldValue, err := m.oldValue(ctx)
  41694. if err != nil {
  41695. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  41696. }
  41697. return oldValue.AllowList, nil
  41698. }
  41699. // AppendAllowList adds s to the "allow_list" field.
  41700. func (m *WhatsappMutation) AppendAllowList(s []string) {
  41701. m.appendallow_list = append(m.appendallow_list, s...)
  41702. }
  41703. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  41704. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  41705. if len(m.appendallow_list) == 0 {
  41706. return nil, false
  41707. }
  41708. return m.appendallow_list, true
  41709. }
  41710. // ClearAllowList clears the value of the "allow_list" field.
  41711. func (m *WhatsappMutation) ClearAllowList() {
  41712. m.allow_list = nil
  41713. m.appendallow_list = nil
  41714. m.clearedFields[whatsapp.FieldAllowList] = struct{}{}
  41715. }
  41716. // AllowListCleared returns if the "allow_list" field was cleared in this mutation.
  41717. func (m *WhatsappMutation) AllowListCleared() bool {
  41718. _, ok := m.clearedFields[whatsapp.FieldAllowList]
  41719. return ok
  41720. }
  41721. // ResetAllowList resets all changes to the "allow_list" field.
  41722. func (m *WhatsappMutation) ResetAllowList() {
  41723. m.allow_list = nil
  41724. m.appendallow_list = nil
  41725. delete(m.clearedFields, whatsapp.FieldAllowList)
  41726. }
  41727. // SetGroupAllowList sets the "group_allow_list" field.
  41728. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  41729. m.group_allow_list = &s
  41730. m.appendgroup_allow_list = nil
  41731. }
  41732. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  41733. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  41734. v := m.group_allow_list
  41735. if v == nil {
  41736. return
  41737. }
  41738. return *v, true
  41739. }
  41740. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  41741. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41742. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41743. func (m *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  41744. if !m.op.Is(OpUpdateOne) {
  41745. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  41746. }
  41747. if m.id == nil || m.oldValue == nil {
  41748. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  41749. }
  41750. oldValue, err := m.oldValue(ctx)
  41751. if err != nil {
  41752. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  41753. }
  41754. return oldValue.GroupAllowList, nil
  41755. }
  41756. // AppendGroupAllowList adds s to the "group_allow_list" field.
  41757. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  41758. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  41759. }
  41760. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  41761. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  41762. if len(m.appendgroup_allow_list) == 0 {
  41763. return nil, false
  41764. }
  41765. return m.appendgroup_allow_list, true
  41766. }
  41767. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  41768. func (m *WhatsappMutation) ClearGroupAllowList() {
  41769. m.group_allow_list = nil
  41770. m.appendgroup_allow_list = nil
  41771. m.clearedFields[whatsapp.FieldGroupAllowList] = struct{}{}
  41772. }
  41773. // GroupAllowListCleared returns if the "group_allow_list" field was cleared in this mutation.
  41774. func (m *WhatsappMutation) GroupAllowListCleared() bool {
  41775. _, ok := m.clearedFields[whatsapp.FieldGroupAllowList]
  41776. return ok
  41777. }
  41778. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  41779. func (m *WhatsappMutation) ResetGroupAllowList() {
  41780. m.group_allow_list = nil
  41781. m.appendgroup_allow_list = nil
  41782. delete(m.clearedFields, whatsapp.FieldGroupAllowList)
  41783. }
  41784. // SetBlockList sets the "block_list" field.
  41785. func (m *WhatsappMutation) SetBlockList(s []string) {
  41786. m.block_list = &s
  41787. m.appendblock_list = nil
  41788. }
  41789. // BlockList returns the value of the "block_list" field in the mutation.
  41790. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  41791. v := m.block_list
  41792. if v == nil {
  41793. return
  41794. }
  41795. return *v, true
  41796. }
  41797. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  41798. // If the Whatsapp 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 *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  41801. if !m.op.Is(OpUpdateOne) {
  41802. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  41803. }
  41804. if m.id == nil || m.oldValue == nil {
  41805. return v, errors.New("OldBlockList 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 OldBlockList: %w", err)
  41810. }
  41811. return oldValue.BlockList, nil
  41812. }
  41813. // AppendBlockList adds s to the "block_list" field.
  41814. func (m *WhatsappMutation) AppendBlockList(s []string) {
  41815. m.appendblock_list = append(m.appendblock_list, s...)
  41816. }
  41817. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  41818. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  41819. if len(m.appendblock_list) == 0 {
  41820. return nil, false
  41821. }
  41822. return m.appendblock_list, true
  41823. }
  41824. // ClearBlockList clears the value of the "block_list" field.
  41825. func (m *WhatsappMutation) ClearBlockList() {
  41826. m.block_list = nil
  41827. m.appendblock_list = nil
  41828. m.clearedFields[whatsapp.FieldBlockList] = struct{}{}
  41829. }
  41830. // BlockListCleared returns if the "block_list" field was cleared in this mutation.
  41831. func (m *WhatsappMutation) BlockListCleared() bool {
  41832. _, ok := m.clearedFields[whatsapp.FieldBlockList]
  41833. return ok
  41834. }
  41835. // ResetBlockList resets all changes to the "block_list" field.
  41836. func (m *WhatsappMutation) ResetBlockList() {
  41837. m.block_list = nil
  41838. m.appendblock_list = nil
  41839. delete(m.clearedFields, whatsapp.FieldBlockList)
  41840. }
  41841. // SetGroupBlockList sets the "group_block_list" field.
  41842. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  41843. m.group_block_list = &s
  41844. m.appendgroup_block_list = nil
  41845. }
  41846. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  41847. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  41848. v := m.group_block_list
  41849. if v == nil {
  41850. return
  41851. }
  41852. return *v, true
  41853. }
  41854. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  41855. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41856. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41857. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  41858. if !m.op.Is(OpUpdateOne) {
  41859. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  41860. }
  41861. if m.id == nil || m.oldValue == nil {
  41862. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  41863. }
  41864. oldValue, err := m.oldValue(ctx)
  41865. if err != nil {
  41866. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  41867. }
  41868. return oldValue.GroupBlockList, nil
  41869. }
  41870. // AppendGroupBlockList adds s to the "group_block_list" field.
  41871. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  41872. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  41873. }
  41874. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  41875. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  41876. if len(m.appendgroup_block_list) == 0 {
  41877. return nil, false
  41878. }
  41879. return m.appendgroup_block_list, true
  41880. }
  41881. // ClearGroupBlockList clears the value of the "group_block_list" field.
  41882. func (m *WhatsappMutation) ClearGroupBlockList() {
  41883. m.group_block_list = nil
  41884. m.appendgroup_block_list = nil
  41885. m.clearedFields[whatsapp.FieldGroupBlockList] = struct{}{}
  41886. }
  41887. // GroupBlockListCleared returns if the "group_block_list" field was cleared in this mutation.
  41888. func (m *WhatsappMutation) GroupBlockListCleared() bool {
  41889. _, ok := m.clearedFields[whatsapp.FieldGroupBlockList]
  41890. return ok
  41891. }
  41892. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  41893. func (m *WhatsappMutation) ResetGroupBlockList() {
  41894. m.group_block_list = nil
  41895. m.appendgroup_block_list = nil
  41896. delete(m.clearedFields, whatsapp.FieldGroupBlockList)
  41897. }
  41898. // ClearAgent clears the "agent" edge to the Agent entity.
  41899. func (m *WhatsappMutation) ClearAgent() {
  41900. m.clearedagent = true
  41901. m.clearedFields[whatsapp.FieldAgentID] = struct{}{}
  41902. }
  41903. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  41904. func (m *WhatsappMutation) AgentCleared() bool {
  41905. return m.clearedagent
  41906. }
  41907. // AgentIDs returns the "agent" edge IDs in the mutation.
  41908. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  41909. // AgentID instead. It exists only for internal usage by the builders.
  41910. func (m *WhatsappMutation) AgentIDs() (ids []uint64) {
  41911. if id := m.agent; id != nil {
  41912. ids = append(ids, *id)
  41913. }
  41914. return
  41915. }
  41916. // ResetAgent resets all changes to the "agent" edge.
  41917. func (m *WhatsappMutation) ResetAgent() {
  41918. m.agent = nil
  41919. m.clearedagent = false
  41920. }
  41921. // Where appends a list predicates to the WhatsappMutation builder.
  41922. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  41923. m.predicates = append(m.predicates, ps...)
  41924. }
  41925. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  41926. // users can use type-assertion to append predicates that do not depend on any generated package.
  41927. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  41928. p := make([]predicate.Whatsapp, len(ps))
  41929. for i := range ps {
  41930. p[i] = ps[i]
  41931. }
  41932. m.Where(p...)
  41933. }
  41934. // Op returns the operation name.
  41935. func (m *WhatsappMutation) Op() Op {
  41936. return m.op
  41937. }
  41938. // SetOp allows setting the mutation operation.
  41939. func (m *WhatsappMutation) SetOp(op Op) {
  41940. m.op = op
  41941. }
  41942. // Type returns the node type of this mutation (Whatsapp).
  41943. func (m *WhatsappMutation) Type() string {
  41944. return m.typ
  41945. }
  41946. // Fields returns all fields that were changed during this mutation. Note that in
  41947. // order to get all numeric fields that were incremented/decremented, call
  41948. // AddedFields().
  41949. func (m *WhatsappMutation) Fields() []string {
  41950. fields := make([]string, 0, 21)
  41951. if m.created_at != nil {
  41952. fields = append(fields, whatsapp.FieldCreatedAt)
  41953. }
  41954. if m.updated_at != nil {
  41955. fields = append(fields, whatsapp.FieldUpdatedAt)
  41956. }
  41957. if m.status != nil {
  41958. fields = append(fields, whatsapp.FieldStatus)
  41959. }
  41960. if m.deleted_at != nil {
  41961. fields = append(fields, whatsapp.FieldDeletedAt)
  41962. }
  41963. if m.wa_id != nil {
  41964. fields = append(fields, whatsapp.FieldWaID)
  41965. }
  41966. if m.wa_name != nil {
  41967. fields = append(fields, whatsapp.FieldWaName)
  41968. }
  41969. if m.callback != nil {
  41970. fields = append(fields, whatsapp.FieldCallback)
  41971. }
  41972. if m.agent != nil {
  41973. fields = append(fields, whatsapp.FieldAgentID)
  41974. }
  41975. if m.account != nil {
  41976. fields = append(fields, whatsapp.FieldAccount)
  41977. }
  41978. if m.cc != nil {
  41979. fields = append(fields, whatsapp.FieldCc)
  41980. }
  41981. if m.phone != nil {
  41982. fields = append(fields, whatsapp.FieldPhone)
  41983. }
  41984. if m.cc_phone != nil {
  41985. fields = append(fields, whatsapp.FieldCcPhone)
  41986. }
  41987. if m.phone_name != nil {
  41988. fields = append(fields, whatsapp.FieldPhoneName)
  41989. }
  41990. if m.phone_status != nil {
  41991. fields = append(fields, whatsapp.FieldPhoneStatus)
  41992. }
  41993. if m.organization_id != nil {
  41994. fields = append(fields, whatsapp.FieldOrganizationID)
  41995. }
  41996. if m.api_base != nil {
  41997. fields = append(fields, whatsapp.FieldAPIBase)
  41998. }
  41999. if m.api_key != nil {
  42000. fields = append(fields, whatsapp.FieldAPIKey)
  42001. }
  42002. if m.allow_list != nil {
  42003. fields = append(fields, whatsapp.FieldAllowList)
  42004. }
  42005. if m.group_allow_list != nil {
  42006. fields = append(fields, whatsapp.FieldGroupAllowList)
  42007. }
  42008. if m.block_list != nil {
  42009. fields = append(fields, whatsapp.FieldBlockList)
  42010. }
  42011. if m.group_block_list != nil {
  42012. fields = append(fields, whatsapp.FieldGroupBlockList)
  42013. }
  42014. return fields
  42015. }
  42016. // Field returns the value of a field with the given name. The second boolean
  42017. // return value indicates that this field was not set, or was not defined in the
  42018. // schema.
  42019. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  42020. switch name {
  42021. case whatsapp.FieldCreatedAt:
  42022. return m.CreatedAt()
  42023. case whatsapp.FieldUpdatedAt:
  42024. return m.UpdatedAt()
  42025. case whatsapp.FieldStatus:
  42026. return m.Status()
  42027. case whatsapp.FieldDeletedAt:
  42028. return m.DeletedAt()
  42029. case whatsapp.FieldWaID:
  42030. return m.WaID()
  42031. case whatsapp.FieldWaName:
  42032. return m.WaName()
  42033. case whatsapp.FieldCallback:
  42034. return m.Callback()
  42035. case whatsapp.FieldAgentID:
  42036. return m.AgentID()
  42037. case whatsapp.FieldAccount:
  42038. return m.Account()
  42039. case whatsapp.FieldCc:
  42040. return m.Cc()
  42041. case whatsapp.FieldPhone:
  42042. return m.Phone()
  42043. case whatsapp.FieldCcPhone:
  42044. return m.CcPhone()
  42045. case whatsapp.FieldPhoneName:
  42046. return m.PhoneName()
  42047. case whatsapp.FieldPhoneStatus:
  42048. return m.PhoneStatus()
  42049. case whatsapp.FieldOrganizationID:
  42050. return m.OrganizationID()
  42051. case whatsapp.FieldAPIBase:
  42052. return m.APIBase()
  42053. case whatsapp.FieldAPIKey:
  42054. return m.APIKey()
  42055. case whatsapp.FieldAllowList:
  42056. return m.AllowList()
  42057. case whatsapp.FieldGroupAllowList:
  42058. return m.GroupAllowList()
  42059. case whatsapp.FieldBlockList:
  42060. return m.BlockList()
  42061. case whatsapp.FieldGroupBlockList:
  42062. return m.GroupBlockList()
  42063. }
  42064. return nil, false
  42065. }
  42066. // OldField returns the old value of the field from the database. An error is
  42067. // returned if the mutation operation is not UpdateOne, or the query to the
  42068. // database failed.
  42069. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  42070. switch name {
  42071. case whatsapp.FieldCreatedAt:
  42072. return m.OldCreatedAt(ctx)
  42073. case whatsapp.FieldUpdatedAt:
  42074. return m.OldUpdatedAt(ctx)
  42075. case whatsapp.FieldStatus:
  42076. return m.OldStatus(ctx)
  42077. case whatsapp.FieldDeletedAt:
  42078. return m.OldDeletedAt(ctx)
  42079. case whatsapp.FieldWaID:
  42080. return m.OldWaID(ctx)
  42081. case whatsapp.FieldWaName:
  42082. return m.OldWaName(ctx)
  42083. case whatsapp.FieldCallback:
  42084. return m.OldCallback(ctx)
  42085. case whatsapp.FieldAgentID:
  42086. return m.OldAgentID(ctx)
  42087. case whatsapp.FieldAccount:
  42088. return m.OldAccount(ctx)
  42089. case whatsapp.FieldCc:
  42090. return m.OldCc(ctx)
  42091. case whatsapp.FieldPhone:
  42092. return m.OldPhone(ctx)
  42093. case whatsapp.FieldCcPhone:
  42094. return m.OldCcPhone(ctx)
  42095. case whatsapp.FieldPhoneName:
  42096. return m.OldPhoneName(ctx)
  42097. case whatsapp.FieldPhoneStatus:
  42098. return m.OldPhoneStatus(ctx)
  42099. case whatsapp.FieldOrganizationID:
  42100. return m.OldOrganizationID(ctx)
  42101. case whatsapp.FieldAPIBase:
  42102. return m.OldAPIBase(ctx)
  42103. case whatsapp.FieldAPIKey:
  42104. return m.OldAPIKey(ctx)
  42105. case whatsapp.FieldAllowList:
  42106. return m.OldAllowList(ctx)
  42107. case whatsapp.FieldGroupAllowList:
  42108. return m.OldGroupAllowList(ctx)
  42109. case whatsapp.FieldBlockList:
  42110. return m.OldBlockList(ctx)
  42111. case whatsapp.FieldGroupBlockList:
  42112. return m.OldGroupBlockList(ctx)
  42113. }
  42114. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  42115. }
  42116. // SetField sets the value of a field with the given name. It returns an error if
  42117. // the field is not defined in the schema, or if the type mismatched the field
  42118. // type.
  42119. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  42120. switch name {
  42121. case whatsapp.FieldCreatedAt:
  42122. v, ok := value.(time.Time)
  42123. if !ok {
  42124. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42125. }
  42126. m.SetCreatedAt(v)
  42127. return nil
  42128. case whatsapp.FieldUpdatedAt:
  42129. v, ok := value.(time.Time)
  42130. if !ok {
  42131. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42132. }
  42133. m.SetUpdatedAt(v)
  42134. return nil
  42135. case whatsapp.FieldStatus:
  42136. v, ok := value.(uint8)
  42137. if !ok {
  42138. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42139. }
  42140. m.SetStatus(v)
  42141. return nil
  42142. case whatsapp.FieldDeletedAt:
  42143. v, ok := value.(time.Time)
  42144. if !ok {
  42145. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42146. }
  42147. m.SetDeletedAt(v)
  42148. return nil
  42149. case whatsapp.FieldWaID:
  42150. v, ok := value.(string)
  42151. if !ok {
  42152. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42153. }
  42154. m.SetWaID(v)
  42155. return nil
  42156. case whatsapp.FieldWaName:
  42157. v, ok := value.(string)
  42158. if !ok {
  42159. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42160. }
  42161. m.SetWaName(v)
  42162. return nil
  42163. case whatsapp.FieldCallback:
  42164. v, ok := value.(string)
  42165. if !ok {
  42166. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42167. }
  42168. m.SetCallback(v)
  42169. return nil
  42170. case whatsapp.FieldAgentID:
  42171. v, ok := value.(uint64)
  42172. if !ok {
  42173. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42174. }
  42175. m.SetAgentID(v)
  42176. return nil
  42177. case whatsapp.FieldAccount:
  42178. v, ok := value.(string)
  42179. if !ok {
  42180. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42181. }
  42182. m.SetAccount(v)
  42183. return nil
  42184. case whatsapp.FieldCc:
  42185. v, ok := value.(string)
  42186. if !ok {
  42187. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42188. }
  42189. m.SetCc(v)
  42190. return nil
  42191. case whatsapp.FieldPhone:
  42192. v, ok := value.(string)
  42193. if !ok {
  42194. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42195. }
  42196. m.SetPhone(v)
  42197. return nil
  42198. case whatsapp.FieldCcPhone:
  42199. v, ok := value.(string)
  42200. if !ok {
  42201. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42202. }
  42203. m.SetCcPhone(v)
  42204. return nil
  42205. case whatsapp.FieldPhoneName:
  42206. v, ok := value.(string)
  42207. if !ok {
  42208. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42209. }
  42210. m.SetPhoneName(v)
  42211. return nil
  42212. case whatsapp.FieldPhoneStatus:
  42213. v, ok := value.(int8)
  42214. if !ok {
  42215. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42216. }
  42217. m.SetPhoneStatus(v)
  42218. return nil
  42219. case whatsapp.FieldOrganizationID:
  42220. v, ok := value.(uint64)
  42221. if !ok {
  42222. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42223. }
  42224. m.SetOrganizationID(v)
  42225. return nil
  42226. case whatsapp.FieldAPIBase:
  42227. v, ok := value.(string)
  42228. if !ok {
  42229. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42230. }
  42231. m.SetAPIBase(v)
  42232. return nil
  42233. case whatsapp.FieldAPIKey:
  42234. v, ok := value.(string)
  42235. if !ok {
  42236. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42237. }
  42238. m.SetAPIKey(v)
  42239. return nil
  42240. case whatsapp.FieldAllowList:
  42241. v, ok := value.([]string)
  42242. if !ok {
  42243. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42244. }
  42245. m.SetAllowList(v)
  42246. return nil
  42247. case whatsapp.FieldGroupAllowList:
  42248. v, ok := value.([]string)
  42249. if !ok {
  42250. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42251. }
  42252. m.SetGroupAllowList(v)
  42253. return nil
  42254. case whatsapp.FieldBlockList:
  42255. v, ok := value.([]string)
  42256. if !ok {
  42257. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42258. }
  42259. m.SetBlockList(v)
  42260. return nil
  42261. case whatsapp.FieldGroupBlockList:
  42262. v, ok := value.([]string)
  42263. if !ok {
  42264. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42265. }
  42266. m.SetGroupBlockList(v)
  42267. return nil
  42268. }
  42269. return fmt.Errorf("unknown Whatsapp field %s", name)
  42270. }
  42271. // AddedFields returns all numeric fields that were incremented/decremented during
  42272. // this mutation.
  42273. func (m *WhatsappMutation) AddedFields() []string {
  42274. var fields []string
  42275. if m.addstatus != nil {
  42276. fields = append(fields, whatsapp.FieldStatus)
  42277. }
  42278. if m.addphone_status != nil {
  42279. fields = append(fields, whatsapp.FieldPhoneStatus)
  42280. }
  42281. if m.addorganization_id != nil {
  42282. fields = append(fields, whatsapp.FieldOrganizationID)
  42283. }
  42284. return fields
  42285. }
  42286. // AddedField returns the numeric value that was incremented/decremented on a field
  42287. // with the given name. The second boolean return value indicates that this field
  42288. // was not set, or was not defined in the schema.
  42289. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  42290. switch name {
  42291. case whatsapp.FieldStatus:
  42292. return m.AddedStatus()
  42293. case whatsapp.FieldPhoneStatus:
  42294. return m.AddedPhoneStatus()
  42295. case whatsapp.FieldOrganizationID:
  42296. return m.AddedOrganizationID()
  42297. }
  42298. return nil, false
  42299. }
  42300. // AddField adds the value to the field with the given name. It returns an error if
  42301. // the field is not defined in the schema, or if the type mismatched the field
  42302. // type.
  42303. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  42304. switch name {
  42305. case whatsapp.FieldStatus:
  42306. v, ok := value.(int8)
  42307. if !ok {
  42308. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42309. }
  42310. m.AddStatus(v)
  42311. return nil
  42312. case whatsapp.FieldPhoneStatus:
  42313. v, ok := value.(int8)
  42314. if !ok {
  42315. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42316. }
  42317. m.AddPhoneStatus(v)
  42318. return nil
  42319. case whatsapp.FieldOrganizationID:
  42320. v, ok := value.(int64)
  42321. if !ok {
  42322. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42323. }
  42324. m.AddOrganizationID(v)
  42325. return nil
  42326. }
  42327. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  42328. }
  42329. // ClearedFields returns all nullable fields that were cleared during this
  42330. // mutation.
  42331. func (m *WhatsappMutation) ClearedFields() []string {
  42332. var fields []string
  42333. if m.FieldCleared(whatsapp.FieldStatus) {
  42334. fields = append(fields, whatsapp.FieldStatus)
  42335. }
  42336. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  42337. fields = append(fields, whatsapp.FieldDeletedAt)
  42338. }
  42339. if m.FieldCleared(whatsapp.FieldWaID) {
  42340. fields = append(fields, whatsapp.FieldWaID)
  42341. }
  42342. if m.FieldCleared(whatsapp.FieldWaName) {
  42343. fields = append(fields, whatsapp.FieldWaName)
  42344. }
  42345. if m.FieldCleared(whatsapp.FieldCallback) {
  42346. fields = append(fields, whatsapp.FieldCallback)
  42347. }
  42348. if m.FieldCleared(whatsapp.FieldAccount) {
  42349. fields = append(fields, whatsapp.FieldAccount)
  42350. }
  42351. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  42352. fields = append(fields, whatsapp.FieldOrganizationID)
  42353. }
  42354. if m.FieldCleared(whatsapp.FieldAPIBase) {
  42355. fields = append(fields, whatsapp.FieldAPIBase)
  42356. }
  42357. if m.FieldCleared(whatsapp.FieldAPIKey) {
  42358. fields = append(fields, whatsapp.FieldAPIKey)
  42359. }
  42360. if m.FieldCleared(whatsapp.FieldAllowList) {
  42361. fields = append(fields, whatsapp.FieldAllowList)
  42362. }
  42363. if m.FieldCleared(whatsapp.FieldGroupAllowList) {
  42364. fields = append(fields, whatsapp.FieldGroupAllowList)
  42365. }
  42366. if m.FieldCleared(whatsapp.FieldBlockList) {
  42367. fields = append(fields, whatsapp.FieldBlockList)
  42368. }
  42369. if m.FieldCleared(whatsapp.FieldGroupBlockList) {
  42370. fields = append(fields, whatsapp.FieldGroupBlockList)
  42371. }
  42372. return fields
  42373. }
  42374. // FieldCleared returns a boolean indicating if a field with the given name was
  42375. // cleared in this mutation.
  42376. func (m *WhatsappMutation) FieldCleared(name string) bool {
  42377. _, ok := m.clearedFields[name]
  42378. return ok
  42379. }
  42380. // ClearField clears the value of the field with the given name. It returns an
  42381. // error if the field is not defined in the schema.
  42382. func (m *WhatsappMutation) ClearField(name string) error {
  42383. switch name {
  42384. case whatsapp.FieldStatus:
  42385. m.ClearStatus()
  42386. return nil
  42387. case whatsapp.FieldDeletedAt:
  42388. m.ClearDeletedAt()
  42389. return nil
  42390. case whatsapp.FieldWaID:
  42391. m.ClearWaID()
  42392. return nil
  42393. case whatsapp.FieldWaName:
  42394. m.ClearWaName()
  42395. return nil
  42396. case whatsapp.FieldCallback:
  42397. m.ClearCallback()
  42398. return nil
  42399. case whatsapp.FieldAccount:
  42400. m.ClearAccount()
  42401. return nil
  42402. case whatsapp.FieldOrganizationID:
  42403. m.ClearOrganizationID()
  42404. return nil
  42405. case whatsapp.FieldAPIBase:
  42406. m.ClearAPIBase()
  42407. return nil
  42408. case whatsapp.FieldAPIKey:
  42409. m.ClearAPIKey()
  42410. return nil
  42411. case whatsapp.FieldAllowList:
  42412. m.ClearAllowList()
  42413. return nil
  42414. case whatsapp.FieldGroupAllowList:
  42415. m.ClearGroupAllowList()
  42416. return nil
  42417. case whatsapp.FieldBlockList:
  42418. m.ClearBlockList()
  42419. return nil
  42420. case whatsapp.FieldGroupBlockList:
  42421. m.ClearGroupBlockList()
  42422. return nil
  42423. }
  42424. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  42425. }
  42426. // ResetField resets all changes in the mutation for the field with the given name.
  42427. // It returns an error if the field is not defined in the schema.
  42428. func (m *WhatsappMutation) ResetField(name string) error {
  42429. switch name {
  42430. case whatsapp.FieldCreatedAt:
  42431. m.ResetCreatedAt()
  42432. return nil
  42433. case whatsapp.FieldUpdatedAt:
  42434. m.ResetUpdatedAt()
  42435. return nil
  42436. case whatsapp.FieldStatus:
  42437. m.ResetStatus()
  42438. return nil
  42439. case whatsapp.FieldDeletedAt:
  42440. m.ResetDeletedAt()
  42441. return nil
  42442. case whatsapp.FieldWaID:
  42443. m.ResetWaID()
  42444. return nil
  42445. case whatsapp.FieldWaName:
  42446. m.ResetWaName()
  42447. return nil
  42448. case whatsapp.FieldCallback:
  42449. m.ResetCallback()
  42450. return nil
  42451. case whatsapp.FieldAgentID:
  42452. m.ResetAgentID()
  42453. return nil
  42454. case whatsapp.FieldAccount:
  42455. m.ResetAccount()
  42456. return nil
  42457. case whatsapp.FieldCc:
  42458. m.ResetCc()
  42459. return nil
  42460. case whatsapp.FieldPhone:
  42461. m.ResetPhone()
  42462. return nil
  42463. case whatsapp.FieldCcPhone:
  42464. m.ResetCcPhone()
  42465. return nil
  42466. case whatsapp.FieldPhoneName:
  42467. m.ResetPhoneName()
  42468. return nil
  42469. case whatsapp.FieldPhoneStatus:
  42470. m.ResetPhoneStatus()
  42471. return nil
  42472. case whatsapp.FieldOrganizationID:
  42473. m.ResetOrganizationID()
  42474. return nil
  42475. case whatsapp.FieldAPIBase:
  42476. m.ResetAPIBase()
  42477. return nil
  42478. case whatsapp.FieldAPIKey:
  42479. m.ResetAPIKey()
  42480. return nil
  42481. case whatsapp.FieldAllowList:
  42482. m.ResetAllowList()
  42483. return nil
  42484. case whatsapp.FieldGroupAllowList:
  42485. m.ResetGroupAllowList()
  42486. return nil
  42487. case whatsapp.FieldBlockList:
  42488. m.ResetBlockList()
  42489. return nil
  42490. case whatsapp.FieldGroupBlockList:
  42491. m.ResetGroupBlockList()
  42492. return nil
  42493. }
  42494. return fmt.Errorf("unknown Whatsapp field %s", name)
  42495. }
  42496. // AddedEdges returns all edge names that were set/added in this mutation.
  42497. func (m *WhatsappMutation) AddedEdges() []string {
  42498. edges := make([]string, 0, 1)
  42499. if m.agent != nil {
  42500. edges = append(edges, whatsapp.EdgeAgent)
  42501. }
  42502. return edges
  42503. }
  42504. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  42505. // name in this mutation.
  42506. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  42507. switch name {
  42508. case whatsapp.EdgeAgent:
  42509. if id := m.agent; id != nil {
  42510. return []ent.Value{*id}
  42511. }
  42512. }
  42513. return nil
  42514. }
  42515. // RemovedEdges returns all edge names that were removed in this mutation.
  42516. func (m *WhatsappMutation) RemovedEdges() []string {
  42517. edges := make([]string, 0, 1)
  42518. return edges
  42519. }
  42520. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  42521. // the given name in this mutation.
  42522. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  42523. return nil
  42524. }
  42525. // ClearedEdges returns all edge names that were cleared in this mutation.
  42526. func (m *WhatsappMutation) ClearedEdges() []string {
  42527. edges := make([]string, 0, 1)
  42528. if m.clearedagent {
  42529. edges = append(edges, whatsapp.EdgeAgent)
  42530. }
  42531. return edges
  42532. }
  42533. // EdgeCleared returns a boolean which indicates if the edge with the given name
  42534. // was cleared in this mutation.
  42535. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  42536. switch name {
  42537. case whatsapp.EdgeAgent:
  42538. return m.clearedagent
  42539. }
  42540. return false
  42541. }
  42542. // ClearEdge clears the value of the edge with the given name. It returns an error
  42543. // if that edge is not defined in the schema.
  42544. func (m *WhatsappMutation) ClearEdge(name string) error {
  42545. switch name {
  42546. case whatsapp.EdgeAgent:
  42547. m.ClearAgent()
  42548. return nil
  42549. }
  42550. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  42551. }
  42552. // ResetEdge resets all changes to the edge with the given name in this mutation.
  42553. // It returns an error if the edge is not defined in the schema.
  42554. func (m *WhatsappMutation) ResetEdge(name string) error {
  42555. switch name {
  42556. case whatsapp.EdgeAgent:
  42557. m.ResetAgent()
  42558. return nil
  42559. }
  42560. return fmt.Errorf("unknown Whatsapp edge %s", name)
  42561. }
  42562. // WhatsappChannelMutation represents an operation that mutates the WhatsappChannel nodes in the graph.
  42563. type WhatsappChannelMutation struct {
  42564. config
  42565. op Op
  42566. typ string
  42567. id *uint64
  42568. created_at *time.Time
  42569. updated_at *time.Time
  42570. status *uint8
  42571. addstatus *int8
  42572. deleted_at *time.Time
  42573. ak *string
  42574. sk *string
  42575. wa_id *string
  42576. wa_name *string
  42577. waba_id *uint64
  42578. addwaba_id *int64
  42579. business_id *uint64
  42580. addbusiness_id *int64
  42581. organization_id *uint64
  42582. addorganization_id *int64
  42583. verify_account *string
  42584. clearedFields map[string]struct{}
  42585. done bool
  42586. oldValue func(context.Context) (*WhatsappChannel, error)
  42587. predicates []predicate.WhatsappChannel
  42588. }
  42589. var _ ent.Mutation = (*WhatsappChannelMutation)(nil)
  42590. // whatsappchannelOption allows management of the mutation configuration using functional options.
  42591. type whatsappchannelOption func(*WhatsappChannelMutation)
  42592. // newWhatsappChannelMutation creates new mutation for the WhatsappChannel entity.
  42593. func newWhatsappChannelMutation(c config, op Op, opts ...whatsappchannelOption) *WhatsappChannelMutation {
  42594. m := &WhatsappChannelMutation{
  42595. config: c,
  42596. op: op,
  42597. typ: TypeWhatsappChannel,
  42598. clearedFields: make(map[string]struct{}),
  42599. }
  42600. for _, opt := range opts {
  42601. opt(m)
  42602. }
  42603. return m
  42604. }
  42605. // withWhatsappChannelID sets the ID field of the mutation.
  42606. func withWhatsappChannelID(id uint64) whatsappchannelOption {
  42607. return func(m *WhatsappChannelMutation) {
  42608. var (
  42609. err error
  42610. once sync.Once
  42611. value *WhatsappChannel
  42612. )
  42613. m.oldValue = func(ctx context.Context) (*WhatsappChannel, error) {
  42614. once.Do(func() {
  42615. if m.done {
  42616. err = errors.New("querying old values post mutation is not allowed")
  42617. } else {
  42618. value, err = m.Client().WhatsappChannel.Get(ctx, id)
  42619. }
  42620. })
  42621. return value, err
  42622. }
  42623. m.id = &id
  42624. }
  42625. }
  42626. // withWhatsappChannel sets the old WhatsappChannel of the mutation.
  42627. func withWhatsappChannel(node *WhatsappChannel) whatsappchannelOption {
  42628. return func(m *WhatsappChannelMutation) {
  42629. m.oldValue = func(context.Context) (*WhatsappChannel, error) {
  42630. return node, nil
  42631. }
  42632. m.id = &node.ID
  42633. }
  42634. }
  42635. // Client returns a new `ent.Client` from the mutation. If the mutation was
  42636. // executed in a transaction (ent.Tx), a transactional client is returned.
  42637. func (m WhatsappChannelMutation) Client() *Client {
  42638. client := &Client{config: m.config}
  42639. client.init()
  42640. return client
  42641. }
  42642. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  42643. // it returns an error otherwise.
  42644. func (m WhatsappChannelMutation) Tx() (*Tx, error) {
  42645. if _, ok := m.driver.(*txDriver); !ok {
  42646. return nil, errors.New("ent: mutation is not running in a transaction")
  42647. }
  42648. tx := &Tx{config: m.config}
  42649. tx.init()
  42650. return tx, nil
  42651. }
  42652. // SetID sets the value of the id field. Note that this
  42653. // operation is only accepted on creation of WhatsappChannel entities.
  42654. func (m *WhatsappChannelMutation) SetID(id uint64) {
  42655. m.id = &id
  42656. }
  42657. // ID returns the ID value in the mutation. Note that the ID is only available
  42658. // if it was provided to the builder or after it was returned from the database.
  42659. func (m *WhatsappChannelMutation) ID() (id uint64, exists bool) {
  42660. if m.id == nil {
  42661. return
  42662. }
  42663. return *m.id, true
  42664. }
  42665. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  42666. // That means, if the mutation is applied within a transaction with an isolation level such
  42667. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  42668. // or updated by the mutation.
  42669. func (m *WhatsappChannelMutation) IDs(ctx context.Context) ([]uint64, error) {
  42670. switch {
  42671. case m.op.Is(OpUpdateOne | OpDeleteOne):
  42672. id, exists := m.ID()
  42673. if exists {
  42674. return []uint64{id}, nil
  42675. }
  42676. fallthrough
  42677. case m.op.Is(OpUpdate | OpDelete):
  42678. return m.Client().WhatsappChannel.Query().Where(m.predicates...).IDs(ctx)
  42679. default:
  42680. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  42681. }
  42682. }
  42683. // SetCreatedAt sets the "created_at" field.
  42684. func (m *WhatsappChannelMutation) SetCreatedAt(t time.Time) {
  42685. m.created_at = &t
  42686. }
  42687. // CreatedAt returns the value of the "created_at" field in the mutation.
  42688. func (m *WhatsappChannelMutation) CreatedAt() (r time.Time, exists bool) {
  42689. v := m.created_at
  42690. if v == nil {
  42691. return
  42692. }
  42693. return *v, true
  42694. }
  42695. // OldCreatedAt returns the old "created_at" field's value of the WhatsappChannel entity.
  42696. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  42697. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42698. func (m *WhatsappChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  42699. if !m.op.Is(OpUpdateOne) {
  42700. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  42701. }
  42702. if m.id == nil || m.oldValue == nil {
  42703. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  42704. }
  42705. oldValue, err := m.oldValue(ctx)
  42706. if err != nil {
  42707. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  42708. }
  42709. return oldValue.CreatedAt, nil
  42710. }
  42711. // ResetCreatedAt resets all changes to the "created_at" field.
  42712. func (m *WhatsappChannelMutation) ResetCreatedAt() {
  42713. m.created_at = nil
  42714. }
  42715. // SetUpdatedAt sets the "updated_at" field.
  42716. func (m *WhatsappChannelMutation) SetUpdatedAt(t time.Time) {
  42717. m.updated_at = &t
  42718. }
  42719. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  42720. func (m *WhatsappChannelMutation) UpdatedAt() (r time.Time, exists bool) {
  42721. v := m.updated_at
  42722. if v == nil {
  42723. return
  42724. }
  42725. return *v, true
  42726. }
  42727. // OldUpdatedAt returns the old "updated_at" field's value of the WhatsappChannel entity.
  42728. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  42729. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42730. func (m *WhatsappChannelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  42731. if !m.op.Is(OpUpdateOne) {
  42732. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  42733. }
  42734. if m.id == nil || m.oldValue == nil {
  42735. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  42736. }
  42737. oldValue, err := m.oldValue(ctx)
  42738. if err != nil {
  42739. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  42740. }
  42741. return oldValue.UpdatedAt, nil
  42742. }
  42743. // ResetUpdatedAt resets all changes to the "updated_at" field.
  42744. func (m *WhatsappChannelMutation) ResetUpdatedAt() {
  42745. m.updated_at = nil
  42746. }
  42747. // SetStatus sets the "status" field.
  42748. func (m *WhatsappChannelMutation) SetStatus(u uint8) {
  42749. m.status = &u
  42750. m.addstatus = nil
  42751. }
  42752. // Status returns the value of the "status" field in the mutation.
  42753. func (m *WhatsappChannelMutation) Status() (r uint8, exists bool) {
  42754. v := m.status
  42755. if v == nil {
  42756. return
  42757. }
  42758. return *v, true
  42759. }
  42760. // OldStatus returns the old "status" field's value of the WhatsappChannel entity.
  42761. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  42762. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42763. func (m *WhatsappChannelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  42764. if !m.op.Is(OpUpdateOne) {
  42765. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  42766. }
  42767. if m.id == nil || m.oldValue == nil {
  42768. return v, errors.New("OldStatus requires an ID field in the mutation")
  42769. }
  42770. oldValue, err := m.oldValue(ctx)
  42771. if err != nil {
  42772. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  42773. }
  42774. return oldValue.Status, nil
  42775. }
  42776. // AddStatus adds u to the "status" field.
  42777. func (m *WhatsappChannelMutation) AddStatus(u int8) {
  42778. if m.addstatus != nil {
  42779. *m.addstatus += u
  42780. } else {
  42781. m.addstatus = &u
  42782. }
  42783. }
  42784. // AddedStatus returns the value that was added to the "status" field in this mutation.
  42785. func (m *WhatsappChannelMutation) AddedStatus() (r int8, exists bool) {
  42786. v := m.addstatus
  42787. if v == nil {
  42788. return
  42789. }
  42790. return *v, true
  42791. }
  42792. // ClearStatus clears the value of the "status" field.
  42793. func (m *WhatsappChannelMutation) ClearStatus() {
  42794. m.status = nil
  42795. m.addstatus = nil
  42796. m.clearedFields[whatsappchannel.FieldStatus] = struct{}{}
  42797. }
  42798. // StatusCleared returns if the "status" field was cleared in this mutation.
  42799. func (m *WhatsappChannelMutation) StatusCleared() bool {
  42800. _, ok := m.clearedFields[whatsappchannel.FieldStatus]
  42801. return ok
  42802. }
  42803. // ResetStatus resets all changes to the "status" field.
  42804. func (m *WhatsappChannelMutation) ResetStatus() {
  42805. m.status = nil
  42806. m.addstatus = nil
  42807. delete(m.clearedFields, whatsappchannel.FieldStatus)
  42808. }
  42809. // SetDeletedAt sets the "deleted_at" field.
  42810. func (m *WhatsappChannelMutation) SetDeletedAt(t time.Time) {
  42811. m.deleted_at = &t
  42812. }
  42813. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  42814. func (m *WhatsappChannelMutation) DeletedAt() (r time.Time, exists bool) {
  42815. v := m.deleted_at
  42816. if v == nil {
  42817. return
  42818. }
  42819. return *v, true
  42820. }
  42821. // OldDeletedAt returns the old "deleted_at" field's value of the WhatsappChannel entity.
  42822. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  42823. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42824. func (m *WhatsappChannelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  42825. if !m.op.Is(OpUpdateOne) {
  42826. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  42827. }
  42828. if m.id == nil || m.oldValue == nil {
  42829. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  42830. }
  42831. oldValue, err := m.oldValue(ctx)
  42832. if err != nil {
  42833. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  42834. }
  42835. return oldValue.DeletedAt, nil
  42836. }
  42837. // ClearDeletedAt clears the value of the "deleted_at" field.
  42838. func (m *WhatsappChannelMutation) ClearDeletedAt() {
  42839. m.deleted_at = nil
  42840. m.clearedFields[whatsappchannel.FieldDeletedAt] = struct{}{}
  42841. }
  42842. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  42843. func (m *WhatsappChannelMutation) DeletedAtCleared() bool {
  42844. _, ok := m.clearedFields[whatsappchannel.FieldDeletedAt]
  42845. return ok
  42846. }
  42847. // ResetDeletedAt resets all changes to the "deleted_at" field.
  42848. func (m *WhatsappChannelMutation) ResetDeletedAt() {
  42849. m.deleted_at = nil
  42850. delete(m.clearedFields, whatsappchannel.FieldDeletedAt)
  42851. }
  42852. // SetAk sets the "ak" field.
  42853. func (m *WhatsappChannelMutation) SetAk(s string) {
  42854. m.ak = &s
  42855. }
  42856. // Ak returns the value of the "ak" field in the mutation.
  42857. func (m *WhatsappChannelMutation) Ak() (r string, exists bool) {
  42858. v := m.ak
  42859. if v == nil {
  42860. return
  42861. }
  42862. return *v, true
  42863. }
  42864. // OldAk returns the old "ak" field's value of the WhatsappChannel entity.
  42865. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  42866. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42867. func (m *WhatsappChannelMutation) OldAk(ctx context.Context) (v string, err error) {
  42868. if !m.op.Is(OpUpdateOne) {
  42869. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  42870. }
  42871. if m.id == nil || m.oldValue == nil {
  42872. return v, errors.New("OldAk requires an ID field in the mutation")
  42873. }
  42874. oldValue, err := m.oldValue(ctx)
  42875. if err != nil {
  42876. return v, fmt.Errorf("querying old value for OldAk: %w", err)
  42877. }
  42878. return oldValue.Ak, nil
  42879. }
  42880. // ClearAk clears the value of the "ak" field.
  42881. func (m *WhatsappChannelMutation) ClearAk() {
  42882. m.ak = nil
  42883. m.clearedFields[whatsappchannel.FieldAk] = struct{}{}
  42884. }
  42885. // AkCleared returns if the "ak" field was cleared in this mutation.
  42886. func (m *WhatsappChannelMutation) AkCleared() bool {
  42887. _, ok := m.clearedFields[whatsappchannel.FieldAk]
  42888. return ok
  42889. }
  42890. // ResetAk resets all changes to the "ak" field.
  42891. func (m *WhatsappChannelMutation) ResetAk() {
  42892. m.ak = nil
  42893. delete(m.clearedFields, whatsappchannel.FieldAk)
  42894. }
  42895. // SetSk sets the "sk" field.
  42896. func (m *WhatsappChannelMutation) SetSk(s string) {
  42897. m.sk = &s
  42898. }
  42899. // Sk returns the value of the "sk" field in the mutation.
  42900. func (m *WhatsappChannelMutation) Sk() (r string, exists bool) {
  42901. v := m.sk
  42902. if v == nil {
  42903. return
  42904. }
  42905. return *v, true
  42906. }
  42907. // OldSk returns the old "sk" field's value of the WhatsappChannel entity.
  42908. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  42909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42910. func (m *WhatsappChannelMutation) OldSk(ctx context.Context) (v string, err error) {
  42911. if !m.op.Is(OpUpdateOne) {
  42912. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  42913. }
  42914. if m.id == nil || m.oldValue == nil {
  42915. return v, errors.New("OldSk requires an ID field in the mutation")
  42916. }
  42917. oldValue, err := m.oldValue(ctx)
  42918. if err != nil {
  42919. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  42920. }
  42921. return oldValue.Sk, nil
  42922. }
  42923. // ResetSk resets all changes to the "sk" field.
  42924. func (m *WhatsappChannelMutation) ResetSk() {
  42925. m.sk = nil
  42926. }
  42927. // SetWaID sets the "wa_id" field.
  42928. func (m *WhatsappChannelMutation) SetWaID(s string) {
  42929. m.wa_id = &s
  42930. }
  42931. // WaID returns the value of the "wa_id" field in the mutation.
  42932. func (m *WhatsappChannelMutation) WaID() (r string, exists bool) {
  42933. v := m.wa_id
  42934. if v == nil {
  42935. return
  42936. }
  42937. return *v, true
  42938. }
  42939. // OldWaID returns the old "wa_id" field's value of the WhatsappChannel entity.
  42940. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  42941. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42942. func (m *WhatsappChannelMutation) OldWaID(ctx context.Context) (v string, err error) {
  42943. if !m.op.Is(OpUpdateOne) {
  42944. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  42945. }
  42946. if m.id == nil || m.oldValue == nil {
  42947. return v, errors.New("OldWaID requires an ID field in the mutation")
  42948. }
  42949. oldValue, err := m.oldValue(ctx)
  42950. if err != nil {
  42951. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  42952. }
  42953. return oldValue.WaID, nil
  42954. }
  42955. // ClearWaID clears the value of the "wa_id" field.
  42956. func (m *WhatsappChannelMutation) ClearWaID() {
  42957. m.wa_id = nil
  42958. m.clearedFields[whatsappchannel.FieldWaID] = struct{}{}
  42959. }
  42960. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  42961. func (m *WhatsappChannelMutation) WaIDCleared() bool {
  42962. _, ok := m.clearedFields[whatsappchannel.FieldWaID]
  42963. return ok
  42964. }
  42965. // ResetWaID resets all changes to the "wa_id" field.
  42966. func (m *WhatsappChannelMutation) ResetWaID() {
  42967. m.wa_id = nil
  42968. delete(m.clearedFields, whatsappchannel.FieldWaID)
  42969. }
  42970. // SetWaName sets the "wa_name" field.
  42971. func (m *WhatsappChannelMutation) SetWaName(s string) {
  42972. m.wa_name = &s
  42973. }
  42974. // WaName returns the value of the "wa_name" field in the mutation.
  42975. func (m *WhatsappChannelMutation) WaName() (r string, exists bool) {
  42976. v := m.wa_name
  42977. if v == nil {
  42978. return
  42979. }
  42980. return *v, true
  42981. }
  42982. // OldWaName returns the old "wa_name" field's value of the WhatsappChannel entity.
  42983. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  42984. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42985. func (m *WhatsappChannelMutation) OldWaName(ctx context.Context) (v string, err error) {
  42986. if !m.op.Is(OpUpdateOne) {
  42987. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  42988. }
  42989. if m.id == nil || m.oldValue == nil {
  42990. return v, errors.New("OldWaName requires an ID field in the mutation")
  42991. }
  42992. oldValue, err := m.oldValue(ctx)
  42993. if err != nil {
  42994. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  42995. }
  42996. return oldValue.WaName, nil
  42997. }
  42998. // ClearWaName clears the value of the "wa_name" field.
  42999. func (m *WhatsappChannelMutation) ClearWaName() {
  43000. m.wa_name = nil
  43001. m.clearedFields[whatsappchannel.FieldWaName] = struct{}{}
  43002. }
  43003. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  43004. func (m *WhatsappChannelMutation) WaNameCleared() bool {
  43005. _, ok := m.clearedFields[whatsappchannel.FieldWaName]
  43006. return ok
  43007. }
  43008. // ResetWaName resets all changes to the "wa_name" field.
  43009. func (m *WhatsappChannelMutation) ResetWaName() {
  43010. m.wa_name = nil
  43011. delete(m.clearedFields, whatsappchannel.FieldWaName)
  43012. }
  43013. // SetWabaID sets the "waba_id" field.
  43014. func (m *WhatsappChannelMutation) SetWabaID(u uint64) {
  43015. m.waba_id = &u
  43016. m.addwaba_id = nil
  43017. }
  43018. // WabaID returns the value of the "waba_id" field in the mutation.
  43019. func (m *WhatsappChannelMutation) WabaID() (r uint64, exists bool) {
  43020. v := m.waba_id
  43021. if v == nil {
  43022. return
  43023. }
  43024. return *v, true
  43025. }
  43026. // OldWabaID returns the old "waba_id" field's value of the WhatsappChannel entity.
  43027. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43028. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43029. func (m *WhatsappChannelMutation) OldWabaID(ctx context.Context) (v uint64, err error) {
  43030. if !m.op.Is(OpUpdateOne) {
  43031. return v, errors.New("OldWabaID is only allowed on UpdateOne operations")
  43032. }
  43033. if m.id == nil || m.oldValue == nil {
  43034. return v, errors.New("OldWabaID requires an ID field in the mutation")
  43035. }
  43036. oldValue, err := m.oldValue(ctx)
  43037. if err != nil {
  43038. return v, fmt.Errorf("querying old value for OldWabaID: %w", err)
  43039. }
  43040. return oldValue.WabaID, nil
  43041. }
  43042. // AddWabaID adds u to the "waba_id" field.
  43043. func (m *WhatsappChannelMutation) AddWabaID(u int64) {
  43044. if m.addwaba_id != nil {
  43045. *m.addwaba_id += u
  43046. } else {
  43047. m.addwaba_id = &u
  43048. }
  43049. }
  43050. // AddedWabaID returns the value that was added to the "waba_id" field in this mutation.
  43051. func (m *WhatsappChannelMutation) AddedWabaID() (r int64, exists bool) {
  43052. v := m.addwaba_id
  43053. if v == nil {
  43054. return
  43055. }
  43056. return *v, true
  43057. }
  43058. // ResetWabaID resets all changes to the "waba_id" field.
  43059. func (m *WhatsappChannelMutation) ResetWabaID() {
  43060. m.waba_id = nil
  43061. m.addwaba_id = nil
  43062. }
  43063. // SetBusinessID sets the "business_id" field.
  43064. func (m *WhatsappChannelMutation) SetBusinessID(u uint64) {
  43065. m.business_id = &u
  43066. m.addbusiness_id = nil
  43067. }
  43068. // BusinessID returns the value of the "business_id" field in the mutation.
  43069. func (m *WhatsappChannelMutation) BusinessID() (r uint64, exists bool) {
  43070. v := m.business_id
  43071. if v == nil {
  43072. return
  43073. }
  43074. return *v, true
  43075. }
  43076. // OldBusinessID returns the old "business_id" field's value of the WhatsappChannel entity.
  43077. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43078. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43079. func (m *WhatsappChannelMutation) OldBusinessID(ctx context.Context) (v uint64, err error) {
  43080. if !m.op.Is(OpUpdateOne) {
  43081. return v, errors.New("OldBusinessID is only allowed on UpdateOne operations")
  43082. }
  43083. if m.id == nil || m.oldValue == nil {
  43084. return v, errors.New("OldBusinessID requires an ID field in the mutation")
  43085. }
  43086. oldValue, err := m.oldValue(ctx)
  43087. if err != nil {
  43088. return v, fmt.Errorf("querying old value for OldBusinessID: %w", err)
  43089. }
  43090. return oldValue.BusinessID, nil
  43091. }
  43092. // AddBusinessID adds u to the "business_id" field.
  43093. func (m *WhatsappChannelMutation) AddBusinessID(u int64) {
  43094. if m.addbusiness_id != nil {
  43095. *m.addbusiness_id += u
  43096. } else {
  43097. m.addbusiness_id = &u
  43098. }
  43099. }
  43100. // AddedBusinessID returns the value that was added to the "business_id" field in this mutation.
  43101. func (m *WhatsappChannelMutation) AddedBusinessID() (r int64, exists bool) {
  43102. v := m.addbusiness_id
  43103. if v == nil {
  43104. return
  43105. }
  43106. return *v, true
  43107. }
  43108. // ResetBusinessID resets all changes to the "business_id" field.
  43109. func (m *WhatsappChannelMutation) ResetBusinessID() {
  43110. m.business_id = nil
  43111. m.addbusiness_id = nil
  43112. }
  43113. // SetOrganizationID sets the "organization_id" field.
  43114. func (m *WhatsappChannelMutation) SetOrganizationID(u uint64) {
  43115. m.organization_id = &u
  43116. m.addorganization_id = nil
  43117. }
  43118. // OrganizationID returns the value of the "organization_id" field in the mutation.
  43119. func (m *WhatsappChannelMutation) OrganizationID() (r uint64, exists bool) {
  43120. v := m.organization_id
  43121. if v == nil {
  43122. return
  43123. }
  43124. return *v, true
  43125. }
  43126. // OldOrganizationID returns the old "organization_id" field's value of the WhatsappChannel entity.
  43127. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43128. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43129. func (m *WhatsappChannelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  43130. if !m.op.Is(OpUpdateOne) {
  43131. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  43132. }
  43133. if m.id == nil || m.oldValue == nil {
  43134. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  43135. }
  43136. oldValue, err := m.oldValue(ctx)
  43137. if err != nil {
  43138. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  43139. }
  43140. return oldValue.OrganizationID, nil
  43141. }
  43142. // AddOrganizationID adds u to the "organization_id" field.
  43143. func (m *WhatsappChannelMutation) AddOrganizationID(u int64) {
  43144. if m.addorganization_id != nil {
  43145. *m.addorganization_id += u
  43146. } else {
  43147. m.addorganization_id = &u
  43148. }
  43149. }
  43150. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  43151. func (m *WhatsappChannelMutation) AddedOrganizationID() (r int64, exists bool) {
  43152. v := m.addorganization_id
  43153. if v == nil {
  43154. return
  43155. }
  43156. return *v, true
  43157. }
  43158. // ClearOrganizationID clears the value of the "organization_id" field.
  43159. func (m *WhatsappChannelMutation) ClearOrganizationID() {
  43160. m.organization_id = nil
  43161. m.addorganization_id = nil
  43162. m.clearedFields[whatsappchannel.FieldOrganizationID] = struct{}{}
  43163. }
  43164. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  43165. func (m *WhatsappChannelMutation) OrganizationIDCleared() bool {
  43166. _, ok := m.clearedFields[whatsappchannel.FieldOrganizationID]
  43167. return ok
  43168. }
  43169. // ResetOrganizationID resets all changes to the "organization_id" field.
  43170. func (m *WhatsappChannelMutation) ResetOrganizationID() {
  43171. m.organization_id = nil
  43172. m.addorganization_id = nil
  43173. delete(m.clearedFields, whatsappchannel.FieldOrganizationID)
  43174. }
  43175. // SetVerifyAccount sets the "verify_account" field.
  43176. func (m *WhatsappChannelMutation) SetVerifyAccount(s string) {
  43177. m.verify_account = &s
  43178. }
  43179. // VerifyAccount returns the value of the "verify_account" field in the mutation.
  43180. func (m *WhatsappChannelMutation) VerifyAccount() (r string, exists bool) {
  43181. v := m.verify_account
  43182. if v == nil {
  43183. return
  43184. }
  43185. return *v, true
  43186. }
  43187. // OldVerifyAccount returns the old "verify_account" field's value of the WhatsappChannel entity.
  43188. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43189. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43190. func (m *WhatsappChannelMutation) OldVerifyAccount(ctx context.Context) (v string, err error) {
  43191. if !m.op.Is(OpUpdateOne) {
  43192. return v, errors.New("OldVerifyAccount is only allowed on UpdateOne operations")
  43193. }
  43194. if m.id == nil || m.oldValue == nil {
  43195. return v, errors.New("OldVerifyAccount requires an ID field in the mutation")
  43196. }
  43197. oldValue, err := m.oldValue(ctx)
  43198. if err != nil {
  43199. return v, fmt.Errorf("querying old value for OldVerifyAccount: %w", err)
  43200. }
  43201. return oldValue.VerifyAccount, nil
  43202. }
  43203. // ResetVerifyAccount resets all changes to the "verify_account" field.
  43204. func (m *WhatsappChannelMutation) ResetVerifyAccount() {
  43205. m.verify_account = nil
  43206. }
  43207. // Where appends a list predicates to the WhatsappChannelMutation builder.
  43208. func (m *WhatsappChannelMutation) Where(ps ...predicate.WhatsappChannel) {
  43209. m.predicates = append(m.predicates, ps...)
  43210. }
  43211. // WhereP appends storage-level predicates to the WhatsappChannelMutation builder. Using this method,
  43212. // users can use type-assertion to append predicates that do not depend on any generated package.
  43213. func (m *WhatsappChannelMutation) WhereP(ps ...func(*sql.Selector)) {
  43214. p := make([]predicate.WhatsappChannel, len(ps))
  43215. for i := range ps {
  43216. p[i] = ps[i]
  43217. }
  43218. m.Where(p...)
  43219. }
  43220. // Op returns the operation name.
  43221. func (m *WhatsappChannelMutation) Op() Op {
  43222. return m.op
  43223. }
  43224. // SetOp allows setting the mutation operation.
  43225. func (m *WhatsappChannelMutation) SetOp(op Op) {
  43226. m.op = op
  43227. }
  43228. // Type returns the node type of this mutation (WhatsappChannel).
  43229. func (m *WhatsappChannelMutation) Type() string {
  43230. return m.typ
  43231. }
  43232. // Fields returns all fields that were changed during this mutation. Note that in
  43233. // order to get all numeric fields that were incremented/decremented, call
  43234. // AddedFields().
  43235. func (m *WhatsappChannelMutation) Fields() []string {
  43236. fields := make([]string, 0, 12)
  43237. if m.created_at != nil {
  43238. fields = append(fields, whatsappchannel.FieldCreatedAt)
  43239. }
  43240. if m.updated_at != nil {
  43241. fields = append(fields, whatsappchannel.FieldUpdatedAt)
  43242. }
  43243. if m.status != nil {
  43244. fields = append(fields, whatsappchannel.FieldStatus)
  43245. }
  43246. if m.deleted_at != nil {
  43247. fields = append(fields, whatsappchannel.FieldDeletedAt)
  43248. }
  43249. if m.ak != nil {
  43250. fields = append(fields, whatsappchannel.FieldAk)
  43251. }
  43252. if m.sk != nil {
  43253. fields = append(fields, whatsappchannel.FieldSk)
  43254. }
  43255. if m.wa_id != nil {
  43256. fields = append(fields, whatsappchannel.FieldWaID)
  43257. }
  43258. if m.wa_name != nil {
  43259. fields = append(fields, whatsappchannel.FieldWaName)
  43260. }
  43261. if m.waba_id != nil {
  43262. fields = append(fields, whatsappchannel.FieldWabaID)
  43263. }
  43264. if m.business_id != nil {
  43265. fields = append(fields, whatsappchannel.FieldBusinessID)
  43266. }
  43267. if m.organization_id != nil {
  43268. fields = append(fields, whatsappchannel.FieldOrganizationID)
  43269. }
  43270. if m.verify_account != nil {
  43271. fields = append(fields, whatsappchannel.FieldVerifyAccount)
  43272. }
  43273. return fields
  43274. }
  43275. // Field returns the value of a field with the given name. The second boolean
  43276. // return value indicates that this field was not set, or was not defined in the
  43277. // schema.
  43278. func (m *WhatsappChannelMutation) Field(name string) (ent.Value, bool) {
  43279. switch name {
  43280. case whatsappchannel.FieldCreatedAt:
  43281. return m.CreatedAt()
  43282. case whatsappchannel.FieldUpdatedAt:
  43283. return m.UpdatedAt()
  43284. case whatsappchannel.FieldStatus:
  43285. return m.Status()
  43286. case whatsappchannel.FieldDeletedAt:
  43287. return m.DeletedAt()
  43288. case whatsappchannel.FieldAk:
  43289. return m.Ak()
  43290. case whatsappchannel.FieldSk:
  43291. return m.Sk()
  43292. case whatsappchannel.FieldWaID:
  43293. return m.WaID()
  43294. case whatsappchannel.FieldWaName:
  43295. return m.WaName()
  43296. case whatsappchannel.FieldWabaID:
  43297. return m.WabaID()
  43298. case whatsappchannel.FieldBusinessID:
  43299. return m.BusinessID()
  43300. case whatsappchannel.FieldOrganizationID:
  43301. return m.OrganizationID()
  43302. case whatsappchannel.FieldVerifyAccount:
  43303. return m.VerifyAccount()
  43304. }
  43305. return nil, false
  43306. }
  43307. // OldField returns the old value of the field from the database. An error is
  43308. // returned if the mutation operation is not UpdateOne, or the query to the
  43309. // database failed.
  43310. func (m *WhatsappChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  43311. switch name {
  43312. case whatsappchannel.FieldCreatedAt:
  43313. return m.OldCreatedAt(ctx)
  43314. case whatsappchannel.FieldUpdatedAt:
  43315. return m.OldUpdatedAt(ctx)
  43316. case whatsappchannel.FieldStatus:
  43317. return m.OldStatus(ctx)
  43318. case whatsappchannel.FieldDeletedAt:
  43319. return m.OldDeletedAt(ctx)
  43320. case whatsappchannel.FieldAk:
  43321. return m.OldAk(ctx)
  43322. case whatsappchannel.FieldSk:
  43323. return m.OldSk(ctx)
  43324. case whatsappchannel.FieldWaID:
  43325. return m.OldWaID(ctx)
  43326. case whatsappchannel.FieldWaName:
  43327. return m.OldWaName(ctx)
  43328. case whatsappchannel.FieldWabaID:
  43329. return m.OldWabaID(ctx)
  43330. case whatsappchannel.FieldBusinessID:
  43331. return m.OldBusinessID(ctx)
  43332. case whatsappchannel.FieldOrganizationID:
  43333. return m.OldOrganizationID(ctx)
  43334. case whatsappchannel.FieldVerifyAccount:
  43335. return m.OldVerifyAccount(ctx)
  43336. }
  43337. return nil, fmt.Errorf("unknown WhatsappChannel field %s", name)
  43338. }
  43339. // SetField sets the value of a field with the given name. It returns an error if
  43340. // the field is not defined in the schema, or if the type mismatched the field
  43341. // type.
  43342. func (m *WhatsappChannelMutation) SetField(name string, value ent.Value) error {
  43343. switch name {
  43344. case whatsappchannel.FieldCreatedAt:
  43345. v, ok := value.(time.Time)
  43346. if !ok {
  43347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43348. }
  43349. m.SetCreatedAt(v)
  43350. return nil
  43351. case whatsappchannel.FieldUpdatedAt:
  43352. v, ok := value.(time.Time)
  43353. if !ok {
  43354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43355. }
  43356. m.SetUpdatedAt(v)
  43357. return nil
  43358. case whatsappchannel.FieldStatus:
  43359. v, ok := value.(uint8)
  43360. if !ok {
  43361. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43362. }
  43363. m.SetStatus(v)
  43364. return nil
  43365. case whatsappchannel.FieldDeletedAt:
  43366. v, ok := value.(time.Time)
  43367. if !ok {
  43368. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43369. }
  43370. m.SetDeletedAt(v)
  43371. return nil
  43372. case whatsappchannel.FieldAk:
  43373. v, ok := value.(string)
  43374. if !ok {
  43375. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43376. }
  43377. m.SetAk(v)
  43378. return nil
  43379. case whatsappchannel.FieldSk:
  43380. v, ok := value.(string)
  43381. if !ok {
  43382. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43383. }
  43384. m.SetSk(v)
  43385. return nil
  43386. case whatsappchannel.FieldWaID:
  43387. v, ok := value.(string)
  43388. if !ok {
  43389. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43390. }
  43391. m.SetWaID(v)
  43392. return nil
  43393. case whatsappchannel.FieldWaName:
  43394. v, ok := value.(string)
  43395. if !ok {
  43396. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43397. }
  43398. m.SetWaName(v)
  43399. return nil
  43400. case whatsappchannel.FieldWabaID:
  43401. v, ok := value.(uint64)
  43402. if !ok {
  43403. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43404. }
  43405. m.SetWabaID(v)
  43406. return nil
  43407. case whatsappchannel.FieldBusinessID:
  43408. v, ok := value.(uint64)
  43409. if !ok {
  43410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43411. }
  43412. m.SetBusinessID(v)
  43413. return nil
  43414. case whatsappchannel.FieldOrganizationID:
  43415. v, ok := value.(uint64)
  43416. if !ok {
  43417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43418. }
  43419. m.SetOrganizationID(v)
  43420. return nil
  43421. case whatsappchannel.FieldVerifyAccount:
  43422. v, ok := value.(string)
  43423. if !ok {
  43424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43425. }
  43426. m.SetVerifyAccount(v)
  43427. return nil
  43428. }
  43429. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  43430. }
  43431. // AddedFields returns all numeric fields that were incremented/decremented during
  43432. // this mutation.
  43433. func (m *WhatsappChannelMutation) AddedFields() []string {
  43434. var fields []string
  43435. if m.addstatus != nil {
  43436. fields = append(fields, whatsappchannel.FieldStatus)
  43437. }
  43438. if m.addwaba_id != nil {
  43439. fields = append(fields, whatsappchannel.FieldWabaID)
  43440. }
  43441. if m.addbusiness_id != nil {
  43442. fields = append(fields, whatsappchannel.FieldBusinessID)
  43443. }
  43444. if m.addorganization_id != nil {
  43445. fields = append(fields, whatsappchannel.FieldOrganizationID)
  43446. }
  43447. return fields
  43448. }
  43449. // AddedField returns the numeric value that was incremented/decremented on a field
  43450. // with the given name. The second boolean return value indicates that this field
  43451. // was not set, or was not defined in the schema.
  43452. func (m *WhatsappChannelMutation) AddedField(name string) (ent.Value, bool) {
  43453. switch name {
  43454. case whatsappchannel.FieldStatus:
  43455. return m.AddedStatus()
  43456. case whatsappchannel.FieldWabaID:
  43457. return m.AddedWabaID()
  43458. case whatsappchannel.FieldBusinessID:
  43459. return m.AddedBusinessID()
  43460. case whatsappchannel.FieldOrganizationID:
  43461. return m.AddedOrganizationID()
  43462. }
  43463. return nil, false
  43464. }
  43465. // AddField adds the value to the field with the given name. It returns an error if
  43466. // the field is not defined in the schema, or if the type mismatched the field
  43467. // type.
  43468. func (m *WhatsappChannelMutation) AddField(name string, value ent.Value) error {
  43469. switch name {
  43470. case whatsappchannel.FieldStatus:
  43471. v, ok := value.(int8)
  43472. if !ok {
  43473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43474. }
  43475. m.AddStatus(v)
  43476. return nil
  43477. case whatsappchannel.FieldWabaID:
  43478. v, ok := value.(int64)
  43479. if !ok {
  43480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43481. }
  43482. m.AddWabaID(v)
  43483. return nil
  43484. case whatsappchannel.FieldBusinessID:
  43485. v, ok := value.(int64)
  43486. if !ok {
  43487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43488. }
  43489. m.AddBusinessID(v)
  43490. return nil
  43491. case whatsappchannel.FieldOrganizationID:
  43492. v, ok := value.(int64)
  43493. if !ok {
  43494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43495. }
  43496. m.AddOrganizationID(v)
  43497. return nil
  43498. }
  43499. return fmt.Errorf("unknown WhatsappChannel numeric field %s", name)
  43500. }
  43501. // ClearedFields returns all nullable fields that were cleared during this
  43502. // mutation.
  43503. func (m *WhatsappChannelMutation) ClearedFields() []string {
  43504. var fields []string
  43505. if m.FieldCleared(whatsappchannel.FieldStatus) {
  43506. fields = append(fields, whatsappchannel.FieldStatus)
  43507. }
  43508. if m.FieldCleared(whatsappchannel.FieldDeletedAt) {
  43509. fields = append(fields, whatsappchannel.FieldDeletedAt)
  43510. }
  43511. if m.FieldCleared(whatsappchannel.FieldAk) {
  43512. fields = append(fields, whatsappchannel.FieldAk)
  43513. }
  43514. if m.FieldCleared(whatsappchannel.FieldWaID) {
  43515. fields = append(fields, whatsappchannel.FieldWaID)
  43516. }
  43517. if m.FieldCleared(whatsappchannel.FieldWaName) {
  43518. fields = append(fields, whatsappchannel.FieldWaName)
  43519. }
  43520. if m.FieldCleared(whatsappchannel.FieldOrganizationID) {
  43521. fields = append(fields, whatsappchannel.FieldOrganizationID)
  43522. }
  43523. return fields
  43524. }
  43525. // FieldCleared returns a boolean indicating if a field with the given name was
  43526. // cleared in this mutation.
  43527. func (m *WhatsappChannelMutation) FieldCleared(name string) bool {
  43528. _, ok := m.clearedFields[name]
  43529. return ok
  43530. }
  43531. // ClearField clears the value of the field with the given name. It returns an
  43532. // error if the field is not defined in the schema.
  43533. func (m *WhatsappChannelMutation) ClearField(name string) error {
  43534. switch name {
  43535. case whatsappchannel.FieldStatus:
  43536. m.ClearStatus()
  43537. return nil
  43538. case whatsappchannel.FieldDeletedAt:
  43539. m.ClearDeletedAt()
  43540. return nil
  43541. case whatsappchannel.FieldAk:
  43542. m.ClearAk()
  43543. return nil
  43544. case whatsappchannel.FieldWaID:
  43545. m.ClearWaID()
  43546. return nil
  43547. case whatsappchannel.FieldWaName:
  43548. m.ClearWaName()
  43549. return nil
  43550. case whatsappchannel.FieldOrganizationID:
  43551. m.ClearOrganizationID()
  43552. return nil
  43553. }
  43554. return fmt.Errorf("unknown WhatsappChannel nullable field %s", name)
  43555. }
  43556. // ResetField resets all changes in the mutation for the field with the given name.
  43557. // It returns an error if the field is not defined in the schema.
  43558. func (m *WhatsappChannelMutation) ResetField(name string) error {
  43559. switch name {
  43560. case whatsappchannel.FieldCreatedAt:
  43561. m.ResetCreatedAt()
  43562. return nil
  43563. case whatsappchannel.FieldUpdatedAt:
  43564. m.ResetUpdatedAt()
  43565. return nil
  43566. case whatsappchannel.FieldStatus:
  43567. m.ResetStatus()
  43568. return nil
  43569. case whatsappchannel.FieldDeletedAt:
  43570. m.ResetDeletedAt()
  43571. return nil
  43572. case whatsappchannel.FieldAk:
  43573. m.ResetAk()
  43574. return nil
  43575. case whatsappchannel.FieldSk:
  43576. m.ResetSk()
  43577. return nil
  43578. case whatsappchannel.FieldWaID:
  43579. m.ResetWaID()
  43580. return nil
  43581. case whatsappchannel.FieldWaName:
  43582. m.ResetWaName()
  43583. return nil
  43584. case whatsappchannel.FieldWabaID:
  43585. m.ResetWabaID()
  43586. return nil
  43587. case whatsappchannel.FieldBusinessID:
  43588. m.ResetBusinessID()
  43589. return nil
  43590. case whatsappchannel.FieldOrganizationID:
  43591. m.ResetOrganizationID()
  43592. return nil
  43593. case whatsappchannel.FieldVerifyAccount:
  43594. m.ResetVerifyAccount()
  43595. return nil
  43596. }
  43597. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  43598. }
  43599. // AddedEdges returns all edge names that were set/added in this mutation.
  43600. func (m *WhatsappChannelMutation) AddedEdges() []string {
  43601. edges := make([]string, 0, 0)
  43602. return edges
  43603. }
  43604. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  43605. // name in this mutation.
  43606. func (m *WhatsappChannelMutation) AddedIDs(name string) []ent.Value {
  43607. return nil
  43608. }
  43609. // RemovedEdges returns all edge names that were removed in this mutation.
  43610. func (m *WhatsappChannelMutation) RemovedEdges() []string {
  43611. edges := make([]string, 0, 0)
  43612. return edges
  43613. }
  43614. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  43615. // the given name in this mutation.
  43616. func (m *WhatsappChannelMutation) RemovedIDs(name string) []ent.Value {
  43617. return nil
  43618. }
  43619. // ClearedEdges returns all edge names that were cleared in this mutation.
  43620. func (m *WhatsappChannelMutation) ClearedEdges() []string {
  43621. edges := make([]string, 0, 0)
  43622. return edges
  43623. }
  43624. // EdgeCleared returns a boolean which indicates if the edge with the given name
  43625. // was cleared in this mutation.
  43626. func (m *WhatsappChannelMutation) EdgeCleared(name string) bool {
  43627. return false
  43628. }
  43629. // ClearEdge clears the value of the edge with the given name. It returns an error
  43630. // if that edge is not defined in the schema.
  43631. func (m *WhatsappChannelMutation) ClearEdge(name string) error {
  43632. return fmt.Errorf("unknown WhatsappChannel unique edge %s", name)
  43633. }
  43634. // ResetEdge resets all changes to the edge with the given name in this mutation.
  43635. // It returns an error if the edge is not defined in the schema.
  43636. func (m *WhatsappChannelMutation) ResetEdge(name string) error {
  43637. return fmt.Errorf("unknown WhatsappChannel edge %s", name)
  43638. }
  43639. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  43640. type WorkExperienceMutation struct {
  43641. config
  43642. op Op
  43643. typ string
  43644. id *uint64
  43645. created_at *time.Time
  43646. updated_at *time.Time
  43647. deleted_at *time.Time
  43648. start_date *time.Time
  43649. end_date *time.Time
  43650. company *string
  43651. experience *string
  43652. organization_id *uint64
  43653. addorganization_id *int64
  43654. clearedFields map[string]struct{}
  43655. employee *uint64
  43656. clearedemployee bool
  43657. done bool
  43658. oldValue func(context.Context) (*WorkExperience, error)
  43659. predicates []predicate.WorkExperience
  43660. }
  43661. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  43662. // workexperienceOption allows management of the mutation configuration using functional options.
  43663. type workexperienceOption func(*WorkExperienceMutation)
  43664. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  43665. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  43666. m := &WorkExperienceMutation{
  43667. config: c,
  43668. op: op,
  43669. typ: TypeWorkExperience,
  43670. clearedFields: make(map[string]struct{}),
  43671. }
  43672. for _, opt := range opts {
  43673. opt(m)
  43674. }
  43675. return m
  43676. }
  43677. // withWorkExperienceID sets the ID field of the mutation.
  43678. func withWorkExperienceID(id uint64) workexperienceOption {
  43679. return func(m *WorkExperienceMutation) {
  43680. var (
  43681. err error
  43682. once sync.Once
  43683. value *WorkExperience
  43684. )
  43685. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  43686. once.Do(func() {
  43687. if m.done {
  43688. err = errors.New("querying old values post mutation is not allowed")
  43689. } else {
  43690. value, err = m.Client().WorkExperience.Get(ctx, id)
  43691. }
  43692. })
  43693. return value, err
  43694. }
  43695. m.id = &id
  43696. }
  43697. }
  43698. // withWorkExperience sets the old WorkExperience of the mutation.
  43699. func withWorkExperience(node *WorkExperience) workexperienceOption {
  43700. return func(m *WorkExperienceMutation) {
  43701. m.oldValue = func(context.Context) (*WorkExperience, error) {
  43702. return node, nil
  43703. }
  43704. m.id = &node.ID
  43705. }
  43706. }
  43707. // Client returns a new `ent.Client` from the mutation. If the mutation was
  43708. // executed in a transaction (ent.Tx), a transactional client is returned.
  43709. func (m WorkExperienceMutation) Client() *Client {
  43710. client := &Client{config: m.config}
  43711. client.init()
  43712. return client
  43713. }
  43714. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  43715. // it returns an error otherwise.
  43716. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  43717. if _, ok := m.driver.(*txDriver); !ok {
  43718. return nil, errors.New("ent: mutation is not running in a transaction")
  43719. }
  43720. tx := &Tx{config: m.config}
  43721. tx.init()
  43722. return tx, nil
  43723. }
  43724. // SetID sets the value of the id field. Note that this
  43725. // operation is only accepted on creation of WorkExperience entities.
  43726. func (m *WorkExperienceMutation) SetID(id uint64) {
  43727. m.id = &id
  43728. }
  43729. // ID returns the ID value in the mutation. Note that the ID is only available
  43730. // if it was provided to the builder or after it was returned from the database.
  43731. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  43732. if m.id == nil {
  43733. return
  43734. }
  43735. return *m.id, true
  43736. }
  43737. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  43738. // That means, if the mutation is applied within a transaction with an isolation level such
  43739. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  43740. // or updated by the mutation.
  43741. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  43742. switch {
  43743. case m.op.Is(OpUpdateOne | OpDeleteOne):
  43744. id, exists := m.ID()
  43745. if exists {
  43746. return []uint64{id}, nil
  43747. }
  43748. fallthrough
  43749. case m.op.Is(OpUpdate | OpDelete):
  43750. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  43751. default:
  43752. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  43753. }
  43754. }
  43755. // SetCreatedAt sets the "created_at" field.
  43756. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  43757. m.created_at = &t
  43758. }
  43759. // CreatedAt returns the value of the "created_at" field in the mutation.
  43760. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  43761. v := m.created_at
  43762. if v == nil {
  43763. return
  43764. }
  43765. return *v, true
  43766. }
  43767. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  43768. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  43769. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43770. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  43771. if !m.op.Is(OpUpdateOne) {
  43772. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  43773. }
  43774. if m.id == nil || m.oldValue == nil {
  43775. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  43776. }
  43777. oldValue, err := m.oldValue(ctx)
  43778. if err != nil {
  43779. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  43780. }
  43781. return oldValue.CreatedAt, nil
  43782. }
  43783. // ResetCreatedAt resets all changes to the "created_at" field.
  43784. func (m *WorkExperienceMutation) ResetCreatedAt() {
  43785. m.created_at = nil
  43786. }
  43787. // SetUpdatedAt sets the "updated_at" field.
  43788. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  43789. m.updated_at = &t
  43790. }
  43791. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  43792. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  43793. v := m.updated_at
  43794. if v == nil {
  43795. return
  43796. }
  43797. return *v, true
  43798. }
  43799. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  43800. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  43801. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43802. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  43803. if !m.op.Is(OpUpdateOne) {
  43804. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  43805. }
  43806. if m.id == nil || m.oldValue == nil {
  43807. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  43808. }
  43809. oldValue, err := m.oldValue(ctx)
  43810. if err != nil {
  43811. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  43812. }
  43813. return oldValue.UpdatedAt, nil
  43814. }
  43815. // ResetUpdatedAt resets all changes to the "updated_at" field.
  43816. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  43817. m.updated_at = nil
  43818. }
  43819. // SetDeletedAt sets the "deleted_at" field.
  43820. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  43821. m.deleted_at = &t
  43822. }
  43823. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  43824. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  43825. v := m.deleted_at
  43826. if v == nil {
  43827. return
  43828. }
  43829. return *v, true
  43830. }
  43831. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  43832. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  43833. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43834. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  43835. if !m.op.Is(OpUpdateOne) {
  43836. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  43837. }
  43838. if m.id == nil || m.oldValue == nil {
  43839. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  43840. }
  43841. oldValue, err := m.oldValue(ctx)
  43842. if err != nil {
  43843. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  43844. }
  43845. return oldValue.DeletedAt, nil
  43846. }
  43847. // ClearDeletedAt clears the value of the "deleted_at" field.
  43848. func (m *WorkExperienceMutation) ClearDeletedAt() {
  43849. m.deleted_at = nil
  43850. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  43851. }
  43852. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  43853. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  43854. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  43855. return ok
  43856. }
  43857. // ResetDeletedAt resets all changes to the "deleted_at" field.
  43858. func (m *WorkExperienceMutation) ResetDeletedAt() {
  43859. m.deleted_at = nil
  43860. delete(m.clearedFields, workexperience.FieldDeletedAt)
  43861. }
  43862. // SetEmployeeID sets the "employee_id" field.
  43863. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  43864. m.employee = &u
  43865. }
  43866. // EmployeeID returns the value of the "employee_id" field in the mutation.
  43867. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  43868. v := m.employee
  43869. if v == nil {
  43870. return
  43871. }
  43872. return *v, true
  43873. }
  43874. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  43875. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  43876. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43877. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  43878. if !m.op.Is(OpUpdateOne) {
  43879. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  43880. }
  43881. if m.id == nil || m.oldValue == nil {
  43882. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  43883. }
  43884. oldValue, err := m.oldValue(ctx)
  43885. if err != nil {
  43886. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  43887. }
  43888. return oldValue.EmployeeID, nil
  43889. }
  43890. // ResetEmployeeID resets all changes to the "employee_id" field.
  43891. func (m *WorkExperienceMutation) ResetEmployeeID() {
  43892. m.employee = nil
  43893. }
  43894. // SetStartDate sets the "start_date" field.
  43895. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  43896. m.start_date = &t
  43897. }
  43898. // StartDate returns the value of the "start_date" field in the mutation.
  43899. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  43900. v := m.start_date
  43901. if v == nil {
  43902. return
  43903. }
  43904. return *v, true
  43905. }
  43906. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  43907. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  43908. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43909. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  43910. if !m.op.Is(OpUpdateOne) {
  43911. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  43912. }
  43913. if m.id == nil || m.oldValue == nil {
  43914. return v, errors.New("OldStartDate requires an ID field in the mutation")
  43915. }
  43916. oldValue, err := m.oldValue(ctx)
  43917. if err != nil {
  43918. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  43919. }
  43920. return oldValue.StartDate, nil
  43921. }
  43922. // ResetStartDate resets all changes to the "start_date" field.
  43923. func (m *WorkExperienceMutation) ResetStartDate() {
  43924. m.start_date = nil
  43925. }
  43926. // SetEndDate sets the "end_date" field.
  43927. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  43928. m.end_date = &t
  43929. }
  43930. // EndDate returns the value of the "end_date" field in the mutation.
  43931. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  43932. v := m.end_date
  43933. if v == nil {
  43934. return
  43935. }
  43936. return *v, true
  43937. }
  43938. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  43939. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  43940. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43941. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  43942. if !m.op.Is(OpUpdateOne) {
  43943. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  43944. }
  43945. if m.id == nil || m.oldValue == nil {
  43946. return v, errors.New("OldEndDate requires an ID field in the mutation")
  43947. }
  43948. oldValue, err := m.oldValue(ctx)
  43949. if err != nil {
  43950. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  43951. }
  43952. return oldValue.EndDate, nil
  43953. }
  43954. // ResetEndDate resets all changes to the "end_date" field.
  43955. func (m *WorkExperienceMutation) ResetEndDate() {
  43956. m.end_date = nil
  43957. }
  43958. // SetCompany sets the "company" field.
  43959. func (m *WorkExperienceMutation) SetCompany(s string) {
  43960. m.company = &s
  43961. }
  43962. // Company returns the value of the "company" field in the mutation.
  43963. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  43964. v := m.company
  43965. if v == nil {
  43966. return
  43967. }
  43968. return *v, true
  43969. }
  43970. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  43971. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  43972. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43973. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  43974. if !m.op.Is(OpUpdateOne) {
  43975. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  43976. }
  43977. if m.id == nil || m.oldValue == nil {
  43978. return v, errors.New("OldCompany requires an ID field in the mutation")
  43979. }
  43980. oldValue, err := m.oldValue(ctx)
  43981. if err != nil {
  43982. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  43983. }
  43984. return oldValue.Company, nil
  43985. }
  43986. // ResetCompany resets all changes to the "company" field.
  43987. func (m *WorkExperienceMutation) ResetCompany() {
  43988. m.company = nil
  43989. }
  43990. // SetExperience sets the "experience" field.
  43991. func (m *WorkExperienceMutation) SetExperience(s string) {
  43992. m.experience = &s
  43993. }
  43994. // Experience returns the value of the "experience" field in the mutation.
  43995. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  43996. v := m.experience
  43997. if v == nil {
  43998. return
  43999. }
  44000. return *v, true
  44001. }
  44002. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  44003. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  44004. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44005. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  44006. if !m.op.Is(OpUpdateOne) {
  44007. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  44008. }
  44009. if m.id == nil || m.oldValue == nil {
  44010. return v, errors.New("OldExperience requires an ID field in the mutation")
  44011. }
  44012. oldValue, err := m.oldValue(ctx)
  44013. if err != nil {
  44014. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  44015. }
  44016. return oldValue.Experience, nil
  44017. }
  44018. // ResetExperience resets all changes to the "experience" field.
  44019. func (m *WorkExperienceMutation) ResetExperience() {
  44020. m.experience = nil
  44021. }
  44022. // SetOrganizationID sets the "organization_id" field.
  44023. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  44024. m.organization_id = &u
  44025. m.addorganization_id = nil
  44026. }
  44027. // OrganizationID returns the value of the "organization_id" field in the mutation.
  44028. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  44029. v := m.organization_id
  44030. if v == nil {
  44031. return
  44032. }
  44033. return *v, true
  44034. }
  44035. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  44036. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  44037. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44038. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  44039. if !m.op.Is(OpUpdateOne) {
  44040. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  44041. }
  44042. if m.id == nil || m.oldValue == nil {
  44043. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  44044. }
  44045. oldValue, err := m.oldValue(ctx)
  44046. if err != nil {
  44047. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  44048. }
  44049. return oldValue.OrganizationID, nil
  44050. }
  44051. // AddOrganizationID adds u to the "organization_id" field.
  44052. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  44053. if m.addorganization_id != nil {
  44054. *m.addorganization_id += u
  44055. } else {
  44056. m.addorganization_id = &u
  44057. }
  44058. }
  44059. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  44060. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  44061. v := m.addorganization_id
  44062. if v == nil {
  44063. return
  44064. }
  44065. return *v, true
  44066. }
  44067. // ResetOrganizationID resets all changes to the "organization_id" field.
  44068. func (m *WorkExperienceMutation) ResetOrganizationID() {
  44069. m.organization_id = nil
  44070. m.addorganization_id = nil
  44071. }
  44072. // ClearEmployee clears the "employee" edge to the Employee entity.
  44073. func (m *WorkExperienceMutation) ClearEmployee() {
  44074. m.clearedemployee = true
  44075. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  44076. }
  44077. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  44078. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  44079. return m.clearedemployee
  44080. }
  44081. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  44082. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  44083. // EmployeeID instead. It exists only for internal usage by the builders.
  44084. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  44085. if id := m.employee; id != nil {
  44086. ids = append(ids, *id)
  44087. }
  44088. return
  44089. }
  44090. // ResetEmployee resets all changes to the "employee" edge.
  44091. func (m *WorkExperienceMutation) ResetEmployee() {
  44092. m.employee = nil
  44093. m.clearedemployee = false
  44094. }
  44095. // Where appends a list predicates to the WorkExperienceMutation builder.
  44096. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  44097. m.predicates = append(m.predicates, ps...)
  44098. }
  44099. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  44100. // users can use type-assertion to append predicates that do not depend on any generated package.
  44101. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  44102. p := make([]predicate.WorkExperience, len(ps))
  44103. for i := range ps {
  44104. p[i] = ps[i]
  44105. }
  44106. m.Where(p...)
  44107. }
  44108. // Op returns the operation name.
  44109. func (m *WorkExperienceMutation) Op() Op {
  44110. return m.op
  44111. }
  44112. // SetOp allows setting the mutation operation.
  44113. func (m *WorkExperienceMutation) SetOp(op Op) {
  44114. m.op = op
  44115. }
  44116. // Type returns the node type of this mutation (WorkExperience).
  44117. func (m *WorkExperienceMutation) Type() string {
  44118. return m.typ
  44119. }
  44120. // Fields returns all fields that were changed during this mutation. Note that in
  44121. // order to get all numeric fields that were incremented/decremented, call
  44122. // AddedFields().
  44123. func (m *WorkExperienceMutation) Fields() []string {
  44124. fields := make([]string, 0, 9)
  44125. if m.created_at != nil {
  44126. fields = append(fields, workexperience.FieldCreatedAt)
  44127. }
  44128. if m.updated_at != nil {
  44129. fields = append(fields, workexperience.FieldUpdatedAt)
  44130. }
  44131. if m.deleted_at != nil {
  44132. fields = append(fields, workexperience.FieldDeletedAt)
  44133. }
  44134. if m.employee != nil {
  44135. fields = append(fields, workexperience.FieldEmployeeID)
  44136. }
  44137. if m.start_date != nil {
  44138. fields = append(fields, workexperience.FieldStartDate)
  44139. }
  44140. if m.end_date != nil {
  44141. fields = append(fields, workexperience.FieldEndDate)
  44142. }
  44143. if m.company != nil {
  44144. fields = append(fields, workexperience.FieldCompany)
  44145. }
  44146. if m.experience != nil {
  44147. fields = append(fields, workexperience.FieldExperience)
  44148. }
  44149. if m.organization_id != nil {
  44150. fields = append(fields, workexperience.FieldOrganizationID)
  44151. }
  44152. return fields
  44153. }
  44154. // Field returns the value of a field with the given name. The second boolean
  44155. // return value indicates that this field was not set, or was not defined in the
  44156. // schema.
  44157. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  44158. switch name {
  44159. case workexperience.FieldCreatedAt:
  44160. return m.CreatedAt()
  44161. case workexperience.FieldUpdatedAt:
  44162. return m.UpdatedAt()
  44163. case workexperience.FieldDeletedAt:
  44164. return m.DeletedAt()
  44165. case workexperience.FieldEmployeeID:
  44166. return m.EmployeeID()
  44167. case workexperience.FieldStartDate:
  44168. return m.StartDate()
  44169. case workexperience.FieldEndDate:
  44170. return m.EndDate()
  44171. case workexperience.FieldCompany:
  44172. return m.Company()
  44173. case workexperience.FieldExperience:
  44174. return m.Experience()
  44175. case workexperience.FieldOrganizationID:
  44176. return m.OrganizationID()
  44177. }
  44178. return nil, false
  44179. }
  44180. // OldField returns the old value of the field from the database. An error is
  44181. // returned if the mutation operation is not UpdateOne, or the query to the
  44182. // database failed.
  44183. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  44184. switch name {
  44185. case workexperience.FieldCreatedAt:
  44186. return m.OldCreatedAt(ctx)
  44187. case workexperience.FieldUpdatedAt:
  44188. return m.OldUpdatedAt(ctx)
  44189. case workexperience.FieldDeletedAt:
  44190. return m.OldDeletedAt(ctx)
  44191. case workexperience.FieldEmployeeID:
  44192. return m.OldEmployeeID(ctx)
  44193. case workexperience.FieldStartDate:
  44194. return m.OldStartDate(ctx)
  44195. case workexperience.FieldEndDate:
  44196. return m.OldEndDate(ctx)
  44197. case workexperience.FieldCompany:
  44198. return m.OldCompany(ctx)
  44199. case workexperience.FieldExperience:
  44200. return m.OldExperience(ctx)
  44201. case workexperience.FieldOrganizationID:
  44202. return m.OldOrganizationID(ctx)
  44203. }
  44204. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  44205. }
  44206. // SetField sets the value of a field with the given name. It returns an error if
  44207. // the field is not defined in the schema, or if the type mismatched the field
  44208. // type.
  44209. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  44210. switch name {
  44211. case workexperience.FieldCreatedAt:
  44212. v, ok := value.(time.Time)
  44213. if !ok {
  44214. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44215. }
  44216. m.SetCreatedAt(v)
  44217. return nil
  44218. case workexperience.FieldUpdatedAt:
  44219. v, ok := value.(time.Time)
  44220. if !ok {
  44221. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44222. }
  44223. m.SetUpdatedAt(v)
  44224. return nil
  44225. case workexperience.FieldDeletedAt:
  44226. v, ok := value.(time.Time)
  44227. if !ok {
  44228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44229. }
  44230. m.SetDeletedAt(v)
  44231. return nil
  44232. case workexperience.FieldEmployeeID:
  44233. v, ok := value.(uint64)
  44234. if !ok {
  44235. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44236. }
  44237. m.SetEmployeeID(v)
  44238. return nil
  44239. case workexperience.FieldStartDate:
  44240. v, ok := value.(time.Time)
  44241. if !ok {
  44242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44243. }
  44244. m.SetStartDate(v)
  44245. return nil
  44246. case workexperience.FieldEndDate:
  44247. v, ok := value.(time.Time)
  44248. if !ok {
  44249. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44250. }
  44251. m.SetEndDate(v)
  44252. return nil
  44253. case workexperience.FieldCompany:
  44254. v, ok := value.(string)
  44255. if !ok {
  44256. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44257. }
  44258. m.SetCompany(v)
  44259. return nil
  44260. case workexperience.FieldExperience:
  44261. v, ok := value.(string)
  44262. if !ok {
  44263. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44264. }
  44265. m.SetExperience(v)
  44266. return nil
  44267. case workexperience.FieldOrganizationID:
  44268. v, ok := value.(uint64)
  44269. if !ok {
  44270. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44271. }
  44272. m.SetOrganizationID(v)
  44273. return nil
  44274. }
  44275. return fmt.Errorf("unknown WorkExperience field %s", name)
  44276. }
  44277. // AddedFields returns all numeric fields that were incremented/decremented during
  44278. // this mutation.
  44279. func (m *WorkExperienceMutation) AddedFields() []string {
  44280. var fields []string
  44281. if m.addorganization_id != nil {
  44282. fields = append(fields, workexperience.FieldOrganizationID)
  44283. }
  44284. return fields
  44285. }
  44286. // AddedField returns the numeric value that was incremented/decremented on a field
  44287. // with the given name. The second boolean return value indicates that this field
  44288. // was not set, or was not defined in the schema.
  44289. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  44290. switch name {
  44291. case workexperience.FieldOrganizationID:
  44292. return m.AddedOrganizationID()
  44293. }
  44294. return nil, false
  44295. }
  44296. // AddField adds the value to the field with the given name. It returns an error if
  44297. // the field is not defined in the schema, or if the type mismatched the field
  44298. // type.
  44299. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  44300. switch name {
  44301. case workexperience.FieldOrganizationID:
  44302. v, ok := value.(int64)
  44303. if !ok {
  44304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44305. }
  44306. m.AddOrganizationID(v)
  44307. return nil
  44308. }
  44309. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  44310. }
  44311. // ClearedFields returns all nullable fields that were cleared during this
  44312. // mutation.
  44313. func (m *WorkExperienceMutation) ClearedFields() []string {
  44314. var fields []string
  44315. if m.FieldCleared(workexperience.FieldDeletedAt) {
  44316. fields = append(fields, workexperience.FieldDeletedAt)
  44317. }
  44318. return fields
  44319. }
  44320. // FieldCleared returns a boolean indicating if a field with the given name was
  44321. // cleared in this mutation.
  44322. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  44323. _, ok := m.clearedFields[name]
  44324. return ok
  44325. }
  44326. // ClearField clears the value of the field with the given name. It returns an
  44327. // error if the field is not defined in the schema.
  44328. func (m *WorkExperienceMutation) ClearField(name string) error {
  44329. switch name {
  44330. case workexperience.FieldDeletedAt:
  44331. m.ClearDeletedAt()
  44332. return nil
  44333. }
  44334. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  44335. }
  44336. // ResetField resets all changes in the mutation for the field with the given name.
  44337. // It returns an error if the field is not defined in the schema.
  44338. func (m *WorkExperienceMutation) ResetField(name string) error {
  44339. switch name {
  44340. case workexperience.FieldCreatedAt:
  44341. m.ResetCreatedAt()
  44342. return nil
  44343. case workexperience.FieldUpdatedAt:
  44344. m.ResetUpdatedAt()
  44345. return nil
  44346. case workexperience.FieldDeletedAt:
  44347. m.ResetDeletedAt()
  44348. return nil
  44349. case workexperience.FieldEmployeeID:
  44350. m.ResetEmployeeID()
  44351. return nil
  44352. case workexperience.FieldStartDate:
  44353. m.ResetStartDate()
  44354. return nil
  44355. case workexperience.FieldEndDate:
  44356. m.ResetEndDate()
  44357. return nil
  44358. case workexperience.FieldCompany:
  44359. m.ResetCompany()
  44360. return nil
  44361. case workexperience.FieldExperience:
  44362. m.ResetExperience()
  44363. return nil
  44364. case workexperience.FieldOrganizationID:
  44365. m.ResetOrganizationID()
  44366. return nil
  44367. }
  44368. return fmt.Errorf("unknown WorkExperience field %s", name)
  44369. }
  44370. // AddedEdges returns all edge names that were set/added in this mutation.
  44371. func (m *WorkExperienceMutation) AddedEdges() []string {
  44372. edges := make([]string, 0, 1)
  44373. if m.employee != nil {
  44374. edges = append(edges, workexperience.EdgeEmployee)
  44375. }
  44376. return edges
  44377. }
  44378. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  44379. // name in this mutation.
  44380. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  44381. switch name {
  44382. case workexperience.EdgeEmployee:
  44383. if id := m.employee; id != nil {
  44384. return []ent.Value{*id}
  44385. }
  44386. }
  44387. return nil
  44388. }
  44389. // RemovedEdges returns all edge names that were removed in this mutation.
  44390. func (m *WorkExperienceMutation) RemovedEdges() []string {
  44391. edges := make([]string, 0, 1)
  44392. return edges
  44393. }
  44394. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  44395. // the given name in this mutation.
  44396. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  44397. return nil
  44398. }
  44399. // ClearedEdges returns all edge names that were cleared in this mutation.
  44400. func (m *WorkExperienceMutation) ClearedEdges() []string {
  44401. edges := make([]string, 0, 1)
  44402. if m.clearedemployee {
  44403. edges = append(edges, workexperience.EdgeEmployee)
  44404. }
  44405. return edges
  44406. }
  44407. // EdgeCleared returns a boolean which indicates if the edge with the given name
  44408. // was cleared in this mutation.
  44409. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  44410. switch name {
  44411. case workexperience.EdgeEmployee:
  44412. return m.clearedemployee
  44413. }
  44414. return false
  44415. }
  44416. // ClearEdge clears the value of the edge with the given name. It returns an error
  44417. // if that edge is not defined in the schema.
  44418. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  44419. switch name {
  44420. case workexperience.EdgeEmployee:
  44421. m.ClearEmployee()
  44422. return nil
  44423. }
  44424. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  44425. }
  44426. // ResetEdge resets all changes to the edge with the given name in this mutation.
  44427. // It returns an error if the edge is not defined in the schema.
  44428. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  44429. switch name {
  44430. case workexperience.EdgeEmployee:
  44431. m.ResetEmployee()
  44432. return nil
  44433. }
  44434. return fmt.Errorf("unknown WorkExperience edge %s", name)
  44435. }
  44436. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  44437. type WpChatroomMutation struct {
  44438. config
  44439. op Op
  44440. typ string
  44441. id *uint64
  44442. created_at *time.Time
  44443. updated_at *time.Time
  44444. status *uint8
  44445. addstatus *int8
  44446. wx_wxid *string
  44447. chatroom_id *string
  44448. nickname *string
  44449. owner *string
  44450. avatar *string
  44451. member_list *[]string
  44452. appendmember_list []string
  44453. clearedFields map[string]struct{}
  44454. done bool
  44455. oldValue func(context.Context) (*WpChatroom, error)
  44456. predicates []predicate.WpChatroom
  44457. }
  44458. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  44459. // wpchatroomOption allows management of the mutation configuration using functional options.
  44460. type wpchatroomOption func(*WpChatroomMutation)
  44461. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  44462. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  44463. m := &WpChatroomMutation{
  44464. config: c,
  44465. op: op,
  44466. typ: TypeWpChatroom,
  44467. clearedFields: make(map[string]struct{}),
  44468. }
  44469. for _, opt := range opts {
  44470. opt(m)
  44471. }
  44472. return m
  44473. }
  44474. // withWpChatroomID sets the ID field of the mutation.
  44475. func withWpChatroomID(id uint64) wpchatroomOption {
  44476. return func(m *WpChatroomMutation) {
  44477. var (
  44478. err error
  44479. once sync.Once
  44480. value *WpChatroom
  44481. )
  44482. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  44483. once.Do(func() {
  44484. if m.done {
  44485. err = errors.New("querying old values post mutation is not allowed")
  44486. } else {
  44487. value, err = m.Client().WpChatroom.Get(ctx, id)
  44488. }
  44489. })
  44490. return value, err
  44491. }
  44492. m.id = &id
  44493. }
  44494. }
  44495. // withWpChatroom sets the old WpChatroom of the mutation.
  44496. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  44497. return func(m *WpChatroomMutation) {
  44498. m.oldValue = func(context.Context) (*WpChatroom, error) {
  44499. return node, nil
  44500. }
  44501. m.id = &node.ID
  44502. }
  44503. }
  44504. // Client returns a new `ent.Client` from the mutation. If the mutation was
  44505. // executed in a transaction (ent.Tx), a transactional client is returned.
  44506. func (m WpChatroomMutation) Client() *Client {
  44507. client := &Client{config: m.config}
  44508. client.init()
  44509. return client
  44510. }
  44511. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  44512. // it returns an error otherwise.
  44513. func (m WpChatroomMutation) Tx() (*Tx, error) {
  44514. if _, ok := m.driver.(*txDriver); !ok {
  44515. return nil, errors.New("ent: mutation is not running in a transaction")
  44516. }
  44517. tx := &Tx{config: m.config}
  44518. tx.init()
  44519. return tx, nil
  44520. }
  44521. // SetID sets the value of the id field. Note that this
  44522. // operation is only accepted on creation of WpChatroom entities.
  44523. func (m *WpChatroomMutation) SetID(id uint64) {
  44524. m.id = &id
  44525. }
  44526. // ID returns the ID value in the mutation. Note that the ID is only available
  44527. // if it was provided to the builder or after it was returned from the database.
  44528. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  44529. if m.id == nil {
  44530. return
  44531. }
  44532. return *m.id, true
  44533. }
  44534. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  44535. // That means, if the mutation is applied within a transaction with an isolation level such
  44536. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  44537. // or updated by the mutation.
  44538. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  44539. switch {
  44540. case m.op.Is(OpUpdateOne | OpDeleteOne):
  44541. id, exists := m.ID()
  44542. if exists {
  44543. return []uint64{id}, nil
  44544. }
  44545. fallthrough
  44546. case m.op.Is(OpUpdate | OpDelete):
  44547. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  44548. default:
  44549. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  44550. }
  44551. }
  44552. // SetCreatedAt sets the "created_at" field.
  44553. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  44554. m.created_at = &t
  44555. }
  44556. // CreatedAt returns the value of the "created_at" field in the mutation.
  44557. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  44558. v := m.created_at
  44559. if v == nil {
  44560. return
  44561. }
  44562. return *v, true
  44563. }
  44564. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  44565. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  44566. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44567. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  44568. if !m.op.Is(OpUpdateOne) {
  44569. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  44570. }
  44571. if m.id == nil || m.oldValue == nil {
  44572. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  44573. }
  44574. oldValue, err := m.oldValue(ctx)
  44575. if err != nil {
  44576. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  44577. }
  44578. return oldValue.CreatedAt, nil
  44579. }
  44580. // ResetCreatedAt resets all changes to the "created_at" field.
  44581. func (m *WpChatroomMutation) ResetCreatedAt() {
  44582. m.created_at = nil
  44583. }
  44584. // SetUpdatedAt sets the "updated_at" field.
  44585. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  44586. m.updated_at = &t
  44587. }
  44588. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  44589. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  44590. v := m.updated_at
  44591. if v == nil {
  44592. return
  44593. }
  44594. return *v, true
  44595. }
  44596. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  44597. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  44598. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44599. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  44600. if !m.op.Is(OpUpdateOne) {
  44601. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  44602. }
  44603. if m.id == nil || m.oldValue == nil {
  44604. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  44605. }
  44606. oldValue, err := m.oldValue(ctx)
  44607. if err != nil {
  44608. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  44609. }
  44610. return oldValue.UpdatedAt, nil
  44611. }
  44612. // ResetUpdatedAt resets all changes to the "updated_at" field.
  44613. func (m *WpChatroomMutation) ResetUpdatedAt() {
  44614. m.updated_at = nil
  44615. }
  44616. // SetStatus sets the "status" field.
  44617. func (m *WpChatroomMutation) SetStatus(u uint8) {
  44618. m.status = &u
  44619. m.addstatus = nil
  44620. }
  44621. // Status returns the value of the "status" field in the mutation.
  44622. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  44623. v := m.status
  44624. if v == nil {
  44625. return
  44626. }
  44627. return *v, true
  44628. }
  44629. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  44630. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  44631. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44632. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  44633. if !m.op.Is(OpUpdateOne) {
  44634. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  44635. }
  44636. if m.id == nil || m.oldValue == nil {
  44637. return v, errors.New("OldStatus requires an ID field in the mutation")
  44638. }
  44639. oldValue, err := m.oldValue(ctx)
  44640. if err != nil {
  44641. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  44642. }
  44643. return oldValue.Status, nil
  44644. }
  44645. // AddStatus adds u to the "status" field.
  44646. func (m *WpChatroomMutation) AddStatus(u int8) {
  44647. if m.addstatus != nil {
  44648. *m.addstatus += u
  44649. } else {
  44650. m.addstatus = &u
  44651. }
  44652. }
  44653. // AddedStatus returns the value that was added to the "status" field in this mutation.
  44654. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  44655. v := m.addstatus
  44656. if v == nil {
  44657. return
  44658. }
  44659. return *v, true
  44660. }
  44661. // ClearStatus clears the value of the "status" field.
  44662. func (m *WpChatroomMutation) ClearStatus() {
  44663. m.status = nil
  44664. m.addstatus = nil
  44665. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  44666. }
  44667. // StatusCleared returns if the "status" field was cleared in this mutation.
  44668. func (m *WpChatroomMutation) StatusCleared() bool {
  44669. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  44670. return ok
  44671. }
  44672. // ResetStatus resets all changes to the "status" field.
  44673. func (m *WpChatroomMutation) ResetStatus() {
  44674. m.status = nil
  44675. m.addstatus = nil
  44676. delete(m.clearedFields, wpchatroom.FieldStatus)
  44677. }
  44678. // SetWxWxid sets the "wx_wxid" field.
  44679. func (m *WpChatroomMutation) SetWxWxid(s string) {
  44680. m.wx_wxid = &s
  44681. }
  44682. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  44683. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  44684. v := m.wx_wxid
  44685. if v == nil {
  44686. return
  44687. }
  44688. return *v, true
  44689. }
  44690. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  44691. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  44692. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44693. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  44694. if !m.op.Is(OpUpdateOne) {
  44695. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  44696. }
  44697. if m.id == nil || m.oldValue == nil {
  44698. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  44699. }
  44700. oldValue, err := m.oldValue(ctx)
  44701. if err != nil {
  44702. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  44703. }
  44704. return oldValue.WxWxid, nil
  44705. }
  44706. // ResetWxWxid resets all changes to the "wx_wxid" field.
  44707. func (m *WpChatroomMutation) ResetWxWxid() {
  44708. m.wx_wxid = nil
  44709. }
  44710. // SetChatroomID sets the "chatroom_id" field.
  44711. func (m *WpChatroomMutation) SetChatroomID(s string) {
  44712. m.chatroom_id = &s
  44713. }
  44714. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  44715. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  44716. v := m.chatroom_id
  44717. if v == nil {
  44718. return
  44719. }
  44720. return *v, true
  44721. }
  44722. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  44723. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  44724. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44725. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  44726. if !m.op.Is(OpUpdateOne) {
  44727. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  44728. }
  44729. if m.id == nil || m.oldValue == nil {
  44730. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  44731. }
  44732. oldValue, err := m.oldValue(ctx)
  44733. if err != nil {
  44734. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  44735. }
  44736. return oldValue.ChatroomID, nil
  44737. }
  44738. // ResetChatroomID resets all changes to the "chatroom_id" field.
  44739. func (m *WpChatroomMutation) ResetChatroomID() {
  44740. m.chatroom_id = nil
  44741. }
  44742. // SetNickname sets the "nickname" field.
  44743. func (m *WpChatroomMutation) SetNickname(s string) {
  44744. m.nickname = &s
  44745. }
  44746. // Nickname returns the value of the "nickname" field in the mutation.
  44747. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  44748. v := m.nickname
  44749. if v == nil {
  44750. return
  44751. }
  44752. return *v, true
  44753. }
  44754. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  44755. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  44756. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44757. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  44758. if !m.op.Is(OpUpdateOne) {
  44759. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  44760. }
  44761. if m.id == nil || m.oldValue == nil {
  44762. return v, errors.New("OldNickname requires an ID field in the mutation")
  44763. }
  44764. oldValue, err := m.oldValue(ctx)
  44765. if err != nil {
  44766. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  44767. }
  44768. return oldValue.Nickname, nil
  44769. }
  44770. // ResetNickname resets all changes to the "nickname" field.
  44771. func (m *WpChatroomMutation) ResetNickname() {
  44772. m.nickname = nil
  44773. }
  44774. // SetOwner sets the "owner" field.
  44775. func (m *WpChatroomMutation) SetOwner(s string) {
  44776. m.owner = &s
  44777. }
  44778. // Owner returns the value of the "owner" field in the mutation.
  44779. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  44780. v := m.owner
  44781. if v == nil {
  44782. return
  44783. }
  44784. return *v, true
  44785. }
  44786. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  44787. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  44788. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44789. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  44790. if !m.op.Is(OpUpdateOne) {
  44791. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  44792. }
  44793. if m.id == nil || m.oldValue == nil {
  44794. return v, errors.New("OldOwner requires an ID field in the mutation")
  44795. }
  44796. oldValue, err := m.oldValue(ctx)
  44797. if err != nil {
  44798. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  44799. }
  44800. return oldValue.Owner, nil
  44801. }
  44802. // ResetOwner resets all changes to the "owner" field.
  44803. func (m *WpChatroomMutation) ResetOwner() {
  44804. m.owner = nil
  44805. }
  44806. // SetAvatar sets the "avatar" field.
  44807. func (m *WpChatroomMutation) SetAvatar(s string) {
  44808. m.avatar = &s
  44809. }
  44810. // Avatar returns the value of the "avatar" field in the mutation.
  44811. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  44812. v := m.avatar
  44813. if v == nil {
  44814. return
  44815. }
  44816. return *v, true
  44817. }
  44818. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  44819. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  44820. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44821. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  44822. if !m.op.Is(OpUpdateOne) {
  44823. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  44824. }
  44825. if m.id == nil || m.oldValue == nil {
  44826. return v, errors.New("OldAvatar requires an ID field in the mutation")
  44827. }
  44828. oldValue, err := m.oldValue(ctx)
  44829. if err != nil {
  44830. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  44831. }
  44832. return oldValue.Avatar, nil
  44833. }
  44834. // ResetAvatar resets all changes to the "avatar" field.
  44835. func (m *WpChatroomMutation) ResetAvatar() {
  44836. m.avatar = nil
  44837. }
  44838. // SetMemberList sets the "member_list" field.
  44839. func (m *WpChatroomMutation) SetMemberList(s []string) {
  44840. m.member_list = &s
  44841. m.appendmember_list = nil
  44842. }
  44843. // MemberList returns the value of the "member_list" field in the mutation.
  44844. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  44845. v := m.member_list
  44846. if v == nil {
  44847. return
  44848. }
  44849. return *v, true
  44850. }
  44851. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  44852. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  44853. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44854. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  44855. if !m.op.Is(OpUpdateOne) {
  44856. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  44857. }
  44858. if m.id == nil || m.oldValue == nil {
  44859. return v, errors.New("OldMemberList requires an ID field in the mutation")
  44860. }
  44861. oldValue, err := m.oldValue(ctx)
  44862. if err != nil {
  44863. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  44864. }
  44865. return oldValue.MemberList, nil
  44866. }
  44867. // AppendMemberList adds s to the "member_list" field.
  44868. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  44869. m.appendmember_list = append(m.appendmember_list, s...)
  44870. }
  44871. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  44872. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  44873. if len(m.appendmember_list) == 0 {
  44874. return nil, false
  44875. }
  44876. return m.appendmember_list, true
  44877. }
  44878. // ResetMemberList resets all changes to the "member_list" field.
  44879. func (m *WpChatroomMutation) ResetMemberList() {
  44880. m.member_list = nil
  44881. m.appendmember_list = nil
  44882. }
  44883. // Where appends a list predicates to the WpChatroomMutation builder.
  44884. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  44885. m.predicates = append(m.predicates, ps...)
  44886. }
  44887. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  44888. // users can use type-assertion to append predicates that do not depend on any generated package.
  44889. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  44890. p := make([]predicate.WpChatroom, len(ps))
  44891. for i := range ps {
  44892. p[i] = ps[i]
  44893. }
  44894. m.Where(p...)
  44895. }
  44896. // Op returns the operation name.
  44897. func (m *WpChatroomMutation) Op() Op {
  44898. return m.op
  44899. }
  44900. // SetOp allows setting the mutation operation.
  44901. func (m *WpChatroomMutation) SetOp(op Op) {
  44902. m.op = op
  44903. }
  44904. // Type returns the node type of this mutation (WpChatroom).
  44905. func (m *WpChatroomMutation) Type() string {
  44906. return m.typ
  44907. }
  44908. // Fields returns all fields that were changed during this mutation. Note that in
  44909. // order to get all numeric fields that were incremented/decremented, call
  44910. // AddedFields().
  44911. func (m *WpChatroomMutation) Fields() []string {
  44912. fields := make([]string, 0, 9)
  44913. if m.created_at != nil {
  44914. fields = append(fields, wpchatroom.FieldCreatedAt)
  44915. }
  44916. if m.updated_at != nil {
  44917. fields = append(fields, wpchatroom.FieldUpdatedAt)
  44918. }
  44919. if m.status != nil {
  44920. fields = append(fields, wpchatroom.FieldStatus)
  44921. }
  44922. if m.wx_wxid != nil {
  44923. fields = append(fields, wpchatroom.FieldWxWxid)
  44924. }
  44925. if m.chatroom_id != nil {
  44926. fields = append(fields, wpchatroom.FieldChatroomID)
  44927. }
  44928. if m.nickname != nil {
  44929. fields = append(fields, wpchatroom.FieldNickname)
  44930. }
  44931. if m.owner != nil {
  44932. fields = append(fields, wpchatroom.FieldOwner)
  44933. }
  44934. if m.avatar != nil {
  44935. fields = append(fields, wpchatroom.FieldAvatar)
  44936. }
  44937. if m.member_list != nil {
  44938. fields = append(fields, wpchatroom.FieldMemberList)
  44939. }
  44940. return fields
  44941. }
  44942. // Field returns the value of a field with the given name. The second boolean
  44943. // return value indicates that this field was not set, or was not defined in the
  44944. // schema.
  44945. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  44946. switch name {
  44947. case wpchatroom.FieldCreatedAt:
  44948. return m.CreatedAt()
  44949. case wpchatroom.FieldUpdatedAt:
  44950. return m.UpdatedAt()
  44951. case wpchatroom.FieldStatus:
  44952. return m.Status()
  44953. case wpchatroom.FieldWxWxid:
  44954. return m.WxWxid()
  44955. case wpchatroom.FieldChatroomID:
  44956. return m.ChatroomID()
  44957. case wpchatroom.FieldNickname:
  44958. return m.Nickname()
  44959. case wpchatroom.FieldOwner:
  44960. return m.Owner()
  44961. case wpchatroom.FieldAvatar:
  44962. return m.Avatar()
  44963. case wpchatroom.FieldMemberList:
  44964. return m.MemberList()
  44965. }
  44966. return nil, false
  44967. }
  44968. // OldField returns the old value of the field from the database. An error is
  44969. // returned if the mutation operation is not UpdateOne, or the query to the
  44970. // database failed.
  44971. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  44972. switch name {
  44973. case wpchatroom.FieldCreatedAt:
  44974. return m.OldCreatedAt(ctx)
  44975. case wpchatroom.FieldUpdatedAt:
  44976. return m.OldUpdatedAt(ctx)
  44977. case wpchatroom.FieldStatus:
  44978. return m.OldStatus(ctx)
  44979. case wpchatroom.FieldWxWxid:
  44980. return m.OldWxWxid(ctx)
  44981. case wpchatroom.FieldChatroomID:
  44982. return m.OldChatroomID(ctx)
  44983. case wpchatroom.FieldNickname:
  44984. return m.OldNickname(ctx)
  44985. case wpchatroom.FieldOwner:
  44986. return m.OldOwner(ctx)
  44987. case wpchatroom.FieldAvatar:
  44988. return m.OldAvatar(ctx)
  44989. case wpchatroom.FieldMemberList:
  44990. return m.OldMemberList(ctx)
  44991. }
  44992. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  44993. }
  44994. // SetField sets the value of a field with the given name. It returns an error if
  44995. // the field is not defined in the schema, or if the type mismatched the field
  44996. // type.
  44997. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  44998. switch name {
  44999. case wpchatroom.FieldCreatedAt:
  45000. v, ok := value.(time.Time)
  45001. if !ok {
  45002. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45003. }
  45004. m.SetCreatedAt(v)
  45005. return nil
  45006. case wpchatroom.FieldUpdatedAt:
  45007. v, ok := value.(time.Time)
  45008. if !ok {
  45009. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45010. }
  45011. m.SetUpdatedAt(v)
  45012. return nil
  45013. case wpchatroom.FieldStatus:
  45014. v, ok := value.(uint8)
  45015. if !ok {
  45016. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45017. }
  45018. m.SetStatus(v)
  45019. return nil
  45020. case wpchatroom.FieldWxWxid:
  45021. v, ok := value.(string)
  45022. if !ok {
  45023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45024. }
  45025. m.SetWxWxid(v)
  45026. return nil
  45027. case wpchatroom.FieldChatroomID:
  45028. v, ok := value.(string)
  45029. if !ok {
  45030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45031. }
  45032. m.SetChatroomID(v)
  45033. return nil
  45034. case wpchatroom.FieldNickname:
  45035. v, ok := value.(string)
  45036. if !ok {
  45037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45038. }
  45039. m.SetNickname(v)
  45040. return nil
  45041. case wpchatroom.FieldOwner:
  45042. v, ok := value.(string)
  45043. if !ok {
  45044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45045. }
  45046. m.SetOwner(v)
  45047. return nil
  45048. case wpchatroom.FieldAvatar:
  45049. v, ok := value.(string)
  45050. if !ok {
  45051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45052. }
  45053. m.SetAvatar(v)
  45054. return nil
  45055. case wpchatroom.FieldMemberList:
  45056. v, ok := value.([]string)
  45057. if !ok {
  45058. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45059. }
  45060. m.SetMemberList(v)
  45061. return nil
  45062. }
  45063. return fmt.Errorf("unknown WpChatroom field %s", name)
  45064. }
  45065. // AddedFields returns all numeric fields that were incremented/decremented during
  45066. // this mutation.
  45067. func (m *WpChatroomMutation) AddedFields() []string {
  45068. var fields []string
  45069. if m.addstatus != nil {
  45070. fields = append(fields, wpchatroom.FieldStatus)
  45071. }
  45072. return fields
  45073. }
  45074. // AddedField returns the numeric value that was incremented/decremented on a field
  45075. // with the given name. The second boolean return value indicates that this field
  45076. // was not set, or was not defined in the schema.
  45077. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  45078. switch name {
  45079. case wpchatroom.FieldStatus:
  45080. return m.AddedStatus()
  45081. }
  45082. return nil, false
  45083. }
  45084. // AddField adds the value to the field with the given name. It returns an error if
  45085. // the field is not defined in the schema, or if the type mismatched the field
  45086. // type.
  45087. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  45088. switch name {
  45089. case wpchatroom.FieldStatus:
  45090. v, ok := value.(int8)
  45091. if !ok {
  45092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45093. }
  45094. m.AddStatus(v)
  45095. return nil
  45096. }
  45097. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  45098. }
  45099. // ClearedFields returns all nullable fields that were cleared during this
  45100. // mutation.
  45101. func (m *WpChatroomMutation) ClearedFields() []string {
  45102. var fields []string
  45103. if m.FieldCleared(wpchatroom.FieldStatus) {
  45104. fields = append(fields, wpchatroom.FieldStatus)
  45105. }
  45106. return fields
  45107. }
  45108. // FieldCleared returns a boolean indicating if a field with the given name was
  45109. // cleared in this mutation.
  45110. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  45111. _, ok := m.clearedFields[name]
  45112. return ok
  45113. }
  45114. // ClearField clears the value of the field with the given name. It returns an
  45115. // error if the field is not defined in the schema.
  45116. func (m *WpChatroomMutation) ClearField(name string) error {
  45117. switch name {
  45118. case wpchatroom.FieldStatus:
  45119. m.ClearStatus()
  45120. return nil
  45121. }
  45122. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  45123. }
  45124. // ResetField resets all changes in the mutation for the field with the given name.
  45125. // It returns an error if the field is not defined in the schema.
  45126. func (m *WpChatroomMutation) ResetField(name string) error {
  45127. switch name {
  45128. case wpchatroom.FieldCreatedAt:
  45129. m.ResetCreatedAt()
  45130. return nil
  45131. case wpchatroom.FieldUpdatedAt:
  45132. m.ResetUpdatedAt()
  45133. return nil
  45134. case wpchatroom.FieldStatus:
  45135. m.ResetStatus()
  45136. return nil
  45137. case wpchatroom.FieldWxWxid:
  45138. m.ResetWxWxid()
  45139. return nil
  45140. case wpchatroom.FieldChatroomID:
  45141. m.ResetChatroomID()
  45142. return nil
  45143. case wpchatroom.FieldNickname:
  45144. m.ResetNickname()
  45145. return nil
  45146. case wpchatroom.FieldOwner:
  45147. m.ResetOwner()
  45148. return nil
  45149. case wpchatroom.FieldAvatar:
  45150. m.ResetAvatar()
  45151. return nil
  45152. case wpchatroom.FieldMemberList:
  45153. m.ResetMemberList()
  45154. return nil
  45155. }
  45156. return fmt.Errorf("unknown WpChatroom field %s", name)
  45157. }
  45158. // AddedEdges returns all edge names that were set/added in this mutation.
  45159. func (m *WpChatroomMutation) AddedEdges() []string {
  45160. edges := make([]string, 0, 0)
  45161. return edges
  45162. }
  45163. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  45164. // name in this mutation.
  45165. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  45166. return nil
  45167. }
  45168. // RemovedEdges returns all edge names that were removed in this mutation.
  45169. func (m *WpChatroomMutation) RemovedEdges() []string {
  45170. edges := make([]string, 0, 0)
  45171. return edges
  45172. }
  45173. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  45174. // the given name in this mutation.
  45175. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  45176. return nil
  45177. }
  45178. // ClearedEdges returns all edge names that were cleared in this mutation.
  45179. func (m *WpChatroomMutation) ClearedEdges() []string {
  45180. edges := make([]string, 0, 0)
  45181. return edges
  45182. }
  45183. // EdgeCleared returns a boolean which indicates if the edge with the given name
  45184. // was cleared in this mutation.
  45185. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  45186. return false
  45187. }
  45188. // ClearEdge clears the value of the edge with the given name. It returns an error
  45189. // if that edge is not defined in the schema.
  45190. func (m *WpChatroomMutation) ClearEdge(name string) error {
  45191. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  45192. }
  45193. // ResetEdge resets all changes to the edge with the given name in this mutation.
  45194. // It returns an error if the edge is not defined in the schema.
  45195. func (m *WpChatroomMutation) ResetEdge(name string) error {
  45196. return fmt.Errorf("unknown WpChatroom edge %s", name)
  45197. }
  45198. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  45199. type WpChatroomMemberMutation struct {
  45200. config
  45201. op Op
  45202. typ string
  45203. id *uint64
  45204. created_at *time.Time
  45205. updated_at *time.Time
  45206. status *uint8
  45207. addstatus *int8
  45208. wx_wxid *string
  45209. wxid *string
  45210. nickname *string
  45211. avatar *string
  45212. clearedFields map[string]struct{}
  45213. done bool
  45214. oldValue func(context.Context) (*WpChatroomMember, error)
  45215. predicates []predicate.WpChatroomMember
  45216. }
  45217. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  45218. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  45219. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  45220. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  45221. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  45222. m := &WpChatroomMemberMutation{
  45223. config: c,
  45224. op: op,
  45225. typ: TypeWpChatroomMember,
  45226. clearedFields: make(map[string]struct{}),
  45227. }
  45228. for _, opt := range opts {
  45229. opt(m)
  45230. }
  45231. return m
  45232. }
  45233. // withWpChatroomMemberID sets the ID field of the mutation.
  45234. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  45235. return func(m *WpChatroomMemberMutation) {
  45236. var (
  45237. err error
  45238. once sync.Once
  45239. value *WpChatroomMember
  45240. )
  45241. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  45242. once.Do(func() {
  45243. if m.done {
  45244. err = errors.New("querying old values post mutation is not allowed")
  45245. } else {
  45246. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  45247. }
  45248. })
  45249. return value, err
  45250. }
  45251. m.id = &id
  45252. }
  45253. }
  45254. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  45255. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  45256. return func(m *WpChatroomMemberMutation) {
  45257. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  45258. return node, nil
  45259. }
  45260. m.id = &node.ID
  45261. }
  45262. }
  45263. // Client returns a new `ent.Client` from the mutation. If the mutation was
  45264. // executed in a transaction (ent.Tx), a transactional client is returned.
  45265. func (m WpChatroomMemberMutation) Client() *Client {
  45266. client := &Client{config: m.config}
  45267. client.init()
  45268. return client
  45269. }
  45270. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  45271. // it returns an error otherwise.
  45272. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  45273. if _, ok := m.driver.(*txDriver); !ok {
  45274. return nil, errors.New("ent: mutation is not running in a transaction")
  45275. }
  45276. tx := &Tx{config: m.config}
  45277. tx.init()
  45278. return tx, nil
  45279. }
  45280. // SetID sets the value of the id field. Note that this
  45281. // operation is only accepted on creation of WpChatroomMember entities.
  45282. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  45283. m.id = &id
  45284. }
  45285. // ID returns the ID value in the mutation. Note that the ID is only available
  45286. // if it was provided to the builder or after it was returned from the database.
  45287. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  45288. if m.id == nil {
  45289. return
  45290. }
  45291. return *m.id, true
  45292. }
  45293. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  45294. // That means, if the mutation is applied within a transaction with an isolation level such
  45295. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  45296. // or updated by the mutation.
  45297. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  45298. switch {
  45299. case m.op.Is(OpUpdateOne | OpDeleteOne):
  45300. id, exists := m.ID()
  45301. if exists {
  45302. return []uint64{id}, nil
  45303. }
  45304. fallthrough
  45305. case m.op.Is(OpUpdate | OpDelete):
  45306. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  45307. default:
  45308. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  45309. }
  45310. }
  45311. // SetCreatedAt sets the "created_at" field.
  45312. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  45313. m.created_at = &t
  45314. }
  45315. // CreatedAt returns the value of the "created_at" field in the mutation.
  45316. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  45317. v := m.created_at
  45318. if v == nil {
  45319. return
  45320. }
  45321. return *v, true
  45322. }
  45323. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  45324. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  45325. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45326. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  45327. if !m.op.Is(OpUpdateOne) {
  45328. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  45329. }
  45330. if m.id == nil || m.oldValue == nil {
  45331. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  45332. }
  45333. oldValue, err := m.oldValue(ctx)
  45334. if err != nil {
  45335. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  45336. }
  45337. return oldValue.CreatedAt, nil
  45338. }
  45339. // ResetCreatedAt resets all changes to the "created_at" field.
  45340. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  45341. m.created_at = nil
  45342. }
  45343. // SetUpdatedAt sets the "updated_at" field.
  45344. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  45345. m.updated_at = &t
  45346. }
  45347. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  45348. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  45349. v := m.updated_at
  45350. if v == nil {
  45351. return
  45352. }
  45353. return *v, true
  45354. }
  45355. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  45356. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  45357. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45358. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  45359. if !m.op.Is(OpUpdateOne) {
  45360. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  45361. }
  45362. if m.id == nil || m.oldValue == nil {
  45363. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  45364. }
  45365. oldValue, err := m.oldValue(ctx)
  45366. if err != nil {
  45367. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  45368. }
  45369. return oldValue.UpdatedAt, nil
  45370. }
  45371. // ResetUpdatedAt resets all changes to the "updated_at" field.
  45372. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  45373. m.updated_at = nil
  45374. }
  45375. // SetStatus sets the "status" field.
  45376. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  45377. m.status = &u
  45378. m.addstatus = nil
  45379. }
  45380. // Status returns the value of the "status" field in the mutation.
  45381. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  45382. v := m.status
  45383. if v == nil {
  45384. return
  45385. }
  45386. return *v, true
  45387. }
  45388. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  45389. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  45390. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45391. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  45392. if !m.op.Is(OpUpdateOne) {
  45393. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  45394. }
  45395. if m.id == nil || m.oldValue == nil {
  45396. return v, errors.New("OldStatus requires an ID field in the mutation")
  45397. }
  45398. oldValue, err := m.oldValue(ctx)
  45399. if err != nil {
  45400. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  45401. }
  45402. return oldValue.Status, nil
  45403. }
  45404. // AddStatus adds u to the "status" field.
  45405. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  45406. if m.addstatus != nil {
  45407. *m.addstatus += u
  45408. } else {
  45409. m.addstatus = &u
  45410. }
  45411. }
  45412. // AddedStatus returns the value that was added to the "status" field in this mutation.
  45413. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  45414. v := m.addstatus
  45415. if v == nil {
  45416. return
  45417. }
  45418. return *v, true
  45419. }
  45420. // ClearStatus clears the value of the "status" field.
  45421. func (m *WpChatroomMemberMutation) ClearStatus() {
  45422. m.status = nil
  45423. m.addstatus = nil
  45424. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  45425. }
  45426. // StatusCleared returns if the "status" field was cleared in this mutation.
  45427. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  45428. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  45429. return ok
  45430. }
  45431. // ResetStatus resets all changes to the "status" field.
  45432. func (m *WpChatroomMemberMutation) ResetStatus() {
  45433. m.status = nil
  45434. m.addstatus = nil
  45435. delete(m.clearedFields, wpchatroommember.FieldStatus)
  45436. }
  45437. // SetWxWxid sets the "wx_wxid" field.
  45438. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  45439. m.wx_wxid = &s
  45440. }
  45441. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  45442. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  45443. v := m.wx_wxid
  45444. if v == nil {
  45445. return
  45446. }
  45447. return *v, true
  45448. }
  45449. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  45450. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  45451. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45452. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  45453. if !m.op.Is(OpUpdateOne) {
  45454. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  45455. }
  45456. if m.id == nil || m.oldValue == nil {
  45457. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  45458. }
  45459. oldValue, err := m.oldValue(ctx)
  45460. if err != nil {
  45461. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  45462. }
  45463. return oldValue.WxWxid, nil
  45464. }
  45465. // ResetWxWxid resets all changes to the "wx_wxid" field.
  45466. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  45467. m.wx_wxid = nil
  45468. }
  45469. // SetWxid sets the "wxid" field.
  45470. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  45471. m.wxid = &s
  45472. }
  45473. // Wxid returns the value of the "wxid" field in the mutation.
  45474. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  45475. v := m.wxid
  45476. if v == nil {
  45477. return
  45478. }
  45479. return *v, true
  45480. }
  45481. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  45482. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  45483. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45484. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  45485. if !m.op.Is(OpUpdateOne) {
  45486. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  45487. }
  45488. if m.id == nil || m.oldValue == nil {
  45489. return v, errors.New("OldWxid requires an ID field in the mutation")
  45490. }
  45491. oldValue, err := m.oldValue(ctx)
  45492. if err != nil {
  45493. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  45494. }
  45495. return oldValue.Wxid, nil
  45496. }
  45497. // ResetWxid resets all changes to the "wxid" field.
  45498. func (m *WpChatroomMemberMutation) ResetWxid() {
  45499. m.wxid = nil
  45500. }
  45501. // SetNickname sets the "nickname" field.
  45502. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  45503. m.nickname = &s
  45504. }
  45505. // Nickname returns the value of the "nickname" field in the mutation.
  45506. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  45507. v := m.nickname
  45508. if v == nil {
  45509. return
  45510. }
  45511. return *v, true
  45512. }
  45513. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  45514. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  45515. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45516. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  45517. if !m.op.Is(OpUpdateOne) {
  45518. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  45519. }
  45520. if m.id == nil || m.oldValue == nil {
  45521. return v, errors.New("OldNickname requires an ID field in the mutation")
  45522. }
  45523. oldValue, err := m.oldValue(ctx)
  45524. if err != nil {
  45525. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  45526. }
  45527. return oldValue.Nickname, nil
  45528. }
  45529. // ResetNickname resets all changes to the "nickname" field.
  45530. func (m *WpChatroomMemberMutation) ResetNickname() {
  45531. m.nickname = nil
  45532. }
  45533. // SetAvatar sets the "avatar" field.
  45534. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  45535. m.avatar = &s
  45536. }
  45537. // Avatar returns the value of the "avatar" field in the mutation.
  45538. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  45539. v := m.avatar
  45540. if v == nil {
  45541. return
  45542. }
  45543. return *v, true
  45544. }
  45545. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  45546. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  45547. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45548. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  45549. if !m.op.Is(OpUpdateOne) {
  45550. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  45551. }
  45552. if m.id == nil || m.oldValue == nil {
  45553. return v, errors.New("OldAvatar requires an ID field in the mutation")
  45554. }
  45555. oldValue, err := m.oldValue(ctx)
  45556. if err != nil {
  45557. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  45558. }
  45559. return oldValue.Avatar, nil
  45560. }
  45561. // ResetAvatar resets all changes to the "avatar" field.
  45562. func (m *WpChatroomMemberMutation) ResetAvatar() {
  45563. m.avatar = nil
  45564. }
  45565. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  45566. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  45567. m.predicates = append(m.predicates, ps...)
  45568. }
  45569. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  45570. // users can use type-assertion to append predicates that do not depend on any generated package.
  45571. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  45572. p := make([]predicate.WpChatroomMember, len(ps))
  45573. for i := range ps {
  45574. p[i] = ps[i]
  45575. }
  45576. m.Where(p...)
  45577. }
  45578. // Op returns the operation name.
  45579. func (m *WpChatroomMemberMutation) Op() Op {
  45580. return m.op
  45581. }
  45582. // SetOp allows setting the mutation operation.
  45583. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  45584. m.op = op
  45585. }
  45586. // Type returns the node type of this mutation (WpChatroomMember).
  45587. func (m *WpChatroomMemberMutation) Type() string {
  45588. return m.typ
  45589. }
  45590. // Fields returns all fields that were changed during this mutation. Note that in
  45591. // order to get all numeric fields that were incremented/decremented, call
  45592. // AddedFields().
  45593. func (m *WpChatroomMemberMutation) Fields() []string {
  45594. fields := make([]string, 0, 7)
  45595. if m.created_at != nil {
  45596. fields = append(fields, wpchatroommember.FieldCreatedAt)
  45597. }
  45598. if m.updated_at != nil {
  45599. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  45600. }
  45601. if m.status != nil {
  45602. fields = append(fields, wpchatroommember.FieldStatus)
  45603. }
  45604. if m.wx_wxid != nil {
  45605. fields = append(fields, wpchatroommember.FieldWxWxid)
  45606. }
  45607. if m.wxid != nil {
  45608. fields = append(fields, wpchatroommember.FieldWxid)
  45609. }
  45610. if m.nickname != nil {
  45611. fields = append(fields, wpchatroommember.FieldNickname)
  45612. }
  45613. if m.avatar != nil {
  45614. fields = append(fields, wpchatroommember.FieldAvatar)
  45615. }
  45616. return fields
  45617. }
  45618. // Field returns the value of a field with the given name. The second boolean
  45619. // return value indicates that this field was not set, or was not defined in the
  45620. // schema.
  45621. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  45622. switch name {
  45623. case wpchatroommember.FieldCreatedAt:
  45624. return m.CreatedAt()
  45625. case wpchatroommember.FieldUpdatedAt:
  45626. return m.UpdatedAt()
  45627. case wpchatroommember.FieldStatus:
  45628. return m.Status()
  45629. case wpchatroommember.FieldWxWxid:
  45630. return m.WxWxid()
  45631. case wpchatroommember.FieldWxid:
  45632. return m.Wxid()
  45633. case wpchatroommember.FieldNickname:
  45634. return m.Nickname()
  45635. case wpchatroommember.FieldAvatar:
  45636. return m.Avatar()
  45637. }
  45638. return nil, false
  45639. }
  45640. // OldField returns the old value of the field from the database. An error is
  45641. // returned if the mutation operation is not UpdateOne, or the query to the
  45642. // database failed.
  45643. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  45644. switch name {
  45645. case wpchatroommember.FieldCreatedAt:
  45646. return m.OldCreatedAt(ctx)
  45647. case wpchatroommember.FieldUpdatedAt:
  45648. return m.OldUpdatedAt(ctx)
  45649. case wpchatroommember.FieldStatus:
  45650. return m.OldStatus(ctx)
  45651. case wpchatroommember.FieldWxWxid:
  45652. return m.OldWxWxid(ctx)
  45653. case wpchatroommember.FieldWxid:
  45654. return m.OldWxid(ctx)
  45655. case wpchatroommember.FieldNickname:
  45656. return m.OldNickname(ctx)
  45657. case wpchatroommember.FieldAvatar:
  45658. return m.OldAvatar(ctx)
  45659. }
  45660. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  45661. }
  45662. // SetField sets the value of a field with the given name. It returns an error if
  45663. // the field is not defined in the schema, or if the type mismatched the field
  45664. // type.
  45665. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  45666. switch name {
  45667. case wpchatroommember.FieldCreatedAt:
  45668. v, ok := value.(time.Time)
  45669. if !ok {
  45670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45671. }
  45672. m.SetCreatedAt(v)
  45673. return nil
  45674. case wpchatroommember.FieldUpdatedAt:
  45675. v, ok := value.(time.Time)
  45676. if !ok {
  45677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45678. }
  45679. m.SetUpdatedAt(v)
  45680. return nil
  45681. case wpchatroommember.FieldStatus:
  45682. v, ok := value.(uint8)
  45683. if !ok {
  45684. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45685. }
  45686. m.SetStatus(v)
  45687. return nil
  45688. case wpchatroommember.FieldWxWxid:
  45689. v, ok := value.(string)
  45690. if !ok {
  45691. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45692. }
  45693. m.SetWxWxid(v)
  45694. return nil
  45695. case wpchatroommember.FieldWxid:
  45696. v, ok := value.(string)
  45697. if !ok {
  45698. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45699. }
  45700. m.SetWxid(v)
  45701. return nil
  45702. case wpchatroommember.FieldNickname:
  45703. v, ok := value.(string)
  45704. if !ok {
  45705. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45706. }
  45707. m.SetNickname(v)
  45708. return nil
  45709. case wpchatroommember.FieldAvatar:
  45710. v, ok := value.(string)
  45711. if !ok {
  45712. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45713. }
  45714. m.SetAvatar(v)
  45715. return nil
  45716. }
  45717. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  45718. }
  45719. // AddedFields returns all numeric fields that were incremented/decremented during
  45720. // this mutation.
  45721. func (m *WpChatroomMemberMutation) AddedFields() []string {
  45722. var fields []string
  45723. if m.addstatus != nil {
  45724. fields = append(fields, wpchatroommember.FieldStatus)
  45725. }
  45726. return fields
  45727. }
  45728. // AddedField returns the numeric value that was incremented/decremented on a field
  45729. // with the given name. The second boolean return value indicates that this field
  45730. // was not set, or was not defined in the schema.
  45731. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  45732. switch name {
  45733. case wpchatroommember.FieldStatus:
  45734. return m.AddedStatus()
  45735. }
  45736. return nil, false
  45737. }
  45738. // AddField adds the value to the field with the given name. It returns an error if
  45739. // the field is not defined in the schema, or if the type mismatched the field
  45740. // type.
  45741. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  45742. switch name {
  45743. case wpchatroommember.FieldStatus:
  45744. v, ok := value.(int8)
  45745. if !ok {
  45746. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45747. }
  45748. m.AddStatus(v)
  45749. return nil
  45750. }
  45751. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  45752. }
  45753. // ClearedFields returns all nullable fields that were cleared during this
  45754. // mutation.
  45755. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  45756. var fields []string
  45757. if m.FieldCleared(wpchatroommember.FieldStatus) {
  45758. fields = append(fields, wpchatroommember.FieldStatus)
  45759. }
  45760. return fields
  45761. }
  45762. // FieldCleared returns a boolean indicating if a field with the given name was
  45763. // cleared in this mutation.
  45764. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  45765. _, ok := m.clearedFields[name]
  45766. return ok
  45767. }
  45768. // ClearField clears the value of the field with the given name. It returns an
  45769. // error if the field is not defined in the schema.
  45770. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  45771. switch name {
  45772. case wpchatroommember.FieldStatus:
  45773. m.ClearStatus()
  45774. return nil
  45775. }
  45776. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  45777. }
  45778. // ResetField resets all changes in the mutation for the field with the given name.
  45779. // It returns an error if the field is not defined in the schema.
  45780. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  45781. switch name {
  45782. case wpchatroommember.FieldCreatedAt:
  45783. m.ResetCreatedAt()
  45784. return nil
  45785. case wpchatroommember.FieldUpdatedAt:
  45786. m.ResetUpdatedAt()
  45787. return nil
  45788. case wpchatroommember.FieldStatus:
  45789. m.ResetStatus()
  45790. return nil
  45791. case wpchatroommember.FieldWxWxid:
  45792. m.ResetWxWxid()
  45793. return nil
  45794. case wpchatroommember.FieldWxid:
  45795. m.ResetWxid()
  45796. return nil
  45797. case wpchatroommember.FieldNickname:
  45798. m.ResetNickname()
  45799. return nil
  45800. case wpchatroommember.FieldAvatar:
  45801. m.ResetAvatar()
  45802. return nil
  45803. }
  45804. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  45805. }
  45806. // AddedEdges returns all edge names that were set/added in this mutation.
  45807. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  45808. edges := make([]string, 0, 0)
  45809. return edges
  45810. }
  45811. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  45812. // name in this mutation.
  45813. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  45814. return nil
  45815. }
  45816. // RemovedEdges returns all edge names that were removed in this mutation.
  45817. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  45818. edges := make([]string, 0, 0)
  45819. return edges
  45820. }
  45821. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  45822. // the given name in this mutation.
  45823. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  45824. return nil
  45825. }
  45826. // ClearedEdges returns all edge names that were cleared in this mutation.
  45827. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  45828. edges := make([]string, 0, 0)
  45829. return edges
  45830. }
  45831. // EdgeCleared returns a boolean which indicates if the edge with the given name
  45832. // was cleared in this mutation.
  45833. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  45834. return false
  45835. }
  45836. // ClearEdge clears the value of the edge with the given name. It returns an error
  45837. // if that edge is not defined in the schema.
  45838. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  45839. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  45840. }
  45841. // ResetEdge resets all changes to the edge with the given name in this mutation.
  45842. // It returns an error if the edge is not defined in the schema.
  45843. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  45844. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  45845. }
  45846. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  45847. type WxMutation struct {
  45848. config
  45849. op Op
  45850. typ string
  45851. id *uint64
  45852. created_at *time.Time
  45853. updated_at *time.Time
  45854. status *uint8
  45855. addstatus *int8
  45856. deleted_at *time.Time
  45857. port *string
  45858. process_id *string
  45859. callback *string
  45860. wxid *string
  45861. account *string
  45862. nickname *string
  45863. tel *string
  45864. head_big *string
  45865. organization_id *uint64
  45866. addorganization_id *int64
  45867. api_base *string
  45868. api_key *string
  45869. allow_list *[]string
  45870. appendallow_list []string
  45871. group_allow_list *[]string
  45872. appendgroup_allow_list []string
  45873. block_list *[]string
  45874. appendblock_list []string
  45875. group_block_list *[]string
  45876. appendgroup_block_list []string
  45877. ctype *uint64
  45878. addctype *int64
  45879. clearedFields map[string]struct{}
  45880. server *uint64
  45881. clearedserver bool
  45882. agent *uint64
  45883. clearedagent bool
  45884. done bool
  45885. oldValue func(context.Context) (*Wx, error)
  45886. predicates []predicate.Wx
  45887. }
  45888. var _ ent.Mutation = (*WxMutation)(nil)
  45889. // wxOption allows management of the mutation configuration using functional options.
  45890. type wxOption func(*WxMutation)
  45891. // newWxMutation creates new mutation for the Wx entity.
  45892. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  45893. m := &WxMutation{
  45894. config: c,
  45895. op: op,
  45896. typ: TypeWx,
  45897. clearedFields: make(map[string]struct{}),
  45898. }
  45899. for _, opt := range opts {
  45900. opt(m)
  45901. }
  45902. return m
  45903. }
  45904. // withWxID sets the ID field of the mutation.
  45905. func withWxID(id uint64) wxOption {
  45906. return func(m *WxMutation) {
  45907. var (
  45908. err error
  45909. once sync.Once
  45910. value *Wx
  45911. )
  45912. m.oldValue = func(ctx context.Context) (*Wx, error) {
  45913. once.Do(func() {
  45914. if m.done {
  45915. err = errors.New("querying old values post mutation is not allowed")
  45916. } else {
  45917. value, err = m.Client().Wx.Get(ctx, id)
  45918. }
  45919. })
  45920. return value, err
  45921. }
  45922. m.id = &id
  45923. }
  45924. }
  45925. // withWx sets the old Wx of the mutation.
  45926. func withWx(node *Wx) wxOption {
  45927. return func(m *WxMutation) {
  45928. m.oldValue = func(context.Context) (*Wx, error) {
  45929. return node, nil
  45930. }
  45931. m.id = &node.ID
  45932. }
  45933. }
  45934. // Client returns a new `ent.Client` from the mutation. If the mutation was
  45935. // executed in a transaction (ent.Tx), a transactional client is returned.
  45936. func (m WxMutation) Client() *Client {
  45937. client := &Client{config: m.config}
  45938. client.init()
  45939. return client
  45940. }
  45941. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  45942. // it returns an error otherwise.
  45943. func (m WxMutation) Tx() (*Tx, error) {
  45944. if _, ok := m.driver.(*txDriver); !ok {
  45945. return nil, errors.New("ent: mutation is not running in a transaction")
  45946. }
  45947. tx := &Tx{config: m.config}
  45948. tx.init()
  45949. return tx, nil
  45950. }
  45951. // SetID sets the value of the id field. Note that this
  45952. // operation is only accepted on creation of Wx entities.
  45953. func (m *WxMutation) SetID(id uint64) {
  45954. m.id = &id
  45955. }
  45956. // ID returns the ID value in the mutation. Note that the ID is only available
  45957. // if it was provided to the builder or after it was returned from the database.
  45958. func (m *WxMutation) ID() (id uint64, exists bool) {
  45959. if m.id == nil {
  45960. return
  45961. }
  45962. return *m.id, true
  45963. }
  45964. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  45965. // That means, if the mutation is applied within a transaction with an isolation level such
  45966. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  45967. // or updated by the mutation.
  45968. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  45969. switch {
  45970. case m.op.Is(OpUpdateOne | OpDeleteOne):
  45971. id, exists := m.ID()
  45972. if exists {
  45973. return []uint64{id}, nil
  45974. }
  45975. fallthrough
  45976. case m.op.Is(OpUpdate | OpDelete):
  45977. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  45978. default:
  45979. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  45980. }
  45981. }
  45982. // SetCreatedAt sets the "created_at" field.
  45983. func (m *WxMutation) SetCreatedAt(t time.Time) {
  45984. m.created_at = &t
  45985. }
  45986. // CreatedAt returns the value of the "created_at" field in the mutation.
  45987. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  45988. v := m.created_at
  45989. if v == nil {
  45990. return
  45991. }
  45992. return *v, true
  45993. }
  45994. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  45995. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45996. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45997. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  45998. if !m.op.Is(OpUpdateOne) {
  45999. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  46000. }
  46001. if m.id == nil || m.oldValue == nil {
  46002. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  46003. }
  46004. oldValue, err := m.oldValue(ctx)
  46005. if err != nil {
  46006. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  46007. }
  46008. return oldValue.CreatedAt, nil
  46009. }
  46010. // ResetCreatedAt resets all changes to the "created_at" field.
  46011. func (m *WxMutation) ResetCreatedAt() {
  46012. m.created_at = nil
  46013. }
  46014. // SetUpdatedAt sets the "updated_at" field.
  46015. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  46016. m.updated_at = &t
  46017. }
  46018. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  46019. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  46020. v := m.updated_at
  46021. if v == nil {
  46022. return
  46023. }
  46024. return *v, true
  46025. }
  46026. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  46027. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46028. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46029. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  46030. if !m.op.Is(OpUpdateOne) {
  46031. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  46032. }
  46033. if m.id == nil || m.oldValue == nil {
  46034. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  46035. }
  46036. oldValue, err := m.oldValue(ctx)
  46037. if err != nil {
  46038. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  46039. }
  46040. return oldValue.UpdatedAt, nil
  46041. }
  46042. // ResetUpdatedAt resets all changes to the "updated_at" field.
  46043. func (m *WxMutation) ResetUpdatedAt() {
  46044. m.updated_at = nil
  46045. }
  46046. // SetStatus sets the "status" field.
  46047. func (m *WxMutation) SetStatus(u uint8) {
  46048. m.status = &u
  46049. m.addstatus = nil
  46050. }
  46051. // Status returns the value of the "status" field in the mutation.
  46052. func (m *WxMutation) Status() (r uint8, exists bool) {
  46053. v := m.status
  46054. if v == nil {
  46055. return
  46056. }
  46057. return *v, true
  46058. }
  46059. // OldStatus returns the old "status" field's value of the Wx entity.
  46060. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46061. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46062. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  46063. if !m.op.Is(OpUpdateOne) {
  46064. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  46065. }
  46066. if m.id == nil || m.oldValue == nil {
  46067. return v, errors.New("OldStatus requires an ID field in the mutation")
  46068. }
  46069. oldValue, err := m.oldValue(ctx)
  46070. if err != nil {
  46071. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  46072. }
  46073. return oldValue.Status, nil
  46074. }
  46075. // AddStatus adds u to the "status" field.
  46076. func (m *WxMutation) AddStatus(u int8) {
  46077. if m.addstatus != nil {
  46078. *m.addstatus += u
  46079. } else {
  46080. m.addstatus = &u
  46081. }
  46082. }
  46083. // AddedStatus returns the value that was added to the "status" field in this mutation.
  46084. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  46085. v := m.addstatus
  46086. if v == nil {
  46087. return
  46088. }
  46089. return *v, true
  46090. }
  46091. // ClearStatus clears the value of the "status" field.
  46092. func (m *WxMutation) ClearStatus() {
  46093. m.status = nil
  46094. m.addstatus = nil
  46095. m.clearedFields[wx.FieldStatus] = struct{}{}
  46096. }
  46097. // StatusCleared returns if the "status" field was cleared in this mutation.
  46098. func (m *WxMutation) StatusCleared() bool {
  46099. _, ok := m.clearedFields[wx.FieldStatus]
  46100. return ok
  46101. }
  46102. // ResetStatus resets all changes to the "status" field.
  46103. func (m *WxMutation) ResetStatus() {
  46104. m.status = nil
  46105. m.addstatus = nil
  46106. delete(m.clearedFields, wx.FieldStatus)
  46107. }
  46108. // SetDeletedAt sets the "deleted_at" field.
  46109. func (m *WxMutation) SetDeletedAt(t time.Time) {
  46110. m.deleted_at = &t
  46111. }
  46112. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  46113. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  46114. v := m.deleted_at
  46115. if v == nil {
  46116. return
  46117. }
  46118. return *v, true
  46119. }
  46120. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  46121. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46122. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46123. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  46124. if !m.op.Is(OpUpdateOne) {
  46125. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  46126. }
  46127. if m.id == nil || m.oldValue == nil {
  46128. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  46129. }
  46130. oldValue, err := m.oldValue(ctx)
  46131. if err != nil {
  46132. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  46133. }
  46134. return oldValue.DeletedAt, nil
  46135. }
  46136. // ClearDeletedAt clears the value of the "deleted_at" field.
  46137. func (m *WxMutation) ClearDeletedAt() {
  46138. m.deleted_at = nil
  46139. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  46140. }
  46141. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  46142. func (m *WxMutation) DeletedAtCleared() bool {
  46143. _, ok := m.clearedFields[wx.FieldDeletedAt]
  46144. return ok
  46145. }
  46146. // ResetDeletedAt resets all changes to the "deleted_at" field.
  46147. func (m *WxMutation) ResetDeletedAt() {
  46148. m.deleted_at = nil
  46149. delete(m.clearedFields, wx.FieldDeletedAt)
  46150. }
  46151. // SetServerID sets the "server_id" field.
  46152. func (m *WxMutation) SetServerID(u uint64) {
  46153. m.server = &u
  46154. }
  46155. // ServerID returns the value of the "server_id" field in the mutation.
  46156. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  46157. v := m.server
  46158. if v == nil {
  46159. return
  46160. }
  46161. return *v, true
  46162. }
  46163. // OldServerID returns the old "server_id" field's value of the Wx entity.
  46164. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46165. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46166. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  46167. if !m.op.Is(OpUpdateOne) {
  46168. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  46169. }
  46170. if m.id == nil || m.oldValue == nil {
  46171. return v, errors.New("OldServerID requires an ID field in the mutation")
  46172. }
  46173. oldValue, err := m.oldValue(ctx)
  46174. if err != nil {
  46175. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  46176. }
  46177. return oldValue.ServerID, nil
  46178. }
  46179. // ClearServerID clears the value of the "server_id" field.
  46180. func (m *WxMutation) ClearServerID() {
  46181. m.server = nil
  46182. m.clearedFields[wx.FieldServerID] = struct{}{}
  46183. }
  46184. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  46185. func (m *WxMutation) ServerIDCleared() bool {
  46186. _, ok := m.clearedFields[wx.FieldServerID]
  46187. return ok
  46188. }
  46189. // ResetServerID resets all changes to the "server_id" field.
  46190. func (m *WxMutation) ResetServerID() {
  46191. m.server = nil
  46192. delete(m.clearedFields, wx.FieldServerID)
  46193. }
  46194. // SetPort sets the "port" field.
  46195. func (m *WxMutation) SetPort(s string) {
  46196. m.port = &s
  46197. }
  46198. // Port returns the value of the "port" field in the mutation.
  46199. func (m *WxMutation) Port() (r string, exists bool) {
  46200. v := m.port
  46201. if v == nil {
  46202. return
  46203. }
  46204. return *v, true
  46205. }
  46206. // OldPort returns the old "port" field's value of the Wx entity.
  46207. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46208. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46209. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  46210. if !m.op.Is(OpUpdateOne) {
  46211. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  46212. }
  46213. if m.id == nil || m.oldValue == nil {
  46214. return v, errors.New("OldPort requires an ID field in the mutation")
  46215. }
  46216. oldValue, err := m.oldValue(ctx)
  46217. if err != nil {
  46218. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  46219. }
  46220. return oldValue.Port, nil
  46221. }
  46222. // ResetPort resets all changes to the "port" field.
  46223. func (m *WxMutation) ResetPort() {
  46224. m.port = nil
  46225. }
  46226. // SetProcessID sets the "process_id" field.
  46227. func (m *WxMutation) SetProcessID(s string) {
  46228. m.process_id = &s
  46229. }
  46230. // ProcessID returns the value of the "process_id" field in the mutation.
  46231. func (m *WxMutation) ProcessID() (r string, exists bool) {
  46232. v := m.process_id
  46233. if v == nil {
  46234. return
  46235. }
  46236. return *v, true
  46237. }
  46238. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  46239. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46240. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46241. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  46242. if !m.op.Is(OpUpdateOne) {
  46243. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  46244. }
  46245. if m.id == nil || m.oldValue == nil {
  46246. return v, errors.New("OldProcessID requires an ID field in the mutation")
  46247. }
  46248. oldValue, err := m.oldValue(ctx)
  46249. if err != nil {
  46250. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  46251. }
  46252. return oldValue.ProcessID, nil
  46253. }
  46254. // ResetProcessID resets all changes to the "process_id" field.
  46255. func (m *WxMutation) ResetProcessID() {
  46256. m.process_id = nil
  46257. }
  46258. // SetCallback sets the "callback" field.
  46259. func (m *WxMutation) SetCallback(s string) {
  46260. m.callback = &s
  46261. }
  46262. // Callback returns the value of the "callback" field in the mutation.
  46263. func (m *WxMutation) Callback() (r string, exists bool) {
  46264. v := m.callback
  46265. if v == nil {
  46266. return
  46267. }
  46268. return *v, true
  46269. }
  46270. // OldCallback returns the old "callback" field's value of the Wx entity.
  46271. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46272. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46273. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  46274. if !m.op.Is(OpUpdateOne) {
  46275. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  46276. }
  46277. if m.id == nil || m.oldValue == nil {
  46278. return v, errors.New("OldCallback requires an ID field in the mutation")
  46279. }
  46280. oldValue, err := m.oldValue(ctx)
  46281. if err != nil {
  46282. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  46283. }
  46284. return oldValue.Callback, nil
  46285. }
  46286. // ResetCallback resets all changes to the "callback" field.
  46287. func (m *WxMutation) ResetCallback() {
  46288. m.callback = nil
  46289. }
  46290. // SetWxid sets the "wxid" field.
  46291. func (m *WxMutation) SetWxid(s string) {
  46292. m.wxid = &s
  46293. }
  46294. // Wxid returns the value of the "wxid" field in the mutation.
  46295. func (m *WxMutation) Wxid() (r string, exists bool) {
  46296. v := m.wxid
  46297. if v == nil {
  46298. return
  46299. }
  46300. return *v, true
  46301. }
  46302. // OldWxid returns the old "wxid" field's value of the Wx entity.
  46303. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46304. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46305. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  46306. if !m.op.Is(OpUpdateOne) {
  46307. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  46308. }
  46309. if m.id == nil || m.oldValue == nil {
  46310. return v, errors.New("OldWxid requires an ID field in the mutation")
  46311. }
  46312. oldValue, err := m.oldValue(ctx)
  46313. if err != nil {
  46314. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  46315. }
  46316. return oldValue.Wxid, nil
  46317. }
  46318. // ResetWxid resets all changes to the "wxid" field.
  46319. func (m *WxMutation) ResetWxid() {
  46320. m.wxid = nil
  46321. }
  46322. // SetAccount sets the "account" field.
  46323. func (m *WxMutation) SetAccount(s string) {
  46324. m.account = &s
  46325. }
  46326. // Account returns the value of the "account" field in the mutation.
  46327. func (m *WxMutation) Account() (r string, exists bool) {
  46328. v := m.account
  46329. if v == nil {
  46330. return
  46331. }
  46332. return *v, true
  46333. }
  46334. // OldAccount returns the old "account" field's value of the Wx entity.
  46335. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46336. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46337. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  46338. if !m.op.Is(OpUpdateOne) {
  46339. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  46340. }
  46341. if m.id == nil || m.oldValue == nil {
  46342. return v, errors.New("OldAccount requires an ID field in the mutation")
  46343. }
  46344. oldValue, err := m.oldValue(ctx)
  46345. if err != nil {
  46346. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  46347. }
  46348. return oldValue.Account, nil
  46349. }
  46350. // ResetAccount resets all changes to the "account" field.
  46351. func (m *WxMutation) ResetAccount() {
  46352. m.account = nil
  46353. }
  46354. // SetNickname sets the "nickname" field.
  46355. func (m *WxMutation) SetNickname(s string) {
  46356. m.nickname = &s
  46357. }
  46358. // Nickname returns the value of the "nickname" field in the mutation.
  46359. func (m *WxMutation) Nickname() (r string, exists bool) {
  46360. v := m.nickname
  46361. if v == nil {
  46362. return
  46363. }
  46364. return *v, true
  46365. }
  46366. // OldNickname returns the old "nickname" field's value of the Wx entity.
  46367. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46368. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46369. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  46370. if !m.op.Is(OpUpdateOne) {
  46371. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  46372. }
  46373. if m.id == nil || m.oldValue == nil {
  46374. return v, errors.New("OldNickname requires an ID field in the mutation")
  46375. }
  46376. oldValue, err := m.oldValue(ctx)
  46377. if err != nil {
  46378. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  46379. }
  46380. return oldValue.Nickname, nil
  46381. }
  46382. // ResetNickname resets all changes to the "nickname" field.
  46383. func (m *WxMutation) ResetNickname() {
  46384. m.nickname = nil
  46385. }
  46386. // SetTel sets the "tel" field.
  46387. func (m *WxMutation) SetTel(s string) {
  46388. m.tel = &s
  46389. }
  46390. // Tel returns the value of the "tel" field in the mutation.
  46391. func (m *WxMutation) Tel() (r string, exists bool) {
  46392. v := m.tel
  46393. if v == nil {
  46394. return
  46395. }
  46396. return *v, true
  46397. }
  46398. // OldTel returns the old "tel" field's value of the Wx entity.
  46399. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46400. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46401. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  46402. if !m.op.Is(OpUpdateOne) {
  46403. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  46404. }
  46405. if m.id == nil || m.oldValue == nil {
  46406. return v, errors.New("OldTel requires an ID field in the mutation")
  46407. }
  46408. oldValue, err := m.oldValue(ctx)
  46409. if err != nil {
  46410. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  46411. }
  46412. return oldValue.Tel, nil
  46413. }
  46414. // ResetTel resets all changes to the "tel" field.
  46415. func (m *WxMutation) ResetTel() {
  46416. m.tel = nil
  46417. }
  46418. // SetHeadBig sets the "head_big" field.
  46419. func (m *WxMutation) SetHeadBig(s string) {
  46420. m.head_big = &s
  46421. }
  46422. // HeadBig returns the value of the "head_big" field in the mutation.
  46423. func (m *WxMutation) HeadBig() (r string, exists bool) {
  46424. v := m.head_big
  46425. if v == nil {
  46426. return
  46427. }
  46428. return *v, true
  46429. }
  46430. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  46431. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46432. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46433. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  46434. if !m.op.Is(OpUpdateOne) {
  46435. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  46436. }
  46437. if m.id == nil || m.oldValue == nil {
  46438. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  46439. }
  46440. oldValue, err := m.oldValue(ctx)
  46441. if err != nil {
  46442. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  46443. }
  46444. return oldValue.HeadBig, nil
  46445. }
  46446. // ResetHeadBig resets all changes to the "head_big" field.
  46447. func (m *WxMutation) ResetHeadBig() {
  46448. m.head_big = nil
  46449. }
  46450. // SetOrganizationID sets the "organization_id" field.
  46451. func (m *WxMutation) SetOrganizationID(u uint64) {
  46452. m.organization_id = &u
  46453. m.addorganization_id = nil
  46454. }
  46455. // OrganizationID returns the value of the "organization_id" field in the mutation.
  46456. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  46457. v := m.organization_id
  46458. if v == nil {
  46459. return
  46460. }
  46461. return *v, true
  46462. }
  46463. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  46464. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46465. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46466. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  46467. if !m.op.Is(OpUpdateOne) {
  46468. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  46469. }
  46470. if m.id == nil || m.oldValue == nil {
  46471. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  46472. }
  46473. oldValue, err := m.oldValue(ctx)
  46474. if err != nil {
  46475. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  46476. }
  46477. return oldValue.OrganizationID, nil
  46478. }
  46479. // AddOrganizationID adds u to the "organization_id" field.
  46480. func (m *WxMutation) AddOrganizationID(u int64) {
  46481. if m.addorganization_id != nil {
  46482. *m.addorganization_id += u
  46483. } else {
  46484. m.addorganization_id = &u
  46485. }
  46486. }
  46487. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  46488. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  46489. v := m.addorganization_id
  46490. if v == nil {
  46491. return
  46492. }
  46493. return *v, true
  46494. }
  46495. // ClearOrganizationID clears the value of the "organization_id" field.
  46496. func (m *WxMutation) ClearOrganizationID() {
  46497. m.organization_id = nil
  46498. m.addorganization_id = nil
  46499. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  46500. }
  46501. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  46502. func (m *WxMutation) OrganizationIDCleared() bool {
  46503. _, ok := m.clearedFields[wx.FieldOrganizationID]
  46504. return ok
  46505. }
  46506. // ResetOrganizationID resets all changes to the "organization_id" field.
  46507. func (m *WxMutation) ResetOrganizationID() {
  46508. m.organization_id = nil
  46509. m.addorganization_id = nil
  46510. delete(m.clearedFields, wx.FieldOrganizationID)
  46511. }
  46512. // SetAgentID sets the "agent_id" field.
  46513. func (m *WxMutation) SetAgentID(u uint64) {
  46514. m.agent = &u
  46515. }
  46516. // AgentID returns the value of the "agent_id" field in the mutation.
  46517. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  46518. v := m.agent
  46519. if v == nil {
  46520. return
  46521. }
  46522. return *v, true
  46523. }
  46524. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  46525. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46526. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46527. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  46528. if !m.op.Is(OpUpdateOne) {
  46529. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  46530. }
  46531. if m.id == nil || m.oldValue == nil {
  46532. return v, errors.New("OldAgentID requires an ID field in the mutation")
  46533. }
  46534. oldValue, err := m.oldValue(ctx)
  46535. if err != nil {
  46536. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  46537. }
  46538. return oldValue.AgentID, nil
  46539. }
  46540. // ResetAgentID resets all changes to the "agent_id" field.
  46541. func (m *WxMutation) ResetAgentID() {
  46542. m.agent = nil
  46543. }
  46544. // SetAPIBase sets the "api_base" field.
  46545. func (m *WxMutation) SetAPIBase(s string) {
  46546. m.api_base = &s
  46547. }
  46548. // APIBase returns the value of the "api_base" field in the mutation.
  46549. func (m *WxMutation) APIBase() (r string, exists bool) {
  46550. v := m.api_base
  46551. if v == nil {
  46552. return
  46553. }
  46554. return *v, true
  46555. }
  46556. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  46557. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46558. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46559. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  46560. if !m.op.Is(OpUpdateOne) {
  46561. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  46562. }
  46563. if m.id == nil || m.oldValue == nil {
  46564. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  46565. }
  46566. oldValue, err := m.oldValue(ctx)
  46567. if err != nil {
  46568. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  46569. }
  46570. return oldValue.APIBase, nil
  46571. }
  46572. // ClearAPIBase clears the value of the "api_base" field.
  46573. func (m *WxMutation) ClearAPIBase() {
  46574. m.api_base = nil
  46575. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  46576. }
  46577. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  46578. func (m *WxMutation) APIBaseCleared() bool {
  46579. _, ok := m.clearedFields[wx.FieldAPIBase]
  46580. return ok
  46581. }
  46582. // ResetAPIBase resets all changes to the "api_base" field.
  46583. func (m *WxMutation) ResetAPIBase() {
  46584. m.api_base = nil
  46585. delete(m.clearedFields, wx.FieldAPIBase)
  46586. }
  46587. // SetAPIKey sets the "api_key" field.
  46588. func (m *WxMutation) SetAPIKey(s string) {
  46589. m.api_key = &s
  46590. }
  46591. // APIKey returns the value of the "api_key" field in the mutation.
  46592. func (m *WxMutation) APIKey() (r string, exists bool) {
  46593. v := m.api_key
  46594. if v == nil {
  46595. return
  46596. }
  46597. return *v, true
  46598. }
  46599. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  46600. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46601. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46602. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  46603. if !m.op.Is(OpUpdateOne) {
  46604. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  46605. }
  46606. if m.id == nil || m.oldValue == nil {
  46607. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  46608. }
  46609. oldValue, err := m.oldValue(ctx)
  46610. if err != nil {
  46611. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  46612. }
  46613. return oldValue.APIKey, nil
  46614. }
  46615. // ClearAPIKey clears the value of the "api_key" field.
  46616. func (m *WxMutation) ClearAPIKey() {
  46617. m.api_key = nil
  46618. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  46619. }
  46620. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  46621. func (m *WxMutation) APIKeyCleared() bool {
  46622. _, ok := m.clearedFields[wx.FieldAPIKey]
  46623. return ok
  46624. }
  46625. // ResetAPIKey resets all changes to the "api_key" field.
  46626. func (m *WxMutation) ResetAPIKey() {
  46627. m.api_key = nil
  46628. delete(m.clearedFields, wx.FieldAPIKey)
  46629. }
  46630. // SetAllowList sets the "allow_list" field.
  46631. func (m *WxMutation) SetAllowList(s []string) {
  46632. m.allow_list = &s
  46633. m.appendallow_list = nil
  46634. }
  46635. // AllowList returns the value of the "allow_list" field in the mutation.
  46636. func (m *WxMutation) AllowList() (r []string, exists bool) {
  46637. v := m.allow_list
  46638. if v == nil {
  46639. return
  46640. }
  46641. return *v, true
  46642. }
  46643. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  46644. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46645. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46646. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  46647. if !m.op.Is(OpUpdateOne) {
  46648. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  46649. }
  46650. if m.id == nil || m.oldValue == nil {
  46651. return v, errors.New("OldAllowList requires an ID field in the mutation")
  46652. }
  46653. oldValue, err := m.oldValue(ctx)
  46654. if err != nil {
  46655. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  46656. }
  46657. return oldValue.AllowList, nil
  46658. }
  46659. // AppendAllowList adds s to the "allow_list" field.
  46660. func (m *WxMutation) AppendAllowList(s []string) {
  46661. m.appendallow_list = append(m.appendallow_list, s...)
  46662. }
  46663. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  46664. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  46665. if len(m.appendallow_list) == 0 {
  46666. return nil, false
  46667. }
  46668. return m.appendallow_list, true
  46669. }
  46670. // ResetAllowList resets all changes to the "allow_list" field.
  46671. func (m *WxMutation) ResetAllowList() {
  46672. m.allow_list = nil
  46673. m.appendallow_list = nil
  46674. }
  46675. // SetGroupAllowList sets the "group_allow_list" field.
  46676. func (m *WxMutation) SetGroupAllowList(s []string) {
  46677. m.group_allow_list = &s
  46678. m.appendgroup_allow_list = nil
  46679. }
  46680. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  46681. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  46682. v := m.group_allow_list
  46683. if v == nil {
  46684. return
  46685. }
  46686. return *v, true
  46687. }
  46688. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  46689. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46690. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46691. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  46692. if !m.op.Is(OpUpdateOne) {
  46693. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  46694. }
  46695. if m.id == nil || m.oldValue == nil {
  46696. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  46697. }
  46698. oldValue, err := m.oldValue(ctx)
  46699. if err != nil {
  46700. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  46701. }
  46702. return oldValue.GroupAllowList, nil
  46703. }
  46704. // AppendGroupAllowList adds s to the "group_allow_list" field.
  46705. func (m *WxMutation) AppendGroupAllowList(s []string) {
  46706. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  46707. }
  46708. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  46709. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  46710. if len(m.appendgroup_allow_list) == 0 {
  46711. return nil, false
  46712. }
  46713. return m.appendgroup_allow_list, true
  46714. }
  46715. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  46716. func (m *WxMutation) ResetGroupAllowList() {
  46717. m.group_allow_list = nil
  46718. m.appendgroup_allow_list = nil
  46719. }
  46720. // SetBlockList sets the "block_list" field.
  46721. func (m *WxMutation) SetBlockList(s []string) {
  46722. m.block_list = &s
  46723. m.appendblock_list = nil
  46724. }
  46725. // BlockList returns the value of the "block_list" field in the mutation.
  46726. func (m *WxMutation) BlockList() (r []string, exists bool) {
  46727. v := m.block_list
  46728. if v == nil {
  46729. return
  46730. }
  46731. return *v, true
  46732. }
  46733. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  46734. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46735. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46736. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  46737. if !m.op.Is(OpUpdateOne) {
  46738. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  46739. }
  46740. if m.id == nil || m.oldValue == nil {
  46741. return v, errors.New("OldBlockList requires an ID field in the mutation")
  46742. }
  46743. oldValue, err := m.oldValue(ctx)
  46744. if err != nil {
  46745. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  46746. }
  46747. return oldValue.BlockList, nil
  46748. }
  46749. // AppendBlockList adds s to the "block_list" field.
  46750. func (m *WxMutation) AppendBlockList(s []string) {
  46751. m.appendblock_list = append(m.appendblock_list, s...)
  46752. }
  46753. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  46754. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  46755. if len(m.appendblock_list) == 0 {
  46756. return nil, false
  46757. }
  46758. return m.appendblock_list, true
  46759. }
  46760. // ResetBlockList resets all changes to the "block_list" field.
  46761. func (m *WxMutation) ResetBlockList() {
  46762. m.block_list = nil
  46763. m.appendblock_list = nil
  46764. }
  46765. // SetGroupBlockList sets the "group_block_list" field.
  46766. func (m *WxMutation) SetGroupBlockList(s []string) {
  46767. m.group_block_list = &s
  46768. m.appendgroup_block_list = nil
  46769. }
  46770. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  46771. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  46772. v := m.group_block_list
  46773. if v == nil {
  46774. return
  46775. }
  46776. return *v, true
  46777. }
  46778. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  46779. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46781. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  46782. if !m.op.Is(OpUpdateOne) {
  46783. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  46784. }
  46785. if m.id == nil || m.oldValue == nil {
  46786. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  46787. }
  46788. oldValue, err := m.oldValue(ctx)
  46789. if err != nil {
  46790. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  46791. }
  46792. return oldValue.GroupBlockList, nil
  46793. }
  46794. // AppendGroupBlockList adds s to the "group_block_list" field.
  46795. func (m *WxMutation) AppendGroupBlockList(s []string) {
  46796. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  46797. }
  46798. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  46799. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  46800. if len(m.appendgroup_block_list) == 0 {
  46801. return nil, false
  46802. }
  46803. return m.appendgroup_block_list, true
  46804. }
  46805. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  46806. func (m *WxMutation) ResetGroupBlockList() {
  46807. m.group_block_list = nil
  46808. m.appendgroup_block_list = nil
  46809. }
  46810. // SetCtype sets the "ctype" field.
  46811. func (m *WxMutation) SetCtype(u uint64) {
  46812. m.ctype = &u
  46813. m.addctype = nil
  46814. }
  46815. // Ctype returns the value of the "ctype" field in the mutation.
  46816. func (m *WxMutation) Ctype() (r uint64, exists bool) {
  46817. v := m.ctype
  46818. if v == nil {
  46819. return
  46820. }
  46821. return *v, true
  46822. }
  46823. // OldCtype returns the old "ctype" field's value of the Wx entity.
  46824. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46825. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46826. func (m *WxMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  46827. if !m.op.Is(OpUpdateOne) {
  46828. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  46829. }
  46830. if m.id == nil || m.oldValue == nil {
  46831. return v, errors.New("OldCtype requires an ID field in the mutation")
  46832. }
  46833. oldValue, err := m.oldValue(ctx)
  46834. if err != nil {
  46835. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  46836. }
  46837. return oldValue.Ctype, nil
  46838. }
  46839. // AddCtype adds u to the "ctype" field.
  46840. func (m *WxMutation) AddCtype(u int64) {
  46841. if m.addctype != nil {
  46842. *m.addctype += u
  46843. } else {
  46844. m.addctype = &u
  46845. }
  46846. }
  46847. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  46848. func (m *WxMutation) AddedCtype() (r int64, exists bool) {
  46849. v := m.addctype
  46850. if v == nil {
  46851. return
  46852. }
  46853. return *v, true
  46854. }
  46855. // ClearCtype clears the value of the "ctype" field.
  46856. func (m *WxMutation) ClearCtype() {
  46857. m.ctype = nil
  46858. m.addctype = nil
  46859. m.clearedFields[wx.FieldCtype] = struct{}{}
  46860. }
  46861. // CtypeCleared returns if the "ctype" field was cleared in this mutation.
  46862. func (m *WxMutation) CtypeCleared() bool {
  46863. _, ok := m.clearedFields[wx.FieldCtype]
  46864. return ok
  46865. }
  46866. // ResetCtype resets all changes to the "ctype" field.
  46867. func (m *WxMutation) ResetCtype() {
  46868. m.ctype = nil
  46869. m.addctype = nil
  46870. delete(m.clearedFields, wx.FieldCtype)
  46871. }
  46872. // ClearServer clears the "server" edge to the Server entity.
  46873. func (m *WxMutation) ClearServer() {
  46874. m.clearedserver = true
  46875. m.clearedFields[wx.FieldServerID] = struct{}{}
  46876. }
  46877. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  46878. func (m *WxMutation) ServerCleared() bool {
  46879. return m.ServerIDCleared() || m.clearedserver
  46880. }
  46881. // ServerIDs returns the "server" edge IDs in the mutation.
  46882. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  46883. // ServerID instead. It exists only for internal usage by the builders.
  46884. func (m *WxMutation) ServerIDs() (ids []uint64) {
  46885. if id := m.server; id != nil {
  46886. ids = append(ids, *id)
  46887. }
  46888. return
  46889. }
  46890. // ResetServer resets all changes to the "server" edge.
  46891. func (m *WxMutation) ResetServer() {
  46892. m.server = nil
  46893. m.clearedserver = false
  46894. }
  46895. // ClearAgent clears the "agent" edge to the Agent entity.
  46896. func (m *WxMutation) ClearAgent() {
  46897. m.clearedagent = true
  46898. m.clearedFields[wx.FieldAgentID] = struct{}{}
  46899. }
  46900. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  46901. func (m *WxMutation) AgentCleared() bool {
  46902. return m.clearedagent
  46903. }
  46904. // AgentIDs returns the "agent" edge IDs in the mutation.
  46905. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  46906. // AgentID instead. It exists only for internal usage by the builders.
  46907. func (m *WxMutation) AgentIDs() (ids []uint64) {
  46908. if id := m.agent; id != nil {
  46909. ids = append(ids, *id)
  46910. }
  46911. return
  46912. }
  46913. // ResetAgent resets all changes to the "agent" edge.
  46914. func (m *WxMutation) ResetAgent() {
  46915. m.agent = nil
  46916. m.clearedagent = false
  46917. }
  46918. // Where appends a list predicates to the WxMutation builder.
  46919. func (m *WxMutation) Where(ps ...predicate.Wx) {
  46920. m.predicates = append(m.predicates, ps...)
  46921. }
  46922. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  46923. // users can use type-assertion to append predicates that do not depend on any generated package.
  46924. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  46925. p := make([]predicate.Wx, len(ps))
  46926. for i := range ps {
  46927. p[i] = ps[i]
  46928. }
  46929. m.Where(p...)
  46930. }
  46931. // Op returns the operation name.
  46932. func (m *WxMutation) Op() Op {
  46933. return m.op
  46934. }
  46935. // SetOp allows setting the mutation operation.
  46936. func (m *WxMutation) SetOp(op Op) {
  46937. m.op = op
  46938. }
  46939. // Type returns the node type of this mutation (Wx).
  46940. func (m *WxMutation) Type() string {
  46941. return m.typ
  46942. }
  46943. // Fields returns all fields that were changed during this mutation. Note that in
  46944. // order to get all numeric fields that were incremented/decremented, call
  46945. // AddedFields().
  46946. func (m *WxMutation) Fields() []string {
  46947. fields := make([]string, 0, 22)
  46948. if m.created_at != nil {
  46949. fields = append(fields, wx.FieldCreatedAt)
  46950. }
  46951. if m.updated_at != nil {
  46952. fields = append(fields, wx.FieldUpdatedAt)
  46953. }
  46954. if m.status != nil {
  46955. fields = append(fields, wx.FieldStatus)
  46956. }
  46957. if m.deleted_at != nil {
  46958. fields = append(fields, wx.FieldDeletedAt)
  46959. }
  46960. if m.server != nil {
  46961. fields = append(fields, wx.FieldServerID)
  46962. }
  46963. if m.port != nil {
  46964. fields = append(fields, wx.FieldPort)
  46965. }
  46966. if m.process_id != nil {
  46967. fields = append(fields, wx.FieldProcessID)
  46968. }
  46969. if m.callback != nil {
  46970. fields = append(fields, wx.FieldCallback)
  46971. }
  46972. if m.wxid != nil {
  46973. fields = append(fields, wx.FieldWxid)
  46974. }
  46975. if m.account != nil {
  46976. fields = append(fields, wx.FieldAccount)
  46977. }
  46978. if m.nickname != nil {
  46979. fields = append(fields, wx.FieldNickname)
  46980. }
  46981. if m.tel != nil {
  46982. fields = append(fields, wx.FieldTel)
  46983. }
  46984. if m.head_big != nil {
  46985. fields = append(fields, wx.FieldHeadBig)
  46986. }
  46987. if m.organization_id != nil {
  46988. fields = append(fields, wx.FieldOrganizationID)
  46989. }
  46990. if m.agent != nil {
  46991. fields = append(fields, wx.FieldAgentID)
  46992. }
  46993. if m.api_base != nil {
  46994. fields = append(fields, wx.FieldAPIBase)
  46995. }
  46996. if m.api_key != nil {
  46997. fields = append(fields, wx.FieldAPIKey)
  46998. }
  46999. if m.allow_list != nil {
  47000. fields = append(fields, wx.FieldAllowList)
  47001. }
  47002. if m.group_allow_list != nil {
  47003. fields = append(fields, wx.FieldGroupAllowList)
  47004. }
  47005. if m.block_list != nil {
  47006. fields = append(fields, wx.FieldBlockList)
  47007. }
  47008. if m.group_block_list != nil {
  47009. fields = append(fields, wx.FieldGroupBlockList)
  47010. }
  47011. if m.ctype != nil {
  47012. fields = append(fields, wx.FieldCtype)
  47013. }
  47014. return fields
  47015. }
  47016. // Field returns the value of a field with the given name. The second boolean
  47017. // return value indicates that this field was not set, or was not defined in the
  47018. // schema.
  47019. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  47020. switch name {
  47021. case wx.FieldCreatedAt:
  47022. return m.CreatedAt()
  47023. case wx.FieldUpdatedAt:
  47024. return m.UpdatedAt()
  47025. case wx.FieldStatus:
  47026. return m.Status()
  47027. case wx.FieldDeletedAt:
  47028. return m.DeletedAt()
  47029. case wx.FieldServerID:
  47030. return m.ServerID()
  47031. case wx.FieldPort:
  47032. return m.Port()
  47033. case wx.FieldProcessID:
  47034. return m.ProcessID()
  47035. case wx.FieldCallback:
  47036. return m.Callback()
  47037. case wx.FieldWxid:
  47038. return m.Wxid()
  47039. case wx.FieldAccount:
  47040. return m.Account()
  47041. case wx.FieldNickname:
  47042. return m.Nickname()
  47043. case wx.FieldTel:
  47044. return m.Tel()
  47045. case wx.FieldHeadBig:
  47046. return m.HeadBig()
  47047. case wx.FieldOrganizationID:
  47048. return m.OrganizationID()
  47049. case wx.FieldAgentID:
  47050. return m.AgentID()
  47051. case wx.FieldAPIBase:
  47052. return m.APIBase()
  47053. case wx.FieldAPIKey:
  47054. return m.APIKey()
  47055. case wx.FieldAllowList:
  47056. return m.AllowList()
  47057. case wx.FieldGroupAllowList:
  47058. return m.GroupAllowList()
  47059. case wx.FieldBlockList:
  47060. return m.BlockList()
  47061. case wx.FieldGroupBlockList:
  47062. return m.GroupBlockList()
  47063. case wx.FieldCtype:
  47064. return m.Ctype()
  47065. }
  47066. return nil, false
  47067. }
  47068. // OldField returns the old value of the field from the database. An error is
  47069. // returned if the mutation operation is not UpdateOne, or the query to the
  47070. // database failed.
  47071. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  47072. switch name {
  47073. case wx.FieldCreatedAt:
  47074. return m.OldCreatedAt(ctx)
  47075. case wx.FieldUpdatedAt:
  47076. return m.OldUpdatedAt(ctx)
  47077. case wx.FieldStatus:
  47078. return m.OldStatus(ctx)
  47079. case wx.FieldDeletedAt:
  47080. return m.OldDeletedAt(ctx)
  47081. case wx.FieldServerID:
  47082. return m.OldServerID(ctx)
  47083. case wx.FieldPort:
  47084. return m.OldPort(ctx)
  47085. case wx.FieldProcessID:
  47086. return m.OldProcessID(ctx)
  47087. case wx.FieldCallback:
  47088. return m.OldCallback(ctx)
  47089. case wx.FieldWxid:
  47090. return m.OldWxid(ctx)
  47091. case wx.FieldAccount:
  47092. return m.OldAccount(ctx)
  47093. case wx.FieldNickname:
  47094. return m.OldNickname(ctx)
  47095. case wx.FieldTel:
  47096. return m.OldTel(ctx)
  47097. case wx.FieldHeadBig:
  47098. return m.OldHeadBig(ctx)
  47099. case wx.FieldOrganizationID:
  47100. return m.OldOrganizationID(ctx)
  47101. case wx.FieldAgentID:
  47102. return m.OldAgentID(ctx)
  47103. case wx.FieldAPIBase:
  47104. return m.OldAPIBase(ctx)
  47105. case wx.FieldAPIKey:
  47106. return m.OldAPIKey(ctx)
  47107. case wx.FieldAllowList:
  47108. return m.OldAllowList(ctx)
  47109. case wx.FieldGroupAllowList:
  47110. return m.OldGroupAllowList(ctx)
  47111. case wx.FieldBlockList:
  47112. return m.OldBlockList(ctx)
  47113. case wx.FieldGroupBlockList:
  47114. return m.OldGroupBlockList(ctx)
  47115. case wx.FieldCtype:
  47116. return m.OldCtype(ctx)
  47117. }
  47118. return nil, fmt.Errorf("unknown Wx field %s", name)
  47119. }
  47120. // SetField sets the value of a field with the given name. It returns an error if
  47121. // the field is not defined in the schema, or if the type mismatched the field
  47122. // type.
  47123. func (m *WxMutation) SetField(name string, value ent.Value) error {
  47124. switch name {
  47125. case wx.FieldCreatedAt:
  47126. v, ok := value.(time.Time)
  47127. if !ok {
  47128. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47129. }
  47130. m.SetCreatedAt(v)
  47131. return nil
  47132. case wx.FieldUpdatedAt:
  47133. v, ok := value.(time.Time)
  47134. if !ok {
  47135. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47136. }
  47137. m.SetUpdatedAt(v)
  47138. return nil
  47139. case wx.FieldStatus:
  47140. v, ok := value.(uint8)
  47141. if !ok {
  47142. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47143. }
  47144. m.SetStatus(v)
  47145. return nil
  47146. case wx.FieldDeletedAt:
  47147. v, ok := value.(time.Time)
  47148. if !ok {
  47149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47150. }
  47151. m.SetDeletedAt(v)
  47152. return nil
  47153. case wx.FieldServerID:
  47154. v, ok := value.(uint64)
  47155. if !ok {
  47156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47157. }
  47158. m.SetServerID(v)
  47159. return nil
  47160. case wx.FieldPort:
  47161. v, ok := value.(string)
  47162. if !ok {
  47163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47164. }
  47165. m.SetPort(v)
  47166. return nil
  47167. case wx.FieldProcessID:
  47168. v, ok := value.(string)
  47169. if !ok {
  47170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47171. }
  47172. m.SetProcessID(v)
  47173. return nil
  47174. case wx.FieldCallback:
  47175. v, ok := value.(string)
  47176. if !ok {
  47177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47178. }
  47179. m.SetCallback(v)
  47180. return nil
  47181. case wx.FieldWxid:
  47182. v, ok := value.(string)
  47183. if !ok {
  47184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47185. }
  47186. m.SetWxid(v)
  47187. return nil
  47188. case wx.FieldAccount:
  47189. v, ok := value.(string)
  47190. if !ok {
  47191. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47192. }
  47193. m.SetAccount(v)
  47194. return nil
  47195. case wx.FieldNickname:
  47196. v, ok := value.(string)
  47197. if !ok {
  47198. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47199. }
  47200. m.SetNickname(v)
  47201. return nil
  47202. case wx.FieldTel:
  47203. v, ok := value.(string)
  47204. if !ok {
  47205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47206. }
  47207. m.SetTel(v)
  47208. return nil
  47209. case wx.FieldHeadBig:
  47210. v, ok := value.(string)
  47211. if !ok {
  47212. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47213. }
  47214. m.SetHeadBig(v)
  47215. return nil
  47216. case wx.FieldOrganizationID:
  47217. v, ok := value.(uint64)
  47218. if !ok {
  47219. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47220. }
  47221. m.SetOrganizationID(v)
  47222. return nil
  47223. case wx.FieldAgentID:
  47224. v, ok := value.(uint64)
  47225. if !ok {
  47226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47227. }
  47228. m.SetAgentID(v)
  47229. return nil
  47230. case wx.FieldAPIBase:
  47231. v, ok := value.(string)
  47232. if !ok {
  47233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47234. }
  47235. m.SetAPIBase(v)
  47236. return nil
  47237. case wx.FieldAPIKey:
  47238. v, ok := value.(string)
  47239. if !ok {
  47240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47241. }
  47242. m.SetAPIKey(v)
  47243. return nil
  47244. case wx.FieldAllowList:
  47245. v, ok := value.([]string)
  47246. if !ok {
  47247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47248. }
  47249. m.SetAllowList(v)
  47250. return nil
  47251. case wx.FieldGroupAllowList:
  47252. v, ok := value.([]string)
  47253. if !ok {
  47254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47255. }
  47256. m.SetGroupAllowList(v)
  47257. return nil
  47258. case wx.FieldBlockList:
  47259. v, ok := value.([]string)
  47260. if !ok {
  47261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47262. }
  47263. m.SetBlockList(v)
  47264. return nil
  47265. case wx.FieldGroupBlockList:
  47266. v, ok := value.([]string)
  47267. if !ok {
  47268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47269. }
  47270. m.SetGroupBlockList(v)
  47271. return nil
  47272. case wx.FieldCtype:
  47273. v, ok := value.(uint64)
  47274. if !ok {
  47275. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47276. }
  47277. m.SetCtype(v)
  47278. return nil
  47279. }
  47280. return fmt.Errorf("unknown Wx field %s", name)
  47281. }
  47282. // AddedFields returns all numeric fields that were incremented/decremented during
  47283. // this mutation.
  47284. func (m *WxMutation) AddedFields() []string {
  47285. var fields []string
  47286. if m.addstatus != nil {
  47287. fields = append(fields, wx.FieldStatus)
  47288. }
  47289. if m.addorganization_id != nil {
  47290. fields = append(fields, wx.FieldOrganizationID)
  47291. }
  47292. if m.addctype != nil {
  47293. fields = append(fields, wx.FieldCtype)
  47294. }
  47295. return fields
  47296. }
  47297. // AddedField returns the numeric value that was incremented/decremented on a field
  47298. // with the given name. The second boolean return value indicates that this field
  47299. // was not set, or was not defined in the schema.
  47300. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  47301. switch name {
  47302. case wx.FieldStatus:
  47303. return m.AddedStatus()
  47304. case wx.FieldOrganizationID:
  47305. return m.AddedOrganizationID()
  47306. case wx.FieldCtype:
  47307. return m.AddedCtype()
  47308. }
  47309. return nil, false
  47310. }
  47311. // AddField adds the value to the field with the given name. It returns an error if
  47312. // the field is not defined in the schema, or if the type mismatched the field
  47313. // type.
  47314. func (m *WxMutation) AddField(name string, value ent.Value) error {
  47315. switch name {
  47316. case wx.FieldStatus:
  47317. v, ok := value.(int8)
  47318. if !ok {
  47319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47320. }
  47321. m.AddStatus(v)
  47322. return nil
  47323. case wx.FieldOrganizationID:
  47324. v, ok := value.(int64)
  47325. if !ok {
  47326. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47327. }
  47328. m.AddOrganizationID(v)
  47329. return nil
  47330. case wx.FieldCtype:
  47331. v, ok := value.(int64)
  47332. if !ok {
  47333. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47334. }
  47335. m.AddCtype(v)
  47336. return nil
  47337. }
  47338. return fmt.Errorf("unknown Wx numeric field %s", name)
  47339. }
  47340. // ClearedFields returns all nullable fields that were cleared during this
  47341. // mutation.
  47342. func (m *WxMutation) ClearedFields() []string {
  47343. var fields []string
  47344. if m.FieldCleared(wx.FieldStatus) {
  47345. fields = append(fields, wx.FieldStatus)
  47346. }
  47347. if m.FieldCleared(wx.FieldDeletedAt) {
  47348. fields = append(fields, wx.FieldDeletedAt)
  47349. }
  47350. if m.FieldCleared(wx.FieldServerID) {
  47351. fields = append(fields, wx.FieldServerID)
  47352. }
  47353. if m.FieldCleared(wx.FieldOrganizationID) {
  47354. fields = append(fields, wx.FieldOrganizationID)
  47355. }
  47356. if m.FieldCleared(wx.FieldAPIBase) {
  47357. fields = append(fields, wx.FieldAPIBase)
  47358. }
  47359. if m.FieldCleared(wx.FieldAPIKey) {
  47360. fields = append(fields, wx.FieldAPIKey)
  47361. }
  47362. if m.FieldCleared(wx.FieldCtype) {
  47363. fields = append(fields, wx.FieldCtype)
  47364. }
  47365. return fields
  47366. }
  47367. // FieldCleared returns a boolean indicating if a field with the given name was
  47368. // cleared in this mutation.
  47369. func (m *WxMutation) FieldCleared(name string) bool {
  47370. _, ok := m.clearedFields[name]
  47371. return ok
  47372. }
  47373. // ClearField clears the value of the field with the given name. It returns an
  47374. // error if the field is not defined in the schema.
  47375. func (m *WxMutation) ClearField(name string) error {
  47376. switch name {
  47377. case wx.FieldStatus:
  47378. m.ClearStatus()
  47379. return nil
  47380. case wx.FieldDeletedAt:
  47381. m.ClearDeletedAt()
  47382. return nil
  47383. case wx.FieldServerID:
  47384. m.ClearServerID()
  47385. return nil
  47386. case wx.FieldOrganizationID:
  47387. m.ClearOrganizationID()
  47388. return nil
  47389. case wx.FieldAPIBase:
  47390. m.ClearAPIBase()
  47391. return nil
  47392. case wx.FieldAPIKey:
  47393. m.ClearAPIKey()
  47394. return nil
  47395. case wx.FieldCtype:
  47396. m.ClearCtype()
  47397. return nil
  47398. }
  47399. return fmt.Errorf("unknown Wx nullable field %s", name)
  47400. }
  47401. // ResetField resets all changes in the mutation for the field with the given name.
  47402. // It returns an error if the field is not defined in the schema.
  47403. func (m *WxMutation) ResetField(name string) error {
  47404. switch name {
  47405. case wx.FieldCreatedAt:
  47406. m.ResetCreatedAt()
  47407. return nil
  47408. case wx.FieldUpdatedAt:
  47409. m.ResetUpdatedAt()
  47410. return nil
  47411. case wx.FieldStatus:
  47412. m.ResetStatus()
  47413. return nil
  47414. case wx.FieldDeletedAt:
  47415. m.ResetDeletedAt()
  47416. return nil
  47417. case wx.FieldServerID:
  47418. m.ResetServerID()
  47419. return nil
  47420. case wx.FieldPort:
  47421. m.ResetPort()
  47422. return nil
  47423. case wx.FieldProcessID:
  47424. m.ResetProcessID()
  47425. return nil
  47426. case wx.FieldCallback:
  47427. m.ResetCallback()
  47428. return nil
  47429. case wx.FieldWxid:
  47430. m.ResetWxid()
  47431. return nil
  47432. case wx.FieldAccount:
  47433. m.ResetAccount()
  47434. return nil
  47435. case wx.FieldNickname:
  47436. m.ResetNickname()
  47437. return nil
  47438. case wx.FieldTel:
  47439. m.ResetTel()
  47440. return nil
  47441. case wx.FieldHeadBig:
  47442. m.ResetHeadBig()
  47443. return nil
  47444. case wx.FieldOrganizationID:
  47445. m.ResetOrganizationID()
  47446. return nil
  47447. case wx.FieldAgentID:
  47448. m.ResetAgentID()
  47449. return nil
  47450. case wx.FieldAPIBase:
  47451. m.ResetAPIBase()
  47452. return nil
  47453. case wx.FieldAPIKey:
  47454. m.ResetAPIKey()
  47455. return nil
  47456. case wx.FieldAllowList:
  47457. m.ResetAllowList()
  47458. return nil
  47459. case wx.FieldGroupAllowList:
  47460. m.ResetGroupAllowList()
  47461. return nil
  47462. case wx.FieldBlockList:
  47463. m.ResetBlockList()
  47464. return nil
  47465. case wx.FieldGroupBlockList:
  47466. m.ResetGroupBlockList()
  47467. return nil
  47468. case wx.FieldCtype:
  47469. m.ResetCtype()
  47470. return nil
  47471. }
  47472. return fmt.Errorf("unknown Wx field %s", name)
  47473. }
  47474. // AddedEdges returns all edge names that were set/added in this mutation.
  47475. func (m *WxMutation) AddedEdges() []string {
  47476. edges := make([]string, 0, 2)
  47477. if m.server != nil {
  47478. edges = append(edges, wx.EdgeServer)
  47479. }
  47480. if m.agent != nil {
  47481. edges = append(edges, wx.EdgeAgent)
  47482. }
  47483. return edges
  47484. }
  47485. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  47486. // name in this mutation.
  47487. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  47488. switch name {
  47489. case wx.EdgeServer:
  47490. if id := m.server; id != nil {
  47491. return []ent.Value{*id}
  47492. }
  47493. case wx.EdgeAgent:
  47494. if id := m.agent; id != nil {
  47495. return []ent.Value{*id}
  47496. }
  47497. }
  47498. return nil
  47499. }
  47500. // RemovedEdges returns all edge names that were removed in this mutation.
  47501. func (m *WxMutation) RemovedEdges() []string {
  47502. edges := make([]string, 0, 2)
  47503. return edges
  47504. }
  47505. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  47506. // the given name in this mutation.
  47507. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  47508. return nil
  47509. }
  47510. // ClearedEdges returns all edge names that were cleared in this mutation.
  47511. func (m *WxMutation) ClearedEdges() []string {
  47512. edges := make([]string, 0, 2)
  47513. if m.clearedserver {
  47514. edges = append(edges, wx.EdgeServer)
  47515. }
  47516. if m.clearedagent {
  47517. edges = append(edges, wx.EdgeAgent)
  47518. }
  47519. return edges
  47520. }
  47521. // EdgeCleared returns a boolean which indicates if the edge with the given name
  47522. // was cleared in this mutation.
  47523. func (m *WxMutation) EdgeCleared(name string) bool {
  47524. switch name {
  47525. case wx.EdgeServer:
  47526. return m.clearedserver
  47527. case wx.EdgeAgent:
  47528. return m.clearedagent
  47529. }
  47530. return false
  47531. }
  47532. // ClearEdge clears the value of the edge with the given name. It returns an error
  47533. // if that edge is not defined in the schema.
  47534. func (m *WxMutation) ClearEdge(name string) error {
  47535. switch name {
  47536. case wx.EdgeServer:
  47537. m.ClearServer()
  47538. return nil
  47539. case wx.EdgeAgent:
  47540. m.ClearAgent()
  47541. return nil
  47542. }
  47543. return fmt.Errorf("unknown Wx unique edge %s", name)
  47544. }
  47545. // ResetEdge resets all changes to the edge with the given name in this mutation.
  47546. // It returns an error if the edge is not defined in the schema.
  47547. func (m *WxMutation) ResetEdge(name string) error {
  47548. switch name {
  47549. case wx.EdgeServer:
  47550. m.ResetServer()
  47551. return nil
  47552. case wx.EdgeAgent:
  47553. m.ResetAgent()
  47554. return nil
  47555. }
  47556. return fmt.Errorf("unknown Wx edge %s", name)
  47557. }
  47558. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  47559. type WxCardMutation struct {
  47560. config
  47561. op Op
  47562. typ string
  47563. id *uint64
  47564. created_at *time.Time
  47565. updated_at *time.Time
  47566. deleted_at *time.Time
  47567. user_id *uint64
  47568. adduser_id *int64
  47569. wx_user_id *uint64
  47570. addwx_user_id *int64
  47571. avatar *string
  47572. logo *string
  47573. name *string
  47574. company *string
  47575. address *string
  47576. phone *string
  47577. official_account *string
  47578. wechat_account *string
  47579. email *string
  47580. api_base *string
  47581. api_key *string
  47582. ai_info *string
  47583. intro *string
  47584. clearedFields map[string]struct{}
  47585. done bool
  47586. oldValue func(context.Context) (*WxCard, error)
  47587. predicates []predicate.WxCard
  47588. }
  47589. var _ ent.Mutation = (*WxCardMutation)(nil)
  47590. // wxcardOption allows management of the mutation configuration using functional options.
  47591. type wxcardOption func(*WxCardMutation)
  47592. // newWxCardMutation creates new mutation for the WxCard entity.
  47593. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  47594. m := &WxCardMutation{
  47595. config: c,
  47596. op: op,
  47597. typ: TypeWxCard,
  47598. clearedFields: make(map[string]struct{}),
  47599. }
  47600. for _, opt := range opts {
  47601. opt(m)
  47602. }
  47603. return m
  47604. }
  47605. // withWxCardID sets the ID field of the mutation.
  47606. func withWxCardID(id uint64) wxcardOption {
  47607. return func(m *WxCardMutation) {
  47608. var (
  47609. err error
  47610. once sync.Once
  47611. value *WxCard
  47612. )
  47613. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  47614. once.Do(func() {
  47615. if m.done {
  47616. err = errors.New("querying old values post mutation is not allowed")
  47617. } else {
  47618. value, err = m.Client().WxCard.Get(ctx, id)
  47619. }
  47620. })
  47621. return value, err
  47622. }
  47623. m.id = &id
  47624. }
  47625. }
  47626. // withWxCard sets the old WxCard of the mutation.
  47627. func withWxCard(node *WxCard) wxcardOption {
  47628. return func(m *WxCardMutation) {
  47629. m.oldValue = func(context.Context) (*WxCard, error) {
  47630. return node, nil
  47631. }
  47632. m.id = &node.ID
  47633. }
  47634. }
  47635. // Client returns a new `ent.Client` from the mutation. If the mutation was
  47636. // executed in a transaction (ent.Tx), a transactional client is returned.
  47637. func (m WxCardMutation) Client() *Client {
  47638. client := &Client{config: m.config}
  47639. client.init()
  47640. return client
  47641. }
  47642. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  47643. // it returns an error otherwise.
  47644. func (m WxCardMutation) Tx() (*Tx, error) {
  47645. if _, ok := m.driver.(*txDriver); !ok {
  47646. return nil, errors.New("ent: mutation is not running in a transaction")
  47647. }
  47648. tx := &Tx{config: m.config}
  47649. tx.init()
  47650. return tx, nil
  47651. }
  47652. // SetID sets the value of the id field. Note that this
  47653. // operation is only accepted on creation of WxCard entities.
  47654. func (m *WxCardMutation) SetID(id uint64) {
  47655. m.id = &id
  47656. }
  47657. // ID returns the ID value in the mutation. Note that the ID is only available
  47658. // if it was provided to the builder or after it was returned from the database.
  47659. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  47660. if m.id == nil {
  47661. return
  47662. }
  47663. return *m.id, true
  47664. }
  47665. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  47666. // That means, if the mutation is applied within a transaction with an isolation level such
  47667. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  47668. // or updated by the mutation.
  47669. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  47670. switch {
  47671. case m.op.Is(OpUpdateOne | OpDeleteOne):
  47672. id, exists := m.ID()
  47673. if exists {
  47674. return []uint64{id}, nil
  47675. }
  47676. fallthrough
  47677. case m.op.Is(OpUpdate | OpDelete):
  47678. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  47679. default:
  47680. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  47681. }
  47682. }
  47683. // SetCreatedAt sets the "created_at" field.
  47684. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  47685. m.created_at = &t
  47686. }
  47687. // CreatedAt returns the value of the "created_at" field in the mutation.
  47688. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  47689. v := m.created_at
  47690. if v == nil {
  47691. return
  47692. }
  47693. return *v, true
  47694. }
  47695. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  47696. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47697. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47698. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  47699. if !m.op.Is(OpUpdateOne) {
  47700. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  47701. }
  47702. if m.id == nil || m.oldValue == nil {
  47703. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  47704. }
  47705. oldValue, err := m.oldValue(ctx)
  47706. if err != nil {
  47707. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  47708. }
  47709. return oldValue.CreatedAt, nil
  47710. }
  47711. // ResetCreatedAt resets all changes to the "created_at" field.
  47712. func (m *WxCardMutation) ResetCreatedAt() {
  47713. m.created_at = nil
  47714. }
  47715. // SetUpdatedAt sets the "updated_at" field.
  47716. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  47717. m.updated_at = &t
  47718. }
  47719. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  47720. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  47721. v := m.updated_at
  47722. if v == nil {
  47723. return
  47724. }
  47725. return *v, true
  47726. }
  47727. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  47728. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47729. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47730. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  47731. if !m.op.Is(OpUpdateOne) {
  47732. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  47733. }
  47734. if m.id == nil || m.oldValue == nil {
  47735. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  47736. }
  47737. oldValue, err := m.oldValue(ctx)
  47738. if err != nil {
  47739. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  47740. }
  47741. return oldValue.UpdatedAt, nil
  47742. }
  47743. // ResetUpdatedAt resets all changes to the "updated_at" field.
  47744. func (m *WxCardMutation) ResetUpdatedAt() {
  47745. m.updated_at = nil
  47746. }
  47747. // SetDeletedAt sets the "deleted_at" field.
  47748. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  47749. m.deleted_at = &t
  47750. }
  47751. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  47752. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  47753. v := m.deleted_at
  47754. if v == nil {
  47755. return
  47756. }
  47757. return *v, true
  47758. }
  47759. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  47760. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47761. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47762. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  47763. if !m.op.Is(OpUpdateOne) {
  47764. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  47765. }
  47766. if m.id == nil || m.oldValue == nil {
  47767. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  47768. }
  47769. oldValue, err := m.oldValue(ctx)
  47770. if err != nil {
  47771. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  47772. }
  47773. return oldValue.DeletedAt, nil
  47774. }
  47775. // ClearDeletedAt clears the value of the "deleted_at" field.
  47776. func (m *WxCardMutation) ClearDeletedAt() {
  47777. m.deleted_at = nil
  47778. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  47779. }
  47780. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  47781. func (m *WxCardMutation) DeletedAtCleared() bool {
  47782. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  47783. return ok
  47784. }
  47785. // ResetDeletedAt resets all changes to the "deleted_at" field.
  47786. func (m *WxCardMutation) ResetDeletedAt() {
  47787. m.deleted_at = nil
  47788. delete(m.clearedFields, wxcard.FieldDeletedAt)
  47789. }
  47790. // SetUserID sets the "user_id" field.
  47791. func (m *WxCardMutation) SetUserID(u uint64) {
  47792. m.user_id = &u
  47793. m.adduser_id = nil
  47794. }
  47795. // UserID returns the value of the "user_id" field in the mutation.
  47796. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  47797. v := m.user_id
  47798. if v == nil {
  47799. return
  47800. }
  47801. return *v, true
  47802. }
  47803. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  47804. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47805. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47806. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  47807. if !m.op.Is(OpUpdateOne) {
  47808. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  47809. }
  47810. if m.id == nil || m.oldValue == nil {
  47811. return v, errors.New("OldUserID requires an ID field in the mutation")
  47812. }
  47813. oldValue, err := m.oldValue(ctx)
  47814. if err != nil {
  47815. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  47816. }
  47817. return oldValue.UserID, nil
  47818. }
  47819. // AddUserID adds u to the "user_id" field.
  47820. func (m *WxCardMutation) AddUserID(u int64) {
  47821. if m.adduser_id != nil {
  47822. *m.adduser_id += u
  47823. } else {
  47824. m.adduser_id = &u
  47825. }
  47826. }
  47827. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  47828. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  47829. v := m.adduser_id
  47830. if v == nil {
  47831. return
  47832. }
  47833. return *v, true
  47834. }
  47835. // ClearUserID clears the value of the "user_id" field.
  47836. func (m *WxCardMutation) ClearUserID() {
  47837. m.user_id = nil
  47838. m.adduser_id = nil
  47839. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  47840. }
  47841. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  47842. func (m *WxCardMutation) UserIDCleared() bool {
  47843. _, ok := m.clearedFields[wxcard.FieldUserID]
  47844. return ok
  47845. }
  47846. // ResetUserID resets all changes to the "user_id" field.
  47847. func (m *WxCardMutation) ResetUserID() {
  47848. m.user_id = nil
  47849. m.adduser_id = nil
  47850. delete(m.clearedFields, wxcard.FieldUserID)
  47851. }
  47852. // SetWxUserID sets the "wx_user_id" field.
  47853. func (m *WxCardMutation) SetWxUserID(u uint64) {
  47854. m.wx_user_id = &u
  47855. m.addwx_user_id = nil
  47856. }
  47857. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  47858. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  47859. v := m.wx_user_id
  47860. if v == nil {
  47861. return
  47862. }
  47863. return *v, true
  47864. }
  47865. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  47866. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47867. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47868. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  47869. if !m.op.Is(OpUpdateOne) {
  47870. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  47871. }
  47872. if m.id == nil || m.oldValue == nil {
  47873. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  47874. }
  47875. oldValue, err := m.oldValue(ctx)
  47876. if err != nil {
  47877. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  47878. }
  47879. return oldValue.WxUserID, nil
  47880. }
  47881. // AddWxUserID adds u to the "wx_user_id" field.
  47882. func (m *WxCardMutation) AddWxUserID(u int64) {
  47883. if m.addwx_user_id != nil {
  47884. *m.addwx_user_id += u
  47885. } else {
  47886. m.addwx_user_id = &u
  47887. }
  47888. }
  47889. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  47890. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  47891. v := m.addwx_user_id
  47892. if v == nil {
  47893. return
  47894. }
  47895. return *v, true
  47896. }
  47897. // ClearWxUserID clears the value of the "wx_user_id" field.
  47898. func (m *WxCardMutation) ClearWxUserID() {
  47899. m.wx_user_id = nil
  47900. m.addwx_user_id = nil
  47901. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  47902. }
  47903. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  47904. func (m *WxCardMutation) WxUserIDCleared() bool {
  47905. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  47906. return ok
  47907. }
  47908. // ResetWxUserID resets all changes to the "wx_user_id" field.
  47909. func (m *WxCardMutation) ResetWxUserID() {
  47910. m.wx_user_id = nil
  47911. m.addwx_user_id = nil
  47912. delete(m.clearedFields, wxcard.FieldWxUserID)
  47913. }
  47914. // SetAvatar sets the "avatar" field.
  47915. func (m *WxCardMutation) SetAvatar(s string) {
  47916. m.avatar = &s
  47917. }
  47918. // Avatar returns the value of the "avatar" field in the mutation.
  47919. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  47920. v := m.avatar
  47921. if v == nil {
  47922. return
  47923. }
  47924. return *v, true
  47925. }
  47926. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  47927. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47928. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47929. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  47930. if !m.op.Is(OpUpdateOne) {
  47931. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  47932. }
  47933. if m.id == nil || m.oldValue == nil {
  47934. return v, errors.New("OldAvatar requires an ID field in the mutation")
  47935. }
  47936. oldValue, err := m.oldValue(ctx)
  47937. if err != nil {
  47938. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  47939. }
  47940. return oldValue.Avatar, nil
  47941. }
  47942. // ResetAvatar resets all changes to the "avatar" field.
  47943. func (m *WxCardMutation) ResetAvatar() {
  47944. m.avatar = nil
  47945. }
  47946. // SetLogo sets the "logo" field.
  47947. func (m *WxCardMutation) SetLogo(s string) {
  47948. m.logo = &s
  47949. }
  47950. // Logo returns the value of the "logo" field in the mutation.
  47951. func (m *WxCardMutation) Logo() (r string, exists bool) {
  47952. v := m.logo
  47953. if v == nil {
  47954. return
  47955. }
  47956. return *v, true
  47957. }
  47958. // OldLogo returns the old "logo" field's value of the WxCard entity.
  47959. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47960. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47961. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  47962. if !m.op.Is(OpUpdateOne) {
  47963. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  47964. }
  47965. if m.id == nil || m.oldValue == nil {
  47966. return v, errors.New("OldLogo requires an ID field in the mutation")
  47967. }
  47968. oldValue, err := m.oldValue(ctx)
  47969. if err != nil {
  47970. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  47971. }
  47972. return oldValue.Logo, nil
  47973. }
  47974. // ResetLogo resets all changes to the "logo" field.
  47975. func (m *WxCardMutation) ResetLogo() {
  47976. m.logo = nil
  47977. }
  47978. // SetName sets the "name" field.
  47979. func (m *WxCardMutation) SetName(s string) {
  47980. m.name = &s
  47981. }
  47982. // Name returns the value of the "name" field in the mutation.
  47983. func (m *WxCardMutation) Name() (r string, exists bool) {
  47984. v := m.name
  47985. if v == nil {
  47986. return
  47987. }
  47988. return *v, true
  47989. }
  47990. // OldName returns the old "name" field's value of the WxCard entity.
  47991. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47992. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47993. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  47994. if !m.op.Is(OpUpdateOne) {
  47995. return v, errors.New("OldName is only allowed on UpdateOne operations")
  47996. }
  47997. if m.id == nil || m.oldValue == nil {
  47998. return v, errors.New("OldName requires an ID field in the mutation")
  47999. }
  48000. oldValue, err := m.oldValue(ctx)
  48001. if err != nil {
  48002. return v, fmt.Errorf("querying old value for OldName: %w", err)
  48003. }
  48004. return oldValue.Name, nil
  48005. }
  48006. // ResetName resets all changes to the "name" field.
  48007. func (m *WxCardMutation) ResetName() {
  48008. m.name = nil
  48009. }
  48010. // SetCompany sets the "company" field.
  48011. func (m *WxCardMutation) SetCompany(s string) {
  48012. m.company = &s
  48013. }
  48014. // Company returns the value of the "company" field in the mutation.
  48015. func (m *WxCardMutation) Company() (r string, exists bool) {
  48016. v := m.company
  48017. if v == nil {
  48018. return
  48019. }
  48020. return *v, true
  48021. }
  48022. // OldCompany returns the old "company" field's value of the WxCard entity.
  48023. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48024. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48025. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  48026. if !m.op.Is(OpUpdateOne) {
  48027. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  48028. }
  48029. if m.id == nil || m.oldValue == nil {
  48030. return v, errors.New("OldCompany requires an ID field in the mutation")
  48031. }
  48032. oldValue, err := m.oldValue(ctx)
  48033. if err != nil {
  48034. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  48035. }
  48036. return oldValue.Company, nil
  48037. }
  48038. // ResetCompany resets all changes to the "company" field.
  48039. func (m *WxCardMutation) ResetCompany() {
  48040. m.company = nil
  48041. }
  48042. // SetAddress sets the "address" field.
  48043. func (m *WxCardMutation) SetAddress(s string) {
  48044. m.address = &s
  48045. }
  48046. // Address returns the value of the "address" field in the mutation.
  48047. func (m *WxCardMutation) Address() (r string, exists bool) {
  48048. v := m.address
  48049. if v == nil {
  48050. return
  48051. }
  48052. return *v, true
  48053. }
  48054. // OldAddress returns the old "address" field's value of the WxCard entity.
  48055. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48056. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48057. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  48058. if !m.op.Is(OpUpdateOne) {
  48059. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  48060. }
  48061. if m.id == nil || m.oldValue == nil {
  48062. return v, errors.New("OldAddress requires an ID field in the mutation")
  48063. }
  48064. oldValue, err := m.oldValue(ctx)
  48065. if err != nil {
  48066. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  48067. }
  48068. return oldValue.Address, nil
  48069. }
  48070. // ResetAddress resets all changes to the "address" field.
  48071. func (m *WxCardMutation) ResetAddress() {
  48072. m.address = nil
  48073. }
  48074. // SetPhone sets the "phone" field.
  48075. func (m *WxCardMutation) SetPhone(s string) {
  48076. m.phone = &s
  48077. }
  48078. // Phone returns the value of the "phone" field in the mutation.
  48079. func (m *WxCardMutation) Phone() (r string, exists bool) {
  48080. v := m.phone
  48081. if v == nil {
  48082. return
  48083. }
  48084. return *v, true
  48085. }
  48086. // OldPhone returns the old "phone" field's value of the WxCard entity.
  48087. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48088. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48089. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  48090. if !m.op.Is(OpUpdateOne) {
  48091. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  48092. }
  48093. if m.id == nil || m.oldValue == nil {
  48094. return v, errors.New("OldPhone requires an ID field in the mutation")
  48095. }
  48096. oldValue, err := m.oldValue(ctx)
  48097. if err != nil {
  48098. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  48099. }
  48100. return oldValue.Phone, nil
  48101. }
  48102. // ResetPhone resets all changes to the "phone" field.
  48103. func (m *WxCardMutation) ResetPhone() {
  48104. m.phone = nil
  48105. }
  48106. // SetOfficialAccount sets the "official_account" field.
  48107. func (m *WxCardMutation) SetOfficialAccount(s string) {
  48108. m.official_account = &s
  48109. }
  48110. // OfficialAccount returns the value of the "official_account" field in the mutation.
  48111. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  48112. v := m.official_account
  48113. if v == nil {
  48114. return
  48115. }
  48116. return *v, true
  48117. }
  48118. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  48119. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48120. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48121. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  48122. if !m.op.Is(OpUpdateOne) {
  48123. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  48124. }
  48125. if m.id == nil || m.oldValue == nil {
  48126. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  48127. }
  48128. oldValue, err := m.oldValue(ctx)
  48129. if err != nil {
  48130. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  48131. }
  48132. return oldValue.OfficialAccount, nil
  48133. }
  48134. // ResetOfficialAccount resets all changes to the "official_account" field.
  48135. func (m *WxCardMutation) ResetOfficialAccount() {
  48136. m.official_account = nil
  48137. }
  48138. // SetWechatAccount sets the "wechat_account" field.
  48139. func (m *WxCardMutation) SetWechatAccount(s string) {
  48140. m.wechat_account = &s
  48141. }
  48142. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  48143. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  48144. v := m.wechat_account
  48145. if v == nil {
  48146. return
  48147. }
  48148. return *v, true
  48149. }
  48150. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  48151. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48152. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48153. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  48154. if !m.op.Is(OpUpdateOne) {
  48155. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  48156. }
  48157. if m.id == nil || m.oldValue == nil {
  48158. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  48159. }
  48160. oldValue, err := m.oldValue(ctx)
  48161. if err != nil {
  48162. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  48163. }
  48164. return oldValue.WechatAccount, nil
  48165. }
  48166. // ResetWechatAccount resets all changes to the "wechat_account" field.
  48167. func (m *WxCardMutation) ResetWechatAccount() {
  48168. m.wechat_account = nil
  48169. }
  48170. // SetEmail sets the "email" field.
  48171. func (m *WxCardMutation) SetEmail(s string) {
  48172. m.email = &s
  48173. }
  48174. // Email returns the value of the "email" field in the mutation.
  48175. func (m *WxCardMutation) Email() (r string, exists bool) {
  48176. v := m.email
  48177. if v == nil {
  48178. return
  48179. }
  48180. return *v, true
  48181. }
  48182. // OldEmail returns the old "email" field's value of the WxCard entity.
  48183. // If the WxCard 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 *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  48186. if !m.op.Is(OpUpdateOne) {
  48187. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  48188. }
  48189. if m.id == nil || m.oldValue == nil {
  48190. return v, errors.New("OldEmail 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 OldEmail: %w", err)
  48195. }
  48196. return oldValue.Email, nil
  48197. }
  48198. // ClearEmail clears the value of the "email" field.
  48199. func (m *WxCardMutation) ClearEmail() {
  48200. m.email = nil
  48201. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  48202. }
  48203. // EmailCleared returns if the "email" field was cleared in this mutation.
  48204. func (m *WxCardMutation) EmailCleared() bool {
  48205. _, ok := m.clearedFields[wxcard.FieldEmail]
  48206. return ok
  48207. }
  48208. // ResetEmail resets all changes to the "email" field.
  48209. func (m *WxCardMutation) ResetEmail() {
  48210. m.email = nil
  48211. delete(m.clearedFields, wxcard.FieldEmail)
  48212. }
  48213. // SetAPIBase sets the "api_base" field.
  48214. func (m *WxCardMutation) SetAPIBase(s string) {
  48215. m.api_base = &s
  48216. }
  48217. // APIBase returns the value of the "api_base" field in the mutation.
  48218. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  48219. v := m.api_base
  48220. if v == nil {
  48221. return
  48222. }
  48223. return *v, true
  48224. }
  48225. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  48226. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48227. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48228. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  48229. if !m.op.Is(OpUpdateOne) {
  48230. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  48231. }
  48232. if m.id == nil || m.oldValue == nil {
  48233. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  48234. }
  48235. oldValue, err := m.oldValue(ctx)
  48236. if err != nil {
  48237. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  48238. }
  48239. return oldValue.APIBase, nil
  48240. }
  48241. // ClearAPIBase clears the value of the "api_base" field.
  48242. func (m *WxCardMutation) ClearAPIBase() {
  48243. m.api_base = nil
  48244. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  48245. }
  48246. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  48247. func (m *WxCardMutation) APIBaseCleared() bool {
  48248. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  48249. return ok
  48250. }
  48251. // ResetAPIBase resets all changes to the "api_base" field.
  48252. func (m *WxCardMutation) ResetAPIBase() {
  48253. m.api_base = nil
  48254. delete(m.clearedFields, wxcard.FieldAPIBase)
  48255. }
  48256. // SetAPIKey sets the "api_key" field.
  48257. func (m *WxCardMutation) SetAPIKey(s string) {
  48258. m.api_key = &s
  48259. }
  48260. // APIKey returns the value of the "api_key" field in the mutation.
  48261. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  48262. v := m.api_key
  48263. if v == nil {
  48264. return
  48265. }
  48266. return *v, true
  48267. }
  48268. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  48269. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48270. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48271. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  48272. if !m.op.Is(OpUpdateOne) {
  48273. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  48274. }
  48275. if m.id == nil || m.oldValue == nil {
  48276. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  48277. }
  48278. oldValue, err := m.oldValue(ctx)
  48279. if err != nil {
  48280. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  48281. }
  48282. return oldValue.APIKey, nil
  48283. }
  48284. // ClearAPIKey clears the value of the "api_key" field.
  48285. func (m *WxCardMutation) ClearAPIKey() {
  48286. m.api_key = nil
  48287. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  48288. }
  48289. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  48290. func (m *WxCardMutation) APIKeyCleared() bool {
  48291. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  48292. return ok
  48293. }
  48294. // ResetAPIKey resets all changes to the "api_key" field.
  48295. func (m *WxCardMutation) ResetAPIKey() {
  48296. m.api_key = nil
  48297. delete(m.clearedFields, wxcard.FieldAPIKey)
  48298. }
  48299. // SetAiInfo sets the "ai_info" field.
  48300. func (m *WxCardMutation) SetAiInfo(s string) {
  48301. m.ai_info = &s
  48302. }
  48303. // AiInfo returns the value of the "ai_info" field in the mutation.
  48304. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  48305. v := m.ai_info
  48306. if v == nil {
  48307. return
  48308. }
  48309. return *v, true
  48310. }
  48311. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  48312. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48313. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48314. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  48315. if !m.op.Is(OpUpdateOne) {
  48316. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  48317. }
  48318. if m.id == nil || m.oldValue == nil {
  48319. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  48320. }
  48321. oldValue, err := m.oldValue(ctx)
  48322. if err != nil {
  48323. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  48324. }
  48325. return oldValue.AiInfo, nil
  48326. }
  48327. // ClearAiInfo clears the value of the "ai_info" field.
  48328. func (m *WxCardMutation) ClearAiInfo() {
  48329. m.ai_info = nil
  48330. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  48331. }
  48332. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  48333. func (m *WxCardMutation) AiInfoCleared() bool {
  48334. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  48335. return ok
  48336. }
  48337. // ResetAiInfo resets all changes to the "ai_info" field.
  48338. func (m *WxCardMutation) ResetAiInfo() {
  48339. m.ai_info = nil
  48340. delete(m.clearedFields, wxcard.FieldAiInfo)
  48341. }
  48342. // SetIntro sets the "intro" field.
  48343. func (m *WxCardMutation) SetIntro(s string) {
  48344. m.intro = &s
  48345. }
  48346. // Intro returns the value of the "intro" field in the mutation.
  48347. func (m *WxCardMutation) Intro() (r string, exists bool) {
  48348. v := m.intro
  48349. if v == nil {
  48350. return
  48351. }
  48352. return *v, true
  48353. }
  48354. // OldIntro returns the old "intro" field's value of the WxCard entity.
  48355. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48357. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  48358. if !m.op.Is(OpUpdateOne) {
  48359. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  48360. }
  48361. if m.id == nil || m.oldValue == nil {
  48362. return v, errors.New("OldIntro requires an ID field in the mutation")
  48363. }
  48364. oldValue, err := m.oldValue(ctx)
  48365. if err != nil {
  48366. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  48367. }
  48368. return oldValue.Intro, nil
  48369. }
  48370. // ClearIntro clears the value of the "intro" field.
  48371. func (m *WxCardMutation) ClearIntro() {
  48372. m.intro = nil
  48373. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  48374. }
  48375. // IntroCleared returns if the "intro" field was cleared in this mutation.
  48376. func (m *WxCardMutation) IntroCleared() bool {
  48377. _, ok := m.clearedFields[wxcard.FieldIntro]
  48378. return ok
  48379. }
  48380. // ResetIntro resets all changes to the "intro" field.
  48381. func (m *WxCardMutation) ResetIntro() {
  48382. m.intro = nil
  48383. delete(m.clearedFields, wxcard.FieldIntro)
  48384. }
  48385. // Where appends a list predicates to the WxCardMutation builder.
  48386. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  48387. m.predicates = append(m.predicates, ps...)
  48388. }
  48389. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  48390. // users can use type-assertion to append predicates that do not depend on any generated package.
  48391. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  48392. p := make([]predicate.WxCard, len(ps))
  48393. for i := range ps {
  48394. p[i] = ps[i]
  48395. }
  48396. m.Where(p...)
  48397. }
  48398. // Op returns the operation name.
  48399. func (m *WxCardMutation) Op() Op {
  48400. return m.op
  48401. }
  48402. // SetOp allows setting the mutation operation.
  48403. func (m *WxCardMutation) SetOp(op Op) {
  48404. m.op = op
  48405. }
  48406. // Type returns the node type of this mutation (WxCard).
  48407. func (m *WxCardMutation) Type() string {
  48408. return m.typ
  48409. }
  48410. // Fields returns all fields that were changed during this mutation. Note that in
  48411. // order to get all numeric fields that were incremented/decremented, call
  48412. // AddedFields().
  48413. func (m *WxCardMutation) Fields() []string {
  48414. fields := make([]string, 0, 18)
  48415. if m.created_at != nil {
  48416. fields = append(fields, wxcard.FieldCreatedAt)
  48417. }
  48418. if m.updated_at != nil {
  48419. fields = append(fields, wxcard.FieldUpdatedAt)
  48420. }
  48421. if m.deleted_at != nil {
  48422. fields = append(fields, wxcard.FieldDeletedAt)
  48423. }
  48424. if m.user_id != nil {
  48425. fields = append(fields, wxcard.FieldUserID)
  48426. }
  48427. if m.wx_user_id != nil {
  48428. fields = append(fields, wxcard.FieldWxUserID)
  48429. }
  48430. if m.avatar != nil {
  48431. fields = append(fields, wxcard.FieldAvatar)
  48432. }
  48433. if m.logo != nil {
  48434. fields = append(fields, wxcard.FieldLogo)
  48435. }
  48436. if m.name != nil {
  48437. fields = append(fields, wxcard.FieldName)
  48438. }
  48439. if m.company != nil {
  48440. fields = append(fields, wxcard.FieldCompany)
  48441. }
  48442. if m.address != nil {
  48443. fields = append(fields, wxcard.FieldAddress)
  48444. }
  48445. if m.phone != nil {
  48446. fields = append(fields, wxcard.FieldPhone)
  48447. }
  48448. if m.official_account != nil {
  48449. fields = append(fields, wxcard.FieldOfficialAccount)
  48450. }
  48451. if m.wechat_account != nil {
  48452. fields = append(fields, wxcard.FieldWechatAccount)
  48453. }
  48454. if m.email != nil {
  48455. fields = append(fields, wxcard.FieldEmail)
  48456. }
  48457. if m.api_base != nil {
  48458. fields = append(fields, wxcard.FieldAPIBase)
  48459. }
  48460. if m.api_key != nil {
  48461. fields = append(fields, wxcard.FieldAPIKey)
  48462. }
  48463. if m.ai_info != nil {
  48464. fields = append(fields, wxcard.FieldAiInfo)
  48465. }
  48466. if m.intro != nil {
  48467. fields = append(fields, wxcard.FieldIntro)
  48468. }
  48469. return fields
  48470. }
  48471. // Field returns the value of a field with the given name. The second boolean
  48472. // return value indicates that this field was not set, or was not defined in the
  48473. // schema.
  48474. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  48475. switch name {
  48476. case wxcard.FieldCreatedAt:
  48477. return m.CreatedAt()
  48478. case wxcard.FieldUpdatedAt:
  48479. return m.UpdatedAt()
  48480. case wxcard.FieldDeletedAt:
  48481. return m.DeletedAt()
  48482. case wxcard.FieldUserID:
  48483. return m.UserID()
  48484. case wxcard.FieldWxUserID:
  48485. return m.WxUserID()
  48486. case wxcard.FieldAvatar:
  48487. return m.Avatar()
  48488. case wxcard.FieldLogo:
  48489. return m.Logo()
  48490. case wxcard.FieldName:
  48491. return m.Name()
  48492. case wxcard.FieldCompany:
  48493. return m.Company()
  48494. case wxcard.FieldAddress:
  48495. return m.Address()
  48496. case wxcard.FieldPhone:
  48497. return m.Phone()
  48498. case wxcard.FieldOfficialAccount:
  48499. return m.OfficialAccount()
  48500. case wxcard.FieldWechatAccount:
  48501. return m.WechatAccount()
  48502. case wxcard.FieldEmail:
  48503. return m.Email()
  48504. case wxcard.FieldAPIBase:
  48505. return m.APIBase()
  48506. case wxcard.FieldAPIKey:
  48507. return m.APIKey()
  48508. case wxcard.FieldAiInfo:
  48509. return m.AiInfo()
  48510. case wxcard.FieldIntro:
  48511. return m.Intro()
  48512. }
  48513. return nil, false
  48514. }
  48515. // OldField returns the old value of the field from the database. An error is
  48516. // returned if the mutation operation is not UpdateOne, or the query to the
  48517. // database failed.
  48518. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  48519. switch name {
  48520. case wxcard.FieldCreatedAt:
  48521. return m.OldCreatedAt(ctx)
  48522. case wxcard.FieldUpdatedAt:
  48523. return m.OldUpdatedAt(ctx)
  48524. case wxcard.FieldDeletedAt:
  48525. return m.OldDeletedAt(ctx)
  48526. case wxcard.FieldUserID:
  48527. return m.OldUserID(ctx)
  48528. case wxcard.FieldWxUserID:
  48529. return m.OldWxUserID(ctx)
  48530. case wxcard.FieldAvatar:
  48531. return m.OldAvatar(ctx)
  48532. case wxcard.FieldLogo:
  48533. return m.OldLogo(ctx)
  48534. case wxcard.FieldName:
  48535. return m.OldName(ctx)
  48536. case wxcard.FieldCompany:
  48537. return m.OldCompany(ctx)
  48538. case wxcard.FieldAddress:
  48539. return m.OldAddress(ctx)
  48540. case wxcard.FieldPhone:
  48541. return m.OldPhone(ctx)
  48542. case wxcard.FieldOfficialAccount:
  48543. return m.OldOfficialAccount(ctx)
  48544. case wxcard.FieldWechatAccount:
  48545. return m.OldWechatAccount(ctx)
  48546. case wxcard.FieldEmail:
  48547. return m.OldEmail(ctx)
  48548. case wxcard.FieldAPIBase:
  48549. return m.OldAPIBase(ctx)
  48550. case wxcard.FieldAPIKey:
  48551. return m.OldAPIKey(ctx)
  48552. case wxcard.FieldAiInfo:
  48553. return m.OldAiInfo(ctx)
  48554. case wxcard.FieldIntro:
  48555. return m.OldIntro(ctx)
  48556. }
  48557. return nil, fmt.Errorf("unknown WxCard field %s", name)
  48558. }
  48559. // SetField sets the value of a field with the given name. It returns an error if
  48560. // the field is not defined in the schema, or if the type mismatched the field
  48561. // type.
  48562. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  48563. switch name {
  48564. case wxcard.FieldCreatedAt:
  48565. v, ok := value.(time.Time)
  48566. if !ok {
  48567. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48568. }
  48569. m.SetCreatedAt(v)
  48570. return nil
  48571. case wxcard.FieldUpdatedAt:
  48572. v, ok := value.(time.Time)
  48573. if !ok {
  48574. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48575. }
  48576. m.SetUpdatedAt(v)
  48577. return nil
  48578. case wxcard.FieldDeletedAt:
  48579. v, ok := value.(time.Time)
  48580. if !ok {
  48581. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48582. }
  48583. m.SetDeletedAt(v)
  48584. return nil
  48585. case wxcard.FieldUserID:
  48586. v, ok := value.(uint64)
  48587. if !ok {
  48588. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48589. }
  48590. m.SetUserID(v)
  48591. return nil
  48592. case wxcard.FieldWxUserID:
  48593. v, ok := value.(uint64)
  48594. if !ok {
  48595. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48596. }
  48597. m.SetWxUserID(v)
  48598. return nil
  48599. case wxcard.FieldAvatar:
  48600. v, ok := value.(string)
  48601. if !ok {
  48602. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48603. }
  48604. m.SetAvatar(v)
  48605. return nil
  48606. case wxcard.FieldLogo:
  48607. v, ok := value.(string)
  48608. if !ok {
  48609. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48610. }
  48611. m.SetLogo(v)
  48612. return nil
  48613. case wxcard.FieldName:
  48614. v, ok := value.(string)
  48615. if !ok {
  48616. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48617. }
  48618. m.SetName(v)
  48619. return nil
  48620. case wxcard.FieldCompany:
  48621. v, ok := value.(string)
  48622. if !ok {
  48623. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48624. }
  48625. m.SetCompany(v)
  48626. return nil
  48627. case wxcard.FieldAddress:
  48628. v, ok := value.(string)
  48629. if !ok {
  48630. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48631. }
  48632. m.SetAddress(v)
  48633. return nil
  48634. case wxcard.FieldPhone:
  48635. v, ok := value.(string)
  48636. if !ok {
  48637. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48638. }
  48639. m.SetPhone(v)
  48640. return nil
  48641. case wxcard.FieldOfficialAccount:
  48642. v, ok := value.(string)
  48643. if !ok {
  48644. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48645. }
  48646. m.SetOfficialAccount(v)
  48647. return nil
  48648. case wxcard.FieldWechatAccount:
  48649. v, ok := value.(string)
  48650. if !ok {
  48651. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48652. }
  48653. m.SetWechatAccount(v)
  48654. return nil
  48655. case wxcard.FieldEmail:
  48656. v, ok := value.(string)
  48657. if !ok {
  48658. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48659. }
  48660. m.SetEmail(v)
  48661. return nil
  48662. case wxcard.FieldAPIBase:
  48663. v, ok := value.(string)
  48664. if !ok {
  48665. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48666. }
  48667. m.SetAPIBase(v)
  48668. return nil
  48669. case wxcard.FieldAPIKey:
  48670. v, ok := value.(string)
  48671. if !ok {
  48672. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48673. }
  48674. m.SetAPIKey(v)
  48675. return nil
  48676. case wxcard.FieldAiInfo:
  48677. v, ok := value.(string)
  48678. if !ok {
  48679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48680. }
  48681. m.SetAiInfo(v)
  48682. return nil
  48683. case wxcard.FieldIntro:
  48684. v, ok := value.(string)
  48685. if !ok {
  48686. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48687. }
  48688. m.SetIntro(v)
  48689. return nil
  48690. }
  48691. return fmt.Errorf("unknown WxCard field %s", name)
  48692. }
  48693. // AddedFields returns all numeric fields that were incremented/decremented during
  48694. // this mutation.
  48695. func (m *WxCardMutation) AddedFields() []string {
  48696. var fields []string
  48697. if m.adduser_id != nil {
  48698. fields = append(fields, wxcard.FieldUserID)
  48699. }
  48700. if m.addwx_user_id != nil {
  48701. fields = append(fields, wxcard.FieldWxUserID)
  48702. }
  48703. return fields
  48704. }
  48705. // AddedField returns the numeric value that was incremented/decremented on a field
  48706. // with the given name. The second boolean return value indicates that this field
  48707. // was not set, or was not defined in the schema.
  48708. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  48709. switch name {
  48710. case wxcard.FieldUserID:
  48711. return m.AddedUserID()
  48712. case wxcard.FieldWxUserID:
  48713. return m.AddedWxUserID()
  48714. }
  48715. return nil, false
  48716. }
  48717. // AddField adds the value to the field with the given name. It returns an error if
  48718. // the field is not defined in the schema, or if the type mismatched the field
  48719. // type.
  48720. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  48721. switch name {
  48722. case wxcard.FieldUserID:
  48723. v, ok := value.(int64)
  48724. if !ok {
  48725. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48726. }
  48727. m.AddUserID(v)
  48728. return nil
  48729. case wxcard.FieldWxUserID:
  48730. v, ok := value.(int64)
  48731. if !ok {
  48732. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48733. }
  48734. m.AddWxUserID(v)
  48735. return nil
  48736. }
  48737. return fmt.Errorf("unknown WxCard numeric field %s", name)
  48738. }
  48739. // ClearedFields returns all nullable fields that were cleared during this
  48740. // mutation.
  48741. func (m *WxCardMutation) ClearedFields() []string {
  48742. var fields []string
  48743. if m.FieldCleared(wxcard.FieldDeletedAt) {
  48744. fields = append(fields, wxcard.FieldDeletedAt)
  48745. }
  48746. if m.FieldCleared(wxcard.FieldUserID) {
  48747. fields = append(fields, wxcard.FieldUserID)
  48748. }
  48749. if m.FieldCleared(wxcard.FieldWxUserID) {
  48750. fields = append(fields, wxcard.FieldWxUserID)
  48751. }
  48752. if m.FieldCleared(wxcard.FieldEmail) {
  48753. fields = append(fields, wxcard.FieldEmail)
  48754. }
  48755. if m.FieldCleared(wxcard.FieldAPIBase) {
  48756. fields = append(fields, wxcard.FieldAPIBase)
  48757. }
  48758. if m.FieldCleared(wxcard.FieldAPIKey) {
  48759. fields = append(fields, wxcard.FieldAPIKey)
  48760. }
  48761. if m.FieldCleared(wxcard.FieldAiInfo) {
  48762. fields = append(fields, wxcard.FieldAiInfo)
  48763. }
  48764. if m.FieldCleared(wxcard.FieldIntro) {
  48765. fields = append(fields, wxcard.FieldIntro)
  48766. }
  48767. return fields
  48768. }
  48769. // FieldCleared returns a boolean indicating if a field with the given name was
  48770. // cleared in this mutation.
  48771. func (m *WxCardMutation) FieldCleared(name string) bool {
  48772. _, ok := m.clearedFields[name]
  48773. return ok
  48774. }
  48775. // ClearField clears the value of the field with the given name. It returns an
  48776. // error if the field is not defined in the schema.
  48777. func (m *WxCardMutation) ClearField(name string) error {
  48778. switch name {
  48779. case wxcard.FieldDeletedAt:
  48780. m.ClearDeletedAt()
  48781. return nil
  48782. case wxcard.FieldUserID:
  48783. m.ClearUserID()
  48784. return nil
  48785. case wxcard.FieldWxUserID:
  48786. m.ClearWxUserID()
  48787. return nil
  48788. case wxcard.FieldEmail:
  48789. m.ClearEmail()
  48790. return nil
  48791. case wxcard.FieldAPIBase:
  48792. m.ClearAPIBase()
  48793. return nil
  48794. case wxcard.FieldAPIKey:
  48795. m.ClearAPIKey()
  48796. return nil
  48797. case wxcard.FieldAiInfo:
  48798. m.ClearAiInfo()
  48799. return nil
  48800. case wxcard.FieldIntro:
  48801. m.ClearIntro()
  48802. return nil
  48803. }
  48804. return fmt.Errorf("unknown WxCard nullable field %s", name)
  48805. }
  48806. // ResetField resets all changes in the mutation for the field with the given name.
  48807. // It returns an error if the field is not defined in the schema.
  48808. func (m *WxCardMutation) ResetField(name string) error {
  48809. switch name {
  48810. case wxcard.FieldCreatedAt:
  48811. m.ResetCreatedAt()
  48812. return nil
  48813. case wxcard.FieldUpdatedAt:
  48814. m.ResetUpdatedAt()
  48815. return nil
  48816. case wxcard.FieldDeletedAt:
  48817. m.ResetDeletedAt()
  48818. return nil
  48819. case wxcard.FieldUserID:
  48820. m.ResetUserID()
  48821. return nil
  48822. case wxcard.FieldWxUserID:
  48823. m.ResetWxUserID()
  48824. return nil
  48825. case wxcard.FieldAvatar:
  48826. m.ResetAvatar()
  48827. return nil
  48828. case wxcard.FieldLogo:
  48829. m.ResetLogo()
  48830. return nil
  48831. case wxcard.FieldName:
  48832. m.ResetName()
  48833. return nil
  48834. case wxcard.FieldCompany:
  48835. m.ResetCompany()
  48836. return nil
  48837. case wxcard.FieldAddress:
  48838. m.ResetAddress()
  48839. return nil
  48840. case wxcard.FieldPhone:
  48841. m.ResetPhone()
  48842. return nil
  48843. case wxcard.FieldOfficialAccount:
  48844. m.ResetOfficialAccount()
  48845. return nil
  48846. case wxcard.FieldWechatAccount:
  48847. m.ResetWechatAccount()
  48848. return nil
  48849. case wxcard.FieldEmail:
  48850. m.ResetEmail()
  48851. return nil
  48852. case wxcard.FieldAPIBase:
  48853. m.ResetAPIBase()
  48854. return nil
  48855. case wxcard.FieldAPIKey:
  48856. m.ResetAPIKey()
  48857. return nil
  48858. case wxcard.FieldAiInfo:
  48859. m.ResetAiInfo()
  48860. return nil
  48861. case wxcard.FieldIntro:
  48862. m.ResetIntro()
  48863. return nil
  48864. }
  48865. return fmt.Errorf("unknown WxCard field %s", name)
  48866. }
  48867. // AddedEdges returns all edge names that were set/added in this mutation.
  48868. func (m *WxCardMutation) AddedEdges() []string {
  48869. edges := make([]string, 0, 0)
  48870. return edges
  48871. }
  48872. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  48873. // name in this mutation.
  48874. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  48875. return nil
  48876. }
  48877. // RemovedEdges returns all edge names that were removed in this mutation.
  48878. func (m *WxCardMutation) RemovedEdges() []string {
  48879. edges := make([]string, 0, 0)
  48880. return edges
  48881. }
  48882. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  48883. // the given name in this mutation.
  48884. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  48885. return nil
  48886. }
  48887. // ClearedEdges returns all edge names that were cleared in this mutation.
  48888. func (m *WxCardMutation) ClearedEdges() []string {
  48889. edges := make([]string, 0, 0)
  48890. return edges
  48891. }
  48892. // EdgeCleared returns a boolean which indicates if the edge with the given name
  48893. // was cleared in this mutation.
  48894. func (m *WxCardMutation) EdgeCleared(name string) bool {
  48895. return false
  48896. }
  48897. // ClearEdge clears the value of the edge with the given name. It returns an error
  48898. // if that edge is not defined in the schema.
  48899. func (m *WxCardMutation) ClearEdge(name string) error {
  48900. return fmt.Errorf("unknown WxCard unique edge %s", name)
  48901. }
  48902. // ResetEdge resets all changes to the edge with the given name in this mutation.
  48903. // It returns an error if the edge is not defined in the schema.
  48904. func (m *WxCardMutation) ResetEdge(name string) error {
  48905. return fmt.Errorf("unknown WxCard edge %s", name)
  48906. }
  48907. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  48908. type WxCardUserMutation struct {
  48909. config
  48910. op Op
  48911. typ string
  48912. id *uint64
  48913. created_at *time.Time
  48914. updated_at *time.Time
  48915. deleted_at *time.Time
  48916. wxid *string
  48917. account *string
  48918. avatar *string
  48919. nickname *string
  48920. remark *string
  48921. phone *string
  48922. open_id *string
  48923. union_id *string
  48924. session_key *string
  48925. is_vip *int
  48926. addis_vip *int
  48927. clearedFields map[string]struct{}
  48928. done bool
  48929. oldValue func(context.Context) (*WxCardUser, error)
  48930. predicates []predicate.WxCardUser
  48931. }
  48932. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  48933. // wxcarduserOption allows management of the mutation configuration using functional options.
  48934. type wxcarduserOption func(*WxCardUserMutation)
  48935. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  48936. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  48937. m := &WxCardUserMutation{
  48938. config: c,
  48939. op: op,
  48940. typ: TypeWxCardUser,
  48941. clearedFields: make(map[string]struct{}),
  48942. }
  48943. for _, opt := range opts {
  48944. opt(m)
  48945. }
  48946. return m
  48947. }
  48948. // withWxCardUserID sets the ID field of the mutation.
  48949. func withWxCardUserID(id uint64) wxcarduserOption {
  48950. return func(m *WxCardUserMutation) {
  48951. var (
  48952. err error
  48953. once sync.Once
  48954. value *WxCardUser
  48955. )
  48956. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  48957. once.Do(func() {
  48958. if m.done {
  48959. err = errors.New("querying old values post mutation is not allowed")
  48960. } else {
  48961. value, err = m.Client().WxCardUser.Get(ctx, id)
  48962. }
  48963. })
  48964. return value, err
  48965. }
  48966. m.id = &id
  48967. }
  48968. }
  48969. // withWxCardUser sets the old WxCardUser of the mutation.
  48970. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  48971. return func(m *WxCardUserMutation) {
  48972. m.oldValue = func(context.Context) (*WxCardUser, error) {
  48973. return node, nil
  48974. }
  48975. m.id = &node.ID
  48976. }
  48977. }
  48978. // Client returns a new `ent.Client` from the mutation. If the mutation was
  48979. // executed in a transaction (ent.Tx), a transactional client is returned.
  48980. func (m WxCardUserMutation) Client() *Client {
  48981. client := &Client{config: m.config}
  48982. client.init()
  48983. return client
  48984. }
  48985. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  48986. // it returns an error otherwise.
  48987. func (m WxCardUserMutation) Tx() (*Tx, error) {
  48988. if _, ok := m.driver.(*txDriver); !ok {
  48989. return nil, errors.New("ent: mutation is not running in a transaction")
  48990. }
  48991. tx := &Tx{config: m.config}
  48992. tx.init()
  48993. return tx, nil
  48994. }
  48995. // SetID sets the value of the id field. Note that this
  48996. // operation is only accepted on creation of WxCardUser entities.
  48997. func (m *WxCardUserMutation) SetID(id uint64) {
  48998. m.id = &id
  48999. }
  49000. // ID returns the ID value in the mutation. Note that the ID is only available
  49001. // if it was provided to the builder or after it was returned from the database.
  49002. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  49003. if m.id == nil {
  49004. return
  49005. }
  49006. return *m.id, true
  49007. }
  49008. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  49009. // That means, if the mutation is applied within a transaction with an isolation level such
  49010. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  49011. // or updated by the mutation.
  49012. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  49013. switch {
  49014. case m.op.Is(OpUpdateOne | OpDeleteOne):
  49015. id, exists := m.ID()
  49016. if exists {
  49017. return []uint64{id}, nil
  49018. }
  49019. fallthrough
  49020. case m.op.Is(OpUpdate | OpDelete):
  49021. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  49022. default:
  49023. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  49024. }
  49025. }
  49026. // SetCreatedAt sets the "created_at" field.
  49027. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  49028. m.created_at = &t
  49029. }
  49030. // CreatedAt returns the value of the "created_at" field in the mutation.
  49031. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  49032. v := m.created_at
  49033. if v == nil {
  49034. return
  49035. }
  49036. return *v, true
  49037. }
  49038. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  49039. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  49040. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49041. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  49042. if !m.op.Is(OpUpdateOne) {
  49043. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  49044. }
  49045. if m.id == nil || m.oldValue == nil {
  49046. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  49047. }
  49048. oldValue, err := m.oldValue(ctx)
  49049. if err != nil {
  49050. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  49051. }
  49052. return oldValue.CreatedAt, nil
  49053. }
  49054. // ResetCreatedAt resets all changes to the "created_at" field.
  49055. func (m *WxCardUserMutation) ResetCreatedAt() {
  49056. m.created_at = nil
  49057. }
  49058. // SetUpdatedAt sets the "updated_at" field.
  49059. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  49060. m.updated_at = &t
  49061. }
  49062. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  49063. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  49064. v := m.updated_at
  49065. if v == nil {
  49066. return
  49067. }
  49068. return *v, true
  49069. }
  49070. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  49071. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  49072. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49073. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  49074. if !m.op.Is(OpUpdateOne) {
  49075. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  49076. }
  49077. if m.id == nil || m.oldValue == nil {
  49078. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  49079. }
  49080. oldValue, err := m.oldValue(ctx)
  49081. if err != nil {
  49082. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  49083. }
  49084. return oldValue.UpdatedAt, nil
  49085. }
  49086. // ResetUpdatedAt resets all changes to the "updated_at" field.
  49087. func (m *WxCardUserMutation) ResetUpdatedAt() {
  49088. m.updated_at = nil
  49089. }
  49090. // SetDeletedAt sets the "deleted_at" field.
  49091. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  49092. m.deleted_at = &t
  49093. }
  49094. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  49095. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  49096. v := m.deleted_at
  49097. if v == nil {
  49098. return
  49099. }
  49100. return *v, true
  49101. }
  49102. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  49103. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  49104. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49105. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  49106. if !m.op.Is(OpUpdateOne) {
  49107. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  49108. }
  49109. if m.id == nil || m.oldValue == nil {
  49110. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  49111. }
  49112. oldValue, err := m.oldValue(ctx)
  49113. if err != nil {
  49114. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  49115. }
  49116. return oldValue.DeletedAt, nil
  49117. }
  49118. // ClearDeletedAt clears the value of the "deleted_at" field.
  49119. func (m *WxCardUserMutation) ClearDeletedAt() {
  49120. m.deleted_at = nil
  49121. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  49122. }
  49123. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  49124. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  49125. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  49126. return ok
  49127. }
  49128. // ResetDeletedAt resets all changes to the "deleted_at" field.
  49129. func (m *WxCardUserMutation) ResetDeletedAt() {
  49130. m.deleted_at = nil
  49131. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  49132. }
  49133. // SetWxid sets the "wxid" field.
  49134. func (m *WxCardUserMutation) SetWxid(s string) {
  49135. m.wxid = &s
  49136. }
  49137. // Wxid returns the value of the "wxid" field in the mutation.
  49138. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  49139. v := m.wxid
  49140. if v == nil {
  49141. return
  49142. }
  49143. return *v, true
  49144. }
  49145. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  49146. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  49147. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49148. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  49149. if !m.op.Is(OpUpdateOne) {
  49150. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  49151. }
  49152. if m.id == nil || m.oldValue == nil {
  49153. return v, errors.New("OldWxid requires an ID field in the mutation")
  49154. }
  49155. oldValue, err := m.oldValue(ctx)
  49156. if err != nil {
  49157. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  49158. }
  49159. return oldValue.Wxid, nil
  49160. }
  49161. // ResetWxid resets all changes to the "wxid" field.
  49162. func (m *WxCardUserMutation) ResetWxid() {
  49163. m.wxid = nil
  49164. }
  49165. // SetAccount sets the "account" field.
  49166. func (m *WxCardUserMutation) SetAccount(s string) {
  49167. m.account = &s
  49168. }
  49169. // Account returns the value of the "account" field in the mutation.
  49170. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  49171. v := m.account
  49172. if v == nil {
  49173. return
  49174. }
  49175. return *v, true
  49176. }
  49177. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  49178. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  49179. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49180. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  49181. if !m.op.Is(OpUpdateOne) {
  49182. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  49183. }
  49184. if m.id == nil || m.oldValue == nil {
  49185. return v, errors.New("OldAccount requires an ID field in the mutation")
  49186. }
  49187. oldValue, err := m.oldValue(ctx)
  49188. if err != nil {
  49189. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  49190. }
  49191. return oldValue.Account, nil
  49192. }
  49193. // ResetAccount resets all changes to the "account" field.
  49194. func (m *WxCardUserMutation) ResetAccount() {
  49195. m.account = nil
  49196. }
  49197. // SetAvatar sets the "avatar" field.
  49198. func (m *WxCardUserMutation) SetAvatar(s string) {
  49199. m.avatar = &s
  49200. }
  49201. // Avatar returns the value of the "avatar" field in the mutation.
  49202. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  49203. v := m.avatar
  49204. if v == nil {
  49205. return
  49206. }
  49207. return *v, true
  49208. }
  49209. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  49210. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  49211. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49212. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  49213. if !m.op.Is(OpUpdateOne) {
  49214. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  49215. }
  49216. if m.id == nil || m.oldValue == nil {
  49217. return v, errors.New("OldAvatar requires an ID field in the mutation")
  49218. }
  49219. oldValue, err := m.oldValue(ctx)
  49220. if err != nil {
  49221. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  49222. }
  49223. return oldValue.Avatar, nil
  49224. }
  49225. // ResetAvatar resets all changes to the "avatar" field.
  49226. func (m *WxCardUserMutation) ResetAvatar() {
  49227. m.avatar = nil
  49228. }
  49229. // SetNickname sets the "nickname" field.
  49230. func (m *WxCardUserMutation) SetNickname(s string) {
  49231. m.nickname = &s
  49232. }
  49233. // Nickname returns the value of the "nickname" field in the mutation.
  49234. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  49235. v := m.nickname
  49236. if v == nil {
  49237. return
  49238. }
  49239. return *v, true
  49240. }
  49241. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  49242. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  49243. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49244. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  49245. if !m.op.Is(OpUpdateOne) {
  49246. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  49247. }
  49248. if m.id == nil || m.oldValue == nil {
  49249. return v, errors.New("OldNickname requires an ID field in the mutation")
  49250. }
  49251. oldValue, err := m.oldValue(ctx)
  49252. if err != nil {
  49253. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  49254. }
  49255. return oldValue.Nickname, nil
  49256. }
  49257. // ResetNickname resets all changes to the "nickname" field.
  49258. func (m *WxCardUserMutation) ResetNickname() {
  49259. m.nickname = nil
  49260. }
  49261. // SetRemark sets the "remark" field.
  49262. func (m *WxCardUserMutation) SetRemark(s string) {
  49263. m.remark = &s
  49264. }
  49265. // Remark returns the value of the "remark" field in the mutation.
  49266. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  49267. v := m.remark
  49268. if v == nil {
  49269. return
  49270. }
  49271. return *v, true
  49272. }
  49273. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  49274. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  49275. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49276. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  49277. if !m.op.Is(OpUpdateOne) {
  49278. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  49279. }
  49280. if m.id == nil || m.oldValue == nil {
  49281. return v, errors.New("OldRemark requires an ID field in the mutation")
  49282. }
  49283. oldValue, err := m.oldValue(ctx)
  49284. if err != nil {
  49285. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  49286. }
  49287. return oldValue.Remark, nil
  49288. }
  49289. // ResetRemark resets all changes to the "remark" field.
  49290. func (m *WxCardUserMutation) ResetRemark() {
  49291. m.remark = nil
  49292. }
  49293. // SetPhone sets the "phone" field.
  49294. func (m *WxCardUserMutation) SetPhone(s string) {
  49295. m.phone = &s
  49296. }
  49297. // Phone returns the value of the "phone" field in the mutation.
  49298. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  49299. v := m.phone
  49300. if v == nil {
  49301. return
  49302. }
  49303. return *v, true
  49304. }
  49305. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  49306. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  49307. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49308. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  49309. if !m.op.Is(OpUpdateOne) {
  49310. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  49311. }
  49312. if m.id == nil || m.oldValue == nil {
  49313. return v, errors.New("OldPhone requires an ID field in the mutation")
  49314. }
  49315. oldValue, err := m.oldValue(ctx)
  49316. if err != nil {
  49317. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  49318. }
  49319. return oldValue.Phone, nil
  49320. }
  49321. // ResetPhone resets all changes to the "phone" field.
  49322. func (m *WxCardUserMutation) ResetPhone() {
  49323. m.phone = nil
  49324. }
  49325. // SetOpenID sets the "open_id" field.
  49326. func (m *WxCardUserMutation) SetOpenID(s string) {
  49327. m.open_id = &s
  49328. }
  49329. // OpenID returns the value of the "open_id" field in the mutation.
  49330. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  49331. v := m.open_id
  49332. if v == nil {
  49333. return
  49334. }
  49335. return *v, true
  49336. }
  49337. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  49338. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  49339. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49340. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  49341. if !m.op.Is(OpUpdateOne) {
  49342. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  49343. }
  49344. if m.id == nil || m.oldValue == nil {
  49345. return v, errors.New("OldOpenID requires an ID field in the mutation")
  49346. }
  49347. oldValue, err := m.oldValue(ctx)
  49348. if err != nil {
  49349. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  49350. }
  49351. return oldValue.OpenID, nil
  49352. }
  49353. // ResetOpenID resets all changes to the "open_id" field.
  49354. func (m *WxCardUserMutation) ResetOpenID() {
  49355. m.open_id = nil
  49356. }
  49357. // SetUnionID sets the "union_id" field.
  49358. func (m *WxCardUserMutation) SetUnionID(s string) {
  49359. m.union_id = &s
  49360. }
  49361. // UnionID returns the value of the "union_id" field in the mutation.
  49362. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  49363. v := m.union_id
  49364. if v == nil {
  49365. return
  49366. }
  49367. return *v, true
  49368. }
  49369. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  49370. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  49371. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49372. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  49373. if !m.op.Is(OpUpdateOne) {
  49374. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  49375. }
  49376. if m.id == nil || m.oldValue == nil {
  49377. return v, errors.New("OldUnionID requires an ID field in the mutation")
  49378. }
  49379. oldValue, err := m.oldValue(ctx)
  49380. if err != nil {
  49381. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  49382. }
  49383. return oldValue.UnionID, nil
  49384. }
  49385. // ResetUnionID resets all changes to the "union_id" field.
  49386. func (m *WxCardUserMutation) ResetUnionID() {
  49387. m.union_id = nil
  49388. }
  49389. // SetSessionKey sets the "session_key" field.
  49390. func (m *WxCardUserMutation) SetSessionKey(s string) {
  49391. m.session_key = &s
  49392. }
  49393. // SessionKey returns the value of the "session_key" field in the mutation.
  49394. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  49395. v := m.session_key
  49396. if v == nil {
  49397. return
  49398. }
  49399. return *v, true
  49400. }
  49401. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  49402. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  49403. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49404. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  49405. if !m.op.Is(OpUpdateOne) {
  49406. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  49407. }
  49408. if m.id == nil || m.oldValue == nil {
  49409. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  49410. }
  49411. oldValue, err := m.oldValue(ctx)
  49412. if err != nil {
  49413. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  49414. }
  49415. return oldValue.SessionKey, nil
  49416. }
  49417. // ResetSessionKey resets all changes to the "session_key" field.
  49418. func (m *WxCardUserMutation) ResetSessionKey() {
  49419. m.session_key = nil
  49420. }
  49421. // SetIsVip sets the "is_vip" field.
  49422. func (m *WxCardUserMutation) SetIsVip(i int) {
  49423. m.is_vip = &i
  49424. m.addis_vip = nil
  49425. }
  49426. // IsVip returns the value of the "is_vip" field in the mutation.
  49427. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  49428. v := m.is_vip
  49429. if v == nil {
  49430. return
  49431. }
  49432. return *v, true
  49433. }
  49434. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  49435. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  49436. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49437. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  49438. if !m.op.Is(OpUpdateOne) {
  49439. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  49440. }
  49441. if m.id == nil || m.oldValue == nil {
  49442. return v, errors.New("OldIsVip requires an ID field in the mutation")
  49443. }
  49444. oldValue, err := m.oldValue(ctx)
  49445. if err != nil {
  49446. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  49447. }
  49448. return oldValue.IsVip, nil
  49449. }
  49450. // AddIsVip adds i to the "is_vip" field.
  49451. func (m *WxCardUserMutation) AddIsVip(i int) {
  49452. if m.addis_vip != nil {
  49453. *m.addis_vip += i
  49454. } else {
  49455. m.addis_vip = &i
  49456. }
  49457. }
  49458. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  49459. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  49460. v := m.addis_vip
  49461. if v == nil {
  49462. return
  49463. }
  49464. return *v, true
  49465. }
  49466. // ResetIsVip resets all changes to the "is_vip" field.
  49467. func (m *WxCardUserMutation) ResetIsVip() {
  49468. m.is_vip = nil
  49469. m.addis_vip = nil
  49470. }
  49471. // Where appends a list predicates to the WxCardUserMutation builder.
  49472. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  49473. m.predicates = append(m.predicates, ps...)
  49474. }
  49475. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  49476. // users can use type-assertion to append predicates that do not depend on any generated package.
  49477. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  49478. p := make([]predicate.WxCardUser, len(ps))
  49479. for i := range ps {
  49480. p[i] = ps[i]
  49481. }
  49482. m.Where(p...)
  49483. }
  49484. // Op returns the operation name.
  49485. func (m *WxCardUserMutation) Op() Op {
  49486. return m.op
  49487. }
  49488. // SetOp allows setting the mutation operation.
  49489. func (m *WxCardUserMutation) SetOp(op Op) {
  49490. m.op = op
  49491. }
  49492. // Type returns the node type of this mutation (WxCardUser).
  49493. func (m *WxCardUserMutation) Type() string {
  49494. return m.typ
  49495. }
  49496. // Fields returns all fields that were changed during this mutation. Note that in
  49497. // order to get all numeric fields that were incremented/decremented, call
  49498. // AddedFields().
  49499. func (m *WxCardUserMutation) Fields() []string {
  49500. fields := make([]string, 0, 13)
  49501. if m.created_at != nil {
  49502. fields = append(fields, wxcarduser.FieldCreatedAt)
  49503. }
  49504. if m.updated_at != nil {
  49505. fields = append(fields, wxcarduser.FieldUpdatedAt)
  49506. }
  49507. if m.deleted_at != nil {
  49508. fields = append(fields, wxcarduser.FieldDeletedAt)
  49509. }
  49510. if m.wxid != nil {
  49511. fields = append(fields, wxcarduser.FieldWxid)
  49512. }
  49513. if m.account != nil {
  49514. fields = append(fields, wxcarduser.FieldAccount)
  49515. }
  49516. if m.avatar != nil {
  49517. fields = append(fields, wxcarduser.FieldAvatar)
  49518. }
  49519. if m.nickname != nil {
  49520. fields = append(fields, wxcarduser.FieldNickname)
  49521. }
  49522. if m.remark != nil {
  49523. fields = append(fields, wxcarduser.FieldRemark)
  49524. }
  49525. if m.phone != nil {
  49526. fields = append(fields, wxcarduser.FieldPhone)
  49527. }
  49528. if m.open_id != nil {
  49529. fields = append(fields, wxcarduser.FieldOpenID)
  49530. }
  49531. if m.union_id != nil {
  49532. fields = append(fields, wxcarduser.FieldUnionID)
  49533. }
  49534. if m.session_key != nil {
  49535. fields = append(fields, wxcarduser.FieldSessionKey)
  49536. }
  49537. if m.is_vip != nil {
  49538. fields = append(fields, wxcarduser.FieldIsVip)
  49539. }
  49540. return fields
  49541. }
  49542. // Field returns the value of a field with the given name. The second boolean
  49543. // return value indicates that this field was not set, or was not defined in the
  49544. // schema.
  49545. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  49546. switch name {
  49547. case wxcarduser.FieldCreatedAt:
  49548. return m.CreatedAt()
  49549. case wxcarduser.FieldUpdatedAt:
  49550. return m.UpdatedAt()
  49551. case wxcarduser.FieldDeletedAt:
  49552. return m.DeletedAt()
  49553. case wxcarduser.FieldWxid:
  49554. return m.Wxid()
  49555. case wxcarduser.FieldAccount:
  49556. return m.Account()
  49557. case wxcarduser.FieldAvatar:
  49558. return m.Avatar()
  49559. case wxcarduser.FieldNickname:
  49560. return m.Nickname()
  49561. case wxcarduser.FieldRemark:
  49562. return m.Remark()
  49563. case wxcarduser.FieldPhone:
  49564. return m.Phone()
  49565. case wxcarduser.FieldOpenID:
  49566. return m.OpenID()
  49567. case wxcarduser.FieldUnionID:
  49568. return m.UnionID()
  49569. case wxcarduser.FieldSessionKey:
  49570. return m.SessionKey()
  49571. case wxcarduser.FieldIsVip:
  49572. return m.IsVip()
  49573. }
  49574. return nil, false
  49575. }
  49576. // OldField returns the old value of the field from the database. An error is
  49577. // returned if the mutation operation is not UpdateOne, or the query to the
  49578. // database failed.
  49579. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  49580. switch name {
  49581. case wxcarduser.FieldCreatedAt:
  49582. return m.OldCreatedAt(ctx)
  49583. case wxcarduser.FieldUpdatedAt:
  49584. return m.OldUpdatedAt(ctx)
  49585. case wxcarduser.FieldDeletedAt:
  49586. return m.OldDeletedAt(ctx)
  49587. case wxcarduser.FieldWxid:
  49588. return m.OldWxid(ctx)
  49589. case wxcarduser.FieldAccount:
  49590. return m.OldAccount(ctx)
  49591. case wxcarduser.FieldAvatar:
  49592. return m.OldAvatar(ctx)
  49593. case wxcarduser.FieldNickname:
  49594. return m.OldNickname(ctx)
  49595. case wxcarduser.FieldRemark:
  49596. return m.OldRemark(ctx)
  49597. case wxcarduser.FieldPhone:
  49598. return m.OldPhone(ctx)
  49599. case wxcarduser.FieldOpenID:
  49600. return m.OldOpenID(ctx)
  49601. case wxcarduser.FieldUnionID:
  49602. return m.OldUnionID(ctx)
  49603. case wxcarduser.FieldSessionKey:
  49604. return m.OldSessionKey(ctx)
  49605. case wxcarduser.FieldIsVip:
  49606. return m.OldIsVip(ctx)
  49607. }
  49608. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  49609. }
  49610. // SetField sets the value of a field with the given name. It returns an error if
  49611. // the field is not defined in the schema, or if the type mismatched the field
  49612. // type.
  49613. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  49614. switch name {
  49615. case wxcarduser.FieldCreatedAt:
  49616. v, ok := value.(time.Time)
  49617. if !ok {
  49618. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49619. }
  49620. m.SetCreatedAt(v)
  49621. return nil
  49622. case wxcarduser.FieldUpdatedAt:
  49623. v, ok := value.(time.Time)
  49624. if !ok {
  49625. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49626. }
  49627. m.SetUpdatedAt(v)
  49628. return nil
  49629. case wxcarduser.FieldDeletedAt:
  49630. v, ok := value.(time.Time)
  49631. if !ok {
  49632. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49633. }
  49634. m.SetDeletedAt(v)
  49635. return nil
  49636. case wxcarduser.FieldWxid:
  49637. v, ok := value.(string)
  49638. if !ok {
  49639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49640. }
  49641. m.SetWxid(v)
  49642. return nil
  49643. case wxcarduser.FieldAccount:
  49644. v, ok := value.(string)
  49645. if !ok {
  49646. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49647. }
  49648. m.SetAccount(v)
  49649. return nil
  49650. case wxcarduser.FieldAvatar:
  49651. v, ok := value.(string)
  49652. if !ok {
  49653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49654. }
  49655. m.SetAvatar(v)
  49656. return nil
  49657. case wxcarduser.FieldNickname:
  49658. v, ok := value.(string)
  49659. if !ok {
  49660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49661. }
  49662. m.SetNickname(v)
  49663. return nil
  49664. case wxcarduser.FieldRemark:
  49665. v, ok := value.(string)
  49666. if !ok {
  49667. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49668. }
  49669. m.SetRemark(v)
  49670. return nil
  49671. case wxcarduser.FieldPhone:
  49672. v, ok := value.(string)
  49673. if !ok {
  49674. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49675. }
  49676. m.SetPhone(v)
  49677. return nil
  49678. case wxcarduser.FieldOpenID:
  49679. v, ok := value.(string)
  49680. if !ok {
  49681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49682. }
  49683. m.SetOpenID(v)
  49684. return nil
  49685. case wxcarduser.FieldUnionID:
  49686. v, ok := value.(string)
  49687. if !ok {
  49688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49689. }
  49690. m.SetUnionID(v)
  49691. return nil
  49692. case wxcarduser.FieldSessionKey:
  49693. v, ok := value.(string)
  49694. if !ok {
  49695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49696. }
  49697. m.SetSessionKey(v)
  49698. return nil
  49699. case wxcarduser.FieldIsVip:
  49700. v, ok := value.(int)
  49701. if !ok {
  49702. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49703. }
  49704. m.SetIsVip(v)
  49705. return nil
  49706. }
  49707. return fmt.Errorf("unknown WxCardUser field %s", name)
  49708. }
  49709. // AddedFields returns all numeric fields that were incremented/decremented during
  49710. // this mutation.
  49711. func (m *WxCardUserMutation) AddedFields() []string {
  49712. var fields []string
  49713. if m.addis_vip != nil {
  49714. fields = append(fields, wxcarduser.FieldIsVip)
  49715. }
  49716. return fields
  49717. }
  49718. // AddedField returns the numeric value that was incremented/decremented on a field
  49719. // with the given name. The second boolean return value indicates that this field
  49720. // was not set, or was not defined in the schema.
  49721. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  49722. switch name {
  49723. case wxcarduser.FieldIsVip:
  49724. return m.AddedIsVip()
  49725. }
  49726. return nil, false
  49727. }
  49728. // AddField adds the value to the field with the given name. It returns an error if
  49729. // the field is not defined in the schema, or if the type mismatched the field
  49730. // type.
  49731. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  49732. switch name {
  49733. case wxcarduser.FieldIsVip:
  49734. v, ok := value.(int)
  49735. if !ok {
  49736. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49737. }
  49738. m.AddIsVip(v)
  49739. return nil
  49740. }
  49741. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  49742. }
  49743. // ClearedFields returns all nullable fields that were cleared during this
  49744. // mutation.
  49745. func (m *WxCardUserMutation) ClearedFields() []string {
  49746. var fields []string
  49747. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  49748. fields = append(fields, wxcarduser.FieldDeletedAt)
  49749. }
  49750. return fields
  49751. }
  49752. // FieldCleared returns a boolean indicating if a field with the given name was
  49753. // cleared in this mutation.
  49754. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  49755. _, ok := m.clearedFields[name]
  49756. return ok
  49757. }
  49758. // ClearField clears the value of the field with the given name. It returns an
  49759. // error if the field is not defined in the schema.
  49760. func (m *WxCardUserMutation) ClearField(name string) error {
  49761. switch name {
  49762. case wxcarduser.FieldDeletedAt:
  49763. m.ClearDeletedAt()
  49764. return nil
  49765. }
  49766. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  49767. }
  49768. // ResetField resets all changes in the mutation for the field with the given name.
  49769. // It returns an error if the field is not defined in the schema.
  49770. func (m *WxCardUserMutation) ResetField(name string) error {
  49771. switch name {
  49772. case wxcarduser.FieldCreatedAt:
  49773. m.ResetCreatedAt()
  49774. return nil
  49775. case wxcarduser.FieldUpdatedAt:
  49776. m.ResetUpdatedAt()
  49777. return nil
  49778. case wxcarduser.FieldDeletedAt:
  49779. m.ResetDeletedAt()
  49780. return nil
  49781. case wxcarduser.FieldWxid:
  49782. m.ResetWxid()
  49783. return nil
  49784. case wxcarduser.FieldAccount:
  49785. m.ResetAccount()
  49786. return nil
  49787. case wxcarduser.FieldAvatar:
  49788. m.ResetAvatar()
  49789. return nil
  49790. case wxcarduser.FieldNickname:
  49791. m.ResetNickname()
  49792. return nil
  49793. case wxcarduser.FieldRemark:
  49794. m.ResetRemark()
  49795. return nil
  49796. case wxcarduser.FieldPhone:
  49797. m.ResetPhone()
  49798. return nil
  49799. case wxcarduser.FieldOpenID:
  49800. m.ResetOpenID()
  49801. return nil
  49802. case wxcarduser.FieldUnionID:
  49803. m.ResetUnionID()
  49804. return nil
  49805. case wxcarduser.FieldSessionKey:
  49806. m.ResetSessionKey()
  49807. return nil
  49808. case wxcarduser.FieldIsVip:
  49809. m.ResetIsVip()
  49810. return nil
  49811. }
  49812. return fmt.Errorf("unknown WxCardUser field %s", name)
  49813. }
  49814. // AddedEdges returns all edge names that were set/added in this mutation.
  49815. func (m *WxCardUserMutation) AddedEdges() []string {
  49816. edges := make([]string, 0, 0)
  49817. return edges
  49818. }
  49819. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  49820. // name in this mutation.
  49821. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  49822. return nil
  49823. }
  49824. // RemovedEdges returns all edge names that were removed in this mutation.
  49825. func (m *WxCardUserMutation) RemovedEdges() []string {
  49826. edges := make([]string, 0, 0)
  49827. return edges
  49828. }
  49829. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  49830. // the given name in this mutation.
  49831. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  49832. return nil
  49833. }
  49834. // ClearedEdges returns all edge names that were cleared in this mutation.
  49835. func (m *WxCardUserMutation) ClearedEdges() []string {
  49836. edges := make([]string, 0, 0)
  49837. return edges
  49838. }
  49839. // EdgeCleared returns a boolean which indicates if the edge with the given name
  49840. // was cleared in this mutation.
  49841. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  49842. return false
  49843. }
  49844. // ClearEdge clears the value of the edge with the given name. It returns an error
  49845. // if that edge is not defined in the schema.
  49846. func (m *WxCardUserMutation) ClearEdge(name string) error {
  49847. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  49848. }
  49849. // ResetEdge resets all changes to the edge with the given name in this mutation.
  49850. // It returns an error if the edge is not defined in the schema.
  49851. func (m *WxCardUserMutation) ResetEdge(name string) error {
  49852. return fmt.Errorf("unknown WxCardUser edge %s", name)
  49853. }
  49854. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  49855. type WxCardVisitMutation struct {
  49856. config
  49857. op Op
  49858. typ string
  49859. id *uint64
  49860. created_at *time.Time
  49861. updated_at *time.Time
  49862. deleted_at *time.Time
  49863. user_id *uint64
  49864. adduser_id *int64
  49865. bot_id *uint64
  49866. addbot_id *int64
  49867. bot_type *uint8
  49868. addbot_type *int8
  49869. clearedFields map[string]struct{}
  49870. done bool
  49871. oldValue func(context.Context) (*WxCardVisit, error)
  49872. predicates []predicate.WxCardVisit
  49873. }
  49874. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  49875. // wxcardvisitOption allows management of the mutation configuration using functional options.
  49876. type wxcardvisitOption func(*WxCardVisitMutation)
  49877. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  49878. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  49879. m := &WxCardVisitMutation{
  49880. config: c,
  49881. op: op,
  49882. typ: TypeWxCardVisit,
  49883. clearedFields: make(map[string]struct{}),
  49884. }
  49885. for _, opt := range opts {
  49886. opt(m)
  49887. }
  49888. return m
  49889. }
  49890. // withWxCardVisitID sets the ID field of the mutation.
  49891. func withWxCardVisitID(id uint64) wxcardvisitOption {
  49892. return func(m *WxCardVisitMutation) {
  49893. var (
  49894. err error
  49895. once sync.Once
  49896. value *WxCardVisit
  49897. )
  49898. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  49899. once.Do(func() {
  49900. if m.done {
  49901. err = errors.New("querying old values post mutation is not allowed")
  49902. } else {
  49903. value, err = m.Client().WxCardVisit.Get(ctx, id)
  49904. }
  49905. })
  49906. return value, err
  49907. }
  49908. m.id = &id
  49909. }
  49910. }
  49911. // withWxCardVisit sets the old WxCardVisit of the mutation.
  49912. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  49913. return func(m *WxCardVisitMutation) {
  49914. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  49915. return node, nil
  49916. }
  49917. m.id = &node.ID
  49918. }
  49919. }
  49920. // Client returns a new `ent.Client` from the mutation. If the mutation was
  49921. // executed in a transaction (ent.Tx), a transactional client is returned.
  49922. func (m WxCardVisitMutation) Client() *Client {
  49923. client := &Client{config: m.config}
  49924. client.init()
  49925. return client
  49926. }
  49927. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  49928. // it returns an error otherwise.
  49929. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  49930. if _, ok := m.driver.(*txDriver); !ok {
  49931. return nil, errors.New("ent: mutation is not running in a transaction")
  49932. }
  49933. tx := &Tx{config: m.config}
  49934. tx.init()
  49935. return tx, nil
  49936. }
  49937. // SetID sets the value of the id field. Note that this
  49938. // operation is only accepted on creation of WxCardVisit entities.
  49939. func (m *WxCardVisitMutation) SetID(id uint64) {
  49940. m.id = &id
  49941. }
  49942. // ID returns the ID value in the mutation. Note that the ID is only available
  49943. // if it was provided to the builder or after it was returned from the database.
  49944. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  49945. if m.id == nil {
  49946. return
  49947. }
  49948. return *m.id, true
  49949. }
  49950. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  49951. // That means, if the mutation is applied within a transaction with an isolation level such
  49952. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  49953. // or updated by the mutation.
  49954. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  49955. switch {
  49956. case m.op.Is(OpUpdateOne | OpDeleteOne):
  49957. id, exists := m.ID()
  49958. if exists {
  49959. return []uint64{id}, nil
  49960. }
  49961. fallthrough
  49962. case m.op.Is(OpUpdate | OpDelete):
  49963. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  49964. default:
  49965. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  49966. }
  49967. }
  49968. // SetCreatedAt sets the "created_at" field.
  49969. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  49970. m.created_at = &t
  49971. }
  49972. // CreatedAt returns the value of the "created_at" field in the mutation.
  49973. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  49974. v := m.created_at
  49975. if v == nil {
  49976. return
  49977. }
  49978. return *v, true
  49979. }
  49980. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  49981. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  49982. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49983. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  49984. if !m.op.Is(OpUpdateOne) {
  49985. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  49986. }
  49987. if m.id == nil || m.oldValue == nil {
  49988. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  49989. }
  49990. oldValue, err := m.oldValue(ctx)
  49991. if err != nil {
  49992. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  49993. }
  49994. return oldValue.CreatedAt, nil
  49995. }
  49996. // ResetCreatedAt resets all changes to the "created_at" field.
  49997. func (m *WxCardVisitMutation) ResetCreatedAt() {
  49998. m.created_at = nil
  49999. }
  50000. // SetUpdatedAt sets the "updated_at" field.
  50001. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  50002. m.updated_at = &t
  50003. }
  50004. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  50005. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  50006. v := m.updated_at
  50007. if v == nil {
  50008. return
  50009. }
  50010. return *v, true
  50011. }
  50012. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  50013. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  50014. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50015. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  50016. if !m.op.Is(OpUpdateOne) {
  50017. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  50018. }
  50019. if m.id == nil || m.oldValue == nil {
  50020. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  50021. }
  50022. oldValue, err := m.oldValue(ctx)
  50023. if err != nil {
  50024. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  50025. }
  50026. return oldValue.UpdatedAt, nil
  50027. }
  50028. // ResetUpdatedAt resets all changes to the "updated_at" field.
  50029. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  50030. m.updated_at = nil
  50031. }
  50032. // SetDeletedAt sets the "deleted_at" field.
  50033. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  50034. m.deleted_at = &t
  50035. }
  50036. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  50037. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  50038. v := m.deleted_at
  50039. if v == nil {
  50040. return
  50041. }
  50042. return *v, true
  50043. }
  50044. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  50045. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  50046. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50047. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  50048. if !m.op.Is(OpUpdateOne) {
  50049. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  50050. }
  50051. if m.id == nil || m.oldValue == nil {
  50052. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  50053. }
  50054. oldValue, err := m.oldValue(ctx)
  50055. if err != nil {
  50056. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  50057. }
  50058. return oldValue.DeletedAt, nil
  50059. }
  50060. // ClearDeletedAt clears the value of the "deleted_at" field.
  50061. func (m *WxCardVisitMutation) ClearDeletedAt() {
  50062. m.deleted_at = nil
  50063. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  50064. }
  50065. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  50066. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  50067. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  50068. return ok
  50069. }
  50070. // ResetDeletedAt resets all changes to the "deleted_at" field.
  50071. func (m *WxCardVisitMutation) ResetDeletedAt() {
  50072. m.deleted_at = nil
  50073. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  50074. }
  50075. // SetUserID sets the "user_id" field.
  50076. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  50077. m.user_id = &u
  50078. m.adduser_id = nil
  50079. }
  50080. // UserID returns the value of the "user_id" field in the mutation.
  50081. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  50082. v := m.user_id
  50083. if v == nil {
  50084. return
  50085. }
  50086. return *v, true
  50087. }
  50088. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  50089. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  50090. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50091. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  50092. if !m.op.Is(OpUpdateOne) {
  50093. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  50094. }
  50095. if m.id == nil || m.oldValue == nil {
  50096. return v, errors.New("OldUserID requires an ID field in the mutation")
  50097. }
  50098. oldValue, err := m.oldValue(ctx)
  50099. if err != nil {
  50100. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  50101. }
  50102. return oldValue.UserID, nil
  50103. }
  50104. // AddUserID adds u to the "user_id" field.
  50105. func (m *WxCardVisitMutation) AddUserID(u int64) {
  50106. if m.adduser_id != nil {
  50107. *m.adduser_id += u
  50108. } else {
  50109. m.adduser_id = &u
  50110. }
  50111. }
  50112. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  50113. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  50114. v := m.adduser_id
  50115. if v == nil {
  50116. return
  50117. }
  50118. return *v, true
  50119. }
  50120. // ClearUserID clears the value of the "user_id" field.
  50121. func (m *WxCardVisitMutation) ClearUserID() {
  50122. m.user_id = nil
  50123. m.adduser_id = nil
  50124. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  50125. }
  50126. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  50127. func (m *WxCardVisitMutation) UserIDCleared() bool {
  50128. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  50129. return ok
  50130. }
  50131. // ResetUserID resets all changes to the "user_id" field.
  50132. func (m *WxCardVisitMutation) ResetUserID() {
  50133. m.user_id = nil
  50134. m.adduser_id = nil
  50135. delete(m.clearedFields, wxcardvisit.FieldUserID)
  50136. }
  50137. // SetBotID sets the "bot_id" field.
  50138. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  50139. m.bot_id = &u
  50140. m.addbot_id = nil
  50141. }
  50142. // BotID returns the value of the "bot_id" field in the mutation.
  50143. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  50144. v := m.bot_id
  50145. if v == nil {
  50146. return
  50147. }
  50148. return *v, true
  50149. }
  50150. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  50151. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  50152. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50153. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  50154. if !m.op.Is(OpUpdateOne) {
  50155. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  50156. }
  50157. if m.id == nil || m.oldValue == nil {
  50158. return v, errors.New("OldBotID requires an ID field in the mutation")
  50159. }
  50160. oldValue, err := m.oldValue(ctx)
  50161. if err != nil {
  50162. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  50163. }
  50164. return oldValue.BotID, nil
  50165. }
  50166. // AddBotID adds u to the "bot_id" field.
  50167. func (m *WxCardVisitMutation) AddBotID(u int64) {
  50168. if m.addbot_id != nil {
  50169. *m.addbot_id += u
  50170. } else {
  50171. m.addbot_id = &u
  50172. }
  50173. }
  50174. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  50175. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  50176. v := m.addbot_id
  50177. if v == nil {
  50178. return
  50179. }
  50180. return *v, true
  50181. }
  50182. // ResetBotID resets all changes to the "bot_id" field.
  50183. func (m *WxCardVisitMutation) ResetBotID() {
  50184. m.bot_id = nil
  50185. m.addbot_id = nil
  50186. }
  50187. // SetBotType sets the "bot_type" field.
  50188. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  50189. m.bot_type = &u
  50190. m.addbot_type = nil
  50191. }
  50192. // BotType returns the value of the "bot_type" field in the mutation.
  50193. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  50194. v := m.bot_type
  50195. if v == nil {
  50196. return
  50197. }
  50198. return *v, true
  50199. }
  50200. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  50201. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  50202. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50203. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  50204. if !m.op.Is(OpUpdateOne) {
  50205. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  50206. }
  50207. if m.id == nil || m.oldValue == nil {
  50208. return v, errors.New("OldBotType requires an ID field in the mutation")
  50209. }
  50210. oldValue, err := m.oldValue(ctx)
  50211. if err != nil {
  50212. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  50213. }
  50214. return oldValue.BotType, nil
  50215. }
  50216. // AddBotType adds u to the "bot_type" field.
  50217. func (m *WxCardVisitMutation) AddBotType(u int8) {
  50218. if m.addbot_type != nil {
  50219. *m.addbot_type += u
  50220. } else {
  50221. m.addbot_type = &u
  50222. }
  50223. }
  50224. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  50225. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  50226. v := m.addbot_type
  50227. if v == nil {
  50228. return
  50229. }
  50230. return *v, true
  50231. }
  50232. // ResetBotType resets all changes to the "bot_type" field.
  50233. func (m *WxCardVisitMutation) ResetBotType() {
  50234. m.bot_type = nil
  50235. m.addbot_type = nil
  50236. }
  50237. // Where appends a list predicates to the WxCardVisitMutation builder.
  50238. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  50239. m.predicates = append(m.predicates, ps...)
  50240. }
  50241. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  50242. // users can use type-assertion to append predicates that do not depend on any generated package.
  50243. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  50244. p := make([]predicate.WxCardVisit, len(ps))
  50245. for i := range ps {
  50246. p[i] = ps[i]
  50247. }
  50248. m.Where(p...)
  50249. }
  50250. // Op returns the operation name.
  50251. func (m *WxCardVisitMutation) Op() Op {
  50252. return m.op
  50253. }
  50254. // SetOp allows setting the mutation operation.
  50255. func (m *WxCardVisitMutation) SetOp(op Op) {
  50256. m.op = op
  50257. }
  50258. // Type returns the node type of this mutation (WxCardVisit).
  50259. func (m *WxCardVisitMutation) Type() string {
  50260. return m.typ
  50261. }
  50262. // Fields returns all fields that were changed during this mutation. Note that in
  50263. // order to get all numeric fields that were incremented/decremented, call
  50264. // AddedFields().
  50265. func (m *WxCardVisitMutation) Fields() []string {
  50266. fields := make([]string, 0, 6)
  50267. if m.created_at != nil {
  50268. fields = append(fields, wxcardvisit.FieldCreatedAt)
  50269. }
  50270. if m.updated_at != nil {
  50271. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  50272. }
  50273. if m.deleted_at != nil {
  50274. fields = append(fields, wxcardvisit.FieldDeletedAt)
  50275. }
  50276. if m.user_id != nil {
  50277. fields = append(fields, wxcardvisit.FieldUserID)
  50278. }
  50279. if m.bot_id != nil {
  50280. fields = append(fields, wxcardvisit.FieldBotID)
  50281. }
  50282. if m.bot_type != nil {
  50283. fields = append(fields, wxcardvisit.FieldBotType)
  50284. }
  50285. return fields
  50286. }
  50287. // Field returns the value of a field with the given name. The second boolean
  50288. // return value indicates that this field was not set, or was not defined in the
  50289. // schema.
  50290. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  50291. switch name {
  50292. case wxcardvisit.FieldCreatedAt:
  50293. return m.CreatedAt()
  50294. case wxcardvisit.FieldUpdatedAt:
  50295. return m.UpdatedAt()
  50296. case wxcardvisit.FieldDeletedAt:
  50297. return m.DeletedAt()
  50298. case wxcardvisit.FieldUserID:
  50299. return m.UserID()
  50300. case wxcardvisit.FieldBotID:
  50301. return m.BotID()
  50302. case wxcardvisit.FieldBotType:
  50303. return m.BotType()
  50304. }
  50305. return nil, false
  50306. }
  50307. // OldField returns the old value of the field from the database. An error is
  50308. // returned if the mutation operation is not UpdateOne, or the query to the
  50309. // database failed.
  50310. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  50311. switch name {
  50312. case wxcardvisit.FieldCreatedAt:
  50313. return m.OldCreatedAt(ctx)
  50314. case wxcardvisit.FieldUpdatedAt:
  50315. return m.OldUpdatedAt(ctx)
  50316. case wxcardvisit.FieldDeletedAt:
  50317. return m.OldDeletedAt(ctx)
  50318. case wxcardvisit.FieldUserID:
  50319. return m.OldUserID(ctx)
  50320. case wxcardvisit.FieldBotID:
  50321. return m.OldBotID(ctx)
  50322. case wxcardvisit.FieldBotType:
  50323. return m.OldBotType(ctx)
  50324. }
  50325. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  50326. }
  50327. // SetField sets the value of a field with the given name. It returns an error if
  50328. // the field is not defined in the schema, or if the type mismatched the field
  50329. // type.
  50330. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  50331. switch name {
  50332. case wxcardvisit.FieldCreatedAt:
  50333. v, ok := value.(time.Time)
  50334. if !ok {
  50335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50336. }
  50337. m.SetCreatedAt(v)
  50338. return nil
  50339. case wxcardvisit.FieldUpdatedAt:
  50340. v, ok := value.(time.Time)
  50341. if !ok {
  50342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50343. }
  50344. m.SetUpdatedAt(v)
  50345. return nil
  50346. case wxcardvisit.FieldDeletedAt:
  50347. v, ok := value.(time.Time)
  50348. if !ok {
  50349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50350. }
  50351. m.SetDeletedAt(v)
  50352. return nil
  50353. case wxcardvisit.FieldUserID:
  50354. v, ok := value.(uint64)
  50355. if !ok {
  50356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50357. }
  50358. m.SetUserID(v)
  50359. return nil
  50360. case wxcardvisit.FieldBotID:
  50361. v, ok := value.(uint64)
  50362. if !ok {
  50363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50364. }
  50365. m.SetBotID(v)
  50366. return nil
  50367. case wxcardvisit.FieldBotType:
  50368. v, ok := value.(uint8)
  50369. if !ok {
  50370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50371. }
  50372. m.SetBotType(v)
  50373. return nil
  50374. }
  50375. return fmt.Errorf("unknown WxCardVisit field %s", name)
  50376. }
  50377. // AddedFields returns all numeric fields that were incremented/decremented during
  50378. // this mutation.
  50379. func (m *WxCardVisitMutation) AddedFields() []string {
  50380. var fields []string
  50381. if m.adduser_id != nil {
  50382. fields = append(fields, wxcardvisit.FieldUserID)
  50383. }
  50384. if m.addbot_id != nil {
  50385. fields = append(fields, wxcardvisit.FieldBotID)
  50386. }
  50387. if m.addbot_type != nil {
  50388. fields = append(fields, wxcardvisit.FieldBotType)
  50389. }
  50390. return fields
  50391. }
  50392. // AddedField returns the numeric value that was incremented/decremented on a field
  50393. // with the given name. The second boolean return value indicates that this field
  50394. // was not set, or was not defined in the schema.
  50395. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  50396. switch name {
  50397. case wxcardvisit.FieldUserID:
  50398. return m.AddedUserID()
  50399. case wxcardvisit.FieldBotID:
  50400. return m.AddedBotID()
  50401. case wxcardvisit.FieldBotType:
  50402. return m.AddedBotType()
  50403. }
  50404. return nil, false
  50405. }
  50406. // AddField adds the value to the field with the given name. It returns an error if
  50407. // the field is not defined in the schema, or if the type mismatched the field
  50408. // type.
  50409. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  50410. switch name {
  50411. case wxcardvisit.FieldUserID:
  50412. v, ok := value.(int64)
  50413. if !ok {
  50414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50415. }
  50416. m.AddUserID(v)
  50417. return nil
  50418. case wxcardvisit.FieldBotID:
  50419. v, ok := value.(int64)
  50420. if !ok {
  50421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50422. }
  50423. m.AddBotID(v)
  50424. return nil
  50425. case wxcardvisit.FieldBotType:
  50426. v, ok := value.(int8)
  50427. if !ok {
  50428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50429. }
  50430. m.AddBotType(v)
  50431. return nil
  50432. }
  50433. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  50434. }
  50435. // ClearedFields returns all nullable fields that were cleared during this
  50436. // mutation.
  50437. func (m *WxCardVisitMutation) ClearedFields() []string {
  50438. var fields []string
  50439. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  50440. fields = append(fields, wxcardvisit.FieldDeletedAt)
  50441. }
  50442. if m.FieldCleared(wxcardvisit.FieldUserID) {
  50443. fields = append(fields, wxcardvisit.FieldUserID)
  50444. }
  50445. return fields
  50446. }
  50447. // FieldCleared returns a boolean indicating if a field with the given name was
  50448. // cleared in this mutation.
  50449. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  50450. _, ok := m.clearedFields[name]
  50451. return ok
  50452. }
  50453. // ClearField clears the value of the field with the given name. It returns an
  50454. // error if the field is not defined in the schema.
  50455. func (m *WxCardVisitMutation) ClearField(name string) error {
  50456. switch name {
  50457. case wxcardvisit.FieldDeletedAt:
  50458. m.ClearDeletedAt()
  50459. return nil
  50460. case wxcardvisit.FieldUserID:
  50461. m.ClearUserID()
  50462. return nil
  50463. }
  50464. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  50465. }
  50466. // ResetField resets all changes in the mutation for the field with the given name.
  50467. // It returns an error if the field is not defined in the schema.
  50468. func (m *WxCardVisitMutation) ResetField(name string) error {
  50469. switch name {
  50470. case wxcardvisit.FieldCreatedAt:
  50471. m.ResetCreatedAt()
  50472. return nil
  50473. case wxcardvisit.FieldUpdatedAt:
  50474. m.ResetUpdatedAt()
  50475. return nil
  50476. case wxcardvisit.FieldDeletedAt:
  50477. m.ResetDeletedAt()
  50478. return nil
  50479. case wxcardvisit.FieldUserID:
  50480. m.ResetUserID()
  50481. return nil
  50482. case wxcardvisit.FieldBotID:
  50483. m.ResetBotID()
  50484. return nil
  50485. case wxcardvisit.FieldBotType:
  50486. m.ResetBotType()
  50487. return nil
  50488. }
  50489. return fmt.Errorf("unknown WxCardVisit field %s", name)
  50490. }
  50491. // AddedEdges returns all edge names that were set/added in this mutation.
  50492. func (m *WxCardVisitMutation) AddedEdges() []string {
  50493. edges := make([]string, 0, 0)
  50494. return edges
  50495. }
  50496. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  50497. // name in this mutation.
  50498. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  50499. return nil
  50500. }
  50501. // RemovedEdges returns all edge names that were removed in this mutation.
  50502. func (m *WxCardVisitMutation) RemovedEdges() []string {
  50503. edges := make([]string, 0, 0)
  50504. return edges
  50505. }
  50506. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  50507. // the given name in this mutation.
  50508. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  50509. return nil
  50510. }
  50511. // ClearedEdges returns all edge names that were cleared in this mutation.
  50512. func (m *WxCardVisitMutation) ClearedEdges() []string {
  50513. edges := make([]string, 0, 0)
  50514. return edges
  50515. }
  50516. // EdgeCleared returns a boolean which indicates if the edge with the given name
  50517. // was cleared in this mutation.
  50518. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  50519. return false
  50520. }
  50521. // ClearEdge clears the value of the edge with the given name. It returns an error
  50522. // if that edge is not defined in the schema.
  50523. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  50524. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  50525. }
  50526. // ResetEdge resets all changes to the edge with the given name in this mutation.
  50527. // It returns an error if the edge is not defined in the schema.
  50528. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  50529. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  50530. }
  50531. // XunjiMutation represents an operation that mutates the Xunji nodes in the graph.
  50532. type XunjiMutation struct {
  50533. config
  50534. op Op
  50535. typ string
  50536. id *uint64
  50537. created_at *time.Time
  50538. updated_at *time.Time
  50539. status *uint8
  50540. addstatus *int8
  50541. deleted_at *time.Time
  50542. app_key *string
  50543. app_secret *string
  50544. token *string
  50545. encoding_key *string
  50546. organization_id *uint64
  50547. addorganization_id *int64
  50548. clearedFields map[string]struct{}
  50549. done bool
  50550. oldValue func(context.Context) (*Xunji, error)
  50551. predicates []predicate.Xunji
  50552. }
  50553. var _ ent.Mutation = (*XunjiMutation)(nil)
  50554. // xunjiOption allows management of the mutation configuration using functional options.
  50555. type xunjiOption func(*XunjiMutation)
  50556. // newXunjiMutation creates new mutation for the Xunji entity.
  50557. func newXunjiMutation(c config, op Op, opts ...xunjiOption) *XunjiMutation {
  50558. m := &XunjiMutation{
  50559. config: c,
  50560. op: op,
  50561. typ: TypeXunji,
  50562. clearedFields: make(map[string]struct{}),
  50563. }
  50564. for _, opt := range opts {
  50565. opt(m)
  50566. }
  50567. return m
  50568. }
  50569. // withXunjiID sets the ID field of the mutation.
  50570. func withXunjiID(id uint64) xunjiOption {
  50571. return func(m *XunjiMutation) {
  50572. var (
  50573. err error
  50574. once sync.Once
  50575. value *Xunji
  50576. )
  50577. m.oldValue = func(ctx context.Context) (*Xunji, error) {
  50578. once.Do(func() {
  50579. if m.done {
  50580. err = errors.New("querying old values post mutation is not allowed")
  50581. } else {
  50582. value, err = m.Client().Xunji.Get(ctx, id)
  50583. }
  50584. })
  50585. return value, err
  50586. }
  50587. m.id = &id
  50588. }
  50589. }
  50590. // withXunji sets the old Xunji of the mutation.
  50591. func withXunji(node *Xunji) xunjiOption {
  50592. return func(m *XunjiMutation) {
  50593. m.oldValue = func(context.Context) (*Xunji, error) {
  50594. return node, nil
  50595. }
  50596. m.id = &node.ID
  50597. }
  50598. }
  50599. // Client returns a new `ent.Client` from the mutation. If the mutation was
  50600. // executed in a transaction (ent.Tx), a transactional client is returned.
  50601. func (m XunjiMutation) Client() *Client {
  50602. client := &Client{config: m.config}
  50603. client.init()
  50604. return client
  50605. }
  50606. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  50607. // it returns an error otherwise.
  50608. func (m XunjiMutation) Tx() (*Tx, error) {
  50609. if _, ok := m.driver.(*txDriver); !ok {
  50610. return nil, errors.New("ent: mutation is not running in a transaction")
  50611. }
  50612. tx := &Tx{config: m.config}
  50613. tx.init()
  50614. return tx, nil
  50615. }
  50616. // SetID sets the value of the id field. Note that this
  50617. // operation is only accepted on creation of Xunji entities.
  50618. func (m *XunjiMutation) SetID(id uint64) {
  50619. m.id = &id
  50620. }
  50621. // ID returns the ID value in the mutation. Note that the ID is only available
  50622. // if it was provided to the builder or after it was returned from the database.
  50623. func (m *XunjiMutation) ID() (id uint64, exists bool) {
  50624. if m.id == nil {
  50625. return
  50626. }
  50627. return *m.id, true
  50628. }
  50629. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  50630. // That means, if the mutation is applied within a transaction with an isolation level such
  50631. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  50632. // or updated by the mutation.
  50633. func (m *XunjiMutation) IDs(ctx context.Context) ([]uint64, error) {
  50634. switch {
  50635. case m.op.Is(OpUpdateOne | OpDeleteOne):
  50636. id, exists := m.ID()
  50637. if exists {
  50638. return []uint64{id}, nil
  50639. }
  50640. fallthrough
  50641. case m.op.Is(OpUpdate | OpDelete):
  50642. return m.Client().Xunji.Query().Where(m.predicates...).IDs(ctx)
  50643. default:
  50644. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  50645. }
  50646. }
  50647. // SetCreatedAt sets the "created_at" field.
  50648. func (m *XunjiMutation) SetCreatedAt(t time.Time) {
  50649. m.created_at = &t
  50650. }
  50651. // CreatedAt returns the value of the "created_at" field in the mutation.
  50652. func (m *XunjiMutation) CreatedAt() (r time.Time, exists bool) {
  50653. v := m.created_at
  50654. if v == nil {
  50655. return
  50656. }
  50657. return *v, true
  50658. }
  50659. // OldCreatedAt returns the old "created_at" field's value of the Xunji entity.
  50660. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  50661. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50662. func (m *XunjiMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  50663. if !m.op.Is(OpUpdateOne) {
  50664. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  50665. }
  50666. if m.id == nil || m.oldValue == nil {
  50667. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  50668. }
  50669. oldValue, err := m.oldValue(ctx)
  50670. if err != nil {
  50671. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  50672. }
  50673. return oldValue.CreatedAt, nil
  50674. }
  50675. // ResetCreatedAt resets all changes to the "created_at" field.
  50676. func (m *XunjiMutation) ResetCreatedAt() {
  50677. m.created_at = nil
  50678. }
  50679. // SetUpdatedAt sets the "updated_at" field.
  50680. func (m *XunjiMutation) SetUpdatedAt(t time.Time) {
  50681. m.updated_at = &t
  50682. }
  50683. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  50684. func (m *XunjiMutation) UpdatedAt() (r time.Time, exists bool) {
  50685. v := m.updated_at
  50686. if v == nil {
  50687. return
  50688. }
  50689. return *v, true
  50690. }
  50691. // OldUpdatedAt returns the old "updated_at" field's value of the Xunji entity.
  50692. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  50693. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50694. func (m *XunjiMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  50695. if !m.op.Is(OpUpdateOne) {
  50696. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  50697. }
  50698. if m.id == nil || m.oldValue == nil {
  50699. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  50700. }
  50701. oldValue, err := m.oldValue(ctx)
  50702. if err != nil {
  50703. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  50704. }
  50705. return oldValue.UpdatedAt, nil
  50706. }
  50707. // ResetUpdatedAt resets all changes to the "updated_at" field.
  50708. func (m *XunjiMutation) ResetUpdatedAt() {
  50709. m.updated_at = nil
  50710. }
  50711. // SetStatus sets the "status" field.
  50712. func (m *XunjiMutation) SetStatus(u uint8) {
  50713. m.status = &u
  50714. m.addstatus = nil
  50715. }
  50716. // Status returns the value of the "status" field in the mutation.
  50717. func (m *XunjiMutation) Status() (r uint8, exists bool) {
  50718. v := m.status
  50719. if v == nil {
  50720. return
  50721. }
  50722. return *v, true
  50723. }
  50724. // OldStatus returns the old "status" field's value of the Xunji entity.
  50725. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  50726. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50727. func (m *XunjiMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  50728. if !m.op.Is(OpUpdateOne) {
  50729. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  50730. }
  50731. if m.id == nil || m.oldValue == nil {
  50732. return v, errors.New("OldStatus requires an ID field in the mutation")
  50733. }
  50734. oldValue, err := m.oldValue(ctx)
  50735. if err != nil {
  50736. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  50737. }
  50738. return oldValue.Status, nil
  50739. }
  50740. // AddStatus adds u to the "status" field.
  50741. func (m *XunjiMutation) AddStatus(u int8) {
  50742. if m.addstatus != nil {
  50743. *m.addstatus += u
  50744. } else {
  50745. m.addstatus = &u
  50746. }
  50747. }
  50748. // AddedStatus returns the value that was added to the "status" field in this mutation.
  50749. func (m *XunjiMutation) AddedStatus() (r int8, exists bool) {
  50750. v := m.addstatus
  50751. if v == nil {
  50752. return
  50753. }
  50754. return *v, true
  50755. }
  50756. // ClearStatus clears the value of the "status" field.
  50757. func (m *XunjiMutation) ClearStatus() {
  50758. m.status = nil
  50759. m.addstatus = nil
  50760. m.clearedFields[xunji.FieldStatus] = struct{}{}
  50761. }
  50762. // StatusCleared returns if the "status" field was cleared in this mutation.
  50763. func (m *XunjiMutation) StatusCleared() bool {
  50764. _, ok := m.clearedFields[xunji.FieldStatus]
  50765. return ok
  50766. }
  50767. // ResetStatus resets all changes to the "status" field.
  50768. func (m *XunjiMutation) ResetStatus() {
  50769. m.status = nil
  50770. m.addstatus = nil
  50771. delete(m.clearedFields, xunji.FieldStatus)
  50772. }
  50773. // SetDeletedAt sets the "deleted_at" field.
  50774. func (m *XunjiMutation) SetDeletedAt(t time.Time) {
  50775. m.deleted_at = &t
  50776. }
  50777. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  50778. func (m *XunjiMutation) DeletedAt() (r time.Time, exists bool) {
  50779. v := m.deleted_at
  50780. if v == nil {
  50781. return
  50782. }
  50783. return *v, true
  50784. }
  50785. // OldDeletedAt returns the old "deleted_at" field's value of the Xunji entity.
  50786. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  50787. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50788. func (m *XunjiMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  50789. if !m.op.Is(OpUpdateOne) {
  50790. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  50791. }
  50792. if m.id == nil || m.oldValue == nil {
  50793. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  50794. }
  50795. oldValue, err := m.oldValue(ctx)
  50796. if err != nil {
  50797. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  50798. }
  50799. return oldValue.DeletedAt, nil
  50800. }
  50801. // ClearDeletedAt clears the value of the "deleted_at" field.
  50802. func (m *XunjiMutation) ClearDeletedAt() {
  50803. m.deleted_at = nil
  50804. m.clearedFields[xunji.FieldDeletedAt] = struct{}{}
  50805. }
  50806. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  50807. func (m *XunjiMutation) DeletedAtCleared() bool {
  50808. _, ok := m.clearedFields[xunji.FieldDeletedAt]
  50809. return ok
  50810. }
  50811. // ResetDeletedAt resets all changes to the "deleted_at" field.
  50812. func (m *XunjiMutation) ResetDeletedAt() {
  50813. m.deleted_at = nil
  50814. delete(m.clearedFields, xunji.FieldDeletedAt)
  50815. }
  50816. // SetAppKey sets the "app_key" field.
  50817. func (m *XunjiMutation) SetAppKey(s string) {
  50818. m.app_key = &s
  50819. }
  50820. // AppKey returns the value of the "app_key" field in the mutation.
  50821. func (m *XunjiMutation) AppKey() (r string, exists bool) {
  50822. v := m.app_key
  50823. if v == nil {
  50824. return
  50825. }
  50826. return *v, true
  50827. }
  50828. // OldAppKey returns the old "app_key" field's value of the Xunji entity.
  50829. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  50830. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50831. func (m *XunjiMutation) OldAppKey(ctx context.Context) (v string, err error) {
  50832. if !m.op.Is(OpUpdateOne) {
  50833. return v, errors.New("OldAppKey is only allowed on UpdateOne operations")
  50834. }
  50835. if m.id == nil || m.oldValue == nil {
  50836. return v, errors.New("OldAppKey requires an ID field in the mutation")
  50837. }
  50838. oldValue, err := m.oldValue(ctx)
  50839. if err != nil {
  50840. return v, fmt.Errorf("querying old value for OldAppKey: %w", err)
  50841. }
  50842. return oldValue.AppKey, nil
  50843. }
  50844. // ClearAppKey clears the value of the "app_key" field.
  50845. func (m *XunjiMutation) ClearAppKey() {
  50846. m.app_key = nil
  50847. m.clearedFields[xunji.FieldAppKey] = struct{}{}
  50848. }
  50849. // AppKeyCleared returns if the "app_key" field was cleared in this mutation.
  50850. func (m *XunjiMutation) AppKeyCleared() bool {
  50851. _, ok := m.clearedFields[xunji.FieldAppKey]
  50852. return ok
  50853. }
  50854. // ResetAppKey resets all changes to the "app_key" field.
  50855. func (m *XunjiMutation) ResetAppKey() {
  50856. m.app_key = nil
  50857. delete(m.clearedFields, xunji.FieldAppKey)
  50858. }
  50859. // SetAppSecret sets the "app_secret" field.
  50860. func (m *XunjiMutation) SetAppSecret(s string) {
  50861. m.app_secret = &s
  50862. }
  50863. // AppSecret returns the value of the "app_secret" field in the mutation.
  50864. func (m *XunjiMutation) AppSecret() (r string, exists bool) {
  50865. v := m.app_secret
  50866. if v == nil {
  50867. return
  50868. }
  50869. return *v, true
  50870. }
  50871. // OldAppSecret returns the old "app_secret" field's value of the Xunji entity.
  50872. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  50873. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50874. func (m *XunjiMutation) OldAppSecret(ctx context.Context) (v string, err error) {
  50875. if !m.op.Is(OpUpdateOne) {
  50876. return v, errors.New("OldAppSecret is only allowed on UpdateOne operations")
  50877. }
  50878. if m.id == nil || m.oldValue == nil {
  50879. return v, errors.New("OldAppSecret requires an ID field in the mutation")
  50880. }
  50881. oldValue, err := m.oldValue(ctx)
  50882. if err != nil {
  50883. return v, fmt.Errorf("querying old value for OldAppSecret: %w", err)
  50884. }
  50885. return oldValue.AppSecret, nil
  50886. }
  50887. // ClearAppSecret clears the value of the "app_secret" field.
  50888. func (m *XunjiMutation) ClearAppSecret() {
  50889. m.app_secret = nil
  50890. m.clearedFields[xunji.FieldAppSecret] = struct{}{}
  50891. }
  50892. // AppSecretCleared returns if the "app_secret" field was cleared in this mutation.
  50893. func (m *XunjiMutation) AppSecretCleared() bool {
  50894. _, ok := m.clearedFields[xunji.FieldAppSecret]
  50895. return ok
  50896. }
  50897. // ResetAppSecret resets all changes to the "app_secret" field.
  50898. func (m *XunjiMutation) ResetAppSecret() {
  50899. m.app_secret = nil
  50900. delete(m.clearedFields, xunji.FieldAppSecret)
  50901. }
  50902. // SetToken sets the "token" field.
  50903. func (m *XunjiMutation) SetToken(s string) {
  50904. m.token = &s
  50905. }
  50906. // Token returns the value of the "token" field in the mutation.
  50907. func (m *XunjiMutation) Token() (r string, exists bool) {
  50908. v := m.token
  50909. if v == nil {
  50910. return
  50911. }
  50912. return *v, true
  50913. }
  50914. // OldToken returns the old "token" field's value of the Xunji entity.
  50915. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  50916. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50917. func (m *XunjiMutation) OldToken(ctx context.Context) (v string, err error) {
  50918. if !m.op.Is(OpUpdateOne) {
  50919. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  50920. }
  50921. if m.id == nil || m.oldValue == nil {
  50922. return v, errors.New("OldToken requires an ID field in the mutation")
  50923. }
  50924. oldValue, err := m.oldValue(ctx)
  50925. if err != nil {
  50926. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  50927. }
  50928. return oldValue.Token, nil
  50929. }
  50930. // ClearToken clears the value of the "token" field.
  50931. func (m *XunjiMutation) ClearToken() {
  50932. m.token = nil
  50933. m.clearedFields[xunji.FieldToken] = struct{}{}
  50934. }
  50935. // TokenCleared returns if the "token" field was cleared in this mutation.
  50936. func (m *XunjiMutation) TokenCleared() bool {
  50937. _, ok := m.clearedFields[xunji.FieldToken]
  50938. return ok
  50939. }
  50940. // ResetToken resets all changes to the "token" field.
  50941. func (m *XunjiMutation) ResetToken() {
  50942. m.token = nil
  50943. delete(m.clearedFields, xunji.FieldToken)
  50944. }
  50945. // SetEncodingKey sets the "encoding_key" field.
  50946. func (m *XunjiMutation) SetEncodingKey(s string) {
  50947. m.encoding_key = &s
  50948. }
  50949. // EncodingKey returns the value of the "encoding_key" field in the mutation.
  50950. func (m *XunjiMutation) EncodingKey() (r string, exists bool) {
  50951. v := m.encoding_key
  50952. if v == nil {
  50953. return
  50954. }
  50955. return *v, true
  50956. }
  50957. // OldEncodingKey returns the old "encoding_key" field's value of the Xunji entity.
  50958. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  50959. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50960. func (m *XunjiMutation) OldEncodingKey(ctx context.Context) (v string, err error) {
  50961. if !m.op.Is(OpUpdateOne) {
  50962. return v, errors.New("OldEncodingKey is only allowed on UpdateOne operations")
  50963. }
  50964. if m.id == nil || m.oldValue == nil {
  50965. return v, errors.New("OldEncodingKey requires an ID field in the mutation")
  50966. }
  50967. oldValue, err := m.oldValue(ctx)
  50968. if err != nil {
  50969. return v, fmt.Errorf("querying old value for OldEncodingKey: %w", err)
  50970. }
  50971. return oldValue.EncodingKey, nil
  50972. }
  50973. // ClearEncodingKey clears the value of the "encoding_key" field.
  50974. func (m *XunjiMutation) ClearEncodingKey() {
  50975. m.encoding_key = nil
  50976. m.clearedFields[xunji.FieldEncodingKey] = struct{}{}
  50977. }
  50978. // EncodingKeyCleared returns if the "encoding_key" field was cleared in this mutation.
  50979. func (m *XunjiMutation) EncodingKeyCleared() bool {
  50980. _, ok := m.clearedFields[xunji.FieldEncodingKey]
  50981. return ok
  50982. }
  50983. // ResetEncodingKey resets all changes to the "encoding_key" field.
  50984. func (m *XunjiMutation) ResetEncodingKey() {
  50985. m.encoding_key = nil
  50986. delete(m.clearedFields, xunji.FieldEncodingKey)
  50987. }
  50988. // SetOrganizationID sets the "organization_id" field.
  50989. func (m *XunjiMutation) SetOrganizationID(u uint64) {
  50990. m.organization_id = &u
  50991. m.addorganization_id = nil
  50992. }
  50993. // OrganizationID returns the value of the "organization_id" field in the mutation.
  50994. func (m *XunjiMutation) OrganizationID() (r uint64, exists bool) {
  50995. v := m.organization_id
  50996. if v == nil {
  50997. return
  50998. }
  50999. return *v, true
  51000. }
  51001. // OldOrganizationID returns the old "organization_id" field's value of the Xunji entity.
  51002. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51003. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51004. func (m *XunjiMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  51005. if !m.op.Is(OpUpdateOne) {
  51006. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  51007. }
  51008. if m.id == nil || m.oldValue == nil {
  51009. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  51010. }
  51011. oldValue, err := m.oldValue(ctx)
  51012. if err != nil {
  51013. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  51014. }
  51015. return oldValue.OrganizationID, nil
  51016. }
  51017. // AddOrganizationID adds u to the "organization_id" field.
  51018. func (m *XunjiMutation) AddOrganizationID(u int64) {
  51019. if m.addorganization_id != nil {
  51020. *m.addorganization_id += u
  51021. } else {
  51022. m.addorganization_id = &u
  51023. }
  51024. }
  51025. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  51026. func (m *XunjiMutation) AddedOrganizationID() (r int64, exists bool) {
  51027. v := m.addorganization_id
  51028. if v == nil {
  51029. return
  51030. }
  51031. return *v, true
  51032. }
  51033. // ResetOrganizationID resets all changes to the "organization_id" field.
  51034. func (m *XunjiMutation) ResetOrganizationID() {
  51035. m.organization_id = nil
  51036. m.addorganization_id = nil
  51037. }
  51038. // Where appends a list predicates to the XunjiMutation builder.
  51039. func (m *XunjiMutation) Where(ps ...predicate.Xunji) {
  51040. m.predicates = append(m.predicates, ps...)
  51041. }
  51042. // WhereP appends storage-level predicates to the XunjiMutation builder. Using this method,
  51043. // users can use type-assertion to append predicates that do not depend on any generated package.
  51044. func (m *XunjiMutation) WhereP(ps ...func(*sql.Selector)) {
  51045. p := make([]predicate.Xunji, len(ps))
  51046. for i := range ps {
  51047. p[i] = ps[i]
  51048. }
  51049. m.Where(p...)
  51050. }
  51051. // Op returns the operation name.
  51052. func (m *XunjiMutation) Op() Op {
  51053. return m.op
  51054. }
  51055. // SetOp allows setting the mutation operation.
  51056. func (m *XunjiMutation) SetOp(op Op) {
  51057. m.op = op
  51058. }
  51059. // Type returns the node type of this mutation (Xunji).
  51060. func (m *XunjiMutation) Type() string {
  51061. return m.typ
  51062. }
  51063. // Fields returns all fields that were changed during this mutation. Note that in
  51064. // order to get all numeric fields that were incremented/decremented, call
  51065. // AddedFields().
  51066. func (m *XunjiMutation) Fields() []string {
  51067. fields := make([]string, 0, 9)
  51068. if m.created_at != nil {
  51069. fields = append(fields, xunji.FieldCreatedAt)
  51070. }
  51071. if m.updated_at != nil {
  51072. fields = append(fields, xunji.FieldUpdatedAt)
  51073. }
  51074. if m.status != nil {
  51075. fields = append(fields, xunji.FieldStatus)
  51076. }
  51077. if m.deleted_at != nil {
  51078. fields = append(fields, xunji.FieldDeletedAt)
  51079. }
  51080. if m.app_key != nil {
  51081. fields = append(fields, xunji.FieldAppKey)
  51082. }
  51083. if m.app_secret != nil {
  51084. fields = append(fields, xunji.FieldAppSecret)
  51085. }
  51086. if m.token != nil {
  51087. fields = append(fields, xunji.FieldToken)
  51088. }
  51089. if m.encoding_key != nil {
  51090. fields = append(fields, xunji.FieldEncodingKey)
  51091. }
  51092. if m.organization_id != nil {
  51093. fields = append(fields, xunji.FieldOrganizationID)
  51094. }
  51095. return fields
  51096. }
  51097. // Field returns the value of a field with the given name. The second boolean
  51098. // return value indicates that this field was not set, or was not defined in the
  51099. // schema.
  51100. func (m *XunjiMutation) Field(name string) (ent.Value, bool) {
  51101. switch name {
  51102. case xunji.FieldCreatedAt:
  51103. return m.CreatedAt()
  51104. case xunji.FieldUpdatedAt:
  51105. return m.UpdatedAt()
  51106. case xunji.FieldStatus:
  51107. return m.Status()
  51108. case xunji.FieldDeletedAt:
  51109. return m.DeletedAt()
  51110. case xunji.FieldAppKey:
  51111. return m.AppKey()
  51112. case xunji.FieldAppSecret:
  51113. return m.AppSecret()
  51114. case xunji.FieldToken:
  51115. return m.Token()
  51116. case xunji.FieldEncodingKey:
  51117. return m.EncodingKey()
  51118. case xunji.FieldOrganizationID:
  51119. return m.OrganizationID()
  51120. }
  51121. return nil, false
  51122. }
  51123. // OldField returns the old value of the field from the database. An error is
  51124. // returned if the mutation operation is not UpdateOne, or the query to the
  51125. // database failed.
  51126. func (m *XunjiMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  51127. switch name {
  51128. case xunji.FieldCreatedAt:
  51129. return m.OldCreatedAt(ctx)
  51130. case xunji.FieldUpdatedAt:
  51131. return m.OldUpdatedAt(ctx)
  51132. case xunji.FieldStatus:
  51133. return m.OldStatus(ctx)
  51134. case xunji.FieldDeletedAt:
  51135. return m.OldDeletedAt(ctx)
  51136. case xunji.FieldAppKey:
  51137. return m.OldAppKey(ctx)
  51138. case xunji.FieldAppSecret:
  51139. return m.OldAppSecret(ctx)
  51140. case xunji.FieldToken:
  51141. return m.OldToken(ctx)
  51142. case xunji.FieldEncodingKey:
  51143. return m.OldEncodingKey(ctx)
  51144. case xunji.FieldOrganizationID:
  51145. return m.OldOrganizationID(ctx)
  51146. }
  51147. return nil, fmt.Errorf("unknown Xunji field %s", name)
  51148. }
  51149. // SetField sets the value of a field with the given name. It returns an error if
  51150. // the field is not defined in the schema, or if the type mismatched the field
  51151. // type.
  51152. func (m *XunjiMutation) SetField(name string, value ent.Value) error {
  51153. switch name {
  51154. case xunji.FieldCreatedAt:
  51155. v, ok := value.(time.Time)
  51156. if !ok {
  51157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51158. }
  51159. m.SetCreatedAt(v)
  51160. return nil
  51161. case xunji.FieldUpdatedAt:
  51162. v, ok := value.(time.Time)
  51163. if !ok {
  51164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51165. }
  51166. m.SetUpdatedAt(v)
  51167. return nil
  51168. case xunji.FieldStatus:
  51169. v, ok := value.(uint8)
  51170. if !ok {
  51171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51172. }
  51173. m.SetStatus(v)
  51174. return nil
  51175. case xunji.FieldDeletedAt:
  51176. v, ok := value.(time.Time)
  51177. if !ok {
  51178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51179. }
  51180. m.SetDeletedAt(v)
  51181. return nil
  51182. case xunji.FieldAppKey:
  51183. v, ok := value.(string)
  51184. if !ok {
  51185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51186. }
  51187. m.SetAppKey(v)
  51188. return nil
  51189. case xunji.FieldAppSecret:
  51190. v, ok := value.(string)
  51191. if !ok {
  51192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51193. }
  51194. m.SetAppSecret(v)
  51195. return nil
  51196. case xunji.FieldToken:
  51197. v, ok := value.(string)
  51198. if !ok {
  51199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51200. }
  51201. m.SetToken(v)
  51202. return nil
  51203. case xunji.FieldEncodingKey:
  51204. v, ok := value.(string)
  51205. if !ok {
  51206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51207. }
  51208. m.SetEncodingKey(v)
  51209. return nil
  51210. case xunji.FieldOrganizationID:
  51211. v, ok := value.(uint64)
  51212. if !ok {
  51213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51214. }
  51215. m.SetOrganizationID(v)
  51216. return nil
  51217. }
  51218. return fmt.Errorf("unknown Xunji field %s", name)
  51219. }
  51220. // AddedFields returns all numeric fields that were incremented/decremented during
  51221. // this mutation.
  51222. func (m *XunjiMutation) AddedFields() []string {
  51223. var fields []string
  51224. if m.addstatus != nil {
  51225. fields = append(fields, xunji.FieldStatus)
  51226. }
  51227. if m.addorganization_id != nil {
  51228. fields = append(fields, xunji.FieldOrganizationID)
  51229. }
  51230. return fields
  51231. }
  51232. // AddedField returns the numeric value that was incremented/decremented on a field
  51233. // with the given name. The second boolean return value indicates that this field
  51234. // was not set, or was not defined in the schema.
  51235. func (m *XunjiMutation) AddedField(name string) (ent.Value, bool) {
  51236. switch name {
  51237. case xunji.FieldStatus:
  51238. return m.AddedStatus()
  51239. case xunji.FieldOrganizationID:
  51240. return m.AddedOrganizationID()
  51241. }
  51242. return nil, false
  51243. }
  51244. // AddField adds the value to the field with the given name. It returns an error if
  51245. // the field is not defined in the schema, or if the type mismatched the field
  51246. // type.
  51247. func (m *XunjiMutation) AddField(name string, value ent.Value) error {
  51248. switch name {
  51249. case xunji.FieldStatus:
  51250. v, ok := value.(int8)
  51251. if !ok {
  51252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51253. }
  51254. m.AddStatus(v)
  51255. return nil
  51256. case xunji.FieldOrganizationID:
  51257. v, ok := value.(int64)
  51258. if !ok {
  51259. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51260. }
  51261. m.AddOrganizationID(v)
  51262. return nil
  51263. }
  51264. return fmt.Errorf("unknown Xunji numeric field %s", name)
  51265. }
  51266. // ClearedFields returns all nullable fields that were cleared during this
  51267. // mutation.
  51268. func (m *XunjiMutation) ClearedFields() []string {
  51269. var fields []string
  51270. if m.FieldCleared(xunji.FieldStatus) {
  51271. fields = append(fields, xunji.FieldStatus)
  51272. }
  51273. if m.FieldCleared(xunji.FieldDeletedAt) {
  51274. fields = append(fields, xunji.FieldDeletedAt)
  51275. }
  51276. if m.FieldCleared(xunji.FieldAppKey) {
  51277. fields = append(fields, xunji.FieldAppKey)
  51278. }
  51279. if m.FieldCleared(xunji.FieldAppSecret) {
  51280. fields = append(fields, xunji.FieldAppSecret)
  51281. }
  51282. if m.FieldCleared(xunji.FieldToken) {
  51283. fields = append(fields, xunji.FieldToken)
  51284. }
  51285. if m.FieldCleared(xunji.FieldEncodingKey) {
  51286. fields = append(fields, xunji.FieldEncodingKey)
  51287. }
  51288. return fields
  51289. }
  51290. // FieldCleared returns a boolean indicating if a field with the given name was
  51291. // cleared in this mutation.
  51292. func (m *XunjiMutation) FieldCleared(name string) bool {
  51293. _, ok := m.clearedFields[name]
  51294. return ok
  51295. }
  51296. // ClearField clears the value of the field with the given name. It returns an
  51297. // error if the field is not defined in the schema.
  51298. func (m *XunjiMutation) ClearField(name string) error {
  51299. switch name {
  51300. case xunji.FieldStatus:
  51301. m.ClearStatus()
  51302. return nil
  51303. case xunji.FieldDeletedAt:
  51304. m.ClearDeletedAt()
  51305. return nil
  51306. case xunji.FieldAppKey:
  51307. m.ClearAppKey()
  51308. return nil
  51309. case xunji.FieldAppSecret:
  51310. m.ClearAppSecret()
  51311. return nil
  51312. case xunji.FieldToken:
  51313. m.ClearToken()
  51314. return nil
  51315. case xunji.FieldEncodingKey:
  51316. m.ClearEncodingKey()
  51317. return nil
  51318. }
  51319. return fmt.Errorf("unknown Xunji nullable field %s", name)
  51320. }
  51321. // ResetField resets all changes in the mutation for the field with the given name.
  51322. // It returns an error if the field is not defined in the schema.
  51323. func (m *XunjiMutation) ResetField(name string) error {
  51324. switch name {
  51325. case xunji.FieldCreatedAt:
  51326. m.ResetCreatedAt()
  51327. return nil
  51328. case xunji.FieldUpdatedAt:
  51329. m.ResetUpdatedAt()
  51330. return nil
  51331. case xunji.FieldStatus:
  51332. m.ResetStatus()
  51333. return nil
  51334. case xunji.FieldDeletedAt:
  51335. m.ResetDeletedAt()
  51336. return nil
  51337. case xunji.FieldAppKey:
  51338. m.ResetAppKey()
  51339. return nil
  51340. case xunji.FieldAppSecret:
  51341. m.ResetAppSecret()
  51342. return nil
  51343. case xunji.FieldToken:
  51344. m.ResetToken()
  51345. return nil
  51346. case xunji.FieldEncodingKey:
  51347. m.ResetEncodingKey()
  51348. return nil
  51349. case xunji.FieldOrganizationID:
  51350. m.ResetOrganizationID()
  51351. return nil
  51352. }
  51353. return fmt.Errorf("unknown Xunji field %s", name)
  51354. }
  51355. // AddedEdges returns all edge names that were set/added in this mutation.
  51356. func (m *XunjiMutation) AddedEdges() []string {
  51357. edges := make([]string, 0, 0)
  51358. return edges
  51359. }
  51360. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  51361. // name in this mutation.
  51362. func (m *XunjiMutation) AddedIDs(name string) []ent.Value {
  51363. return nil
  51364. }
  51365. // RemovedEdges returns all edge names that were removed in this mutation.
  51366. func (m *XunjiMutation) RemovedEdges() []string {
  51367. edges := make([]string, 0, 0)
  51368. return edges
  51369. }
  51370. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  51371. // the given name in this mutation.
  51372. func (m *XunjiMutation) RemovedIDs(name string) []ent.Value {
  51373. return nil
  51374. }
  51375. // ClearedEdges returns all edge names that were cleared in this mutation.
  51376. func (m *XunjiMutation) ClearedEdges() []string {
  51377. edges := make([]string, 0, 0)
  51378. return edges
  51379. }
  51380. // EdgeCleared returns a boolean which indicates if the edge with the given name
  51381. // was cleared in this mutation.
  51382. func (m *XunjiMutation) EdgeCleared(name string) bool {
  51383. return false
  51384. }
  51385. // ClearEdge clears the value of the edge with the given name. It returns an error
  51386. // if that edge is not defined in the schema.
  51387. func (m *XunjiMutation) ClearEdge(name string) error {
  51388. return fmt.Errorf("unknown Xunji unique edge %s", name)
  51389. }
  51390. // ResetEdge resets all changes to the edge with the given name in this mutation.
  51391. // It returns an error if the edge is not defined in the schema.
  51392. func (m *XunjiMutation) ResetEdge(name string) error {
  51393. return fmt.Errorf("unknown Xunji edge %s", name)
  51394. }
  51395. // XunjiServiceMutation represents an operation that mutates the XunjiService nodes in the graph.
  51396. type XunjiServiceMutation struct {
  51397. config
  51398. op Op
  51399. typ string
  51400. id *uint64
  51401. created_at *time.Time
  51402. updated_at *time.Time
  51403. status *uint8
  51404. addstatus *int8
  51405. deleted_at *time.Time
  51406. xunji_id *uint64
  51407. addxunji_id *int64
  51408. organization_id *uint64
  51409. addorganization_id *int64
  51410. wxid *string
  51411. api_base *string
  51412. api_key *string
  51413. clearedFields map[string]struct{}
  51414. agent *uint64
  51415. clearedagent bool
  51416. done bool
  51417. oldValue func(context.Context) (*XunjiService, error)
  51418. predicates []predicate.XunjiService
  51419. }
  51420. var _ ent.Mutation = (*XunjiServiceMutation)(nil)
  51421. // xunjiserviceOption allows management of the mutation configuration using functional options.
  51422. type xunjiserviceOption func(*XunjiServiceMutation)
  51423. // newXunjiServiceMutation creates new mutation for the XunjiService entity.
  51424. func newXunjiServiceMutation(c config, op Op, opts ...xunjiserviceOption) *XunjiServiceMutation {
  51425. m := &XunjiServiceMutation{
  51426. config: c,
  51427. op: op,
  51428. typ: TypeXunjiService,
  51429. clearedFields: make(map[string]struct{}),
  51430. }
  51431. for _, opt := range opts {
  51432. opt(m)
  51433. }
  51434. return m
  51435. }
  51436. // withXunjiServiceID sets the ID field of the mutation.
  51437. func withXunjiServiceID(id uint64) xunjiserviceOption {
  51438. return func(m *XunjiServiceMutation) {
  51439. var (
  51440. err error
  51441. once sync.Once
  51442. value *XunjiService
  51443. )
  51444. m.oldValue = func(ctx context.Context) (*XunjiService, error) {
  51445. once.Do(func() {
  51446. if m.done {
  51447. err = errors.New("querying old values post mutation is not allowed")
  51448. } else {
  51449. value, err = m.Client().XunjiService.Get(ctx, id)
  51450. }
  51451. })
  51452. return value, err
  51453. }
  51454. m.id = &id
  51455. }
  51456. }
  51457. // withXunjiService sets the old XunjiService of the mutation.
  51458. func withXunjiService(node *XunjiService) xunjiserviceOption {
  51459. return func(m *XunjiServiceMutation) {
  51460. m.oldValue = func(context.Context) (*XunjiService, error) {
  51461. return node, nil
  51462. }
  51463. m.id = &node.ID
  51464. }
  51465. }
  51466. // Client returns a new `ent.Client` from the mutation. If the mutation was
  51467. // executed in a transaction (ent.Tx), a transactional client is returned.
  51468. func (m XunjiServiceMutation) Client() *Client {
  51469. client := &Client{config: m.config}
  51470. client.init()
  51471. return client
  51472. }
  51473. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  51474. // it returns an error otherwise.
  51475. func (m XunjiServiceMutation) Tx() (*Tx, error) {
  51476. if _, ok := m.driver.(*txDriver); !ok {
  51477. return nil, errors.New("ent: mutation is not running in a transaction")
  51478. }
  51479. tx := &Tx{config: m.config}
  51480. tx.init()
  51481. return tx, nil
  51482. }
  51483. // SetID sets the value of the id field. Note that this
  51484. // operation is only accepted on creation of XunjiService entities.
  51485. func (m *XunjiServiceMutation) SetID(id uint64) {
  51486. m.id = &id
  51487. }
  51488. // ID returns the ID value in the mutation. Note that the ID is only available
  51489. // if it was provided to the builder or after it was returned from the database.
  51490. func (m *XunjiServiceMutation) ID() (id uint64, exists bool) {
  51491. if m.id == nil {
  51492. return
  51493. }
  51494. return *m.id, true
  51495. }
  51496. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  51497. // That means, if the mutation is applied within a transaction with an isolation level such
  51498. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  51499. // or updated by the mutation.
  51500. func (m *XunjiServiceMutation) IDs(ctx context.Context) ([]uint64, error) {
  51501. switch {
  51502. case m.op.Is(OpUpdateOne | OpDeleteOne):
  51503. id, exists := m.ID()
  51504. if exists {
  51505. return []uint64{id}, nil
  51506. }
  51507. fallthrough
  51508. case m.op.Is(OpUpdate | OpDelete):
  51509. return m.Client().XunjiService.Query().Where(m.predicates...).IDs(ctx)
  51510. default:
  51511. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  51512. }
  51513. }
  51514. // SetCreatedAt sets the "created_at" field.
  51515. func (m *XunjiServiceMutation) SetCreatedAt(t time.Time) {
  51516. m.created_at = &t
  51517. }
  51518. // CreatedAt returns the value of the "created_at" field in the mutation.
  51519. func (m *XunjiServiceMutation) CreatedAt() (r time.Time, exists bool) {
  51520. v := m.created_at
  51521. if v == nil {
  51522. return
  51523. }
  51524. return *v, true
  51525. }
  51526. // OldCreatedAt returns the old "created_at" field's value of the XunjiService entity.
  51527. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  51528. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51529. func (m *XunjiServiceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  51530. if !m.op.Is(OpUpdateOne) {
  51531. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  51532. }
  51533. if m.id == nil || m.oldValue == nil {
  51534. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  51535. }
  51536. oldValue, err := m.oldValue(ctx)
  51537. if err != nil {
  51538. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  51539. }
  51540. return oldValue.CreatedAt, nil
  51541. }
  51542. // ResetCreatedAt resets all changes to the "created_at" field.
  51543. func (m *XunjiServiceMutation) ResetCreatedAt() {
  51544. m.created_at = nil
  51545. }
  51546. // SetUpdatedAt sets the "updated_at" field.
  51547. func (m *XunjiServiceMutation) SetUpdatedAt(t time.Time) {
  51548. m.updated_at = &t
  51549. }
  51550. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  51551. func (m *XunjiServiceMutation) UpdatedAt() (r time.Time, exists bool) {
  51552. v := m.updated_at
  51553. if v == nil {
  51554. return
  51555. }
  51556. return *v, true
  51557. }
  51558. // OldUpdatedAt returns the old "updated_at" field's value of the XunjiService entity.
  51559. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  51560. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51561. func (m *XunjiServiceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  51562. if !m.op.Is(OpUpdateOne) {
  51563. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  51564. }
  51565. if m.id == nil || m.oldValue == nil {
  51566. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  51567. }
  51568. oldValue, err := m.oldValue(ctx)
  51569. if err != nil {
  51570. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  51571. }
  51572. return oldValue.UpdatedAt, nil
  51573. }
  51574. // ResetUpdatedAt resets all changes to the "updated_at" field.
  51575. func (m *XunjiServiceMutation) ResetUpdatedAt() {
  51576. m.updated_at = nil
  51577. }
  51578. // SetStatus sets the "status" field.
  51579. func (m *XunjiServiceMutation) SetStatus(u uint8) {
  51580. m.status = &u
  51581. m.addstatus = nil
  51582. }
  51583. // Status returns the value of the "status" field in the mutation.
  51584. func (m *XunjiServiceMutation) Status() (r uint8, exists bool) {
  51585. v := m.status
  51586. if v == nil {
  51587. return
  51588. }
  51589. return *v, true
  51590. }
  51591. // OldStatus returns the old "status" field's value of the XunjiService entity.
  51592. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  51593. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51594. func (m *XunjiServiceMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  51595. if !m.op.Is(OpUpdateOne) {
  51596. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  51597. }
  51598. if m.id == nil || m.oldValue == nil {
  51599. return v, errors.New("OldStatus requires an ID field in the mutation")
  51600. }
  51601. oldValue, err := m.oldValue(ctx)
  51602. if err != nil {
  51603. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  51604. }
  51605. return oldValue.Status, nil
  51606. }
  51607. // AddStatus adds u to the "status" field.
  51608. func (m *XunjiServiceMutation) AddStatus(u int8) {
  51609. if m.addstatus != nil {
  51610. *m.addstatus += u
  51611. } else {
  51612. m.addstatus = &u
  51613. }
  51614. }
  51615. // AddedStatus returns the value that was added to the "status" field in this mutation.
  51616. func (m *XunjiServiceMutation) AddedStatus() (r int8, exists bool) {
  51617. v := m.addstatus
  51618. if v == nil {
  51619. return
  51620. }
  51621. return *v, true
  51622. }
  51623. // ClearStatus clears the value of the "status" field.
  51624. func (m *XunjiServiceMutation) ClearStatus() {
  51625. m.status = nil
  51626. m.addstatus = nil
  51627. m.clearedFields[xunjiservice.FieldStatus] = struct{}{}
  51628. }
  51629. // StatusCleared returns if the "status" field was cleared in this mutation.
  51630. func (m *XunjiServiceMutation) StatusCleared() bool {
  51631. _, ok := m.clearedFields[xunjiservice.FieldStatus]
  51632. return ok
  51633. }
  51634. // ResetStatus resets all changes to the "status" field.
  51635. func (m *XunjiServiceMutation) ResetStatus() {
  51636. m.status = nil
  51637. m.addstatus = nil
  51638. delete(m.clearedFields, xunjiservice.FieldStatus)
  51639. }
  51640. // SetDeletedAt sets the "deleted_at" field.
  51641. func (m *XunjiServiceMutation) SetDeletedAt(t time.Time) {
  51642. m.deleted_at = &t
  51643. }
  51644. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  51645. func (m *XunjiServiceMutation) DeletedAt() (r time.Time, exists bool) {
  51646. v := m.deleted_at
  51647. if v == nil {
  51648. return
  51649. }
  51650. return *v, true
  51651. }
  51652. // OldDeletedAt returns the old "deleted_at" field's value of the XunjiService entity.
  51653. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  51654. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51655. func (m *XunjiServiceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  51656. if !m.op.Is(OpUpdateOne) {
  51657. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  51658. }
  51659. if m.id == nil || m.oldValue == nil {
  51660. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  51661. }
  51662. oldValue, err := m.oldValue(ctx)
  51663. if err != nil {
  51664. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  51665. }
  51666. return oldValue.DeletedAt, nil
  51667. }
  51668. // ClearDeletedAt clears the value of the "deleted_at" field.
  51669. func (m *XunjiServiceMutation) ClearDeletedAt() {
  51670. m.deleted_at = nil
  51671. m.clearedFields[xunjiservice.FieldDeletedAt] = struct{}{}
  51672. }
  51673. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  51674. func (m *XunjiServiceMutation) DeletedAtCleared() bool {
  51675. _, ok := m.clearedFields[xunjiservice.FieldDeletedAt]
  51676. return ok
  51677. }
  51678. // ResetDeletedAt resets all changes to the "deleted_at" field.
  51679. func (m *XunjiServiceMutation) ResetDeletedAt() {
  51680. m.deleted_at = nil
  51681. delete(m.clearedFields, xunjiservice.FieldDeletedAt)
  51682. }
  51683. // SetXunjiID sets the "xunji_id" field.
  51684. func (m *XunjiServiceMutation) SetXunjiID(u uint64) {
  51685. m.xunji_id = &u
  51686. m.addxunji_id = nil
  51687. }
  51688. // XunjiID returns the value of the "xunji_id" field in the mutation.
  51689. func (m *XunjiServiceMutation) XunjiID() (r uint64, exists bool) {
  51690. v := m.xunji_id
  51691. if v == nil {
  51692. return
  51693. }
  51694. return *v, true
  51695. }
  51696. // OldXunjiID returns the old "xunji_id" field's value of the XunjiService entity.
  51697. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  51698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51699. func (m *XunjiServiceMutation) OldXunjiID(ctx context.Context) (v uint64, err error) {
  51700. if !m.op.Is(OpUpdateOne) {
  51701. return v, errors.New("OldXunjiID is only allowed on UpdateOne operations")
  51702. }
  51703. if m.id == nil || m.oldValue == nil {
  51704. return v, errors.New("OldXunjiID requires an ID field in the mutation")
  51705. }
  51706. oldValue, err := m.oldValue(ctx)
  51707. if err != nil {
  51708. return v, fmt.Errorf("querying old value for OldXunjiID: %w", err)
  51709. }
  51710. return oldValue.XunjiID, nil
  51711. }
  51712. // AddXunjiID adds u to the "xunji_id" field.
  51713. func (m *XunjiServiceMutation) AddXunjiID(u int64) {
  51714. if m.addxunji_id != nil {
  51715. *m.addxunji_id += u
  51716. } else {
  51717. m.addxunji_id = &u
  51718. }
  51719. }
  51720. // AddedXunjiID returns the value that was added to the "xunji_id" field in this mutation.
  51721. func (m *XunjiServiceMutation) AddedXunjiID() (r int64, exists bool) {
  51722. v := m.addxunji_id
  51723. if v == nil {
  51724. return
  51725. }
  51726. return *v, true
  51727. }
  51728. // ResetXunjiID resets all changes to the "xunji_id" field.
  51729. func (m *XunjiServiceMutation) ResetXunjiID() {
  51730. m.xunji_id = nil
  51731. m.addxunji_id = nil
  51732. }
  51733. // SetAgentID sets the "agent_id" field.
  51734. func (m *XunjiServiceMutation) SetAgentID(u uint64) {
  51735. m.agent = &u
  51736. }
  51737. // AgentID returns the value of the "agent_id" field in the mutation.
  51738. func (m *XunjiServiceMutation) AgentID() (r uint64, exists bool) {
  51739. v := m.agent
  51740. if v == nil {
  51741. return
  51742. }
  51743. return *v, true
  51744. }
  51745. // OldAgentID returns the old "agent_id" field's value of the XunjiService entity.
  51746. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  51747. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51748. func (m *XunjiServiceMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  51749. if !m.op.Is(OpUpdateOne) {
  51750. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  51751. }
  51752. if m.id == nil || m.oldValue == nil {
  51753. return v, errors.New("OldAgentID requires an ID field in the mutation")
  51754. }
  51755. oldValue, err := m.oldValue(ctx)
  51756. if err != nil {
  51757. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  51758. }
  51759. return oldValue.AgentID, nil
  51760. }
  51761. // ResetAgentID resets all changes to the "agent_id" field.
  51762. func (m *XunjiServiceMutation) ResetAgentID() {
  51763. m.agent = nil
  51764. }
  51765. // SetOrganizationID sets the "organization_id" field.
  51766. func (m *XunjiServiceMutation) SetOrganizationID(u uint64) {
  51767. m.organization_id = &u
  51768. m.addorganization_id = nil
  51769. }
  51770. // OrganizationID returns the value of the "organization_id" field in the mutation.
  51771. func (m *XunjiServiceMutation) OrganizationID() (r uint64, exists bool) {
  51772. v := m.organization_id
  51773. if v == nil {
  51774. return
  51775. }
  51776. return *v, true
  51777. }
  51778. // OldOrganizationID returns the old "organization_id" field's value of the XunjiService entity.
  51779. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  51780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51781. func (m *XunjiServiceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  51782. if !m.op.Is(OpUpdateOne) {
  51783. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  51784. }
  51785. if m.id == nil || m.oldValue == nil {
  51786. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  51787. }
  51788. oldValue, err := m.oldValue(ctx)
  51789. if err != nil {
  51790. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  51791. }
  51792. return oldValue.OrganizationID, nil
  51793. }
  51794. // AddOrganizationID adds u to the "organization_id" field.
  51795. func (m *XunjiServiceMutation) AddOrganizationID(u int64) {
  51796. if m.addorganization_id != nil {
  51797. *m.addorganization_id += u
  51798. } else {
  51799. m.addorganization_id = &u
  51800. }
  51801. }
  51802. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  51803. func (m *XunjiServiceMutation) AddedOrganizationID() (r int64, exists bool) {
  51804. v := m.addorganization_id
  51805. if v == nil {
  51806. return
  51807. }
  51808. return *v, true
  51809. }
  51810. // ResetOrganizationID resets all changes to the "organization_id" field.
  51811. func (m *XunjiServiceMutation) ResetOrganizationID() {
  51812. m.organization_id = nil
  51813. m.addorganization_id = nil
  51814. }
  51815. // SetWxid sets the "wxid" field.
  51816. func (m *XunjiServiceMutation) SetWxid(s string) {
  51817. m.wxid = &s
  51818. }
  51819. // Wxid returns the value of the "wxid" field in the mutation.
  51820. func (m *XunjiServiceMutation) Wxid() (r string, exists bool) {
  51821. v := m.wxid
  51822. if v == nil {
  51823. return
  51824. }
  51825. return *v, true
  51826. }
  51827. // OldWxid returns the old "wxid" field's value of the XunjiService entity.
  51828. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  51829. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51830. func (m *XunjiServiceMutation) OldWxid(ctx context.Context) (v string, err error) {
  51831. if !m.op.Is(OpUpdateOne) {
  51832. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  51833. }
  51834. if m.id == nil || m.oldValue == nil {
  51835. return v, errors.New("OldWxid requires an ID field in the mutation")
  51836. }
  51837. oldValue, err := m.oldValue(ctx)
  51838. if err != nil {
  51839. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  51840. }
  51841. return oldValue.Wxid, nil
  51842. }
  51843. // ResetWxid resets all changes to the "wxid" field.
  51844. func (m *XunjiServiceMutation) ResetWxid() {
  51845. m.wxid = nil
  51846. }
  51847. // SetAPIBase sets the "api_base" field.
  51848. func (m *XunjiServiceMutation) SetAPIBase(s string) {
  51849. m.api_base = &s
  51850. }
  51851. // APIBase returns the value of the "api_base" field in the mutation.
  51852. func (m *XunjiServiceMutation) APIBase() (r string, exists bool) {
  51853. v := m.api_base
  51854. if v == nil {
  51855. return
  51856. }
  51857. return *v, true
  51858. }
  51859. // OldAPIBase returns the old "api_base" field's value of the XunjiService entity.
  51860. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  51861. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51862. func (m *XunjiServiceMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  51863. if !m.op.Is(OpUpdateOne) {
  51864. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  51865. }
  51866. if m.id == nil || m.oldValue == nil {
  51867. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  51868. }
  51869. oldValue, err := m.oldValue(ctx)
  51870. if err != nil {
  51871. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  51872. }
  51873. return oldValue.APIBase, nil
  51874. }
  51875. // ClearAPIBase clears the value of the "api_base" field.
  51876. func (m *XunjiServiceMutation) ClearAPIBase() {
  51877. m.api_base = nil
  51878. m.clearedFields[xunjiservice.FieldAPIBase] = struct{}{}
  51879. }
  51880. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  51881. func (m *XunjiServiceMutation) APIBaseCleared() bool {
  51882. _, ok := m.clearedFields[xunjiservice.FieldAPIBase]
  51883. return ok
  51884. }
  51885. // ResetAPIBase resets all changes to the "api_base" field.
  51886. func (m *XunjiServiceMutation) ResetAPIBase() {
  51887. m.api_base = nil
  51888. delete(m.clearedFields, xunjiservice.FieldAPIBase)
  51889. }
  51890. // SetAPIKey sets the "api_key" field.
  51891. func (m *XunjiServiceMutation) SetAPIKey(s string) {
  51892. m.api_key = &s
  51893. }
  51894. // APIKey returns the value of the "api_key" field in the mutation.
  51895. func (m *XunjiServiceMutation) APIKey() (r string, exists bool) {
  51896. v := m.api_key
  51897. if v == nil {
  51898. return
  51899. }
  51900. return *v, true
  51901. }
  51902. // OldAPIKey returns the old "api_key" field's value of the XunjiService entity.
  51903. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  51904. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51905. func (m *XunjiServiceMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  51906. if !m.op.Is(OpUpdateOne) {
  51907. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  51908. }
  51909. if m.id == nil || m.oldValue == nil {
  51910. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  51911. }
  51912. oldValue, err := m.oldValue(ctx)
  51913. if err != nil {
  51914. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  51915. }
  51916. return oldValue.APIKey, nil
  51917. }
  51918. // ClearAPIKey clears the value of the "api_key" field.
  51919. func (m *XunjiServiceMutation) ClearAPIKey() {
  51920. m.api_key = nil
  51921. m.clearedFields[xunjiservice.FieldAPIKey] = struct{}{}
  51922. }
  51923. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  51924. func (m *XunjiServiceMutation) APIKeyCleared() bool {
  51925. _, ok := m.clearedFields[xunjiservice.FieldAPIKey]
  51926. return ok
  51927. }
  51928. // ResetAPIKey resets all changes to the "api_key" field.
  51929. func (m *XunjiServiceMutation) ResetAPIKey() {
  51930. m.api_key = nil
  51931. delete(m.clearedFields, xunjiservice.FieldAPIKey)
  51932. }
  51933. // ClearAgent clears the "agent" edge to the Agent entity.
  51934. func (m *XunjiServiceMutation) ClearAgent() {
  51935. m.clearedagent = true
  51936. m.clearedFields[xunjiservice.FieldAgentID] = struct{}{}
  51937. }
  51938. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  51939. func (m *XunjiServiceMutation) AgentCleared() bool {
  51940. return m.clearedagent
  51941. }
  51942. // AgentIDs returns the "agent" edge IDs in the mutation.
  51943. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  51944. // AgentID instead. It exists only for internal usage by the builders.
  51945. func (m *XunjiServiceMutation) AgentIDs() (ids []uint64) {
  51946. if id := m.agent; id != nil {
  51947. ids = append(ids, *id)
  51948. }
  51949. return
  51950. }
  51951. // ResetAgent resets all changes to the "agent" edge.
  51952. func (m *XunjiServiceMutation) ResetAgent() {
  51953. m.agent = nil
  51954. m.clearedagent = false
  51955. }
  51956. // Where appends a list predicates to the XunjiServiceMutation builder.
  51957. func (m *XunjiServiceMutation) Where(ps ...predicate.XunjiService) {
  51958. m.predicates = append(m.predicates, ps...)
  51959. }
  51960. // WhereP appends storage-level predicates to the XunjiServiceMutation builder. Using this method,
  51961. // users can use type-assertion to append predicates that do not depend on any generated package.
  51962. func (m *XunjiServiceMutation) WhereP(ps ...func(*sql.Selector)) {
  51963. p := make([]predicate.XunjiService, len(ps))
  51964. for i := range ps {
  51965. p[i] = ps[i]
  51966. }
  51967. m.Where(p...)
  51968. }
  51969. // Op returns the operation name.
  51970. func (m *XunjiServiceMutation) Op() Op {
  51971. return m.op
  51972. }
  51973. // SetOp allows setting the mutation operation.
  51974. func (m *XunjiServiceMutation) SetOp(op Op) {
  51975. m.op = op
  51976. }
  51977. // Type returns the node type of this mutation (XunjiService).
  51978. func (m *XunjiServiceMutation) Type() string {
  51979. return m.typ
  51980. }
  51981. // Fields returns all fields that were changed during this mutation. Note that in
  51982. // order to get all numeric fields that were incremented/decremented, call
  51983. // AddedFields().
  51984. func (m *XunjiServiceMutation) Fields() []string {
  51985. fields := make([]string, 0, 10)
  51986. if m.created_at != nil {
  51987. fields = append(fields, xunjiservice.FieldCreatedAt)
  51988. }
  51989. if m.updated_at != nil {
  51990. fields = append(fields, xunjiservice.FieldUpdatedAt)
  51991. }
  51992. if m.status != nil {
  51993. fields = append(fields, xunjiservice.FieldStatus)
  51994. }
  51995. if m.deleted_at != nil {
  51996. fields = append(fields, xunjiservice.FieldDeletedAt)
  51997. }
  51998. if m.xunji_id != nil {
  51999. fields = append(fields, xunjiservice.FieldXunjiID)
  52000. }
  52001. if m.agent != nil {
  52002. fields = append(fields, xunjiservice.FieldAgentID)
  52003. }
  52004. if m.organization_id != nil {
  52005. fields = append(fields, xunjiservice.FieldOrganizationID)
  52006. }
  52007. if m.wxid != nil {
  52008. fields = append(fields, xunjiservice.FieldWxid)
  52009. }
  52010. if m.api_base != nil {
  52011. fields = append(fields, xunjiservice.FieldAPIBase)
  52012. }
  52013. if m.api_key != nil {
  52014. fields = append(fields, xunjiservice.FieldAPIKey)
  52015. }
  52016. return fields
  52017. }
  52018. // Field returns the value of a field with the given name. The second boolean
  52019. // return value indicates that this field was not set, or was not defined in the
  52020. // schema.
  52021. func (m *XunjiServiceMutation) Field(name string) (ent.Value, bool) {
  52022. switch name {
  52023. case xunjiservice.FieldCreatedAt:
  52024. return m.CreatedAt()
  52025. case xunjiservice.FieldUpdatedAt:
  52026. return m.UpdatedAt()
  52027. case xunjiservice.FieldStatus:
  52028. return m.Status()
  52029. case xunjiservice.FieldDeletedAt:
  52030. return m.DeletedAt()
  52031. case xunjiservice.FieldXunjiID:
  52032. return m.XunjiID()
  52033. case xunjiservice.FieldAgentID:
  52034. return m.AgentID()
  52035. case xunjiservice.FieldOrganizationID:
  52036. return m.OrganizationID()
  52037. case xunjiservice.FieldWxid:
  52038. return m.Wxid()
  52039. case xunjiservice.FieldAPIBase:
  52040. return m.APIBase()
  52041. case xunjiservice.FieldAPIKey:
  52042. return m.APIKey()
  52043. }
  52044. return nil, false
  52045. }
  52046. // OldField returns the old value of the field from the database. An error is
  52047. // returned if the mutation operation is not UpdateOne, or the query to the
  52048. // database failed.
  52049. func (m *XunjiServiceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  52050. switch name {
  52051. case xunjiservice.FieldCreatedAt:
  52052. return m.OldCreatedAt(ctx)
  52053. case xunjiservice.FieldUpdatedAt:
  52054. return m.OldUpdatedAt(ctx)
  52055. case xunjiservice.FieldStatus:
  52056. return m.OldStatus(ctx)
  52057. case xunjiservice.FieldDeletedAt:
  52058. return m.OldDeletedAt(ctx)
  52059. case xunjiservice.FieldXunjiID:
  52060. return m.OldXunjiID(ctx)
  52061. case xunjiservice.FieldAgentID:
  52062. return m.OldAgentID(ctx)
  52063. case xunjiservice.FieldOrganizationID:
  52064. return m.OldOrganizationID(ctx)
  52065. case xunjiservice.FieldWxid:
  52066. return m.OldWxid(ctx)
  52067. case xunjiservice.FieldAPIBase:
  52068. return m.OldAPIBase(ctx)
  52069. case xunjiservice.FieldAPIKey:
  52070. return m.OldAPIKey(ctx)
  52071. }
  52072. return nil, fmt.Errorf("unknown XunjiService field %s", name)
  52073. }
  52074. // SetField sets the value of a field with the given name. It returns an error if
  52075. // the field is not defined in the schema, or if the type mismatched the field
  52076. // type.
  52077. func (m *XunjiServiceMutation) SetField(name string, value ent.Value) error {
  52078. switch name {
  52079. case xunjiservice.FieldCreatedAt:
  52080. v, ok := value.(time.Time)
  52081. if !ok {
  52082. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52083. }
  52084. m.SetCreatedAt(v)
  52085. return nil
  52086. case xunjiservice.FieldUpdatedAt:
  52087. v, ok := value.(time.Time)
  52088. if !ok {
  52089. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52090. }
  52091. m.SetUpdatedAt(v)
  52092. return nil
  52093. case xunjiservice.FieldStatus:
  52094. v, ok := value.(uint8)
  52095. if !ok {
  52096. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52097. }
  52098. m.SetStatus(v)
  52099. return nil
  52100. case xunjiservice.FieldDeletedAt:
  52101. v, ok := value.(time.Time)
  52102. if !ok {
  52103. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52104. }
  52105. m.SetDeletedAt(v)
  52106. return nil
  52107. case xunjiservice.FieldXunjiID:
  52108. v, ok := value.(uint64)
  52109. if !ok {
  52110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52111. }
  52112. m.SetXunjiID(v)
  52113. return nil
  52114. case xunjiservice.FieldAgentID:
  52115. v, ok := value.(uint64)
  52116. if !ok {
  52117. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52118. }
  52119. m.SetAgentID(v)
  52120. return nil
  52121. case xunjiservice.FieldOrganizationID:
  52122. v, ok := value.(uint64)
  52123. if !ok {
  52124. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52125. }
  52126. m.SetOrganizationID(v)
  52127. return nil
  52128. case xunjiservice.FieldWxid:
  52129. v, ok := value.(string)
  52130. if !ok {
  52131. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52132. }
  52133. m.SetWxid(v)
  52134. return nil
  52135. case xunjiservice.FieldAPIBase:
  52136. v, ok := value.(string)
  52137. if !ok {
  52138. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52139. }
  52140. m.SetAPIBase(v)
  52141. return nil
  52142. case xunjiservice.FieldAPIKey:
  52143. v, ok := value.(string)
  52144. if !ok {
  52145. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52146. }
  52147. m.SetAPIKey(v)
  52148. return nil
  52149. }
  52150. return fmt.Errorf("unknown XunjiService field %s", name)
  52151. }
  52152. // AddedFields returns all numeric fields that were incremented/decremented during
  52153. // this mutation.
  52154. func (m *XunjiServiceMutation) AddedFields() []string {
  52155. var fields []string
  52156. if m.addstatus != nil {
  52157. fields = append(fields, xunjiservice.FieldStatus)
  52158. }
  52159. if m.addxunji_id != nil {
  52160. fields = append(fields, xunjiservice.FieldXunjiID)
  52161. }
  52162. if m.addorganization_id != nil {
  52163. fields = append(fields, xunjiservice.FieldOrganizationID)
  52164. }
  52165. return fields
  52166. }
  52167. // AddedField returns the numeric value that was incremented/decremented on a field
  52168. // with the given name. The second boolean return value indicates that this field
  52169. // was not set, or was not defined in the schema.
  52170. func (m *XunjiServiceMutation) AddedField(name string) (ent.Value, bool) {
  52171. switch name {
  52172. case xunjiservice.FieldStatus:
  52173. return m.AddedStatus()
  52174. case xunjiservice.FieldXunjiID:
  52175. return m.AddedXunjiID()
  52176. case xunjiservice.FieldOrganizationID:
  52177. return m.AddedOrganizationID()
  52178. }
  52179. return nil, false
  52180. }
  52181. // AddField adds the value to the field with the given name. It returns an error if
  52182. // the field is not defined in the schema, or if the type mismatched the field
  52183. // type.
  52184. func (m *XunjiServiceMutation) AddField(name string, value ent.Value) error {
  52185. switch name {
  52186. case xunjiservice.FieldStatus:
  52187. v, ok := value.(int8)
  52188. if !ok {
  52189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52190. }
  52191. m.AddStatus(v)
  52192. return nil
  52193. case xunjiservice.FieldXunjiID:
  52194. v, ok := value.(int64)
  52195. if !ok {
  52196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52197. }
  52198. m.AddXunjiID(v)
  52199. return nil
  52200. case xunjiservice.FieldOrganizationID:
  52201. v, ok := value.(int64)
  52202. if !ok {
  52203. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52204. }
  52205. m.AddOrganizationID(v)
  52206. return nil
  52207. }
  52208. return fmt.Errorf("unknown XunjiService numeric field %s", name)
  52209. }
  52210. // ClearedFields returns all nullable fields that were cleared during this
  52211. // mutation.
  52212. func (m *XunjiServiceMutation) ClearedFields() []string {
  52213. var fields []string
  52214. if m.FieldCleared(xunjiservice.FieldStatus) {
  52215. fields = append(fields, xunjiservice.FieldStatus)
  52216. }
  52217. if m.FieldCleared(xunjiservice.FieldDeletedAt) {
  52218. fields = append(fields, xunjiservice.FieldDeletedAt)
  52219. }
  52220. if m.FieldCleared(xunjiservice.FieldAPIBase) {
  52221. fields = append(fields, xunjiservice.FieldAPIBase)
  52222. }
  52223. if m.FieldCleared(xunjiservice.FieldAPIKey) {
  52224. fields = append(fields, xunjiservice.FieldAPIKey)
  52225. }
  52226. return fields
  52227. }
  52228. // FieldCleared returns a boolean indicating if a field with the given name was
  52229. // cleared in this mutation.
  52230. func (m *XunjiServiceMutation) FieldCleared(name string) bool {
  52231. _, ok := m.clearedFields[name]
  52232. return ok
  52233. }
  52234. // ClearField clears the value of the field with the given name. It returns an
  52235. // error if the field is not defined in the schema.
  52236. func (m *XunjiServiceMutation) ClearField(name string) error {
  52237. switch name {
  52238. case xunjiservice.FieldStatus:
  52239. m.ClearStatus()
  52240. return nil
  52241. case xunjiservice.FieldDeletedAt:
  52242. m.ClearDeletedAt()
  52243. return nil
  52244. case xunjiservice.FieldAPIBase:
  52245. m.ClearAPIBase()
  52246. return nil
  52247. case xunjiservice.FieldAPIKey:
  52248. m.ClearAPIKey()
  52249. return nil
  52250. }
  52251. return fmt.Errorf("unknown XunjiService nullable field %s", name)
  52252. }
  52253. // ResetField resets all changes in the mutation for the field with the given name.
  52254. // It returns an error if the field is not defined in the schema.
  52255. func (m *XunjiServiceMutation) ResetField(name string) error {
  52256. switch name {
  52257. case xunjiservice.FieldCreatedAt:
  52258. m.ResetCreatedAt()
  52259. return nil
  52260. case xunjiservice.FieldUpdatedAt:
  52261. m.ResetUpdatedAt()
  52262. return nil
  52263. case xunjiservice.FieldStatus:
  52264. m.ResetStatus()
  52265. return nil
  52266. case xunjiservice.FieldDeletedAt:
  52267. m.ResetDeletedAt()
  52268. return nil
  52269. case xunjiservice.FieldXunjiID:
  52270. m.ResetXunjiID()
  52271. return nil
  52272. case xunjiservice.FieldAgentID:
  52273. m.ResetAgentID()
  52274. return nil
  52275. case xunjiservice.FieldOrganizationID:
  52276. m.ResetOrganizationID()
  52277. return nil
  52278. case xunjiservice.FieldWxid:
  52279. m.ResetWxid()
  52280. return nil
  52281. case xunjiservice.FieldAPIBase:
  52282. m.ResetAPIBase()
  52283. return nil
  52284. case xunjiservice.FieldAPIKey:
  52285. m.ResetAPIKey()
  52286. return nil
  52287. }
  52288. return fmt.Errorf("unknown XunjiService field %s", name)
  52289. }
  52290. // AddedEdges returns all edge names that were set/added in this mutation.
  52291. func (m *XunjiServiceMutation) AddedEdges() []string {
  52292. edges := make([]string, 0, 1)
  52293. if m.agent != nil {
  52294. edges = append(edges, xunjiservice.EdgeAgent)
  52295. }
  52296. return edges
  52297. }
  52298. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  52299. // name in this mutation.
  52300. func (m *XunjiServiceMutation) AddedIDs(name string) []ent.Value {
  52301. switch name {
  52302. case xunjiservice.EdgeAgent:
  52303. if id := m.agent; id != nil {
  52304. return []ent.Value{*id}
  52305. }
  52306. }
  52307. return nil
  52308. }
  52309. // RemovedEdges returns all edge names that were removed in this mutation.
  52310. func (m *XunjiServiceMutation) RemovedEdges() []string {
  52311. edges := make([]string, 0, 1)
  52312. return edges
  52313. }
  52314. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  52315. // the given name in this mutation.
  52316. func (m *XunjiServiceMutation) RemovedIDs(name string) []ent.Value {
  52317. return nil
  52318. }
  52319. // ClearedEdges returns all edge names that were cleared in this mutation.
  52320. func (m *XunjiServiceMutation) ClearedEdges() []string {
  52321. edges := make([]string, 0, 1)
  52322. if m.clearedagent {
  52323. edges = append(edges, xunjiservice.EdgeAgent)
  52324. }
  52325. return edges
  52326. }
  52327. // EdgeCleared returns a boolean which indicates if the edge with the given name
  52328. // was cleared in this mutation.
  52329. func (m *XunjiServiceMutation) EdgeCleared(name string) bool {
  52330. switch name {
  52331. case xunjiservice.EdgeAgent:
  52332. return m.clearedagent
  52333. }
  52334. return false
  52335. }
  52336. // ClearEdge clears the value of the edge with the given name. It returns an error
  52337. // if that edge is not defined in the schema.
  52338. func (m *XunjiServiceMutation) ClearEdge(name string) error {
  52339. switch name {
  52340. case xunjiservice.EdgeAgent:
  52341. m.ClearAgent()
  52342. return nil
  52343. }
  52344. return fmt.Errorf("unknown XunjiService unique edge %s", name)
  52345. }
  52346. // ResetEdge resets all changes to the edge with the given name in this mutation.
  52347. // It returns an error if the edge is not defined in the schema.
  52348. func (m *XunjiServiceMutation) ResetEdge(name string) error {
  52349. switch name {
  52350. case xunjiservice.EdgeAgent:
  52351. m.ResetAgent()
  52352. return nil
  52353. }
  52354. return fmt.Errorf("unknown XunjiService edge %s", name)
  52355. }